From 0e1c636e20bd809a1d388e0c6f630b0ecda7086b Mon Sep 17 00:00:00 2001 From: andi Date: Sat, 2 Apr 2005 17:48:29 +0200 Subject: new parser: correct pageresolving for internal links darcs-hash:20050402154829-9977f-f9576f4bafed9cbc9c15f14a41ad3410ec5c5970.gz --- inc/parser/action.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'inc/parser/action.php') diff --git a/inc/parser/action.php b/inc/parser/action.php index 34d71d3ae..67864b729 100644 --- a/inc/parser/action.php +++ b/inc/parser/action.php @@ -1,4 +1,10 @@ doc; } +/** + * Returns a full page id + * + */ +function resolve_pageid(&$page,&$exists){ + global $ID; + global $conf; + $ns = getNS($ID); + + //if links starts with . add current namespace + if($page{0} == '.'){ + $page = $ns.':'.substr($page,1); + } + + //if link contains no namespace. add current namespace (if any) + if($ns !== false && strpos($page,':') === false){ + $page = $ns.':'.$page; + } + + //keep hashlink if exists then clean both parts + list($page,$hash) = split('#',$page,2); + $page = cleanID($page); + $hash = cleanID($hash); + + $file = wikiFN($page); + + $exists = false; + + //check alternative plural/nonplural form + if(!@file_exists($file)){ + if( $conf['autoplural'] ){ + if(substr($page,-1) == 's'){ + $try = substr($page,0,-1); + }else{ + $try = $page.'s'; + } + if(@file_exists(wikiFN($try))){ + $page = $try; + $exists = true; + } + } + }else{ + $exists = true; + } + + //add hash if any + if(!empty($hash)) $page.'#'.$hash; +} + ?> -- cgit v1.2.3