Location: PHPKode > scripts > SelectaPix Image Gallery > classes/sub_cat.php
<?php
/* +----------------------------------------------------------------------+
   |SelectaPix Open Source Gallery	                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 2004 OutOfTheTrees			                          |
   |                                                                      |
   | http://www.outofthetrees.co.uk/index.php                             |
   | 												                      |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.0 of the GPL license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.outofthetrees.co.uk/license/2_0.txt.                      |
   | If you did not receive a copy of the SelectaPix license and are 	  |
   | unable to obtain it through the world-wide-web, please send a note   |
   | to hide@address.com so we can mail you a copy immediately.|
   +----------------------------------------------------------------------+ */
if (!defined("ACCESS")) {
    die ("Direct request denied");
}

class SubCat extends Page {

	function SubCat($f) {
		$this->f =& $f;
		$this->Page($f);
	}

	function ShowBody($albumid) {
		if(!$albumid) {
			$albumid  = $this->f->conn->query($this->get_min_albumid(), 'index');
		}
		else {
			$albumid = $this->f->util->ForceInt($albumid, 0);
		}
		$this->album_name = $this->f->conn->query($this->get_album_name($albumid), 'index');
		if($this->images_per_page != "") {
			$p = new Pager();
			$limit = $this->images_per_page;
		    $start = $p->findStart($limit);
		    $count = $this->f->conn->query($this->get_album_images_count($albumid), 'index');
		    $pages = $p->findPages($count, $limit);
		    $this->images = $this->f->conn->query($this->get_album_images_by_limit($albumid, $start, $limit));
	    	$pagelist = $p->pageList($this->f->util->ForceInt($_GET['page'], 1), $pages, $albumid);
		}
		else {
			$this->images = $this->f->conn->query($this->get_album_images($albumid));
			$count = count($this->images);
		}
		if($this->f->conn->query($this->is_parent($albumid), 'index')==1) {
			$this->children = $this->f->conn->query($this->get_children_by_parentID($albumid));
			if(!empty($this->children)) {
				echo "<h2>Sub Categories in this Category:</h2>\n";
				for ($i=0; $i<count($this->children); $i++) {
					echo "<a href=\"view_album.php?albumID=".$this->children[$i]['albumID']."\" title=\"View images in the category '".$this->children[$i][album_name]."'\">".$this->children[$i][album_name]."</a>&nbsp;&nbsp;";
				}
			}
		}
		else {
			$siblings = $this->f->conn->query($this->get_siblings($albumid));
			if(!empty($siblings)) {
				echo "<h2>Other albums in this Category:</h2>\n";
				for ($i=0; $i<count($siblings); $i++) {
					echo "<a href=\"view_album.php?albumID=".$siblings[$i]['albumID']."\" title=\"View images in the category '".$siblings[$i]['album_name']."'\">".$siblings[$i]['album_name']."</a>&nbsp;&nbsp;";
				}
			}
		}
		echo "\n\n<h1>$this->album_name (".$count." images)</h1>\n";
		if(count($this->images) > 0) {
			echo @$pagelist;
			for ($i=0; $i<count($this->images); $i++) {
				echo "\n<div class=\"thumb\">\n";
				if(file_exists($this->site_path.$this->img_dir."tn_".$this->images[$i]['image_url'])) {
					$thumb_size = GetImageSize($this->site_path.$this->img_dir."tn_".$this->images[$i]['image_url']);
		  			$thumb_width = $thumb_size[0];
		  			$thumb_height = $thumb_size[1];
		  			$size = GetImageSize($this->site_path.$this->img_dir.$this->images[$i]['image_url']);
		  			$width = $size[0];
		  			$height = $size[1];
					echo "<a href=\"popup.php?albumID=".$albumid."&amp;imageID=".$this->images[$i]['imageID']."\" onclick=\"window.open(this.href, '_blank', 'resizable=1, location=0, toolbar=0, scrollbars=0, height=".($height+155).", width=".$width."'); return false;\" title=\"View a larger picture of ".$this->images[$i]['caption']." in a popup window\">\n";
		      		echo "<img src=\"".$this->site_url.$this->img_dir."tn_".$this->images[$i]['image_url']."\" width=\"".$thumb_width."\" height=\"".$thumb_height."\" alt=\"".$this->images[$i]['caption']."\" /></a><br />\n";
					echo "<a href=\"popup.php?albumID=".$albumid."&amp;imageID=".$this->images[$i]['imageID']."\" onclick=\"window.open(this.href, '_blank', 'resizable=1, location=0, toolbar=0, scrollbars=0, height=".($height+155).", width=".$width."'); return false;\" title=\"View a larger picture of ".$this->images[$i]['caption']." in a popup window\">\n";
		      		echo $this->images[$i][caption]."</a>\n";
			    }
				else {
					echo "<img src=\"".$this->site_url.$this->img_dir."nophoto.gif\" alt=\"Photo unavailable\" />\n\n";
				}
				echo "</div>\n";
			}
			echo @$pagelist;
			echo '<div style="clear: both;"><p style="text-align: center; font-weight:bold; color: #ccc;">Powered by <a style="font-weight:bold; color: #ccc;" href="http://www.outofthetrees.co.uk/" title="Powered by SelectaPix">SelectaPix</a></p></div>';
		}
		else {
			echo "<p class=\"center\">There are no photos in this category</p>\n";
		}
	}

	function get_album_descr($albumID) {
		return $this->sql = "SELECT album_descr
				   	  		 FROM $this->album_table
				      		 WHERE albumid = ".$this->f->util->ForceInt($albumID, 0);
	}
}
?>
Return current item: SelectaPix Image Gallery