[Cs-content-commits] SF.net SVN: cs-content:[444] trunk/1.0/cs_genericPage.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-08-18 20:36:07
|
Revision: 444 http://cs-content.svn.sourceforge.net/cs-content/?rev=444&view=rev Author: crazedsanity Date: 2009-08-18 20:35:56 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Minor modifications after more unit testing. /cs_genericPage.class.php: * print_page(): -- reset internal "unhandledVars" array so it doesn't get updated erroneously. * strip_undef_template_vars(): -- ARG CHANGE: NEW ARG: #2 (array &$unhandled=null) -- this will eventually be called from print_page(), as the only difference was that print_page() stores unhandledVars. -- if the second argument is an array, it updates that with the list of unhandled vars. * strip_undef_template_vars_from_section(): -- added a comment to explain code that otherwise looks a bit like it would continuously call itself... Modified Paths: -------------- trunk/1.0/cs_genericPage.class.php Modified: trunk/1.0/cs_genericPage.class.php =================================================================== --- trunk/1.0/cs_genericPage.class.php 2009-08-18 20:31:49 UTC (rev 443) +++ trunk/1.0/cs_genericPage.class.php 2009-08-18 20:35:56 UTC (rev 444) @@ -268,6 +268,7 @@ * @return (str) Final, parsed page. */ public function print_page($stripUndefVars=1) { + $this->unhandledVars = array(); //Show any available messages. $this->process_set_message(); @@ -630,7 +631,7 @@ //------------------------------------------------------------------------- - public function strip_undef_template_vars($templateContents) { + public function strip_undef_template_vars($templateContents, array &$unhandled=null) { $numLoops = 0; while(preg_match_all('/\{.\S+?\}/', $templateContents, $tags) && $numLoops < 50) { $tags = $tags[0]; @@ -641,6 +642,9 @@ $str2 = str_replace("}", "", $str2); if(!$this->templateVars[$str2]) { //TODO: set an internal pointer or something to use here, so they can see what was missed. + if(is_array($unhandled)) { + $unhandled[$str2]++; + } $templateContents = str_replace($str, '', $templateContents); } } @@ -655,6 +659,7 @@ //------------------------------------------------------------------------- public function strip_undef_template_vars_from_section($section='content') { if(isset($this->templateVars[$section])) { + //rip out undefined vars from the contents of the given section. $this->templateVars[$section] = $this->strip_undef_template_vars($this->templateVars[$section]); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |