<?php
/* 

dseelig - circa 2004 - gallery class

Description:

    Class to handle displaying a gallery of images
    print_header - prints the header :)
    print_footer - prints the footer 
    show_gallery - shows the thumbnails
    
*/

class Gallery {

var 
$local_root;    // /home/seeligd/dysphemism.net/images/
var $web_root;      // dysphemism.net/images/
var $thumbdir;      // directory thumbnails are stored in
var $self_dir;      // directory where index.php i stored
var $album_members// array of sorted images i can use again and again!
var $site_title;    // 'dysphemism photos'

//constructor
function Gallery($local_root,$web_root,$thumbdir,$site_title) { //{{{
global $PHP_SELF;

$this->local_root   $local_root;
$this->web_root     $web_root;
$this->thumbdir     $thumbdir;
$this->self_dir     dirname($PHP_SELF) . "/" .  basename($PHP_SELF);
$this->site_title   $site_title;

#echo "dirname: $this->self_dir";

}
//}}}

function print_header() { //{{{
?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $this->site_title?> </title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" type="image/ico" href="/favicon.ico" />
    <style type="text/css" media="screen">
        @import "black.css";
    </style>

    <style type="text/css">

    </style>

</head>
<body>
<div id='frame'>

<?php
//}}}

function print_footer() { //{{{
?>

</div>
</body>
</html>


<?php
//}}}

function show_gallery() { //{{{

echo "albums:<br/><br/>";

if (
is_dir($this->local_root) )
{
    
$miscDir opendir("$this->local_root");
    
#echo $miscDir;
    #echo "$this->local_root";

    
$filenames = array();
    while(
$file readdir($miscDir)){
         if((
$file[0] != ".") && ($file != "index.php")){
            if( 
is_dir("$this->local_root/$file") ) { 
                
array_push($filenames$file); 
                }
         }
    }

    
natcasesort($filenames);
    
rsort($filenames);


    while( 
$name array_shift($filenames) ){
        
$rand=get_rand_file("$this->local_root/$name/$this->thumbdir");
        print
"<div class='liquid-thumb'><a href=\"".$this->self_dir."?album=$name\"><img alt='' src='$this->web_root/$name/$this->thumbdir/$rand' /></a> <br/>" hyphens_to_spaces($name) . "</div>\n\n";
        
    }   
        echo 
"<div class='spacer'> &nbsp; &nbsp; </div>";
}
else 
    echo 
"it's not a directory!";

//}}}

}
?>