diff options
author | Michael Hamann <michael@content-space.de> | 2011-02-24 23:27:24 +0100 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2011-02-24 23:27:24 +0100 |
commit | f77fc90de1e477b721442757cd7413f91cccc044 (patch) | |
tree | 2abb734dacf39419b96b6b70c65115de57228fc3 /inc/common.php | |
parent | b8c040db1fdc0eee80963e57d95a15fd3813912d (diff) | |
parent | bd07158f0f2569ae470f980dd49d69b7f1fd2c49 (diff) | |
download | rpg-f77fc90de1e477b721442757cd7413f91cccc044.tar.gz rpg-f77fc90de1e477b721442757cd7413f91cccc044.tar.bz2 |
Merge branch 'master' into indexer_rewrite
Conflicts:
inc/fulltext.php
inc/indexer.php
lib/exe/indexer.php
Diffstat (limited to 'inc/common.php')
-rw-r--r-- | inc/common.php | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/inc/common.php b/inc/common.php index b4866bccf..ac7ddd653 100644 --- a/inc/common.php +++ b/inc/common.php @@ -639,7 +639,7 @@ function clientIP($single=false){ // decide which IP to use, trying to avoid local addresses $ip = array_reverse($ip); foreach($ip as $i){ - if(preg_match('/^(127\.|10\.|192\.168\.|172\.((1[6-9])|(2[0-9])|(3[0-1]))\.)/',$i)){ + if(preg_match('/^(::1|[fF][eE]80:|127\.|10\.|192\.168\.|172\.((1[6-9])|(2[0-9])|(3[0-1]))\.)/',$i)){ continue; }else{ return $i; @@ -804,7 +804,7 @@ function rawWiki($id,$rev=''){ /** * Returns the pagetemplate contents for the ID's namespace * - * @triggers COMMON_PAGE_FROMTEMPLATE + * @triggers COMMON_PAGETPL_LOAD * @author Andreas Gohr <andi@splitbrain.org> */ function pageTemplate($id){ @@ -812,29 +812,50 @@ function pageTemplate($id){ if (is_array($id)) $id = $id[0]; - $path = dirname(wikiFN($id)); - $tpl = ''; - if(@file_exists($path.'/_template.txt')){ - $tpl = io_readFile($path.'/_template.txt'); - }else{ - // search upper namespaces for templates - $len = strlen(rtrim($conf['datadir'],'/')); - while (strlen($path) >= $len){ - if(@file_exists($path.'/__template.txt')){ - $tpl = io_readFile($path.'/__template.txt'); - break; + // prepare initial event data + $data = array( + 'id' => $id, // the id of the page to be created + 'tpl' => '', // the text used as template + 'tplfile' => '', // the file above text was/should be loaded from + 'doreplace' => true // should wildcard replacements be done on the text? + ); + + $evt = new Doku_Event('COMMON_PAGETPL_LOAD',$data); + if($evt->advise_before(true)){ + // the before event might have loaded the content already + if(empty($data['tpl'])){ + // if the before event did not set a template file, try to find one + if(empty($data['tplfile'])){ + $path = dirname(wikiFN($id)); + $tpl = ''; + if(@file_exists($path.'/_template.txt')){ + $data['tplfile'] = $path.'/_template.txt'; + }else{ + // search upper namespaces for templates + $len = strlen(rtrim($conf['datadir'],'/')); + while (strlen($path) >= $len){ + if(@file_exists($path.'/__template.txt')){ + $data['tplfile'] = $path.'/__template.txt'; + break; + } + $path = substr($path, 0, strrpos($path, '/')); + } + } } - $path = substr($path, 0, strrpos($path, '/')); + // load the content + $data['tpl'] = io_readFile($data['tplfile']); } + if($data['doreplace']) parsePageTemplate(&$data); } - $data = compact('tpl', 'id'); - trigger_event('COMMON_PAGE_FROMTEMPLATE', $data, 'parsePageTemplate', true); + $evt->advise_after(); + unset($evt); + return $data['tpl']; } /** * Performs common page template replacements - * This is the default action for COMMON_PAGE_FROMTEMPLATE + * This works on data from COMMON_PAGETPL_LOAD * * @author Andreas Gohr <andi@splitbrain.org> */ |