aboutsummaryrefslogtreecommitdiffstats
path: root/include/template.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-01-11 21:44:31 +0000
committerplegall <plg@piwigo.org>2005-01-11 21:44:31 +0000
commit57475d91bec00849987572b2929448d679b5c445 (patch)
tree3d03815aa192f284e3287d8fa68cb4944f18216a /include/template.php
parent037885d2f3d33cd83f4d79415baa5cf7019b5461 (diff)
- new methods parse and p (for print) : enable PhpWebGallery pages to be
fully generated before being send to browser git-svn-id: http://piwigo.org/svn/trunk@687 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/template.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/template.php b/include/template.php
index 42353c8c1..32beecb9a 100644
--- a/include/template.php
+++ b/include/template.php
@@ -55,6 +55,9 @@ class Template {
// This will hold the uncompiled code for that handle.
var $uncompiled_code = array();
+
+ // output
+ var $output = '';
/**
* Constructor. Simply sets the root dir.
@@ -133,6 +136,39 @@ class Template {
eval($this->compiled_code[$handle]);
return true;
}
+
+ /**
+ * fills $output template var
+ */
+ function parse($handle)
+ {
+ if (!$this->loadfile($handle))
+ {
+ die("Template->pparse(): Couldn't load template file for handle $handle");
+ }
+
+ // actually compile the template now.
+ if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
+ {
+ // Actually compile the code now.
+ $this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle], true, '_str');
+ }
+
+ // Run the compiled code.
+ $_str = '';
+ eval($this->compiled_code[$handle]);
+ $this->output.= $_str;
+
+ return true;
+ }
+
+ /**
+ * prints $output template var
+ */
+ function p()
+ {
+ echo $this->output;
+ }
/**
* Inserts the uncompiled code for $handle as the value of $varname in the