summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/common.php10
-rw-r--r--inc/html.php12
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