Gossamer Forum
Home : Products : Links 2.0 : Discussions :

editing db_utils.pl

Quote Reply
editing db_utils.pl
Hi - I have two questions.

1) I am using links 2.0 to manage photos on a website. how can I modify the admin console to actually display the image as well as the actual text URL for the record? I need to change the catagories that several pictures are in, so it would be easy to move from record to record via ID # and view the picture and change the catagory via the admin console. As it stands, I only see the text url for the image. I would like so essentially add an <img src="$db_image"> tag to that table. I think this table is built in db_utils.pl in the sub build_html_record_form sub routine (I have included at the bottom of this message).

2) Since I use this for pictures, I routinely add 36 pics at a time. I have to think there is an easier way to add them than to create 36 new records. Is there any way to automate this process - given the above fix, I could then go into the admin console and bring up the first new record via ID number and see the pic - and then add the accompanying details like title, description, etc. Essentially, I would envision some sort of cron or automated process to search the images directory and create new db entries for each newly added files - when compared to the old links.db. Essentially something like - IF <filename> is found in links.db STOP, ELSE CREATE NEW LINK - with the only filename and link ID being filled in - the rest to be filled in via the admin console.

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) = @_;

$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~; }
}
$output .= "</table></p>\n";
return $output;
}