diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php index ee89aea75..24c833179 100644 --- a/e107_core/shortcodes/batch/page_shortcodes.php +++ b/e107_core/shortcodes/batch/page_shortcodes.php @@ -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=&'.'pagetitle='.rawurlencode($titles).'&tmpl_prefix='.deftrue('PAGE_NEXTPREV_TMPL', $template).'&total='.$total_items.'&amount=1¤t='.$this->scVars->pageSelected.'&url='.$url; + $itext = ($total_items) ? e107::getParser()->parseTemplate("{NEXTPREV={$parms}}") : null; + + return $itext; } function sc_cpagerating() diff --git a/e107_tests/tests/unit/e_parse_shortcodeTest.php b/e107_tests/tests/unit/e_parse_shortcodeTest.php index f9c081a08..1194b1581 100644 --- a/e107_tests/tests/unit/e_parse_shortcodeTest.php +++ b/e107_tests/tests/unit/e_parse_shortcodeTest.php @@ -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 diff --git a/page.php b/page.php index e0c42c73d..366338b49 100644 --- a/page.php +++ b/page.php @@ -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)