Location: PHPKode > projects > Kwalbum > kwalbum/pages/NewPage.php
<?php
/**
 * @version 2.2
 * @since 2.1.3 2009-02-19
 * @package kwalbum
 */
require_once 'include/IPage.php';

class NewPage implements IPage
{
	private $IPI, $title;
	private $numMonths;

	function NewPage()
	{
		global $URLP, $DB;
		if (empty($_GET['n']))
			$_GET['n'] = 1;
		$URLP->SetOrderByField('ItemAddedTs');
		$URLP->SetOrderByDirection('DESC');
		$URLP->SetExtendedURL($URLP->GetExtendedURL().'p=New&amp;');

		if (0 < (int)$_GET['i'])
		{
			require_once 'include/funcGetImageCode.php';
			session_start();
			$count_it = true;
			$id = $URLP->GetId();
			if (isset($_SESSION['itemids']))
			{
				$temp = explode(',', $_SESSION['itemids']);
				foreach($temp as $temp_id)
					if ($temp_id == $id)
					{
						$count_it = false;
						break;
					}
			}
			else
				$_SESSION['itemids'] = '';
			if ($count_it)
			{
				$DB->UpdateSingle(ITEM_TABLE, 'ItemCount', 'ItemCount+1', "ItemId=$id");
				$_SESSION['itemids'] .= ','.$id;
			}
			session_write_close();
		}
	}

	function GetHead(&$title)
	{
		global $URLP, $DB;
		$this->numMonths = (int)$_GET['months'];
		if ($this->numMonths < 1)
			$this->numMonths = 3;
		$URLP->SetWhereQuery($URLP->GetWhereQuery(false).' AND ItemAddedTs > DATE_SUB(NOW(), INTERVAL '.$this->numMonths.' MONTH)');
		$this->title = $URLP->GetTitle().': Newly Added Pictures';

		if (0 < (int)$_GET['i'])
		{
			require 'include/ItemPageInfo.php';
			if (!$this->IPI = new ItemPageInfo($this->title, $URLP))
				return null;
			return $this->IPI->GetHeader();
		}
		return '';
	}

	function ShowBody()
	{
		global $DB, $URLP;

		if (0 < (int)$_GET['i'])
		{
			$IPI = $this->IPI;
			$id = $IPI->id;
			$currentURL = $extendedURL = $URLP->GetExtendedURL();
			$favSpan = "<span id='addFavorite'><a href='' onClick='return AddFavorite($id);'?>Add to Favorites</a></span>";
			require 'ItemPage.html.php';
		}
		else
		{
			$title = $this->title;
			$subtitle = ' from the last '.$this->numMonths.' months (sorted with newest pictures first)';
			$query = $URLP->GetThumbnailQuery();
			$result = $DB->query($query);

			$prevLinks = $URLP->GetPrevPageLink();
			$pageNumber = $URLP->GetPageNumber();
			$pageNumberLinks = $URLP->GetPageNumberLinks();
			$nextPageLinks = $URLP->GetNextPageLink();
			$DB->Close();

			$numRows = $URLP->numRows;
			$numColumns = $URLP->numColumns;
			$extendedURL = $URLP->GetExtendedURL();
			require 'ThumbnailsPage.html.php';
		}
	}
}
Return current item: Kwalbum