1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-05 02:15:13 +02:00

Fixes #4586, Fixes #2774, Fixes #49 - Workaround added for page dropdown navigation. Use {CPAGENAV: tmpl=dropdown} in page_template.php

This commit is contained in:
Cameron 2021-11-24 13:48:20 -08:00
parent 81cbe51228
commit 9fffa59a01
3 changed files with 33 additions and 7 deletions

View File

@ -25,7 +25,7 @@ class cpage_shortcodes extends e_shortcode
private $chapterData = array();
private $cpageFieldName = null;
private $breadcrumbComplete = false;
// Grab all book/chapter data.
function __construct()
{
@ -210,10 +210,30 @@ class cpage_shortcodes extends e_shortcode
// return $com['comment'].$com['moderate'].$com['comment_form'];
}
function sc_cpagenav()
/**
* @param array $parm
* @param string $parm['tmpl'] page|dropdown
* @usage {CPAGENAV}
* @usage {CPAGENAV: tmpl=dropdown}
*
* @return string|null
*/
function sc_cpagenav($parm=null)
{
return isset($this->var['np']) ? $this->var['np'] : null;
$titles = implode("|", $this->scVars->pageTitles);
$total_items = count($this->scVars->pageTitles);
$row = $this->var;
$row['page'] = '--FROM--';
$url = rawurlencode(e107::getUrl()->create('page/view', $row, 'allow=page_id,page_title,page_sef,page'));
$template = isset($parm['tmpl']) ? (string) $parm['tmpl'] : 'page';
$parms = 'nonavcount&bullet='.rawurlencode($this->scVars->bullet.' ').'&caption=<!-- Empty -->&'.'pagetitle='.rawurlencode($titles).'&tmpl_prefix='.deftrue('PAGE_NEXTPREV_TMPL', $template).'&total='.$total_items.'&amount=1&current='.$this->scVars->pageSelected.'&url='.$url;
$itext = ($total_items) ? e107::getParser()->parseTemplate("{NEXTPREV={$parms}}") : null;
return $itext;
}
function sc_cpagerating()

View File

@ -633,6 +633,9 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
$sc->__construct();
$sc->setVars($vars);
$sc->setScVar('pageTitles', []);
$sc->setScVar('pageSelected', 0);
$sc->setScVar('bullet', '');
$exclude = array('sc_cpagemessage'); // system messages

View File

@ -699,7 +699,7 @@ class pageClass
$pagenav = $rating = $comments = '';
if($this->authorized === true)
{
$pagenav = $this->pageIndex();
// $pagenav = $this->pageIndex();
$rating = $this->pageRating($this->page['page_rating_flag']);
$comments = $this->pageComment($this->page['page_comment_flag']);
}
@ -718,7 +718,7 @@ class pageClass
// ---- New --- -
$this->page['page_text'] = $this->pageToRender;
$this->page['np'] = $pagenav;
// $this->page['np'] = $pagenav;
$this->page['rating'] = $rating;
$this->page['comments'] = $comments;
$this->page['err'] = false;
@ -736,6 +736,9 @@ class pageClass
e107::getEvent()->trigger('user_page_item_viewed',$this->page);
$this->batch->setVars($this->page);
$this->batch->setScVar('pageTitles', $this->pageTitles);
$this->batch->setScVar('pageSelected', $this->pageSelected);
$this->batch->setScVar('bullet', $this->bullet);
$this->batch->breadcrumb();
$metaTitle = eHelper::formatMetaTitle($this->page['page_title']);
@ -1039,7 +1042,7 @@ class pageClass
}
/** @deprecated */
function pageIndex()
{
// Use always nextprev shortcode (with a special default 'page' tempalte)