, to make sure we only look for a text file for links, not categories. Note, this is NOT corrected on the previous attachments.
Code:
sub build_html_record_form {
# --------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_;
# >>> External Text File mod (next 2
6 lines)
if ($in{'db'} eq 'links') { # Make sure we're editing links, and not categories.
# If validating input from modify.cgi, get the temporary text file from the /text/modified directory.
if ($in{'validate_form'}) {
my $text_file = "$external_modified_text_dir/$rec{$db_key}.txt";
if (-e $text_file) { # Check if there's a file in the /text/modified directory...
open (TEXT, "<$external_modified_text_dir/$rec{$db_key}.txt") or &cgierr("Error in db_utils.pl, sub build_html_record_form (A). Unable to open text file $external_modified_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;
$rec{'text'} = join "",@text;
}
# If validating input from add.cgi, get the new text file from the /text/validate directory.
else { # ...if not, it must be in the /text/validate directory.
open (TEXT, "<$external_validate_text_dir/$rec{$db_key}.txt") or &cgierr("Error in db_utils.pl, sub build_html_record_form (B). Unable to open text file $external_modified_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;
$rec{'text'} = join "",@text;
}
}
# If modifying from the admin, get the current text file.
if ($in{'modify_form'}) {
open (TEXT, "<$external_text_dir/$rec{$db_key}.txt") or &cgierr("Error in db_utils.pl, sub build_html_record_form (C). Unable to open text file $external_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;
$rec{'text'} = join "",@text;
}
} # <<<
$output = "<p><table border=1>";
# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
}
foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=3") . "</td></tr>\n"; }
elsif ($db_select_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~; }
elsif ($db_form_len{$field} == -1) { $output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
}
# >>> External Text File mod (next
7 lines)
# Put the textarea in the admin forms.
# Fix the textarea display.
if ($in{'db'} eq 'links') { # Make sure we're editing links, and not categories.
$rec{'text'} =~ s,</textarea>,</text-area>,ig;
$output .= qq~<tr><td align=right valign=top width=20%><$font>Text:</font></td><td width=80%><textarea name="text" rows="10" cols="40" wrap="virtual" value="">$rec{'text'}</textarea></td></tr>\n~;
}
# <<<
$output .= "</table></p>\n";
return $output;
}