[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[188] trunk/0.4
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2010-10-07 19:08:16
|
Revision: 188 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=188&view=rev Author: crazedsanity Date: 2010-10-07 19:08:10 +0000 (Thu, 07 Oct 2010) Log Message: ----------- Changes to work with cs-phpxml v1.1 (trunk) /cs_siteConfig.class.php: * __construct(): -- use cs_phpxmlCreator::attributeIndex to remove any root attributes. * parse_config(): -- use cs_phpxmlCreator::attributeIndex to remove any root attributes. -- TODO about taking out the UPPERCASE requirement... -- modifications to handle cs-phpxml v1.1 (trunk) * get_section(): -- minor changes to retrieve data based on cs-phpxml v1.1 (trunk) * get_value(): -- use dataIndex constant from cs_phpxmlCreator to get value. /cs_webdbupgrade.class.php: * read_upgrade_config_file(): -- build the "matching" array here. -- pull the "INITIALVERSION" value here, if it exists. * do_single_upgrade(): -- updated paths to configuration data. * get_upgrade_list(): -- updated path to config data * load_initial_version(): -- use new location of INITIALVERSION in config. Modified Paths: -------------- trunk/0.4/cs_siteConfig.class.php trunk/0.4/cs_webdbupgrade.class.php Modified: trunk/0.4/cs_siteConfig.class.php =================================================================== --- trunk/0.4/cs_siteConfig.class.php 2010-10-01 19:24:30 UTC (rev 187) +++ trunk/0.4/cs_siteConfig.class.php 2010-10-07 19:08:10 UTC (rev 188) @@ -103,7 +103,7 @@ if(is_null($section) || !strlen($section)) { $myData = $this->xmlReader->get_path($this->xmlReader->get_root_element()); - unset($myData['type'], $myData['attributes']); + unset($myData['type'], $myData[cs_phpxmlCreator::attributeIndex]); $myData = array_keys($myData); $section = $myData[0]; } @@ -168,22 +168,23 @@ private function parse_config() { if(is_object($this->xmlReader)) { $data = $this->xmlReader->get_path($this->xmlReader->get_root_element()); + unset($data[cs_phpxmlCreator::attributeIndex]); $specialVars = $this->build_special_vars(); $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" + //only handle UPPERCASE index names.... + //TODO: take this (above) requirement out, as cs-phpxml doesn't require everything to be upper-case. if($section == strtoupper($section)) { $this->configSections[] = $section; - unset($secData['type']); - - if(isset($secData['attributes']) && is_array($secData['attributes'])) { - $sectionAttribs = $secData['attributes']; - unset($secData['attributes']); + //TODO: use method (i.e. $this->xmlReader->get_attribute($path)) to retrieve attributes. + if(isset($secData[cs_phpxmlCreator::attributeIndex]) && is_array($secData[cs_phpxmlCreator::attributeIndex])) { + //TODO: use method (i.e. $this->xmlReader->get_attribute($path)) to retrieve attributes. + $sectionAttribs = $secData[cs_phpxmlCreator::attributeIndex]; + unset($secData[cs_phpxmlCreator::attributeIndex]); //put stuff into the globals scope... if(isset($sectionAttribs['SETGLOBAL'])) { @@ -197,13 +198,23 @@ } } + $secData = $secData[0]; + $tSectionAttribs = null; + if(isset($secData[cs_phpxmlCreator::attributeIndex])) { + $tSectionAttribs = $secData[cs_phpxmlCreator::attributeIndex]; + unset($secData[cs_phpxmlCreator::attributeIndex]); + } foreach($secData as $itemName=>$itemValue) { $attribs = array(); - if(isset($itemValue['attributes']) && is_array($itemValue['attributes'])) { - $attribs = $itemValue['attributes']; + //TODO: use method (i.e. $this->xmlReader->get_attribute($path)) to retrieve attributes. + if(isset($itemValue[0][cs_phpxmlCreator::attributeIndex]) && is_array($itemValue[0][cs_phpxmlCreator::attributeIndex])) { + //TODO: use method (i.e. $this->xmlReader->get_attribute($path)) to retrieve attributes. + $attribs = $itemValue[0][cs_phpxmlCreator::attributeIndex]; } - if(isset($itemValue['value'])) { - $itemValue = $itemValue['value']; + //TODO: use method (i.e. $this->xmlReader->get_value($path)) to retrieve tag value. + if(isset($itemValue[0][cs_phpxmlCreator::dataIndex])) { + //TODO: use method (i.e. $this->xmlReader->get_value($path)) to retrieve tag value. + $itemValue = $itemValue[0][cs_phpxmlCreator::dataIndex]; } else { $itemValue = null; @@ -230,7 +241,7 @@ $parseThis[$itemName] = $itemValue; $parseThis[$section ."/". $itemName] = $itemValue; - $data[$section][$itemName]['value'] = $itemValue; + $data[$section][$itemName][cs_phpxmlCreator::dataIndex] = $itemValue; $setVarIndex = $this->setVarPrefix . $itemName; if(isset($attribs['SETGLOBAL'])) { @@ -264,7 +275,7 @@ if($this->a2p->get_data($configPath)) { $setMe = array(); foreach($this->a2p->get_data($configPath) as $i=>$v) { - $setMe[$i] = $v['value']; + $setMe[$i] = $v[cs_phpxmlCreator::dataIndex]; } $globA2p->set_data($globalsPath, $setMe); } @@ -294,14 +305,13 @@ public function get_section($section) { if($this->isInitialized === true) { $section = strtoupper($section); - $data = $this->a2p->get_data($section); + $data = $this->a2p->get_data($section .'/0'); - if(is_array($data) && count($data) && $data['type'] == 'open') { - unset($data['type']); + if(is_array($data) && count($data)) { $retval = $data; } else { - throw new exception(__METHOD__ .": invalid section (". $section .") or no data (". $data['type'] .")"); + throw new exception(__METHOD__ .": invalid section (". $section .") or no data::: ". $this->gfObj->debug_print($data,0)); } } else { @@ -332,7 +342,7 @@ //section NOT given, assume they're looking for something in the active section. $index = $this->activeSection ."/". $index; } - $retval = $this->a2p->get_data($index .'/value'); + $retval = $this->a2p->get_data($index .'/'. cs_phpxmlCreator::dataIndex); } else { throw new exception(__METHOD__ .": not initialized"); Modified: trunk/0.4/cs_webdbupgrade.class.php =================================================================== --- trunk/0.4/cs_webdbupgrade.class.php 2010-10-01 19:24:30 UTC (rev 187) +++ trunk/0.4/cs_webdbupgrade.class.php 2010-10-07 19:08:10 UTC (rev 188) @@ -304,10 +304,32 @@ //parse the file. $xmlParser = new cs_phpxmlParser($xmlString); - $config = $xmlParser->get_tree(TRUE); - - if(is_array($config['UPGRADE']) && count($config['UPGRADE'])) { - $this->config['UPGRADELIST'] = $config['UPGRADE']; + if($xmlParser->get_root_element() == 'UPGRADE') { + + //see if there's an "initial version" setting. + try { + $this->config['INITIALVERSION'] = $xmlParser->get_tag_value('/UPGRADE/INITIALVERSION'); + } + catch(Exception $e) { + //no worries, this only happens when the tag doesn't exist or it doesn't have data (that is okay). + } + + $tConfig = array(); + if(is_array($xmlParser->get_data('/UPGRADE/MATCHING'))) { + $matchingData = $xmlParser->get_data('/UPGRADE/MATCHING'); + foreach($matchingData as $index=>$array) { + $array = $array[0]; + foreach($array as $matchingName=>$subInfo) { + if(isset($subInfo[0][cs_phpxmlCreator::dataIndex])) { + $tConfig[$index][$matchingName] = $subInfo[0][cs_phpxmlCreator::dataIndex]; + } + else { + throw new exception(__METHOD__ .": invalid data beneath matching (". $index .")::: ". $this->gfObj->debug_print($subInfo,0)); + } + } + } + } + $this->config['matchingData'] = $tConfig; } else { $this->error_handler(__METHOD__ .": failed to retrieve 'UPGRADE' section; " . @@ -581,7 +603,7 @@ private function do_single_upgrade($fromVersion, $toVersion=null) { //Use the "matching_syntax" data in the upgrade.xml file to determine the filename. $versionIndex = "V". $this->get_full_version_string($fromVersion); - if(!isset($this->config['UPGRADELIST']['MATCHING'][$versionIndex])) { + if(!isset($this->config['matchingData'][$versionIndex])) { //version-only upgrade. $this->newVersion = $toVersion; $this->update_database_version($toVersion); @@ -590,7 +612,7 @@ //scripted upgrade... $scriptIndex = $versionIndex; - $upgradeData = $this->config['UPGRADELIST']['MATCHING'][$versionIndex]; + $upgradeData = $this->config['matchingData'][$versionIndex]; if(isset($upgradeData['TARGET_VERSION']) && count($upgradeData) > 1) { $this->newVersion = $upgradeData['TARGET_VERSION']; @@ -764,9 +786,9 @@ if(!$this->is_higher_version($dbVersion, $newVersion)) { $this->error_handler(__METHOD__ .": version (". $newVersion .") isn't higher than (". $dbVersion .")... something is broken"); } - elseif(is_array($this->config['UPGRADELIST']['MATCHING'])) { + elseif(is_array($this->config['matchingData'])) { $lastVersion = $dbVersion; - foreach($this->config['UPGRADELIST']['MATCHING'] as $matchVersion=>$data) { + foreach($this->config['matchingData'] as $matchVersion=>$data) { $matchVersion = preg_replace('/^V/', '', $matchVersion); if($matchVersion == $data['TARGET_VERSION']) { @@ -1044,8 +1066,8 @@ //if there's an INITIAL_VERSION in the upgrade config file, use that. $this->read_upgrade_config_file(); $insertData = array(); - if(isset($this->config['UPGRADELIST']['INITIALVERSION'])) { - $parseThis = $this->config['UPGRADELIST']['INITIALVERSION']; + if(isset($this->config['INITIALVERSION'])) { + $parseThis = $this->config['INITIALVERSION']; } else { $parseThis = $this->versionFileVersion; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |