summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2008-01-26 17:59:59 +0100
committerAndreas Gohr <andi@splitbrain.org>2008-01-26 17:59:59 +0100
commite29549fe009f3e56c93b04cd8278d38df1253a20 (patch)
tree659e4b0ce2d2547c7f54f483a73538838e13b4df /inc
parent6e03f825b8414f0daf4937eb48d6c894d870943e (diff)
downloadrpg-e29549fe009f3e56c93b04cd8278d38df1253a20.tar.gz
rpg-e29549fe009f3e56c93b04cd8278d38df1253a20.tar.bz2
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
Diffstat (limited to 'inc')
-rw-r--r--inc/common.php21
1 files changed, 20 insertions, 1 deletions
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;
}