[Clipart] The web-site

Bryce Harrington bryce at bryceharrington.com
Fri Jun 25 16:42:37 PDT 2004


On Mon, 21 Jun 2004, Bryce Harrington wrote:
> On Mon, 21 Jun 2004, [ISO-8859-1] Alberto Simões wrote:
> > Hi.
> > I love the idea of openclipart. In fact, I am a programmer and very,
> > but really very bad designer. Open Clipart can help me to save my
> > reputation :-)
> > 
> > Meanwhile, looking to the website, I would say that it would be nice
> > to have an interface like desktop backgrounds sites. Categories or
> > classes, browsables, with previews for each image. I think that to be
> > able to download a full tarball is handy, but it would also be nice to
> > be possible to download some specific SVG file, only.
> > 
> > Well, at least it is my point of view :-)
> 
> > Yep, I can help. But PHP is not my language.
> > But of course I can help in anything :-)
> 
> I have the php SVG browser scripts from sodipodi.com, and can pass that
> along to you; it looks like it could be adapted without too much
> effort, or at least provide some inspiration.  Let me know, and I'll
> send it to you.

Hi Alberto,

Hope all is well.  I've attached the php script.  Something like that in
either Perl or PHP, but that works with the openclipart package, and
that does what you describe would be very cool.

E.g., it would be nice to give the script an argument to the location of
the untarred clipart tarball, and have it allow browsing through the
contents in various ways, including thumbnails, etc. like you describe.

Bryce
-------------- next part --------------
<?php
global $PHP_SELF;
global $n;
$cols = 4;
$perpage = 24;

// Set page variables
if ($n == 0) $n = 1;
$area = $pagedata['area'];

$count = 0;
$dir = opendir("./clipart/$area/");
while ($file = readdir($dir)) {
	if (ereg(".svg$", $file)) {
		$filelist[] = $file;
	}
}
closedir($dir);

sort($filelist);
$total = count($filelist);

// Generate 'Previous' and 'Next' navigation links
$left = $n - $perpage;
if ($left > 0) $previous = "<A HREF='$PHP_SELF?section=$section/$area&area=$area&n=$left'><<< Previous</A>\n";

$right = $n + $perpage;
if ($right < $total) $next = "<A HREF='$PHP_SELF?section=$section/$area&area=$area&n=$right'>Next >>>></A>\n";

// Generate drop-down with page numbers
print "<CENTER><FORM ACTION='$PHP_SELF' METHOD='POST'>\n";
print "<TABLE WIDTH='90%'><TR><TD WIDTH='33%' ALIGN='left'>$previous</TD>\n";
print "<TD WIDTH='33%' ALIGN='center'>\n";
print "<INPUT TYPE='hidden' NAME='section' VALUE='$section/$area'>\n";
print "<INPUT TYPE='hidden' NAME='area' VALUE='$area'>\n";
print "<SELECT NAME='n'>\n";
for ($i=0; $i<($total / $perpage); $i++) {
	$def = '';
	$first = ($i * $perpage) + 1;
	$last = ($i + 1) * $perpage;
	if ($last > $total) $last = $total;

	if ($first == $n) $def = ' selected';

	print "<OPTION VALUE='$first'$def>$first - $last</OPTION>\n";
}
print "</SELECT><INPUT TYPE='SUBMIT' VALUE='Go'></TD>\n";
print "<TD WIDTH='33%' ALIGN='right'>$next</TD></TR></TABLE></FORM></CENTER>\n";

print "<BR><BR><TABLE WIDTH='90%' BORDER='0'>\n";

for ($i=($n-1); $i<($n + $perpage - 1); $i++) {
	$svgfile = $filelist[$i];
 	$basefile = basename($svgfile, '.svg');
 	$txtfile = $basefile.".txt";
 	$pngfile = $basefile.".png";
	if ($i >= $total) break;

	if ($count % $cols == 0) print "<TR ALIGN='center' VALIGN='bottom'>\n";
	
	/* $basefile = basename($file, '.txt'); */

	print "<TD>\n";
	print "<A HREF='clipart/$area/$svgfile' CLASS='clipart'>\n";
	print "<IMG SRC='clipart/$area/$pngfile' CLASS='clipart'>\n";

	if (file_exists ("./clipart/$area/$txtfile")) {
		$title = "";
		$author = "";
		$eval = file("./clipart/$area/$txtfile");
		eval (join('', $eval));
		print "<BR>\n";
		if ($title) {print "<B>$title</B>";}
		print "</A><BR>";
		if ($author) { print "By: $author\n";}
		print "<BR> </TD>\n";
	}

	$count++;
	if ($count % $cols == 0) print "</TR>\n";
}

// Make sure table closed off properly
if ($count % $cols != 0) print "</TR>\n";
?>

</TABLE>

<BR><BR>
<CENTER>

<TABLE WIDTH='90%'><TR>
<TD WIDTH='33%' ALIGN='left'><?php echo $previous?></TD>
<TD WIDTH='33%' ALIGN='center'>Total: <B><?php echo $total?></B></TD>
<TD WIDTH='33%' ALIGN='right'><?php echo $next?></TD>
</TR></TABLE>

</CENTER>


More information about the clipart mailing list