summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-06-18 14:15:21 +0200
committerAndreas Gohr <andi@splitbrain.org>2006-06-18 14:15:21 +0200
commit377f9e9776677a6d3963718bfd48bba361571dfb (patch)
treef2f6796ac0bd857566d8b640e04817484660cd0d
parent796bafb3af11c7e4722b0053c663919808740953 (diff)
downloadrpg-377f9e9776677a6d3963718bfd48bba361571dfb.tar.gz
rpg-377f9e9776677a6d3963718bfd48bba361571dfb.tar.bz2
simplified tpl_getparent
4th part of the global start series darcs-hash:20060618121521-7ad00-8ea574bdb2c8a12560cf892c7ed53a4972af998d.gz
-rw-r--r--inc/template.php32
1 files changed, 6 insertions, 26 deletions
diff --git a/inc/template.php b/inc/template.php
index 2cd4d0f06..78dc45e37 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -253,34 +253,14 @@ function tpl_pagelink($id,$name=NULL){
* Tries to find out which page is parent.
* returns false if none is available
*
- * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
-function tpl_getparent($ID){
+function tpl_getparent($id){
global $conf;
-
- if ($ID != $conf['start']) {
- $idparts = explode(':', $ID);
- $pn = array_pop($idparts); // get the page name
-
- for ($n=0; $n < 2; $n++) {
- if (count($idparts) == 0) {
- $ID = $conf['start']; // go to topmost page
- break;
- }else{
- $ns = array_pop($idparts); // get the last part of namespace
- if ($pn != $ns) { // are we already home?
- array_push($idparts, $ns, $ns); // no, then add a page with same name
- $ID = implode (':', $idparts); // as the namespace and recombine $ID
- break;
- }
- }
- }
-
- if (@file_exists(wikiFN($ID))) {
- return $ID;
- }
- }
- return false;
+ $parent = getNS($id).':';
+ resolve_pageid('',$parent,$exists);
+ if($parent == $id) return false;
+ return $parent;
}
/**