summaryrefslogtreecommitdiff
path: root/inc/pageutils.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r--inc/pageutils.php19
1 files changed, 19 insertions, 0 deletions
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'];