<?php
    
require_once "/home/uellue/pub/PHPGallue/libgallue/gallery.inc.php";
    
$gallery = new GALGallery("/home/uellue/pub/PHPGallue/config.xml");
    class 
MyGlobalVars extends GALGlobalVars {
        function 
url($changes = array()) {
            return 
htmlspecialchars(parent::url($changes), ENT_QUOTES'UTF-8');
        }
    }
    
/* Tabelle ermitteln */
    
$grouptbl $gallery->database->cleanName($gallery->config->tables->Groups->v);
    
/* userID aus der config */
    
$juleID intval($gallery->config->julechronik->juleID->v);
    
/* globalvars anfang */
    
$globalvars = new MyGlobalVars(0"index.php");
    
$globalvars->register("rightbox"GALDescriptor::GETGALVariable::STRING"home""home");
    
$globalvars->register("imageID"GALDescriptor::GETGALVariable::UINT00);
    
$globalvars->evaluate($_GET$_POST$_COOKIE);
    
/* globalvars ende */
    /* Galeriegruppe */
    
define("GroupID"65);
    
$group $gallery->groups->row(array('groupID' => GroupID));
    
/* sichtbare Bilder der Galeriegruppe */
    /* images ist vom typ GALImageIterator */ 
    
$images $group->loadImages($gallery->images->visible(),"sortHint ASC"); 
    
prefetch($imagesGAL_IMG_MEDIUM);
    
prefetch($imagesGAL_IMG_THUMB);

    function 
imgTag($instanceIDGALImage $image) {
        
$instance $image->instance($instanceID);
        if (
$instance instanceof GALInstance) {
        echo(
'<img
            src="'
.htmlspecialchars($instance->url(), ENT_QUOTES'UTF-8').'"
            width="'
.$instance->x.'"
            height="'
.$instance->y.'"
            alt="'
.htmlspecialchars($image->titleENT_QUOTES'UTF-8').'"
            longdesc="'
.htmlspecialchars($image->commentENT_QUOTES'UTF-8').'"
            title="'
.htmlspecialchars($image->titleENT_QUOTES'UTF-8').'" />'
        
);
        } else {
        
$rawInstance $image->instance(0);
        
$sizestr number_format($rawInstance->blob->size 10242'.''')." kB";
        echo (
htmlspecialchars($rawInstance->blob->mimeType." ($sizestr)"ENT_QUOTES'UTF-8'));
        }
    }
    
    function 
prefetch(GALImageIterator $images$instanceID) {
        global 
$gallery;
        
$imageIDs $images->verticalFetch('imageID');
        
$expr = new GALExpressionList($gallery->database$gallery->instances'imageID'$imageIDs);
        
$expr $expr->eand($gallery->instances->compareExpression('instanceID''='$instanceID));
        
$instances $gallery->instances->load($expr);
        while (
$inst $instances->fetch()) {}
    }
    
    function 
galerie_rightbox() {
    global 
$globalvars;
    global 
$images;
    global 
$group;
    global 
$gallery;
?>
<h1>Galerie</h1>
<?php
    $imageIDs 
$images->verticalFetch("imageID");
    
$images->rewind();
    echo(
"<ul class='inlinenavlist galerienav'>");
    
/* 2. Durchlauf für den Rest  */
    
while ($image $images->fetch()) {
        echo(
"<li>");
        echo(
"<a href='index.php?rightbox=galerie&amp;imageID=".$image->getID()."'>");
        
/* Thumbnail ausgeben */
        
echo(imgTag(GAL_IMG_THUMB$image));
        echo(
"</a>");
        echo(
"</li>");
    }
    
/* valide imageID gesetzt? falls nicht, erstes Bild */
    
if(!(in_array($globalvars->imageID$imageIDs))) {
        
$globalvars->imageID $imageIDs[0];
    }
    
$big_image $gallery->images->row(array("imageID" => $globalvars->imageID));
    echo(
"</ul>");
    echo(
"<div class='galerieitem'>");
            echo 
imgTag(GAL_IMG_MEDIUM$big_image);
    echo(
"</div>");
}
?>