<?php
/**
Xcomic
$Id: NewsDisplay.class.php,v 1.6.2.1.2.1 2005/07/22 01:49:07 mikexstudios Exp $
*/
/*
define('IN_XCOMIC', true);
$xcomicRootPath='../';
include_once($xcomicRootPath.'initialize.php');
*/
//$xcomicRootPath is defined in the file that includes this file
//Unfortunately, for sites with register_globals turned on, this poses
//a security theat--especially since $xcomicRootPath is being used in include
//statements. Therefore, check for hacking attempts
if ( !defined('IN_XCOMIC') )
{
die("Hacking attempt");
}
class NewsDisplay {
var $newsInfo; //Latest news info
var $id; //Holds current Id
function NewsDisplay($inId=NULL) {
if($inId!=NULL)
{
$this->id = $inId;
$this->getNewsInfo($inId);
}
}
function queryNewsInfo($inId, $idOperator='=', $inOrderBy='') {
global $xcomicDb, $message;
$sql = 'SELECT id, title, date, username, content
FROM '.XCOMIC_NEWS_TABLE."
WHERE id $idOperator $inId
ORDER BY id $inOrderBy";
# Removal of SQL error display. Switched to slient SQL execution.
# Fix by Tom Parkison (hide@address.com
$result = $xcomicDb->sql_query($sql);
//Make the changes happen
if($xcomicDb->sql_numrows() != 0)
{
return $xcomicDb->sql_fetchrow($result);
}
}
function getNewsInfo($inId) {
//Set this to current comic id
$this->id = $inId;
$this->newsInfo = $this->queryNewsInfo($this->id);
}
function setCurrentNewsId($inId) {
$this->id = $inId;
}
function nextId($inCategory='default') {
$next = $this->queryNewsInfo($this->id, '>', 'ASC');
$nextId = $next['id'];
if(empty($nextId))
{
//There is no next Id
return false;
}
else
{
return $nextId;
}
}
function prevId($inCategory='default') {
$prev = $this->queryComicInfo($this->id, '<', 'DESC');
$prevId = $prev['id'];
if(empty($prevId))
{
//There is no prev Id
return false;
}
else
{
return $prevId;
}
}
function getId() {
return $this->newsInfo['id'];
}
function getTitle() {
return $this->newsInfo['title'];
}
function getDate() {
return $this->newsInfo['date'];
}
function getUsername() {
return $this->newsInfo['username'];
}
function getContent() {
return $this->newsInfo['content'];
}
}
/*
//Testing NewsDisplay
$x = new NewsDisplay();
$x->getNewsInfo(3);
echo $x->getTitle();
echo $x->getContent();
*/
?>