1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Bugtracker #3662, #3886 - nextprev on day, month, 2-column news sorted.

This commit is contained in:
e107steved
2007-06-07 20:34:02 +00:00
parent 75e61bb9f4
commit 8e25b97b1f

289
news.php
View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/news.php,v $ | $Source: /cvs_backup/e107_0.8/news.php,v $
| $Revision: 1.6 $ | $Revision: 1.7 $
| $Date: 2007-05-21 19:18:40 $ | $Date: 2007-06-07 20:34:02 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -21,60 +21,87 @@ require_once(e_HANDLER."news_class.php");
require_once(e_HANDLER."comment_class.php"); require_once(e_HANDLER."comment_class.php");
$cobj = new comment; $cobj = new comment;
if (isset($NEWSHEADER)) { if (isset($NEWSHEADER))
{
require_once(HEADERF); require_once(HEADERF);
require_once(FOOTERF); require_once(FOOTERF);
exit; exit;
} }
$cacheString = 'news.php_'.e_QUERY; $cacheString = 'news.php_'.e_QUERY;
$action = ''; $action = '';
if (!defined("ITEMVIEW")){ $sub_action = '';
if ($pref['newsposts']==""){ $order = "news_datestamp";
define("ITEMVIEW", 15); $newsfrom = 0;
} else {
define("ITEMVIEW", $pref['newsposts']); if (!defined("ITEMVIEW"))
} {
define("ITEMVIEW", varset($pref['newsposts'],15));
} }
if (e_QUERY) { if (e_QUERY)
{
$tmp = explode(".", e_QUERY); $tmp = explode(".", e_QUERY);
$action = $tmp[0]; $action = $tmp[0]; // At least one parameter here
$sub_action = $tmp[1]; $sub_action = varset($tmp[1],''); // Usually a numeric category, but don't presume yet
$id = $tmp[2]; $id = varset($tmp[2],''); // ID of specific news item where required
$newsfrom = intval(varset($tmp[2],0)); // Item number for first item on multi-page lists
} }
$newsfrom = (!is_numeric($action) || !e_QUERY ? 0 : ($action ? $action : e_QUERY)); //$newsfrom = (!is_numeric($action) || !e_QUERY ? 0 : ($action ? $action : e_QUERY));
if (isset($tmp[1]) && $tmp[1] == 'list') {
$action = 'list'; // Usually the first query parameter is the action.
$newsfrom = intval($tmp[0]); // For any of the 'list' modes (inc month, day), the action being second is a legacy situation
$sub_action = intval($tmp[2]); // .... which can hopefully go sometime
if (is_numeric($action) && isset($tmp[1]) && (($tmp[1] == 'list') || ($tmp[1] == 'month') || ($tmp[1] == 'day')))
{
$action = $tmp[1];
$sub_action = varset($tmp[0],'');
} }
if ($action == 'all' || $action == 'cat') {
$newsfrom = intval($tmp[2]);
$sub_action = intval($tmp[1]);
if ($action == 'all' || $action == 'cat')
{
$sub_action = intval(varset($tmp[1],0));
} }
/*
Variables Used:
$action - the basic display format/filter
$sub_action - category number or news item number
$newsfrom - first item number in list (default 0) - derived from nextprev
$order - sets the listing order for 'list' format
*/
$ix = new news; $ix = new news;
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'"; $nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
if ($action == 'cat' || $action == 'all'){
// --> Cache //------------------------------------------------------
if($tmp = checkCache($cacheString)){ // DISPLAY NEWS IN 'CATEGORY' FORMAT HERE
//------------------------------------------------------
// Just title and a few other details
if ($action == 'cat' || $action == 'all')
{ // --> Cache
if($tmp = checkCache($cacheString))
{
require_once(HEADERF); require_once(HEADERF);
renderCache($tmp, TRUE); renderCache($tmp, TRUE);
} }
// <-- Cache // <-- Cache
$qs = explode(".", e_QUERY);
$category = intval($qs[1]); $category = intval($sub_action);
if ($action == 'cat' && $category != 0) { if ($action == 'cat' && $category != 0)
{
$gen = new convert; $gen = new convert;
$sql->db_Select("news_category", "*", "category_id='$category'"); $sql->db_Select("news_category", "*", "category_id='$category'");
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
extract($row); // still required for the table-render. :( extract($row); // still required for the table-render. :(
} }
if ($action == 'all'){ if ($action == 'all')
{
if(!defined("NEWSALL_LIMIT")) { define("NEWSALL_LIMIT",10); } if(!defined("NEWSALL_LIMIT")) { define("NEWSALL_LIMIT",10); }
// show archive of all news items using list-style template. // show archive of all news items using list-style template.
$news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")"); $news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")");
@@ -82,26 +109,36 @@ if ($action == 'cat' || $action == 'all'){
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()."
AND (n.news_end=0 || n.news_end>".time().") ORDER BY n.news_sticky DESC,n.news_datestamp DESC LIMIT ".intval($newsfrom).",".NEWSALL_LIMIT; AND (n.news_end=0 || n.news_end>".time().")
ORDER BY n.news_sticky DESC, n.news_datestamp DESC
LIMIT ".intval($newsfrom).",".NEWSALL_LIMIT;
$category_name = "All"; $category_name = "All";
} }
elseif ($action == 'cat'){ elseif ($action == 'cat')
{
// show archive of all news items in a particular category using list-style template. // show archive of all news items in a particular category using list-style template.
$news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().") AND news_category=".intval($sub_action)); $news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().") AND news_category=".intval($sub_action));
if(!defined("NEWSLIST_LIMIT")) { define("NEWSLIST_LIMIT",10); } if(!defined("NEWSLIST_LIMIT")) { define("NEWSLIST_LIMIT",10); }
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_category=".intval($sub_action)." ORDER BY n.news_datestamp DESC LIMIT ".intval($newsfrom).",".NEWSLIST_LIMIT; WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_category=".intval($sub_action)."
ORDER BY n.news_datestamp DESC
LIMIT ".intval($newsfrom).",".NEWSLIST_LIMIT;
} }
if($category_name){ if($category_name)
define("e_PAGETITLE", $tp->toHTML($category_name,FALSE,"defs")); {
// define("e_PAGETITLE", $tp->toHTML($category_name,FALSE,"defs"));
define("e_PAGETITLE", $tp->toHTML($category_name,FALSE,"TITLE"));
} }
require_once(HEADERF); require_once(HEADERF);
if(!$NEWSLISTSTYLE){ if(!$NEWSLISTSTYLE)
{
$NEWSLISTSTYLE = " $NEWSLISTSTYLE = "
<div style='padding:3px;width:100%'> <div style='padding:3px;width:100%'>
<table style='border-bottom:1px solid black;width:100%' cellpadding='0' cellspacing='0'> <table style='border-bottom:1px solid black;width:100%' cellpadding='0' cellspacing='0'>
@@ -136,11 +173,13 @@ if ($action == 'cat' || $action == 'all'){
$amount = ($action == "all") ? NEWSALL_LIMIT : NEWSLIST_LIMIT; $amount = ($action == "all") ? NEWSALL_LIMIT : NEWSLIST_LIMIT;
$icon = ($row['category_icon']) ? "<img src='".e_IMAGE."icons/".$row['category_icon']."' alt='' />" : ""; $icon = ($row['category_icon']) ? "<img src='".e_IMAGE."icons/".$row['category_icon']."' alt='' />" : "";
$parms = $news_total.",".$amount.",".$newsfrom.",".e_SELF.'?'.$action.".".$sub_action.".[FROM]"; $parms = $news_total.",".$amount.",".$newsfrom.",".e_SELF.'?'.$action.".".$category.".[FROM]";
$text .= "<div class='nextprev'>".$tp->parseTemplate("{NEXTPREV={$parms}}")."</div>"; $text .= "<div class='nextprev'>".$tp->parseTemplate("{NEXTPREV={$parms}}")."</div>";
if(!$NEWSLISTTITLE){ if(!$NEWSLISTTITLE)
$NEWSLISTTITLE = LAN_NEWS_82." '".$tp->toHTML($category_name,FALSE,"defs")."'"; {
// $NEWSLISTTITLE = LAN_NEWS_82." '".$tp->toHTML($category_name,FALSE,"defs")."'";
$NEWSLISTTITLE = LAN_NEWS_82." '".$tp->toHTML($category_name,FALSE,"TITLE")."'";
} }
ob_start(); ob_start();
@@ -151,9 +190,13 @@ if ($action == 'cat' || $action == 'all'){
exit; exit;
} }
if ($action == "extend") {
// --> Cache
//------------------------------------------------------
// DISPLAY SINGLE ITEM IN EXTENDED FORMAT HERE
//------------------------------------------------------
if ($action == "extend")
{ // --> Cache
if($tmp = checkCache($cacheString)){ if($tmp = checkCache($cacheString)){
require_once(HEADERF); require_once(HEADERF);
renderCache($tmp, TRUE); renderCache($tmp, TRUE);
@@ -184,97 +227,108 @@ if ($action == "extend") {
exit; exit;
} }
if (empty($order)){
//------------------------------------------------------
// DISPLAY NEWS IN LIST FORMAT HERE
//------------------------------------------------------
// Show title, author, first part of news item...
if (empty($order))
{
$order = "news_datestamp"; $order = "news_datestamp";
} }
$order = $tp -> toDB($order, true); $order = $tp -> toDB($order, true);
$interval = $pref['newsposts']; $interval = $pref['newsposts'];
if ($action == "list"){
$sub_action = intval($sub_action);
$news_total = $sql->db_Count("news", "(*)", "WHERE news_category=$sub_action AND news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")");
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()."
AND (n.news_end=0 || n.news_end>".time().") AND n.news_category={$sub_action} ORDER BY n.news_sticky DESC,".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW;
} switch ($action)
elseif($action == "item")
{ {
case "list" :
$sub_action = intval($sub_action); $sub_action = intval($sub_action);
// $news_total = $sql->db_Count("news", "(*)", "WHERE news_category={$sub_action} AND news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")");
$query = "SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_category={$sub_action}
ORDER BY n.news_sticky DESC,".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW;
break;
case "item" :
$sub_action = intval($sub_action);
$news_total = 1;
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_id={$sub_action}"; WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
} AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_id={$sub_action}";
elseif(strstr(e_QUERY, "month")) break;
{
$tmp = explode(".", e_QUERY); case "month" :
$item = $tp -> toDB($tmp[1]); $item = $tp -> toDB($sub_action).'20000101';
$year = substr($item, 0, 4); $year = substr($item, 0, 4);
$month = substr($item, 4); $month = substr($item, 4,2);
$startdate = mktime(0, 0, 0, $month, 1, $year); $startdate = mktime(0, 0, 0, $month, 1, $year);
$lastday = date("t", $startdate); $lastday = date("t", $startdate);
$enddate = mktime(23, 59, 59, $month, $lastday, $year); $enddate = mktime(23, 59, 59, $month, $lastday, $year);
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n $query = "SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_render_type<2 AND n.news_datestamp > $startdate AND n.news_datestamp < $enddate ORDER BY ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW; WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
} AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
elseif(strstr(e_QUERY, "day")) AND n.news_render_type<2 AND n.news_datestamp > {$startdate} AND n.news_datestamp < {$enddate}
{ ORDER BY ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW;
$tmp = explode(".", e_QUERY); break;
$item = $tp -> toDB($tmp[1]);
case "day" :
$item = $tp -> toDB($sub_action).'20000101';
$year = substr($item, 0, 4); $year = substr($item, 0, 4);
$month = substr($item, 4, 2); $month = substr($item, 4, 2);
$day = substr($item, 6, 2); $day = substr($item, 6, 2);
$startdate = mktime(0, 0, 0, $month, $day, $year); $startdate = mktime(0, 0, 0, $month, $day, $year);
$lastday = date("t", $startdate); $lastday = date("t", $startdate);
$enddate = mktime(23, 59, 59, $month, $day, $year); $enddate = mktime(23, 59, 59, $month, $day, $year);
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n $query = "SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_render_type<2 AND n.news_datestamp > $startdate AND n.news_datestamp < $enddate ORDER BY ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW; WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_render_type<2 AND n.news_datestamp > $startdate AND n.news_datestamp < $enddate ORDER BY ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW;
} break;
else
{ default :
$news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().") AND news_render_type<2" ); $action = '';
// $news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().") AND news_render_type<2" );
if(!isset($pref['newsposts_archive'])) if(!isset($pref['newsposts_archive']))
{ {
$pref['newsposts_archive'] = 0; $pref['newsposts_archive'] = 0;
} }
$interval = $pref['newsposts']-$pref['newsposts_archive']; $interval = $pref['newsposts']-$pref['newsposts_archive']; // Number of 'full' posts to show
// Get number of news item to show // Get number of news item to show
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) { if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) {
$query = "SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, COUNT(*) AS tbcount FROM #news AS n $query = "SELECT SQL_CALC_FOUND_ROWS COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, COUNT(*) AS tbcount FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_start < ".time()."
AND (n.news_end=0 || n.news_end>".time().")
AND n.news_render_type<2 AND n.news_render_type<2
GROUP by n.news_id GROUP by n.news_id
ORDER BY news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".$pref['newsposts']; ORDER BY news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".$pref['newsposts'];
} }
else else
{ {
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n $query = "SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_start < ".time()."
AND (n.news_end=0 || n.news_end>".time().")
AND n.news_render_type<2 AND n.news_render_type<2
ORDER BY n.news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".$pref['newsposts']; ORDER BY n.news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".$pref['newsposts'];
} }
// #### END --------------------------------------------------------------------------------------------------- } // END - switch($action)
}
if($tmp_cache = checkCache($cacheString)) // normal news front-page - with cache. if($tmp_cache = checkCache($cacheString)) // normal news front-page - with cache.
{ {
@@ -300,7 +354,7 @@ if($tmp_cache = checkCache($cacheString)) // normal news front-page - with cache
if($newsarchive = checkCache('newsarchive')){ if($newsarchive = checkCache('newsarchive')){
$tmp_cache = $tmp_cache.$newsarchive; $tmp_cache = $tmp_cache.$newsarchive;
}else{ }else{
newsarchive($newsAr); show_newsarchive($newsAr,$interval);
} }
} }
} }
@@ -308,21 +362,30 @@ if($tmp_cache = checkCache($cacheString)) // normal news front-page - with cache
} }
if (!$sql->db_Select_gen($query)) { if (!($news_total = $sql->db_Select_gen($query)))
{ // No news items
require_once(HEADERF); require_once(HEADERF);
echo "<br /><br /><div style='text-align:center'><b>".(strstr(e_QUERY, "month") ? LAN_NEWS_462 : LAN_NEWS_83)."</b></div><br /><br />"; echo "<br /><br /><div style='text-align:center'><b>".(strstr(e_QUERY, "month") ? LAN_NEWS_462 : LAN_NEWS_83)."</b></div><br /><br />";
require_once(FOOTERF); require_once(FOOTERF);
exit; exit;
} else {
$newsAr = $sql -> db_getList();
} }
$newsAr = $sql -> db_getList();
$p_title = ($action == "item") ? $newsAr[1]['news_title'] : $tp->toHTML($newsAr[1]['category_name'],FALSE,"defs"); // ***** CAUTION ! - DEBUG MUCKS THIS UP! *****
$sql -> db_Query("SELECT FOUND_ROWS()");
$frows = $sql -> db_Fetch();
$news_total = $frows[0];
//echo "<br />Total ".$news_total." items found, ".count($newsAr)." displayed, Interval = {$interval}<br /><br />";
//$p_title = ($action == "item") ? $newsAr[1]['news_title'] : $tp->toHTML($newsAr[1]['category_name'],FALSE,"defs");
$p_title = ($action == "item") ? $newsAr[1]['news_title'] : $tp->toHTML($newsAr[1]['category_name'],FALSE,"TITLE");
if($action != "" && !is_numeric($action)) if($action != "" && !is_numeric($action))
{ {
if($action == "item" && $pref['meta_news_summary'] && $newsAr[1]['news_title']){ if($action == "item" && $pref['meta_news_summary'] && $newsAr[1]['news_title'])
{
define("META_DESCRIPTION",SITENAME.": ".$newsAr[1]['news_title']." - ".$newsAr[1]['news_summary']); define("META_DESCRIPTION",SITENAME.": ".$newsAr[1]['news_title']." - ".$newsAr[1]['news_summary']);
} }
define("e_PAGETITLE", $p_title); define("e_PAGETITLE", $p_title);
@@ -340,17 +403,13 @@ if(!$action)
} }
} }
if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists(THEME."news_template.php"))
/* {
changes by jalist 03/02/2005:
news page templating
*/
if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists(THEME."news_template.php")) {
// theme specific template required ... // theme specific template required ...
require_once(THEME."news_template.php"); require_once(THEME."news_template.php");
if($ALTERNATECLASS1){ if($ALTERNATECLASS1)
{
return TRUE; return TRUE;
} }
@@ -380,15 +439,16 @@ if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists(
$text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSCLAYOUT); $text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSCLAYOUT);
require_once(HEADERF); require_once(HEADERF);
$parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]";
$nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
$text .= ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
// $text=''.$text.'<center>'.$nextprev.'</center>';
echo $text; echo $text;
setNewsCache($cacheString, $text); setNewsCache($cacheString, $text);
}
} else { else
/* {
changes by jalist 22/01/2005:
added ability to add a new date header to news posts, turn on and off from news->prefs
*/
ob_start(); ob_start();
$newpostday = 0; $newpostday = 0;
@@ -408,19 +468,21 @@ if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists(
$news = $newsAr[$i]; $news = $newsAr[$i];
// render new date header if pref selected ... // render new date header if pref selected ...
$thispostday = strftime("%j", $news['news_datestamp']); $thispostday = strftime("%j", $news['news_datestamp']);
if ($newpostday != $thispostday && (isset($pref['news_newdateheader']) && $pref['news_newdateheader'])) { if ($newpostday != $thispostday && (isset($pref['news_newdateheader']) && $pref['news_newdateheader']))
{
echo "<div class='".DATEHEADERCLASS."'>".strftime("%A %d %B %Y", $news['news_datestamp'])."</div>"; echo "<div class='".DATEHEADERCLASS."'>".strftime("%A %d %B %Y", $news['news_datestamp'])."</div>";
} }
$newpostday = $thispostday; $newpostday = $thispostday;
$news['category_id'] = $news['news_category']; $news['category_id'] = $news['news_category'];
if ($action == "item") { if ($action == "item")
{
unset($news['news_render_type']); unset($news['news_render_type']);
} }
$ix->render_newsitem($news); $ix->render_newsitem($news);
$i++; $i++;
} }
$parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'."[FROM].".$action.(isset($sub_action) ? ".".$sub_action : ""); $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]";
$nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
echo ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : ""); echo ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
@@ -432,15 +494,17 @@ if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists(
// ##### -------------------------------------------------------------------------------------------------------------- // ##### --------------------------------------------------------------------------------------------------------------
function newsarchive($newsAr){ function show_newsarchive($newsAr, $i = 1)
global $ns, $gen, $interval, $pref, $tp, $news_archive_shortcodes, $NEWSARCHIVE, $news2; {
global $ns, $gen, $pref, $tp, $news_archive_shortcodes, $NEWSARCHIVE, $news2;
// do not show the news archive on the news.php?item.X page (but only on the news mainpage) // do not show the news archive on the news.php?item.X page (but only on the news mainpage)
require_once(e_FILE.'shortcode/batch/news_archives.php'); require_once(e_FILE.'shortcode/batch/news_archives.php');
$textnewsarchive = '';
ob_start(); ob_start();
$i = $interval + 1; $i++; // First entry to show
while(isset($newsAr[$i])) while(isset($newsAr[$i]))
{ {
$news2 = $newsAr[$i]; $news2 = $newsAr[$i];
@@ -476,8 +540,8 @@ function newsarchive($newsAr){
</tr> </tr>
</table> </table>
</div>"; </div>";
} }
$textnewsarchive .= $tp->parseTemplate($NEWSARCHIVE, FALSE, $news_archive_shortcodes); $textnewsarchive .= $tp->parseTemplate($NEWSARCHIVE, FALSE, $news_archive_shortcodes);
$i++; $i++;
} }
@@ -488,8 +552,9 @@ function newsarchive($newsAr){
} }
// #### new: news archive --------------------------------------------------------------------------------------------- // #### new: news archive ---------------------------------------------------------------------------------------------
if ($action != "item" && $action != 'list' && $pref['newsposts_archive']) { if ($action != "item" && $action != 'list' && $pref['newsposts_archive'])
newsarchive($newsAr); {
show_newsarchive($newsAr,$interval);
} }
// #### END ----------------------------------------------------------------------------------------------------------- // #### END -----------------------------------------------------------------------------------------------------------