diff options
author | Andreas Gohr <andi@splitbrain.org> | 2006-06-18 13:35:32 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2006-06-18 13:35:32 +0200 |
commit | 796bafb3af11c7e4722b0053c663919808740953 (patch) | |
tree | 4836ed5823f246fd9ce9ed53374a7a050dd58f64 | |
parent | 1808c8dab0847f1c4b85b16d3d9544497e1c53a2 (diff) | |
download | rpg-796bafb3af11c7e4722b0053c663919808740953.tar.gz rpg-796bafb3af11c7e4722b0053c663919808740953.tar.bz2 |
updated hierarchical breadcrumbs
Third part of the global start series
darcs-hash:20060618113532-7ad00-46a62cc819c41ead8a16bc3f6c6d1bf67d9c6bf4.gz
-rw-r--r-- | inc/pageutils.php | 1 | ||||
-rw-r--r-- | inc/parserutils.php | 5 | ||||
-rw-r--r-- | inc/template.php | 74 |
3 files changed, 42 insertions, 38 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php index 29cb0379c..f9d182aac 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -309,7 +309,6 @@ function resolve_pageid($ns,&$page,&$exists){ }else{ // fall back to default $page = $page.$conf['start']; - $exists = false; } }else{ //check alternative plural/nonplural form diff --git a/inc/parserutils.php b/inc/parserutils.php index f2fe0ea48..dc6fe4fb9 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -482,9 +482,12 @@ function p_render($mode,$instructions,& $info){ * @author Andreas Gohr <andi@splitbrain.org> */ function p_get_first_heading($id){ + global $conf; + if(!$conf['useheading']) return null; + $meta = p_get_metadata($id); if($meta['title']) return $meta['title']; - return NULL; + return null; } //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/template.php b/inc/template.php index aace105d0..2cd4d0f06 100644 --- a/inc/template.php +++ b/inc/template.php @@ -558,52 +558,54 @@ function tpl_breadcrumbs(){ * @link http://wiki.splitbrain.org/wiki:tipsandtricks:hierarchicalbreadcrumbs * @todo May behave strangely in RTL languages */ -function tpl_youarehere(){ +function tpl_youarehere($sep=' » '){ global $conf; global $ID; global $lang; - //check if enabled + // check if enabled if(!$conf['youarehere']) return; - $parts = explode(':', $ID); - - print $lang['youarehere'].': '; - - //always print the startpage - if( $a_part[0] != $conf['start']){ - if($conf['useheading']){ - $pageName = p_get_first_heading($conf['start']); + $parts = explode(':', $ID); + $count = count($parts); + + echo $lang['youarehere'].': '; + + // always print the startpage + $title = p_get_first_heading($conf['start']); + if(!$title) $title = $conf['start']; + tpl_link(wl($conf['start']),$title,'title="'.$conf['start'].'"'); + + // print intermediate namespace links + $part = ''; + for($i=0; $i<$count - 1; $i++){ + $part .= $parts[$i].':'; + $page = $part; + resolve_pageid('',$page,$exists); + if ($page == $conf['start']) continue; // Skip startpage + + // output + echo $sep; + if($exists){ + $title = p_get_first_heading($page); + if(!$title) $title = $parts[$i]; + tpl_link(wl($page),$title,'title="'.$page.'"'); }else{ - $pageName = $conf['start']; + tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2"'); } - tpl_link(wl($conf['start']),$pageName,'title="'.$pageName.'"'); } - $page = ''; - foreach ($parts as $part){ - // Skip startpage if already done - if ($part == $conf['start']) continue; - - print ' » '; - $page .= $part; - - if(file_exists(wikiFN($page))){ - if($conf['useheading']){ - $pageName = p_get_first_heading($page); - $partName = $pageName; - }else{ - $pageName = $page; - $partName = $part; - } - tpl_link(wl($page),$partName,'title="'.$pageName.'"'); - }else{ - // Print the link, but mark as not-existing, as for other non-existing links - tpl_link(wl($page),$part,'title="'.$page.'" class="wikilink2"'); - //print $page; - } - - $page .= ':'; + // print current page, skipping start page, skipping for namespace index + if($page == $part.$parts[$i]) return; + $page = $part.$parts[$i]; + if($page == $conf['start']) return; + echo $sep; + if(file_exists(wikiFN($page))){ + $title = p_get_first_heading($page); + if(!$title) $title = $parts[$i]; + tpl_link(wl($page),$title,'title="'.$page.'"'); + }else{ + tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2"'); } } |