diff options
Diffstat (limited to 'inc/parser/action.php')
-rw-r--r-- | inc/parser/action.php | 55 |
1 files changed, 55 insertions, 0 deletions
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 @@ <?php +/** + * + * @todo maybe wrap in class + * @todo rename to helper + */ + if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); function parse_to_instructions($text){ @@ -80,4 +86,53 @@ function render_as_xhtml($instructions){ return $Renderer->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; +} + ?> |