[phpwebapp-commits] CVS: web_app class.WebApp.php,1.12.2.1,1.12.2.2
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-10-07 09:58:29
|
Update of /cvsroot/phpwebapp/web_app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1192 Modified Files: Tag: phpwebapp-1_0 class.WebApp.php Log Message: Index: class.WebApp.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/class.WebApp.php,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -C2 -d -r1.12.2.1 -r1.12.2.2 *** class.WebApp.php 4 Oct 2004 09:09:31 -0000 1.12.2.1 --- class.WebApp.php 7 Oct 2004 09:58:16 -0000 1.12.2.2 *************** *** 148,151 **** --- 148,192 ---- /** + * 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; + $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. *************** *** 156,160 **** function reloadPage($tpl_file=UNDEFINED) { ! global $webPage, $tplVars; if ($tpl_file==UNDEFINED) //no parameter given --- 197,201 ---- function reloadPage($tpl_file=UNDEFINED) { ! global $webPage, $tplVars, $parser; if ($tpl_file==UNDEFINED) //no parameter given *************** *** 163,171 **** $tpl_file = $webPage->tpl_file; } ! unset($webPage); ! unset($varStack); ! $webPage = new WebPage; $tplVars = new VarStack; ! $webPage->load($tpl_file); } --- 204,214 ---- $tpl_file = $webPage->tpl_file; } ! //XX $tplVars = new VarStack; ! $parser = new Parser; ! print "<xmp>--------------------------------------</xmp>\n"; //XX ! $parser->parse_main(TPL_PATH.$tpl_file); ! global $webapp_stop_parser; ! $webapp_stop_parser = true; } |