mirror of
https://github.com/e107inc/e107.git
synced 2025-04-21 13:11:52 +02:00
Issue #106: News Category SEF
This commit is contained in:
parent
439fb926a5
commit
a6adeca93c
@ -92,19 +92,21 @@ class news_cat_ui extends e_admin_ui
|
||||
protected $pid = "category_id";
|
||||
protected $perPage = 0; //no limit
|
||||
protected $batchDelete = false;
|
||||
protected $sortField = 'category_order';
|
||||
protected $listOrder = "category_order ASC";
|
||||
|
||||
protected $fields = array(
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
||||
'category_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
|
||||
'category_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE),
|
||||
'category_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
|
||||
'category_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE, 'validate' => true, 'inline' => true),
|
||||
|
||||
'category_meta_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'readonly'=>FALSE),
|
||||
'category_meta_keywords' => array('title'=> "Meta Keywords", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
|
||||
'category_sef' => array('title'=> "SEF Url String", 'type' => 'text', 'width' => 'auto', 'readonly'=>FALSE), // Display name
|
||||
'category_manager' => array('title'=> "Manage Permissions",'type' => 'userclass', 'width' => 'auto', 'data' => 'int','batch'=>TRUE, 'filter'=>TRUE),
|
||||
'category_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto', 'thclass' => 'right', 'class'=> 'right' ),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center', 'sort' => true)
|
||||
);
|
||||
|
||||
protected $fieldpref = array('checkboxes', 'category_icon', 'category_id', 'category_name', 'category_description','category_manager', 'category_order', 'options');
|
||||
@ -123,13 +125,45 @@ class news_cat_ui extends e_admin_ui
|
||||
|
||||
public function beforeCreate($new_data)
|
||||
{
|
||||
|
||||
if(empty($new_data['category_sef']))
|
||||
{
|
||||
$new_data['category_sef'] = eHelper::title2sef($new_data['category_name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_data['category_sef'] = eHelper::secureSef($new_data['category_sef']);
|
||||
}
|
||||
$sef = e107::getParser()->toDB($new_data['category_sef']);
|
||||
|
||||
if(e107::getDb()->count('news_category', '(*)', "category_sef='{$sef}'"))
|
||||
{
|
||||
e107::getMessage()->addError('Please choose unique SEF URL string for this category');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($new_data['category_order']))
|
||||
{
|
||||
$c = e107::getDb()->count('news_category');
|
||||
$new_data['category_order'] = $c ? $c : 0;
|
||||
}
|
||||
|
||||
return $new_data;
|
||||
}
|
||||
|
||||
|
||||
public function beforeUpdate($new_data, $old_data, $id)
|
||||
{
|
||||
|
||||
if(empty($new_data['category_sef']))
|
||||
{
|
||||
$new_data['category_sef'] = eHelper::title2sef($new_data['category_name']);
|
||||
}
|
||||
$sef = e107::getParser()->toDB($new_data['category_sef']);
|
||||
if(e107::getDb()->count('news_category', '(*)', "category_sef='{$sef}' AND category_id!=".intval($id)))
|
||||
{
|
||||
e107::getMessage()->addError('Please choose unique SEF URL string for this category');
|
||||
return false;
|
||||
}
|
||||
return $new_data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,13 @@ class news_shortcodes extends e_shortcode
|
||||
return $this->e107->tp->toHTML($this->news_item['news_title'], TRUE, 'TITLE');
|
||||
}
|
||||
|
||||
function sc_newsurltitle()
|
||||
{
|
||||
$title = $this->sc_newstitle();
|
||||
// FIXME generic parser toAttribute method (currently toAttribute() isn't appropriate)
|
||||
return '<a href="'.$this->sc_newsurl().'" title="'.preg_replace('/\'|"|<|>/s', '', $this->news_item['news_title']).'">'.$title.'</a>';
|
||||
}
|
||||
|
||||
function sc_newsbody($parm)
|
||||
{
|
||||
e107::getBB()->setClass("news");
|
||||
|
@ -5,7 +5,15 @@
|
||||
* News Categories shortcode
|
||||
*/
|
||||
//<?
|
||||
global $e107, $sql,$pref,$tp,$NEWSCAT,$NEWSCAT_ITEM;
|
||||
global $NEWSCAT,$NEWSCAT_ITEM;
|
||||
|
||||
// FIXME full rewrite!!!
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
$sql = e107::getDb();
|
||||
$pref = e107::getPref();
|
||||
$tp = e107::getParser();
|
||||
$scbatch = e107::getScBatch('news');
|
||||
|
||||
$cString = 'nq_news_categories_sc';
|
||||
$cached = e107::getCache()->retrieve($cString);
|
||||
@ -21,11 +29,19 @@ $ix = new news;
|
||||
$nbr_cols = (isset($pref['nbr_cols'])) ? $pref['nbr_cols'] : 1;
|
||||
$nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
|
||||
if(!defined("NEWSCAT_AMOUNT")){
|
||||
if(!defined("NEWSCAT_AMOUNT"))
|
||||
{
|
||||
define("NEWSCAT_AMOUNT",3);
|
||||
}
|
||||
|
||||
if(!$NEWSCAT){
|
||||
// News templates with BC
|
||||
if(!$NEWSCAT)
|
||||
{
|
||||
$tmpl = e107::getTemplate('news', 'news', 'category');
|
||||
$NEWSCAT = $tmpl['body'];
|
||||
}
|
||||
if(!$NEWSCAT)
|
||||
{
|
||||
$NEWSCAT = "
|
||||
<div style='padding:5px'><div style='border-bottom:1px inset black; padding-bottom:1px;margin-bottom:5px'>
|
||||
{NEWSCATICON} {NEWSCATEGORY}
|
||||
@ -34,8 +50,15 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
</div>
|
||||
";
|
||||
}
|
||||
|
||||
if(!$NEWSCAT_ITEM){
|
||||
|
||||
// News templates with BC
|
||||
if(!$NEWSCAT_ITEM)
|
||||
{
|
||||
$tmpl = e107::getTemplate('news', 'news', 'category');
|
||||
$NEWSCAT_ITEM = $tmpl['item'];
|
||||
}
|
||||
if(!$NEWSCAT_ITEM)
|
||||
{
|
||||
$NEWSCAT_ITEM = "
|
||||
<div style='width:100%;padding-bottom:2px'>
|
||||
<table style='width:100%' cellpadding='0' cellspacing='0' border='0'>
|
||||
@ -52,23 +75,29 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
}
|
||||
|
||||
|
||||
if(!defined("NEWSCAT_CATLINK")){
|
||||
if(!defined("NEWSCAT_CATLINK"))
|
||||
{
|
||||
define("NEWSCAT_CATLINK","");
|
||||
}
|
||||
if(!defined("NEWSCAT_ITEMLINK")){
|
||||
if(!defined("NEWSCAT_ITEMLINK"))
|
||||
{
|
||||
define("NEWSCAT_ITEMLINK","");
|
||||
}
|
||||
if(!defined("NEWSCAT_STYLE")){
|
||||
if(!defined("NEWSCAT_STYLE"))
|
||||
{
|
||||
define("NEWSCAT_STYLE","width:96%");
|
||||
}
|
||||
if(!defined("NEWSCAT_CATICON")){
|
||||
if(!defined("NEWSCAT_CATICON"))
|
||||
{
|
||||
define("NEWSCAT_CATICON","border:0px");
|
||||
}
|
||||
if(!defined("NEWSCAT_THUMB")){
|
||||
if(!defined("NEWSCAT_THUMB"))
|
||||
{
|
||||
define("NEWSCAT_THUMB","border:0px");
|
||||
}
|
||||
|
||||
if(!defined("NEWSCAT_CELL")){
|
||||
if(!defined("NEWSCAT_CELL"))
|
||||
{
|
||||
define("NEWSCAT_CELL","vertical-align:top");
|
||||
}
|
||||
|
||||
@ -79,24 +108,37 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
$param['catlink'] = NEWSCAT_CATLINK;
|
||||
$param['caticon'] = NEWSCAT_CATICON;
|
||||
|
||||
$sql2 = new db;
|
||||
$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 ASC
|
||||
";
|
||||
// get categories
|
||||
$sql2 = e107::getDb('sql2');
|
||||
$_time = time();
|
||||
$qry = "SELECT nc.*, COUNT(n.news_id) as ccount FROM #news_category AS nc
|
||||
LEFT JOIN #news as n ON n.news_category=nc.category_id
|
||||
WHERE n.news_class IN (".USERCLASS_LIST.")
|
||||
AND (n.news_start=0 || news_start < {$_time})
|
||||
AND (n.news_end=0 || news_end > {$_time})
|
||||
GROUP BY nc.category_id
|
||||
ORDER BY nc.category_order ASC";
|
||||
if(!$sql2->db_Select_gen($qry))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$cats = array();
|
||||
while ($row = $sql2->db_Fetch())
|
||||
{
|
||||
if($row['ccount'] > 0) $cats[$row['category_id']] = $row;
|
||||
}
|
||||
if(empty($cats)) return;
|
||||
|
||||
$text3 = "\n\n\n
|
||||
<div style='width:100%;text-align:center;margin-left:auto;margin-right:auto'>
|
||||
<table style='".NEWSCAT_STYLE."' cellpadding='0' cellspacing='0'>
|
||||
\n";
|
||||
$t = 0;
|
||||
$wid = floor(100/$nbr_cols);
|
||||
while ($row3 = $sql2->db_Fetch()) {
|
||||
$wid = floor(100/$nbr_cols);
|
||||
foreach($cats as $row3)
|
||||
{
|
||||
extract($row3);
|
||||
$scbatch->setScVar('news_item', $row3);
|
||||
//quick fix
|
||||
if($category_icon)
|
||||
{
|
||||
@ -110,30 +152,22 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
$category_icon = e_IMAGE_ABS."icons/".$category_icon;
|
||||
}
|
||||
}
|
||||
$search[0] = "/\{NEWSCATICON\}(.*?)/si";
|
||||
$replace[0] = ($category_icon) ? "<a href='".e107::getUrl('core:news', 'main', 'action=list&id='.$category_id.'&sef='.$news_category_rewrite_string)."'><img src='".$category_icon."' alt='' style='".$param['caticon']."' /></a>" : "";
|
||||
|
||||
$search[1] = "/\{NEWSCATEGORY\}(.*?)/si";
|
||||
$replace[1] = ($category_name) ? "<a href='".e107::getUrl('core:news', 'main', 'action=list&id='.$category_id.'&sef='.$news_category_rewrite_string)."' style='".$param['catlink']."' >".$tp->toHTML($category_name,TRUE,"defs")."</a>" : "";
|
||||
|
||||
$text3 .= ($t % $nbr_cols == 0) ? "<tr>" : "";
|
||||
$text3 .= "\n<td style='".NEWSCAT_CELL."; width:$wid%;'>\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
|
||||
$cqry = "SELECT n.* FROM #news AS n
|
||||
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().")
|
||||
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_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()) {
|
||||
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
$scbatch->setScVar('news_item', $row);
|
||||
//$row['category_name'] = $category_name;
|
||||
//$row['category_icon'] = $category_icon;
|
||||
$row = array_merge($row, $row3);
|
||||
@ -142,24 +176,38 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
}
|
||||
}
|
||||
// ----------------------------------
|
||||
$search[0] = "/\{NEWSCATICON\}(.*?)/si";
|
||||
$replace[0] = $scbatch->sc_newscaticon('url');
|
||||
|
||||
$search[1] = "/\{NEWSCATEGORY\}(.*?)/si";
|
||||
$replace[1] = $scbatch->sc_newscategory();
|
||||
|
||||
$search[2] = "/\{NEWSCAT_ITEM\}(.*?)/si";
|
||||
$replace[2] = $textbody;
|
||||
|
||||
|
||||
$text3 .= ($t % $nbr_cols == 0) ? "<tr>" : "";
|
||||
$text3 .= "\n<td style='".NEWSCAT_CELL."; width:$wid%;'>\n";
|
||||
|
||||
$text3 .= preg_replace($search, $replace,$NEWSCAT);
|
||||
unset($textbody);
|
||||
|
||||
|
||||
$text3 .= "\n</td>\n";
|
||||
if (($t+1) % $nbr_cols == 0) {
|
||||
|
||||
if (($t+1) % $nbr_cols == 0)
|
||||
{
|
||||
$text3 .= "</tr>";
|
||||
$t++;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$t++;
|
||||
}
|
||||
}
|
||||
|
||||
while ($t % $nbr_cols != 0){
|
||||
while ($t % $nbr_cols != 0)
|
||||
{
|
||||
$text3 .= "<td style='".NEWSCAT_CELL.";width:{$wid}%'> </td>\n";
|
||||
$text3 .= (($t+1) % $nbr_cols == 0) ? "</tr>" : "";
|
||||
$t++;
|
||||
|
@ -1,3 +1,5 @@
|
||||
require_once(e_PLUGIN."alt_news/alt_news.php");
|
||||
alt_news($parm);
|
||||
//<?
|
||||
// FIXME obsolete, remove, or switch to news_categories_menu (BC)
|
||||
//require_once(e_PLUGIN."alt_news/alt_news.php");
|
||||
//alt_news($parm);
|
||||
return "";
|
||||
|
@ -1847,6 +1847,7 @@ class e_form
|
||||
}
|
||||
|
||||
if(vartrue($attributes['inline'])) $parms['editable'] = true; // attribute alias
|
||||
if(vartrue($attributes['sort'])) $parms['sort'] = true; // attribute alias
|
||||
|
||||
$tp = e107::getParser();
|
||||
switch($field) // special fields
|
||||
|
@ -14,17 +14,18 @@ global $sc_style;
|
||||
//$NEWS_MENU_TEMPLATE['list']['start'] = '<ul class="nav nav-list news-menu-months">';
|
||||
//$NEWS_MENU_TEMPLATE['list']['end'] = '</ul>';
|
||||
$NEWS_TEMPLATE['list']['item'] = '
|
||||
<div class="news-list-item">
|
||||
<h2>{NEWSTITLE}</h2>
|
||||
<div class="item-date">{NEWSDATE=short}</div>
|
||||
<div class="item-author">{NEWSAUTHOR}</div>
|
||||
|
||||
<div class="item-body">
|
||||
<div class="list-item">
|
||||
<h2>{NEWSURLTITLE}</h2>
|
||||
<div class="category">in {NEWSCATEGORY}</div>
|
||||
<div class="date">{NEWSDATE=short}</div>
|
||||
<div class="author">{NEWSAUTHOR}</div>
|
||||
|
||||
<div class="body">
|
||||
{NEWSIMAGE}
|
||||
{NEWSBODY}
|
||||
{EXTENDED}
|
||||
</div>
|
||||
<div class="item-options">
|
||||
<div class="options">
|
||||
{NEWSCOMMENTS} {EMAILICON} {PRINTICON} {PDFICON} {ADMINOPTIONS}
|
||||
</div>
|
||||
</div>
|
||||
@ -35,19 +36,44 @@ $NEWS_TEMPLATE['list']['item'] = '
|
||||
//$NEWS_MENU_TEMPLATE['view']['start'] = '<ul class="nav nav-list news-menu-months">';
|
||||
//$NEWS_MENU_TEMPLATE['view']['end'] = '</ul>';
|
||||
$NEWS_TEMPLATE['view']['item'] = '
|
||||
<div class="news-view-item">
|
||||
<div class="view-item">
|
||||
<h2>{NEWSTITLE}</h2>
|
||||
<div class="item-date">{NEWSDATE=short}</div>
|
||||
<div class="item-author">{NEWSAUTHOR}</div>
|
||||
|
||||
<div class="item-body">
|
||||
<div class="category">in {NEWSCATEGORY}</div>
|
||||
<div class="date">{NEWSDATE=short}</div>
|
||||
<div class="author">{NEWSAUTHOR}</div>
|
||||
|
||||
<div class="body">
|
||||
{NEWSIMAGE}
|
||||
{NEWSBODY}
|
||||
{EXTENDED}
|
||||
</div>
|
||||
<div class="item-options">
|
||||
<div class="options">
|
||||
{NEWSCOMMENTS} {EMAILICON} {PRINTICON} {PDFICON} {ADMINOPTIONS}
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
//$NEWS_MENU_TEMPLATE['view']['separator'] = '<br />';
|
||||
//$NEWS_MENU_TEMPLATE['view']['separator'] = '<br />';
|
||||
|
||||
|
||||
###### news_categories.sc (temporary) - TODO rewrite news, template standards ######
|
||||
$NEWS_TEMPLATE['category']['body'] = '
|
||||
<div style="padding:5px"><div style="border-bottom:1px inset black; padding-bottom:1px;margin-bottom:5px">
|
||||
{NEWSCATICON} {NEWSCATEGORY}
|
||||
</div>
|
||||
{NEWSCAT_ITEM}
|
||||
</div>
|
||||
';
|
||||
|
||||
$NEWS_TEMPLATE['category']['item'] = '
|
||||
<div style="width:100%;padding-bottom:2px">
|
||||
<table style="width:100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td style="width:2px;vertical-align:top">•
|
||||
</td>
|
||||
<td style="text-align:left;vertical-align:top;padding-left:3px">
|
||||
{NEWSTITLELINK}
|
||||
<br />
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
';
|
64
news.php
64
news.php
@ -45,6 +45,11 @@ if (!defined('ITEMVIEW'))
|
||||
{
|
||||
define('ITEMVIEW', varset($pref['newsposts'],15));
|
||||
}
|
||||
// XXX remove ITEMVIEW?
|
||||
if(!defined("NEWSALL_LIMIT"))
|
||||
{
|
||||
define("NEWSALL_LIMIT",varset($pref['newsposts'],15));
|
||||
}
|
||||
|
||||
if (e_QUERY) //TODO add support for $_GET['cat'] and $_GET['mode'] and phase-out the x.x.x format.
|
||||
{
|
||||
@ -149,12 +154,11 @@ if ($action == 'cat' || $action == 'all' || vartrue($_GET['tag']))
|
||||
}
|
||||
if ($action == 'all')
|
||||
{
|
||||
if(!defined("NEWSALL_LIMIT")) { define("NEWSALL_LIMIT",10); }
|
||||
// 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().")");
|
||||
$query = "
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon,
|
||||
nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon,
|
||||
nc.category_meta_keywords, nc.category_meta_description
|
||||
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
|
||||
@ -170,8 +174,8 @@ if ($action == 'cat' || $action == 'all' || vartrue($_GET['tag']))
|
||||
$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); }
|
||||
$query = "
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, nc.category_meta_keywords,
|
||||
nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords,
|
||||
nc.category_meta_description
|
||||
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
|
||||
@ -185,8 +189,8 @@ if ($action == 'cat' || $action == 'all' || vartrue($_GET['tag']))
|
||||
{
|
||||
$tagsearch = preg_replace('#[^a-zA-Z0-9\-]#','', $_GET['tag']);
|
||||
$query = "
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, nc.category_meta_keywords,
|
||||
nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords,
|
||||
nc.category_meta_description
|
||||
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
|
||||
@ -272,7 +276,7 @@ if ($action == 'cat' || $action == 'all' || vartrue($_GET['tag']))
|
||||
//
|
||||
// $text .= "<div class='nextprev'>".$tp->parseTemplate("{NEXTPREV={$parms}}")."</div>";
|
||||
|
||||
$amount = ($action == "all") ? NEWSALL_LIMIT : NEWSLIST_LIMIT;
|
||||
$amount = NEWSLIST_LIMIT;
|
||||
$nitems = defined('NEWS_NEXTPREV_NAVCOUNT') ? '&navcount='.NEWS_NEXTPREV_NAVCOUNT : '' ;
|
||||
$url = rawurlencode(e107::getUrl()->create($newsRoute, $newsUrlparms));
|
||||
$parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$newsfrom.$nitems.'&url='.$url;
|
||||
@ -312,8 +316,8 @@ if ($action == 'extend')
|
||||
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, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef,
|
||||
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description
|
||||
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
|
||||
@ -326,8 +330,8 @@ if ($action == 'extend')
|
||||
else
|
||||
{
|
||||
$query = "
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, nc.category_meta_keywords,
|
||||
nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords,
|
||||
nc.category_meta_description
|
||||
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
|
||||
@ -455,8 +459,8 @@ switch ($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, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef,
|
||||
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description
|
||||
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
|
||||
@ -473,8 +477,8 @@ switch ($action)
|
||||
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, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef,
|
||||
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description
|
||||
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
|
||||
@ -486,8 +490,8 @@ switch ($action)
|
||||
else
|
||||
{
|
||||
$query = "
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon,
|
||||
nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon,
|
||||
nc.category_meta_keywords, nc.category_meta_description
|
||||
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
|
||||
@ -514,8 +518,8 @@ switch ($action)
|
||||
$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, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef,
|
||||
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description
|
||||
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
|
||||
@ -540,9 +544,9 @@ switch ($action)
|
||||
// Get number of news item to show
|
||||
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) {
|
||||
$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, nc.category_meta_keywords, nc.category_meta_description,
|
||||
COUNT(*) AS tbcount{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT SQL_CALC_FOUND_ROWS COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id
|
||||
nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords, nc.category_meta_description,
|
||||
COUNT(*) AS tbcount
|
||||
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
|
||||
@ -551,20 +555,20 @@ switch ($action)
|
||||
AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
|
||||
AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))
|
||||
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).",".ITEMVIEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = "
|
||||
SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon,
|
||||
nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
|
||||
SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon,
|
||||
nc.category_meta_keywords, nc.category_meta_description
|
||||
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 (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))
|
||||
ORDER BY n.news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".$pref['newsposts'];
|
||||
ORDER BY n.news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW;
|
||||
}
|
||||
} // END - switch($action)
|
||||
|
||||
@ -744,16 +748,20 @@ else
|
||||
$param['current_action'] = $action;
|
||||
|
||||
// Get Correct Template
|
||||
// XXX we use $NEWSLISTSTYLE above - correct as we are currently in list mode
|
||||
// TODO requires BC testing if we comment this one
|
||||
if(vartrue($NEWSSTYLE))
|
||||
{
|
||||
$template = $NEWSSTYLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp = e107::getTemplate('news', 'news', 'view');
|
||||
$tmp = e107::getTemplate('news', 'news', 'list');
|
||||
$template = $tmp['item'];
|
||||
unset($tmp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user