<?php
//
// This file is part of MythWeb,
// a php-based interface into MythTV.
//
require_once "includes/init.php";
require_once theme_dir."mythgallery.php";
class mythGallery {
var $offset;
var $gallerydir;
var $currentdir;
function mythGallery()
{
if($_GET['offset'] >=0 )
$this->offset=$_GET['offset'];
else
$this->offset=0;        
$this->gallerydir = gallery_url;
$this->currentdir=$_GET['currentdir'];
if (!$this->currentdir)
$this->currentdir = $this->gallerydir;
}
function readdircontens($dir)
{
if (!is_dir($dir))
return $dir;
$resdirs = array();
$res = array();
$h = opendir($dir);
while (false !== ($file = readdir($h)))
{
if ($file != "." && $file != ".." && $file != ".thumbcache")
{
if (is_dir($file))
$resdirs[] = $file;
else
$res[] = $file;
}
}
closedir($h);
return array_merge($resdirs, $res);
}
function display()
{
$dircontens = $this->readdircontens($this->currentdir);
$totalcount = count($dircontens);
$gallery = new Theme_mythgallery();
$gallery->setOffset($this->offset);
$gallery->setTotalCount($totalcount);
$gallery->print_header($this->currentdir, $this->gallerydir, $this->parentdir());
if($totalcount > 0)
$gallery->printDetail($dircontens);
else
$gallery->printNoDetail();
$gallery->print_footer();
}
function parentdir()
{
$galpieces = explode("/", $this->gallerydir);
$curpieces = explode("/", $this->currentdir);
array_pop($curpieces);
if (count($galpieces)<count($curpieces))
return implode("/", $curpieces);
        else
return "";
}
}
$mythgallery = new mythGallery();
$mythgallery->display();
?>