From 57475d91bec00849987572b2929448d679b5c445 Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 11 Jan 2005 21:44:31 +0000 Subject: - 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 --- include/template.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'include/template.php') 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 -- cgit v1.2.3