From e29549fe009f3e56c93b04cd8278d38df1253a20 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 26 Jan 2008 17:59:59 +0100 Subject: Support for deep namespace templates and strftime placeholders This patch addes namespace templates will be used for all new namespaces in the same namespace and the namespaces below. They have to be named __template.txt Additionally can strftime() place holders be used in namespace templates to insert any part of the current time into a template. darcs-hash:20080126165959-7ad00-9a820e42d237e1aa0828996ebc9cf3d67d453128.gz --- inc/common.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index e5a833d55..25dffdf94 100644 --- a/inc/common.php +++ b/inc/common.php @@ -708,7 +708,25 @@ function pageTemplate($data){ $id = $data[0]; global $conf; global $INFO; - $tpl = io_readFile(dirname(wikiFN($id)).'/_template.txt'); + + $path = dirname(wikiFN($id)); + + 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; + } + $path = substr($path, 0, strrpos($path, '/')); + } + } + if(!$tpl) return ''; + + // replace placeholders $tpl = str_replace('@ID@',$id,$tpl); $tpl = str_replace('@NS@',getNS($id),$tpl); $tpl = str_replace('@PAGE@',strtr(noNS($id),'_',' '),$tpl); @@ -716,6 +734,7 @@ function pageTemplate($data){ $tpl = str_replace('@NAME@',$INFO['userinfo']['name'],$tpl); $tpl = str_replace('@MAIL@',$INFO['userinfo']['mail'],$tpl); $tpl = str_replace('@DATE@',date($conf['dformat']),$tpl); + $tpl = strftime($tpl); return $tpl; } -- cgit v1.2.3