".htmlentities($row["HEADING"])."\n";
$story = empty($row["STORY"])?" ":$row["STORY"];
$galleryName = $row["NAME"];
$hasGallery = !(empty($heading) || empty($row["STORY"]));
}
else
{
$hasGallery = FALSE;
$story = 'Keine Gallery zu dieser ID gefunden!';
}
if ($hasGallery)
{
// count images in gallery
$sql = "SELECT COUNT(ID) FROM `images` WHERE GALLERY='$galleryName'";
$countResult = mysql_query($sql);
$numImages = 0;
if ($countRow = mysql_fetch_array($countResult))
{
$numImages = $countRow[0];
}
mysql_free_result($countResult);
// get images for gallery
$lower = ($galleryPage-1) * $imagesPerPage;
$upper = $imagesPerPage;
$sql = "SELECT * FROM `images` WHERE GALLERY='$galleryName' ORDER BY IMAGEFILE, ID";
$imageResult = mysql_query($sql);
$maxPages = ceil($numImages / $imagesPerPage);
}
if ($galleryPage > $maxPages)
{
$galleryPage = $maxPages;
}
if ($isDetail)
{
mysql_data_seek($imageResult, $display-1);
if ($row = mysql_fetch_array($imageResult))
{
$detailStory = $row["STORY"];
if (!empty($detailStory))
{
$story = $story . "
" . $detailStory;
}
}
}
function get_up_link()
{
global $gallery;
global $galleryPage;
global $isDetail;
global $thisScript;
if ($isDetail)
{
$upLink = "$thisScript?gallery=" . $gallery . "&galleryPage=" . $galleryPage;
}
return $upLink;
}
function show_next_thumb($imageResult, $rowNum)
{
global $thisScript;
global $gallery;
global $galleryPage;
global $imagesPerPage;
global $basePath;
$thumb = ' ';
if ($row = mysql_fetch_array($imageResult))
{
$imageName = $row["IMAGEFILE"];
$paths = pathinfo($imageName);
$thumbName = $paths["dirname"] . "/thumbnails/" . $paths["basename"];
if (file_exists($thumbName))
{
$imgInfo = GetImageSize($thumbName);
// now add path for browser
if (!empty($basePath))
{
$thumbName = $basePath . $thumbName;
}
$imgNum = ($galleryPage-1) * $imagesPerPage + ($rowNum+1);
$params = "gallery=" . $gallery . "&galleryPage=" . $galleryPage . "&display=" . $imgNum;
$link = "$thisScript?" . $params;
$thumb = '';
$thumb = $thumb . '
';
// add name
$name = '
' . $paths["basename"] . '';
$thumb = $thumb . $name;
}
}
return $thumb;
}
function show_thumbs($imageResult)
{
print '
';
for ($i = 0; $i < 3; $i++)
{
print "\n";
for ($j = 0; $j < 4; $j++)
{
print "\n";
print show_next_thumb($imageResult, $i * 4 + $j);
print " | \n";
}
print "
\n";
}
print "
\n";
}
function gallery_navigation()
{
global $gallery;
global $galleryPage;
global $maxPages;
global $thisScript;
if ($maxPages == 1)
{
return;
}
$params = "gallery=" . $gallery . "&galleryPage=";
$link = "$thisScript?" . $params;
$pagePrev = ' ';
$pageNext = ' ';
// build links
if ($galleryPage > 1) {
$url = $link . ($galleryPage - 1);
$alt = "Seite " . ($galleryPage-1);
$imgPrev = '
';
$pagePrev = '' . $imgPrev . '';
}
if ($galleryPage < $maxPages)
{
$url = $link . ($galleryPage + 1);
$alt = "Seite " . ($galleryPage+1);
$imgNext = '
';
$pageNext = '' . $imgNext . '';
}
// and print it
/*
print $pagePrev;
if ($maxPages > 1) {
print "Seite $galleryPage von $maxPages";
}
print $pageNext;
*/
print "\n";
print "\n";
print "$pagePrev | \n";
// print uplink
$imgUp = '
';
print 'Seite ' . $galleryPage . ' von ' . $maxPages . ' | ' . "\n";
print "$pageNext | \n";
print "
\n
\n";
}
function image_navigation()
{
global $gallery;
global $galleryPage;
global $numImages;
global $display;
global $thisScript;
$params = "gallery=" . $gallery . "&galleryPage=" . $galleryPage . "&display=";
$link = "$thisScript?" . $params;
$pagePrev = ' ';
$pageNext = ' ';
// build links
if ($display > 1) {
$url = $link . ($display - 1);
$alt = "Zu Bild " . ($display - 1);
$imgPrev = '
';
$pagePrev = '' . $imgPrev . '';
}
if ($display < $numImages)
{
$url = $link . ($display + 1);
$alt = "Zu Bild " . ($display + 1);
$imgNext = '
';
$pageNext = '' . $imgNext . '';
}
// and print it
print "\n";
print "\n";
print "$pagePrev | \n";
// print uplink
$imgUp = '
';
print '' . $imgUp . ' | ' . "\n";
print "$pageNext | \n";
print "
\n
\n";
}
function detail_display($imageResult)
{
global $display;
global $basePath;
mysql_data_seek($imageResult, $display-1);
if ($row = mysql_fetch_array($imageResult))
{
$imageData = GetImageSize($row["IMAGEFILE"]);
$alt = $row["ALTTEXT"];
$src= $row["IMAGEFILE"];
if (!empty($basePath))
{
$src = $basePath . $src;
}
$id = "image" . $imageData[0];
print "\n";
print "

\n";
print "
\n";
}
}
function generate_style()
{
// generate the style for the image
global $imageResult;
global $display;
global $imageData;
global $hasGallery;
global $display;
mysql_data_seek($imageResult, $display-1);
if ($row = mysql_fetch_array($imageResult))
{
$imageData = GetImageSize($row["IMAGEFILE"]);
$left = "8px";
// if ($imageData[0] >= 768) {
// $left = "-100px";
// }
// if no content move image div
$top = "240px";
if (!$hasGallery) {
$top = "60px";
$left = "154px";
}
$style = "\tdiv#image {position: absolute; top: $top; left: $left; width: $imageData[0]px; height: $imageData[1]px; border: solid 5px white;}\n";
}
return $style;
}
function generate_style_2()
{
// generate the style for the image
global $imageResult;
global $display;
global $imageData;
global $hasGallery;
global $display;
mysql_data_seek($imageResult, $display-1);
if ($row = mysql_fetch_array($imageResult))
{
$imageData = GetImageSize($row["IMAGEFILE"]);
if ($imageData[0] >= 768)
{
return generate_style();
}
$left = "0px";
// if no content move image div
$top = "5px";
$style = "\tdiv#image {position: relative; top: $top; left: $left; width: $imageData[0]px; height: $imageData[1]px; border: solid 5px white;}\n";
}
return $style;
}
?>
Dirk Steins: gallery