mirror of
https://github.com/e107inc/e107.git
synced 2025-08-07 15:16:30 +02:00
Fixes #4805 News pagination in 'page' mode.
This commit is contained in:
@@ -43,6 +43,7 @@ class news_front
|
|||||||
private $dayMonth = null;
|
private $dayMonth = null;
|
||||||
private $tagAuthor = null;
|
private $tagAuthor = null;
|
||||||
private $comments = array();
|
private $comments = array();
|
||||||
|
private $pagination;
|
||||||
// private $interval = 1;
|
// private $interval = 1;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
@@ -56,6 +57,8 @@ class news_front
|
|||||||
$this->pref = e107::getPref();
|
$this->pref = e107::getPref();
|
||||||
|
|
||||||
$this->cacheRefreshTime = vartrue($this->pref['news_cache_timeout'],false);
|
$this->cacheRefreshTime = vartrue($this->pref['news_cache_timeout'],false);
|
||||||
|
|
||||||
|
$this->pagination = varset($this->pref['news_pagination'], 'record');
|
||||||
// $this->interval = $this->pref['newsposts']-$this>pref['newsposts_archive'];
|
// $this->interval = $this->pref['newsposts']-$this>pref['newsposts_archive'];
|
||||||
|
|
||||||
require_once(e_HANDLER."news_class.php");
|
require_once(e_HANDLER."news_class.php");
|
||||||
@@ -1118,13 +1121,9 @@ class news_front
|
|||||||
|
|
||||||
$icon = ($row['category_icon']) ? "<img src='".e_IMAGE."icons/".$row['category_icon']."' alt='' />" : "";
|
$icon = ($row['category_icon']) ? "<img src='".e_IMAGE."icons/".$row['category_icon']."' alt='' />" : "";
|
||||||
|
|
||||||
|
$parms = $this->getPaginationParms($news_total, NEWSLIST_LIMIT);
|
||||||
|
|
||||||
$amount = NEWSLIST_LIMIT;
|
|
||||||
$nitems = defined('NEWS_NEXTPREV_NAVCOUNT') ? '&navcount='.NEWS_NEXTPREV_NAVCOUNT : '' ;
|
|
||||||
$url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms));
|
|
||||||
$parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url;
|
|
||||||
|
|
||||||
$this->addDebug('newsUrlParms',$this->newsUrlparms);
|
|
||||||
|
|
||||||
$paginationSC = false;
|
$paginationSC = false;
|
||||||
if(!empty($template['end']))
|
if(!empty($template['end']))
|
||||||
@@ -1724,24 +1723,9 @@ class news_front
|
|||||||
|
|
||||||
$text = $tp->parseTemplate($NEWSCLAYOUT, false, $items);
|
$text = $tp->parseTemplate($NEWSCLAYOUT, false, $items);
|
||||||
|
|
||||||
// $text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSCLAYOUT);
|
$parms = $this->getPaginationParms($news_total, ITEMVIEW);
|
||||||
|
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
// $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]";
|
|
||||||
|
|
||||||
$amount = ITEMVIEW;
|
|
||||||
$nitems = defined('NEWS_NEXTPREV_NAVCOUNT') ? '&navcount='.NEWS_NEXTPREV_NAVCOUNT : '' ;
|
|
||||||
$url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms));
|
|
||||||
$parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url;
|
|
||||||
|
|
||||||
$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
|
$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
|
||||||
// This section is deprecated so no pagination shortcode support should be added.
|
// This section is deprecated so no pagination shortcode support should be added.
|
||||||
|
|
||||||
// echo $text;
|
|
||||||
$this->setNewsCache($this->cacheString, $text);
|
$this->setNewsCache($this->cacheString, $text);
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -1924,19 +1908,7 @@ class news_front
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$parms = $this->getPaginationParms($news_total, ITEMVIEW);
|
||||||
|
|
||||||
$amount = ITEMVIEW;
|
|
||||||
$nitems = defined('NEWS_NEXTPREV_NAVCOUNT') ? '&navcount='.NEWS_NEXTPREV_NAVCOUNT : '' ;
|
|
||||||
$url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms));
|
|
||||||
|
|
||||||
$this->addDebug('News Pagination Parms', $this->newsUrlparms);
|
|
||||||
|
|
||||||
// Example of passing route data instead building the URL outside the shortcode - for a reference only
|
|
||||||
// $url = rawurlencode('url::'.$newsRoute.'::'.http_build_query($newsUrlparms, null, '&'));
|
|
||||||
|
|
||||||
$parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url;
|
|
||||||
|
|
||||||
$paginationSC = false;
|
$paginationSC = false;
|
||||||
|
|
||||||
if(!empty($tmpl['end']))
|
if(!empty($tmpl['end']))
|
||||||
@@ -1965,6 +1937,44 @@ class news_front
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $total
|
||||||
|
* @param int $amount
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getPaginationParms($total, $amount)
|
||||||
|
{
|
||||||
|
|
||||||
|
$opts = [
|
||||||
|
'tmpl_prefix' => deftrue('NEWS_NEXTPREV_TMPL', 'default'),
|
||||||
|
'total' => (int) $total,
|
||||||
|
'amount' => (int) $amount,
|
||||||
|
'current' => $this->from,
|
||||||
|
'url' => e107::getUrl()->create($this->route, $this->newsUrlparms),
|
||||||
|
];
|
||||||
|
|
||||||
|
if(defined('NEWS_NEXTPREV_NAVCOUNT'))
|
||||||
|
{
|
||||||
|
$opts['navcount'] = NEWS_NEXTPREV_NAVCOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->pagination === 'page')
|
||||||
|
{
|
||||||
|
$opts['type'] = 'page';
|
||||||
|
$opts['total'] = ceil($opts['total'] / $opts['amount']);
|
||||||
|
$opts['current'] = ($opts['current'] / $opts['amount']) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addDebug('newsUrlParms', $this->newsUrlparms);
|
||||||
|
$this->addDebug('paginationParms', $opts);
|
||||||
|
|
||||||
|
// $parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url;
|
||||||
|
|
||||||
|
$parms = http_build_query($opts);
|
||||||
|
|
||||||
|
return $parms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newsObj = new news_front;
|
$newsObj = new news_front;
|
||||||
|
Reference in New Issue
Block a user