From 04ef72faa7a7550e4afc7cd30ff6e555cbe7ab09 Mon Sep 17 00:00:00 2001 From: e107steved Date: Mon, 15 Oct 2007 19:16:04 +0000 Subject: [PATCH] Bugtracker #4137 - show trackback count on extended news --- news.php | 66 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/news.php b/news.php index dda6e3441..73d4ad234 100644 --- a/news.php +++ b/news.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/news.php,v $ -| $Revision: 1.7 $ -| $Date: 2007-06-07 20:34:02 $ +| $Revision: 1.8 $ +| $Date: 2007-10-15 19:16:04 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -131,7 +131,6 @@ if ($action == 'cat' || $action == 'all') if($category_name) { -// define("e_PAGETITLE", $tp->toHTML($category_name,FALSE,"defs")); define("e_PAGETITLE", $tp->toHTML($category_name,FALSE,"TITLE")); } @@ -178,7 +177,6 @@ if ($action == 'cat' || $action == 'all') if(!$NEWSLISTTITLE) { -// $NEWSLISTTITLE = LAN_NEWS_82." '".$tp->toHTML($category_name,FALSE,"defs")."'"; $NEWSLISTTITLE = LAN_NEWS_82." '".$tp->toHTML($category_name,FALSE,"TITLE")."'"; } @@ -203,18 +201,33 @@ if ($action == "extend") } // <-- Cache - $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n + 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 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 + LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id + WHERE n.news_id=".intval($sub_action)." AND 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().") "; + } + else + { + $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_id=".intval($sub_action); + } $sql->db_Select_gen($query); $news = $sql->db_Fetch(); - if($news['news_title']){ - if($pref['meta_news_summary'] && $news['news_title']){ - define("META_DESCRIPTION",SITENAME.": ".$news['news_title']." - ".$news['news_summary']); - } - define("e_PAGETITLE",$news['news_title']); + if($news['news_title']) + { + if($pref['meta_news_summary'] && $news['news_title']) + { + define("META_DESCRIPTION",SITENAME.": ".$news['news_title']." - ".$news['news_summary']); + } + define("e_PAGETITLE",$news['news_title']); } require_once(HEADERF); @@ -266,11 +279,21 @@ switch ($action) break; case "month" : + case "day" : $item = $tp -> toDB($sub_action).'20000101'; $year = substr($item, 0, 4); $month = substr($item, 4,2); - $startdate = mktime(0, 0, 0, $month, 1, $year); - $lastday = date("t", $startdate); + if ($action == 'day') + { + $day = substr($item, 6, 2); + $lastday = $day; + } + else + { // A month's worth + $day = 1; + $lastday = date("t", $startdate); + } + $startdate = mktime(0, 0, 0, $month, $day, $year); $enddate = mktime(23, 59, 59, $month, $lastday, $year); $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 @@ -281,20 +304,6 @@ switch ($action) ORDER BY ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW; break; - case "day" : - $item = $tp -> toDB($sub_action).'20000101'; - $year = substr($item, 0, 4); - $month = substr($item, 4, 2); - $day = substr($item, 6, 2); - $startdate = mktime(0, 0, 0, $month, $day, $year); - $lastday = date("t", $startdate); - $enddate = mktime(23, 59, 59, $month, $day, $year); - $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_render_type<2 AND n.news_datestamp > $startdate AND n.news_datestamp < $enddate ORDER BY ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW; - break; - default : $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" ); @@ -372,14 +381,13 @@ if (!($news_total = $sql->db_Select_gen($query))) $newsAr = $sql -> db_getList(); -// ***** CAUTION ! - DEBUG MUCKS THIS UP! ***** -$sql -> db_Query("SELECT FOUND_ROWS()"); +// Get number of entries +$sql -> db_Select_gen("SELECT FOUND_ROWS()"); $frows = $sql -> db_Fetch(); $news_total = $frows[0]; //echo "
Total ".$news_total." items found, ".count($newsAr)." displayed, Interval = {$interval}

"; -//$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))