PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,55 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Config
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Array.php 23775 2011-03-01 17:25:24Z ralph $
*/
/**
* @see Zend_Config_Writer
*/
// require_once 'Zend/Config/Writer/FileAbstract.php';
/**
* @category Zend
* @package Zend_Config
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Config_Writer_Array extends Zend_Config_Writer_FileAbstract
{
/**
* Render a Zend_Config into a PHP Array config string.
*
* @since 1.10
* @return string
*/
public function render()
{
$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";
return $arrayString;
}
}

View File

@ -0,0 +1,134 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Config
* @package Writer
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
// require_once "Zend/Config/Writer.php";
/**
* Abstract File Writer
*
* @category Zend
* @package Zend_package
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FileAbstract.php 23775 2011-03-01 17:25:24Z ralph $
*/
class Zend_Config_Writer_FileAbstract extends Zend_Config_Writer
{
/**
* Filename to write to
*
* @var string
*/
protected $_filename = null;
/**
* Wether to exclusively lock the file or not
*
* @var boolean
*/
protected $_exclusiveLock = false;
/**
* Set the target filename
*
* @param string $filename
* @return Zend_Config_Writer_Array
*/
public function setFilename($filename)
{
$this->_filename = $filename;
return $this;
}
/**
* Set wether to exclusively lock the file or not
*
* @param boolean $exclusiveLock
* @return Zend_Config_Writer_Array
*/
public function setExclusiveLock($exclusiveLock)
{
$this->_exclusiveLock = $exclusiveLock;
return $this;
}
/**
* Write configuration to file.
*
* @param string $filename
* @param Zend_Config $config
* @param bool $exclusiveLock
* @return void
*/
public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null)
{
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');
}
$configString = $this->render();
$flags = 0;
if ($this->_exclusiveLock) {
$flags |= LOCK_EX;
}
$result = @file_put_contents($this->_filename, $configString, $flags);
if ($result === false) {
// require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
}
}
/**
* Render a Zend_Config into a config file string.
*
* @since 1.10
* @todo For 2.0 this should be redone into an abstract method.
* @return string
*/
public function render()
{
return "";
}
}

View File

@ -0,0 +1,193 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Config
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ini.php 23775 2011-03-01 17:25:24Z ralph $
*/
/**
* @see Zend_Config_Writer
*/
// require_once 'Zend/Config/Writer/FileAbstract.php';
/**
* @category Zend
* @package Zend_Config
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract
{
/**
* String that separates nesting levels of configuration data identifiers
*
* @var string
*/
protected $_nestSeparator = '.';
/**
* If true the ini string is rendered in the global namespace without sections.
*
* @var bool
*/
protected $_renderWithoutSections = false;
/**
* Set the nest separator
*
* @param string $filename
* @return Zend_Config_Writer_Ini
*/
public function setNestSeparator($separator)
{
$this->_nestSeparator = $separator;
return $this;
}
/**
* Set if rendering should occour without sections or not.
*
* If set to true, the INI file is rendered without sections completely
* into the global namespace of the INI file.
*
* @param bool $withoutSections
* @return Zend_Config_Writer_Ini
*/
public function setRenderWithoutSections($withoutSections=true)
{
$this->_renderWithoutSections = (bool)$withoutSections;
return $this;
}
/**
* Render a Zend_Config into a INI config string.
*
* @since 1.10
* @return string
*/
public function render()
{
$iniString = '';
$extends = $this->_config->getExtends();
$sectionName = $this->_config->getSectionName();
if($this->_renderWithoutSections == true) {
$iniString .= $this->_addBranch($this->_config);
} else if (is_string($sectionName)) {
$iniString .= '[' . $sectionName . ']' . "\n"
. $this->_addBranch($this->_config)
. "\n";
} else {
$config = $this->_sortRootElements($this->_config);
foreach ($config as $sectionName => $data) {
if (!($data instanceof Zend_Config)) {
$iniString .= $sectionName
. ' = '
. $this->_prepareValue($data)
. "\n";
} else {
if (isset($extends[$sectionName])) {
$sectionName .= ' : ' . $extends[$sectionName];
}
$iniString .= '[' . $sectionName . ']' . "\n"
. $this->_addBranch($data)
. "\n";
}
}
}
return $iniString;
}
/**
* Add a branch to an INI string recursively
*
* @param Zend_Config $config
* @return void
*/
protected function _addBranch(Zend_Config $config, $parents = array())
{
$iniString = '';
foreach ($config as $key => $value) {
$group = array_merge($parents, array($key));
if ($value instanceof Zend_Config) {
$iniString .= $this->_addBranch($value, $group);
} else {
$iniString .= implode($this->_nestSeparator, $group)
. ' = '
. $this->_prepareValue($value)
. "\n";
}
}
return $iniString;
}
/**
* Prepare a value for INI
*
* @param mixed $value
* @return string
*/
protected function _prepareValue($value)
{
if (is_integer($value) || is_float($value)) {
return $value;
} elseif (is_bool($value)) {
return ($value ? 'true' : 'false');
} elseif (strpos($value, '"') === false) {
return '"' . $value . '"';
} else {
/** @see Zend_Config_Exception */
// require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Value can not contain double quotes "');
}
}
/**
* Root elements that are not assigned to any section needs to be
* on the top of config.
*
* @see http://framework.zend.com/issues/browse/ZF-6289
* @param Zend_Config
* @return Zend_Config
*/
protected function _sortRootElements(Zend_Config $config)
{
$configArray = $config->toArray();
$sections = array();
// remove sections from config array
foreach ($configArray as $key => $value) {
if (is_array($value)) {
$sections[$key] = $value;
unset($configArray[$key]);
}
}
// readd sections to the end
foreach ($sections as $key => $value) {
$configArray[$key] = $value;
}
return new Zend_Config($configArray);
}
}

