mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
Improvements for {PAGE_NAVIGATION} shortcode. {PAGE_CHAPTER_NAME} and {PAGE_CHAPTER_DESCRIPTION} added.
This commit is contained in:
@@ -790,7 +790,7 @@ class e_parse_shortcode
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
if(preg_match('/^([A-Z]*):(.*)/', $matches[1], $newMatch))
|
||||
if(preg_match('/^([A-Z_]*):(.*)/', $matches[1], $newMatch))
|
||||
{
|
||||
$code = $newMatch[1];
|
||||
$parmStr = trim($newMatch[2]);
|
||||
|
@@ -12,29 +12,93 @@ if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
class page_shortcodes extends e_shortcode
|
||||
{
|
||||
function sc_page_navigation($parm) // TODO when No $parm provided, auto-detect based on URL which book/chapters to display.
|
||||
protected $request;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
// FIXME sitelink class should be page_sitelink
|
||||
$links = e107::getAddon('page', 'e_sitelink');
|
||||
|
||||
$data = $links->pageNav($parm);
|
||||
$this->request = e107::getRegistry('core/pages/request');
|
||||
|
||||
if(varset($this->request['action']) == 'listPages' && vartrue($this->request['id']))
|
||||
{
|
||||
$this->var = e107::getDb()->retrieve('page_chapters','chapter_name, chapter_meta_description','chapter_id = '.intval($this->request['id']).' LIMIT 1');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Page Navigation
|
||||
* @example {PAGE_NAVIGATION: template=navdoc&auto=1} in your Theme template.
|
||||
*/
|
||||
function sc_page_navigation($parm='') // TODO when No $parm provided, auto-detect based on URL which book/chapters to display.
|
||||
{
|
||||
// $parm = eHelper::scParams($parm);
|
||||
|
||||
$template = e107::getCoreTemplate('page','nav');
|
||||
$template = e107::getCoreTemplate('page',vartrue($parm['template'],'nav'), true, true); // always merge
|
||||
|
||||
$request = $this->request;
|
||||
|
||||
if($request && is_array($request))
|
||||
{
|
||||
switch ($request['action'])
|
||||
{
|
||||
case 'listChapters':
|
||||
$parm['cbook'] = $request['id'];
|
||||
break;
|
||||
|
||||
case 'listPages':
|
||||
$parm['cchapter'] = $request['id'];
|
||||
break;
|
||||
|
||||
case 'showPage':
|
||||
$parm['cpage'] = $request['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($parm)
|
||||
{
|
||||
$parm = http_build_query($parm, null, '&');
|
||||
}
|
||||
else
|
||||
{
|
||||
$parm = '';
|
||||
}
|
||||
|
||||
|
||||
$links = e107::getAddon('page', 'e_sitelink');
|
||||
$data = $links->pageNav($parm);
|
||||
|
||||
|
||||
if(isset($data['title']) && !vartrue($template['noAutoTitle']))
|
||||
{
|
||||
// use chapter title
|
||||
$template['caption'] = $data['title'];
|
||||
$data = $data['body'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(empty($data)){ return; }
|
||||
|
||||
return e107::getNav()->render($data, $template) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function sc_page_chapter_name($parm='')
|
||||
{
|
||||
return e107::getParser()->toHtml($this->var['chapter_name']);
|
||||
}
|
||||
|
||||
|
||||
function sc_page_chapter_description($parm='')
|
||||
{
|
||||
return e107::getParser()->toHtml($this->var['chapter_meta_description'],true);
|
||||
}
|
||||
|
||||
/**
|
||||
* New in v2.x. eg. {CMENU=feature-1} Renders a menu called 'feature-1' as found in the e107_page table See admin Pages/Menus .
|
||||
*/
|
||||
function sc_cmenu($parm='',$mode='')
|
||||
function sc_cmenu($parm='')
|
||||
{
|
||||
return e107::getMenu()->renderMenu($parm, false);
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
|
||||
//FIXME XXX - This menu should call the {PAGE_NAVIGATION} shortcode instead of duplicating its code and automatically display all links.
|
||||
|
||||
$parm = eHelper::scParams($parm);
|
||||
|
||||
|
@@ -416,8 +416,8 @@ $HEADER['docs'] = <<<TMPL
|
||||
================================================== -->
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<div class="container">
|
||||
<h1>{e_PAGETITLE}</h1>
|
||||
<p class="lead">How to get started..</p>
|
||||
<h1>{PAGE_CHAPTER_NAME}</h1>
|
||||
<p class="lead">{PAGE_CHAPTER_DESCRIPTION}</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -430,7 +430,7 @@ $HEADER['docs'] = <<<TMPL
|
||||
|
||||
<div class="span3 bs-docs-sidebar">
|
||||
{SETSTYLE=navdoc}
|
||||
{PLUGIN=page/page_navigation_menu|template=navdoc&auto=1}
|
||||
{PAGE_NAVIGATION: template=navdoc&auto=1}
|
||||
</div>
|
||||
{SETSTYLE=doc}
|
||||
|
||||
|
Reference in New Issue
Block a user