1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

News are using nextprev templates now (new nextprev feature)

This commit is contained in:
secretr
2011-11-29 14:16:24 +00:00
parent e5e8a73eb6
commit 48b9ceb5d2

112
news.php
View File

@@ -2,7 +2,7 @@
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@@ -52,7 +52,7 @@ if (e_QUERY)
$tmp = explode(".",e_QUERY);
$action = $tmp[0]; // At least one parameter here
$sub_action = varset($tmp[1],''); // Usually a numeric category, or numeric news item number, but don't presume yet
// $id = varset($tmp[2],''); // ID of specific news item where required
// $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
$cacheString = 'news.php_'.e_QUERY;
}
@@ -78,16 +78,41 @@ if ($action == 'all' || $action == 'cat')
/*
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
$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;
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
// URL settings (nextprev)
$newsUrlparms = array('page' => '--FROM--');
if($sub_action)
{
switch ($action)
{
case 'list':
$newsUrlparms['id'] = $sub_action;
$newsRoute = 'list/category';
break;
case 'cat':
$newsUrlparms['id'] = $sub_action;
$newsRoute = 'list/short';
break;
default:
$newsRoute = 'list/items';
break;
}
}
else $newsRoute = 'list/items';
$newsRoute = 'news/'.$newsRoute;
//------------------------------------------------------
// DISPLAY NEWS IN 'CATEGORY' FORMAT HERE
//------------------------------------------------------
@@ -199,15 +224,18 @@ if ($action == 'cat' || $action == 'all')
$text .= $ix->render_newsitem($row, 'return', '', $NEWSLISTSTYLE, $param);
}
$amount = ($action == "all") ? NEWSALL_LIMIT : NEWSLIST_LIMIT;
$icon = ($row['category_icon']) ? "<img src='".e_IMAGE."icons/".$row['category_icon']."' alt='' />" : "";
// Deprecated.
// $parms = $news_total.",".$amount.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action={$action}&subaction={$category}");
$parms = $news_total.",".$amount.",".$newsfrom.",".e_SELF.'?'.$action.".".$category.".[FROM]";
$text .= "<div class='nextprev'>".$tp->parseTemplate("{NEXTPREV={$parms}}")."</div>";
// $parms = $news_total.",".$amount.",".$newsfrom.",".e_SELF.'?'.$action.".".$category.".[FROM]";
//
// $text .= "<div class='nextprev'>".$tp->parseTemplate("{NEXTPREV={$parms}}")."</div>";
$amount = ($action == "all") ? NEWSALL_LIMIT : 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.'&current='.$newsfrom.$nitems.'&url='.$url;
$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
if(!$NEWSLISTTITLE)
{
@@ -370,7 +398,7 @@ switch ($action)
{
case "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().")");
// $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}
@@ -446,7 +474,7 @@ switch ($action)
default :
$action = '';
$cacheString = 'news.php_default_'; // Make sure its sensible
// $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" );
// $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']))
{
@@ -493,10 +521,10 @@ if($newsCachedPage = checkCache($cacheString)) // normal news front-page - with
if(!$action)
{
// Removed, themes should use {FEATUREBOX} shortcode instead
// if (isset($pref['fb_active']))
// {
// require_once(e_PLUGIN."featurebox/featurebox.php");
// }
// if (isset($pref['fb_active']))
// {
// require_once(e_PLUGIN."featurebox/featurebox.php");
// }
if (isset($pref['nfp_display']) && $pref['nfp_display'] == 1)
{
require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php");
@@ -550,11 +578,11 @@ switch($action)
/*if($action != "" && !is_numeric($action))
{
if($action == "item" && $pref['meta_news_summary'] && $newsAr[1]['news_title'])
{
define("META_DESCRIPTION",SITENAME.": ".$newsAr[1]['news_title']." - ".$newsAr[1]['news_summary']);
}
define("e_PAGETITLE", $p_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("e_PAGETITLE", $p_title);
}*/
$currentNewsAction = $action;
@@ -564,9 +592,9 @@ $action = $currentNewsAction;
if(!$action)
{
// Removed, themes should use {FEATUREBOX} shortcode instead
// if (isset($pref['fb_active'])){ // --->feature box
// require_once(e_PLUGIN."featurebox/featurebox.php");
// }
// if (isset($pref['fb_active'])){ // --->feature box
// require_once(e_PLUGIN."featurebox/featurebox.php");
// }
if (isset($pref['nfp_display']) && $pref['nfp_display'] == 1){
require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php");
@@ -615,10 +643,18 @@ if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists(
// $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action=".($action ? $action : 'default' )."&subaction=".($sub_action ? $sub_action : "0"));
$sub_action = intval($sub_action);
$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>';
// $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]";
$amount = ITEMVIEW;
$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.'&current='.$newsfrom.$nitems.'&url='.$url;
$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
// $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
// $text .= ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
// $text=''.$text.'<center>'.$nextprev.'</center>';
echo $text;
setNewsCache($cacheString, $text);
@@ -661,10 +697,16 @@ else
$i++;
}
$sub_action = intval($sub_action);
$parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]";
$nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
echo ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
$amount = ITEMVIEW;
$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.'&current='.$newsfrom.$nitems.'&url='.$url;
echo $tp->parseTemplate("{NEXTPREV={$parms}}");
// $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]";
// $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
// echo ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
$cache_data = ob_get_clean();
require_once(HEADERF);
@@ -750,8 +792,8 @@ if ($action != "item") {
if(is_dir("remotefile")) {
require_once(e_HANDLER."file_class.php");
$file = new e_file;
// $reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*', 'Readme.txt');
// $crem = $file -> get_files(e_BASE."remotefile", "", $reject);
// $reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*', 'Readme.txt');
// $crem = $file -> get_files(e_BASE."remotefile", "", $reject);
$crem = $file -> get_files(e_BASE."remotefile", '~Readme\.txt');
if(count($crem)) {
foreach($crem as $loadrem) {