<?php
include_once("Gallery.class.php");
include_once(
"albums.php");

class 
Album extends Gallery{
/* 

dseelig - circa 2004 - album class

Description:

    Class to handle displaying an album of images
    show_abum   - show all images in an album 
    show_image  - show an image from an album 
    
*/


var $title;         // album_name
var $local_root;    // /home/seeligd/dysphemism.net/images/
var $web_root;      // dysphemism.net/images/
var $rweb_root;     // http://gridley.res.carleton.edu/photos/
var $thumbdir;      // directory thumbnails are stored in
var $origdir;       // directory originals are stored in
var $max5dir;       // directory medium-sizes are stored in
var $albumdir_full// /home/seeligd/dysphemism.net/images/north-shore
var $thumbdir_full// /home/seeligd/dysphemism.net/images/north-shore/thumbs
var $albumdir_web;  // http://dysphemism.net/images/north-shore
var $thumbdir_web;  // http://dysphemism.net/images/north-shore/thumbs
var $origdir_web;   // http://gridley.res.carleton.edu/photos/albumdir/orig
var $self_dir;      // where index.php is stored
var $site_title;    // the title of the rendered page

var $album_members// array of sorted images i can use again and again!

//constructor
function Album($title,$local_root,$web_root$thumbdir,$max5dir,$origdir,$rweb_root,$site_title ) { //{{{
    
global $PHP_SELF;
    
$this->self_dir=dirname($PHP_SELF) . "/" basename($PHP_SELF);
    
#echo "location: $this->self_dir<br/>";

    
$this->title=$title;
    
$this->local_root=$local_root;
    
$this->web_root=$web_root;
    
$this->thumbdir=$thumbdir;
    
$this->site_title=$site_title;

    
$this->origdir=$origdir;
    
$this->max5dir=$max5dir;
    
$this->rweb_root=$rweb_root;

    
$this->albumdir_full=$this->local_root .  $this->title;
    
$this->thumbdir_full=$this->albumdir_full ."/"$this->thumbdir;
    
$this->albumdir_web=$this->web_root .  $this->title;
    
$this->thumbdir_web=$this->albumdir_web "/" $this->thumbdir;

    
$this->albumdir_full=$this->albumdir_full "/" $this->max5dir;
    
$this->albumdir_web=$this->albumdir_web "/" $this->max5dir;

    
$this->origdir_web=$this->rweb_root $title "/" $this->origdir;

/*
    echo "max5dir: $this->max5dir <br>\n";
    echo "origdir: $this->origdir <br>\n";
    echo "rweb_root: $this->rweb_root <br>\n";
    echo "origdir_web: $this->origdir_web <br>\n";
    echo "thumbdir: $this->thumbdir_full <br>\n";
    echo "albumdir: $this->albumdir_full <br>\n";
    echo "webroot: $this->web_root <br>\n";
    echo "album-webroot: $this->albumdir_web <br>\n";
    echo "thumbdir-webroot: $this->thumbdir_web <br>\n";
*/

    
if (!file_exists($this->thumbdir_full))
        echo 
"there is no thumbs directory";

    
$handle opendir($this->albumdir_full);
    
$this->album_members = array();
    while(
$file readdir($handle)){
        if  (
ereg(".jpg$",$file) ) {
            
array_push($this->album_members$file);
            
#echo $file . "<br>\n";
        
}
    }

    
usort($this->album_members'strnatcmp');

}
//}}}

//show the entire album
function show_album() { //{{{

    
print "<a href='$this->self_dir'>albums</a> : $this->title <br/><br/>";

    
$temp_members=$this->album_members;

    
# $dir = dirname($PHP_SELF);
    
while( $file array_shift($temp_members) ){
        
$size getimagesize($this->thumbdir_full "/" $file);
        
$sizebig getimagesize("$this->albumdir_full/$file");

        echo 
"<div class='liquid-thumb'><a href='$this->self_dir?album=$this->title&image=$file#photo'><img src='$this->thumbdir_web/$file' ".$size[3]." /></a><br/>";

        echo 
"</div>\n\n";
    }

    echo 
"<div class='spacer'> &nbsp;</div>";



?>



<?php
}
//}}}

function show_image($image) { //{{{

    
$length count($this->album_members);

    
$index array_search($image$this->album_members);

    if (
$index>0)
        
$prev $index-1;
    else
        
$prev "-1";
    
    if (
$index<$length-1)
        
$next $index+1;
    else
        
$next "-1";

    
$size getimagesize($this->albumdir_full "/" $this->album_members[$index]);
    
$x $size[0];
    
$y $size[1];
    
$halfxround($x/2);
    
$halfx1 $halfx+1;

    print 
"<a href='$this->self_dir'>albums</a> : <a href='$this->self_dir?album=$this->title'>$this->title</a> : $image <br/><br/>";

    print 
"<div class=image_browse>";
    echo 
"<img src='"$this->albumdir_web "/" .  $this->album_members[$index] . "' alt='' usemap='#browse'/>";
    
    print 
"
    <map name='browse'>
    <area shape='rect' coords='1,1,$halfx,$y' href='$this->self_dir?album=$this->title&image="
$this->album_members[$prev] . "' title='previous image'>
    <area shape='rect' coords='$halfx1,1,$x,$y' href='$this->self_dir?album=$this->title&image="
$this->album_members[$next] . "' title='next image'>
    </map>
    "
;

    print 

    <span class='left'><a href='$this->self_dir?album=$this->title&image="
.$this->album_members[$prev]."' title='previous image'>previous</a></span> 
    <span class='right'><a href='$this->self_dir?album=$this->title&image="
.$this->album_members[$next]."' title='next image'>next</a> <br/></span>
    <span class='center'><a href='$this->origdir_web/"
.$this->album_members[$index]."' title='download image'>larger</a></span> 
    
    </div>"
;


}
//}}}

}
?>