[Cs-content-commits] SF.net SVN: cs-content:[484] trunk/1.0/cs_globalFunctions.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2010-09-01 14:03:09
|
Revision: 484 http://cs-content.svn.sourceforge.net/cs-content/?rev=484&view=rev Author: crazedsanity Date: 2010-09-01 14:03:03 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Minor feature addition + exception on invalid data. /cs_globalFunctions.class.php: * debug_print(): -- ARG CHANGE: NEW ARG: #4 ($usePreTags=true) -- don't wrap the output with "<pre></pre>" if $usePreTags is false; set default value as true to keep normal behaviour if not specified. * mini_parser(): -- throw an exception if no array was passed. Modified Paths: -------------- trunk/1.0/cs_globalFunctions.class.php Modified: trunk/1.0/cs_globalFunctions.class.php =================================================================== --- trunk/1.0/cs_globalFunctions.class.php 2010-08-12 15:10:22 UTC (rev 483) +++ trunk/1.0/cs_globalFunctions.class.php 2010-09-01 14:03:03 UTC (rev 484) @@ -617,7 +617,7 @@ * * @return (string) printed data. */ - public function debug_print($input=NULL, $printItForMe=NULL, $removeHR=NULL) { + public function debug_print($input=NULL, $printItForMe=NULL, $removeHR=NULL, $usePreTags=true) { if(!is_numeric($removeHR)) { $removeHR = $this->debugRemoveHr; } @@ -630,9 +630,11 @@ print_r($input); $output = ob_get_contents(); ob_end_clean(); - - $output = "<pre>$output</pre>"; + if($usePreTags === true) { + $output = "<pre>$output</pre>"; + } + if(!isset($_SERVER['SERVER_PROTOCOL']) || !$_SERVER['SERVER_PROTOCOL']) { $output = strip_tags($output); $hrString = "\n***************************************************************\n"; @@ -690,12 +692,18 @@ $b="{"; $e="}"; } - - foreach($repArr as $key=>$value) { - //run the replacements. - $key = "$b" . $key . "$e"; - $template = str_replace("$key", $value, $template); + + if(is_array($repArr)) { + foreach($repArr as $key=>$value) { + //run the replacements. + $key = "$b" . $key . "$e"; + $template = str_replace("$key", $value, $template); + } } + else { + cs_debug_backtrace(1); + throw new exception(__METHOD__ .": no replacement array passed, or array was empty"); + } return($template); }//end mini_parser() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |