process_comment_form();
//START RENDERING
$page->header("Photos");
require("inc/header.inc.php");
// folder > tree
//print "
" . $scnamegallery . "";
print "
" . $scnamegallery . "";
#############################
# Overall Gallery Index #
#############################
if (!$galerie) {
# finish off navigation bar
print "
\n\n\n\n";
# I've nuked date.txt to replace it with a more generic info.txt
# It optionally supplies i18n name, camera model, author and date
# TODO: imgconv script support
while ($file = $adr->Read()) {
// checking for inc is only really needed when gallery_dir == $root
// hopefully not many galleries will be named inc ;)
if (is_dir("$gallery_dir/$file") && !ereg("\.", $file) && $file!="inc") {
// Use date file for gallery date if avaliable
// info.txt format described in README
readInfo("$root/$gallery_dir/$file/info.txt", $file);
}
}
if (!isset($galeriemonth)) $galeriemonth = array();
if (!isset($galerieday)) $galerieday = array();
//sort within month depending on $sortinmonth
if ($sortinmonth) {
//alphabetically
ksort($galeriemonth);
reset($galeriemonth);
} else {//by date
arsort($galerieday);
reset($galerieday);
}
$thisyear = 0;
if (!$yearto) $yearto = date("Y");
for ($i = $yearto; $i >= $yearsince; $i--) {
for ($thismonth=12; $thismonth>0; $thismonth--) { // go year by year, month by month
// down
foreach ($galerieday as $foldername => $day) { //using $galerieday (for when sorted)
if ($galeriemonth["$foldername"] == $thismonth &&
$galerieyear["$foldername"] == $i) { //such Y/M exists
$galerieyearordered["$foldername"]=$galerieyear["$foldername"];
$galeriemonthordered["$foldername"]=$galeriemonth["$foldername"];
}
}
}
}
$months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'),
__('September'), __('October'), __('November'), __('December'));
$one_out = false;
foreach ($galerieyearordered as $foldername => $year) {
$one_out = true;
if (@$thisyear!=$year) { #if the year is not equal to the current year
#This is the first year
if (@$thisyear) { print "
\n\n";}// end last year if this is
// not the first one
#This is a new year
unset($thismonth);
print "$year
\n";
print "";
}
$month=$galeriemonth["$foldername"];
# now months
if (@$thismonth!=$month) {
#first one
if (@$thismonth) { print " \n"; } // end of last month if
// this is not the first one
#new month
$monthindex = $month - 1;
$monthname = $months[$monthindex];
print " $monthname
\n";
}
#galleries within month
if ($galerielogin[$foldername]) {
print "
";
print $galeriename[$foldername];
print "";
} else {
print " href=\"$ThisScript?galerie=$foldername\">$foldername";
}
if (@$galeriedesc[$foldername]) {
print "" . $galeriedesc[$foldername];
print "\n";
}
if (@$galerieauthor[$foldername]) {
print "by " . $galerieauthor[$foldername];
print "\n";
}
if (@$galerieday[$foldername]) {
print "";
print "$monthname " . $galerieday[$foldername];
print "\n";
}
print "
\n";
$thisyear=$year;
$thismonth=$month;
}
if ($one_out) print ("
\n\n\n");
##############################
# Individual Gallery Index #
##############################
} elseif (!$snimek) {
# finish off navigation header
print "\n > ";
if ($galeriename[$galerie]) {
print $galeriename[$galerie];
} else {
print $galerie;
}
print "\n\n";
//thumbnails
print "\n";
$path = "$gallery_dir/$galerie/thumbs";
$imgfiles = new SortDir($path);
check($galerie); // check for nasty input
while ($file = $imgfiles->read()) {
if (is_file("$path/$file") && eregi("^img-([0-9]+)\.(png|jpe?g)", $file, $x)) {
$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
$imgsize = getimagesize("$root/$thumb");
//check for portraits
$portrait = "false";
$class = "";
if($imgsize[0]<100) {
//portraits need a special class for styling
$class = "portrait";
}
//check for number of comments per photo
if ($comments) { //there probably won't be user comments if it's off
$NumOfComments = 0;
if (file_exists("$gallery_dir/$galerie/comments/user_${x[1]}.txt")) {
if ($class) $class .= " ";
$class .= "hascomments";
//now let's count'em
$fh = fopen("$gallery_dir/$galerie/comments/user_${x[1]}.txt","r");
while (!feof($fh)) {
$line = fgets($fh);
if (eregi("commententry",$line)) $NumOfComments++;
}
fclose($fh);
}
if ($NumOfComments==1) {
$NumOfComments = $NumOfComments . " " . __('Comment');
} else {
$NumOfComments = $NumOfComments . " " . __('Comments');
}
}
if (file_exists("$gallery_dir/$galerie/comments/${x[1]}.txt") &&
$title = file_get_contents("$gallery_dir/$galerie/comments/${x[1]}.txt")) {
$title = ereg_replace("(\"|\')","",trim(strip_tags($title)));
$title = ereg_replace("(.{77}).*","\\1",$title);
} else
$title = "Photo ${x[1]}";
print " ";
print "";
print "\n";
}
}
print "
\n";
//info
print "\n";
if ($galeriedesc[$galerie]) {
print "
";
print "";
print $galeriedesc[$galerie] . "
\n";
}
if ($galerieauthor[$galerie]) {
print "
Author: ";
print "";
print $galerieauthor[$galerie] . "
\n";
}
print "
\n";
//and links to archived images:
print "\n\n";
if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) {
print "[ " . __('zipped MQ images') . " ] ";
}
if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) {
print "[ " . __('MQ images tarball') . " ] ";
}
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
print "[ " . __('zipped HQ images') . " ]";
}
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
print "[ " . __('HQ images tarball') . " ]";
}
print "
";
#######################
# Individual Image #
#######################
} else { //low-res image
# finish off header
print "\n > ";
if ($galeriename[$galerie]) {
print $galeriename[$galerie];
} else {
print $galerie;
}
print "\n > Photo";
print " $snimek";
$path = "$gallery_dir/$galerie/thumbs";
$imgfiles = new SortDir("$path");
check($galerie);
$path = "$gallery_dir/$galerie/lq";
$file = "$path/img-$snimek.jpg";
if (!file_exists($file)) {
print __('No such image');
$page->footer();
exit;
}
if (!$picture) { //picture may have been created if commentform submitted
require_once("$root/inc/photo.class.inc.php");
$picture = new C_photo($file, $snimek);
}
// mini thumbnail roll
if ($show_thumbs) {
print "\n\n";
print "
";
print "\n";
print " : \n";
while ($thumbfile = $imgfiles->read()) {
if ( eregi("^img-([0-9]+)\.(png|jpe?g)",
$thumbfile, $x)) {
$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
print "
";
print "";
print " \n";
}
}
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
print "
";
print "zip";
}
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
print "
";
print "zip";
}
print "
\n";
} else {
// show the popup button
print "\n\n\n";
}
/* main image + thumbnail navigation (prev/next) */
$picture->renderPreview();
$page->navigation($galerie, $snimek, "prev");
$page->navigation($galerie, $snimek, "next");
print "\n"; //end image div
if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php");
/* Image comment
really poor naming here, it is caption.
*/
$picture->renderCaption();
//show page counter
if ($log_access) {
$picture->renderCounter();
}
$picture->renderBigSize();
$page->user_comments($picture->number);
$page->navigation($galerie, $snimek, null);
}
require("inc/footer.inc.php");
$page->footer();
?>