$val) {
$$key = $val;
}
// Display sub albums
if ($layout_conf["LOCK_TO_ALBUM"] != "on") {
$res = $p->D->dbQuery("select * from ".GALLERY_ALBUM." where PARENTID=$gallery");
while ($subalbum = $p->D->dbFetchArray($res)) {
// Fetch album image
$res2 = $p->D->dbQuery("select i.* from ".GALLERY_IMAGE." i, ".GALLERY_ALBUM_IMAGE." a where a.ALBUMID=".$subalbum["ID"]." and a.IMAGEID=i.ID order by i.ID limit 1");
if (empty($subalbum["FRONTIMAGEID"])) {
$albumimage = $p->D->dbFetchArray($res2);
$albumimage = $albumimage["ID"];
} else {
$albumimage = $subalbum["FRONTIMAGEID"];
}
$p->D->dbSetTable(GALLERY_ALBUM_IMAGE);
$numImages = $p->D->dbGetFieldN("count(*)", "ALBUMID", $subalbum["ID"]);
print '
';
}
}
// Display pictures
$p->D->dbSetTable(GALLERY_ALBUM);
$title = $p->D->dbGetFieldN("TITLE", "ID", $gallery);
$desc = $p->D->dbGetFieldN("DESCRIPTION", "ID", $gallery);
$res = $p->D->dbQuery("select i.*,a.SEQUENCENUMBER from ".GALLERY_IMAGE." i, ".GALLERY_ALBUM_IMAGE." a where a.ALBUMID=$gallery and a.IMAGEID=i.ID order by a.SEQUENCENUMBER");
if ($p->D->dbNumRows($res)) {
print ''.$title.'
';
print $p->convertContent($desc).'
';
print ''. $layout_conf["CLICKIMAGES_STR"] .'
';
print '';
$img = 0;
while ($image = $p->D->dbFetchArray($res)) {
$filename = constant('SCRIPT_ROOT') . 'fundanemt/'. $image['FILENAME'];
list($imagewidth, $imageheight) = @getimagesize($filename);
$srcRatio = $imagewidth / $imageheight;
$destRatio = $THUMBNAIL_SIZE_X / $THUMBNAIL_SIZE_Y;
if ($destRatio > $srcRatio) {
$thumbnailWidth = (int)($THUMBNAIL_SIZE_Y * $srcRatio);
$thumbnailHeight = $THUMBNAIL_SIZE_X;
} else {
$thumbnailWidth = $THUMBNAIL_SIZE_X;
$thumbnailHeight = (int)($THUMBNAIL_SIZE_Y / $srcRatio);
}
$img++;
if ($img % $ROW_SIZE == 1) print '';
print '
 |
';
if ($img % $ROW_SIZE == 0) print '
';
}
for ($i=$img; $i % $ROW_SIZE != 0; $i++) {
print ' | ';
}
print '';
print '
';
}
if ($gallery != GALLERY_ROOT && $gallery != $layout_conf["ROOT_ALBUM"] && $LOCK_TO_ALBUM != "on") {
$p->D->dbSetTable(GALLERY_ALBUM);
$parent = $p->D->dbGetFieldN("PARENTID", "ID", $gallery);
print '
« '.$BACKTOOVERVIEW_STR.'';
}
}
function printImage($p, $galleryid, $num, $layout_conf, $conf, $VSTYLE) {
// Import layout configuration
foreach ($layout_conf as $key=>$val) {
$$key = $val;
}
$img = array();
// Get number of images in album
$p->D->dbSetTable(GALLERY_ALBUM_IMAGE);
$total = $p->D->dbGetFieldN("count(IMAGEID)", "ALBUMID", $galleryid);
// Sanity checks
$num = is_numeric($num) ? $num : 1;
// Get image number in album
$res = $p->D->dbQuery("select count(IMAGEID) from ".GALLERY_ALBUM_IMAGE." where ALBUMID=$galleryid and SEQUENCENUMBER<=$num");
$number = $p->D->dbFetchArray($res);
$number = $number[0];
// Get max sequence number in album
$p->D->dbSetTable(GALLERY_ALBUM_IMAGE);
$max = $p->D->dbGetFieldN("MAX(SEQUENCENUMBER)", "ALBUMID", $galleryid);
// Album contains no images
if ($max == null) {
print "Gallery is empty.";
return;
}
// Make sure image is actually in sequence
// Might have been deleted.
$res = $p->D->dbQuery("select 1 from ".GALLERY_ALBUM_IMAGE." where ALBUMID=$galleryid and SEQUENCENUMBER=$num");
$fallback = $p->D->dbFetchArray($res);
if ($num < 1 || $fallback == NULL) {
$number = 1;
$num = 1;
} else if ($num > $max) {
$num = $max;
} else {
// ..
}
// Previous image
$res = $p->D->dbQuery("select IMAGEID,SEQUENCENUMBER from ".GALLERY_ALBUM_IMAGE." where ALBUMID=$galleryid and SEQUENCENUMBER<$num order by SEQUENCENUMBER desc LIMIT 1");
$prev_image = $p->D->dbFetchArray($res);
// Next image
$res = $p->D->dbQuery("select IMAGEID,SEQUENCENUMBER from ".GALLERY_ALBUM_IMAGE." where ALBUMID=$galleryid and SEQUENCENUMBER>$num order by SEQUENCENUMBER asc LIMIT 1");
$next_image = $p->D->dbFetchArray($res);
// Get current image information
$res = $p->D->dbQuery("select i.* from ".GALLERY_IMAGE." i, ".GALLERY_ALBUM_IMAGE." a where a.ALBUMID=$galleryid and a.SEQUENCENUMBER=$num and i.ID=a.IMAGEID");
$image = $p->D->dbFetchArray($res);
// Calculate image size
$filename = SCRIPT_ROOT."fundanemt/".$image["FILENAME"];
list($width, $height, $type, $attr) = getimagesize($filename);
// If layout does not specify a image size we do not scale.
if (!empty($layout_conf["IMAGE_SIZE_X"]) && !empty($layout_conf["IMAGE_SIZE_Y"])) {
$srcRatio = $width/$height; // width/height ratio
$destRatio = $layout_conf["IMAGE_SIZE_X"]/$layout_conf["IMAGE_SIZE_Y"];
if ($destRatio > $srcRatio) {
$height = $layout_conf["IMAGE_SIZE_Y"];
$width = $layout_conf["IMAGE_SIZE_Y"] * $srcRatio;
} else {
$width = $layout_conf["IMAGE_SIZE_X"];
$height = $layout_conf["IMAGE_SIZE_X"] / $srcRatio;
}
}
$img["IMAGE_SIZE_X"] = round($width);
$img["IMAGE_SIZE_Y"] = round($height);
if (is_array($prev_image)) {
$img["PREVIOUS_LINK"] = $p->printUrl($p->ID, true).(URL_TYPE==0 ? "&" : "?").'gallery='.$galleryid.'&num='.$prev_image["SEQUENCENUMBER"];
}
if (is_array($next_image)) {
$img["NEXT_LINK"] = $p->printUrl($p->ID, true).(URL_TYPE==0 ? "&" : "?").'gallery='.$galleryid.'&num='.$next_image["SEQUENCENUMBER"];
}
$img["IMAGE"] = SCRIPT_URL.'fundanemt/modules/fundaGallery/viewImage.php?id='.$image["ID"].'&width='.$layout_conf["IMAGE_SIZE_X"].'&height='.$layout_conf["IMAGE_SIZE_Y"];
$img["TEXT"] = $p->convertContent(htmlentities($image["TEXT"]));
$img["PHOTOGRAPHER"] = htmlentities($image["PHOTOGRAPHER"]);
// Exif information
if (function_exists('exif_read_data')) {
$exif = @exif_read_data(SCRIPT_ROOT."fundanemt/".$image["FILENAME"], "FILE");
} else {
$exif = '';
}
if ($layout_conf["SHOW_EXIF"] == "on" && is_array($exif) && (array_key_exists("DateTimeOriginal", $exif) || array_key_exists("Model", $exif))) {
if (!strstr("0000:00:00 00:00:00", $exif["DateTimeOriginal"])) {
$img["EXIF"][] = array("Picture taken:", $exif["DateTimeOriginal"]);
}
if (isset($exif["Model"]) && !empty($exif["Model"])) {
$img["EXIF"][] = array("Camera:", $exif["Model"]);
}
}
if ($LOCK_TO_ALBUM != "on") {
$img["BACKLINK"] = $p->printUrl($p->ID, true).(URL_TYPE==0 ? "&" : "?")."gallery=".$galleryid;
}
include MODULE_ROOT."fundaGallery/insert_layouts/$VSTYLE/".$conf["slideshow_view"];
// Update image view count
if ($image != null) {
$p->D->dbSetTable(GALLERY_IMAGE);
$p->D->dbQuery("update ".$p->D->table." set VIEW=". ($image["VIEW"] + 1) ." where ID=".$image["ID"]);
}
}
?>