mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Navigation compile/parser issues solved
This commit is contained in:
@@ -70,6 +70,13 @@ $NAVIGATION_TEMPLATE['main']['submenu_loweritem'] = '
|
||||
</li>
|
||||
';
|
||||
|
||||
$NAVIGATION_TEMPLATE['main']['submenu_loweritem_active'] = '
|
||||
<li role="menuitem" class="dropdown-submenu active">
|
||||
<a href="{LINK_URL}">{LINK_IMAGE}{LINK_NAME}</a>
|
||||
{LINK_SUB}
|
||||
</li>
|
||||
';
|
||||
|
||||
$NAVIGATION_TEMPLATE['main']['submenu_item_active'] = '
|
||||
<li role="menuitem" class="active">
|
||||
<a href="{LINK_URL}">{LINK_IMAGE}{LINK_NAME}</a>
|
||||
|
@@ -143,16 +143,6 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
|
||||
|
||||
$PAGE_TEMPLATE['nav']['end'] = '</ul>';
|
||||
|
||||
$PAGE_TEMPLATE['nav']['item_active'] = '
|
||||
<li class="active">
|
||||
<a role="button" href="{LINK_URL}">
|
||||
{LINK_IMAGE} {LINK_NAME}
|
||||
</a>
|
||||
</li>
|
||||
';
|
||||
|
||||
$PAGE_TEMPLATE['nav']['end'] = '</ul>';
|
||||
|
||||
|
||||
$PAGE_TEMPLATE['nav']['submenu_start'] = '<ul class="page-nav" id="page-nav-{LINK_PARENT}" role="menu" >';
|
||||
|
||||
@@ -170,6 +160,12 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
|
||||
{LINK_SUB}
|
||||
</li>
|
||||
';
|
||||
$PAGE_TEMPLATE['nav']['submenu_loweritem_active'] = '
|
||||
<li role="menuitem" class="active">
|
||||
<a href="{LINK_URL}">{LINK_IMAGE}{LINK_NAME}</a>
|
||||
{LINK_SUB}
|
||||
</li>
|
||||
';
|
||||
|
||||
$PAGE_TEMPLATE['nav']['submenu_item_active'] = '
|
||||
<li role="menuitem" class="active">
|
||||
|
@@ -1343,7 +1343,8 @@ class e_navigation
|
||||
if($val['link_parent'] == $pid)
|
||||
{
|
||||
$val['link_sub'] = $this->isDynamic($val);
|
||||
$this->compile($inArray, $val['link_sub'], $val['link_id']);
|
||||
// prevent loop of death
|
||||
if( $val['link_id'] != $pid) $this->compile($inArray, $val['link_sub'], $val['link_id']);
|
||||
$outArray[] = $val;
|
||||
}
|
||||
}
|
||||
@@ -1471,33 +1472,18 @@ class navigation_shortcodes extends e_shortcode
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX possible dead loop if LINK_SUB SC present in submenu_start template
|
||||
$text = e107::getParser()->parseTemplate($this->template['submenu_start'], true, $this);
|
||||
$text = e107::getParser()->parseTemplate(str_replace('{LINK_SUB}', '', $this->template['submenu_start']), true, $this);
|
||||
|
||||
foreach($this->var['link_sub'] as $val)
|
||||
{
|
||||
$this->setVars($val);
|
||||
$active = (e107::getNav()->isActive($val)) ? "_active" : "";
|
||||
$tmpl = vartrue($val['link_sub']) ? varset($this->template['submenu_loweritem']) : varset($this->template['submenu_item'.$active]);
|
||||
$tmpl = vartrue($val['link_sub']) ? varset($this->template['submenu_loweritem'.$active]) : varset($this->template['submenu_item'.$active]);
|
||||
$text .= e107::getParser()->parseTemplate($tmpl, TRUE);
|
||||
}
|
||||
|
||||
// XXX possible dead loop if LINK_SUB SC present in submenu_end template
|
||||
$text .= e107::getParser()->parseTemplate($this->template['submenu_end'], true, $this);
|
||||
$text .= e107::getParser()->parseTemplate(str_replace('{LINK_SUB}', '', $this->template['submenu_end']), true, $this);
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
@@ -15,7 +15,7 @@ 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.
|
||||
{
|
||||
// FIXME sitelink class should be page_sitelink
|
||||
$links = e107::getAddon('page', 'e_sitelink', 'page_sitelink');
|
||||
$links = e107::getAddon('page', 'e_sitelink');
|
||||
|
||||
$data = $links->pageNav($parm);
|
||||
|
||||
|
@@ -40,6 +40,28 @@ class page_sitelink // include plugin-folder in the name.
|
||||
$sublinks = array();
|
||||
$arr = array();
|
||||
|
||||
// map current when in auto mode
|
||||
if(vartrue($options['auto']))
|
||||
{
|
||||
// current book found, top book not set
|
||||
if(vartrue($options['cbook']) && !vartrue($options['book']))
|
||||
{
|
||||
$options['book'] = $options['cbook'];
|
||||
}
|
||||
|
||||
// current chapter found, top chapter not set
|
||||
if(vartrue($options['cchapter']) && !vartrue($options['chapter']))
|
||||
{
|
||||
$options['chapter'] = $options['cchapter'];
|
||||
}
|
||||
|
||||
// current chapter found, top chapter not set
|
||||
if(vartrue($options['cpage']) && !vartrue($options['page']))
|
||||
{
|
||||
$options['page'] = $options['cpage'];
|
||||
}
|
||||
}
|
||||
|
||||
// find the chapter if required
|
||||
if(vartrue($options['page']) && !vartrue($options['chapter']))
|
||||
{
|
||||
@@ -78,7 +100,7 @@ class page_sitelink // include plugin-folder in the name.
|
||||
'link_parent' => $row['page_chapter'],
|
||||
'link_open' => '',
|
||||
'link_class' => intval($row['page_class']),
|
||||
'link_active' => ($options['page'] && $row['page_id'] == $options['page']),
|
||||
'link_active' => ($options['cpage'] && $row['page_id'] == $options['cpage']),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -108,7 +130,6 @@ class page_sitelink // include plugin-folder in the name.
|
||||
$books = $sql->retrieve("SELECT * FROM #page_chapters WHERE ".$filter." ORDER BY chapter_order ASC" , true);
|
||||
foreach($books as $row)
|
||||
{
|
||||
|
||||
$arr[] = array(
|
||||
'link_id' => $row['chapter_id'],
|
||||
'link_name' => $row['chapter_name'],
|
||||
@@ -124,13 +145,12 @@ class page_sitelink // include plugin-folder in the name.
|
||||
'link_open' => '',
|
||||
'link_class' => 0,
|
||||
'link_sub' => varset($sublinks[$row['chapter_id']]),
|
||||
'link_active' => false,
|
||||
'link_active' => $row['chapter_parent'] == 0 ? $options['cbook'] && $options['cbook'] == $row['chapter_id'] : $options['cchapter'] && $options['cchapter'] == $row['chapter_id'],
|
||||
);
|
||||
$parent = vartrue($options['book']) ? intval($row['chapter_parent']) : 0;
|
||||
|
||||
}
|
||||
|
||||
$outArray = array();
|
||||
$parent = vartrue($options['book']) ? $options['book'] : 0;
|
||||
$ret = e107::getNav()->compile($arr, $outArray, $parent);
|
||||
|
||||
if(!$title) return $ret;
|
||||
|
@@ -12,33 +12,31 @@ if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
$template = e107::getCoreTemplate('page','nav');
|
||||
|
||||
### Auto mode - detect the current location
|
||||
if(empty($parm))
|
||||
$parm = eHelper::scParams($parm);
|
||||
$request = e107::getRegistry('core/pages/request');
|
||||
if($request && is_array($request))
|
||||
{
|
||||
$request = e107::getRegistry('core/pages/request');
|
||||
$parm = array();
|
||||
if($request && is_array($request))
|
||||
{
|
||||
switch ($request['action'])
|
||||
{
|
||||
case 'listChapters':
|
||||
$parm['book'] = $request['id'];
|
||||
$parm['cbook'] = $request['id'];
|
||||
break;
|
||||
|
||||
case 'listPages':
|
||||
$parm['chapter'] = $request['id'];
|
||||
$parm['cchapter'] = $request['id'];
|
||||
break;
|
||||
|
||||
case 'showPage':
|
||||
$parm['page'] = $request['id'];
|
||||
$parm['cpage'] = $request['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($parm) $parm = http_build_query($parm);
|
||||
}
|
||||
|
||||
if($parm) $parm = http_build_query($parm, null, '&');
|
||||
else $parm = '';
|
||||
|
||||
### Retrieve
|
||||
$links = e107::getAddon('page', 'e_sitelink', 'page_sitelink');
|
||||
$links = e107::getAddon('page', 'e_sitelink');
|
||||
$data = $links->pageNav($parm);
|
||||
if(isset($data['title']) && !vartrue($template['noAutoTitle']))
|
||||
{
|
||||
@@ -46,6 +44,8 @@ if(isset($data['title']) && !vartrue($template['noAutoTitle']))
|
||||
$template['caption'] = $data['title'];
|
||||
$data = $data['body'];
|
||||
}
|
||||
|
||||
if(empty($data)) return;
|
||||
$text = e107::getNav()->render($data, $template) ;
|
||||
|
||||
### Render
|
||||
|
Reference in New Issue
Block a user