<?php
/**
* @version 2.2
* @since 2.1.3 2009-02-24
* @package kwalbum
*/
require_once 'include/IPage.php';
class PopularPage implements IPage
{
private $IPI, $title;
function PopularPage()
{
global $URLP, $DB;
if (empty($_GET['n']))
$_GET['n'] = 1;
$URLP->SetOrderByField('ItemCount');
$URLP->SetOrderByDirection('DESC');
$URLP->SetExtendedURL($URLP->GetExtendedURL().'p=Popular&');
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->title = $URLP->GetTitle().': Popular 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 = '(sorted with most popular 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';
}
}
}