<?php
/*========================================================*\
||########################################################||
||# #||
||# WB News v2.0.0 #||
||# ---------------------------------------------------- #||
||# Copyright (c) 2004-2008 #||
||# Created: 15th Jan 2008 #||
||# Filename: SendFriend.php #||
||# #||
||########################################################||
/*========================================================*/
/**
* @author $Author: pmcilwaine $
* @version $Id: Archive.php,v 1.1.2.3.2.1 2008/07/14 11:05:24 pmcilwaine Exp $
*/
require_once( $config["installdir"] . "/base/News.php" );
class Archive extends News
{
function Archive()
{
$this->News();
}
/**
* Get a list of months that are archived
*
* @param int $monthLimit the amount of months to list of archive
* @return mixed
*/
function GetArchive( $monthLimit = NULL )
{
if ( $this->config["systemstatus"] )
{
return;
}
$page = isset($_GET["offset"]) ? $this->DB->escape( $_GET["offset"] ) : 0 ;
$archivelist = $this->GetNews( SHOW_NEWS_ARCHIVE, $page, NULL, $monthLimit );
if ( !$archivelist )
{
return;
}
$this->tmpl->SetFilename( BuildPath( "list-archive.ihtml" ) );
$rows =& $this->tmpl->AddParam( "rows", array() );
foreach ( $archivelist as $archive )
{
list( $year, $month ) = explode( "-", $archive["yearmonth"] );
$rows[] = array(
"year" => htmlspecialchars( $year ),
"month" => htmlspecialchars( $month ),
"label" => tz_date( "F, Y", mktime( 0,0,0, $month, 1, $year ) )
);
}
return $this->tmpl->GetHTML();
}
function DisplayNewsArchive()
{
if ( $this->config["systemstatus"] )
{
return;
}
$this->year = intval( $_GET["year"] );
$this->month = intval( $_GET["month"] );
if ( !$this->year || !$this->month )
{
return ;
}
$page = isset($_GET["offset"]) ? $_GET["offset"] : 0 ;
$newslist = $this->GetNews( SHOW_NEWS_ARCHIVE_LIST, $page );
if ( !$newslist )
{
return ;
}
$this->tmpl->SetFilename( BuildPath( "list-news.ihtml" ) );
$rows =& $this->tmpl->AddParam( "rows", array() );
// if we are here means we have some news
foreach ( $newslist as $news )
{
$avatar = FALSE;
if ( $news["avatar_name"] )
{
$path = str_replace( $_SERVER['DOCUMENT_ROOT'], "", $this->config['installdir'] );
$avatar = 'http://' . $_SERVER['HTTP_HOST'] . $path . "/avatar/" . $news["avatar_name"];
}
else if ( $news["avatar_url"] )
{
$avatar = $news["avatar_url"];
}
list( $y, $m, $d, $h, $i, $s ) = split("[-: ]", $news["ts"] );
$rows[] = array(
"newsid" => $news["id"],
"postname" => htmlspecialchars( $news["postname"] ),
"title" => filter( $news["title"] ),
"date" => tz_date( $this->config["dateFormat"], mktime( $h, $i, $s, $m, $d, $y ) ),
"news" => filter( $news["news"] ),
"allowcomments" => $news["allowcomments"],
"comments" => $this->CountComments( $news["id"] ),
"avatar" => $avatar
);
}
return $this->tmpl->GetHTML();
}
}
return;
?>