View File

@ -0,0 +1,106 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @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: Json.php 23294 2010-11-05 00:27:34Z ramon $
*/
/**
* @see Zend_Config_Writer
*/
// require_once 'Zend/Config/Writer/FileAbstract.php';
/**
* @see Zend_Config_Json
*/
// require_once 'Zend/Config/Json.php';
/**
* @category Zend
* @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
*/
class Zend_Config_Writer_Json extends Zend_Config_Writer_FileAbstract
{
/**
* If we need to pretty-print JSON data
*
* @var boolean
*/
protected $_prettyPrint = false;
/**
* Get prettyPrint flag
*
* @return the prettyPrint flag
*/
public function prettyPrint()
{
return $this->_prettyPrint;
}
/**
* Set prettyPrint flag
*
* @param bool $prettyPrint PrettyPrint flag
* @return Zend_Config_Writer_Json
*/
public function setPrettyPrint($flag)
{
$this->_prettyPrint = (bool) $flag;
return $this;
}
/**
* Render a Zend_Config into a JSON config string.
*
* @since 1.10
* @return string
*/
public function render()
{
$data = $this->_config->toArray();
$sectionName = $this->_config->getSectionName();
$extends = $this->_config->getExtends();
if (is_string($sectionName)) {
$data = array($sectionName => $data);
}
foreach ($extends as $section => $parentSection) {
$data[$section][Zend_Config_Json::EXTENDS_NAME] = $parentSection;
}
// Ensure that each "extends" section actually exists
foreach ($data as $section => $sectionData) {
if (is_array($sectionData) && isset($sectionData[Zend_Config_Json::EXTENDS_NAME])) {
$sectionExtends = $sectionData[Zend_Config_Json::EXTENDS_NAME];
if (!isset($data[$sectionExtends])) {
// Remove "extends" declaration if section does not exist
unset($data[$section][Zend_Config_Json::EXTENDS_NAME]);
}
}
}
$out = Zend_Json::encode($data);
if ($this->prettyPrint()) {
$out = Zend_Json::prettyPrint($out);
}
return $out;
}
}

View File

