package Gantry::Utils::HTML;
require Exporter;
use strict;
use Carp qw( croak );
use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS );
############################################################
# Variables #
############################################################
@ISA = qw( Exporter );
@EXPORT = qw();
@EXPORT_OK = qw( ht_a
ht_b ht_br
ht_checkbox
ht_div ht_udiv
ht_form ht_form_js
ht_h
ht_help
ht_i ht_img ht_input
ht_lines
ht_p ht_popup
ht_qt
ht_radio
ht_select ht_submit
ht_table ht_tr ht_td ht_utd
ht_uform ht_up ht_uqt ht_utable ht_utr );
%EXPORT_TAGS =( 'common' => [qw/ ht_a ht_br ht_img ht_lines ht_qt ht_uqt/ ],
'style' => [qw/ ht_div ht_udiv ht_b ht_h ht_i ht_p ht_up/],
'form' => [qw/ ht_checkbox ht_form ht_form_js
ht_input ht_radio ht_select
ht_submit ht_uform / ],
'table' => [qw/ ht_table ht_tr ht_td ht_utd ht_utr
ht_utable / ],
'jscript' => [qw/ ht_help ht_popup / ],
'all' => [qw/ ht_a
ht_div ht_udiv
ht_b ht_br
ht_checkbox
ht_form ht_form_js
ht_h
ht_help
ht_i ht_img ht_input
ht_lines
ht_p ht_popup
ht_qt
ht_radio
ht_select ht_submit
ht_table ht_tr ht_td ht_utd
ht_uform ht_up ht_uqt ht_utable ht_utr / ]);
############################################################
# Functions #
############################################################
#-------------------------------------------------
# ht_a( $url, $text, @extras )
#-------------------------------------------------
sub ht_a {
my ( $url, $text, @extras ) = @_;
return( join( ' ', qq!$text! ) );
} # END ht_a
#-------------------------------------------------
# ht_b( @inside )
#-------------------------------------------------
sub ht_b {
return( join( '', '', @_, '' ) );
} # END ht_b
#-------------------------------------------------
# ht_br()
#-------------------------------------------------
sub ht_br {
return( '
' );
} # END ht_br
#-------------------------------------------------
# ht_div( $options, @data )
#-------------------------------------------------
sub ht_div {
my ( $options, @data ) = @_;
my @params = ( '
' ); } # END ht_p #------------------------------------------------- # ht_up() #------------------------------------------------- sub ht_up { return( '
' ); } # END ht_up #------------------------------------------------- # ht_i( @inside ) #------------------------------------------------- sub ht_i { return( join( '', '', @_, '' ) ); } # END ht_i #------------------------------------------------- # ht_h( $level, @text ) #------------------------------------------------- sub ht_h { my ( $level, @text ) = @_; $level = 3 if ( ( ! defined $level ) || ( $level eq '' ) ); return( join( '', "| ' ), @data, ' | ' ); } return( join( ' ', '' ) ); } # END ht_td #------------------------------------------------- # ht_utd() #------------------------------------------------- sub ht_utd () { return( ' | ' ); } # END ht_utr #------------------------------------------------- # ht_utr() #------------------------------------------------- sub ht_utr () { return( '
> tag.
=item @popup = ht_popup( $url, $text, $winname, $height, $width )
This function creates a special html "ref" call. It creates a link to a new
javascript window with the properties specified. The "C<$url>" is the URL
of the new window, "C<$text>" is the text to be displayed by the link.
"C<$winname>" is the name of the window that will be created. "C<$height>" and
"C<$width>" are the height and the width of the window, respectively.
=item $string = ht_qt( $string )
This function will escape the html special characters in "C<$string>" and
return the specially formated value of the string.
=item $radio = ht_radio( $name, $value, $form_value, @params )
This function generates individual radio buttons. "C<$name>" is the name
of the radio buttion group. "C<$value>" is the value to set for this
radio button. "C<$form_value> is the currently selected value, for a
radio button to be checked the $value must be exactly equal to
$form_value. An %in hash with a key of $name may also be used for
$form_value. C<@params> is passed directly to the end of the radio
button, this can be used for javascript or arbitrary html.
=item @select = ht_select( $name, $size, $value, $multiple, $opts, @items )
This function creates a html select box. "C<$name>" is the name of select
box for use in parsing the form. "C<$size>" is the number of rows to show
for the select box. "C<$value>" is the a hash reference which contains the
value that is currently selected with a hash key of the value of "C<$name>".
"C<$multiple>" needs only to be defined to create the select box as a multiple
select rather than a single select box. "C<@items>" is an array/hash of the
values of the select box. C<$opts> will be included directly into the
opening of the select, this allows tweaky javascript things.
=item $submit = ht_submit( $name, $value )
This function creates a submit button with the name of "C<$name>" and the
value of "C<$value>".
=item $table = ht_table( $options )
This function creates an open table tag. It takes a hash reference,
C<$options>. The hash reference should contain key value pairs corresponding
to the table options ie: 'cellpadding', '0', 'border', '1' or the like.
=item $tr = ht_tr( $options )
This function creates an open table row tag, it operates exactly as the
C and the ht_utd function should be
used as well.
=item $uform = ht_uform()
This function should be paried with either C