mirror of
https://github.com/e107inc/e107.git
synced 2025-07-25 00:41:52 +02:00
Remove PHP Warnings. Next/Prev test added.
This commit is contained in:
@@ -58,7 +58,7 @@ class cpage_shortcodes extends e_shortcode
|
||||
function getChapter()
|
||||
{
|
||||
|
||||
$id = $this->var['page_chapter'];
|
||||
$id = varset($this->var['page_chapter']);
|
||||
|
||||
if(!empty($this->chapterData[$id]['chapter_id']) && $this->chapterData[$id]['chapter_parent'] > 0)
|
||||
{
|
||||
@@ -663,7 +663,8 @@ class cpage_shortcodes extends e_shortcode
|
||||
$action = varset($request['action']);
|
||||
|
||||
$row = $this->getChapter();
|
||||
$brow = $this->getBook($row['chapter_parent']);
|
||||
$parent = isset($row['chapter_parent']) ? (int) $row['chapter_parent'] : 0;
|
||||
$brow = $this->getBook($parent);
|
||||
|
||||
if(empty($brow['chapter_sef']) || $this->breadcrumbComplete === true || ($action === 'listBooks'))
|
||||
{
|
||||
|
@@ -191,6 +191,11 @@ class e_theme
|
||||
|
||||
$ret = [];
|
||||
|
||||
if(empty($themeXMLData))
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
foreach($themeXMLData as $info)
|
||||
{
|
||||
if(!isset($info['scope']))
|
||||
|
@@ -438,6 +438,62 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
|
||||
|
||||
}
|
||||
|
||||
// "Next/Prev"
|
||||
public function testPaginationShortCode()
|
||||
{
|
||||
require_once(e_CORE."shortcodes/single/nextprev.php");
|
||||
|
||||
$tests = array(
|
||||
0 => array(
|
||||
'parm' => array (
|
||||
'nonavcount' => '',
|
||||
'bullet' => '',
|
||||
'caption' => '',
|
||||
'pagetitle' => 'Page 1|Page1|Page2|Page3',
|
||||
'tmpl_prefix' => 'page',
|
||||
'total' => '4',
|
||||
'amount' => '1',
|
||||
'current' => '0',
|
||||
'url' => '/new-page-test?page=--FROM--',
|
||||
),
|
||||
'expected' => '
|
||||
<!-- Start of Next/Prev -->
|
||||
<div class="cpage-nav">
|
||||
<a class=\'cpage-np current\' href=\'#\' onclick=\'return false;\' title="Page 1">Page 1</a><br /> <a class=\'cpage-np\' href=\'/new-page-test?page=1\' title="Page1">Page1</a><br /> <a class=\'cpage-np\' href=\'/new-page-test?page=2\' title="Page2">Page2</a><br /> <a class=\'cpage-np\' href=\'/new-page-test?page=3\' title="Page3">Page3</a>
|
||||
</div>
|
||||
<!-- End of Next/Prev -->
|
||||
'),
|
||||
1 => array(
|
||||
'parm' => array (
|
||||
'nonavcount' => '',
|
||||
'bullet' => '',
|
||||
'caption' => '',
|
||||
'pagetitle' => 'Page 1|Page1|Page2|Page3',
|
||||
'tmpl_prefix' => 'dropdown',
|
||||
'total' => '4',
|
||||
'amount' => '1',
|
||||
'current' => '0',
|
||||
'url' => '/new-page-test?page=--FROM--',
|
||||
),
|
||||
'expected' => '
|
||||
<!-- Start of Next/Prev -->
|
||||
<div class="nextprev form-group form-inline input-group input-group-btn"><select class="tbox npdropdown nextprev-select form-control form-select" name="pageSelect" onchange="window.location.href=this.options[selectedIndex].value"><option value="/new-page-test?page=0" selected="selected">Page 1</option><option value="/new-page-test?page=1">Page1</option><option value="/new-page-test?page=2">Page2</option><option value="/new-page-test?page=3">Page3</option></select><a class="btn btn-default btn-outline-secondary nextprev-item next tbox npbutton" href="/new-page-test?page=1" title="Go to the next page">next</a></div>
|
||||
<!-- End of Next/Prev -->
|
||||
',
|
||||
),
|
||||
|
||||
|
||||
);
|
||||
|
||||
foreach($tests as $item)
|
||||
{
|
||||
$result = nextprev_shortcode($item['parm']);
|
||||
$this->assertSame($item['expected'], $result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testNewsArchiveShortcodes()
|
||||
{
|
||||
|
3
page.php
3
page.php
@@ -38,6 +38,7 @@ if(!e_QUERY)
|
||||
}
|
||||
elseif(vartrue($_GET['bk'])) // List Chapters within a specific Book
|
||||
{
|
||||
e107::getDebug()->log("Page Mode: Display list of chapters within a book");
|
||||
$id = $e107CorePage->setRequest('listChapters');
|
||||
$e107CorePage->listChapters($id);
|
||||
e107::canonical('page/book/index', $e107CorePage->getChapterData($id));
|
||||
@@ -50,6 +51,7 @@ elseif(vartrue($_GET['bk'])) // List Chapters within a specific Book
|
||||
}
|
||||
elseif(vartrue($_GET['ch'])) // List Pages within a specific Chapter
|
||||
{
|
||||
e107::getDebug()->log("Page Mode: Display list of pages within a chapter");
|
||||
$id = $e107CorePage->setRequest('listPages');
|
||||
$e107CorePage->listPages($id);
|
||||
$chData = $e107CorePage->getChapterData($id);
|
||||
@@ -64,6 +66,7 @@ elseif(vartrue($_GET['ch'])) // List Pages within a specific Chapter
|
||||
}
|
||||
else
|
||||
{
|
||||
e107::getDebug()->log("Page Mode: Display page");
|
||||
$e107CorePage->setRequest('showPage');
|
||||
$e107CorePage->processViewPage();
|
||||
$e107CorePage->setPage();
|
||||
|
Reference in New Issue
Block a user