[Cs-content-commits] SF.net SVN: cs-content:[385] trunk/1.0/contentSystem.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-05-31 21:22:11
|
Revision: 385 http://cs-content.svn.sourceforge.net/cs-content/?rev=385&view=rev Author: crazedsanity Date: 2009-05-31 21:22:05 +0000 (Sun, 31 May 2009) Log Message: ----------- All setting of template vars in contentSystem occurs within one method. /contentSystem.class.php: * load_page_templates(); -- converted to using add_template(). * load_shared_templates(): -- use add_template(). * finish(): -- when swapping index into the "content" var, call add_template_var() * add_template_var() [NEW]: -- method for assigning template vars to files internally. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-28 13:56:42 UTC (rev 384) +++ trunk/1.0/contentSystem.class.php 2009-05-31 21:22:05 UTC (rev 385) @@ -469,8 +469,7 @@ $tmplList = $this->arrange_directory_contents('name', 'section'); if(isset($tmplList[$value])) { foreach($tmplList[$value] as $mySection=>$myTmpl) { - // - $this->templateList[$mySection] = $myTmpl; + $this->add_template($mySection, $myTmpl); } } if(!$this->tmplFs->cd($value)) { @@ -481,14 +480,14 @@ $finalTmplList = $this->arrange_directory_contents('name', 'section'); foreach($finalTmplList as $mySection => $subArr) { foreach($subArr as $internalSection => $myTmpl) { - $this->templateList[$mySection] = $myTmpl; + $this->add_template($mySection, $myTmpl); } } //go through the final section, if set, so the templates defined there are used. if(isset($finalTmplList[$finalSection])) { foreach($finalTmplList[$finalSection] as $mySection => $myTmpl) { - $this->templateList[$mySection] = $myTmpl; + $this->add_template($mySection, $myTmpl); } } @@ -497,12 +496,12 @@ $tmplList = $this->arrange_directory_contents('name', 'section'); if(isset($tmplList['index'])) { foreach($tmplList['index'] as $mySection => $myTmpl) { - $this->templateList[$mySection] = $myTmpl; + $this->add_template($mySection, $myTmpl); } } if(isset($tmplList[$this->baseDir]['content'])) { //load template for the main page (if $this->baseDir == "help", this would load "/help.content.tmpl" as content) - $this->templateList['content'] = $tmplList[$this->baseDir]['content']; + $this->add_template('content', $tmplList[$this->baseDir]['content']); } } }//end load_page_templates() @@ -522,7 +521,7 @@ if(is_array($dirContents)) { foreach($dirContents as $mySection => $subArr) { foreach($subArr as $subIndex=>$templateFilename) { - $this->templateList[$mySection] = $templateFilename; + $this->add_template($mySection, $templateFilename); } } } @@ -549,7 +548,7 @@ if(count($dirContents['shared'])) { foreach($dirContents['shared'] as $section => $template) { - $this->templateList[$section] = $template; + $this->add_template($section, $template); } } }//end load_shared_templates() @@ -782,7 +781,7 @@ //if we loaded an index, but there is no "content", then move 'em around so we have content. if(isset($this->templateList['index']) && !isset($this->templateList['content'])) { - $this->templateList['content'] = $this->templateList['index']; + $this->add_template('content', $this->templateList['index']); unset($this->templateList['index']); } @@ -916,6 +915,22 @@ //------------------------------------------------------------------------ + private final function add_template($var, $file, $allowIndex=false) { + if($var == 'index' && $allowIndex !== true) { + $this->gfObj->debug_print(__METHOD__ .": set index invalidly (". $file ."), IGNORED"); + } + else { + if(isset($this->templateList[$var])) { + $this->gfObj->debug_print(__METHOD__ .": REPLACING [". $var ."], was (". $this->templateList[$var] .") with (". $file .")"); + } + $this->templateList[$var] = $file; + } + }//end add_template() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ public function inject_var($varName, $value) { $this->injectVars[$varName] = $value; }//end inject_var() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |