import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Ini.php 16201 2009-06-21 18:51:15Z thomas $
|
||||
* @version $Id: Ini.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ class Zend_Config_Ini extends Zend_Config
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_skipExtends = false;
|
||||
|
||||
|
||||
/**
|
||||
* Loads the section $section from the config file $filename for
|
||||
* access facilitated by nested object properties.
|
||||
@ -153,7 +153,7 @@ class Zend_Config_Ini extends Zend_Config
|
||||
|
||||
}
|
||||
parent::__construct($dataArray, $allowModifications);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_loadedSection = $section;
|
||||
}
|
||||
@ -210,7 +210,7 @@ class Zend_Config_Ini extends Zend_Config
|
||||
|
||||
return $iniArray;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process each element in the section and handle the ";extends" inheritance
|
||||
* key. Passes control to _processKey() to handle the nest separator
|
||||
@ -230,7 +230,7 @@ class Zend_Config_Ini extends Zend_Config
|
||||
if (strtolower($key) == ';extends') {
|
||||
if (isset($iniArray[$value])) {
|
||||
$this->_assertValidExtend($section, $value);
|
||||
|
||||
|
||||
if (!$this->_skipExtends) {
|
||||
$config = $this->_processSection($iniArray, $value, $config);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Writer.php 16201 2009-06-21 18:51:15Z thomas $
|
||||
* @version $Id: Writer.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -29,13 +29,13 @@ abstract class Zend_Config_Writer
|
||||
{
|
||||
/**
|
||||
* Option keys to skip when calling setOptions()
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_skipOptions = array(
|
||||
'options'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Config object to write
|
||||
*
|
||||
@ -45,8 +45,8 @@ abstract class Zend_Config_Writer
|
||||
|
||||
/**
|
||||
* Create a new adapter
|
||||
*
|
||||
* $options can only be passed as array or be omitted
|
||||
*
|
||||
* $options can only be passed as array or be omitted
|
||||
*
|
||||
* @param null|array $options
|
||||
*/
|
||||
@ -56,7 +56,7 @@ abstract class Zend_Config_Writer
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set options via a Zend_Config instance
|
||||
*
|
||||
@ -66,10 +66,10 @@ abstract class Zend_Config_Writer
|
||||
public function setConfig(Zend_Config $config)
|
||||
{
|
||||
$this->_config = $config;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set options via an array
|
||||
*
|
||||
@ -88,10 +88,10 @@ abstract class Zend_Config_Writer
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a Zend_Config object to it's target
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Array.php 16201 2009-06-21 18:51:15Z thomas $
|
||||
* @version $Id: Array.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -38,14 +38,14 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
|
||||
* @var string
|
||||
*/
|
||||
protected $_filename = null;
|
||||
|
||||
|
||||
/**
|
||||
* Wether to exclusively lock the file or not
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_exclusiveLock = false;
|
||||
|
||||
|
||||
/**
|
||||
* Set the target filename
|
||||
*
|
||||
@ -55,10 +55,10 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
|
||||
public function setFilename($filename)
|
||||
{
|
||||
$this->_filename = $filename;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set wether to exclusively lock the file or not
|
||||
*
|
||||
@ -68,10 +68,10 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
|
||||
public function setExclusiveLock($exclusiveLock)
|
||||
{
|
||||
$this->_exclusiveLock = $exclusiveLock;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defined by Zend_Config_Writer
|
||||
*
|
||||
@ -87,43 +87,43 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
|
||||
if ($filename !== null) {
|
||||
$this->setFilename($filename);
|
||||
}
|
||||
|
||||
|
||||
if ($config !== null) {
|
||||
$this->setConfig($config);
|
||||
}
|
||||
|
||||
|
||||
if ($exclusiveLock !== null) {
|
||||
$this->setExclusiveLock($exclusiveLock);
|
||||
}
|
||||
|
||||
|
||||
if ($this->_filename === null) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No filename was set');
|
||||
}
|
||||
|
||||
|
||||
if ($this->_config === null) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No config was set');
|
||||
}
|
||||
|
||||
|
||||
$data = $this->_config->toArray();
|
||||
$sectionName = $this->_config->getSectionName();
|
||||
|
||||
|
||||
if (is_string($sectionName)) {
|
||||
$data = array($sectionName => $data);
|
||||
}
|
||||
|
||||
|
||||
$arrayString = "<?php\n"
|
||||
. "return " . var_export($data, true) . ";\n";
|
||||
|
||||
|
||||
$flags = 0;
|
||||
|
||||
|
||||
if ($this->_exclusiveLock) {
|
||||
$flags |= LOCK_EX;
|
||||
}
|
||||
|
||||
|
||||
$result = @file_put_contents($this->_filename, $arrayString, $flags);
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Ini.php 16201 2009-06-21 18:51:15Z thomas $
|
||||
* @version $Id: Ini.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -38,21 +38,21 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
* @var string
|
||||
*/
|
||||
protected $_filename = null;
|
||||
|
||||
|
||||
/**
|
||||
* Wether to exclusively lock the file or not
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_exclusiveLock = false;
|
||||
|
||||
|
||||
/**
|
||||
* String that separates nesting levels of configuration data identifiers
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_nestSeparator = '.';
|
||||
|
||||
|
||||
/**
|
||||
* Set the target filename
|
||||
*
|
||||
@ -62,10 +62,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
public function setFilename($filename)
|
||||
{
|
||||
$this->_filename = $filename;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set wether to exclusively lock the file or not
|
||||
*
|
||||
@ -75,10 +75,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
public function setExclusiveLock($exclusiveLock)
|
||||
{
|
||||
$this->_exclusiveLock = $exclusiveLock;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the nest separator
|
||||
*
|
||||
@ -88,10 +88,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
public function setNestSeparator($separator)
|
||||
{
|
||||
$this->_nestSeparator = $separator;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defined by Zend_Config_Writer
|
||||
*
|
||||
@ -107,29 +107,29 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
if ($filename !== null) {
|
||||
$this->setFilename($filename);
|
||||
}
|
||||
|
||||
|
||||
if ($config !== null) {
|
||||
$this->setConfig($config);
|
||||
}
|
||||
|
||||
|
||||
if ($exclusiveLock !== null) {
|
||||
$this->setExclusiveLock($exclusiveLock);
|
||||
}
|
||||
|
||||
|
||||
if ($this->_filename === null) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No filename was set');
|
||||
}
|
||||
|
||||
|
||||
if ($this->_config === null) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No config was set');
|
||||
}
|
||||
|
||||
|
||||
$iniString = '';
|
||||
$extends = $this->_config->getExtends();
|
||||
$sectionName = $this->_config->getSectionName();
|
||||
|
||||
|
||||
if (is_string($sectionName)) {
|
||||
$iniString .= '[' . $sectionName . ']' . "\n"
|
||||
. $this->_addBranch($this->_config)
|
||||
@ -145,20 +145,20 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
if (isset($extends[$sectionName])) {
|
||||
$sectionName .= ' : ' . $extends[$sectionName];
|
||||
}
|
||||
|
||||
|
||||
$iniString .= '[' . $sectionName . ']' . "\n"
|
||||
. $this->_addBranch($data)
|
||||
. "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$flags = 0;
|
||||
|
||||
|
||||
if ($this->_exclusiveLock) {
|
||||
$flags |= LOCK_EX;
|
||||
}
|
||||
|
||||
|
||||
$result = @file_put_contents($this->_filename, $iniString, $flags);
|
||||
|
||||
if ($result === false) {
|
||||
@ -166,7 +166,7 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a branch to an INI string recursively
|
||||
*
|
||||
@ -179,7 +179,7 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
$group = array_merge($parents, array($key));
|
||||
|
||||
|
||||
if ($value instanceof Zend_Config) {
|
||||
$iniString .= $this->_addBranch($value, $group);
|
||||
} else {
|
||||
@ -189,10 +189,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
|
||||
. "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $iniString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare a value for INI
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Xml.php 16924 2009-07-21 16:34:04Z dasprid $
|
||||
* @version $Id: Xml.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -43,14 +43,14 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
|
||||
* @var string
|
||||
*/
|
||||
protected $_filename = null;
|
||||
|
||||
|
||||
/**
|
||||
* Wether to exclusively lock the file or not
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_exclusiveLock = false;
|
||||
|
||||
|
||||
/**
|
||||
* Set the target filename
|
||||
*
|
||||
@ -60,10 +60,10 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
|
||||
public function setFilename($filename)
|
||||
{
|
||||
$this->_filename = $filename;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set wether to exclusively lock the file or not
|
||||
*
|
||||
@ -73,10 +73,10 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
|
||||
public function setExclusiveLock($exclusiveLock)
|
||||
{
|
||||
$this->_exclusiveLock = $exclusiveLock;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defined by Zend_Config_Writer
|
||||
*
|
||||
@ -92,29 +92,29 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
|
||||
if ($filename !== null) {
|
||||
$this->setFilename($filename);
|
||||
}
|
||||
|
||||
|
||||
if ($config !== null) {
|
||||
$this->setConfig($config);
|
||||
}
|
||||
|
||||
|
||||
if ($exclusiveLock !== null) {
|
||||
$this->setExclusiveLock($exclusiveLock);
|
||||
}
|
||||
|
||||
|
||||
if ($this->_filename === null) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No filename was set');
|
||||
}
|
||||
|
||||
|
||||
if ($this->_config === null) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No config was set');
|
||||
}
|
||||
|
||||
|
||||
$xml = new SimpleXMLElement('<zend-config xmlns:zf="' . Zend_Config_Xml::XML_NAMESPACE . '"/>');
|
||||
$extends = $this->_config->getExtends();
|
||||
$sectionName = $this->_config->getSectionName();
|
||||
|
||||
|
||||
if (is_string($sectionName)) {
|
||||
$child = $xml->addChild($sectionName);
|
||||
|
||||
@ -125,35 +125,35 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
|
||||
$xml->addChild($sectionName, (string) $data);
|
||||
} else {
|
||||
$child = $xml->addChild($sectionName);
|
||||
|
||||
|
||||
if (isset($extends[$sectionName])) {
|
||||
$child->addAttribute('zf:extends', $extends[$sectionName], Zend_Config_Xml::XML_NAMESPACE);
|
||||
}
|
||||
|
||||
|
||||
$this->_addBranch($data, $child, $xml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dom = dom_import_simplexml($xml)->ownerDocument;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
|
||||
$xmlString = $dom->saveXML();
|
||||
|
||||
|
||||
$flags = 0;
|
||||
|
||||
|
||||
if ($this->_exclusiveLock) {
|
||||
$flags |= LOCK_EX;
|
||||
}
|
||||
|
||||
|
||||
$result = @file_put_contents($this->_filename, $xmlString, $flags);
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a branch to an XML object recursively
|
||||
*
|
||||
@ -165,35 +165,35 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
|
||||
protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
|
||||
{
|
||||
$branchType = null;
|
||||
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
if ($branchType === null) {
|
||||
if (is_numeric($key)) {
|
||||
$branchType = 'numeric';
|
||||
$branchName = $xml->getName();
|
||||
$xml = $parent;
|
||||
|
||||
|
||||
unset($parent->{$branchName});
|
||||
} else {
|
||||
$branchType = 'string';
|
||||
}
|
||||
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
|
||||
require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
|
||||
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
|
||||
}
|
||||
|
||||
|
||||
if ($branchType === 'numeric') {
|
||||
if ($value instanceof Zend_Config) {
|
||||
$child = $parent->addChild($branchName, (string) $value);
|
||||
|
||||
|
||||
$this->_addBranch($value, $child, $parent);
|
||||
} else {
|
||||
$parent->addChild($branchName, (string) $value);
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
if ($value instanceof Zend_Config) {
|
||||
$child = $xml->addChild($key);
|
||||
|
||||
|
||||
$this->_addBranch($value, $child, $xml);
|
||||
} else {
|
||||
$xml->addChild($key, (string) $value);
|
||||
|
Reference in New Issue
Block a user