Location: PHPKode > scripts > SelectaPix Image Gallery > classes/album.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 album extends admin_page {
	var $f;

	function album($f) {
		$this->f =& $f;
		$this->admin_page($this->f);
		$this->get_temp_albumID();
	}

	function get_parent_albums() {
		return $this->sql = "SELECT * FROM $this->album_table WHERE parent_albumID = 0 ORDER BY albumID ASC";
	}

	function get_parent_album_count($albumID) {
		$albumID = $this->f->util->ForceInt($albumID, 0);
		return $this->sql = "SELECT COUNT(albumID) FROM $this->album_table WHERE parent_albumID = '$albumID'";
	}

	function get_temp_albumID() {
		if(!$this->temp_albumID) {
			$temp_albumID = $this->f->conn->query("SELECT albumID FROM $this->album_table WHERE album_name = 'upload_temp'", 'index');
			$this->set_temp_albumID($temp_albumID);
			return $this->temp_albumID;
		}
		else {
			return $this->temp_albumID;
		}
	}

	function set_temp_albumID($albumID) {
		$albumID = $this->f->util->ForceInt($albumID, 0);
		$this->temp_albumID = $albumID;
	}

	function get_sub_albums($parentID) {
	    $parentID = $this->f->util->ForceInt($parentID, 0);
		return $this->sql = "SELECT * FROM $this->album_table WHERE parent_albumID = '$parentID' ORDER BY albumID ASC";
	}

	function get_subalbum_count($albumID) {
		$albumID = $this->f->util->ForceInt($albumID, 0);
		return $this->sql = "SELECT COUNT(albumID)
	                         FROM $this->album_table
	                         WHERE parent_albumID = '$albumID'";
	}

	function check_if_album_is_active($albumID) {
		$albumID = $this->f->util->ForceInt($albumID, 0);
		return $this->sql = "SELECT active FROM $this->album_table WHERE albumID = '$albumID'";
	}

	function get_album_name($albumID) {
		$albumID = $this->f->util->ForceInt($albumID, 0);
		return $this->sql = "SELECT album_name FROM $this->album_table WHERE albumID = '$albumID'";
	}

	function get_albumID_by_name($album_name) {
		$album_name = $this->f->util->FormatStringForDatabaseInput($album_name, 1);
		return $this->sql = "SELECT albumID FROM $this->album_table WHERE album_name = '$album_name'";
	}

	function check_album_name_exists($album_name) {
		$album_name = $this->f->util->FormatStringForDatabaseInput($album_name, 1);
		return $this->sql = "SELECT DISTINCT album_name FROM $this->album_table WHERE album_name LIKE '%$album_name%' LIMIT 1";
	}

	function get_album_info($albumID) {
		$albumID = $this->f->util->ForceInt($albumID, 0);
		return $this->sql = "SELECT * FROM $this->album_table WHERE albumID = '$albumID'";
	}

	function update_album_status($action, $albumID) {
		$albumID = $this->f->util->ForceInt($albumID, 0);
		if($action=='enable_album') {
			$sql = "UPDATE $this->album_table SET active = 'yes' WHERE albumID = '$albumID'";
		}
		if($action=='disable_album') {
			$sql = "UPDATE $this->album_table SET active = 'no' WHERE albumID = '$albumID'";
		}
		$this->f->conn->query($sql, 'none');
		if(!$this->f->conn->result) {
		    if($action=='enable_album') {
		    	return '<p class="badnews">Album could not be set to active, please try again later.</p>';
		    }
		    if($action=='disable_album') {
		    	return '<p class="badnews">Album could not be set to disabled, please try again later.</p>';
		    }
		}
		else {
		    if($action=='enable_album') {
		    	return '<p class="goodnews">Album is now active.</p>';
		    }
		    if($action=='disable_album') {
		    	return '<p class="goodnews">Album is now disabled.</p>';
		    }
		}
	}

	function update_album() {
	    $this->albumID = $this->f->util->ForceInt($_POST['albumID'], 0);
		$this->album_name = $this->f->util->FormatStringForDatabaseInput($_POST['album_name'], 1);
		$this->album_descr = $this->f->util->FormatStringForDatabaseInput($_POST['album_descr'], 1);
		$this->f->conn->query("UPDATE $this->album_table
		              SET album_name = '$this->album_name',
		              album_descr = '$this->album_descr'
		              WHERE albumID = '$this->albumID'", 'none');
		if(!$this->f->conn->result) {
		   	return '<p class="badnews">Could not update Album, please try again later.</p>';
		}
		else {
		    return '<p class="goodnews">Album updated.</p>';
		}
	}

	function add_album($parent_albumID=0) {
		$parent_albumID = $this->f->util->ForceInt($parent_albumID, 0);
		$album_name = $this->f->util->FormatStringForDatabaseInput($_POST['album_name'], 1);
		$album_descr = $this->f->util->FormatStringForDatabaseInput($_POST['album_descr'], 1);

		$this->f->conn->query("INSERT INTO $this->album_table (album_name, album_descr, parent_albumID)
		          	  		   VALUES ('$album_name', '$album_descr', '$parent_albumID')", 'none');
		if(!$this->f->conn->result) {
		  	return '<p class="badnews">Could not create Album, please try again later.</p>';
		}
		else {
		    return "<p class=\"goodnews\">New Album &#8212; <strong>".$album_name."</strong> &#8212; created.</p>";
		}
	}

	function delete_album() {
		$this->albumID = $this->f->util->ForceInt($_POST['albumID'], 0);
		//First return the Album (and sub albums) that are to be deleted
		$row = $this->f->conn->query("SELECT albumID
								      FROM $this->album_table
								      WHERE albumID = '$this->albumID'
								      OR parent_albumID = '$this->albumID'
								      ORDER BY albumID DESC");
		for ($n=0; $n<count($row); $n++) {
		    $this->albumID = $row[$n]['albumID'];
		    //Return the name of the album before it's deleted
		    $this->album_name = $this->f->conn->query("SELECT album_name
						                   	  			FROM $this->album_table
						                      			WHERE albumID = '$this->albumID'", 'index');
		    //Next return resultset for images in requested album - we'll be deleting these later
		    $this->images = $this->f->conn->query("SELECT i.image_url, i.caption, c.album_name
					                      			FROM $this->image_table as i, $this->album_table as a
								                    WHERE a.albumID = '$this->albumID'
								                    AND i.albumID = a.albumID");
		    if(!empty($this->images)) {
			    //Delete the images from their physical location
			    echo '<p class="goodnews"><strong>Deleting images...</strong></p>';
			    for ($i=0; $i<count($this->images); $i++) {
			    	$this->image = $this->images[$i][image_url];
			        $this->caption = $this->images[$i][caption];
			        if(file_exists($this->site_path.$this->img_dir.$this->image)) {
				    	if(@unlink($this->site_path.$this->img_dir.$this->image)) {
				            $this->news .= "<p class=\"goodnews\">".$this->image." &#8212; image deleted</p>";
				        }
				        else {
					        $this->news .= "<p class=\"badnews\">".$this->image." &#8212; image could not be deleted!</p>";
					    }
				    }
				    else {
				        $this->news .= "<p class=\"badnews\">No image was found for ".$this->caption."</p>";
				    }
			        if(file_exists($this->site_path.$this->img_dir."tn_".$this->image)) {
						if(@unlink($this->site_path.$this->img_dir."tn_".$this->image)) {
				            $this->news .= "tn_".$this->image." &#8212; thumbnail deleted</p>";
				        }
				        else {
					        $this->news .= "<p class=\"badnews\">".$this->image." &#8212; image could not be deleted!</p>";
					    }
				    }
				    else {
				    	$this->news .= "<p class=\"badnews\">No thumbnail image was found for ".$this->caption."</p>";
				    }
			        echo $this->news;
			    }
		    }

		    //Next try to delete images from the Album
		    $this->res1 = $this->f->conn->query("DELETE FROM $this->image_table
		                  				         WHERE albumID = '$albumID'");
		    $this->num_images = $this->f->conn->getNumRows();

			//Now delete the album only if images successfully deleted
		    //or no images found
		    if(($this->num_images == 0) && ($this->albumID != $this->temp_albumID)) {
		    	$this->res2 = $this->f->conn->query("DELETE FROM $this->album_table
		                      						 WHERE albumID = '$this->albumID'", 'none');
		    }
		    if($this->albumID == $this->temp_albumID) {
		        echo '<p class="badnews">You may not delete this Album&#8212;it is required by the system.</p>';
		    }
		    elseif(!$this->res1 && ($this->num_images != 0)) {
		        echo '<p class="badnews">Could not delete images from Album, please try again later.</p>';
		    }
		    elseif ($this->res2 && $this->num_images == 0) {
		    	echo '<p class="goodnews"><strong>Album <em>"'.$this->album_name.'"</em> deleted</strong> (it contained no images)</p>';
		    }
		    elseif (!$this->res2) {
		   		echo '<p class="badnews"><strong>Could not delete Album</strong>, please try again later.</p>';
		    }
		    else {
		        echo "<p class=\"goodnews\"><strong>Album: <em>\"".$this->album_name."\"</em> &amp; <em>".$this->num_images." image(s)</em> deleted.</strong></p>";
		    }
		}
		echo '<p class="centreform"><a href="gallery.php">Return to the View albums page</a>.</p>';
		do_html_footer('6');
		exit;
	}

	function album_overview($news='') {
		$img = $this->f->objectBuilder->NewFrameworkObject($this->f, "image");
	    echo @$news;
	    echo "\n<h2>Current image albums</h2>\n";
	    echo '<div class="iecentrehack">';
	    echo "\n<table summary=\"Summary of current image albums\">\n";
	    echo "<tr>\n\t<th class=\"tdleft\">album</th>\n\t<th>Images</th>\n\t<th>sub-albums</th>\n\t<th>Images</th>\n\t<th>Edit album<br />&amp; images</th>\n\t<th>Delete album<br />&amp; images</th>\n\t<th>Status</th>\n</tr>\n";
		$row = $this->f->conn->query($this->get_parent_albums());
		if(!is_array($row)) {
			echo "<tr>\n\t<td colspan=\"7\">You have not created any albums. Use the form below to create one.</td>\n</tr>\n";
		}
	    for ($i=0; $i<count($row); $i++) {
	    	echo '<tr>';
	        echo "\n\t<td class=\"tdleft\" title=\"View or edit sub-albums and images in this album\" onmouseover=\"return showStatus('View or edit sub-albums and images in this album')\" onmouseout=\"return clearStatus()\"><a href=\"edit_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=0\">";
	        echo $row[$i]["album_name"];
	        echo '</a></td>';
	        $img_total = $this->f->conn->query($img->get_image_count($row[$i]['albumID']), 'index');
	        echo "\n\t<td title=\"There are ".$img_total." images in this album\">";
	        if($img_total > 0) {
	            echo $img_total;
	        }
	        else {
	            echo 'empty';
	        }
	        echo '</td>';
	        $album_total = $this->f->conn->query($this->get_subalbum_count($row[$i]['albumID']), 'index');
	        echo "\n\t<td title=\"There are ".$album_total." sub-albums in this album\">";
	        if($album_total > 0) {
	            echo $album_total;
	        }
	        else {
	            echo 'none';
	        }
	        echo '</td>';
	        $img_total = $this->f->conn->query($img->get_subalbum_image_count($row[$i]['albumID']), 'index');
	        echo "\n\t<td title=\"There are ".$img_total." images in this album\">";
	        if($img_total > 0) {
	            echo $img_total;
	        }
	        else {
	            echo 'empty';
	        }
	        echo '</td>';
	        echo "\n\t<td title=\"View or edit this album\" onmouseover=\"return showStatus('View or edit the images and sub-albums in this album')\" onmouseout=\"return clearStatus()\"><a href=\"edit_album.php?albumID=".$row[$i]["albumID"]."\">";
	        echo "<img src=\"images/view_album_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"Edit ".$row[$i]["album_name"]."\" /></a>";
	        echo " <a href=\"edit_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=0\">View/Edit album</a></td>";
	        echo "\n\t<td title=\"Delete ".$row[$i]["album_name"]." album and any images in it\" onmouseover=\"return showStatus('Delete this album and any images in it')\" onmouseout=\"return clearStatus()\"><a href=\"delete_album.php?albumID=".$row[$i]["albumID"]."\">";
	        echo "<img src=\"images/delete_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"Delete ".$row[$i]["album_name"]."\" /></a>";
	        echo " <a href=\"delete_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=0\">Delete</a></td>\n";
	        $active = $this->f->conn->query($this->check_if_album_is_active($row[$i]["albumID"]), 'index');
	        if($active=='yes') {
	        	echo "\n\t<td title=\"".$row[$i]["album_name"]." is currently active\" onmouseover=\"return showStatus('".str_replace("'", "", $row[$i]["album_name"])." is currently active')\" onmouseout=\"return clearStatus()\">\n";
	        	echo "<img src=\"images/go_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"".$row[$i]["album_name"]." is currently active\" style=\"margin-right: 10px;\" />";
	        	echo "<a href=\"".$_SERVER['PHP_SELF']."?action=disable_album&amp;target=".$row[$i]["albumID"]."\" title=\"Disable this album\">Disable</a></td>\n</tr>\n";
	        }
	        elseif($active=='no') {
	        	echo "\n\t<td title=\"".$row[$i]["album_name"]." is currently disabled\" onmouseover=\"return showStatus('".str_replace("'", "", $row[$i]["album_name"])." is currently disabled')\" onmouseout=\"return clearStatus()\">\n";
	        	echo "<img src=\"images/stop_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"".$row[$i]["album_name"]." is currently disabled\" style=\"margin-right: 10px;\" />";
	        	echo "<a href=\"".$_SERVER['PHP_SELF']."?action=enable_album&amp;target=".$row[$i]["albumID"]."\" title=\"Disable this album\">Enable</a></td>\n</tr>\n";
	        }
	    }
	    echo "</table>\n</div>\n\n";
	}

	function list_sub_albums($news = '') {
		$img = $this->f->objectBuilder->NewFrameworkObject($this->f, "image");
	    @$this->albumID = $this->f->util->ForceInt($_REQUEST['albumID'], 0);
	    @$this->parentID = $this->f->util->ForceInt($_REQUEST['parentID'], 0);
	    $this->album_name = $this->f->conn->query($this->get_album_name($this->albumID), 'index');
		if($this->parentID == 0) {
			echo "<div id=\"breadcrumbtrail\">\n<a href=\"member.php\">";
	        echo 'Main Admin Area</a> &gt;&gt; <a href="gallery.php">Albums</a>';
	        echo "&nbsp;&gt;&gt;&nbsp;Edit an album</div>\n\n";
	        $this->upload_links($this->albumID, $this->parentID);
		    if(!$this->album_name) {
		        echo '<p class="badnews">Could not find that album! Please try again.</p>';
		        exit;
		    }
		    echo @$news;
		    echo "<h2>Current sub-albums for <strong>'$this->album_name'</strong></h2>";
		    echo "\n<div class=\"iecentrehack\">\n";
		    echo '<table summary="Summary of current image sub-albums">';
		    echo "\n<tr>\n\t<th class=\"tdleft\">Sub album</th>\n\t<th>images</th>\n\t<th>Edit album<br />&amp; images</th>\n\t<th>Delete album<br />&amp; Images</th>\n\t<th>Status</th>\n</tr>\n";

		    $row = $this->f->conn->query($this->get_sub_albums($this->albumID));
		    $nrOfSubalbums = count($row);
		    if($nrOfSubalbums == 0) {
		        echo "\n<tr>\n\t<td colspan=\"7\">You have not created any sub-albums. Use the form below to create one.</td>\n</tr>\n";
		    }
		    for ($i=0; $i<$nrOfSubalbums; $i++) {
		       	$image_total = $this->f->conn->query($img->get_image_count($row[$i]['albumID']), 'index');
		       	echo '<tr>';
		        echo "\n\t<td class=\"tdleft\" title=\"View sub-albums or edit this album\"><a href=\"edit_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=".$this->albumID."\" onmouseover=\"return showStatus('View or edit the images in this album')\" onmouseout=\"return clearStatus()\">";
		        echo $row[$i]["album_name"];
		        echo '</a></td>';
		        echo "\n\t<td title=\"There are ".$image_total." images in this album\">";
		        if($image_total > 0) {
		            echo $image_total;
		        }
		        else {
		            echo '<p>empty</p>';
		        }
		        echo '</td>';

		        echo "\n\t<td title=\"View or edit this album\" onmouseover=\"return showStatus('View or edit the images in this album')\" onmouseout=\"return clearStatus()\"><a href=\"edit_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=".$this->albumID."\">";
		        echo "<img src=\"images/view_album_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"Edit ".$row[$i]["album_name"]."\" /></a>";
		        echo " <a href=\"edit_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=".$this->albumID."\">View/Edit album</a></td>";
		        echo "\n\t<td title=\"Delete this album and any images in it\" onmouseover=\"return showStatus('Delete this album and any images in it')\" onmouseout=\"return clearStatus()\"><a href=\"delete_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=".$this->albumID."\">";
		        echo "<img src=\"images/delete_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"Delete ".$row[$i]["album_name"]."\" /></a>";
		        echo " <a href=\"delete_album.php?albumID=".$row[$i]["albumID"]."&amp;parentID=".$this->albumID."\">Delete</a></td>\n";
		    	$active = $this->f->conn->query($this->check_if_album_is_active($row[$i]['albumID']), 'index');
		        if($active=='yes') {
		        	echo "\n\t<td title=\"".$row[$i]["album_name"]." is currently active\" onmouseover=\"return showStatus('".str_replace("'", "", $row[$i]["album_name"])." is currently active')\" onmouseout=\"return clearStatus()\">\n";
		        	echo "<img src=\"images/go_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"".$row[$i]["album_name"]." is currently active\" style=\"margin-right: 10px;\" />";
		        	echo "<a href=\"".$_SERVER['PHP_SELF']."?action=disable_album&amp;target=".$row[$i]["albumID"]."&amp;albumID=".$this->albumID."\" title=\"Disable this album\">Disable</a></td>\n</tr>\n";
		        }
		        elseif($active=='no') {
		        	echo "\n\t<td title=\"".$row[$i]["album_name"]." is currently disabled\" onmouseover=\"return showStatus('".str_replace("'", "", $row[$i]["album_name"])." is currently disabled')\" onmouseout=\"return clearStatus()\">\n";
		        	echo "<img src=\"images/stop_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"".$row[$i]["album_name"]." is currently disabled\" style=\"margin-right: 10px;\" />";
		        	echo "<a href=\"".$_SERVER['PHP_SELF']."?action=enable_album&amp;target=".$row[$i]["albumID"]."&amp;albumID=".$this->albumID."\" title=\"Enable this album\">Enable</a></td>\n</tr>\n";
		        }
		    }
		    echo "\n</table>\n</div>\n\n";
			display_new_sub_album_form($this->albumID);
		}
		else {
			echo "<div id=\"breadcrumbtrail\">\n<a href=\"member.php\">";
	        echo 'Main Admin Area</a> &gt;&gt; <a href="gallery.php">Albums</a>';
	        echo " &gt;&gt; <a href=\"edit_album.php?albumID=".$this->parentID."&amp;parentID=0\">Edit an album</a> &gt;&gt; Edit a sub-album</div>\n\n";
	        $this->upload_links($this->albumID, $this->parentID);
	        echo @$news;
		}
		echo "\n<h2>Current images in <strong>'$this->album_name'</strong></h2>\n";
	    $row = $this->f->conn->query($img->get_image_info($this->albumID));
	    if(!empty($row)) {
		    $parentID = $_REQUEST['parentID'];
		    for ($i=0; $i<count($row); $i++) {
		        echo "<div class=\"thumb\">\n";
		        echo '<a title="Edit the details of this image" href="edit_image.php?imageID=';
		        echo $row[$i]['imageID']."&amp;parentID=".$parentID."&amp;albumID=".$this->albumID."\">";
		        if(file_exists($this->site_path.$this->img_dir.'tn_'.$row[$i]['image_url'])) {
				    $size = GetImageSize($this->site_path.$this->img_dir.'tn_'.$row[$i]['image_url']);
			  		$width = $size[0];
			  		$height = $size[1];
					echo "<img src=\"".$this->site_url.$this->img_dir."tn_";
		        	echo $row[$i]['image_url'];
		        	echo "\" width=\"".$width."\" height=\"".$height;
		        	echo "\" alt=\"".$row[$i]['caption']."\" /></a>\n";
			    }
			    else {
			    	echo "\n<img src=\"".$this->site_url.$this->img_dir."nophoto.gif\" alt=\"Photo unavailable\" /></a>\n";
			    }
		        echo "<div class=\"wrapper\">\n";
		        echo '<a title="Edit the details of this image" href="edit_image.php?imageID=';
		        echo $row[$i]['imageID']."&amp;parentID=".$parentID."&amp;albumID=".$this->albumID."\"><img src=\"images/view_edit_image_small.gif\" width=\"24\" height=\"24\" alt=\"Edit image\" /> Edit image</a><br />\n";
		        echo '<a title="Permanently remove this image" href="delete_image.php?imageID=';
		        echo $row[$i]['imageID']."&amp;parentID=".$parentID."&amp;albumID=".$this->albumID."\"><img src=\"images/delete_small.gif\" width=\"24\" height=\"24\" alt=\"Delete image\" /> Delete image</a><br />\n";

		        $active = $this->f->conn->query($img->check_if_image_is_active($row[$i]['imageID']), 'index');
		        if($active=='yes') {
		        	echo "<img src=\"images/go_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"".$row[$i]['caption']." is currently active\" style=\"margin-right: 10px;\" />";
		        	echo "<a href=\"".$_SERVER['PHP_SELF']."?action=disable_image&amp;target=".$row[$i]['imageID']."&amp;parentID=".$parentID."&amp;albumID=".$this->albumID."\" title=\"Disable this album\">Disable image</a>\n</div>\n</div>\n\n";
		        }
		        elseif($active=='no') {
		        	echo "<img src=\"images/stop_small.gif\" class=\"small_nav\" width=\"24\" height=\"24\" alt=\"".$row[$i]['caption']." is currently disabled\" style=\"margin-right: 10px;\" />";
		        	echo "<a href=\"".$_SERVER['PHP_SELF']."?action=enable_image&amp;target=".$row[$i]['imageID']."&amp;parentID=".$parentID."&amp;albumID=".$this->albumID."\" title=\"Enable this album\">Enable image</a>\n</div>\n</div>\n";
		        }
		    }
	    }
	    else {
	    	echo "\n<p style=\"text-align: center;\">This album does not contain any images</p>\n";
	    }
	    $album_info = $this->f->conn->query($this->get_album_info($this->albumID));
	    display_update_album_form($this->albumID, $this->parentID, $album_info[0][album_name], $album_info[0][album_descr]);
	}

	function confirm_delete_album() {
		$this->albumID = $this->f->util->ForceInt($_REQUEST[albumID], 0);
	    $this->parentID = $this->f->util->ForceInt($_REQUEST[parentID], 0);
	    echo '<div class="margins">';
	    $album_info = $this->f->conn->query($this->get_album_info($this->albumID));
	    if(empty($album_info)) {
	        echo '<p class="badnews">Could not find any albums</p>';
	        echo '</div>';
	        exit;
	    }
	    for($i=0; $i<count($album_info); $i++) {
		    echo "<h2 class=\"edit\">You are about to delete <em>".$album_info[$i]['album_name']."</em>.</h2>\n";
		    echo '<div class="iecentrehack">';
		    echo "\n<form action=\"delete_album.php?albumID=".$album_info[$i]['albumID']."&amp;parentID=".$this->parentID."\" method=\"post\" class=\"centreform\">\n<div class=\"formrow\">";
		    echo "\n<input type=\"hidden\" name=\"albumID\" value=\"".$album_info[$i]['albumID']."\" />\n";
		    echo "\n<input type=\"hidden\" name=\"parentID\" value=\"".$this->parentID."\" />\n";
		    echo "<strong>This will also delete any sub-albums and any images they contain.</strong>\n</div>\n";
		    echo "<div class=\"formrow\">Are you <em>sure</em> you want to delete this album?</div>\n";
		    echo '<div class="formrow"><input type="submit" class="warning" name="delete_album" value="Delete" />';
		    echo '<input type="hidden" name="delete_album" value="true" /></div>';
		    echo "\n</form>\n";
		    echo "<p class=\"centreform\"><a href=\"edit_album.php?albumID=".$album_info[$i]['albumID']."&amp;parentID=".$this->parentID."\">Don't make any changes</a></p>\n</div>\n\n";

		    $img = $this->f->objectBuilder->NewFrameworkObject($this->f, 'image');
		    $image_info = $this->f->conn->query($img->get_image_info($album_info[$i]['albumID']));
		    for($ii=0; $ii<count($image_info); $ii++) {
		        echo '<div class="thumb">';
			    if(file_exists($this->site_path.$this->img_dir.'tn_'.$image_info[$ii]['image_url'])) {
			        $size = GetImageSize($this->site_path.$this->img_dir.'tn_'.$image_info[$ii]['image_url']);
		  			$width = $size[0];
		  			$height = $size[1];
					echo "\n<img src=\"".$this->site_url.$this->img_dir;
			        echo "tn_".$image_info[$ii]['image_url'];
			        echo "\" width=\"$width\" height=\"";
			        echo $height."\" alt=\"".$image_info[$ii]['caption']."\" />";
		        }
		        else {
		        	echo "\n<img src=\"".$this->site_url."/assets/nophoto.gif\" alt=\"Photo unavailable\" />";
		        }
		        echo "<br />\n</div>\n\n";
		    }
		}
		if(!is_array($image_info)) {
			echo '<div class="empty">There are no images in this album.</div>';
		}
		echo '</div>';
	}
}
?>
Return current item: SelectaPix Image Gallery