diff options
author | andi <andi@splitbrain.org> | 2005-04-02 17:48:29 +0200 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-04-02 17:48:29 +0200 |
commit | 0e1c636e20bd809a1d388e0c6f630b0ecda7086b (patch) | |
tree | 5617c75e2a337c861585aaaab7468171d65544a9 /inc/parser/action.php | |
parent | 3fc748361df73d42ec30804c3e0fdfad1fb945e8 (diff) | |
download | rpg-0e1c636e20bd809a1d388e0c6f630b0ecda7086b.tar.gz rpg-0e1c636e20bd809a1d388e0c6f630b0ecda7086b.tar.bz2 |
new parser: correct pageresolving for internal links
darcs-hash:20050402154829-9977f-f9576f4bafed9cbc9c15f14a41ad3410ec5c5970.gz
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; +} + ?> |