1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-07 23:26:41 +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

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