Skip to content
Snippets Groups Projects
Commit e29549fe authored by Andreas Gohr's avatar Andreas Gohr
Browse files

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
parent 6e03f825
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment