### PHP Image Posting Code for BLUR 02 ###
## Functions to provide thumbnail and page display functionality.
#################################################################
## Function to read photo information from the data file and return an array.
## Data files exist for EACH directory (aka category) of image and are
## called 'photos.data'
##
function getAllPhotoInfo($theDirectory) {
if (file_exists($theDirectory."/photos.data")) {
## read each line of data file into array
$photosData = file($theDirectory."/photos.data");
while (list($key,$val) = each($photosData)) {
if ($key == "0") {
## first line of the data file is the category, not an image file
$photos[$key]["category"] = chop($val);
} else {
## split data line into it's parts and create image array entry.
list($prefix,$title,$description) = split("\t",$val);
$photos[$key]["small"] = $theDirectory."/".$prefix."_sm.jpg";
$photos[$key]["large"] = $theDirectory."/".$prefix."_lrg.jpg";
$photos[$key]["title"] = $title;
$photos[$key]["description"] = $description;
$photos[$key]["URL"] = "pop_win.php?dir=".urlencode($theDirectory)."&img=".urlencode($prefix);
}
}
return $photos;
} else {
return 0;
}
}
## Function to display photo thumbnail grid
##
function displayPhotoGrid($photoArray,$cols) {
if ($photoArray) {
$x = 0;
print "
";
while (list($key,$imageInfo) = each($photoArray)) {
if ($key == "0") {
## print category row
print "| ".$imageInfo['category']." |
\n";
} else {
$x++;
## check to see if a new row needs to be started
if ($x > $cols) {
$x = 1;
print "
\n";
}
## print image table cell
print " | \n";
}
}
## print empty cells to fill rest of row if necessary
while ($x < $cols) {
print " | \n";
$x++;
}
print "
";
} else {
## no photo array to display (incorrect directory name?)
print "ERROR: No Photos
";
}
}
?>
Blur 02 Photos
Images may not be reproduced in any form without the permission of New School University.
All rights reserved © New School University // 2002
|