mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Fix for news archive.
This commit is contained in:
69
e107_core/shortcodes/batch/news_archive_shortcodes.php
Normal file
69
e107_core/shortcodes/batch/news_archive_shortcodes.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/news_archives.php,v $
|
||||||
|
* $Revision$
|
||||||
|
* $Date$
|
||||||
|
* $Author$
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
// include_once(e_HANDLER.'shortcode_handler.php');
|
||||||
|
// $news_archive_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
|
||||||
|
|
||||||
|
|
||||||
|
class news_archive_shortcodes extends e_shortcode
|
||||||
|
{
|
||||||
|
|
||||||
|
function sc_archive_bullet()
|
||||||
|
{
|
||||||
|
$bullet = '';
|
||||||
|
if(defined('BULLET'))
|
||||||
|
{
|
||||||
|
$bullet = '<img src="'.THEME.'images/'.BULLET.'" alt="" class="icon" />';
|
||||||
|
}
|
||||||
|
elseif(file_exists(THEME.'images/bullet2.gif'))
|
||||||
|
{
|
||||||
|
$bullet = '<img src="'.THEME.'images/bullet2.gif" alt="" class="icon" />';
|
||||||
|
}
|
||||||
|
return $bullet;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sc_archive_link()
|
||||||
|
{
|
||||||
|
return "<a href='news.php?item.".$this->var['news_id']."'>".$this->var['news_title']."</a>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sc_archive_author()
|
||||||
|
{
|
||||||
|
return "<a href='".e_BASE."user.php?id.".$this->var['user_id']."'>".$this->var['user_name']."</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sc_archive_datestamp()
|
||||||
|
{
|
||||||
|
return e107::getParser()->toDate($this->var['news_datestamp'], 'short');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sc_archive_category()
|
||||||
|
{
|
||||||
|
return $this->var['category_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@@ -37,6 +37,7 @@ class news_front
|
|||||||
private $text = null;
|
private $text = null;
|
||||||
private $pref = array();
|
private $pref = array();
|
||||||
private $debugInfo = array();
|
private $debugInfo = array();
|
||||||
|
// private $interval = 1;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@@ -47,6 +48,8 @@ class news_front
|
|||||||
|
|
||||||
$this->pref = e107::getPref();
|
$this->pref = e107::getPref();
|
||||||
|
|
||||||
|
// $this->interval = $this->pref['newsposts']-$this>pref['newsposts_archive'];
|
||||||
|
|
||||||
require_once(e_HANDLER."news_class.php");
|
require_once(e_HANDLER."news_class.php");
|
||||||
|
|
||||||
if(isset($NEWSHEADER))
|
if(isset($NEWSHEADER))
|
||||||
@@ -58,40 +61,32 @@ class news_front
|
|||||||
$this->ix = new news;
|
$this->ix = new news;
|
||||||
|
|
||||||
$this->setConstants();
|
$this->setConstants();
|
||||||
|
$this->setActions();
|
||||||
|
$this->setRoute();
|
||||||
$this->detect();
|
$this->detect();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function detect()
|
private function detect()
|
||||||
{
|
{
|
||||||
$this->setActions();
|
|
||||||
$this->setRoute();
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->action == 'cat' || $this->action == 'all' || !empty($_GET['tag']) || !empty($_GET['author']))
|
if ($this->action == 'cat' || $this->action == 'all' || !empty($_GET['tag']) || !empty($_GET['author']))
|
||||||
{ // --> Cache
|
{ // --> Cache
|
||||||
$this->text = $this->renderListTemplate();
|
$this->text = $this->renderListTemplate();
|
||||||
|
$this->text .= $this->render_newscats();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->action == 'extend')
|
if ($this->action == 'extend')
|
||||||
{ // --> Cache
|
{ // --> Cache
|
||||||
$this->text = $this->renderViewTemplate();
|
$this->text = $this->renderViewTemplate();
|
||||||
|
$this->text .= $this->render_newscats();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->action != "item" && $this->action != 'list' && $this->pref['newsposts_archive'])
|
$this->text .= $this->renderDefaultTemplate();
|
||||||
{
|
|
||||||
// return $this->show_newsarchive($newsAr,$interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->text = $this->renderDefaultTemplate();
|
|
||||||
|
|
||||||
if(isset($this->pref['nfp_display']) && $this->pref['nfp_display'] == 2 && is_readable(e_PLUGIN."newforumposts_main/newforumposts_main.php"))
|
if(isset($this->pref['nfp_display']) && $this->pref['nfp_display'] == 2 && is_readable(e_PLUGIN."newforumposts_main/newforumposts_main.php"))
|
||||||
{
|
{
|
||||||
@@ -101,6 +96,7 @@ class news_front
|
|||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->text .= $this->show_newsarchive();
|
||||||
$this->text .= $this->render_newscats();
|
$this->text .= $this->render_newscats();
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -159,10 +155,6 @@ class news_front
|
|||||||
$this->subAction= $sub_action;
|
$this->subAction= $sub_action;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -303,46 +295,47 @@ class news_front
|
|||||||
// ----------- old functions ------------------------
|
// ----------- old functions ------------------------
|
||||||
|
|
||||||
|
|
||||||
private function show_newsarchive($newsAr, $i = 1)
|
private function show_newsarchive()
|
||||||
{
|
{
|
||||||
global $ns, $gen, $tp, $news_archive_shortcodes, $NEWSARCHIVE, $news2;
|
|
||||||
|
|
||||||
$tp = e107::getParser();
|
|
||||||
// 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_CORE.'shortcodes/batch/news_archives.php');
|
if(empty($this->defaultTemplate) || !empty($this->action))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$textnewsarchive = '';
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
$i++; // First entry to show
|
global $NEWSARCHIVE;
|
||||||
while(isset($newsAr[$i]))
|
|
||||||
|
$sql = e107::getDb();
|
||||||
|
$tp = e107::getParser();
|
||||||
|
$ns = e107::getRender();
|
||||||
|
|
||||||
|
$query = $this->getQuery();
|
||||||
|
|
||||||
|
if($newsarchive = $this->checkCache('newsarchive'))
|
||||||
{
|
{
|
||||||
$news2 = $newsAr[$i];
|
$this->addDebug("News Archive Cache", 'active');
|
||||||
// Code from Lisa
|
return $newsarchive;
|
||||||
// copied from the rss creation, but added here to make sure the url for the newsitem is to the news.php?item.X
|
}
|
||||||
// instead of the actual hyperlink that may have been added to a newstitle on creation
|
|
||||||
$search = array();
|
|
||||||
$replace = array();
|
|
||||||
$search[0] = "/\<a href=\"(.*?)\">(.*?)<\/a>/si";
|
|
||||||
$replace[0] = '\\2';
|
|
||||||
$search[1] = "/\<a href='(.*?)'>(.*?)<\/a>/si";
|
|
||||||
$replace[1] = '\\2';
|
|
||||||
$search[2] = "/\<a href='(.*?)'>(.*?)<\/a>/si";
|
|
||||||
$replace[2] = '\\2';
|
|
||||||
$search[3] = "/\<a href="(.*?)">(.*?)<\/a>/si";
|
|
||||||
$replace[3] = '\\2';
|
|
||||||
$search[4] = "/\<a href='(.*?)'>(.*?)<\/a>/si";
|
|
||||||
$replace[4] = '\\2';
|
|
||||||
$news2['news_title'] = preg_replace($search, $replace, $news2['news_title']);
|
|
||||||
// End of code from Lisa
|
|
||||||
|
|
||||||
$gen = new convert;
|
$newsAr = array();
|
||||||
$news2['news_datestamp'] = $gen->convert_date($news2['news_datestamp'], "short");
|
|
||||||
|
if ($sql->gen($query))
|
||||||
|
{
|
||||||
|
$newsAr = $sql -> db_getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
$i = $this->interval;
|
||||||
|
|
||||||
|
|
||||||
if(!$NEWSARCHIVE){
|
// require_once(e_CORE.'shortcodes/batch/news_archives.php');
|
||||||
$NEWSARCHIVE ="<div>
|
$sc = e107::getScBatch('news_archive');
|
||||||
<table style='width:98%;'>
|
|
||||||
|
if(!$NEWSARCHIVE)
|
||||||
|
{
|
||||||
|
$NEWSARCHIVE ="<div>
|
||||||
|
<table style='width:100%;'>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div>{ARCHIVE_BULLET} <b>{ARCHIVE_LINK}</b> <span class='smalltext'><i>{ARCHIVE_AUTHOR} @ ({ARCHIVE_DATESTAMP}) ({ARCHIVE_CATEGORY})</i></span></div>
|
<div>{ARCHIVE_BULLET} <b>{ARCHIVE_LINK}</b> <span class='smalltext'><i>{ARCHIVE_AUTHOR} @ ({ARCHIVE_DATESTAMP}) ({ARCHIVE_CATEGORY})</i></span></div>
|
||||||
@@ -350,17 +343,24 @@ class news_front
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>";
|
</div>";
|
||||||
}
|
|
||||||
|
|
||||||
$textnewsarchive .= $tp->parseTemplate($NEWSARCHIVE, FALSE, $news_archive_shortcodes);
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$newsarchive = $ns->tablerender($this->pref['newsposts_archive_title'], $textnewsarchive, 'news_archive', true);
|
$text = '';
|
||||||
|
|
||||||
$this->setNewsCache('newsarchive', $newsarchive);
|
foreach($newsAr as $row)
|
||||||
|
{
|
||||||
|
$sc->setVars($row);
|
||||||
|
$text .= $tp->parseTemplate($NEWSARCHIVE, FALSE, $sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ret = $ns->tablerender($this->pref['newsposts_archive_title'], $text, 'news_archive', true);
|
||||||
|
|
||||||
|
$this->setNewsCache('newsarchive', $ret);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
|
||||||
return $newsarchive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1048,17 +1048,33 @@ class news_front
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function getQuery()
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
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 ".$this->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, ".$this->order." DESC LIMIT ".intval($this->from).",".ITEMVIEW;
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function renderDefaultTemplate()
|
private function renderDefaultTemplate()
|
||||||
{
|
{
|
||||||
$this->addDebug("Method",'renderDefaultTemplate()');
|
$this->addDebug("Method",'renderDefaultTemplate()');
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
|
|
||||||
if (empty($this->order))
|
|
||||||
{
|
|
||||||
$order = 'news_datestamp';
|
|
||||||
}
|
|
||||||
$order = $tp -> toDB($this->order, true); /// @todo - try not to use toDB() - triggers prefilter
|
|
||||||
|
|
||||||
$interval = $this->pref['newsposts'];
|
$interval = $this->pref['newsposts'];
|
||||||
|
|
||||||
@@ -1078,7 +1094,7 @@ class news_front
|
|||||||
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.")
|
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->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_category={$sub_action}
|
AND n.news_category={$sub_action}
|
||||||
ORDER BY n.news_sticky DESC,".$order." DESC LIMIT ".intval($this->from).",".ITEMVIEW;
|
ORDER BY n.news_sticky DESC,".$this->order." DESC LIMIT ".intval($this->from).",".ITEMVIEW;
|
||||||
|
|
||||||
$noNewsMessage = LAN_NEWS_463;
|
$noNewsMessage = LAN_NEWS_463;
|
||||||
break;
|
break;
|
||||||
@@ -1149,7 +1165,7 @@ class news_front
|
|||||||
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.")
|
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->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 (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) AND n.news_datestamp BETWEEN {$startdate} AND {$enddate}
|
AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) AND n.news_datestamp BETWEEN {$startdate} AND {$enddate}
|
||||||
ORDER BY ".$order." DESC LIMIT ".intval($this->from).",".ITEMVIEW;
|
ORDER BY ".$this->order." DESC LIMIT ".intval($this->from).",".ITEMVIEW;
|
||||||
|
|
||||||
$noNewsMessage = LAN_NEWS_462;
|
$noNewsMessage = LAN_NEWS_462;
|
||||||
|
|
||||||
@@ -1181,20 +1197,13 @@ class news_front
|
|||||||
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 (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))
|
AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))
|
||||||
GROUP by n.news_id
|
GROUP by n.news_id
|
||||||
ORDER BY news_sticky DESC, ".$order." DESC LIMIT ".intval($this->from).",".ITEMVIEW;
|
ORDER BY news_sticky DESC, ".$this->order." DESC LIMIT ".intval($this->from).",".ITEMVIEW;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$query = "
|
$query = $this->getQuery();
|
||||||
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 ".$this->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($this->from).",".ITEMVIEW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$noNewsMessage = LAN_NEWS_83;
|
$noNewsMessage = LAN_NEWS_83;
|
||||||
@@ -1227,6 +1236,9 @@ class news_front
|
|||||||
|
|
||||||
if ($sql->gen($query))
|
if ($sql->gen($query))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$newsAr = $sql -> db_getList();
|
$newsAr = $sql -> db_getList();
|
||||||
|
|
||||||
if($newsarchive = $this->checkCache('newsarchive'))
|
if($newsarchive = $this->checkCache('newsarchive'))
|
||||||
@@ -1235,7 +1247,7 @@ class news_front
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->show_newsarchive($newsAr,$interval);
|
// $this->show_newsarchive($newsAr,$interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user