From fe17917e7668864526ec0f0ae65dd0787831d8a4 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 10 Mar 2010 10:41:32 +0100 Subject: Move & rename HTML_PAGE_FROMTEMPLATE to common.php The new COMMON_PAGE_FROMTEMPLATE is triggered by pageTemplate AFTER the template has been read but before performing the template replacements. --- inc/actions.php | 3 +-- inc/common.php | 17 ++++++++++++----- inc/html.php | 1 - lib/exe/xmlrpc.php | 3 +-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/inc/actions.php b/inc/actions.php index 01d1d29d4..6ce67eb9a 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -474,8 +474,7 @@ function act_edit($act){ $TEXT = rawWiki($ID,$REV); } } else { - $data = array($ID); - $TEXT = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); + $TEXT = pageTemplate($ID); } } diff --git a/inc/common.php b/inc/common.php index 0d5efbee9..6601ae478 100644 --- a/inc/common.php +++ b/inc/common.php @@ -809,14 +809,16 @@ function rawWiki($id,$rev=''){ /** * Returns the pagetemplate contents for the ID's namespace * + * @triggers COMMON_PAGE_FROMTEMPLATE * @author Andreas Gohr */ -function pageTemplate($data){ - $id = $data[0]; +function pageTemplate($id){ global $conf; - $path = dirname(wikiFN($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{ @@ -830,15 +832,20 @@ function pageTemplate($data){ $path = substr($path, 0, strrpos($path, '/')); } } - return isset($tpl) ? parsePageTemplate($tpl, $id) : ''; + $data = compact('tpl', 'id'); + trigger_event('COMMON_PAGE_FROMTEMPLATE', $data, 'parsePageTemplate', true); + return $data['tpl']; } /** * Performs common page template replacements + * This is the default action for COMMON_PAGE_FROMTEMPLATE * * @author Andreas Gohr */ -function parsePageTemplate($tpl, $id) { +function parsePageTemplate($data) { + extract($data); + global $USERINFO; global $conf; diff --git a/inc/html.php b/inc/html.php index ae3e56e0a..cfa4dbe3d 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1127,7 +1127,6 @@ function html_updateprofile(){ /** * Preprocess edit form data * - * @triggers HTML_PAGE_FROMTEMPLATE * @author Andreas Gohr */ function html_edit(){ diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index a29a40612..155812d22 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -290,8 +290,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } $text = rawWiki($id,$rev); if(!$text) { - $data = array($id); - return trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); + return pageTemplate($id); } else { return $text; } -- cgit v1.2.3