From c419de106c0d4850c87b99a7e8c16df3e5218163 Mon Sep 17 00:00:00 2001 From: secretr Date: Tue, 15 Sep 2009 15:08:50 +0000 Subject: [PATCH] news rewrite related fixes --- .../shortcode/batch/news_shortcodes.php | 12 +++--- e107_files/shortcode/news_categories.sc | 42 +++++++++++++------ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/e107_files/shortcode/batch/news_shortcodes.php b/e107_files/shortcode/batch/news_shortcodes.php index ca0e959ef..839df3c8d 100644 --- a/e107_files/shortcode/batch/news_shortcodes.php +++ b/e107_files/shortcode/batch/news_shortcodes.php @@ -1,7 +1,7 @@ e107->tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']); - if($this->news_item['news_extended'] && (isset($_POST['preview']) || strpos(e_QUERY, 'extend') !== FALSE) && $parm != 'noextend') + if($this->news_item['news_extended'] && (isset($_POST['preview']) || $this->param['current_action'] == 'extend') && $parm != 'noextend') { - $news_extended = $this->e107->tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']); - $news_body .= '

'.$news_extended; + $news_body .= $this->e107->tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']); } return $news_body; @@ -113,7 +112,7 @@ class news_shortcodes return ''; } - if (varsettrue($pref['multilanguage'])) + if (vartrue($pref['multilanguage'])) { // Can have multilanguage news table, monlingual comment table. If the comment table is multilingual, it'll only count entries in the current language $news_item['news_comment_total'] = $sql->db_Count("comments", "(*)", "WHERE comment_item_id='".$news_item['news_id']."' AND comment_type='0' "); } @@ -238,7 +237,8 @@ class news_shortcodes function sc_extended($parm) { - if ($this->news_item['news_extended'] && (strpos(e_QUERY, 'extend') === FALSE || $parm == 'force')) + + if ($this->news_item['news_extended'] && ($this->param['current_action'] != 'extend' || $parm == 'force')) { if (defined('PRE_EXTENDEDSTRING')) { diff --git a/e107_files/shortcode/news_categories.sc b/e107_files/shortcode/news_categories.sc index eca1b87c9..7a7541ca2 100644 --- a/e107_files/shortcode/news_categories.sc +++ b/e107_files/shortcode/news_categories.sc @@ -1,6 +1,6 @@ /* * Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt) - * $Id: news_categories.sc,v 1.4 2009-06-06 17:03:25 e107steved Exp $ + * $Id: news_categories.sc,v 1.5 2009-09-15 15:08:50 secretr Exp $ * * News Categories shortcode */ @@ -70,7 +70,14 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols; $param['caticon'] = NEWSCAT_CATICON; $sql2 = new db; - $sql2->db_Select("news_category", "*", "category_id!='' ORDER BY category_name ASC"); + $qry = "SELECT nc.*, ncr.news_rewrite_string AS news_category_rewrite_string, ncr.news_rewrite_id AS news_category_rewrite_id FROM #news_category AS nc + LEFT JOIN #news_rewrite AS ncr ON nc.category_id=ncr.news_rewrite_source AND ncr.news_rewrite_type=2 + ORDER BY nc.category_order + "; + if(!$sql2->db_Select_gen($qry)) + { + return ''; + } $text3 = "\n\n\n
@@ -82,24 +89,35 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols; extract($row3); $search[0] = "/\{NEWSCATICON\}(.*?)/si"; - $replace[0] = ($category_icon) ? "" : ""; + $replace[0] = ($category_icon) ? "" : ""; $search[1] = "/\{NEWSCATEGORY\}(.*?)/si"; - $replace[1] = ($category_name) ? "".$tp->toHTML($category_name,TRUE,"defs")."" : ""; + $replace[1] = ($category_name) ? "".$tp->toHTML($category_name,TRUE,"defs")."" : ""; $text3 .= ($t % $nbr_cols == 0) ? "" : ""; $text3 .= "\n\n"; // Grab each news item.-------------- + $cqry = "SELECT n.*, nr.* FROM #news AS n + LEFT JOIN #news_rewrite AS nr ON n.news_id=nr.news_rewrite_source AND nr.news_rewrite_type=1 + WHERE news_category='".intval($category_id)."' + AND news_class IN (".USERCLASS_LIST.") + AND (news_start=0 || news_start < ".time().") + AND (news_end=0 || news_end>".time().") + ORDER BY news_datestamp DESC LIMIT 0,".NEWSCAT_AMOUNT; - $count = $sql->db_Select("news", "*", "news_category='".intval($category_id)."' AND news_class IN (".USERCLASS_LIST.") AND (news_start=0 || news_start < ".time().") AND (news_end=0 || news_end>".time().") ORDER BY news_datestamp DESC LIMIT 0,".NEWSCAT_AMOUNT); - while ($row = $sql->db_Fetch()) { - - $row['category_name'] = $category_name; - $row['category_icon'] = $category_icon; - - $textbody .= $ix -> render_newsitem($row, 'return', '', $NEWSCAT_ITEM, $param); - + $count = $sql->db_Select_gen($cqry); + //$count = $sql->db_Select("news", "*", "news_category='".intval($category_id)."' AND news_class IN (".USERCLASS_LIST.") AND (news_start=0 || news_start < ".time().") AND (news_end=0 || news_end>".time().") ORDER BY news_datestamp DESC LIMIT 0,".NEWSCAT_AMOUNT); + if($count) + { + while ($row = $sql->db_Fetch()) { + + //$row['category_name'] = $category_name; + //$row['category_icon'] = $category_icon; + $row = array_merge($row, $row3); + $textbody .= $ix -> render_newsitem($row, 'return', '', $NEWSCAT_ITEM, $param); + + } } // ----------------------------------