############################################################################## # A U T O G E N E R A T E E N H A N C E M E N T S # # # # Last Modified: 11 Aug 1999 # ############################################################################## # # # -- Allows selection of "admin-only" checkboxes, radio fields, select # # fields and textareas # # -- Creates "clickable" links for email addresses and URLs # # -- Allows you to set whether you would like skip rows where the field # # value is blank. # # -- Maintains line formatting in textarea fields # # # ############################################################################## ############################################################################### ######## file: default.cfg ######## ######## add ######## ######## ######## ######## ######## ######## What it does -- ######## ######## Changes the setting for autogenerated textarea fields ######## ######## ######## ######## Where to put it -- ######## ######## Just after ######## ######## # Checkbox fields. Field name => Checkbox value. ######## ######## %db_checkbox_fields = ( Popular => 'Yes' ); ######## ############################################################################### # Textarea fields. Field name => '[columns]x[rows]'. %db_textarea_fields = ( Description => '40x3' ); ############################################################################### ######## file: default.cfg ######## ######## add ######## ######## ######## ######## ######## ######## What it does -- ######## ######## Allows you to set whether blank fields will be skipped when ######## ######## using the autogenerate feature to build record displays ######## ######## ######## ######## Where to put it -- ######## ######## Just after ######## ######## # Auto generate the html forms (1 = Yes, 0 = No). ######## ######## $db_auto_generate = 0; ######## ############################################################################### # Skip blank fields in autogenerated record display (1 = Yes, 0 = No). $db_skip_blank = 1; ############################################################################### ######## file: default.cfg ######## ######## change ######## ######## ######## ######## ######## ######## What it does -- ######## ######## Changes the setting for autogenerated textarea fields ######## ######## ######## ######## Original line -- ######## ######## Description => [6, 'alpha', '40x3', 500, 0, '', ''], ######## ############################################################################### Description => [6, 'alpha', 0, 500, 0, '', ''], ################################################################################ ######## script: db.cgi ######## ######## replace ######## ######## sub build_html_record ######## ######## ######## ######## What it does -- ######## ######## creates clickable links if the contents of the field is either ######## ######## a URL or an email address. ######## ######## Skips blank fields in record ######## ######## keeps formatting in textarea fields ######## ######## removes bold tags from clickable links to make them clickable ######## ################################################################################ sub build_html_record { # -------------------------------------------------------- # Builds a record based on the config information. # my (%rec) = @_; my ($output, $field, $url); $output = "

"; foreach $field (@db_cols) { next if ($db_form_len{$field} == -1); next if (($db_form_len{$field} == -2) && (!$per_admin)); next if (($db_skip_blank) && (!$rec{$field})); # Skips blank fields $rec{$field} =~ s/\n/
/g; # Keeps formatting in textarea fields $output .= qq~~; if ($rec{$field} =~ /^http:/) { # Creates clickable URLs $url = $rec{$field}; $url =~ s/<\/?B>//g; $output .= qq~~; } elsif ($rec{$field} =~ /.+\@.+\..+/) { # Creates clickable email addresses $url = $rec{$field}; $url =~ s/<\/?B>//g; $output .= qq~~; } else { $output .= qq~~; } } $output .= "
<$font>$field:<$font>$rec{$field}
<$font>$rec{$field}
<$font>$rec{$field}

\n"; return $output; } ################################################################################ ######## script: db.cgi ######## ######## replace ######## ######## sub build_html_record_form ######## ######## ######## ######## What it does -- ######## ######## allows select lists, radio fields, checkboxes and textareas to ######## ######## be designated as "admin-only." ######## ######## Also requires the change in default.cfg (above) to allow you ######## ######## to set the size of textarea fields ######## ################################################################################ sub build_html_record_form { # -------------------------------------------------------- # Builds a record form based on the config information. # my (%rec) = @_; my ($output, $field); $output = "

"; foreach $field (@db_cols) { if (($db_form_len{$field} == -2) && (!$per_admin)) { $output = qq~$output~; } elsif ($db_form_len{$field} == -1) { $output = qq~$output~; } elsif ($db_select_fields{$field}) { $output .= ""; } elsif ($db_radio_fields{$field}) { $output .= ""; } elsif ($db_checkbox_fields{$field}) { $output .= ""; } elsif ($db_textarea_fields{$field}) { $output .= ""; } else { $output .= qq~~; } } $output .= "
<$font>$field:" . &build_select_field($field, $rec{$field}) . "
<$font>$field:" . &build_radio_field($field, $rec{$field}) . "
<$font>$field:" . &build_checkbox_field($field, $rec{$field}) . "
<$font>$field:" . &build_textarea_field($field, $rec{$field}) . "
<$font>$field:

\n"; return $output; } ################################################################################ ######## script: db.cgi ######## ######## new subroutine ######## ######## sub build_textarea_field ######## ######## ######## ######## What it does -- ######## ######## allows you to use the format ######## ######## print &build_textarea_field("FieldName","$rec{'FieldName'}"); ######## ######## to create textarea fields in your forms. ######## ######## ######## ######## It is also used by the new build_html_record subroutine. ######## ################################################################################ sub build_textarea_field { # -------------------------------------------------------- # Builds a TEXTAREA field based on information found # in the database definition. Parameters are the column to build # and a default value (optional). my ($column, $value) = @_; my ($output); unless ($db_textarea_fields{$column} =~ /(\d+)x(\d+)/) { $output = "error building textarea field: textarea field definition incorrect in config for field '$column'!"; } else { $output = qq||; } return $output; }