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> </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'] = ' $NAVIGATION_TEMPLATE['main']['submenu_item_active'] = '
<li role="menuitem" class="active"> <li role="menuitem" class="active">
<a href="{LINK_URL}">{LINK_IMAGE}{LINK_NAME}</a> <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']['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" >'; $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} {LINK_SUB}
</li> </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'] = ' $PAGE_TEMPLATE['nav']['submenu_item_active'] = '
<li role="menuitem" class="active"> <li role="menuitem" class="active">

View File

@@ -1343,7 +1343,8 @@ class e_navigation
if($val['link_parent'] == $pid) if($val['link_parent'] == $pid)
{ {
$val['link_sub'] = $this->isDynamic($val); $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; $outArray[] = $val;
} }
} }
@@ -1471,33 +1472,18 @@ class navigation_shortcodes extends e_shortcode
return; return;
} }
// XXX possible dead loop if LINK_SUB SC present in submenu_start template $text = e107::getParser()->parseTemplate(str_replace('{LINK_SUB}', '', $this->template['submenu_start']), true, $this);
$text = e107::getParser()->parseTemplate($this->template['submenu_start'], true, $this);
foreach($this->var['link_sub'] as $val) foreach($this->var['link_sub'] as $val)
{ {
$this->setVars($val); $this->setVars($val);
$active = (e107::getNav()->isActive($val)) ? "_active" : ""; $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); $text .= e107::getParser()->parseTemplate($tmpl, TRUE);
} }
// XXX possible dead loop if LINK_SUB SC present in submenu_end template $text .= e107::getParser()->parseTemplate(str_replace('{LINK_SUB}', '', $this->template['submenu_end']), true, $this);
$text .= e107::getParser()->parseTemplate($this->template['submenu_end'], true, $this);
return $text; 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. 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 // 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); $data = $links->pageNav($parm);

View File

@@ -40,6 +40,28 @@ class page_sitelink // include plugin-folder in the name.
$sublinks = array(); $sublinks = array();
$arr = 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 // find the chapter if required
if(vartrue($options['page']) && !vartrue($options['chapter'])) 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_parent' => $row['page_chapter'],
'link_open' => '', 'link_open' => '',
'link_class' => intval($row['page_class']), '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); $books = $sql->retrieve("SELECT * FROM #page_chapters WHERE ".$filter." ORDER BY chapter_order ASC" , true);
foreach($books as $row) foreach($books as $row)
{ {
$arr[] = array( $arr[] = array(
'link_id' => $row['chapter_id'], 'link_id' => $row['chapter_id'],
'link_name' => $row['chapter_name'], 'link_name' => $row['chapter_name'],
@@ -124,13 +145,12 @@ class page_sitelink // include plugin-folder in the name.
'link_open' => '', 'link_open' => '',
'link_class' => 0, 'link_class' => 0,
'link_sub' => varset($sublinks[$row['chapter_id']]), '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(); $outArray = array();
$parent = vartrue($options['book']) ? $options['book'] : 0;
$ret = e107::getNav()->compile($arr, $outArray, $parent); $ret = e107::getNav()->compile($arr, $outArray, $parent);
if(!$title) return $ret; if(!$title) return $ret;

View File

@@ -12,33 +12,31 @@ if (!defined('e107_INIT')) { exit; }
$template = e107::getCoreTemplate('page','nav'); $template = e107::getCoreTemplate('page','nav');
### Auto mode - detect the current location $parm = eHelper::scParams($parm);
if(empty($parm))
{
$request = e107::getRegistry('core/pages/request'); $request = e107::getRegistry('core/pages/request');
$parm = array();
if($request && is_array($request)) if($request && is_array($request))
{ {
switch ($request['action']) switch ($request['action'])
{ {
case 'listChapters': case 'listChapters':
$parm['book'] = $request['id']; $parm['cbook'] = $request['id'];
break; break;
case 'listPages': case 'listPages':
$parm['chapter'] = $request['id']; $parm['cchapter'] = $request['id'];
break; break;
case 'showPage': case 'showPage':
$parm['page'] = $request['id']; $parm['cpage'] = $request['id'];
break; break;
} }
} }
if($parm) $parm = http_build_query($parm);
} if($parm) $parm = http_build_query($parm, null, '&');
else $parm = '';
### Retrieve ### Retrieve
$links = e107::getAddon('page', 'e_sitelink', 'page_sitelink'); $links = e107::getAddon('page', 'e_sitelink');
$data = $links->pageNav($parm); $data = $links->pageNav($parm);
if(isset($data['title']) && !vartrue($template['noAutoTitle'])) if(isset($data['title']) && !vartrue($template['noAutoTitle']))
{ {
@@ -46,6 +44,8 @@ if(isset($data['title']) && !vartrue($template['noAutoTitle']))
$template['caption'] = $data['title']; $template['caption'] = $data['title'];
$data = $data['body']; $data = $data['body'];
} }
if(empty($data)) return;
$text = e107::getNav()->render($data, $template) ; $text = e107::getNav()->render($data, $template) ;
### Render ### Render