[Cs-content-commits] SF.net SVN: cs-content:[378] trunk/1.0/contentSystem.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
|
From: <cra...@us...> - 2009-05-22 16:29:20
|
Revision: 378
http://cs-content.svn.sourceforge.net/cs-content/?rev=378&view=rev
Author: crazedsanity
Date: 2009-05-22 16:29:11 +0000 (Fri, 22 May 2009)
Log Message:
-----------
Implement feature request #273 (post-include file support).
/contentSystem.class.php:
* MAIN:::
-- added new (protected) property, afterIncludesList=array()
* load_includes():
-- check for that final "shared.after.inc" file (load_dir_includes()
will not do this for the final section).
* load_dir_includes():
-- initialize blank array for holding list of "after" includes.
-- checks for shared.after.inc and {section}.after.inc
-- NOTE::: if ordering works properly from inside add_include(), then
the "after" includes should be done through add_include($file,true)
as well to avoid confusion.
* finish():
-- processes the "after" includes once the normal includes are done.
* add_include():
-- ARG CHANGE: NEW ARG: #2 ($addAfter=false)
-- support for adding includes to the "after" array (defaults to using
the normal array)--each item is put to the TOP of the list for proper
order of inclusion.
-- NOTE::: see note for load_dir_includes() about this...
Modified Paths:
--------------
trunk/1.0/contentSystem.class.php
Modified: trunk/1.0/contentSystem.class.php
===================================================================
--- trunk/1.0/contentSystem.class.php 2009-05-15 15:21:15 UTC (rev 377)
+++ trunk/1.0/contentSystem.class.php 2009-05-22 16:29:11 UTC (rev 378)
@@ -94,6 +94,7 @@
);
protected $templateList = array();
protected $includesList = array();
+ protected $afterIncludesList= array();
public $templateObj = NULL;
protected $gfObj = NULL;
protected $tabs = NULL;
@@ -659,6 +660,9 @@
if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) {
$this->add_include('shared.inc');
}
+ if(isset($lsData['shared.after.inc']) && is_array($lsData['shared.after.inc'])) {
+ $this->add_include('shared.after.inc',true);
+ }
if(isset($lsData['index.inc']) && is_array($lsData['index.inc'])) {
$this->add_include('index.inc');
}
@@ -676,22 +680,32 @@
private function load_dir_includes($section) {
$lsData = $this->incFs->ls();
+ $addThese = array();
+
//attempt to load the shared includes file.
if(isset($lsData['shared.inc']) && $lsData['shared.inc']['type'] == 'file') {
$this->add_include('shared.inc');
}
+ //add the shared "after" script.
+ if(isset($lsData['shared.after.inc'])) {
+ $addThese [] = 'shared.after.inc';
+ }
+
//attempt to load the section's includes file.
$myFile = $section .'.inc';
if(isset($lsData[$myFile]) && $lsData[$myFile]['type'] == 'file') {
$this->add_include($myFile);
}
- if(isset($lsData[$section]) && !count($this->sectionArr)) {
- $this->incFs->cd($section);
- $lsData = $this->incFs->ls();
- if(isset($lsData['index.inc'])) {
- $this->includesList[] = $this->incFs->realcwd .'/index.inc';
+ //add the section "after" script.
+ if(isset($lsData[$section .'.after.inc'])) {
+ $addThese [] = $section .'.after.inc';
+ }
+
+ if(is_array($addThese) && count($addThese)) {
+ foreach($addThese as $f) {
+ $this->add_include($f,true);
}
}
}//end load_dir_includes()
@@ -783,6 +797,14 @@
$this->myLastInclude = $myInternalScriptName;
include_once($this->myLastInclude);
}
+
+ //now load the "after" includes.
+ if(is_array($this->afterIncludesList)) {
+ foreach($this->afterIncludesList as $myInternalIndex=>$myInternalScriptName) {
+ $this->myLastInclude = $myInternalScriptName;
+ include_once($this->myLastInclude);
+ }
+ }
}
catch(exception $e) {
$myRoot = preg_replace('/\//', '\\\/', $this->incFs->root);
@@ -869,10 +891,15 @@
/**
* Method that appends filenames to the list of include scripts.
*/
- private final function add_include($file) {
+ private final function add_include($file, $addAfter=false) {
$myFile = preg_replace('/\/{2,}/', '/', $this->incFs->realcwd .'/'. $file);
if(!is_numeric(array_search($myFile, $this->includesList))) {
- $this->includesList[] = $myFile;
+ if($addAfter === true) {
+ array_unshift($this->afterIncludesList, $myFile);
+ }
+ else {
+ $this->includesList[] = $myFile;
+ }
}
}//end add_include()
//------------------------------------------------------------------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|