[Cs-content-commits] SF.net SVN: cs-content:[383] trunk/1.0/contentSystem.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
|
From: <cra...@us...> - 2009-05-28 04:19:31
|
Revision: 383
http://cs-content.svn.sourceforge.net/cs-content/?rev=383&view=rev
Author: crazedsanity
Date: 2009-05-28 04:19:30 +0000 (Thu, 28 May 2009)
Log Message:
-----------
Implemented changes that had been incorrectly commited to releases/1.0 @r380:
*** ORIGINAL COMMIT LOG (releases/1.0@380) ***
Fix problem where includes/content/index.inc wasn't loaded for the "/" URL.
/contentSystem.class.php:
* prepare():
-- sets the internal "finalSection" variable as the last element in
the internal sectionArr (previously, it would be set as the last
accessible directory in the includes directory).
-- NOTE: finalSection was moved here because otherwise it was created
too late for use in load_includes().
-- NOTE2: if the internal sectionArr is empty, it will now throw an
exception...
* validate_page():
-- no longer sets the internal finalSection value.
* load_includes():
-- when considering inclusion of index.inc, has extra checks to allow
it if finalSection is "index".
Modified Paths:
--------------
trunk/1.0/contentSystem.class.php
Modified: trunk/1.0/contentSystem.class.php
===================================================================
--- trunk/1.0/contentSystem.class.php 2009-05-28 03:54:58 UTC (rev 382)
+++ trunk/1.0/contentSystem.class.php 2009-05-28 04:19:30 UTC (rev 383)
@@ -378,6 +378,17 @@
* Retrieves the list of templates & includes in preparation for later work.
*/
private function prepare() {
+
+ //Set the final section...
+ if(count($this->sectionArr)) {
+ $mySectionArr = $this->sectionArr;
+ $this->finalSection = array_pop($mySectionArr);
+ }
+ else {
+ throw new exception(__METHOD__ .": FATAL - section array is empty");
+ }
+
+
//attempt to load any includes...
$this->load_includes();
$foundIncludes = count($this->includesList);
@@ -432,8 +443,24 @@
$reasonText = "page template";
}
else {
- $this->finalSection = $this->baseDir;
- $reasonText = "base template";
+ //if the baseDir is "help", this would try to use "/help/index.content.tmpl"
+ $myFile = $this->baseDir .'/index.content.tmpl';
+ $sectionLsData = $this->fileSystemObj->ls($myFile);
+
+ //if the baseDir is "help", this would try to use "/help.content.tmpl"
+ $sectionFile = $this->baseDir .'.content.tmpl';
+ $lsData = $this->fileSystemObj->ls();
+
+ if(isset($lsData[$sectionFile]) && is_array($lsData[$sectionFile])) {
+ $valid = TRUE;
+ }
+ elseif(isset($sectionLsData[$myFile]) && $sectionLsData[$myFile]['type'] == 'file') {
+ //we're good.
+ $valid = TRUE;
+ }
+ else {
+ $this->reason = __METHOD__ .": couldn't find base template.";
+ }
}
$tmplFile1 = $this->section .".content.tmpl";
@@ -640,6 +667,10 @@
$this->load_dir_includes($this->baseDir);
//okay, now loop through $this->sectionArr & see if we can include anything else.
+ $addIndex=false;
+ if($this->finalSection == 'index') {
+ $addIndex = true;
+ }
if(($this->incFs->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) {
@@ -658,6 +689,9 @@
//attempt to cd() into the next directory, or die if we can't.
if(!$this->incFs->cd($mySection)) {
//no dice. Break the loop.
+ if($this->finalSection == 'index') {
+ $addIndex = true;
+ }
break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|