diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-07-01 14:36:57 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-07-01 14:36:57 +0200 |
commit | 35a00f69494a05af349fa86a0fbd4f7641a384e4 (patch) | |
tree | c4a2c161e026f8ff854cc4ce7cb63ca946ea67ce /inc/pageutils.php | |
parent | 578b2c23b773d74f9fc04c48baa5f826020209ba (diff) | |
parent | e66d3e6dfa7ba6f0cf55b58f0b00b66b52c98321 (diff) | |
download | rpg-35a00f69494a05af349fa86a0fbd4f7641a384e4.tar.gz rpg-35a00f69494a05af349fa86a0fbd4f7641a384e4.tar.bz2 |
Merge branch 'sidebar'
* sidebar:
Improved sidebar inclusion
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r-- | inc/pageutils.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php index c94d14624..f525c44d0 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -622,3 +622,27 @@ function utf8_decodeFN($file){ return urldecode($file); } +/** + * Find a page in the current namespace (determined from $ID) or any + * higher namespace + * + * Used for sidebars, but can be used other stuff as well + * + * @todo add event hook + * @param string $page the pagename you're looking for + * @return string|false the full page id of the found page, false if any + */ +function page_findnearest($page){ + global $ID; + + $ns = $ID; + do { + $ns = getNS($ns); + $pageid = ltrim("$ns:$page",':'); + if(page_exists($pageid)){ + return $pageid; + } + } while($ns); + + return false; +} |