diff options
author | Andreas Gohr <andi@splitbrain.org> | 2005-07-18 19:38:42 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2005-07-18 19:38:42 +0200 |
commit | 7146cee21edfdc97ce25d1b5536817f301dc916b (patch) | |
tree | c64f55166fe9111c133f8385ba0f9b4769f0abbd | |
parent | 87c434ceeeeb15fff4bbada53294c4dd63ecd9f6 (diff) | |
download | rpg-7146cee21edfdc97ce25d1b5536817f301dc916b.tar.gz rpg-7146cee21edfdc97ce25d1b5536817f301dc916b.tar.bz2 |
pagetemplate support #104
This adds very simple pagetemplate support. When a file named _template.txt
exists in a namespace this file's contents are loaded into the editor when
a new page is added in the namespace.
Please note that this file is not editable from within the Wiki as it starts
with an underscore. The wiki admin has to create it her self on the
filesystem.
darcs-hash:20050718173842-7ad00-39b1b76bef4c6243fc00d94673793d68b356aecb.gz
-rw-r--r-- | inc/common.php | 10 | ||||
-rw-r--r-- | inc/html.php | 12 |
2 files changed, 19 insertions, 3 deletions
diff --git a/inc/common.php b/inc/common.php index af0123fcd..f40c8f1fd 100644 --- a/inc/common.php +++ b/inc/common.php @@ -397,6 +397,16 @@ function rawWiki($id,$rev=''){ } /** + * Returns the pagetemplate contents for the ID's namespace + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function pageTemplate($id){ + return io_readFile(dirname(wikiFN($id)).'/_template.txt'); +} + + +/** * Returns the raw Wiki Text in three slices. * * The range parameter needs to have the form "from-to" diff --git a/inc/html.php b/inc/html.php index 8e576bb58..7768a1005 100644 --- a/inc/html.php +++ b/inc/html.php @@ -817,6 +817,7 @@ function html_register(){ /** * This displays the edit form (lots of logic included) * + * @fixme this is a huge lump of code and should be modularized * @author Andreas Gohr <andi@splitbrain.org> */ function html_edit($text=null,$include='edit'){ //FIXME: include needed? @@ -843,10 +844,15 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? //no text? Load it! if(!isset($text)){ $pr = false; //no preview mode - if($RANGE){ - list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); + if($INFO['exists']){ + if($RANGE){ + list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); + }else{ + $text = rawWiki($ID,$REV); + } }else{ - $text = rawWiki($ID,$REV); + //try to load a pagetemplate + $text = pageTemplate($ID); } }else{ $pr = true; //preview mode |