[Cs-content-commits] SF.net SVN: cs-content:[321] trunk/0.10
PHP Templating & Includes System
Brought to you by:
crazedsanity
|
From: <cra...@us...> - 2009-01-20 05:18:26
|
Revision: 321
http://cs-content.svn.sourceforge.net/cs-content/?rev=321&view=rev
Author: crazedsanity
Date: 2009-01-20 05:18:20 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
Minor requirement additions, better errors, and removed unneeded methods.
/cs_siteConfig.class.php:
* MAIN:::
-- require cs_globalFunctions and cs_fileSystemClass.
* parse_config():
-- throw an exception if xmlReader isn't an object; this is basically a
check to make debugging easier.
* create_site_config() [DELETED]:
-- it is easier for a person to copy the sample configuration file than
to attempt to create a generic one.
/tests/testOfCSContent.php:
* remove unneeded debug_print() statement.
Modified Paths:
--------------
trunk/0.10/cs_siteConfig.class.php
trunk/0.10/tests/testOfCSContent.php
Modified: trunk/0.10/cs_siteConfig.class.php
===================================================================
--- trunk/0.10/cs_siteConfig.class.php 2009-01-19 19:27:21 UTC (rev 320)
+++ trunk/0.10/cs_siteConfig.class.php 2009-01-20 05:18:20 UTC (rev 321)
@@ -15,6 +15,8 @@
*
*/
+require_once(dirname(__FILE__) .'/cs_globalFunctions.php');
+require_once(dirname(__FILE__) .'/cs_fileSystemClass.php');
require_once(dirname(__FILE__). '/../cs-phpxml/xmlParserClass.php');
require_once(dirname(__FILE__) .'/../cs-phpxml/xmlBuilderClass.php');
@@ -156,47 +158,58 @@
* @return exception (FAIL) exception indicates problem encountered.
*/
private function parse_config() {
- $data = $this->xmlReader->get_path($this->xmlReader->get_root_element());
-
- $specialVars = array(
- '_DIRNAMEOFFILE_' => $this->configDirname
- );
- $parseThis = array();
-
-
- $this->configSections = array();
-
- foreach($data as $section=>$secData) {
- //only handle UPPERCASE index names; lowercase indexes are special entries (i.e. "type" or "attributes"
- if($section == strtoupper($section)) {
- $this->configSections[] = $section;
- foreach($secData as $itemName=>$itemValue) {
- $attribs = array();
- if(is_array($itemValue['attributes'])) {
- $attribs = $itemValue['attributes'];
+ if(is_object($this->xmlReader)) {
+ $data = $this->xmlReader->get_path($this->xmlReader->get_root_element());
+
+ $specialVars = array(
+ '_DIRNAMEOFFILE_' => $this->configDirname
+ );
+ $parseThis = array();
+
+
+ $this->configSections = array();
+
+ foreach($data as $section=>$secData) {
+ //only handle UPPERCASE index names; lowercase indexes are special entries (i.e. "type" or "attributes"
+ if($section == strtoupper($section)) {
+ $this->configSections[] = $section;
+ foreach($secData as $itemName=>$itemValue) {
+ $attribs = array();
+ if(is_array($itemValue['attributes'])) {
+ $attribs = $itemValue['attributes'];
+ }
+ $itemValue = $itemValue['value'];
+ if(preg_match("/{/", $itemValue)) {
+ $origVal = $itemValue;
+ $itemValue = $this->gf->mini_parser($itemValue, $specialVars, '{', '}');
+ $itemValue = $this->gf->mini_parser($itemValue, $parseThis, '{', '}');
+ $itemValue = preg_replace("/[\/]{2,}/", "/", $itemValue);
+ }
+
+ if($attribs['CLEANPATH']) {
+ $itemValue = $this->fs->resolve_path_with_dots($itemValue);
+ }
+
+ $parseThis[$itemName] = $itemValue;
+ $parseThis[$section ."/". $itemName] = $itemValue;
+ $data[$section][$itemName]['value'] = $itemValue;
+
+ $setVarIndex = $this->setVarPrefix . $itemName;
+ if($attribs['SETGLOBAL']) {
+ $GLOBALS[$setVarIndex] = $itemValue;
+ }
+ if($attribs['SETCONSTANT']) {
+ define($setVarIndex, $itemValue);
+ }
}
- $itemValue = $itemValue['value'];
- if(preg_match("/{/", $itemValue)) {
- $origVal = $itemValue;
- $itemValue = $this->gf->mini_parser($itemValue, $specialVars, '{', '}');
- $itemValue = $this->gf->mini_parser($itemValue, $parseThis, '{', '}');
- $itemValue = preg_replace("/[\/]{2,}/", "/", $itemValue);
- }
- $parseThis[$itemName] = $itemValue;
- $parseThis[$section ."/". $itemName] = $itemValue;
- $data[$section][$itemName]['value'] = $itemValue;
-
- if($attribs['SETGLOBAL']) {
- $GLOBALS[$this->setVarPrefix . $itemName] = $itemValue;
- }
- if($attribs['SETCONSTANT']) {
- define($this->setVarPrefix . $itemName, $itemValue);
- }
}
}
+ $this->a2p = new arrayToPath($data);
+ $this->isInitialized=true;
}
- $this->a2p = new arrayToPath($data);
- $this->isInitialized=true;
+ else {
+ throw new exception(__METHOD__ .": xmlReader not created, object probably not initialized");
+ }
}//end parse_config()
//-------------------------------------------------------------------------
@@ -289,13 +302,6 @@
}//end get_valid_sections()
//-------------------------------------------------------------------------
-
-
- //-------------------------------------------------------------------------
- public function create_site_config() {
- }//end create_site_config()
- //-------------------------------------------------------------------------
-
}//end cs_siteConfig
?>
Modified: trunk/0.10/tests/testOfCSContent.php
===================================================================
--- trunk/0.10/tests/testOfCSContent.php 2009-01-19 19:27:21 UTC (rev 320)
+++ trunk/0.10/tests/testOfCSContent.php 2009-01-20 05:18:20 UTC (rev 321)
@@ -213,7 +213,6 @@
$setAsGlobals = array();
$setAsConstants = array();
foreach($sc->get_valid_sections() as $section) {
- $this->gf->debug_print(__METHOD__ .": evaluating section (". $section .")");
$sectionData = $sc->get_section($section);
foreach($sectionData as $name=>$value) {
if(is_array($value['attributes'])) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|