[Cs-content-commits] SF.net SVN: cs-content:[373] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-05-01 19:24:50
|
Revision: 373 http://cs-content.svn.sourceforge.net/cs-content/?rev=373&view=rev Author: crazedsanity Date: 2009-05-01 19:24:49 +0000 (Fri, 01 May 2009) Log Message: ----------- Ability to inject vars into pages, make section retrieval case insensitive. /contentSystem.class.php: * MAIN::: -- new (private) var, $injectVars=array() * finish(): -- checks if the internal injectVars array has things in it, and will then inject variables with the given names into the local scope. * inject_var() [NEW]: -- inject a variable into the local scope. /cs_siteConfig.class.php: * get_section(): -- upper-case the given section so no errors are thrown when they ask for a lowercase section. Modified Paths: -------------- trunk/1.0/contentSystem.class.php trunk/1.0/cs_siteConfig.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-01 13:42:14 UTC (rev 372) +++ trunk/1.0/contentSystem.class.php 2009-05-01 19:24:49 UTC (rev 373) @@ -103,6 +103,8 @@ private $isValid=FALSE; private $reason=NULL; + private $injectVars=array(); + //------------------------------------------------------------------------ /** * The CONSTRUCTOR. Duh. @@ -737,6 +739,19 @@ } $page =& $this->templateObj; + + if(is_array($this->injectVars) && count($this->injectVars)) { + $definedVars = get_defined_vars(); + foreach($this->injectVars as $myVarName=>$myVarVal) { + if(!isset($definedVars[$myVarName])) { + $$myVarName = $myVarVal; + } + else { + throw new exception(__METHOD__ .": attempt to inject already defined var '". $myVarName ."'"); + } + } + } + if(is_object($this->session)) { $page->session =& $this->session; } @@ -863,5 +878,13 @@ //------------------------------------------------------------------------ + + //------------------------------------------------------------------------ + public function inject_var($varName, $value) { + $this->injectVars[$varName] = $value; + }//end inject_var() + //------------------------------------------------------------------------ + + }//end contentSystem{} ?> Modified: trunk/1.0/cs_siteConfig.class.php =================================================================== --- trunk/1.0/cs_siteConfig.class.php 2009-05-01 13:42:14 UTC (rev 372) +++ trunk/1.0/cs_siteConfig.class.php 2009-05-01 19:24:49 UTC (rev 373) @@ -234,6 +234,7 @@ */ public function get_section($section) { if($this->isInitialized === true) { + $section = strtoupper($section); $data = $this->a2p->get_data($section); if(is_array($data) && count($data) && $data['type'] == 'open') { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |