[Cs-content-commits] SF.net SVN: cs-content:[371] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-04-22 20:43:44
|
Revision: 371 http://cs-content.svn.sourceforge.net/cs-content/?rev=371&view=rev Author: crazedsanity Date: 2009-04-22 20:43:39 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Fixes for PHP warnings, update for "htdocs" public folder, setting to stop printing from an include. contentSystem.class.php: * finish(): -- only print if templateObj->printOnFinish is true... helps for embedded XML interfaces. cs_genericPage.class.php: * MAIN::: -- new public var, $printOnFinish=true * initialize_locals(): -- also remove "htdocs" from siteRoot. * set_block_row(): -- minor change to fix PHP warnings about referencing non-existent array indexes. * print_page(): -- another minor change to fix PHP warnings on array indexes -- add quotes in reference to 'out' array index to avoid PHP warnings about constants. * rip_all_block_rows(): -- superficial change to avoid PHP warnings if no array was returned. Modified Paths: -------------- trunk/1.0/contentSystem.class.php trunk/1.0/cs_genericPage.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-03-27 14:56:04 UTC (rev 370) +++ trunk/1.0/contentSystem.class.php 2009-04-22 20:43:39 UTC (rev 371) @@ -793,7 +793,9 @@ } if($this->isValid === TRUE) { - $page->print_page(); + if($this->templateObj->printOnFinish === true) { + $page->print_page(); + } } else { $this->die_gracefully($this->reason); Modified: trunk/1.0/cs_genericPage.class.php =================================================================== --- trunk/1.0/cs_genericPage.class.php 2009-03-27 14:56:04 UTC (rev 370) +++ trunk/1.0/cs_genericPage.class.php 2009-04-22 20:43:39 UTC (rev 371) @@ -15,6 +15,7 @@ public $templateVars = array(); //our copy of the global templateVars public $mainTemplate; //the default layout of the site public $unhandledVars=array(); + public $printOnFinish=true; private $tmplDir; private $libDir; @@ -78,6 +79,7 @@ else { //NOTE: this **requires** that the global variable "SITE_ROOT" is already set. $this->siteRoot = preg_replace('/\/public_html/', '', $_SERVER['DOCUMENT_ROOT']); + $this->siteRoot = preg_replace('/\/htdocs/', '', $_SERVER['DOCUMENT_ROOT']); $this->tmplDir = $this->siteRoot .'/templates'; } $this->libDir = $this->siteRoot .'/lib'; @@ -218,7 +220,7 @@ $reg = "/<!-- BEGIN $handle -->(.+){0,}<!-- END $handle -->/sU"; preg_match_all($reg, $str, $m); - if(!is_string($m[0][0])) { + if(!is_array($m) || !isset($m[0][0]) || !is_string($m[0][0])) { #exit("set_block_row(): couldn't find '$handle' in var '$parent'"); $retval = FALSE; } else { @@ -287,9 +289,9 @@ foreach($tags as $key=>$str) { $str2 = str_replace("{", "", $str); $str2 = str_replace("}", "", $str2); - if(!$this->templateVars[$str2] && $stripUndefVars) { + if(!isset($this->templateVars[$str2]) && $stripUndefVars) { //TODO: set an internal pointer or something to use here, so they can see what was missed. - $this->templateObj->varvals[out] = str_replace($str, '', $this->templateObj->varvals[out]); + $this->templateObj->varvals['out'] = str_replace($str, '', $this->templateObj->varvals['out']); $this->unhandledVars[$str2]++; } } @@ -594,17 +596,20 @@ function rip_all_block_rows($templateVar="content", $exceptionArr=array()) { $rowDefs = $this->get_block_row_defs($templateVar); - $useTheseBlockRows = $rowDefs['ordered']; $retval = array(); - if(is_array($useTheseBlockRows)) { - foreach($useTheseBlockRows as $blockRowName) - { - if(!in_array($blockRowName, $exceptionArr)) + + if(is_array($rowDefs) && isset($rowDefs['ordered'])) { + $useTheseBlockRows = $rowDefs['ordered']; + if(is_array($useTheseBlockRows)) { + foreach($useTheseBlockRows as $blockRowName) { - //remove the block row. - $rowData = $this->set_block_row($templateVar, $blockRowName); - $retval[$blockRowName] = $rowData; + if(!in_array($blockRowName, $exceptionArr)) + { + //remove the block row. + $rowData = $this->set_block_row($templateVar, $blockRowName); + $retval[$blockRowName] = $rowData; + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |