Skip to content
Snippets Groups Projects
Commit 377f9e97 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

simplified tpl_getparent

4th part of the global start series

darcs-hash:20060618121521-7ad00-8ea574bdb2c8a12560cf892c7ed53a4972af998d.gz
parent 796bafb3
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment