1
0
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:
SecretR
2013-03-08 13:08:06 +02:00
parent ff5f27581e
commit 1396cfbb69
6 changed files with 67 additions and 58 deletions

View File

@@ -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>

View File

@@ -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">

View File

@@ -1303,7 +1303,7 @@ class e_navigation
foreach ($data as $_data)
{
$sc->setVars($_data);
$active = ($this->isActive($_data)) ? "_active" : "";
$active = ($this->isActive($_data)) ? "_active" : "";
$itemTmpl = count($_data['link_sub']) > 0 ? $template['item_submenu'.$active] : $template['item'.$active];
$ret .= e107::getParser()->parseTemplate($itemTmpl, TRUE);
}
@@ -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]);
$active = (e107::getNav()->isActive($val)) ? "_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;
}
}
?>

View File

@@ -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);

View File

@@ -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;

View File

@@ -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'])
{
switch ($request['action'])
{
case 'listChapters':
$parm['book'] = $request['id'];
break;
case 'listPages':
$parm['chapter'] = $request['id'];
break;
case 'showPage':
$parm['page'] = $request['id'];
break;
}
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);
}
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