Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Validating graphics

Quote Reply
Validating graphics
Can someone please tell me how to make the graphic that was submitted to the list come up along with the information

I took this out of admin_html.pl

-------------------------------------------
# Go through each hit and convert the array to hash and send to
# html_record for printing. Also add a radio button with name=modify
# and value=key.
if ($status ne "ok") { # Error searching database!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT>|;
}
else {
print "<P>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TABLE BORDER=0><TR><TD><INPUT checked TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="modify"></TD><TD>|;
&html_record_form_mult (%tmp);
print qq|</TD><td>GRAPHIC_HERE\n|;
print qq|</TD></TR></TABLE><p><hr><p>\n|;
}
if ($db_next_hits) {
print "
<$font>Pages: $db_next_hits</font>";
}
}

---------------------------------------------

Where "GRAPHIC HERE" is in the code I would like the graphic that was added to the database to come up. This will help me validate and move already validated graphics around to new directories if nessesary.

Please let me know.

Thanks.

Quote Reply
Re: Validating graphics In reply to
Are you using the FILE UPLOAD MOD???

Regards,

Eliot Lee
Quote Reply
Re: Validating graphics In reply to
I will in the future but not right now.

This are all in house graphics that I already have.

They are in the database. I'm just trying to make my life easier.

If this works I can view the graphic along with the information for it and move it around if need to.

Quote Reply
Re: Validating graphics In reply to
So, you are asking to "move" the files around dynamically from the admin.cgi script?? Are these images located in another web server? Like when someone submits a link, they enter the full URL of the image in a field??

If so, then it would be a bit complicated to dynamically take that image and then put it in a local folder.

If the image files are already located locally in your webserver, I would, first, change the naming convention of the images to "ID#.jpg", then you could play around with the field types (like add one for IMAGE rather than ALPHA), and then hack the sub build_html_record_form routine in the db_utils.pl file. Also, I would simply use ONE image file folder in your local web server that will be much easier to manage over the long-term.

Regards,

Eliot Lee
Quote Reply
Re: Validating graphics In reply to
All the images are on one folder on my server. And when I implemented any new graphics will end up in the same directory.

I have over 1000 graphics changing them all to "ID#.jpg" might get complicated, plus when people add more graphics I would have to change them each by hand.

Is there any way to pull the information (just the graphic location) directly from links.db and add it where I want it to go.

I can do simple hacks, but anything too intense or that requires good knowledge of perl is out of my league.

Quote Reply
Re: Validating graphics In reply to
In Reply To:
I have over 1000 graphics changing them all to "ID#.jpg" might get complicated, plus when people add more graphics I would have to change them each by hand.
Well, the reason I suggested that was because of the following reasons:

1) To keep images unique. If your users or you add two images, one named bobhouse.jpg for the 1213 record in your database, and then someone else adds bobhouse.jpg for the 1517 file, then the file will be overwritten.

2) If you ever move to FILE UPLOAD MODS for EITHER Links 2.0 or LINKS SQL, you will be forced to use the PRIMARY KEY of the links database file/table for the name of the file. Makes things easier when you upgrade or add these new features in the script.

In Reply To:
Is there any way to pull the information (just the graphic location) directly from links.db and add it where I want it to go.
Anything is possible in Perl...just a matter of evaluating whether you want to employ a quick and dirty fix, which will not be stable with future upgrades or added functions, or thinking out the ramifications and employing a more robust solution that would be relatively intensive in terms of time, human and financial (time=money) resources, but have a functional system for the long-term.

In Reply To:
I can do simple hacks, but anything too intense or that requires good knowledge of perl is out of my league.
For the more robust solution...it would not be an easy hack...definitely have to have advanced basic to intermediate Perl knowledge to accomplish it.

Good luck!


Regards,

Eliot Lee
Quote Reply
Re: Validating graphics In reply to
For right now I would settle for the quick and easy fix so that I can finish this database and then I can see about more complex fixes.

Quote Reply
Re: Validating graphics In reply to
I will provide UNTESTED codes that will accomplish your first goal of PRINTING the image file within the validation form...

1) Make sure that you have defined the IMAGE field (in your %db_def hash in the links.def file, like the following:

Code:

$db_image = 15;


2) Then in your db_utils.pl file, look for the following codes in the sub build_html_record_form routine:

Code:

elsif ($db_form_len{$field} == -1) {$output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }


AFTER these codes, add the following codes:'

Code:

elsif ($db_cols[$db_image] ne "") {
$output = qq~<a href="$rec{'field'}">
<img src="$rec{'field'}"></a><p>
CHANGE IMAGE: <input type="text" name="$field" value="$rec{'field'}">~;
}
elsif ($db_cols[$db_image] eq "") {
$output = qq~No Image Provided\n$output~;
}


Regards,

Eliot Lee