@ -0,0 +1,127 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Config
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Xml.php 23775 2011-03-01 17:25:24Z ralph $
*/
/**
* @see Zend_Config_Writer
*/
// require_once 'Zend/Config/Writer/FileAbstract.php';
/**
* @see Zend_Config_Xml
*/
// require_once 'Zend/Config/Xml.php';
/**
* @category Zend
* @package Zend_Config
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Config_Writer_Xml extends Zend_Config_Writer_FileAbstract
{
/**
* Render a Zend_Config into a XML config string.
*
* @since 1.10
* @return string
*/
public function render()
{
$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);
$this->_addBranch($this->_config, $child, $xml);
} else {
foreach ($this->_config as $sectionName => $data) {
if (!($data instanceof Zend_Config)) {
$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();
return $xmlString;
}
/**
* Add a branch to an XML object recursively
*
* @param Zend_Config $config
* @param SimpleXMLElement $xml
* @param SimpleXMLElement $parent
* @return void
*/
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');
}
if ($branchType === 'numeric') {
if ($value instanceof Zend_Config) {
$child = $parent->addChild($branchName);
$this->_addBranch($value, $child, $parent);
} else {
$parent->addChild($branchName, (string) $value);
}
} else {
if ($value instanceof Zend_Config) {
$child = $xml->addChild($key);
$this->_addBranch($value, $child, $xml);
} else {
$xml->addChild($key, (string) $value);
}
}
}
}
}

View File

@ -0,0 +1,144 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @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: Yaml.php 23651 2011-01-21 21:51:00Z mikaelkael $
*/
/**
* @see Zend_Config_Writer
*/
// require_once 'Zend/Config/Writer/FileAbstract.php';
/**
* @see Zend_Config_Yaml
*/
// require_once 'Zend/Config/Yaml.php';
/**
* @category Zend
* @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
*/
class Zend_Config_Writer_Yaml extends Zend_Config_Writer_FileAbstract
{
/**
* What to call when we need to decode some YAML?
*
* @var callable
*/
protected $_yamlEncoder = array('Zend_Config_Writer_Yaml', 'encode');
/**
* Get callback for decoding YAML
*
* @return callable
*/
public function getYamlEncoder()
{
return $this->_yamlEncoder;
}
/**
* Set callback for decoding YAML
*
* @param callable $yamlEncoder the decoder to set
* @return Zend_Config_Yaml
*/
public function setYamlEncoder($yamlEncoder)
{
if (!is_callable($yamlEncoder)) {
// require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Invalid parameter to setYamlEncoder - must be callable');
}
$this->_yamlEncoder = $yamlEncoder;
return $this;
}
/**
* Render a Zend_Config into a YAML config string.
*
* @since 1.10
* @return string
*/
public function render()
{
$data = $this->_config->toArray();
$sectionName = $this->_config->getSectionName();
$extends = $this->_config->getExtends();
if (is_string($sectionName)) {
$data = array($sectionName => $data);
}
foreach ($extends as $section => $parentSection) {
$data[$section][Zend_Config_Yaml::EXTENDS_NAME] = $parentSection;
}
// Ensure that each "extends" section actually exists
foreach ($data as $section => $sectionData) {
if (is_array($sectionData) && isset($sectionData[Zend_Config_Yaml::EXTENDS_NAME])) {
$sectionExtends = $sectionData[Zend_Config_Yaml::EXTENDS_NAME];
if (!isset($data[$sectionExtends])) {
// Remove "extends" declaration if section does not exist
unset($data[$section][Zend_Config_Yaml::EXTENDS_NAME]);
}
}
}
return call_user_func($this->getYamlEncoder(), $data);
}
/**
* Very dumb YAML encoder
*
* Until we have Zend_Yaml...
*
* @param array $data YAML data
* @return string
*/
public static function encode($data)
{
return self::_encodeYaml(0, $data);
}
/**
* Service function for encoding YAML
*
* @param int $indent Current indent level
* @param array $data Data to encode
* @return string
*/
protected static function _encodeYaml($indent, $data)
{
reset($data);
$result = "";
$numeric = is_numeric(key($data));
foreach($data as $key => $value) {
if(is_array($value)) {
$encoded = "\n".self::_encodeYaml($indent+1, $value);
} else {
$encoded = (string)$value."\n";
}
$result .= str_repeat(" ", $indent).($numeric?"- ":"$key: ").$encoded;
}
return $result;
}
}