From 671a58a68aaa7c847262d0c5c34541e6d214b5fc Mon Sep 17 00:00:00 2001 From: Guy Brand Date: Fri, 30 Mar 2007 23:28:02 +0200 Subject: Namespace autolinking from URL (FS#991 fix) You can now request doku.php?id darcs-hash:20070330212802-19e2d-d1988ade1a9cd5f898ecb0a55d09860d0193a84d.gz --- inc/pageutils.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'inc/pageutils.php') diff --git a/inc/pageutils.php b/inc/pageutils.php index 243d9ae1d..659f82298 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -52,6 +52,25 @@ function getID($param='id',$clean=true){ //strip leading slashes $id = preg_replace('!^/+!','',$id); } + + // Namespace autolinking from URL + if(substr($id,-1) == ':' || ($conf['useslash'] && substr($id,-1) == '/')){ + if(@file_exists(wikiFN($id.$conf['start']))){ + // start page inside namespace + $id = $id.$conf['start']; + }elseif(@file_exists(wikiFN($id.noNS(cleanID($id))))){ + // page named like the NS inside the NS + $id = $id.noNS(cleanID($id)); + }elseif(@file_exists(wikiFN($id))){ + // page like namespace exists + $id = $id; + }else{ + // fall back to default + $id = $id.$conf['start']; + } + header("Location: ".wl($id,'',true)); + } + if($clean) $id = cleanID($id); if(empty($id) && $param=='id') $id = $conf['start']; -- cgit v1.2.3