Update of /cvsroot/phpwebapp/web_app
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30117
Modified Files:
class.WebApp.php
Log Message:
added the function WebApp::fill_template($tpl_file)
Index: class.WebApp.php
===================================================================
RCS file: /cvsroot/phpwebapp/web_app/class.WebApp.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** class.WebApp.php 22 Jul 2004 16:25:39 -0000 1.20
--- class.WebApp.php 7 Oct 2004 09:41:17 -0000 1.21
***************
*** 104,108 ****
global $render;
$render->collect = $collect;
- //$render = new RenderAnnotated($collect);
$render->render_MainTpl($webPage->rootTpl);
--- 104,107 ----
***************
*** 148,151 ****
--- 147,196 ----
/**
+ * Process the given template file and return it as
+ * a string where the variables have been replaced, etc.
+ * @see getHtmlPage()
+ */
+ function fill_template($tpl_file, $vars =array())
+ {
+ global $webPage, $tplVars, $parser, $render;
+
+ //save the current webPage and whatever
+ //is already constructed in it
+ $old_webPage = $webPage;
+ $old_tplVars = $tplVars;
+ $old_parser = $parser;
+ $old_render = $render;
+
+ //create a new web page in the global variable $webPage
+ $webPage = new WebPage;
+ $webPage->tpl_file = $tpl_file;
+ $tplVars = new VarStack;
+ $tplVars->addVars($vars);
+ $parser = new Parser;
+ $parser->xml_prolog = '<?xml version="1.0" encoding="iso-8859-1"?>
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
+ ';
+ $render = new Render;
+ $render->collect = true;
+
+ //construct it into the $html_page variable
+ $tpl = $parser->parse_file($tpl_file);
+ $render->render_tpl($tpl);
+ $html_page = $render->html_page;
+
+ //return to the previous web page
+ //and continue with its construction
+ $webPage = $old_webPage;
+ $tplVars = $old_tplVars;
+ $parser = $old_parser;
+ $render = $old_render;
+
+ //return the constructed page
+ return $html_page;
+ }
+
+ /**
* This function stops loading the current page
* and starts loading and constructing the given page.
|