diff --git a/install.php b/install.php
index 0f65755806087..5fc031ba5895e 100644
--- a/install.php
+++ b/install.php
@@ -217,8 +217,6 @@
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
//the problem is that we need specific version of quickforms and hacked excel files :-(
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
-//point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
-ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
diff --git a/lib/setup.php b/lib/setup.php
index 4c5930bc03ff2..71b37ad69f74d 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -572,9 +572,6 @@
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
//the problem is that we need specific version of quickforms and hacked excel files :-(
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
-//point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
-//please note zend library is supposed to be used only from web service protocol classes, it may be removed in future
-ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
if (defined('COMPONENT_CLASSLOADER')) {
diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml
index fc8ffe02e1809..a522125a5de23 100644
--- a/lib/thirdpartylibs.xml
+++ b/lib/thirdpartylibs.xml
@@ -196,13 +196,6 @@
1.11.4
-
- zend
- Zend Framework
- BSD
- 1.12.16
-
-
html2text.php
HTML2Text
diff --git a/lib/upgrade.txt b/lib/upgrade.txt
index a88c602c4012c..5135ad3bfcf35 100644
--- a/lib/upgrade.txt
+++ b/lib/upgrade.txt
@@ -84,6 +84,7 @@ information provided here is intended especially for developers.
* \repository::antivir_scan_file() has been deprecated, \core\antivirus\manager::scan_file() that
applies antivirus plugins is replacing its functionality.
* Added core_text::str_max_bytes() which safely truncates multi-byte strings to a maximum number of bytes.
+* Zend Framework has been removed completely.
=== 3.0 ===
diff --git a/lib/zend/Zend/Acl.php b/lib/zend/Zend/Acl.php
deleted file mode 100644
index a5d169f56ac2d..0000000000000
--- a/lib/zend/Zend/Acl.php
+++ /dev/null
@@ -1,1242 +0,0 @@
- array(
- 'allRoles' => array(
- 'allPrivileges' => array(
- 'type' => self::TYPE_DENY,
- 'assert' => null
- ),
- 'byPrivilegeId' => array()
- ),
- 'byRoleId' => array()
- ),
- 'byResourceId' => array()
- );
-
- /**
- * Adds a Role having an identifier unique to the registry
- *
- * The $parents parameter may be a reference to, or the string identifier for,
- * a Role existing in the registry, or $parents may be passed as an array of
- * these - mixing string identifiers and objects is ok - to indicate the Roles
- * from which the newly added Role will directly inherit.
- *
- * In order to resolve potential ambiguities with conflicting rules inherited
- * from different parents, the most recently added parent takes precedence over
- * parents that were previously added. In other words, the first parent added
- * will have the least priority, and the last parent added will have the
- * highest priority.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @param Zend_Acl_Role_Interface|string|array $parents
- * @uses Zend_Acl_Role_Registry::add()
- * @return Zend_Acl Provides a fluent interface
- */
- public function addRole($role, $parents = null)
- {
- if (is_string($role)) {
- $role = new Zend_Acl_Role($role);
- }
-
- if (!$role instanceof Zend_Acl_Role_Interface) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('addRole() expects $role to be of type Zend_Acl_Role_Interface');
- }
-
-
- $this->_getRoleRegistry()->add($role, $parents);
-
- return $this;
- }
-
- /**
- * Returns the identified Role
- *
- * The $role parameter can either be a Role or Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::get()
- * @return Zend_Acl_Role_Interface
- */
- public function getRole($role)
- {
- return $this->_getRoleRegistry()->get($role);
- }
-
- /**
- * Returns true if and only if the Role exists in the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::has()
- * @return boolean
- */
- public function hasRole($role)
- {
- return $this->_getRoleRegistry()->has($role);
- }
-
- /**
- * Returns true if and only if $role inherits from $inherit
- *
- * Both parameters may be either a Role or a Role identifier. If
- * $onlyParents is true, then $role must inherit directly from
- * $inherit in order to return true. By default, this method looks
- * through the entire inheritance DAG to determine whether $role
- * inherits from $inherit through its ancestor Roles.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @param Zend_Acl_Role_Interface|string $inherit
- * @param boolean $onlyParents
- * @uses Zend_Acl_Role_Registry::inherits()
- * @return boolean
- */
- public function inheritsRole($role, $inherit, $onlyParents = false)
- {
- return $this->_getRoleRegistry()->inherits($role, $inherit, $onlyParents);
- }
-
- /**
- * Removes the Role from the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::remove()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeRole($role)
- {
- $this->_getRoleRegistry()->remove($role);
-
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = $role;
- }
-
- foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
- if ($roleId === $roleIdCurrent) {
- unset($this->_rules['allResources']['byRoleId'][$roleIdCurrent]);
- }
- }
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
- if (array_key_exists('byRoleId', $visitor)) {
- foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
- if ($roleId === $roleIdCurrent) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
- }
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Removes all Roles from the registry
- *
- * @uses Zend_Acl_Role_Registry::removeAll()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeRoleAll()
- {
- $this->_getRoleRegistry()->removeAll();
-
- foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
- unset($this->_rules['allResources']['byRoleId'][$roleIdCurrent]);
- }
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
- foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
- }
- }
-
- return $this;
- }
-
- /**
- * Adds a Resource having an identifier unique to the ACL
- *
- * The $parent parameter may be a reference to, or the string identifier for,
- * the existing Resource from which the newly added Resource will inherit.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @param Zend_Acl_Resource_Interface|string $parent
- * @throws Zend_Acl_Exception
- * @return Zend_Acl Provides a fluent interface
- */
- public function addResource($resource, $parent = null)
- {
- if (is_string($resource)) {
- $resource = new Zend_Acl_Resource($resource);
- }
-
- if (!$resource instanceof Zend_Acl_Resource_Interface) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('addResource() expects $resource to be of type Zend_Acl_Resource_Interface');
- }
-
- $resourceId = $resource->getResourceId();
-
- if ($this->has($resourceId)) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Resource id '$resourceId' already exists in the ACL");
- }
-
- $resourceParent = null;
-
- if (null !== $parent) {
- try {
- if ($parent instanceof Zend_Acl_Resource_Interface) {
- $resourceParentId = $parent->getResourceId();
- } else {
- $resourceParentId = $parent;
- }
- $resourceParent = $this->get($resourceParentId);
- } catch (Zend_Acl_Exception $e) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Parent Resource id '$resourceParentId' does not exist", 0, $e);
- }
- $this->_resources[$resourceParentId]['children'][$resourceId] = $resource;
- }
-
- $this->_resources[$resourceId] = array(
- 'instance' => $resource,
- 'parent' => $resourceParent,
- 'children' => array()
- );
-
- return $this;
- }
-
- /**
- * Adds a Resource having an identifier unique to the ACL
- *
- * The $parent parameter may be a reference to, or the string identifier for,
- * the existing Resource from which the newly added Resource will inherit.
- *
- * @deprecated in version 1.9.1 and will be available till 2.0. New code
- * should use addResource() instead.
- *
- * @param Zend_Acl_Resource_Interface $resource
- * @param Zend_Acl_Resource_Interface|string $parent
- * @throws Zend_Acl_Exception
- * @return Zend_Acl Provides a fluent interface
- */
- public function add(Zend_Acl_Resource_Interface $resource, $parent = null)
- {
- return $this->addResource($resource, $parent);
- }
-
- /**
- * Returns the identified Resource
- *
- * The $resource parameter can either be a Resource or a Resource identifier.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @throws Zend_Acl_Exception
- * @return Zend_Acl_Resource_Interface
- */
- public function get($resource)
- {
- if ($resource instanceof Zend_Acl_Resource_Interface) {
- $resourceId = $resource->getResourceId();
- } else {
- $resourceId = (string) $resource;
- }
-
- if (!$this->has($resource)) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Resource '$resourceId' not found");
- }
-
- return $this->_resources[$resourceId]['instance'];
- }
-
- /**
- * Returns true if and only if the Resource exists in the ACL
- *
- * The $resource parameter can either be a Resource or a Resource identifier.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @return boolean
- */
- public function has($resource)
- {
- if ($resource instanceof Zend_Acl_Resource_Interface) {
- $resourceId = $resource->getResourceId();
- } else {
- $resourceId = (string) $resource;
- }
-
- return isset($this->_resources[$resourceId]);
- }
-
- /**
- * Returns true if and only if $resource inherits from $inherit
- *
- * Both parameters may be either a Resource or a Resource identifier. If
- * $onlyParent is true, then $resource must inherit directly from
- * $inherit in order to return true. By default, this method looks
- * through the entire inheritance tree to determine whether $resource
- * inherits from $inherit through its ancestor Resources.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @param Zend_Acl_Resource_Interface|string $inherit
- * @param boolean $onlyParent
- * @throws Zend_Acl_Resource_Registry_Exception
- * @return boolean
- */
- public function inherits($resource, $inherit, $onlyParent = false)
- {
- try {
- $resourceId = $this->get($resource)->getResourceId();
- $inheritId = $this->get($inherit)->getResourceId();
- } catch (Zend_Acl_Exception $e) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- if (null !== $this->_resources[$resourceId]['parent']) {
- $parentId = $this->_resources[$resourceId]['parent']->getResourceId();
- if ($inheritId === $parentId) {
- return true;
- } else if ($onlyParent) {
- return false;
- }
- } else {
- return false;
- }
-
- while (null !== $this->_resources[$parentId]['parent']) {
- $parentId = $this->_resources[$parentId]['parent']->getResourceId();
- if ($inheritId === $parentId) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Removes a Resource and all of its children
- *
- * The $resource parameter can either be a Resource or a Resource identifier.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @throws Zend_Acl_Exception
- * @return Zend_Acl Provides a fluent interface
- */
- public function remove($resource)
- {
- try {
- $resourceId = $this->get($resource)->getResourceId();
- } catch (Zend_Acl_Exception $e) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- $resourcesRemoved = array($resourceId);
- if (null !== ($resourceParent = $this->_resources[$resourceId]['parent'])) {
- unset($this->_resources[$resourceParent->getResourceId()]['children'][$resourceId]);
- }
- foreach ($this->_resources[$resourceId]['children'] as $childId => $child) {
- $this->remove($childId);
- $resourcesRemoved[] = $childId;
- }
-
- foreach ($resourcesRemoved as $resourceIdRemoved) {
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $rules) {
- if ($resourceIdRemoved === $resourceIdCurrent) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]);
- }
- }
- }
-
- unset($this->_resources[$resourceId]);
-
- return $this;
- }
-
- /**
- * Removes all Resources
- *
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeAll()
- {
- foreach ($this->_resources as $resourceId => $resource) {
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $rules) {
- if ($resourceId === $resourceIdCurrent) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]);
- }
- }
- }
-
- $this->_resources = array();
-
- return $this;
- }
-
- /**
- * Adds an "allow" rule to the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @param Zend_Acl_Assert_Interface $assert
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function allow($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)
- {
- return $this->setRule(self::OP_ADD, self::TYPE_ALLOW, $roles, $resources, $privileges, $assert);
- }
-
- /**
- * Adds a "deny" rule to the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @param Zend_Acl_Assert_Interface $assert
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function deny($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)
- {
- return $this->setRule(self::OP_ADD, self::TYPE_DENY, $roles, $resources, $privileges, $assert);
- }
-
- /**
- * Removes "allow" permissions from the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeAllow($roles = null, $resources = null, $privileges = null)
- {
- return $this->setRule(self::OP_REMOVE, self::TYPE_ALLOW, $roles, $resources, $privileges);
- }
-
- /**
- * Removes "deny" restrictions from the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeDeny($roles = null, $resources = null, $privileges = null)
- {
- return $this->setRule(self::OP_REMOVE, self::TYPE_DENY, $roles, $resources, $privileges);
- }
-
- /**
- * Performs operations on ACL rules
- *
- * The $operation parameter may be either OP_ADD or OP_REMOVE, depending on whether the
- * user wants to add or remove a rule, respectively:
- *
- * OP_ADD specifics:
- *
- * A rule is added that would allow one or more Roles access to [certain $privileges
- * upon] the specified Resource(s).
- *
- * OP_REMOVE specifics:
- *
- * The rule is removed only in the context of the given Roles, Resources, and privileges.
- * Existing rules to which the remove operation does not apply would remain in the
- * ACL.
- *
- * The $type parameter may be either TYPE_ALLOW or TYPE_DENY, depending on whether the
- * rule is intended to allow or deny permission, respectively.
- *
- * The $roles and $resources parameters may be references to, or the string identifiers for,
- * existing Resources/Roles, or they may be passed as arrays of these - mixing string identifiers
- * and objects is ok - to indicate the Resources and Roles to which the rule applies. If either
- * $roles or $resources is null, then the rule applies to all Roles or all Resources, respectively.
- * Both may be null in order to work with the default rule of the ACL.
- *
- * The $privileges parameter may be used to further specify that the rule applies only
- * to certain privileges upon the Resource(s) in question. This may be specified to be a single
- * privilege with a string, and multiple privileges may be specified as an array of strings.
- *
- * If $assert is provided, then its assert() method must return true in order for
- * the rule to apply. If $assert is provided with $roles, $resources, and $privileges all
- * equal to null, then a rule having a type of:
- *
- * TYPE_ALLOW will imply a type of TYPE_DENY, and
- *
- * TYPE_DENY will imply a type of TYPE_ALLOW
- *
- * when the rule's assertion fails. This is because the ACL needs to provide expected
- * behavior when an assertion upon the default ACL rule fails.
- *
- * @param string $operation
- * @param string $type
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @param Zend_Acl_Assert_Interface $assert
- * @throws Zend_Acl_Exception
- * @uses Zend_Acl_Role_Registry::get()
- * @uses Zend_Acl::get()
- * @return Zend_Acl Provides a fluent interface
- */
- public function setRule($operation, $type, $roles = null, $resources = null, $privileges = null,
- Zend_Acl_Assert_Interface $assert = null)
- {
- // ensure that the rule type is valid; normalize input to uppercase
- $type = strtoupper($type);
- if (self::TYPE_ALLOW !== $type && self::TYPE_DENY !== $type) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Unsupported rule type; must be either '" . self::TYPE_ALLOW . "' or '"
- . self::TYPE_DENY . "'");
- }
-
- // ensure that all specified Roles exist; normalize input to array of Role objects or null
- if (!is_array($roles)) {
- $roles = array($roles);
- } else if (0 === count($roles)) {
- $roles = array(null);
- }
- $rolesTemp = $roles;
- $roles = array();
- foreach ($rolesTemp as $role) {
- if (null !== $role) {
- $roles[] = $this->_getRoleRegistry()->get($role);
- } else {
- $roles[] = null;
- }
- }
- unset($rolesTemp);
-
- // ensure that all specified Resources exist; normalize input to array of Resource objects or null
- if ($resources !== null) {
- if (!is_array($resources)) {
- $resources = array($resources);
- } else if (0 === count($resources)) {
- $resources = array(null);
- }
- $resourcesTemp = $resources;
- $resources = array();
- foreach ($resourcesTemp as $resource) {
- if (null !== $resource) {
- $resources[] = $this->get($resource);
- } else {
- $resources[] = null;
- }
- }
- unset($resourcesTemp, $resource);
- } else {
- $allResources = array(); // this might be used later if resource iteration is required
- foreach ($this->_resources as $rTarget) {
- $allResources[] = $rTarget['instance'];
- }
- unset($rTarget);
- }
-
- // normalize privileges to array
- if (null === $privileges) {
- $privileges = array();
- } else if (!is_array($privileges)) {
- $privileges = array($privileges);
- }
-
- switch ($operation) {
-
- // add to the rules
- case self::OP_ADD:
- if ($resources !== null) {
- // this block will iterate the provided resources
- foreach ($resources as $resource) {
- foreach ($roles as $role) {
- $rules =& $this->_getRules($resource, $role, true);
- if (0 === count($privileges)) {
- $rules['allPrivileges']['type'] = $type;
- $rules['allPrivileges']['assert'] = $assert;
- if (!isset($rules['byPrivilegeId'])) {
- $rules['byPrivilegeId'] = array();
- }
- } else {
- foreach ($privileges as $privilege) {
- $rules['byPrivilegeId'][$privilege]['type'] = $type;
- $rules['byPrivilegeId'][$privilege]['assert'] = $assert;
- }
- }
- }
- }
- } else {
- // this block will apply to all resources in a global rule
- foreach ($roles as $role) {
- $rules =& $this->_getRules(null, $role, true);
- if (0 === count($privileges)) {
- $rules['allPrivileges']['type'] = $type;
- $rules['allPrivileges']['assert'] = $assert;
- } else {
- foreach ($privileges as $privilege) {
- $rules['byPrivilegeId'][$privilege]['type'] = $type;
- $rules['byPrivilegeId'][$privilege]['assert'] = $assert;
- }
- }
- }
- }
- break;
-
- // remove from the rules
- case self::OP_REMOVE:
- if ($resources !== null) {
- // this block will iterate the provided resources
- foreach ($resources as $resource) {
- foreach ($roles as $role) {
- $rules =& $this->_getRules($resource, $role);
- if (null === $rules) {
- continue;
- }
- if (0 === count($privileges)) {
- if (null === $resource && null === $role) {
- if ($type === $rules['allPrivileges']['type']) {
- $rules = array(
- 'allPrivileges' => array(
- 'type' => self::TYPE_DENY,
- 'assert' => null
- ),
- 'byPrivilegeId' => array()
- );
- }
- continue;
- }
-
- if (isset($rules['allPrivileges']['type']) &&
- $type === $rules['allPrivileges']['type'])
- {
- unset($rules['allPrivileges']);
- }
- } else {
- foreach ($privileges as $privilege) {
- if (isset($rules['byPrivilegeId'][$privilege]) &&
- $type === $rules['byPrivilegeId'][$privilege]['type'])
- {
- unset($rules['byPrivilegeId'][$privilege]);
- }
- }
- }
- }
- }
- } else {
- // this block will apply to all resources in a global rule
- foreach ($roles as $role) {
- /**
- * since null (all resources) was passed to this setRule() call, we need
- * clean up all the rules for the global allResources, as well as the indivually
- * set resources (per privilege as well)
- */
- foreach (array_merge(array(null), $allResources) as $resource) {
- $rules =& $this->_getRules($resource, $role, true);
- if (null === $rules) {
- continue;
- }
- if (0 === count($privileges)) {
- if (null === $role) {
- if ($type === $rules['allPrivileges']['type']) {
- $rules = array(
- 'allPrivileges' => array(
- 'type' => self::TYPE_DENY,
- 'assert' => null
- ),
- 'byPrivilegeId' => array()
- );
- }
- continue;
- }
-
- if (isset($rules['allPrivileges']['type']) && $type === $rules['allPrivileges']['type']) {
- unset($rules['allPrivileges']);
- }
- } else {
- foreach ($privileges as $privilege) {
- if (isset($rules['byPrivilegeId'][$privilege]) &&
- $type === $rules['byPrivilegeId'][$privilege]['type'])
- {
- unset($rules['byPrivilegeId'][$privilege]);
- }
- }
- }
- }
- }
- }
- break;
-
- default:
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Unsupported operation; must be either '" . self::OP_ADD . "' or '"
- . self::OP_REMOVE . "'");
- }
-
- return $this;
- }
-
- /**
- * Returns true if and only if the Role has access to the Resource
- *
- * The $role and $resource parameters may be references to, or the string identifiers for,
- * an existing Resource and Role combination.
- *
- * If either $role or $resource is null, then the query applies to all Roles or all Resources,
- * respectively. Both may be null to query whether the ACL has a "blacklist" rule
- * (allow everything to all). By default, Zend_Acl creates a "whitelist" rule (deny
- * everything to all), and this method would return false unless this default has
- * been overridden (i.e., by executing $acl->allow()).
- *
- * If a $privilege is not provided, then this method returns false if and only if the
- * Role is denied access to at least one privilege upon the Resource. In other words, this
- * method returns true if and only if the Role is allowed all privileges on the Resource.
- *
- * This method checks Role inheritance using a depth-first traversal of the Role registry.
- * The highest priority parent (i.e., the parent most recently added) is checked first,
- * and its respective parents are checked similarly before the lower-priority parents of
- * the Role are checked.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @param Zend_Acl_Resource_Interface|string $resource
- * @param string $privilege
- * @uses Zend_Acl::get()
- * @uses Zend_Acl_Role_Registry::get()
- * @return boolean
- */
- public function isAllowed($role = null, $resource = null, $privilege = null)
- {
- // reset role & resource to null
- $this->_isAllowedRole = null;
- $this->_isAllowedResource = null;
- $this->_isAllowedPrivilege = null;
-
- if (null !== $role) {
- // keep track of originally called role
- $this->_isAllowedRole = $role;
- $role = $this->_getRoleRegistry()->get($role);
- if (!$this->_isAllowedRole instanceof Zend_Acl_Role_Interface) {
- $this->_isAllowedRole = $role;
- }
- }
-
- if (null !== $resource) {
- // keep track of originally called resource
- $this->_isAllowedResource = $resource;
- $resource = $this->get($resource);
- if (!$this->_isAllowedResource instanceof Zend_Acl_Resource_Interface) {
- $this->_isAllowedResource = $resource;
- }
- }
-
- if (null === $privilege) {
- // query on all privileges
- do {
- // depth-first search on $role if it is not 'allRoles' pseudo-parent
- if (null !== $role && null !== ($result = $this->_roleDFSAllPrivileges($role, $resource, $privilege))) {
- return $result;
- }
-
- // look for rule on 'allRoles' psuedo-parent
- if (null !== ($rules = $this->_getRules($resource, null))) {
- foreach ($rules['byPrivilegeId'] as $privilege => $rule) {
- if (self::TYPE_DENY === ($ruleTypeOnePrivilege = $this->_getRuleType($resource, null, $privilege))) {
- return false;
- }
- }
- if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
- }
-
- // try next Resource
- $resource = $this->_resources[$resource->getResourceId()]['parent'];
-
- } while (true); // loop terminates at 'allResources' pseudo-parent
- } else {
- $this->_isAllowedPrivilege = $privilege;
- // query on one privilege
- do {
- // depth-first search on $role if it is not 'allRoles' pseudo-parent
- if (null !== $role && null !== ($result = $this->_roleDFSOnePrivilege($role, $resource, $privilege))) {
- return $result;
- }
-
- // look for rule on 'allRoles' pseudo-parent
- if (null !== ($ruleType = $this->_getRuleType($resource, null, $privilege))) {
- return self::TYPE_ALLOW === $ruleType;
- } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
-
- // try next Resource
- $resource = $this->_resources[$resource->getResourceId()]['parent'];
-
- } while (true); // loop terminates at 'allResources' pseudo-parent
- }
- }
-
- /**
- * Returns the Role registry for this ACL
- *
- * If no Role registry has been created yet, a new default Role registry
- * is created and returned.
- *
- * @return Zend_Acl_Role_Registry
- */
- protected function _getRoleRegistry()
- {
- if (null === $this->_roleRegistry) {
- $this->_roleRegistry = new Zend_Acl_Role_Registry();
- }
- return $this->_roleRegistry;
- }
-
- /**
- * Performs a depth-first search of the Role DAG, starting at $role, in order to find a rule
- * allowing/denying $role access to all privileges upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @return boolean|null
- */
- protected function _roleDFSAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null)
- {
- $dfs = array(
- 'visited' => array(),
- 'stack' => array()
- );
-
- if (null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
- return $result;
- }
-
- while (null !== ($role = array_pop($dfs['stack']))) {
- if (!isset($dfs['visited'][$role->getRoleId()])) {
- if (null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
- return $result;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Visits an $role in order to look for a rule allowing/denying $role access to all privileges upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * This method is used by the internal depth-first search algorithm and may modify the DFS data structure.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @param array $dfs
- * @return boolean|null
- * @throws Zend_Acl_Exception
- */
- protected function _roleDFSVisitAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
- &$dfs = null)
- {
- if (null === $dfs) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$dfs parameter may not be null');
- }
-
- if (null !== ($rules = $this->_getRules($resource, $role))) {
- foreach ($rules['byPrivilegeId'] as $privilege => $rule) {
- if (self::TYPE_DENY === ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
- return false;
- }
- }
- if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
- }
-
- $dfs['visited'][$role->getRoleId()] = true;
- foreach ($this->_getRoleRegistry()->getParents($role) as $roleParentId => $roleParent) {
- $dfs['stack'][] = $roleParent;
- }
-
- return null;
- }
-
- /**
- * Performs a depth-first search of the Role DAG, starting at $role, in order to find a rule
- * allowing/denying $role access to a $privilege upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @param string $privilege
- * @return boolean|null
- * @throws Zend_Acl_Exception
- */
- protected function _roleDFSOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
- $privilege = null)
- {
- if (null === $privilege) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$privilege parameter may not be null');
- }
-
- $dfs = array(
- 'visited' => array(),
- 'stack' => array()
- );
-
- if (null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
- return $result;
- }
-
- while (null !== ($role = array_pop($dfs['stack']))) {
- if (!isset($dfs['visited'][$role->getRoleId()])) {
- if (null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
- return $result;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Visits an $role in order to look for a rule allowing/denying $role access to a $privilege upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * This method is used by the internal depth-first search algorithm and may modify the DFS data structure.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @param string $privilege
- * @param array $dfs
- * @return boolean|null
- * @throws Zend_Acl_Exception
- */
- protected function _roleDFSVisitOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
- $privilege = null, &$dfs = null)
- {
- if (null === $privilege) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$privilege parameter may not be null');
- }
-
- if (null === $dfs) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$dfs parameter may not be null');
- }
-
- if (null !== ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
- return self::TYPE_ALLOW === $ruleTypeOnePrivilege;
- } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
-
- $dfs['visited'][$role->getRoleId()] = true;
- foreach ($this->_getRoleRegistry()->getParents($role) as $roleParentId => $roleParent) {
- $dfs['stack'][] = $roleParent;
- }
-
- return null;
- }
-
- /**
- * Returns the rule type associated with the specified Resource, Role, and privilege
- * combination.
- *
- * If a rule does not exist or its attached assertion fails, which means that
- * the rule is not applicable, then this method returns null. Otherwise, the
- * rule type applies and is returned as either TYPE_ALLOW or TYPE_DENY.
- *
- * If $resource or $role is null, then this means that the rule must apply to
- * all Resources or Roles, respectively.
- *
- * If $privilege is null, then the rule must apply to all privileges.
- *
- * If all three parameters are null, then the default ACL rule type is returned,
- * based on whether its assertion method passes.
- *
- * @param Zend_Acl_Resource_Interface $resource
- * @param Zend_Acl_Role_Interface $role
- * @param string $privilege
- * @return string|null
- */
- protected function _getRuleType(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null,
- $privilege = null)
- {
- // get the rules for the $resource and $role
- if (null === ($rules = $this->_getRules($resource, $role))) {
- return null;
- }
-
- // follow $privilege
- if (null === $privilege) {
- if (isset($rules['allPrivileges'])) {
- $rule = $rules['allPrivileges'];
- } else {
- return null;
- }
- } else if (!isset($rules['byPrivilegeId'][$privilege])) {
- return null;
- } else {
- $rule = $rules['byPrivilegeId'][$privilege];
- }
-
- // check assertion first
- if ($rule['assert']) {
- $assertion = $rule['assert'];
- $assertionValue = $assertion->assert(
- $this,
- ($this->_isAllowedRole instanceof Zend_Acl_Role_Interface) ? $this->_isAllowedRole : $role,
- ($this->_isAllowedResource instanceof Zend_Acl_Resource_Interface) ? $this->_isAllowedResource : $resource,
- $this->_isAllowedPrivilege
- );
- }
-
- if (null === $rule['assert'] || $assertionValue) {
- return $rule['type'];
- } else if (null !== $resource || null !== $role || null !== $privilege) {
- return null;
- } else if (self::TYPE_ALLOW === $rule['type']) {
- return self::TYPE_DENY;
- } else {
- return self::TYPE_ALLOW;
- }
- }
-
- /**
- * Returns the rules associated with a Resource and a Role, or null if no such rules exist
- *
- * If either $resource or $role is null, this means that the rules returned are for all Resources or all Roles,
- * respectively. Both can be null to return the default rule set for all Resources and all Roles.
- *
- * If the $create parameter is true, then a rule set is first created and then returned to the caller.
- *
- * @param Zend_Acl_Resource_Interface $resource
- * @param Zend_Acl_Role_Interface $role
- * @param boolean $create
- * @return array|null
- */
- protected function &_getRules(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null,
- $create = false)
- {
- // create a reference to null
- $null = null;
- $nullRef =& $null;
-
- // follow $resource
- do {
- if (null === $resource) {
- $visitor =& $this->_rules['allResources'];
- break;
- }
- $resourceId = $resource->getResourceId();
- if (!isset($this->_rules['byResourceId'][$resourceId])) {
- if (!$create) {
- return $nullRef;
- }
- $this->_rules['byResourceId'][$resourceId] = array();
- }
- $visitor =& $this->_rules['byResourceId'][$resourceId];
- } while (false);
-
-
- // follow $role
- if (null === $role) {
- if (!isset($visitor['allRoles'])) {
- if (!$create) {
- return $nullRef;
- }
- $visitor['allRoles']['byPrivilegeId'] = array();
- }
- return $visitor['allRoles'];
- }
- $roleId = $role->getRoleId();
- if (!isset($visitor['byRoleId'][$roleId])) {
- if (!$create) {
- return $nullRef;
- }
- $visitor['byRoleId'][$roleId]['byPrivilegeId'] = array();
- $visitor['byRoleId'][$roleId]['allPrivileges'] = array('type' => null, 'assert' => null);
- }
- return $visitor['byRoleId'][$roleId];
- }
-
-
- /**
- * @return array of registered roles (Deprecated)
- * @deprecated Deprecated since version 1.10 (December 2009)
- */
- public function getRegisteredRoles()
- {
- trigger_error('The method getRegisteredRoles() was deprecated as of '
- . 'version 1.0, and may be removed. You\'re encouraged '
- . 'to use getRoles() instead.');
-
- return $this->_getRoleRegistry()->getRoles();
- }
-
- /**
- * Returns an array of registered roles.
- *
- * Note that this method does not return instances of registered roles,
- * but only the role identifiers.
- *
- * @return array of registered roles
- */
- public function getRoles()
- {
- return array_keys($this->_getRoleRegistry()->getRoles());
- }
-
- /**
- * @return array of registered resources
- */
- public function getResources()
- {
- return array_keys($this->_resources);
- }
-
-}
-
diff --git a/lib/zend/Zend/Acl/Assert/Interface.php b/lib/zend/Zend/Acl/Assert/Interface.php
deleted file mode 100644
index e3d02565fc66e..0000000000000
--- a/lib/zend/Zend/Acl/Assert/Interface.php
+++ /dev/null
@@ -1,64 +0,0 @@
-_resourceId = (string) $resourceId;
- }
-
- /**
- * Defined by Zend_Acl_Resource_Interface; returns the Resource identifier
- *
- * @return string
- */
- public function getResourceId()
- {
- return $this->_resourceId;
- }
-
- /**
- * Defined by Zend_Acl_Resource_Interface; returns the Resource identifier
- * Proxies to getResourceId()
- *
- * @return string
- */
- public function __toString()
- {
- return $this->getResourceId();
- }
-}
diff --git a/lib/zend/Zend/Acl/Resource/Interface.php b/lib/zend/Zend/Acl/Resource/Interface.php
deleted file mode 100644
index dcf10586d5169..0000000000000
--- a/lib/zend/Zend/Acl/Resource/Interface.php
+++ /dev/null
@@ -1,37 +0,0 @@
-_roleId = (string) $roleId;
- }
-
- /**
- * Defined by Zend_Acl_Role_Interface; returns the Role identifier
- *
- * @return string
- */
- public function getRoleId()
- {
- return $this->_roleId;
- }
-
- /**
- * Defined by Zend_Acl_Role_Interface; returns the Role identifier
- * Proxies to getRoleId()
- *
- * @return string
- */
- public function __toString()
- {
- return $this->getRoleId();
- }
-}
diff --git a/lib/zend/Zend/Acl/Role/Interface.php b/lib/zend/Zend/Acl/Role/Interface.php
deleted file mode 100644
index e2510003ce5a2..0000000000000
--- a/lib/zend/Zend/Acl/Role/Interface.php
+++ /dev/null
@@ -1,37 +0,0 @@
-getRoleId();
-
- if ($this->has($roleId)) {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- throw new Zend_Acl_Role_Registry_Exception("Role id '$roleId' already exists in the registry");
- }
-
- $roleParents = array();
-
- if (null !== $parents) {
- if (!is_array($parents)) {
- $parents = array($parents);
- }
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- foreach ($parents as $parent) {
- try {
- if ($parent instanceof Zend_Acl_Role_Interface) {
- $roleParentId = $parent->getRoleId();
- } else {
- $roleParentId = $parent;
- }
- $roleParent = $this->get($roleParentId);
- } catch (Zend_Acl_Role_Registry_Exception $e) {
- throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", 0, $e);
- }
- $roleParents[$roleParentId] = $roleParent;
- $this->_roles[$roleParentId]['children'][$roleId] = $role;
- }
- }
-
- $this->_roles[$roleId] = array(
- 'instance' => $role,
- 'parents' => $roleParents,
- 'children' => array()
- );
-
- return $this;
- }
-
- /**
- * Returns the identified Role
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @throws Zend_Acl_Role_Registry_Exception
- * @return Zend_Acl_Role_Interface
- */
- public function get($role)
- {
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = (string) $role;
- }
-
- if (!$this->has($role)) {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- throw new Zend_Acl_Role_Registry_Exception("Role '$roleId' not found");
- }
-
- return $this->_roles[$roleId]['instance'];
- }
-
- /**
- * Returns true if and only if the Role exists in the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @return boolean
- */
- public function has($role)
- {
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = (string) $role;
- }
-
- return isset($this->_roles[$roleId]);
- }
-
- /**
- * Returns an array of an existing Role's parents
- *
- * The array keys are the identifiers of the parent Roles, and the values are
- * the parent Role instances. The parent Roles are ordered in this array by
- * ascending priority. The highest priority parent Role, last in the array,
- * corresponds with the parent Role most recently added.
- *
- * If the Role does not have any parents, then an empty array is returned.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::get()
- * @return array
- */
- public function getParents($role)
- {
- $roleId = $this->get($role)->getRoleId();
-
- return $this->_roles[$roleId]['parents'];
- }
-
- /**
- * Returns true if and only if $role inherits from $inherit
- *
- * Both parameters may be either a Role or a Role identifier. If
- * $onlyParents is true, then $role must inherit directly from
- * $inherit in order to return true. By default, this method looks
- * through the entire inheritance DAG to determine whether $role
- * inherits from $inherit through its ancestor Roles.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @param Zend_Acl_Role_Interface|string $inherit
- * @param boolean $onlyParents
- * @throws Zend_Acl_Role_Registry_Exception
- * @return boolean
- */
- public function inherits($role, $inherit, $onlyParents = false)
- {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- try {
- $roleId = $this->get($role)->getRoleId();
- $inheritId = $this->get($inherit)->getRoleId();
- } catch (Zend_Acl_Role_Registry_Exception $e) {
- throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- $inherits = isset($this->_roles[$roleId]['parents'][$inheritId]);
-
- if ($inherits || $onlyParents) {
- return $inherits;
- }
-
- foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
- if ($this->inherits($parentId, $inheritId)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Removes the Role from the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @throws Zend_Acl_Role_Registry_Exception
- * @return Zend_Acl_Role_Registry Provides a fluent interface
- */
- public function remove($role)
- {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- try {
- $roleId = $this->get($role)->getRoleId();
- } catch (Zend_Acl_Role_Registry_Exception $e) {
- throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- foreach ($this->_roles[$roleId]['children'] as $childId => $child) {
- unset($this->_roles[$childId]['parents'][$roleId]);
- }
- foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
- unset($this->_roles[$parentId]['children'][$roleId]);
- }
-
- unset($this->_roles[$roleId]);
-
- return $this;
- }
-
- /**
- * Removes all Roles from the registry
- *
- * @return Zend_Acl_Role_Registry Provides a fluent interface
- */
- public function removeAll()
- {
- $this->_roles = array();
-
- return $this;
- }
-
- public function getRoles()
- {
- return $this->_roles;
- }
-
-}
diff --git a/lib/zend/Zend/Acl/Role/Registry/Exception.php b/lib/zend/Zend/Acl/Role/Registry/Exception.php
deleted file mode 100644
index a2e906a98a2e2..0000000000000
--- a/lib/zend/Zend/Acl/Role/Registry/Exception.php
+++ /dev/null
@@ -1,36 +0,0 @@
-_acl = new Zend_Acl();
- $xml = Zend_Xml_Security::scanFile($rolefile);
-/*
-Roles file format:
-
-
-
-
-
-
-
-
-*/
- foreach($xml->role as $role) {
- $this->_acl->addRole(new Zend_Acl_Role((string)$role["id"]));
- foreach($role->user as $user) {
- $this->_users[(string)$user["name"]] = array("password" => (string)$user["password"],
- "role" => (string)$role["id"]);
- }
- }
- }
-
- /**
- * Get ACL with roles from XML file
- *
- * @return Zend_Acl
- */
- public function getAcl()
- {
- return $this->_acl;
- }
-
- /**
- * Perform authentication
- *
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- * @see Zend_Auth_Adapter_Interface#authenticate()
- */
- public function authenticate()
- {
- if (empty($this->_username) ||
- empty($this->_password)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Username/password should be set');
- }
-
- if(!isset($this->_users[$this->_username])) {
- return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
- null,
- array('Username not found')
- );
- }
-
- $user = $this->_users[$this->_username];
- if($user["password"] != $this->_password) {
- return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
- null,
- array('Authentication failed')
- );
- }
-
- $id = new stdClass();
- $id->role = $user["role"];
- $id->name = $this->_username;
- return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
- }
-}
diff --git a/lib/zend/Zend/Amf/Adobe/DbInspector.php b/lib/zend/Zend/Amf/Adobe/DbInspector.php
deleted file mode 100644
index a25c3a2b1655c..0000000000000
--- a/lib/zend/Zend/Amf/Adobe/DbInspector.php
+++ /dev/null
@@ -1,103 +0,0 @@
-describeTable('Pdo_Mysql',
- * array(
- * 'host' => '127.0.0.1',
- * 'username' => 'webuser',
- * 'password' => 'xxxxxxxx',
- * 'dbname' => 'test'
- * ),
- * 'mytable'
- * );
- *
- * @param string $dbType Database adapter type for Zend_Db
- * @param array|object $dbDescription Adapter-specific connection settings
- * @param string $tableName Table name
- * @return array Table description
- * @see Zend_Db::describeTable()
- * @see Zend_Db::factory()
- */
- public function describeTable($dbType, $dbDescription, $tableName)
- {
- $db = $this->_connect($dbType, $dbDescription);
- return $db->describeTable($tableName);
- }
-
- /**
- * Test database connection
- *
- * @param string $dbType Database adapter type for Zend_Db
- * @param array|object $dbDescription Adapter-specific connection settings
- * @return bool
- * @see Zend_Db::factory()
- */
- public function connect($dbType, $dbDescription)
- {
- $db = $this->_connect($dbType, $dbDescription);
- $db->listTables();
- return true;
- }
-
- /**
- * Get the list of database tables
- *
- * @param string $dbType Database adapter type for Zend_Db
- * @param array|object $dbDescription Adapter-specific connection settings
- * @return array List of the tables
- */
- public function getTables($dbType, $dbDescription)
- {
- $db = $this->_connect($dbType, $dbDescription);
- return $db->listTables();
- }
-}
diff --git a/lib/zend/Zend/Amf/Adobe/Introspector.php b/lib/zend/Zend/Amf/Adobe/Introspector.php
deleted file mode 100644
index 3eb76c490cc5a..0000000000000
--- a/lib/zend/Zend/Amf/Adobe/Introspector.php
+++ /dev/null
@@ -1,318 +0,0 @@
-_xml = new DOMDocument('1.0', 'utf-8');
- }
-
- /**
- * Create XML definition on an AMF service class
- *
- * @param string $serviceClass Service class name
- * @param array $options invocation options
- * @return string XML with service class introspection
- */
- public function introspect($serviceClass, $options = array())
- {
- $this->_options = $options;
-
- if (strpbrk($serviceClass, '\\/<>')) {
- return $this->_returnError('Invalid service name');
- }
-
- // Transform com.foo.Bar into com_foo_Bar
- $serviceClass = str_replace('.' , '_', $serviceClass);
-
- // Introspect!
- if (!class_exists($serviceClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($serviceClass, $this->_getServicePath());
- }
-
- $serv = $this->_xml->createElement('service-description');
- $serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008');
-
- $this->_types = $this->_xml->createElement('types');
- $this->_ops = $this->_xml->createElement('operations');
-
- $r = Zend_Server_Reflection::reflectClass($serviceClass);
- $this->_addService($r, $this->_ops);
-
- $serv->appendChild($this->_types);
- $serv->appendChild($this->_ops);
- $this->_xml->appendChild($serv);
-
- return $this->_xml->saveXML();
- }
-
- /**
- * Authentication handler
- *
- * @param Zend_Acl $acl
- * @return unknown_type
- */
- public function initAcl(Zend_Acl $acl)
- {
- return false; // we do not need auth for this class
- }
-
- /**
- * Generate map of public class attributes
- *
- * @param string $typename type name
- * @param DOMElement $typexml target XML element
- * @return void
- */
- protected function _addClassAttributes($typename, DOMElement $typexml)
- {
- // Do not try to autoload here because _phpTypeToAS should
- // have already attempted to load this class
- if (!class_exists($typename, false)) {
- return;
- }
-
- $rc = new Zend_Reflection_Class($typename);
- foreach ($rc->getProperties() as $prop) {
- if (!$prop->isPublic()) {
- continue;
- }
-
- $propxml = $this->_xml->createElement('property');
- $propxml->setAttribute('name', $prop->getName());
-
- $type = $this->_registerType($this->_getPropertyType($prop));
- $propxml->setAttribute('type', $type);
-
- $typexml->appendChild($propxml);
- }
- }
-
- /**
- * Build XML service description from reflection class
- *
- * @param Zend_Server_Reflection_Class $refclass
- * @param DOMElement $target target XML element
- * @return void
- */
- protected function _addService(Zend_Server_Reflection_Class $refclass, DOMElement $target)
- {
- foreach ($refclass->getMethods() as $method) {
- if (!$method->isPublic()
- || $method->isConstructor()
- || ('__' == substr($method->name, 0, 2))
- ) {
- continue;
- }
-
- foreach ($method->getPrototypes() as $proto) {
- $op = $this->_xml->createElement('operation');
- $op->setAttribute('name', $method->getName());
-
- $rettype = $this->_registerType($proto->getReturnType());
- $op->setAttribute('returnType', $rettype);
-
- foreach ($proto->getParameters() as $param) {
- $arg = $this->_xml->createElement('argument');
- $arg->setAttribute('name', $param->getName());
-
- $type = $param->getType();
- if ($type == 'mixed' && ($pclass = $param->getClass())) {
- $type = $pclass->getName();
- }
-
- $ptype = $this->_registerType($type);
- $arg->setAttribute('type', $ptype);
-
- if($param->isDefaultValueAvailable()) {
- $arg->setAttribute('defaultvalue', $param->getDefaultValue());
- }
-
- $op->appendChild($arg);
- }
-
- $target->appendChild($op);
- }
- }
- }
-
- /**
- * Extract type of the property from DocBlock
- *
- * @param Zend_Reflection_Property $prop reflection property object
- * @return string Property type
- */
- protected function _getPropertyType(Zend_Reflection_Property $prop)
- {
- $docBlock = $prop->getDocComment();
-
- if (!$docBlock) {
- return 'Unknown';
- }
-
- if (!$docBlock->hasTag('var')) {
- return 'Unknown';
- }
-
- $tag = $docBlock->getTag('var');
- return trim($tag->getDescription());
- }
-
- /**
- * Get the array of service directories
- *
- * @return array Service class directories
- */
- protected function _getServicePath()
- {
- if (isset($this->_options['server'])) {
- return $this->_options['server']->getDirectory();
- }
-
- if (isset($this->_options['directories'])) {
- return $this->_options['directories'];
- }
-
- return array();
- }
-
- /**
- * Map from PHP type name to AS type name
- *
- * @param string $typename PHP type name
- * @return string AS type name
- */
- protected function _phpTypeToAS($typename)
- {
- if (class_exists($typename)) {
- $vars = get_class_vars($typename);
-
- if (isset($vars['_explicitType'])) {
- return $vars['_explicitType'];
- }
- }
-
- if (false !== ($asname = Zend_Amf_Parse_TypeLoader::getMappedClassName($typename))) {
- return $asname;
- }
-
- return $typename;
- }
-
- /**
- * Register new type on the system
- *
- * @param string $typename type name
- * @return string New type name
- */
- protected function _registerType($typename)
- {
- // Known type - return its AS name
- if (isset($this->_typesMap[$typename])) {
- return $this->_typesMap[$typename];
- }
-
- // Standard types
- if (in_array($typename, array('void', 'null', 'mixed', 'unknown_type'))) {
- return 'Unknown';
- }
-
- // Arrays
- if ('array' == $typename) {
- return 'Unknown[]';
- }
-
- if (in_array($typename, array('int', 'integer', 'bool', 'boolean', 'float', 'string', 'object', 'Unknown', 'stdClass'))) {
- return $typename;
- }
-
- // Resolve and store AS name
- $asTypeName = $this->_phpTypeToAS($typename);
- $this->_typesMap[$typename] = $asTypeName;
-
- // Create element for the name
- $typeEl = $this->_xml->createElement('type');
- $typeEl->setAttribute('name', $asTypeName);
- $this->_addClassAttributes($typename, $typeEl);
- $this->_types->appendChild($typeEl);
-
- return $asTypeName;
- }
-
- /**
- * Return error with error message
- *
- * @param string $msg Error message
- * @return string
- */
- protected function _returnError($msg)
- {
- return 'ERROR: $msg';
- }
-}
diff --git a/lib/zend/Zend/Amf/Auth/Abstract.php b/lib/zend/Zend/Amf/Auth/Abstract.php
deleted file mode 100644
index 180568d3fcc0f..0000000000000
--- a/lib/zend/Zend/Amf/Auth/Abstract.php
+++ /dev/null
@@ -1,42 +0,0 @@
-_username = $username;
- $this->_password = $password;
- }
-}
diff --git a/lib/zend/Zend/Amf/Constants.php b/lib/zend/Zend/Amf/Constants.php
deleted file mode 100644
index 723d8ba4fd369..0000000000000
--- a/lib/zend/Zend/Amf/Constants.php
+++ /dev/null
@@ -1,87 +0,0 @@
-_stream->readByte();
- }
-
- switch($typeMarker) {
- // number
- case Zend_Amf_Constants::AMF0_NUMBER:
- return $this->_stream->readDouble();
-
- // boolean
- case Zend_Amf_Constants::AMF0_BOOLEAN:
- return (boolean) $this->_stream->readByte();
-
- // string
- case Zend_Amf_Constants::AMF0_STRING:
- return $this->_stream->readUTF();
-
- // object
- case Zend_Amf_Constants::AMF0_OBJECT:
- return $this->readObject();
-
- // null
- case Zend_Amf_Constants::AMF0_NULL:
- return null;
-
- // undefined
- case Zend_Amf_Constants::AMF0_UNDEFINED:
- return null;
-
- // Circular references are returned here
- case Zend_Amf_Constants::AMF0_REFERENCE:
- return $this->readReference();
-
- // mixed array with numeric and string keys
- case Zend_Amf_Constants::AMF0_MIXEDARRAY:
- return $this->readMixedArray();
-
- // array
- case Zend_Amf_Constants::AMF0_ARRAY:
- return $this->readArray();
-
- // date
- case Zend_Amf_Constants::AMF0_DATE:
- return $this->readDate();
-
- // longString strlen(string) > 2^16
- case Zend_Amf_Constants::AMF0_LONGSTRING:
- return $this->_stream->readLongUTF();
-
- //internal AS object, not supported
- case Zend_Amf_Constants::AMF0_UNSUPPORTED:
- return null;
-
- // XML
- case Zend_Amf_Constants::AMF0_XML:
- return $this->readXmlString();
-
- // typed object ie Custom Class
- case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
- return $this->readTypedObject();
-
- //AMF3-specific
- case Zend_Amf_Constants::AMF0_AMF3:
- return $this->readAmf3TypeMarker();
-
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported marker type: ' . $typeMarker);
- }
- }
-
- /**
- * Read AMF objects and convert to PHP objects
- *
- * Read the name value pair objects form the php message and convert them to
- * a php object class.
- *
- * Called when the marker type is 3.
- *
- * @param array|null $object
- * @return object
- */
- public function readObject($object = null)
- {
- if ($object === null) {
- $object = array();
- }
-
- while (true) {
- $key = $this->_stream->readUTF();
- $typeMarker = $this->_stream->readByte();
- if ($typeMarker != Zend_Amf_Constants::AMF0_OBJECTTERM ){
- //Recursivly call readTypeMarker to get the types of properties in the object
- $object[$key] = $this->readTypeMarker($typeMarker);
- } else {
- //encountered AMF object terminator
- break;
- }
- }
- $this->_reference[] = $object;
- return (object) $object;
- }
-
- /**
- * Read reference objects
- *
- * Used to gain access to the private array of reference objects.
- * Called when marker type is 7.
- *
- * @return object
- * @throws Zend_Amf_Exception for invalid reference keys
- */
- public function readReference()
- {
- $key = $this->_stream->readInt();
- if (!array_key_exists($key, $this->_reference)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid reference key: '. $key);
- }
- return $this->_reference[$key];
- }
-
- /**
- * Reads an array with numeric and string indexes.
- *
- * Called when marker type is 8
- *
- * @todo As of Flash Player 9 there is not support for mixed typed arrays
- * so we handle this as an object. With the introduction of vectors
- * in Flash Player 10 this may need to be reconsidered.
- * @return array
- */
- public function readMixedArray()
- {
- $length = $this->_stream->readLong();
- return $this->readObject();
- }
-
- /**
- * Converts numerically indexed actiosncript arrays into php arrays.
- *
- * Called when marker type is 10
- *
- * @return array
- */
- public function readArray()
- {
- $length = $this->_stream->readLong();
- $array = array();
- while ($length--) {
- $array[] = $this->readTypeMarker();
- }
- return $array;
- }
-
- /**
- * Convert AS Date to Zend_Date
- *
- * @return Zend_Date
- */
- public function readDate()
- {
- // get the unix time stamp. Not sure why ActionScript does not use
- // milliseconds
- $timestamp = floor($this->_stream->readDouble() / 1000);
-
- // The timezone offset is never returned to the server; it is always 0,
- // so read and ignore.
- $offset = $this->_stream->readInt();
-
- require_once 'Zend/Date.php';
- $date = new Zend_Date($timestamp);
- return $date;
- }
-
- /**
- * Convert XML to SimpleXml
- * If user wants DomDocument they can use dom_import_simplexml
- *
- * @return SimpleXml Object
- */
- public function readXmlString()
- {
- $string = $this->_stream->readLongUTF();
- return Zend_Xml_Security::scan($string); //simplexml_load_string($string);
- }
-
- /**
- * Read Class that is to be mapped to a server class.
- *
- * Commonly used for Value Objects on the server
- *
- * @todo implement Typed Class mapping
- * @return object|array
- * @throws Zend_Amf_Exception if unable to load type
- */
- public function readTypedObject()
- {
- require_once 'Zend/Amf/Parse/TypeLoader.php';
- // get the remote class name
- $className = $this->_stream->readUTF();
- $loader = Zend_Amf_Parse_TypeLoader::loadType($className);
- $returnObject = new $loader();
- $properties = get_object_vars($this->readObject());
- foreach($properties as $key=>$value) {
- if($key) {
- $returnObject->$key = $value;
- }
- }
- if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
- $returnObject = get_object_vars($returnObject);
- }
- return $returnObject;
- }
-
- /**
- * AMF3 data type encountered load AMF3 Deserializer to handle
- * type markers.
- *
- * @return string
- */
- public function readAmf3TypeMarker()
- {
- require_once 'Zend/Amf/Parse/Amf3/Deserializer.php';
- $deserializer = new Zend_Amf_Parse_Amf3_Deserializer($this->_stream);
- $this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
- return $deserializer->readTypeMarker();
- }
-
- /**
- * Return the object encoding to check if an AMF3 object
- * is going to be return.
- *
- * @return int
- */
- public function getObjectEncoding()
- {
- return $this->_objectEncoding;
- }
-}
diff --git a/lib/zend/Zend/Amf/Parse/Amf0/Serializer.php b/lib/zend/Zend/Amf/Parse/Amf0/Serializer.php
deleted file mode 100644
index 0a578c12911ef..0000000000000
--- a/lib/zend/Zend/Amf/Parse/Amf0/Serializer.php
+++ /dev/null
@@ -1,362 +0,0 @@
-writeObjectReference($data, $markerType)) {
- // Write the Type Marker to denote the following action script data type
- $this->_stream->writeByte($markerType);
- switch($markerType) {
- case Zend_Amf_Constants::AMF0_NUMBER:
- $this->_stream->writeDouble($data);
- break;
- case Zend_Amf_Constants::AMF0_BOOLEAN:
- $this->_stream->writeByte($data);
- break;
- case Zend_Amf_Constants::AMF0_STRING:
- $this->_stream->writeUTF($data);
- break;
- case Zend_Amf_Constants::AMF0_OBJECT:
- $this->writeObject($data);
- break;
- case Zend_Amf_Constants::AMF0_NULL:
- break;
- case Zend_Amf_Constants::AMF0_REFERENCE:
- $this->_stream->writeInt($data);
- break;
- case Zend_Amf_Constants::AMF0_MIXEDARRAY:
- // Write length of numeric keys as zero.
- $this->_stream->writeLong(0);
- $this->writeObject($data);
- break;
- case Zend_Amf_Constants::AMF0_ARRAY:
- $this->writeArray($data);
- break;
- case Zend_Amf_Constants::AMF0_DATE:
- $this->writeDate($data);
- break;
- case Zend_Amf_Constants::AMF0_LONGSTRING:
- $this->_stream->writeLongUTF($data);
- break;
- case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
- $this->writeTypedObject($data);
- break;
- case Zend_Amf_Constants::AMF0_AMF3:
- $this->writeAmf3TypeMarker($data);
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception("Unknown Type Marker: " . $markerType);
- }
- }
- } else {
- if (is_resource($data)) {
- $data = Zend_Amf_Parse_TypeLoader::handleResource($data);
- }
- switch (true) {
- case (is_int($data) || is_float($data)):
- $markerType = Zend_Amf_Constants::AMF0_NUMBER;
- break;
- case (is_bool($data)):
- $markerType = Zend_Amf_Constants::AMF0_BOOLEAN;
- break;
- case (is_string($data) && (($this->_mbStringFunctionsOverloaded ? mb_strlen($data, '8bit') : strlen($data)) > 65536)):
- $markerType = Zend_Amf_Constants::AMF0_LONGSTRING;
- break;
- case (is_string($data)):
- $markerType = Zend_Amf_Constants::AMF0_STRING;
- break;
- case (is_object($data)):
- if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
- $markerType = Zend_Amf_Constants::AMF0_DATE;
- } else {
-
- if($className = $this->getClassName($data)){
- //Object is a Typed object set classname
- $markerType = Zend_Amf_Constants::AMF0_TYPEDOBJECT;
- $this->_className = $className;
- } else {
- // Object is a generic classname
- $markerType = Zend_Amf_Constants::AMF0_OBJECT;
- }
- break;
- }
- break;
- case (null === $data):
- $markerType = Zend_Amf_Constants::AMF0_NULL;
- break;
- case (is_array($data)):
- // check if it is an associative array
- $i = 0;
- foreach (array_keys($data) as $key) {
- // check if it contains non-integer keys
- if (!is_numeric($key) || intval($key) != $key) {
- $markerType = Zend_Amf_Constants::AMF0_OBJECT;
- break;
- // check if it is a sparse indexed array
- } else if ($key != $i) {
- $markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
- break;
- }
- $i++;
- }
- // Dealing with a standard numeric array
- if(!$markerType){
- $markerType = Zend_Amf_Constants::AMF0_ARRAY;
- break;
- }
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
- }
-
- $this->writeTypeMarker($data, $markerType);
- }
- return $this;
- }
-
- /**
- * Check if the given object is in the reference table, write the reference if it exists,
- * otherwise add the object to the reference table
- *
- * @param mixed $object object reference to check for reference
- * @param string $markerType AMF type of the object to write
- * @param mixed $objectByVal object to check for reference
- * @return Boolean true, if the reference was written, false otherwise
- */
- protected function writeObjectReference(&$object, $markerType, $objectByVal = false)
- {
- // Workaround for PHP5 with E_STRICT enabled complaining about "Only
- // variables should be passed by reference"
- if ((null === $object) && ($objectByVal !== false)) {
- $object = &$objectByVal;
- }
-
- if ($markerType == Zend_Amf_Constants::AMF0_OBJECT
- || $markerType == Zend_Amf_Constants::AMF0_MIXEDARRAY
- || $markerType == Zend_Amf_Constants::AMF0_ARRAY
- || $markerType == Zend_Amf_Constants::AMF0_TYPEDOBJECT
- ) {
- $ref = array_search($object, $this->_referenceObjects, true);
- //handle object reference
- if($ref !== false){
- $this->writeTypeMarker($ref,Zend_Amf_Constants::AMF0_REFERENCE);
- return true;
- }
-
- $this->_referenceObjects[] = $object;
- }
-
- return false;
- }
-
- /**
- * Write a PHP array with string or mixed keys.
- *
- * @param object $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeObject($object)
- {
- // Loop each element and write the name of the property.
- foreach ($object as $key => &$value) {
- // skip variables starting with an _ private transient
- if( $key[0] == "_") continue;
- $this->_stream->writeUTF($key);
- $this->writeTypeMarker($value);
- }
-
- // Write the end object flag
- $this->_stream->writeInt(0);
- $this->_stream->writeByte(Zend_Amf_Constants::AMF0_OBJECTTERM);
- return $this;
- }
-
- /**
- * Write a standard numeric array to the output stream. If a mixed array
- * is encountered call writeTypeMarker with mixed array.
- *
- * @param array $array
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeArray(&$array)
- {
- $length = count($array);
- if (!$length < 0) {
- // write the length of the array
- $this->_stream->writeLong(0);
- } else {
- // Write the length of the numeric array
- $this->_stream->writeLong($length);
- for ($i=0; $i<$length; $i++) {
- $value = isset($array[$i]) ? $array[$i] : null;
- $this->writeTypeMarker($value);
- }
- }
- return $this;
- }
-
- /**
- * Convert the DateTime into an AMF Date
- *
- * @param DateTime|Zend_Date $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeDate($data)
- {
- if ($data instanceof DateTime) {
- $dateString = $data->format('U');
- } elseif ($data instanceof Zend_Date) {
- $dateString = $data->toString('U');
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid date specified; must be a DateTime or Zend_Date object');
- }
- $dateString *= 1000;
-
- // Make the conversion and remove milliseconds.
- $this->_stream->writeDouble($dateString);
-
- // Flash does not respect timezone but requires it.
- $this->_stream->writeInt(0);
-
- return $this;
- }
-
- /**
- * Write a class mapped object to the output stream.
- *
- * @param object $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeTypedObject($data)
- {
- $this->_stream->writeUTF($this->_className);
- $this->writeObject($data);
- return $this;
- }
-
- /**
- * Encountered and AMF3 Type Marker use AMF3 serializer. Once AMF3 is
- * encountered it will not return to AMf0.
- *
- * @param string $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeAmf3TypeMarker(&$data)
- {
- require_once 'Zend/Amf/Parse/Amf3/Serializer.php';
- $serializer = new Zend_Amf_Parse_Amf3_Serializer($this->_stream);
- $serializer->writeTypeMarker($data);
- return $this;
- }
-
- /**
- * Find if the class name is a class mapped name and return the
- * respective classname if it is.
- *
- * @param object $object
- * @return false|string $className
- */
- protected function getClassName($object)
- {
- require_once 'Zend/Amf/Parse/TypeLoader.php';
- //Check to see if the object is a typed object and we need to change
- $className = '';
- switch (true) {
- // the return class mapped name back to actionscript class name.
- case Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)):
- $className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object));
- break;
- // Check to see if the user has defined an explicit Action Script type.
- case isset($object->_explicitType):
- $className = $object->_explicitType;
- break;
- // Check if user has defined a method for accessing the Action Script type
- case method_exists($object, 'getASClassName'):
- $className = $object->getASClassName();
- break;
- // No return class name is set make it a generic object
- case ($object instanceof stdClass):
- $className = '';
- break;
- // By default, use object's class name
- default:
- $className = get_class($object);
- break;
- }
- if(!$className == '') {
- return $className;
- } else {
- return false;
- }
- }
-}
diff --git a/lib/zend/Zend/Amf/Parse/Amf3/Deserializer.php b/lib/zend/Zend/Amf/Parse/Amf3/Deserializer.php
deleted file mode 100644
index 9bcc272af304a..0000000000000
--- a/lib/zend/Zend/Amf/Parse/Amf3/Deserializer.php
+++ /dev/null
@@ -1,425 +0,0 @@
-_stream->readByte();
- }
-
- switch($typeMarker) {
- case Zend_Amf_Constants::AMF3_UNDEFINED:
- return null;
- case Zend_Amf_Constants::AMF3_NULL:
- return null;
- case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
- return false;
- case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
- return true;
- case Zend_Amf_Constants::AMF3_INTEGER:
- return $this->readInteger();
- case Zend_Amf_Constants::AMF3_NUMBER:
- return $this->_stream->readDouble();
- case Zend_Amf_Constants::AMF3_STRING:
- return $this->readString();
- case Zend_Amf_Constants::AMF3_DATE:
- return $this->readDate();
- case Zend_Amf_Constants::AMF3_ARRAY:
- return $this->readArray();
- case Zend_Amf_Constants::AMF3_OBJECT:
- return $this->readObject();
- case Zend_Amf_Constants::AMF3_XML:
- case Zend_Amf_Constants::AMF3_XMLSTRING:
- return $this->readXmlString();
- case Zend_Amf_Constants::AMF3_BYTEARRAY:
- return $this->readString();
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported type marker: ' . $typeMarker);
- }
- }
-
- /**
- * Read and deserialize an integer
- *
- * AMF 3 represents smaller integers with fewer bytes using the most
- * significant bit of each byte. The worst case uses 32-bits
- * to represent a 29-bit number, which is what we would have
- * done with no compression.
- * - 0x00000000 - 0x0000007F : 0xxxxxxx
- * - 0x00000080 - 0x00003FFF : 1xxxxxxx 0xxxxxxx
- * - 0x00004000 - 0x001FFFFF : 1xxxxxxx 1xxxxxxx 0xxxxxxx
- * - 0x00200000 - 0x3FFFFFFF : 1xxxxxxx 1xxxxxxx 1xxxxxxx xxxxxxxx
- * - 0x40000000 - 0xFFFFFFFF : throw range exception
- *
- * 0x04 -> integer type code, followed by up to 4 bytes of data.
- *
- * Parsing integers on OSFlash for the AMF3 integer data format:
- * @link http://osflash.org/amf3/parsing_integers
- * @return int|float
- */
- public function readInteger()
- {
- $count = 1;
- $intReference = $this->_stream->readByte();
- $result = 0;
- while ((($intReference & 0x80) != 0) && $count < 4) {
- $result <<= 7;
- $result |= ($intReference & 0x7f);
- $intReference = $this->_stream->readByte();
- $count++;
- }
- if ($count < 4) {
- $result <<= 7;
- $result |= $intReference;
- } else {
- // Use all 8 bits from the 4th byte
- $result <<= 8;
- $result |= $intReference;
-
- // Check if the integer should be negative
- if (($result & 0x10000000) != 0) {
- //and extend the sign bit
- $result |= ~0xFFFFFFF;
- }
- }
- return $result;
- }
-
- /**
- * Read and deserialize a string
- *
- * Strings can be sent as a reference to a previously
- * occurring String by using an index to the implicit string reference table.
- * Strings are encoding using UTF-8 - however the header may either
- * describe a string literal or a string reference.
- *
- * - string = 0x06 string-data
- * - string-data = integer-data [ modified-utf-8 ]
- * - modified-utf-8 = *OCTET
- *
- * @return String
- */
- public function readString()
- {
- $stringReference = $this->readInteger();
-
- //Check if this is a reference string
- if (($stringReference & 0x01) == 0) {
- // reference string
- $stringReference = $stringReference >> 1;
- if ($stringReference >= count($this->_referenceStrings)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Undefined string reference: ' . $stringReference);
- }
- // reference string found
- return $this->_referenceStrings[$stringReference];
- }
-
- $length = $stringReference >> 1;
- if ($length) {
- $string = $this->_stream->readBytes($length);
- $this->_referenceStrings[] = $string;
- } else {
- $string = "";
- }
- return $string;
- }
-
- /**
- * Read and deserialize a date
- *
- * Data is the number of milliseconds elapsed since the epoch
- * of midnight, 1st Jan 1970 in the UTC time zone.
- * Local time zone information is not sent to flash.
- *
- * - date = 0x08 integer-data [ number-data ]
- *
- * @return Zend_Date
- */
- public function readDate()
- {
- $dateReference = $this->readInteger();
- if (($dateReference & 0x01) == 0) {
- $dateReference = $dateReference >> 1;
- if ($dateReference>=count($this->_referenceObjects)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Undefined date reference: ' . $dateReference);
- }
- return $this->_referenceObjects[$dateReference];
- }
-
- $timestamp = floor($this->_stream->readDouble() / 1000);
-
- require_once 'Zend/Date.php';
- $dateTime = new Zend_Date($timestamp);
- $this->_referenceObjects[] = $dateTime;
- return $dateTime;
- }
-
- /**
- * Read amf array to PHP array
- *
- * - array = 0x09 integer-data ( [ 1OCTET *amf3-data ] | [OCTET *amf3-data 1] | [ OCTET *amf-data ] )
- *
- * @return array
- */
- public function readArray()
- {
- $arrayReference = $this->readInteger();
- if (($arrayReference & 0x01)==0){
- $arrayReference = $arrayReference >> 1;
- if ($arrayReference>=count($this->_referenceObjects)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknow array reference: ' . $arrayReference);
- }
- return $this->_referenceObjects[$arrayReference];
- }
-
- // Create a holder for the array in the reference list
- $data = array();
- $this->_referenceObjects[] =& $data;
- $key = $this->readString();
-
- // Iterating for string based keys.
- while ($key != '') {
- $data[$key] = $this->readTypeMarker();
- $key = $this->readString();
- }
-
- $arrayReference = $arrayReference >>1;
-
- //We have a dense array
- for ($i=0; $i < $arrayReference; $i++) {
- $data[] = $this->readTypeMarker();
- }
-
- return $data;
- }
-
- /**
- * Read an object from the AMF stream and convert it into a PHP object
- *
- * @todo Rather than using an array of traitsInfo create Zend_Amf_Value_TraitsInfo
- * @return object|array
- */
- public function readObject()
- {
- $traitsInfo = $this->readInteger();
- $storedObject = ($traitsInfo & 0x01)==0;
- $traitsInfo = $traitsInfo >> 1;
-
- // Check if the Object is in the stored Objects reference table
- if ($storedObject) {
- $ref = $traitsInfo;
- if (!isset($this->_referenceObjects[$ref])) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Object reference: ' . $ref);
- }
- $returnObject = $this->_referenceObjects[$ref];
- } else {
- // Check if the Object is in the stored Definitions reference table
- $storedClass = ($traitsInfo & 0x01) == 0;
- $traitsInfo = $traitsInfo >> 1;
- if ($storedClass) {
- $ref = $traitsInfo;
- if (!isset($this->_referenceDefinitions[$ref])) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknows Definition reference: '. $ref);
- }
- // Populate the reference attributes
- $className = $this->_referenceDefinitions[$ref]['className'];
- $encoding = $this->_referenceDefinitions[$ref]['encoding'];
- $propertyNames = $this->_referenceDefinitions[$ref]['propertyNames'];
- } else {
- // The class was not in the reference tables. Start reading rawdata to build traits.
- // Create a traits table. Zend_Amf_Value_TraitsInfo would be ideal
- $className = $this->readString();
- $encoding = $traitsInfo & 0x03;
- $propertyNames = array();
- $traitsInfo = $traitsInfo >> 2;
- }
-
- // We now have the object traits defined in variables. Time to go to work:
- if (!$className) {
- // No class name generic object
- $returnObject = new stdClass();
- } else {
- // Defined object
- // Typed object lookup against registered classname maps
- if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
- $returnObject = new $loader();
- } else {
- //user defined typed object
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Typed object not found: '. $className . ' ');
- }
- }
-
- // Add the Object to the reference table
- $this->_referenceObjects[] = $returnObject;
-
- $properties = array(); // clear value
- // Check encoding types for additional processing.
- switch ($encoding) {
- case (Zend_Amf_Constants::ET_EXTERNAL):
- // Externalizable object such as {ArrayCollection} and {ObjectProxy}
- if (!$storedClass) {
- $this->_referenceDefinitions[] = array(
- 'className' => $className,
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
- }
- $returnObject->externalizedData = $this->readTypeMarker();
- break;
- case (Zend_Amf_Constants::ET_DYNAMIC):
- // used for Name-value encoding
- if (!$storedClass) {
- $this->_referenceDefinitions[] = array(
- 'className' => $className,
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
- }
- // not a reference object read name value properties from byte stream
- do {
- $property = $this->readString();
- if ($property != "") {
- $propertyNames[] = $property;
- $properties[$property] = $this->readTypeMarker();
- }
- } while ($property !="");
- break;
- default:
- // basic property list object.
- if (!$storedClass) {
- $count = $traitsInfo; // Number of properties in the list
- for($i=0; $i< $count; $i++) {
- $propertyNames[] = $this->readString();
- }
- // Add a reference to the class.
- $this->_referenceDefinitions[] = array(
- 'className' => $className,
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
- }
- foreach ($propertyNames as $property) {
- $properties[$property] = $this->readTypeMarker();
- }
- break;
- }
-
- // Add properties back to the return object.
- if (!is_array($properties)) $properties = array();
- foreach($properties as $key=>$value) {
- if($key) {
- $returnObject->$key = $value;
- }
- }
-
-
- }
-
- if ($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
- if (isset($returnObject->externalizedData)) {
- $returnObject = $returnObject->externalizedData;
- } else {
- $returnObject = get_object_vars($returnObject);
- }
- }
-
- return $returnObject;
- }
-
- /**
- * Convert XML to SimpleXml
- * If user wants DomDocument they can use dom_import_simplexml
- *
- * @return SimpleXml Object
- */
- public function readXmlString()
- {
- $xmlReference = $this->readInteger();
- $length = $xmlReference >> 1;
- $string = $this->_stream->readBytes($length);
- return Zend_Xml_Security::scan($string);
- }
-}
diff --git a/lib/zend/Zend/Amf/Parse/Amf3/Serializer.php b/lib/zend/Zend/Amf/Parse/Amf3/Serializer.php
deleted file mode 100644
index 3ce47b7f7cb33..0000000000000
--- a/lib/zend/Zend/Amf/Parse/Amf3/Serializer.php
+++ /dev/null
@@ -1,534 +0,0 @@
-_stream->writeByte($markerType);
-
- switch ($markerType) {
- case Zend_Amf_Constants::AMF3_NULL:
- break;
- case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
- break;
- case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
- break;
- case Zend_Amf_Constants::AMF3_INTEGER:
- $this->writeInteger($data);
- break;
- case Zend_Amf_Constants::AMF3_NUMBER:
- $this->_stream->writeDouble($data);
- break;
- case Zend_Amf_Constants::AMF3_STRING:
- $this->writeString($data);
- break;
- case Zend_Amf_Constants::AMF3_DATE:
- $this->writeDate($data);
- break;
- case Zend_Amf_Constants::AMF3_ARRAY:
- $this->writeArray($data);
- break;
- case Zend_Amf_Constants::AMF3_OBJECT:
- $this->writeObject($data);
- break;
- case Zend_Amf_Constants::AMF3_BYTEARRAY:
- $this->writeByteArray($data);
- break;
- case Zend_Amf_Constants::AMF3_XMLSTRING;
- $this->writeXml($data);
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Type Marker: ' . $markerType);
- }
- } else {
- // Detect Type Marker
- if (is_resource($data)) {
- $data = Zend_Amf_Parse_TypeLoader::handleResource($data);
- }
- switch (true) {
- case (null === $data):
- $markerType = Zend_Amf_Constants::AMF3_NULL;
- break;
- case (is_bool($data)):
- if ($data){
- $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
- } else {
- $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
- }
- break;
- case (is_int($data)):
- if (($data > 0xFFFFFFF) || ($data < -268435456)) {
- $markerType = Zend_Amf_Constants::AMF3_NUMBER;
- } else {
- $markerType = Zend_Amf_Constants::AMF3_INTEGER;
- }
- break;
- case (is_float($data)):
- $markerType = Zend_Amf_Constants::AMF3_NUMBER;
- break;
- case (is_string($data)):
- $markerType = Zend_Amf_Constants::AMF3_STRING;
- break;
- case (is_array($data)):
- $markerType = Zend_Amf_Constants::AMF3_ARRAY;
- break;
- case (is_object($data)):
- // Handle object types.
- if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
- $markerType = Zend_Amf_Constants::AMF3_DATE;
- } else if ($data instanceof Zend_Amf_Value_ByteArray) {
- $markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
- } else if (($data instanceof DOMDocument) || ($data instanceof SimpleXMLElement)) {
- $markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
- } else {
- $markerType = Zend_Amf_Constants::AMF3_OBJECT;
- }
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
- }
- $this->writeTypeMarker($data, $markerType);
- }
- }
-
- /**
- * Write an AMF3 integer
- *
- * @param int|float $data
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeInteger($int)
- {
- if (($int & 0xffffff80) == 0) {
- $this->_stream->writeByte($int & 0x7f);
- return $this;
- }
-
- if (($int & 0xffffc000) == 0 ) {
- $this->_stream->writeByte(($int >> 7 ) | 0x80);
- $this->_stream->writeByte($int & 0x7f);
- return $this;
- }
-
- if (($int & 0xffe00000) == 0) {
- $this->_stream->writeByte(($int >> 14 ) | 0x80);
- $this->_stream->writeByte(($int >> 7 ) | 0x80);
- $this->_stream->writeByte($int & 0x7f);
- return $this;
- }
-
- $this->_stream->writeByte(($int >> 22 ) | 0x80);
- $this->_stream->writeByte(($int >> 15 ) | 0x80);
- $this->_stream->writeByte(($int >> 8 ) | 0x80);
- $this->_stream->writeByte($int & 0xff);
- return $this;
- }
-
- /**
- * Send string to output stream, without trying to reference it.
- * The string is prepended with strlen($string) << 1 | 0x01
- *
- * @param string $string
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- protected function writeBinaryString(&$string){
- $ref = ($this->_mbStringFunctionsOverloaded ? mb_strlen($string, '8bit') : strlen($string)) << 1 | 0x01;
- $this->writeInteger($ref);
- $this->_stream->writeBytes($string);
-
- return $this;
- }
-
- /**
- * Send string to output stream
- *
- * @param string $string
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeString(&$string)
- {
- $len = $this->_mbStringFunctionsOverloaded ? mb_strlen($string, '8bit') : strlen($string);
- if(!$len){
- $this->writeInteger(0x01);
- return $this;
- }
-
- $ref = array_key_exists($string, $this->_referenceStrings)
- ? $this->_referenceStrings[$string]
- : false;
- if ($ref === false){
- $this->_referenceStrings[$string] = count($this->_referenceStrings);
- $this->writeBinaryString($string);
- } else {
- $ref <<= 1;
- $this->writeInteger($ref);
- }
-
- return $this;
- }
-
- /**
- * Send ByteArray to output stream
- *
- * @param string|Zend_Amf_Value_ByteArray $data
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeByteArray(&$data)
- {
- if ($this->writeObjectReference($data)) {
- return $this;
- }
-
- if (is_string($data)) {
- //nothing to do
- } else if ($data instanceof Zend_Amf_Value_ByteArray) {
- $data = $data->getData();
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid ByteArray specified; must be a string or Zend_Amf_Value_ByteArray');
- }
-
- $this->writeBinaryString($data);
-
- return $this;
- }
-
- /**
- * Send xml to output stream
- *
- * @param DOMDocument|SimpleXMLElement $xml
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeXml($xml)
- {
- if ($this->writeObjectReference($xml)) {
- return $this;
- }
-
- if(is_string($xml)) {
- //nothing to do
- } else if ($xml instanceof DOMDocument) {
- $xml = $xml->saveXml();
- } else if ($xml instanceof SimpleXMLElement) {
- $xml = $xml->asXML();
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid xml specified; must be a DOMDocument or SimpleXMLElement');
- }
-
- $this->writeBinaryString($xml);
-
- return $this;
- }
-
- /**
- * Convert DateTime/Zend_Date to AMF date
- *
- * @param DateTime|Zend_Date $date
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeDate($date)
- {
- if ($this->writeObjectReference($date)) {
- return $this;
- }
-
- if ($date instanceof DateTime) {
- $dateString = $date->format('U') * 1000;
- } elseif ($date instanceof Zend_Date) {
- $dateString = $date->toString('U') * 1000;
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid date specified; must be a string DateTime or Zend_Date object');
- }
-
- $this->writeInteger(0x01);
- // write time to stream minus milliseconds
- $this->_stream->writeDouble($dateString);
- return $this;
- }
-
- /**
- * Write a PHP array back to the amf output stream
- *
- * @param array $array
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeArray(&$array)
- {
- // arrays aren't reference here but still counted
- $this->_referenceObjects[] = $array;
-
- // have to seperate mixed from numberic keys.
- $numeric = array();
- $string = array();
- foreach ($array as $key => &$value) {
- if (is_int($key)) {
- $numeric[] = $value;
- } else {
- $string[$key] = $value;
- }
- }
-
- // write the preamble id of the array
- $length = count($numeric);
- $id = ($length << 1) | 0x01;
- $this->writeInteger($id);
-
- //Write the mixed type array to the output stream
- foreach($string as $key => &$value) {
- $this->writeString($key)
- ->writeTypeMarker($value);
- }
- $this->writeString($this->_strEmpty);
-
- // Write the numeric array to ouput stream
- foreach($numeric as &$value) {
- $this->writeTypeMarker($value);
- }
- return $this;
- }
-
- /**
- * Check if the given object is in the reference table, write the reference if it exists,
- * otherwise add the object to the reference table
- *
- * @param mixed $object object reference to check for reference
- * @param mixed $objectByVal object to check for reference
- * @return Boolean true, if the reference was written, false otherwise
- */
- protected function writeObjectReference(&$object, $objectByVal = false)
- {
- // Workaround for PHP5 with E_STRICT enabled complaining about "Only
- // variables should be passed by reference"
- if ((null === $object) && ($objectByVal !== false)) {
- $object = &$objectByVal;
- }
-
- $hash = spl_object_hash($object);
- $ref = array_key_exists($hash, $this->_referenceObjects)
- ? $this->_referenceObjects[$hash]
- : false;
-
- // quickly handle object references
- if ($ref !== false){
- $ref <<= 1;
- $this->writeInteger($ref);
- return true;
- }
- $this->_referenceObjects[$hash] = count($this->_referenceObjects);
- return false;
- }
-
- /**
- * Write object to ouput stream
- *
- * @param mixed $data
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeObject($object)
- {
- if($this->writeObjectReference($object)){
- return $this;
- }
-
- $className = '';
-
- //Check to see if the object is a typed object and we need to change
- switch (true) {
- // the return class mapped name back to actionscript class name.
- case ($className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object))):
- break;
-
- // Check to see if the user has defined an explicit Action Script type.
- case isset($object->_explicitType):
- $className = $object->_explicitType;
- break;
-
- // Check if user has defined a method for accessing the Action Script type
- case method_exists($object, 'getASClassName'):
- $className = $object->getASClassName();
- break;
-
- // No return class name is set make it a generic object
- case ($object instanceof stdClass):
- $className = '';
- break;
-
- // By default, use object's class name
- default:
- $className = get_class($object);
- break;
- }
-
- $writeTraits = true;
-
- //check to see, if we have a corresponding definition
- if(array_key_exists($className, $this->_referenceDefinitions)){
- $traitsInfo = $this->_referenceDefinitions[$className]['id'];
- $encoding = $this->_referenceDefinitions[$className]['encoding'];
- $propertyNames = $this->_referenceDefinitions[$className]['propertyNames'];
-
- $traitsInfo = ($traitsInfo << 2) | 0x01;
-
- $writeTraits = false;
- } else {
- $propertyNames = array();
-
- if($className == ''){
- //if there is no className, we interpret the class as dynamic without any sealed members
- $encoding = Zend_Amf_Constants::ET_DYNAMIC;
- } else {
- $encoding = Zend_Amf_Constants::ET_PROPLIST;
-
- foreach($object as $key => $value) {
- if( $key[0] != "_") {
- $propertyNames[] = $key;
- }
- }
- }
-
- $this->_referenceDefinitions[$className] = array(
- 'id' => count($this->_referenceDefinitions),
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
-
- $traitsInfo = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
- $traitsInfo |= $encoding << 2;
- $traitsInfo |= (count($propertyNames) << 4);
- }
-
- $this->writeInteger($traitsInfo);
-
- if($writeTraits){
- $this->writeString($className);
- foreach ($propertyNames as $value) {
- $this->writeString($value);
- }
- }
-
- try {
- switch($encoding) {
- case Zend_Amf_Constants::ET_PROPLIST:
- //Write the sealed values to the output stream.
- foreach ($propertyNames as $key) {
- $this->writeTypeMarker($object->$key);
- }
- break;
- case Zend_Amf_Constants::ET_DYNAMIC:
- //Write the sealed values to the output stream.
- foreach ($propertyNames as $key) {
- $this->writeTypeMarker($object->$key);
- }
-
- //Write remaining properties
- foreach($object as $key => $value){
- if(!in_array($key,$propertyNames) && $key[0] != "_"){
- $this->writeString($key);
- $this->writeTypeMarker($value);
- }
- }
-
- //Write an empty string to end the dynamic part
- $this->writeString($this->_strEmpty);
- break;
- case Zend_Amf_Constants::ET_EXTERNAL:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('External Object Encoding not implemented');
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding);
- }
- } catch (Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage(), 0, $e);
- }
-
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Amf/Parse/Deserializer.php b/lib/zend/Zend/Amf/Parse/Deserializer.php
deleted file mode 100644
index e6d4b1a853d3b..0000000000000
--- a/lib/zend/Zend/Amf/Parse/Deserializer.php
+++ /dev/null
@@ -1,65 +0,0 @@
-_stream = $stream;
- }
-
- /**
- * Checks for AMF marker types and calls the appropriate methods
- * for deserializing those marker types. Markers are the data type of
- * the following value.
- *
- * @param int $typeMarker
- * @return mixed Whatever the data type is of the marker in php
- */
- public abstract function readTypeMarker($markerType = null);
-}
diff --git a/lib/zend/Zend/Amf/Parse/InputStream.php b/lib/zend/Zend/Amf/Parse/InputStream.php
deleted file mode 100644
index 25929651549f5..0000000000000
--- a/lib/zend/Zend/Amf/Parse/InputStream.php
+++ /dev/null
@@ -1,39 +0,0 @@
- Value is Mysql type (exact string) => PHP type
- */
- static public $fieldTypes = array(
- "int" => "int",
- "timestamp" => "int",
- "year" => "int",
- "real" => "float",
- );
- /**
- * Parse resource into array
- *
- * @param resource $resource
- * @return array
- */
- public function parse($resource) {
- $result = array();
- $fieldcnt = mysql_num_fields($resource);
- $fields_transform = array();
- for($i=0;$i<$fieldcnt;$i++) {
- $type = mysql_field_type($resource, $i);
- if(isset(self::$fieldTypes[$type])) {
- $fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type];
- }
- }
-
- while($row = mysql_fetch_object($resource)) {
- foreach($fields_transform as $fieldname => $fieldtype) {
- settype($row->$fieldname, $fieldtype);
- }
- $result[] = $row;
- }
- return $result;
- }
-}
diff --git a/lib/zend/Zend/Amf/Parse/Resource/MysqliResult.php b/lib/zend/Zend/Amf/Parse/Resource/MysqliResult.php
deleted file mode 100644
index 45f53d4b73dae..0000000000000
--- a/lib/zend/Zend/Amf/Parse/Resource/MysqliResult.php
+++ /dev/null
@@ -1,128 +0,0 @@
- "MYSQLI_TYPE_DECIMAL",
- 1 => "MYSQLI_TYPE_TINYINT",
- 2 => "MYSQLI_TYPE_SMALLINT",
- 3 => "MYSQLI_TYPE_INTEGER",
- 4 => "MYSQLI_TYPE_FLOAT",
- 5 => "MYSQLI_TYPE_DOUBLE",
- 7 => "MYSQLI_TYPE_TIMESTAMP",
- 8 => "MYSQLI_TYPE_BIGINT",
- 9 => "MYSQLI_TYPE_MEDIUMINT",
- 10 => "MYSQLI_TYPE_DATE",
- 11 => "MYSQLI_TYPE_TIME",
- 12 => "MYSQLI_TYPE_DATETIME",
- 13 => "MYSQLI_TYPE_YEAR",
- 14 => "MYSQLI_TYPE_DATE",
- 16 => "MYSQLI_TYPE_BIT",
- 246 => "MYSQLI_TYPE_DECIMAL",
- 247 => "MYSQLI_TYPE_ENUM",
- 248 => "MYSQLI_TYPE_SET",
- 249 => "MYSQLI_TYPE_TINYBLOB",
- 250 => "MYSQLI_TYPE_MEDIUMBLOB",
- 251 => "MYSQLI_TYPE_LONGBLOB",
- 252 => "MYSQLI_TYPE_BLOB",
- 253 => "MYSQLI_TYPE_VARCHAR",
- 254 => "MYSQLI_TYPE_CHAR",
- 255 => "MYSQLI_TYPE_GEOMETRY",
- );
-
- // Build an associative array for a type look up
- static $mysqli_to_php = array(
- "MYSQLI_TYPE_DECIMAL" => 'float',
- "MYSQLI_TYPE_NEWDECIMAL" => 'float',
- "MYSQLI_TYPE_BIT" => 'integer',
- "MYSQLI_TYPE_TINYINT" => 'integer',
- "MYSQLI_TYPE_SMALLINT" => 'integer',
- "MYSQLI_TYPE_MEDIUMINT" => 'integer',
- "MYSQLI_TYPE_BIGINT" => 'integer',
- "MYSQLI_TYPE_INTEGER" => 'integer',
- "MYSQLI_TYPE_FLOAT" => 'float',
- "MYSQLI_TYPE_DOUBLE" => 'float',
- "MYSQLI_TYPE_NULL" => 'null',
- "MYSQLI_TYPE_TIMESTAMP" => 'string',
- "MYSQLI_TYPE_INT24" => 'integer',
- "MYSQLI_TYPE_DATE" => 'string',
- "MYSQLI_TYPE_TIME" => 'string',
- "MYSQLI_TYPE_DATETIME" => 'string',
- "MYSQLI_TYPE_YEAR" => 'string',
- "MYSQLI_TYPE_NEWDATE" => 'string',
- "MYSQLI_TYPE_ENUM" => 'string',
- "MYSQLI_TYPE_SET" => 'string',
- "MYSQLI_TYPE_TINYBLOB" => 'object',
- "MYSQLI_TYPE_MEDIUMBLOB" => 'object',
- "MYSQLI_TYPE_LONGBLOB" => 'object',
- "MYSQLI_TYPE_BLOB" => 'object',
- "MYSQLI_TYPE_CHAR" => 'string',
- "MYSQLI_TYPE_VARCHAR" => 'string',
- "MYSQLI_TYPE_GEOMETRY" => 'object',
- "MYSQLI_TYPE_BIT" => 'integer',
- );
-
- /**
- * Parse resource into array
- *
- * @param resource $resource
- * @return array
- */
- public function parse($resource) {
-
- $result = array();
- $fieldcnt = mysqli_num_fields($resource);
-
-
- $fields_transform = array();
-
- for($i=0;$i<$fieldcnt;$i++) {
- $finfo = mysqli_fetch_field_direct($resource, $i);
-
- if(isset(self::$mysqli_type[$finfo->type])) {
- $fields_transform[$finfo->name] = self::$mysqli_to_php[self::$mysqli_type[$finfo->type]];
- }
- }
-
- while($row = mysqli_fetch_assoc($resource)) {
- foreach($fields_transform as $fieldname => $fieldtype) {
- settype($row[$fieldname], $fieldtype);
- }
- $result[] = $row;
- }
- return $result;
- }
-}
diff --git a/lib/zend/Zend/Amf/Parse/Resource/Stream.php b/lib/zend/Zend/Amf/Parse/Resource/Stream.php
deleted file mode 100644
index b8afa148ac2bb..0000000000000
--- a/lib/zend/Zend/Amf/Parse/Resource/Stream.php
+++ /dev/null
@@ -1,42 +0,0 @@
-_stream = $stream;
- $this->_mbStringFunctionsOverloaded = function_exists('mb_strlen') && (ini_get('mbstring.func_overload') !== '') && ((int)ini_get('mbstring.func_overload') & 2);
- }
-
- /**
- * Find the PHP object type and convert it into an AMF object type
- *
- * @param mixed $content
- * @param int $markerType
- * @param mixed $contentByVal
- * @return void
- */
- public abstract function writeTypeMarker(&$content, $markerType = null, $contentByVal = false);
-}
diff --git a/lib/zend/Zend/Amf/Parse/TypeLoader.php b/lib/zend/Zend/Amf/Parse/TypeLoader.php
deleted file mode 100644
index 05c8db42f9299..0000000000000
--- a/lib/zend/Zend/Amf/Parse/TypeLoader.php
+++ /dev/null
@@ -1,231 +0,0 @@
- 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
- 'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
- 'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
- 'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
- );
-
- /**
- * @var array Default class map
- */
- protected static $_defaultClassMap = array(
- 'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
- 'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
- 'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
- 'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
- );
-
- /**
- * @var Zend_Loader_PluginLoader_Interface
- */
- protected static $_resourceLoader = null;
-
-
- /**
- * Load the mapped class type into a callback.
- *
- * @param string $className
- * @return object|false
- */
- public static function loadType($className)
- {
- $class = self::getMappedClassName($className);
- if(!$class) {
- $class = str_replace('.', '_', $className);
- }
- if (!class_exists($class)) {
- return "stdClass";
- }
- return $class;
- }
-
- /**
- * Looks up the supplied call name to its mapped class name
- *
- * @param string $className
- * @return string
- */
- public static function getMappedClassName($className)
- {
- $mappedName = array_search($className, self::$classMap);
-
- if ($mappedName) {
- return $mappedName;
- }
-
- $mappedName = array_search($className, array_flip(self::$classMap));
-
- if ($mappedName) {
- return $mappedName;
- }
-
- return false;
- }
-
- /**
- * Map PHP class names to ActionScript class names
- *
- * Allows users to map the class names of there action script classes
- * to the equivelent php class name. Used in deserialization to load a class
- * and serialiation to set the class name of the returned object.
- *
- * @param string $asClassName
- * @param string $phpClassName
- * @return void
- */
- public static function setMapping($asClassName, $phpClassName)
- {
- self::$classMap[$asClassName] = $phpClassName;
- }
-
- /**
- * Reset type map
- *
- * @return void
- */
- public static function resetMap()
- {
- self::$classMap = self::$_defaultClassMap;
- }
-
- /**
- * Set loader for resource type handlers
- *
- * @param Zend_Loader_PluginLoader_Interface $loader
- */
- public static function setResourceLoader(Zend_Loader_PluginLoader_Interface $loader)
- {
- self::$_resourceLoader = $loader;
- }
-
- /**
- * Add directory to the list of places where to look for resource handlers
- *
- * @param string $prefix
- * @param string $dir
- */
- public static function addResourceDirectory($prefix, $dir)
- {
- if(self::$_resourceLoader) {
- self::$_resourceLoader->addPrefixPath($prefix, $dir);
- }
- }
-
- /**
- * Get plugin class that handles this resource
- *
- * @param resource $resource Resource type
- * @return string Class name
- */
- public static function getResourceParser($resource)
- {
- if(self::$_resourceLoader) {
- $type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
- $type = str_replace(" ","", ucwords($type));
- return self::$_resourceLoader->load($type);
- }
- return false;
- }
-
- /**
- * Convert resource to a serializable object
- *
- * @param resource $resource
- * @return mixed
- */
- public static function handleResource($resource)
- {
- if(!self::$_resourceLoader) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to handle resources - resource plugin loader not set');
- }
- try {
- while(is_resource($resource)) {
- $resclass = self::getResourceParser($resource);
- if(!$resclass) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
- }
- $parser = new $resclass();
- if(is_callable(array($parser, 'parse'))) {
- $resource = $parser->parse($resource);
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception("Could not call parse() method on class $resclass");
- }
- }
- return $resource;
- } catch(Zend_Amf_Exception $e) {
- throw new Zend_Amf_Exception($e->getMessage(), $e->getCode(), $e);
- } catch(Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource), 0, $e);
- }
- }
-}
diff --git a/lib/zend/Zend/Amf/Request.php b/lib/zend/Zend/Amf/Request.php
deleted file mode 100644
index c5da936ef0549..0000000000000
--- a/lib/zend/Zend/Amf/Request.php
+++ /dev/null
@@ -1,251 +0,0 @@
-_inputStream = new Zend_Amf_Parse_InputStream($request);
- $this->_deserializer = new Zend_Amf_Parse_Amf0_Deserializer($this->_inputStream);
- $this->readMessage($this->_inputStream);
- return $this;
- }
-
- /**
- * Takes the raw AMF input stream and converts it into valid PHP objects
- *
- * @param Zend_Amf_Parse_InputStream
- * @return Zend_Amf_Request
- */
- public function readMessage(Zend_Amf_Parse_InputStream $stream)
- {
- $clientVersion = $stream->readUnsignedShort();
- if (($clientVersion != Zend_Amf_Constants::AMF0_OBJECT_ENCODING)
- && ($clientVersion != Zend_Amf_Constants::AMF3_OBJECT_ENCODING)
- && ($clientVersion != Zend_Amf_Constants::FMS_OBJECT_ENCODING)
- ) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Player Version ' . $clientVersion);
- }
-
- $this->_bodies = array();
- $this->_headers = array();
- $headerCount = $stream->readInt();
-
- // Iterate through the AMF envelope header
- while ($headerCount--) {
- $this->_headers[] = $this->readHeader();
- }
-
- // Iterate through the AMF envelope body
- $bodyCount = $stream->readInt();
- while ($bodyCount--) {
- $this->_bodies[] = $this->readBody();
- }
-
- return $this;
- }
-
- /**
- * Deserialize a message header from the input stream.
- *
- * A message header is structured as:
- * - NAME String
- * - MUST UNDERSTAND Boolean
- * - LENGTH Int
- * - DATA Object
- *
- * @return Zend_Amf_Value_MessageHeader
- */
- public function readHeader()
- {
- $name = $this->_inputStream->readUTF();
- $mustRead = (bool)$this->_inputStream->readByte();
- $length = $this->_inputStream->readLong();
-
- try {
- $data = $this->_deserializer->readTypeMarker();
- } catch (Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to parse ' . $name . ' header data: ' . $e->getMessage() . ' '. $e->getLine(), 0, $e);
- }
-
- $header = new Zend_Amf_Value_MessageHeader($name, $mustRead, $data, $length);
- return $header;
- }
-
- /**
- * Deserialize a message body from the input stream
- *
- * @return Zend_Amf_Value_MessageBody
- */
- public function readBody()
- {
- $targetURI = $this->_inputStream->readUTF();
- $responseURI = $this->_inputStream->readUTF();
- $length = $this->_inputStream->readLong();
-
- try {
- $data = $this->_deserializer->readTypeMarker();
- } catch (Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to parse ' . $targetURI . ' body data ' . $e->getMessage(), 0, $e);
- }
-
- // Check for AMF3 objectEncoding
- if ($this->_deserializer->getObjectEncoding() == Zend_Amf_Constants::AMF3_OBJECT_ENCODING) {
- /*
- * When and AMF3 message is sent to the server it is nested inside
- * an AMF0 array called Content. The following code gets the object
- * out of the content array and sets it as the message data.
- */
- if(is_array($data) && $data[0] instanceof Zend_Amf_Value_Messaging_AbstractMessage){
- $data = $data[0];
- }
-
- // set the encoding so we return our message in AMF3
- $this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
- }
-
- $body = new Zend_Amf_Value_MessageBody($targetURI, $responseURI, $data);
- return $body;
- }
-
- /**
- * Return an array of the body objects that were found in the amf request.
- *
- * @return array {target, response, length, content}
- */
- public function getAmfBodies()
- {
- return $this->_bodies;
- }
-
- /**
- * Accessor to private array of message bodies.
- *
- * @param Zend_Amf_Value_MessageBody $message
- * @return Zend_Amf_Request
- */
- public function addAmfBody(Zend_Amf_Value_MessageBody $message)
- {
- $this->_bodies[] = $message;
- return $this;
- }
-
- /**
- * Return an array of headers that were found in the amf request.
- *
- * @return array {operation, mustUnderstand, length, param}
- */
- public function getAmfHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Return the either 0 or 3 for respect AMF version
- *
- * @return int
- */
- public function getObjectEncoding()
- {
- return $this->_objectEncoding;
- }
-
- /**
- * Set the object response encoding
- *
- * @param mixed $int
- * @return Zend_Amf_Request
- */
- public function setObjectEncoding($int)
- {
- $this->_objectEncoding = $int;
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Amf/Request/Http.php b/lib/zend/Zend/Amf/Request/Http.php
deleted file mode 100644
index e5675058e9578..0000000000000
--- a/lib/zend/Zend/Amf/Request/Http.php
+++ /dev/null
@@ -1,80 +0,0 @@
-_rawRequest = $amfRequest;
- $this->initialize($amfRequest);
- } else {
- echo 'Zend Amf Endpoint
' ;
- }
- }
-
- /**
- * Retrieve raw AMF Request
- *
- * @return string
- */
- public function getRawRequest()
- {
- return $this->_rawRequest;
- }
-}
diff --git a/lib/zend/Zend/Amf/Response.php b/lib/zend/Zend/Amf/Response.php
deleted file mode 100644
index 00e75010566ad..0000000000000
--- a/lib/zend/Zend/Amf/Response.php
+++ /dev/null
@@ -1,205 +0,0 @@
-_outputStream = new Zend_Amf_Parse_OutputStream();
- $this->writeMessage($this->_outputStream);
- return $this;
- }
-
- /**
- * Serialize the PHP data types back into Actionscript and
- * create and AMF stream.
- *
- * @param Zend_Amf_Parse_OutputStream $stream
- * @return Zend_Amf_Response
- */
- public function writeMessage(Zend_Amf_Parse_OutputStream $stream)
- {
- $objectEncoding = $this->_objectEncoding;
-
- //Write encoding to start of stream. Preamble byte is written of two byte Unsigned Short
- $stream->writeByte(0x00);
- $stream->writeByte($objectEncoding);
-
- // Loop through the AMF Headers that need to be returned.
- $headerCount = count($this->_headers);
- $stream->writeInt($headerCount);
- foreach ($this->getAmfHeaders() as $header) {
- $serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
- $stream->writeUTF($header->name);
- $stream->writeByte($header->mustRead);
- $stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
- if (is_object($header->data)) {
- // Workaround for PHP5 with E_STRICT enabled complaining about
- // "Only variables should be passed by reference"
- $placeholder = null;
- $serializer->writeTypeMarker($placeholder, null, $header->data);
- } else {
- $serializer->writeTypeMarker($header->data);
- }
- }
-
- // loop through the AMF bodies that need to be returned.
- $bodyCount = count($this->_bodies);
- $stream->writeInt($bodyCount);
- foreach ($this->_bodies as $body) {
- $serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
- $stream->writeUTF($body->getTargetURI());
- $stream->writeUTF($body->getResponseURI());
- $stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
- $bodyData = $body->getData();
- $markerType = ($this->_objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) ? null : Zend_Amf_Constants::AMF0_AMF3;
- if (is_object($bodyData)) {
- // Workaround for PHP5 with E_STRICT enabled complaining about
- // "Only variables should be passed by reference"
- $placeholder = null;
- $serializer->writeTypeMarker($placeholder, $markerType, $bodyData);
- } else {
- $serializer->writeTypeMarker($bodyData, $markerType);
- }
- }
-
- return $this;
- }
-
- /**
- * Return the output stream content
- *
- * @return string The contents of the output stream
- */
- public function getResponse()
- {
- return $this->_outputStream->getStream();
- }
-
- /**
- * Return the output stream content
- *
- * @return string
- */
- public function __toString()
- {
- return $this->getResponse();
- }
-
- /**
- * Add an AMF body to be sent to the Flash Player
- *
- * @param Zend_Amf_Value_MessageBody $body
- * @return Zend_Amf_Response
- */
- public function addAmfBody(Zend_Amf_Value_MessageBody $body)
- {
- $this->_bodies[] = $body;
- return $this;
- }
-
- /**
- * Return an array of AMF bodies to be serialized
- *
- * @return array
- */
- public function getAmfBodies()
- {
- return $this->_bodies;
- }
-
- /**
- * Add an AMF Header to be sent back to the flash player
- *
- * @param Zend_Amf_Value_MessageHeader $header
- * @return Zend_Amf_Response
- */
- public function addAmfHeader(Zend_Amf_Value_MessageHeader $header)
- {
- $this->_headers[] = $header;
- return $this;
- }
-
- /**
- * Retrieve attached AMF message headers
- *
- * @return array Array of Zend_Amf_Value_MessageHeader objects
- */
- public function getAmfHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Set the AMF encoding that will be used for serialization
- *
- * @param int $encoding
- * @return Zend_Amf_Response
- */
- public function setObjectEncoding($encoding)
- {
- $this->_objectEncoding = $encoding;
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Amf/Response/Http.php b/lib/zend/Zend/Amf/Response/Http.php
deleted file mode 100644
index 4182f6aa8ad05..0000000000000
--- a/lib/zend/Zend/Amf/Response/Http.php
+++ /dev/null
@@ -1,73 +0,0 @@
-isIeOverSsl()) {
- header('Cache-Control: cache, must-revalidate');
- header('Pragma: public');
- } else {
- header('Cache-Control: no-cache, must-revalidate');
- header('Pragma: no-cache');
- }
- header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
- header('Content-Type: application/x-amf');
- }
- return parent::getResponse();
- }
-
- protected function isIeOverSsl()
- {
- $ssl = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : false;
- if (!$ssl || ($ssl == 'off')) {
- // IIS reports "off", whereas other browsers simply don't populate
- return false;
- }
-
- $ua = $_SERVER['HTTP_USER_AGENT'];
- if (!preg_match('/; MSIE \d+\.\d+;/', $ua)) {
- // Not MicroSoft Internet Explorer
- return false;
- }
-
- return true;
- }
-}
diff --git a/lib/zend/Zend/Amf/Server.php b/lib/zend/Zend/Amf/Server.php
deleted file mode 100644
index 0f87286031d44..0000000000000
--- a/lib/zend/Zend/Amf/Server.php
+++ /dev/null
@@ -1,1048 +0,0 @@
- method pairs
- * @var array
- */
- protected $_table = array();
-
- /**
- *
- * @var bool session flag; whether or not to add a session to each response.
- */
- protected $_session = false;
-
- /**
- * Namespace allows all AMF calls to not clobber other PHP session variables
- * @var Zend_Session_NameSpace default session namespace zend_amf
- */
- protected $_sesionNamespace = 'zend_amf';
-
- /**
- * Set the default session.name if php_
- * @var string
- */
- protected $_sessionName = 'PHPSESSID';
-
- /**
- * Authentication handler object
- *
- * @var Zend_Amf_Auth_Abstract
- */
- protected $_auth;
- /**
- * ACL handler object
- *
- * @var Zend_Acl
- */
- protected $_acl;
- /**
- * The server constructor
- */
- public function __construct()
- {
- Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Loader_PluginLoader(array("Zend_Amf_Parse_Resource" => "Zend/Amf/Parse/Resource")));
- }
-
- /**
- * Set authentication adapter
- *
- * If the authentication adapter implements a "getAcl()" method, populate
- * the ACL of this instance with it (if none exists already).
- *
- * @param Zend_Amf_Auth_Abstract $auth
- * @return Zend_Amf_Server
- */
- public function setAuth(Zend_Amf_Auth_Abstract $auth)
- {
- $this->_auth = $auth;
- if ((null === $this->getAcl()) && method_exists($auth, 'getAcl')) {
- $this->setAcl($auth->getAcl());
- }
- return $this;
- }
- /**
- * Get authentication adapter
- *
- * @return Zend_Amf_Auth_Abstract
- */
- public function getAuth()
- {
- return $this->_auth;
- }
-
- /**
- * Set ACL adapter
- *
- * @param Zend_Acl $acl
- * @return Zend_Amf_Server
- */
- public function setAcl(Zend_Acl $acl)
- {
- $this->_acl = $acl;
- return $this;
- }
- /**
- * Get ACL adapter
- *
- * @return Zend_Acl
- */
- public function getAcl()
- {
- return $this->_acl;
- }
-
- /**
- * Set production flag
- *
- * @param bool $flag
- * @return Zend_Amf_Server
- */
- public function setProduction($flag)
- {
- $this->_production = (bool) $flag;
- return $this;
- }
-
- /**
- * Whether or not the server is in production
- *
- * @return bool
- */
- public function isProduction()
- {
- return $this->_production;
- }
-
- /**
- * @param namespace of all incoming sessions defaults to Zend_Amf
- * @return Zend_Amf_Server
- */
- public function setSession($namespace = 'Zend_Amf')
- {
- require_once 'Zend/Session.php';
- $this->_session = true;
- $this->_sesionNamespace = new Zend_Session_Namespace($namespace);
- return $this;
- }
-
- /**
- * Whether of not the server is using sessions
- * @return bool
- */
- public function isSession()
- {
- return $this->_session;
- }
-
- /**
- * Check if the ACL allows accessing the function or method
- *
- * @param string|object $object Object or class being accessed
- * @param string $function Function or method being accessed
- * @return unknown_type
- */
- protected function _checkAcl($object, $function)
- {
- if(!$this->_acl) {
- return true;
- }
- if($object) {
- $class = is_object($object)?get_class($object):$object;
- if(!$this->_acl->has($class)) {
- require_once 'Zend/Acl/Resource.php';
- $this->_acl->add(new Zend_Acl_Resource($class));
- }
- $call = array($object, "initAcl");
- if(is_callable($call) && !call_user_func($call, $this->_acl)) {
- // if initAcl returns false, no ACL check
- return true;
- }
- } else {
- $class = null;
- }
-
- $auth = Zend_Auth::getInstance();
- if($auth->hasIdentity()) {
- $role = $auth->getIdentity()->role;
- } else {
- if($this->_acl->hasRole(Zend_Amf_Constants::GUEST_ROLE)) {
- $role = Zend_Amf_Constants::GUEST_ROLE;
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception("Unauthenticated access not allowed");
- }
- }
- if($this->_acl->isAllowed($role, $class, $function)) {
- return true;
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception("Access not allowed");
- }
- }
-
- /**
- * Get PluginLoader for the Server
- *
- * @return Zend_Loader_PluginLoader
- */
- protected function getLoader()
- {
- if(empty($this->_loader)) {
- require_once 'Zend/Loader/PluginLoader.php';
- $this->_loader = new Zend_Loader_PluginLoader();
- }
- return $this->_loader;
- }
-
- /**
- * Loads a remote class or method and executes the function and returns
- * the result
- *
- * @param string $method Is the method to execute
- * @param mixed $param values for the method
- * @return mixed $response the result of executing the method
- * @throws Zend_Amf_Server_Exception
- */
- protected function _dispatch($method, $params = null, $source = null)
- {
- if($source) {
- if(($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
- $source = $mapped;
- }
- }
- $qualifiedName = empty($source) ? $method : $source . '.' . $method;
-
- if (!isset($this->_table[$qualifiedName])) {
- // if source is null a method that was not defined was called.
- if ($source) {
- $className = str_replace('.', '_', $source);
- if(class_exists($className, false) && !isset($this->_classAllowed[$className])) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Can not call "' . $className . '" - use setClass()');
- }
- try {
- $this->getLoader()->load($className);
- } catch (Exception $e) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist: '.$e->getMessage(), 0, $e);
- }
- // Add the new loaded class to the server.
- require_once 'Zend/Amf/Server/Exception.php';
- $this->setClass($className, $source);
- }
-
- if (!isset($this->_table[$qualifiedName])) {
- // Source is null or doesn't contain specified method
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Method "' . $method . '" does not exist');
- }
- }
-
- $info = $this->_table[$qualifiedName];
- $argv = $info->getInvokeArguments();
-
- if (0 < count($argv)) {
- $params = array_merge($params, $argv);
- }
-
- $params = $this->_castParameters($info, $params);
-
- if ($info instanceof Zend_Server_Reflection_Function) {
- $func = $info->getName();
- $this->_checkAcl(null, $func);
- $return = call_user_func_array($func, $params);
- } elseif ($info instanceof Zend_Server_Reflection_Method) {
- // Get class
- $class = $info->getDeclaringClass()->getName();
- if ('static' == $info->isStatic()) {
- // for some reason, invokeArgs() does not work the same as
- // invoke(), and expects the first argument to be an object.
- // So, using a callback if the method is static.
- $this->_checkAcl($class, $info->getName());
- $return = call_user_func_array(array($class, $info->getName()), $params);
- } else {
- // Object methods
- try {
- $object = $info->getDeclaringClass()->newInstance();
- } catch (Exception $e) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName() . ': '.$e->getMessage(), 621, $e);
- }
- $this->_checkAcl($object, $info->getName());
- $return = $info->invokeArgs($object, $params);
- }
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Method missing implementation ' . get_class($info));
- }
-
- return $return;
- }
-
- /**
- * Handles each of the 11 different command message types.
- *
- * A command message is a flex.messaging.messages.CommandMessage
- *
- * @see Zend_Amf_Value_Messaging_CommandMessage
- * @param Zend_Amf_Value_Messaging_CommandMessage $message
- * @return Zend_Amf_Value_Messaging_AcknowledgeMessage
- */
- protected function _loadCommandMessage(Zend_Amf_Value_Messaging_CommandMessage $message)
- {
- require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
- switch($message->operation) {
- case Zend_Amf_Value_Messaging_CommandMessage::DISCONNECT_OPERATION :
- case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- break;
- case Zend_Amf_Value_Messaging_CommandMessage::LOGIN_OPERATION :
- $data = explode(':', base64_decode($message->body));
- $userid = $data[0];
- $password = isset($data[1])?$data[1]:"";
- if(empty($userid)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Login failed: username not supplied');
- }
- if(!$this->_handleAuth($userid, $password)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Authentication failed');
- }
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- break;
- case Zend_Amf_Value_Messaging_CommandMessage::LOGOUT_OPERATION :
- if($this->_auth) {
- Zend_Auth::getInstance()->clearIdentity();
- }
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- break;
- default :
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('CommandMessage::' . $message->operation . ' not implemented');
- break;
- }
- return $return;
- }
-
- /**
- * Create appropriate error message
- *
- * @param int $objectEncoding Current AMF encoding
- * @param string $message Message that was being processed when error happened
- * @param string $description Error description
- * @param mixed $detail Detailed data about the error
- * @param int $code Error code
- * @param int $line Error line
- * @return Zend_Amf_Value_Messaging_ErrorMessage|array
- */
- protected function _errorMessage($objectEncoding, $message, $description, $detail, $code, $line)
- {
- $return = null;
- switch ($objectEncoding) {
- case Zend_Amf_Constants::AMF0_OBJECT_ENCODING :
- return array (
- 'description' => ($this->isProduction ()) ? '' : $description,
- 'detail' => ($this->isProduction ()) ? '' : $detail,
- 'line' => ($this->isProduction ()) ? 0 : $line,
- 'code' => $code
- );
- case Zend_Amf_Constants::AMF3_OBJECT_ENCODING :
- require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
- $return = new Zend_Amf_Value_Messaging_ErrorMessage ( $message );
- $return->faultString = $this->isProduction () ? '' : $description;
- $return->faultCode = $code;
- $return->faultDetail = $this->isProduction () ? '' : $detail;
- break;
- }
- return $return;
- }
-
- /**
- * Handle AMF authentication
- *
- * @param string $userid
- * @param string $password
- * @return boolean
- */
- protected function _handleAuth( $userid, $password)
- {
- if (!$this->_auth) {
- return true;
- }
- $this->_auth->setCredentials($userid, $password);
- $auth = Zend_Auth::getInstance();
- $result = $auth->authenticate($this->_auth);
- if ($result->isValid()) {
- if (!$this->isSession()) {
- $this->setSession();
- }
- return true;
- } else {
- // authentication failed, good bye
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception(
- "Authentication failed: " . join("\n",
- $result->getMessages()), $result->getCode());
- }
-
- }
-
- /**
- * Takes the deserialized AMF request and performs any operations.
- *
- * @todo should implement and SPL observer pattern for custom AMF headers
- * @todo DescribeService support
- * @param Zend_Amf_Request $request
- * @return Zend_Amf_Response
- * @throws Zend_Amf_server_Exception|Exception
- */
- protected function _handle(Zend_Amf_Request $request)
- {
- // Get the object encoding of the request.
- $objectEncoding = $request->getObjectEncoding();
-
- // create a response object to place the output from the services.
- $response = $this->getResponse();
-
- // set response encoding
- $response->setObjectEncoding($objectEncoding);
-
- // Authenticate, if we have credential headers
- $error = false;
- $headers = $request->getAmfHeaders();
- if (isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER])
- && isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid)
- && isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password)
- ) {
- try {
- if ($this->_handleAuth(
- $headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid,
- $headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password
- )) {
- // use RequestPersistentHeader to clear credentials
- $response->addAmfHeader(
- new Zend_Amf_Value_MessageHeader(
- Zend_Amf_Constants::PERSISTENT_HEADER,
- false,
- new Zend_Amf_Value_MessageHeader(
- Zend_Amf_Constants::CREDENTIALS_HEADER,
- false, null
- )
- )
- );
- }
- } catch (Exception $e) {
- // Error during authentication; report it
- $error = $this->_errorMessage(
- $objectEncoding,
- '',
- $e->getMessage(),
- $e->getTraceAsString(),
- $e->getCode(),
- $e->getLine()
- );
- $responseType = Zend_AMF_Constants::STATUS_METHOD;
- }
- }
-
- // Iterate through each of the service calls in the AMF request
- foreach($request->getAmfBodies() as $body)
- {
- if ($error) {
- // Error during authentication; just report it and be done
- $responseURI = $body->getResponseURI() . $responseType;
- $newBody = new Zend_Amf_Value_MessageBody($responseURI, null, $error);
- $response->addAmfBody($newBody);
- continue;
- }
- try {
- switch ($objectEncoding) {
- case Zend_Amf_Constants::AMF0_OBJECT_ENCODING:
- // AMF0 Object Encoding
- $targetURI = $body->getTargetURI();
- $message = '';
-
- // Split the target string into its values.
- $source = substr($targetURI, 0, strrpos($targetURI, '.'));
-
- if ($source) {
- // Break off method name from namespace into source
- $method = substr(strrchr($targetURI, '.'), 1);
- $return = $this->_dispatch($method, $body->getData(), $source);
- } else {
- // Just have a method name.
- $return = $this->_dispatch($targetURI, $body->getData());
- }
- break;
- case Zend_Amf_Constants::AMF3_OBJECT_ENCODING:
- default:
- // AMF3 read message type
- $message = $body->getData();
- if ($message instanceof Zend_Amf_Value_Messaging_CommandMessage) {
- // async call with command message
- $return = $this->_loadCommandMessage($message);
- } elseif ($message instanceof Zend_Amf_Value_Messaging_RemotingMessage) {
- require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- $return->body = $this->_dispatch($message->operation, $message->body, $message->source);
- } else {
- // Amf3 message sent with netConnection
- $targetURI = $body->getTargetURI();
-
- // Split the target string into its values.
- $source = substr($targetURI, 0, strrpos($targetURI, '.'));
-
- if ($source) {
- // Break off method name from namespace into source
- $method = substr(strrchr($targetURI, '.'), 1);
- $return = $this->_dispatch($method, $body->getData(), $source);
- } else {
- // Just have a method name.
- $return = $this->_dispatch($targetURI, $body->getData());
- }
- }
- break;
- }
- $responseType = Zend_AMF_Constants::RESULT_METHOD;
- } catch (Exception $e) {
- $return = $this->_errorMessage($objectEncoding, $message,
- $e->getMessage(), $e->getTraceAsString(),$e->getCode(), $e->getLine());
- $responseType = Zend_AMF_Constants::STATUS_METHOD;
- }
-
- $responseURI = $body->getResponseURI() . $responseType;
- $newBody = new Zend_Amf_Value_MessageBody($responseURI, null, $return);
- $response->addAmfBody($newBody);
- }
- // Add a session header to the body if session is requested.
- if($this->isSession()) {
- $currentID = session_id();
- $joint = "?";
- if(isset($_SERVER['QUERY_STRING'])) {
- if(!strpos($_SERVER['QUERY_STRING'], $currentID) !== FALSE) {
- if(strrpos($_SERVER['QUERY_STRING'], "?") !== FALSE) {
- $joint = "&";
- }
- }
- }
-
- // create a new AMF message header with the session id as a variable.
- $sessionValue = $joint . $this->_sessionName . "=" . $currentID;
- $sessionHeader = new Zend_Amf_Value_MessageHeader(Zend_Amf_Constants::URL_APPEND_HEADER, false, $sessionValue);
- $response->addAmfHeader($sessionHeader);
- }
-
- // serialize the response and return serialized body.
- $response->finalize();
- }
-
- /**
- * Handle an AMF call from the gateway.
- *
- * @param null|Zend_Amf_Request $request Optional
- * @return Zend_Amf_Response
- */
- public function handle($request = null)
- {
- // Check if request was passed otherwise get it from the server
- if ($request === null || !$request instanceof Zend_Amf_Request) {
- $request = $this->getRequest();
- } else {
- $this->setRequest($request);
- }
- if ($this->isSession()) {
- // Check if a session is being sent from the amf call
- if (isset($_COOKIE[$this->_sessionName])) {
- session_id($_COOKIE[$this->_sessionName]);
- }
- }
-
- // Check for errors that may have happend in deserialization of Request.
- try {
- // Take converted PHP objects and handle service call.
- // Serialize to Zend_Amf_response for output stream
- $this->_handle($request);
- $response = $this->getResponse();
- } catch (Exception $e) {
- // Handle any errors in the serialization and service calls.
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Handle error: ' . $e->getMessage() . ' ' . $e->getLine(), 0, $e);
- }
-
- // Return the Amf serialized output string
- return $response;
- }
-
- /**
- * Set request object
- *
- * @param string|Zend_Amf_Request $request
- * @return Zend_Amf_Server
- */
- public function setRequest($request)
- {
- if (is_string($request) && class_exists($request)) {
- $request = new $request();
- if (!$request instanceof Zend_Amf_Request) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid request class');
- }
- } elseif (!$request instanceof Zend_Amf_Request) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid request object');
- }
- $this->_request = $request;
- return $this;
- }
-
- /**
- * Return currently registered request object
- *
- * @return null|Zend_Amf_Request
- */
- public function getRequest()
- {
- if (null === $this->_request) {
- require_once 'Zend/Amf/Request/Http.php';
- $this->setRequest(new Zend_Amf_Request_Http());
- }
-
- return $this->_request;
- }
-
- /**
- * Public access method to private Zend_Amf_Server_Response reference
- *
- * @param string|Zend_Amf_Server_Response $response
- * @return Zend_Amf_Server
- */
- public function setResponse($response)
- {
- if (is_string($response) && class_exists($response)) {
- $response = new $response();
- if (!$response instanceof Zend_Amf_Response) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid response class');
- }
- } elseif (!$response instanceof Zend_Amf_Response) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid response object');
- }
- $this->_response = $response;
- return $this;
- }
-
- /**
- * get a reference to the Zend_Amf_response instance
- *
- * @return Zend_Amf_Server_Response
- */
- public function getResponse()
- {
- if (null === ($response = $this->_response)) {
- require_once 'Zend/Amf/Response/Http.php';
- $this->setResponse(new Zend_Amf_Response_Http());
- }
- return $this->_response;
- }
-
- /**
- * Attach a class or object to the server
- *
- * Class may be either a class name or an instantiated object. Reflection
- * is done on the class or object to determine the available public
- * methods, and each is attached to the server as and available method. If
- * a $namespace has been provided, that namespace is used to prefix
- * AMF service call.
- *
- * @param string|object $class
- * @param string $namespace Optional
- * @param mixed $arg Optional arguments to pass to a method
- * @return Zend_Amf_Server
- * @throws Zend_Amf_Server_Exception on invalid input
- */
- public function setClass($class, $namespace = '', $argv = null)
- {
- if (is_string($class) && !class_exists($class)){
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid method or class');
- } elseif (!is_string($class) && !is_object($class)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid method or class; must be a classname or object');
- }
-
- $args = null;
- if (2 < func_num_args()) {
- $args = array_slice(func_get_args(), 2);
- }
-
- // Use the class name as the name space by default.
-
- if ($namespace == '') {
- $namespace = is_object($class) ? get_class($class) : $class;
- }
-
- $this->_classAllowed[is_object($class) ? get_class($class) : $class] = true;
-
- $this->_methods[] = Zend_Server_Reflection::reflectClass($class, $args, $namespace);
- $this->_buildDispatchTable();
-
- return $this;
- }
-
- /**
- * Attach a function to the server
- *
- * Additional arguments to pass to the function at dispatch may be passed;
- * any arguments following the namespace will be aggregated and passed at
- * dispatch time.
- *
- * @param string|array $function Valid callback
- * @param string $namespace Optional namespace prefix
- * @return Zend_Amf_Server
- * @throws Zend_Amf_Server_Exception
- */
- public function addFunction($function, $namespace = '')
- {
- if (!is_string($function) && !is_array($function)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Unable to attach function');
- }
-
- $argv = null;
- if (2 < func_num_args()) {
- $argv = array_slice(func_get_args(), 2);
- }
-
- $function = (array) $function;
- foreach ($function as $func) {
- if (!is_string($func) || !function_exists($func)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Unable to attach function');
- }
- $this->_methods[] = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
- }
-
- $this->_buildDispatchTable();
- return $this;
- }
-
-
- /**
- * Creates an array of directories in which services can reside.
- * TODO: add support for prefixes?
- *
- * @param string $dir
- */
- public function addDirectory($dir)
- {
- $this->getLoader()->addPrefixPath("", $dir);
- }
-
- /**
- * Returns an array of directories that can hold services.
- *
- * @return array
- */
- public function getDirectory()
- {
- return $this->getLoader()->getPaths("");
- }
-
- /**
- * (Re)Build the dispatch table
- *
- * The dispatch table consists of a an array of method name =>
- * Zend_Server_Reflection_Function_Abstract pairs
- *
- * @return void
- */
- protected function _buildDispatchTable()
- {
- $table = array();
- foreach ($this->_methods as $key => $dispatchable) {
- if ($dispatchable instanceof Zend_Server_Reflection_Function_Abstract) {
- $ns = $dispatchable->getNamespace();
- $name = $dispatchable->getName();
- $name = empty($ns) ? $name : $ns . '.' . $name;
-
- if (isset($table[$name])) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
- }
- $table[$name] = $dispatchable;
- continue;
- }
-
- if ($dispatchable instanceof Zend_Server_Reflection_Class) {
- foreach ($dispatchable->getMethods() as $method) {
- $ns = $method->getNamespace();
- $name = $method->getName();
- $name = empty($ns) ? $name : $ns . '.' . $name;
-
- if (isset($table[$name])) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
- }
- $table[$name] = $method;
- continue;
- }
- }
- }
- $this->_table = $table;
- }
-
-
-
- /**
- * Raise a server fault
- *
- * Unimplemented
- *
- * @param string|Exception $fault
- * @return void
- */
- public function fault($fault = null, $code = 404)
- {
- }
-
- /**
- * Returns a list of registered methods
- *
- * Returns an array of dispatchables (Zend_Server_Reflection_Function,
- * _Method, and _Class items).
- *
- * @return array
- */
- public function getFunctions()
- {
- return $this->_table;
- }
-
- /**
- * Set server persistence
- *
- * Unimplemented
- *
- * @param mixed $mode
- * @return void
- */
- public function setPersistence($mode)
- {
- }
-
- /**
- * Load server definition
- *
- * Unimplemented
- *
- * @param array $definition
- * @return void
- */
- public function loadFunctions($definition)
- {
- }
-
- /**
- * Map ActionScript classes to PHP classes
- *
- * @param string $asClass
- * @param string $phpClass
- * @return Zend_Amf_Server
- */
- public function setClassMap($asClass, $phpClass)
- {
- require_once 'Zend/Amf/Parse/TypeLoader.php';
- Zend_Amf_Parse_TypeLoader::setMapping($asClass, $phpClass);
- return $this;
- }
-
- /**
- * List all available methods
- *
- * Returns an array of method names.
- *
- * @return array
- */
- public function listMethods()
- {
- return array_keys($this->_table);
- }
-
- /**
- * Cast parameters
- *
- * Takes the provided parameters from the request, and attempts to cast them
- * to objects, if the prototype defines any as explicit object types
- *
- * @param Reflection $reflectionMethod
- * @param array $params
- * @return array
- */
- protected function _castParameters($reflectionMethod, array $params)
- {
- $prototypes = $reflectionMethod->getPrototypes();
- $nonObjectTypes = array(
- 'null',
- 'mixed',
- 'void',
- 'unknown',
- 'bool',
- 'boolean',
- 'number',
- 'int',
- 'integer',
- 'double',
- 'float',
- 'string',
- 'array',
- 'object',
- 'stdclass',
- );
- $types = array();
- foreach ($prototypes as $prototype) {
- foreach ($prototype->getParameters() as $parameter) {
- $type = $parameter->getType();
- if (in_array(strtolower($type), $nonObjectTypes)) {
- continue;
- }
- $position = $parameter->getPosition();
- $types[$position] = $type;
- }
- }
-
- if (empty($types)) {
- return $params;
- }
-
- foreach ($params as $position => $value) {
- if (!isset($types[$position])) {
- // No specific type to cast to? done
- continue;
- }
-
- $type = $types[$position];
-
- if (!class_exists($type)) {
- // Not a class, apparently. done
- continue;
- }
-
- if ($value instanceof $type) {
- // Already of the right type? done
- continue;
- }
-
- if (!is_array($value) && !is_object($value)) {
- // Can't cast scalars to objects easily; done
- continue;
- }
-
- // Create instance, and loop through value to set
- $object = new $type;
- foreach ($value as $property => $defined) {
- $object->{$property} = $defined;
- }
-
- $params[$position] = $object;
- }
-
- return $params;
- }
-}
diff --git a/lib/zend/Zend/Amf/Server/Exception.php b/lib/zend/Zend/Amf/Server/Exception.php
deleted file mode 100644
index d9532ac1123ef..0000000000000
--- a/lib/zend/Zend/Amf/Server/Exception.php
+++ /dev/null
@@ -1,37 +0,0 @@
-_stream = $stream;
- $this->_needle = 0;
- $this->_mbStringFunctionsOverloaded = function_exists('mb_strlen') && (ini_get('mbstring.func_overload') !== '') && ((int)ini_get('mbstring.func_overload') & 2);
- $this->_streamLength = $this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream);
- $this->_bigEndian = (pack('l', 1) === "\x00\x00\x00\x01");
- }
-
- /**
- * Returns the current stream
- *
- * @return string
- */
- public function getStream()
- {
- return $this->_stream;
- }
-
- /**
- * Read the number of bytes in a row for the length supplied.
- *
- * @todo Should check that there are enough bytes left in the stream we are about to read.
- * @param int $length
- * @return string
- * @throws Zend_Amf_Exception for buffer underrun
- */
- public function readBytes($length)
- {
- if (($length + $this->_needle) > $this->_streamLength) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
- }
- $bytes = $this->_mbStringFunctionsOverloaded ? mb_substr($this->_stream, $this->_needle, $length, '8bit') : substr($this->_stream, $this->_needle, $length);
- $this->_needle+= $length;
- return $bytes;
- }
-
- /**
- * Write any length of bytes to the stream
- *
- * Usually a string.
- *
- * @param string $bytes
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeBytes($bytes)
- {
- $this->_stream.= $bytes;
- return $this;
- }
-
- /**
- * Reads a signed byte
- *
- * @return int Value is in the range of -128 to 127.
- * @throws Zend_Amf_Exception
- */
- public function readByte()
- {
- if (($this->_needle + 1) > $this->_streamLength) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception(
- 'Buffer underrun at needle position: '
- . $this->_needle
- . ' while requesting length: '
- . $this->_streamLength
- );
- }
-
- return ord($this->_stream{$this->_needle++});
- }
-
- /**
- * Writes the passed string into a signed byte on the stream.
- *
- * @param string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeByte($stream)
- {
- $this->_stream.= pack('c', $stream);
- return $this;
- }
-
- /**
- * Reads a signed 32-bit integer from the data stream.
- *
- * @return int Value is in the range of -2147483648 to 2147483647
- */
- public function readInt()
- {
- return ($this->readByte() << 8) + $this->readByte();
- }
-
- /**
- * Write an the integer to the output stream as a 32 bit signed integer
- *
- * @param int $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeInt($stream)
- {
- $this->_stream.= pack('n', $stream);
- return $this;
- }
-
- /**
- * Reads a UTF-8 string from the data stream
- *
- * @return string A UTF-8 string produced by the byte representation of characters
- */
- public function readUtf()
- {
- $length = $this->readInt();
- return $this->readBytes($length);
- }
-
- /**
- * Wite a UTF-8 string to the outputstream
- *
- * @param string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeUtf($stream)
- {
- $this->writeInt($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream));
- $this->_stream.= $stream;
- return $this;
- }
-
-
- /**
- * Read a long UTF string
- *
- * @return string
- */
- public function readLongUtf()
- {
- $length = $this->readLong();
- return $this->readBytes($length);
- }
-
- /**
- * Write a long UTF string to the buffer
- *
- * @param string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeLongUtf($stream)
- {
- $this->writeLong($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream));
- $this->_stream.= $stream;
- }
-
- /**
- * Read a long numeric value
- *
- * @return double
- */
- public function readLong()
- {
- return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
- }
-
- /**
- * Write long numeric value to output stream
- *
- * @param int|string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeLong($stream)
- {
- $this->_stream.= pack('N', $stream);
- return $this;
- }
-
- /**
- * Read a 16 bit unsigned short.
- *
- * @todo This could use the unpack() w/ S,n, or v
- * @return double
- */
- public function readUnsignedShort()
- {
- $byte1 = $this->readByte();
- $byte2 = $this->readByte();
- return (($byte1 << 8) | $byte2);
- }
-
- /**
- * Reads an IEEE 754 double-precision floating point number from the data stream.
- *
- * @return double Floating point number
- */
- public function readDouble()
- {
- $bytes = $this->_mbStringFunctionsOverloaded ? mb_substr($this->_stream, $this->_needle, 8, '8bit') : substr($this->_stream, $this->_needle, 8);
- $this->_needle+= 8;
-
- if (!$this->_bigEndian) {
- $bytes = strrev($bytes);
- }
-
- $double = unpack('dflt', $bytes);
- return $double['flt'];
- }
-
- /**
- * Writes an IEEE 754 double-precision floating point number from the data stream.
- *
- * @param string|double $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeDouble($stream)
- {
- $stream = pack('d', $stream);
- if (!$this->_bigEndian) {
- $stream = strrev($stream);
- }
- $this->_stream.= $stream;
- return $this;
- }
-
-}
diff --git a/lib/zend/Zend/Amf/Value/ByteArray.php b/lib/zend/Zend/Amf/Value/ByteArray.php
deleted file mode 100644
index 32ebf268b81e2..0000000000000
--- a/lib/zend/Zend/Amf/Value/ByteArray.php
+++ /dev/null
@@ -1,58 +0,0 @@
-_data = $data;
- }
-
- /**
- * Return the byte stream
- *
- * @return string
- */
- public function getData()
- {
- return $this->_data;
- }
-}
diff --git a/lib/zend/Zend/Amf/Value/MessageBody.php b/lib/zend/Zend/Amf/Value/MessageBody.php
deleted file mode 100644
index 59cacba52bea2..0000000000000
--- a/lib/zend/Zend/Amf/Value/MessageBody.php
+++ /dev/null
@@ -1,182 +0,0 @@
-
- * This Message structure defines how a local client would
- * invoke a method/operation on a remote server. Additionally,
- * the response from the Server is structured identically.
- *
- * @package Zend_Amf
- * @subpackage Value
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Amf_Value_MessageBody
-{
- /**
- * A string describing which operation, function, or method
- * is to be remotley invoked.
- * @var string
- */
- protected $_targetUri = "";
-
- /**
- * Universal Resource Identifier that uniquely targets the originator's
- * Object that should receive the server's response. The server will
- * use this path specification to target the "OnResult()" or "onStatus()"
- * handlers within the client. For Flash, it specifies an ActionScript
- * Object path only. The NetResponse object pointed to by the Response Uri
- * contains the connection state information. Passing/specifying this
- * provides a convenient mechanism for the client/server to share access
- * to an object that is managing the state of the shared connection.
- *
- * Since the server will use this field in the event of an error,
- * this field is required even if a successful server request would
- * not be expected to return a value to the client.
- *
- * @var string
- */
- protected $_responseUri = "";
-
- /**
- * Contains the actual data associated with the operation. It contains
- * the client's parameter data that is passed to the server's operation/method.
- * When serializing a root level data type or a parameter list array, no
- * name field is included. That is, the data is anonomously represented
- * as "Type Marker"/"Value" pairs. When serializing member data, the data is
- * represented as a series of "Name"/"Type"/"Value" combinations.
- *
- * For server generated responses, it may contain any ActionScript
- * data/objects that the server was expected to provide.
- *
- * @var string
- */
- protected $_data;
-
- /**
- * Constructor
- *
- * @param string $targetUri
- * @param string $responseUri
- * @param string $data
- * @return void
- */
- public function __construct($targetUri, $responseUri, $data)
- {
- $this->setTargetUri($targetUri);
- $this->setResponseUri($responseUri);
- $this->setData($data);
- }
-
- /**
- * Retrieve target Uri
- *
- * @return string
- */
- public function getTargetUri()
- {
- return $this->_targetUri;
- }
-
- /**
- * Set target Uri
- *
- * @param string $targetUri
- * @return Zend_Amf_Value_MessageBody
- */
- public function setTargetUri($targetUri)
- {
- if (null === $targetUri) {
- $targetUri = '';
- }
- $this->_targetUri = (string) $targetUri;
- return $this;
- }
-
- /**
- * Get target Uri
- *
- * @return string
- */
- public function getResponseUri()
- {
- return $this->_responseUri;
- }
-
- /**
- * Set response Uri
- *
- * @param string $responseUri
- * @return Zend_Amf_Value_MessageBody
- */
- public function setResponseUri($responseUri)
- {
- if (null === $responseUri) {
- $responseUri = '';
- }
- $this->_responseUri = $responseUri;
- return $this;
- }
-
- /**
- * Retrieve response data
- *
- * @return string
- */
- public function getData()
- {
- return $this->_data;
- }
-
- /**
- * Set response data
- *
- * @param mixed $data
- * @return Zend_Amf_Value_MessageBody
- */
- public function setData($data)
- {
- $this->_data = $data;
- return $this;
- }
-
- /**
- * Set reply method
- *
- * @param string $methodName
- * @return Zend_Amf_Value_MessageBody
- */
- public function setReplyMethod($methodName)
- {
- if (!preg_match('#^[/?]#', $methodName)) {
- $this->_targetUri = rtrim($this->_targetUri, '/') . '/';
- }
- $this->_targetUri = $this->_targetUri . $methodName;
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Amf/Value/MessageHeader.php b/lib/zend/Zend/Amf/Value/MessageHeader.php
deleted file mode 100644
index bdbbba2a7db26..0000000000000
--- a/lib/zend/Zend/Amf/Value/MessageHeader.php
+++ /dev/null
@@ -1,81 +0,0 @@
-name = $name;
- $this->mustRead = (bool) $mustRead;
- $this->data = $data;
- if (null !== $length) {
- $this->length = (int) $length;
- }
- }
-}
diff --git a/lib/zend/Zend/Amf/Value/Messaging/AbstractMessage.php b/lib/zend/Zend/Amf/Value/Messaging/AbstractMessage.php
deleted file mode 100644
index acb5a0c6c8e95..0000000000000
--- a/lib/zend/Zend/Amf/Value/Messaging/AbstractMessage.php
+++ /dev/null
@@ -1,92 +0,0 @@
-clientId = $this->generateId();
- $this->destination = null;
- $this->messageId = $this->generateId();
- $this->timestamp = time().'00';
- $this->timeToLive = 0;
- $this->headers = new STDClass();
- $this->body = null;
-
- // correleate the two messages
- if ($message && isset($message->messageId)) {
- $this->correlationId = $message->messageId;
- }
- }
-}
diff --git a/lib/zend/Zend/Amf/Value/Messaging/ArrayCollection.php b/lib/zend/Zend/Amf/Value/Messaging/ArrayCollection.php
deleted file mode 100644
index a759f58e53ed9..0000000000000
--- a/lib/zend/Zend/Amf/Value/Messaging/ArrayCollection.php
+++ /dev/null
@@ -1,35 +0,0 @@
-body
- * of the message.
- */
- const LOGIN_OPERATION = 8;
-
- /**
- * This operation is used to log the user out of the current channel, and
- * will invalidate the server session if the channel is HTTP based.
- */
- const LOGOUT_OPERATION = 9;
-
- /**
- * This operation is used to indicate that the client's subscription to a
- * remote destination has been invalidated.
- */
- const SESSION_INVALIDATE_OPERATION = 10;
-
- /**
- * This operation is used by the MultiTopicConsumer to subscribe/unsubscribe
- * from multiple subtopics/selectors in the same message.
- */
- const MULTI_SUBSCRIBE_OPERATION = 11;
-
- /**
- * This operation is used to indicate that a channel has disconnected
- */
- const DISCONNECT_OPERATION = 12;
-
- /**
- * This is the default operation for new CommandMessage instances.
- */
- const UNKNOWN_OPERATION = 10000;
-
- /**
- * The operation to execute for messages of this type
- * @var int
- */
- public $operation = self::UNKNOWN_OPERATION;
-}
diff --git a/lib/zend/Zend/Amf/Value/Messaging/ErrorMessage.php b/lib/zend/Zend/Amf/Value/Messaging/ErrorMessage.php
deleted file mode 100644
index a6eaf166fb4fe..0000000000000
--- a/lib/zend/Zend/Amf/Value/Messaging/ErrorMessage.php
+++ /dev/null
@@ -1,67 +0,0 @@
-clientId = $this->generateId();
- $this->destination = null;
- $this->messageId = $this->generateId();
- $this->timestamp = time().'00';
- $this->timeToLive = 0;
- $this->headers = new stdClass();
- $this->body = null;
- }
-}
diff --git a/lib/zend/Zend/Amf/Value/TraitsInfo.php b/lib/zend/Zend/Amf/Value/TraitsInfo.php
deleted file mode 100644
index 64d3c990ea0ee..0000000000000
--- a/lib/zend/Zend/Amf/Value/TraitsInfo.php
+++ /dev/null
@@ -1,154 +0,0 @@
-_className = $className;
- $this->_dynamic = $dynamic;
- $this->_externalizable = $externalizable;
- $this->_properties = $properties;
- }
-
- /**
- * Test if the class is a dynamic class
- *
- * @return boolean
- */
- public function isDynamic()
- {
- return $this->_dynamic;
- }
-
- /**
- * Test if class is externalizable
- *
- * @return boolean
- */
- public function isExternalizable()
- {
- return $this->_externalizable;
- }
-
- /**
- * Return the number of properties in the class
- *
- * @return int
- */
- public function length()
- {
- return count($this->_properties);
- }
-
- /**
- * Return the class name
- *
- * @return string
- */
- public function getClassName()
- {
- return $this->_className;
- }
-
- /**
- * Add an additional property
- *
- * @param string $name
- * @return Zend_Amf_Value_TraitsInfo
- */
- public function addProperty($name)
- {
- $this->_properties[] = $name;
- return $this;
- }
-
- /**
- * Add all properties of the class.
- *
- * @param array $props
- * @return Zend_Amf_Value_TraitsInfo
- */
- public function addAllProperties(array $props)
- {
- $this->_properties = $props;
- return $this;
- }
-
- /**
- * Get the property at a given index
- *
- * @param int $index
- * @return string
- */
- public function getProperty($index)
- {
- return $this->_properties[(int) $index];
- }
-
- /**
- * Return all properties of the class.
- *
- * @return array
- */
- public function getAllProperties()
- {
- return $this->_properties;
- }
-}
diff --git a/lib/zend/Zend/Auth.php b/lib/zend/Zend/Auth.php
deleted file mode 100644
index 0b4b00ffb44b1..0000000000000
--- a/lib/zend/Zend/Auth.php
+++ /dev/null
@@ -1,169 +0,0 @@
-_storage) {
- /**
- * @see Zend_Auth_Storage_Session
- */
- require_once 'Zend/Auth/Storage/Session.php';
- $this->setStorage(new Zend_Auth_Storage_Session());
- }
-
- return $this->_storage;
- }
-
- /**
- * Sets the persistent storage handler
- *
- * @param Zend_Auth_Storage_Interface $storage
- * @return Zend_Auth Provides a fluent interface
- */
- public function setStorage(Zend_Auth_Storage_Interface $storage)
- {
- $this->_storage = $storage;
- return $this;
- }
-
- /**
- * Authenticates against the supplied adapter
- *
- * @param Zend_Auth_Adapter_Interface $adapter
- * @return Zend_Auth_Result
- */
- public function authenticate(Zend_Auth_Adapter_Interface $adapter)
- {
- $result = $adapter->authenticate();
-
- /**
- * ZF-7546 - prevent multiple succesive calls from storing inconsistent results
- * Ensure storage has clean state
- */
- if ($this->hasIdentity()) {
- $this->clearIdentity();
- }
-
- if ($result->isValid()) {
- $this->getStorage()->write($result->getIdentity());
- }
-
- return $result;
- }
-
- /**
- * Returns true if and only if an identity is available from storage
- *
- * @return boolean
- */
- public function hasIdentity()
- {
- return !$this->getStorage()->isEmpty();
- }
-
- /**
- * Returns the identity from storage or null if no identity is available
- *
- * @return mixed|null
- */
- public function getIdentity()
- {
- $storage = $this->getStorage();
-
- if ($storage->isEmpty()) {
- return null;
- }
-
- return $storage->read();
- }
-
- /**
- * Clears the identity from persistent storage
- *
- * @return void
- */
- public function clearIdentity()
- {
- $this->getStorage()->clear();
- }
-}
diff --git a/lib/zend/Zend/Auth/Adapter/Digest.php b/lib/zend/Zend/Auth/Adapter/Digest.php
deleted file mode 100644
index f52b651e7a6e3..0000000000000
--- a/lib/zend/Zend/Auth/Adapter/Digest.php
+++ /dev/null
@@ -1,251 +0,0 @@
-$methodName($$option);
- }
- }
- }
-
- /**
- * Returns the filename option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getFilename()
- {
- return $this->_filename;
- }
-
- /**
- * Sets the filename option value
- *
- * @param mixed $filename
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setFilename($filename)
- {
- $this->_filename = (string) $filename;
- return $this;
- }
-
- /**
- * Returns the realm option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getRealm()
- {
- return $this->_realm;
- }
-
- /**
- * Sets the realm option value
- *
- * @param mixed $realm
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setRealm($realm)
- {
- $this->_realm = (string) $realm;
- return $this;
- }
-
- /**
- * Returns the username option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getUsername()
- {
- return $this->_username;
- }
-
- /**
- * Sets the username option value
- *
- * @param mixed $username
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setUsername($username)
- {
- $this->_username = (string) $username;
- return $this;
- }
-
- /**
- * Returns the password option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getPassword()
- {
- return $this->_password;
- }
-
- /**
- * Sets the password option value
- *
- * @param mixed $password
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setPassword($password)
- {
- $this->_password = (string) $password;
- return $this;
- }
-
- /**
- * Defined by Zend_Auth_Adapter_Interface
- *
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- */
- public function authenticate()
- {
- $optionsRequired = array('filename', 'realm', 'username', 'password');
- foreach ($optionsRequired as $optionRequired) {
- if (null === $this->{"_$optionRequired"}) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception("Option '$optionRequired' must be set before authentication");
- }
- }
-
- if (false === ($fileHandle = @fopen($this->_filename, 'r'))) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception("Cannot open '$this->_filename' for reading");
- }
-
- $id = "$this->_username:$this->_realm";
- $idLength = strlen($id);
-
- $result = array(
- 'code' => Zend_Auth_Result::FAILURE,
- 'identity' => array(
- 'realm' => $this->_realm,
- 'username' => $this->_username,
- ),
- 'messages' => array()
- );
-
- while ($line = trim(fgets($fileHandle))) {
- if (substr($line, 0, $idLength) === $id) {
- if ($this->_secureStringCompare(substr($line, -32), md5("$this->_username:$this->_realm:$this->_password"))) {
- $result['code'] = Zend_Auth_Result::SUCCESS;
- } else {
- $result['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
- $result['messages'][] = 'Password incorrect';
- }
- return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
- }
- }
-
- $result['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
- $result['messages'][] = "Username '$this->_username' and realm '$this->_realm' combination not found";
- return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
- }
-
- /**
- * Securely compare two strings for equality while avoided C level memcmp()
- * optimisations capable of leaking timing information useful to an attacker
- * attempting to iteratively guess the unknown string (e.g. password) being
- * compared against.
- *
- * @param string $a
- * @param string $b
- * @return bool
- */
- protected function _secureStringCompare($a, $b)
- {
- if (strlen($a) !== strlen($b)) {
- return false;
- }
- $result = 0;
- for ($i = 0; $i < strlen($a); $i++) {
- $result |= ord($a[$i]) ^ ord($b[$i]);
- }
- return $result == 0;
- }
-}
diff --git a/lib/zend/Zend/Auth/Adapter/Exception.php b/lib/zend/Zend/Auth/Adapter/Exception.php
deleted file mode 100644
index 032164930655c..0000000000000
--- a/lib/zend/Zend/Auth/Adapter/Exception.php
+++ /dev/null
@@ -1,38 +0,0 @@
- 'basic'|'digest'|'basic digest'
- * 'realm' =>
- * 'digest_domains' => Space-delimited list of URIs
- * 'nonce_timeout' =>
- * 'use_opaque' => Whether to send the opaque value in the header
- * 'alogrithm' => See $_supportedAlgos. Default: MD5
- * 'proxy_auth' => Whether to do authentication as a Proxy
- * @throws Zend_Auth_Adapter_Exception
- */
- public function __construct(array $config)
- {
- if (!extension_loaded('hash')) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception(__CLASS__ . ' requires the \'hash\' extension');
- }
-
- $this->_request = null;
- $this->_response = null;
- $this->_ieNoOpaque = false;
-
-
- if (empty($config['accept_schemes'])) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'accept_schemes\' is required');
- }
-
- $schemes = explode(' ', $config['accept_schemes']);
- $this->_acceptSchemes = array_intersect($schemes, $this->_supportedSchemes);
- if (empty($this->_acceptSchemes)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('No supported schemes given in \'accept_schemes\'. Valid values: '
- . implode(', ', $this->_supportedSchemes));
- }
-
- // Double-quotes are used to delimit the realm string in the HTTP header,
- // and colons are field delimiters in the password file.
- if (empty($config['realm']) ||
- !ctype_print($config['realm']) ||
- strpos($config['realm'], ':') !== false ||
- strpos($config['realm'], '"') !== false) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'realm\' is required, and must contain only printable '
- . 'characters, excluding quotation marks and colons');
- } else {
- $this->_realm = $config['realm'];
- }
-
- if (in_array('digest', $this->_acceptSchemes)) {
- if (empty($config['digest_domains']) ||
- !ctype_print($config['digest_domains']) ||
- strpos($config['digest_domains'], '"') !== false) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'digest_domains\' is required, and must contain '
- . 'only printable characters, excluding quotation marks');
- } else {
- $this->_domains = $config['digest_domains'];
- }
-
- if (empty($config['nonce_timeout']) ||
- !is_numeric($config['nonce_timeout'])) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'nonce_timeout\' is required, and must be an '
- . 'integer');
- } else {
- $this->_nonceTimeout = (int) $config['nonce_timeout'];
- }
-
- // We use the opaque value unless explicitly told not to
- if (isset($config['use_opaque']) && false == (bool) $config['use_opaque']) {
- $this->_useOpaque = false;
- } else {
- $this->_useOpaque = true;
- }
-
- if (isset($config['algorithm']) && in_array($config['algorithm'], $this->_supportedAlgos)) {
- $this->_algo = $config['algorithm'];
- } else {
- $this->_algo = 'MD5';
- }
- }
-
- // Don't be a proxy unless explicitly told to do so
- if (isset($config['proxy_auth']) && true == (bool) $config['proxy_auth']) {
- $this->_imaProxy = true; // I'm a Proxy
- } else {
- $this->_imaProxy = false;
- }
- }
-
- /**
- * Setter for the _basicResolver property
- *
- * @param Zend_Auth_Adapter_Http_Resolver_Interface $resolver
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setBasicResolver(Zend_Auth_Adapter_Http_Resolver_Interface $resolver)
- {
- $this->_basicResolver = $resolver;
-
- return $this;
- }
-
- /**
- * Getter for the _basicResolver property
- *
- * @return Zend_Auth_Adapter_Http_Resolver_Interface
- */
- public function getBasicResolver()
- {
- return $this->_basicResolver;
- }
-
- /**
- * Setter for the _digestResolver property
- *
- * @param Zend_Auth_Adapter_Http_Resolver_Interface $resolver
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setDigestResolver(Zend_Auth_Adapter_Http_Resolver_Interface $resolver)
- {
- $this->_digestResolver = $resolver;
-
- return $this;
- }
-
- /**
- * Getter for the _digestResolver property
- *
- * @return Zend_Auth_Adapter_Http_Resolver_Interface
- */
- public function getDigestResolver()
- {
- return $this->_digestResolver;
- }
-
- /**
- * Setter for the Request object
- *
- * @param Zend_Controller_Request_Http $request
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setRequest(Zend_Controller_Request_Http $request)
- {
- $this->_request = $request;
-
- return $this;
- }
-
- /**
- * Getter for the Request object
- *
- * @return Zend_Controller_Request_Http
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Setter for the Response object
- *
- * @param Zend_Controller_Response_Http $response
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setResponse(Zend_Controller_Response_Http $response)
- {
- $this->_response = $response;
-
- return $this;
- }
-
- /**
- * Getter for the Response object
- *
- * @return Zend_Controller_Response_Http
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Authenticate
- *
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- */
- public function authenticate()
- {
- if (empty($this->_request) ||
- empty($this->_response)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling '
- . 'authenticate()');
- }
-
- if ($this->_imaProxy) {
- $getHeader = 'Proxy-Authorization';
- } else {
- $getHeader = 'Authorization';
- }
-
- $authHeader = $this->_request->getHeader($getHeader);
- if (!$authHeader) {
- return $this->_challengeClient();
- }
-
- list($clientScheme) = explode(' ', $authHeader);
- $clientScheme = strtolower($clientScheme);
-
- // The server can issue multiple challenges, but the client should
- // answer with only the selected auth scheme.
- if (!in_array($clientScheme, $this->_supportedSchemes)) {
- $this->_response->setHttpResponseCode(400);
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE_UNCATEGORIZED,
- array(),
- array('Client requested an incorrect or unsupported authentication scheme')
- );
- }
-
- // client sent a scheme that is not the one required
- if (!in_array($clientScheme, $this->_acceptSchemes)) {
- // challenge again the client
- return $this->_challengeClient();
- }
-
- switch ($clientScheme) {
- case 'basic':
- $result = $this->_basicAuth($authHeader);
- break;
- case 'digest':
- $result = $this->_digestAuth($authHeader);
- break;
- default:
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Unsupported authentication scheme');
- }
-
- return $result;
- }
-
- /**
- * Challenge Client
- *
- * Sets a 401 or 407 Unauthorized response code, and creates the
- * appropriate Authenticate header(s) to prompt for credentials.
- *
- * @return Zend_Auth_Result Always returns a non-identity Auth result
- */
- protected function _challengeClient()
- {
- if ($this->_imaProxy) {
- $statusCode = 407;
- $headerName = 'Proxy-Authenticate';
- } else {
- $statusCode = 401;
- $headerName = 'WWW-Authenticate';
- }
-
- $this->_response->setHttpResponseCode($statusCode);
-
- // Send a challenge in each acceptable authentication scheme
- if (in_array('basic', $this->_acceptSchemes)) {
- $this->_response->setHeader($headerName, $this->_basicHeader());
- }
- if (in_array('digest', $this->_acceptSchemes)) {
- $this->_response->setHeader($headerName, $this->_digestHeader());
- }
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
- array(),
- array('Invalid or absent credentials; challenging client')
- );
- }
-
- /**
- * Basic Header
- *
- * Generates a Proxy- or WWW-Authenticate header value in the Basic
- * authentication scheme.
- *
- * @return string Authenticate header value
- */
- protected function _basicHeader()
- {
- return 'Basic realm="' . $this->_realm . '"';
- }
-
- /**
- * Digest Header
- *
- * Generates a Proxy- or WWW-Authenticate header value in the Digest
- * authentication scheme.
- *
- * @return string Authenticate header value
- */
- protected function _digestHeader()
- {
- $wwwauth = 'Digest realm="' . $this->_realm . '", '
- . 'domain="' . $this->_domains . '", '
- . 'nonce="' . $this->_calcNonce() . '", '
- . ($this->_useOpaque ? 'opaque="' . $this->_calcOpaque() . '", ' : '')
- . 'algorithm="' . $this->_algo . '", '
- . 'qop="' . implode(',', $this->_supportedQops) . '"';
-
- return $wwwauth;
- }
-
- /**
- * Basic Authentication
- *
- * @param string $header Client's Authorization header
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- */
- protected function _basicAuth($header)
- {
- if (empty($header)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('The value of the client Authorization header is required');
- }
- if (empty($this->_basicResolver)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('A basicResolver object must be set before doing Basic '
- . 'authentication');
- }
-
- // Decode the Authorization header
- $auth = substr($header, strlen('Basic '));
- $auth = base64_decode($auth);
- if (!$auth) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Unable to base64_decode Authorization header value');
- }
-
- // See ZF-1253. Validate the credentials the same way the digest
- // implementation does. If invalid credentials are detected,
- // re-challenge the client.
- if (!ctype_print($auth)) {
- return $this->_challengeClient();
- }
- // Fix for ZF-1515: Now re-challenges on empty username or password
- $creds = array_filter(explode(':', $auth));
- if (count($creds) != 2) {
- return $this->_challengeClient();
- }
-
- $password = $this->_basicResolver->resolve($creds[0], $this->_realm);
- if ($password && $this->_secureStringCompare($password, $creds[1])) {
- $identity = array('username'=>$creds[0], 'realm'=>$this->_realm);
- return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
- } else {
- return $this->_challengeClient();
- }
- }
-
- /**
- * Digest Authentication
- *
- * @param string $header Client's Authorization header
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result Valid auth result only on successful auth
- */
- protected function _digestAuth($header)
- {
- if (empty($header)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('The value of the client Authorization header is required');
- }
- if (empty($this->_digestResolver)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('A digestResolver object must be set before doing Digest authentication');
- }
-
- $data = $this->_parseDigestAuth($header);
- if ($data === false) {
- $this->_response->setHttpResponseCode(400);
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE_UNCATEGORIZED,
- array(),
- array('Invalid Authorization header format')
- );
- }
-
- // See ZF-1052. This code was a bit too unforgiving of invalid
- // usernames. Now, if the username is bad, we re-challenge the client.
- if ('::invalid::' == $data['username']) {
- return $this->_challengeClient();
- }
-
- // Verify that the client sent back the same nonce
- if ($this->_calcNonce() != $data['nonce']) {
- return $this->_challengeClient();
- }
- // The opaque value is also required to match, but of course IE doesn't
- // play ball.
- if (!$this->_ieNoOpaque && $this->_calcOpaque() != $data['opaque']) {
- return $this->_challengeClient();
- }
-
- // Look up the user's password hash. If not found, deny access.
- // This makes no assumptions about how the password hash was
- // constructed beyond that it must have been built in such a way as
- // to be recreatable with the current settings of this object.
- $ha1 = $this->_digestResolver->resolve($data['username'], $data['realm']);
- if ($ha1 === false) {
- return $this->_challengeClient();
- }
-
- // If MD5-sess is used, a1 value is made of the user's password
- // hash with the server and client nonce appended, separated by
- // colons.
- if ($this->_algo == 'MD5-sess') {
- $ha1 = hash('md5', $ha1 . ':' . $data['nonce'] . ':' . $data['cnonce']);
- }
-
- // Calculate h(a2). The value of this hash depends on the qop
- // option selected by the client and the supported hash functions
- switch ($data['qop']) {
- case 'auth':
- $a2 = $this->_request->getMethod() . ':' . $data['uri'];
- break;
- case 'auth-int':
- // Should be REQUEST_METHOD . ':' . uri . ':' . hash(entity-body),
- // but this isn't supported yet, so fall through to default case
- default:
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Client requested an unsupported qop option');
- }
- // Using hash() should make parameterizing the hash algorithm
- // easier
- $ha2 = hash('md5', $a2);
-
-
- // Calculate the server's version of the request-digest. This must
- // match $data['response']. See RFC 2617, section 3.2.2.1
- $message = $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $ha2;
- $digest = hash('md5', $ha1 . ':' . $message);
-
- // If our digest matches the client's let them in, otherwise return
- // a 401 code and exit to prevent access to the protected resource.
- if ($this->_secureStringCompare($digest, $data['response'])) {
- $identity = array('username'=>$data['username'], 'realm'=>$data['realm']);
- return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
- } else {
- return $this->_challengeClient();
- }
- }
-
- /**
- * Calculate Nonce
- *
- * @return string The nonce value
- */
- protected function _calcNonce()
- {
- // Once subtle consequence of this timeout calculation is that it
- // actually divides all of time into _nonceTimeout-sized sections, such
- // that the value of timeout is the point in time of the next
- // approaching "boundary" of a section. This allows the server to
- // consistently generate the same timeout (and hence the same nonce
- // value) across requests, but only as long as one of those
- // "boundaries" is not crossed between requests. If that happens, the
- // nonce will change on its own, and effectively log the user out. This
- // would be surprising if the user just logged in.
- $timeout = ceil(time() / $this->_nonceTimeout) * $this->_nonceTimeout;
-
- $nonce = hash('md5', $timeout . ':' . $this->_request->getServer('HTTP_USER_AGENT') . ':' . __CLASS__);
- return $nonce;
- }
-
- /**
- * Calculate Opaque
- *
- * The opaque string can be anything; the client must return it exactly as
- * it was sent. It may be useful to store data in this string in some
- * applications. Ideally, a new value for this would be generated each time
- * a WWW-Authenticate header is sent (in order to reduce predictability),
- * but we would have to be able to create the same exact value across at
- * least two separate requests from the same client.
- *
- * @return string The opaque value
- */
- protected function _calcOpaque()
- {
- return hash('md5', 'Opaque Data:' . __CLASS__);
- }
-
- /**
- * Parse Digest Authorization header
- *
- * @param string $header Client's Authorization: HTTP header
- * @return array|false Data elements from header, or false if any part of
- * the header is invalid
- */
- protected function _parseDigestAuth($header)
- {
- $temp = null;
- $data = array();
-
- // See ZF-1052. Detect invalid usernames instead of just returning a
- // 400 code.
- $ret = preg_match('/username="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])
- || !ctype_print($temp[1])
- || strpos($temp[1], ':') !== false) {
- $data['username'] = '::invalid::';
- } else {
- $data['username'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/realm="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!ctype_print($temp[1]) || strpos($temp[1], ':') !== false) {
- return false;
- } else {
- $data['realm'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/nonce="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!ctype_xdigit($temp[1])) {
- return false;
- } else {
- $data['nonce'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/uri="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- // Section 3.2.2.5 in RFC 2617 says the authenticating server must
- // verify that the URI field in the Authorization header is for the
- // same resource requested in the Request Line.
- $rUri = @parse_url($this->_request->getRequestUri());
- $cUri = @parse_url($temp[1]);
- if (false === $rUri || false === $cUri) {
- return false;
- } else {
- // Make sure the path portion of both URIs is the same
- if ($rUri['path'] != $cUri['path']) {
- return false;
- }
- // Section 3.2.2.5 seems to suggest that the value of the URI
- // Authorization field should be made into an absolute URI if the
- // Request URI is absolute, but it's vague, and that's a bunch of
- // code I don't want to write right now.
- $data['uri'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/response="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (32 != strlen($temp[1]) || !ctype_xdigit($temp[1])) {
- return false;
- } else {
- $data['response'] = $temp[1];
- }
- $temp = null;
-
- // The spec says this should default to MD5 if omitted. OK, so how does
- // that square with the algo we send out in the WWW-Authenticate header,
- // if it can easily be overridden by the client?
- $ret = preg_match('/algorithm="?(' . $this->_algo . ')"?/', $header, $temp);
- if ($ret && !empty($temp[1])
- && in_array($temp[1], $this->_supportedAlgos)) {
- $data['algorithm'] = $temp[1];
- } else {
- $data['algorithm'] = 'MD5'; // = $this->_algo; ?
- }
- $temp = null;
-
- // Not optional in this implementation
- $ret = preg_match('/cnonce="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!ctype_print($temp[1])) {
- return false;
- } else {
- $data['cnonce'] = $temp[1];
- }
- $temp = null;
-
- // If the server sent an opaque value, the client must send it back
- if ($this->_useOpaque) {
- $ret = preg_match('/opaque="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
-
- // Big surprise: IE isn't RFC 2617-compliant.
- if (false !== strpos($this->_request->getHeader('User-Agent'), 'MSIE')) {
- $temp[1] = '';
- $this->_ieNoOpaque = true;
- } else {
- return false;
- }
- }
- // This implementation only sends MD5 hex strings in the opaque value
- if (!$this->_ieNoOpaque &&
- (32 != strlen($temp[1]) || !ctype_xdigit($temp[1]))) {
- return false;
- } else {
- $data['opaque'] = $temp[1];
- }
- $temp = null;
- }
-
- // Not optional in this implementation, but must be one of the supported
- // qop types
- $ret = preg_match('/qop="?(' . implode('|', $this->_supportedQops) . ')"?/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!in_array($temp[1], $this->_supportedQops)) {
- return false;
- } else {
- $data['qop'] = $temp[1];
- }
- $temp = null;
-
- // Not optional in this implementation. The spec says this value
- // shouldn't be a quoted string, but apparently some implementations
- // quote it anyway. See ZF-1544.
- $ret = preg_match('/nc="?([0-9A-Fa-f]{8})"?/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (8 != strlen($temp[1]) || !ctype_xdigit($temp[1])) {
- return false;
- } else {
- $data['nc'] = $temp[1];
- }
- $temp = null;
-
- return $data;
- }
-
- /**
- * Securely compare two strings for equality while avoided C level memcmp()
- * optimisations capable of leaking timing information useful to an attacker
- * attempting to iteratively guess the unknown string (e.g. password) being
- * compared against.
- *
- * @param string $a
- * @param string $b
- * @return bool
- */
- protected function _secureStringCompare($a, $b)
- {
- if (strlen($a) !== strlen($b)) {
- return false;
- }
- $result = 0;
- for ($i = 0; $i < strlen($a); $i++) {
- $result |= ord($a[$i]) ^ ord($b[$i]);
- }
- return $result == 0;
- }
-}
diff --git a/lib/zend/Zend/Auth/Adapter/Http/Resolver/Exception.php b/lib/zend/Zend/Auth/Adapter/Http/Resolver/Exception.php
deleted file mode 100644
index e7e2a4e8262bb..0000000000000
--- a/lib/zend/Zend/Auth/Adapter/Http/Resolver/Exception.php
+++ /dev/null
@@ -1,40 +0,0 @@
-setFile($path);
- }
- }
-
- /**
- * Set the path to the credentials file
- *
- * @param string $path
- * @throws Zend_Auth_Adapter_Http_Resolver_Exception
- * @return Zend_Auth_Adapter_Http_Resolver_File Provides a fluent interface
- */
- public function setFile($path)
- {
- if (empty($path) || !is_readable($path)) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Path not readable: ' . $path);
- }
- $this->_file = $path;
-
- return $this;
- }
-
- /**
- * Returns the path to the credentials file
- *
- * @return string
- */
- public function getFile()
- {
- return $this->_file;
- }
-
- /**
- * Resolve credentials
- *
- * Only the first matching username/realm combination in the file is
- * returned. If the file contains credentials for Digest authentication,
- * the returned string is the password hash, or h(a1) from RFC 2617. The
- * returned string is the plain-text password for Basic authentication.
- *
- * The expected format of the file is:
- * username:realm:sharedSecret
- *
- * That is, each line consists of the user's username, the applicable
- * authentication realm, and the password or hash, each delimited by
- * colons.
- *
- * @param string $username Username
- * @param string $realm Authentication Realm
- * @throws Zend_Auth_Adapter_Http_Resolver_Exception
- * @return string|false User's shared secret, if the user is found in the
- * realm, false otherwise.
- */
- public function resolve($username, $realm)
- {
- if (empty($username)) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username is required');
- } else if (!ctype_print($username) || strpos($username, ':') !== false) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username must consist only of printable characters, '
- . 'excluding the colon');
- }
- if (empty($realm)) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm is required');
- } else if (!ctype_print($realm) || strpos($realm, ':') !== false) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm must consist only of printable characters, '
- . 'excluding the colon.');
- }
-
- // Open file, read through looking for matching credentials
- $fp = @fopen($this->_file, 'r');
- if (!$fp) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Unable to open password file: ' . $this->_file);
- }
-
- // No real validation is done on the contents of the password file. The
- // assumption is that we trust the administrators to keep it secure.
- while (($line = fgetcsv($fp, 512, ':')) !== false) {
- if ($line[0] == $username && $line[1] == $realm) {
- $password = $line[2];
- fclose($fp);
- return $password;
- }
- }
-
- fclose($fp);
- return false;
- }
-}
diff --git a/lib/zend/Zend/Auth/Adapter/Http/Resolver/Interface.php b/lib/zend/Zend/Auth/Adapter/Http/Resolver/Interface.php
deleted file mode 100644
index 4326ee8202f38..0000000000000
--- a/lib/zend/Zend/Auth/Adapter/Http/Resolver/Interface.php
+++ /dev/null
@@ -1,47 +0,0 @@
- self::SUCCESS ) {
- $code = 1;
- }
-
- $this->_code = $code;
- $this->_identity = $identity;
- $this->_messages = $messages;
- }
-
- /**
- * Returns whether the result represents a successful authentication attempt
- *
- * @return boolean
- */
- public function isValid()
- {
- return ($this->_code > 0) ? true : false;
- }
-
- /**
- * getCode() - Get the result code for this authentication attempt
- *
- * @return int
- */
- public function getCode()
- {
- return $this->_code;
- }
-
- /**
- * Returns the identity used in the authentication attempt
- *
- * @return mixed
- */
- public function getIdentity()
- {
- return $this->_identity;
- }
-
- /**
- * Returns an array of string reasons why the authentication attempt was unsuccessful
- *
- * If authentication was successful, this method returns an empty array.
- *
- * @return array
- */
- public function getMessages()
- {
- return $this->_messages;
- }
-}
diff --git a/lib/zend/Zend/Auth/Storage/Exception.php b/lib/zend/Zend/Auth/Storage/Exception.php
deleted file mode 100644
index 542b6708a7993..0000000000000
--- a/lib/zend/Zend/Auth/Storage/Exception.php
+++ /dev/null
@@ -1,38 +0,0 @@
-_data);
- }
-
- /**
- * Returns the contents of storage
- * Behavior is undefined when storage is empty.
- *
- * @throws Zend_Auth_Storage_Exception If reading contents from storage is impossible
- * @return mixed
- */
- public function read()
- {
- return $this->_data;
- }
-
- /**
- * Writes $contents to storage
- *
- * @param mixed $contents
- * @throws Zend_Auth_Storage_Exception If writing $contents to storage is impossible
- * @return void
- */
- public function write($contents)
- {
- $this->_data = $contents;
- }
-
- /**
- * Clears contents from storage
- *
- * @throws Zend_Auth_Storage_Exception If clearing contents from storage is impossible
- * @return void
- */
- public function clear()
- {
- $this->_data = null;
- }
-}
diff --git a/lib/zend/Zend/Auth/Storage/Session.php b/lib/zend/Zend/Auth/Storage/Session.php
deleted file mode 100644
index c3680f6faf79a..0000000000000
--- a/lib/zend/Zend/Auth/Storage/Session.php
+++ /dev/null
@@ -1,149 +0,0 @@
-_namespace = $namespace;
- $this->_member = $member;
- $this->_session = new Zend_Session_Namespace($this->_namespace);
- }
-
- /**
- * Returns the session namespace
- *
- * @return string
- */
- public function getNamespace()
- {
- return $this->_namespace;
- }
-
- /**
- * Returns the name of the session object member
- *
- * @return string
- */
- public function getMember()
- {
- return $this->_member;
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @return boolean
- */
- public function isEmpty()
- {
- return !isset($this->_session->{$this->_member});
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @return mixed
- */
- public function read()
- {
- return $this->_session->{$this->_member};
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @param mixed $contents
- * @return void
- */
- public function write($contents)
- {
- $this->_session->{$this->_member} = $contents;
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @return void
- */
- public function clear()
- {
- unset($this->_session->{$this->_member});
- }
-}
diff --git a/lib/zend/Zend/Cache.php b/lib/zend/Zend/Cache.php
deleted file mode 100644
index dc818f30e5757..0000000000000
--- a/lib/zend/Zend/Cache.php
+++ /dev/null
@@ -1,250 +0,0 @@
-setBackend($backendObject);
- return $frontendObject;
- }
-
- /**
- * Backend Constructor
- *
- * @param string $backend
- * @param array $backendOptions
- * @param boolean $customBackendNaming
- * @param boolean $autoload
- * @return Zend_Cache_Backend
- */
- public static function _makeBackend($backend, $backendOptions, $customBackendNaming = false, $autoload = false)
- {
- if (!$customBackendNaming) {
- $backend = self::_normalizeName($backend);
- }
- if (in_array($backend, Zend_Cache::$standardBackends)) {
- // we use a standard backend
- $backendClass = 'Zend_Cache_Backend_' . $backend;
- // security controls are explicit
- require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
- } else {
- // we use a custom backend
- if (!preg_match('~^[\w\\\\]+$~D', $backend)) {
- Zend_Cache::throwException("Invalid backend name [$backend]");
- }
- if (!$customBackendNaming) {
- // we use this boolean to avoid an API break
- $backendClass = 'Zend_Cache_Backend_' . $backend;
- } else {
- $backendClass = $backend;
- }
- if (!$autoload) {
- $file = str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
- if (!(self::_isReadable($file))) {
- self::throwException("file $file not found in include_path");
- }
- require_once $file;
- }
- }
- return new $backendClass($backendOptions);
- }
-
- /**
- * Frontend Constructor
- *
- * @param string $frontend
- * @param array $frontendOptions
- * @param boolean $customFrontendNaming
- * @param boolean $autoload
- * @return Zend_Cache_Core|Zend_Cache_Frontend
- */
- public static function _makeFrontend($frontend, $frontendOptions = array(), $customFrontendNaming = false, $autoload = false)
- {
- if (!$customFrontendNaming) {
- $frontend = self::_normalizeName($frontend);
- }
- if (in_array($frontend, self::$standardFrontends)) {
- // we use a standard frontend
- // For perfs reasons, with frontend == 'Core', we can interact with the Core itself
- $frontendClass = 'Zend_Cache_' . ($frontend != 'Core' ? 'Frontend_' : '') . $frontend;
- // security controls are explicit
- require_once str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';
- } else {
- // we use a custom frontend
- if (!preg_match('~^[\w\\\\]+$~D', $frontend)) {
- Zend_Cache::throwException("Invalid frontend name [$frontend]");
- }
- if (!$customFrontendNaming) {
- // we use this boolean to avoid an API break
- $frontendClass = 'Zend_Cache_Frontend_' . $frontend;
- } else {
- $frontendClass = $frontend;
- }
- if (!$autoload) {
- $file = str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';
- if (!(self::_isReadable($file))) {
- self::throwException("file $file not found in include_path");
- }
- require_once $file;
- }
- }
- return new $frontendClass($frontendOptions);
- }
-
- /**
- * Throw an exception
- *
- * Note : for perf reasons, the "load" of Zend/Cache/Exception is dynamic
- * @param string $msg Message for the exception
- * @throws Zend_Cache_Exception
- */
- public static function throwException($msg, Exception $e = null)
- {
- // For perfs reasons, we use this dynamic inclusion
- require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception($msg, 0, $e);
- }
-
- /**
- * Normalize frontend and backend names to allow multiple words TitleCased
- *
- * @param string $name Name to normalize
- * @return string
- */
- protected static function _normalizeName($name)
- {
- $name = ucfirst(strtolower($name));
- $name = str_replace(array('-', '_', '.'), ' ', $name);
- $name = ucwords($name);
- $name = str_replace(' ', '', $name);
- if (stripos($name, 'ZendServer') === 0) {
- $name = 'ZendServer_' . substr($name, strlen('ZendServer'));
- }
-
- return $name;
- }
-
- /**
- * Returns TRUE if the $filename is readable, or FALSE otherwise.
- * This function uses the PHP include_path, where PHP's is_readable()
- * does not.
- *
- * Note : this method comes from Zend_Loader (see #ZF-2891 for details)
- *
- * @param string $filename
- * @return boolean
- */
- private static function _isReadable($filename)
- {
- if (!$fh = @fopen($filename, 'r', true)) {
- return false;
- }
- @fclose($fh);
- return true;
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend.php b/lib/zend/Zend/Cache/Backend.php
deleted file mode 100644
index 83f1af5f121ad..0000000000000
--- a/lib/zend/Zend/Cache/Backend.php
+++ /dev/null
@@ -1,288 +0,0 @@
- (int) lifetime :
- * - Cache lifetime (in seconds)
- * - If null, the cache is valid forever
- *
- * =====> (int) logging :
- * - if set to true, a logging is activated throw Zend_Log
- *
- * @var array directives
- */
- protected $_directives = array(
- 'lifetime' => 3600,
- 'logging' => false,
- 'logger' => null
- );
-
- /**
- * Available options
- *
- * @var array available options
- */
- protected $_options = array();
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- */
- public function __construct(array $options = array())
- {
- foreach ($options as $name => $value) {
- $this->setOption($name, $value);
- }
- }
-
- /**
- * Set the frontend directives
- *
- * @param array $directives Assoc of directives
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setDirectives($directives)
- {
- if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array');
- while (list($name, $value) = each($directives)) {
- if (!is_string($name)) {
- Zend_Cache::throwException("Incorrect option name : $name");
- }
- $name = strtolower($name);
- if (array_key_exists($name, $this->_directives)) {
- $this->_directives[$name] = $value;
- }
-
- }
-
- $this->_loggerSanity();
- }
-
- /**
- * Set an option
- *
- * @param string $name
- * @param mixed $value
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if (!is_string($name)) {
- Zend_Cache::throwException("Incorrect option name : $name");
- }
- $name = strtolower($name);
- if (array_key_exists($name, $this->_options)) {
- $this->_options[$name] = $value;
- }
- }
-
- /**
- * Returns an option
- *
- * @param string $name Optional, the options name to return
- * @throws Zend_Cache_Exceptions
- * @return mixed
- */
- public function getOption($name)
- {
- $name = strtolower($name);
-
- if (array_key_exists($name, $this->_options)) {
- return $this->_options[$name];
- }
-
- if (array_key_exists($name, $this->_directives)) {
- return $this->_directives[$name];
- }
-
- Zend_Cache::throwException("Incorrect option name : {$name}");
- }
-
- /**
- * Get the life time
- *
- * if $specificLifetime is not false, the given specific life time is used
- * else, the global lifetime is used
- *
- * @param int $specificLifetime
- * @return int Cache life time
- */
- public function getLifetime($specificLifetime)
- {
- if ($specificLifetime === false) {
- return $this->_directives['lifetime'];
- }
- return $specificLifetime;
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * DEPRECATED : use getCapabilities() instead
- *
- * @deprecated
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return true;
- }
-
- /**
- * Determine system TMP directory and detect if we have read access
- *
- * inspired from Zend_File_Transfer_Adapter_Abstract
- *
- * @return string
- * @throws Zend_Cache_Exception if unable to determine directory
- */
- public function getTmpDir()
- {
- $tmpdir = array();
- foreach (array($_ENV, $_SERVER) as $tab) {
- foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
- if (isset($tab[$key]) && is_string($tab[$key])) {
- if (($key == 'windir') or ($key == 'SystemRoot')) {
- $dir = realpath($tab[$key] . '\\temp');
- } else {
- $dir = realpath($tab[$key]);
- }
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- }
- }
- $upload = ini_get('upload_tmp_dir');
- if ($upload) {
- $dir = realpath($upload);
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- if (function_exists('sys_get_temp_dir')) {
- $dir = sys_get_temp_dir();
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- // Attemp to detect by creating a temporary file
- $tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
- if ($tempFile) {
- $dir = realpath(dirname($tempFile));
- unlink($tempFile);
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- if ($this->_isGoodTmpDir('/tmp')) {
- return '/tmp';
- }
- if ($this->_isGoodTmpDir('\\temp')) {
- return '\\temp';
- }
- Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually');
- }
-
- /**
- * Verify if the given temporary directory is readable and writable
- *
- * @param string $dir temporary directory
- * @return boolean true if the directory is ok
- */
- protected function _isGoodTmpDir($dir)
- {
- if (is_readable($dir)) {
- if (is_writable($dir)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Make sure if we enable logging that the Zend_Log class
- * is available.
- * Create a default log object if none is set.
- *
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _loggerSanity()
- {
- if (!isset($this->_directives['logging']) || !$this->_directives['logging']) {
- return;
- }
-
- if (isset($this->_directives['logger'])) {
- if ($this->_directives['logger'] instanceof Zend_Log) {
- return;
- }
- Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
- }
-
- // Create a default logger to the standard output stream
- require_once 'Zend/Log.php';
- require_once 'Zend/Log/Writer/Stream.php';
- require_once 'Zend/Log/Filter/Priority.php';
- $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
- $logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<='));
- $this->_directives['logger'] = $logger;
- }
-
- /**
- * Log a message at the WARN (4) priority.
- *
- * @param string $message
- * @param int $priority
- * @return void
- */
- protected function _log($message, $priority = 4)
- {
- if (!$this->_directives['logging']) {
- return;
- }
-
- if (!isset($this->_directives['logger'])) {
- Zend_Cache::throwException('Logging is enabled but logger is not set.');
- }
- $logger = $this->_directives['logger'];
- if (!$logger instanceof Zend_Log) {
- Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
- }
- $logger->log($message, $priority);
- }
-}
diff --git a/lib/zend/Zend/Cache/Backend/Apc.php b/lib/zend/Zend/Cache/Backend/Apc.php
deleted file mode 100644
index 5a09becdcfdb9..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Apc.php
+++ /dev/null
@@ -1,355 +0,0 @@
- infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- $result = apc_store($id, array($data, time(), $lifetime), $lifetime);
- if (count($tags) > 0) {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- }
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- return apc_delete($id);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- return apc_clear_cache('user');
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_APC_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * DEPRECATED : use getCapabilities() instead
- *
- * @deprecated
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $mem = apc_sma_info(true);
- $memSize = $mem['num_seg'] * $mem['seg_size'];
- $memAvailable= $mem['avail_mem'];
- $memUsed = $memSize - $memAvailable;
- if ($memSize == 0) {
- Zend_Cache::throwException('can\'t get apc memory size');
- }
- if ($memUsed > $memSize) {
- return 100;
- }
- return ((int) (100. * ($memUsed / $memSize)));
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $ids = array();
- $iterator = new APCIterator('user', null, APC_ITER_KEY);
- foreach ($iterator as $item) {
- $ids[] = $item['key'];
- }
-
- return $ids;
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tmp = apc_fetch($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- return array(
- 'expire' => $mtime + $lifetime,
- 'tags' => array(),
- 'mtime' => $mtime
- );
- }
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $tmp = apc_fetch($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
- if ($newLifetime <=0) {
- return false;
- }
- apc_store($id, array($data, time(), $newLifetime), $newLifetime);
- return true;
- }
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => false,
- 'tags' => false,
- 'expired_read' => false,
- 'priority' => false,
- 'infinite_lifetime' => false,
- 'get_list' => true
- );
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/BlackHole.php b/lib/zend/Zend/Cache/Backend/BlackHole.php
deleted file mode 100644
index 0fe1c9d05251b..0000000000000
--- a/lib/zend/Zend/Cache/Backend/BlackHole.php
+++ /dev/null
@@ -1,250 +0,0 @@
- infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- return true;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => remove too old cache entries ($tags is not used)
- * 'matchingTag' => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * 'notMatchingTag' => remove cache entries not matching one of the given tags
- * ($tags can be an array of strings or a single string)
- * 'matchingAnyTag' => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode clean mode
- * @param tags array $tags array of tags
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- return true;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return array();
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- return array();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- * @throws Zend_Cache_Exception
- */
- public function getFillingPercentage()
- {
- return 0;
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => true,
- 'priority' => true,
- 'infinite_lifetime' => true,
- 'get_list' => true,
- );
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id cache id
- */
- public function ___expire($id)
- {
- }
-}
diff --git a/lib/zend/Zend/Cache/Backend/ExtendedInterface.php b/lib/zend/Zend/Cache/Backend/ExtendedInterface.php
deleted file mode 100644
index 0dd8bdf414cd8..0000000000000
--- a/lib/zend/Zend/Cache/Backend/ExtendedInterface.php
+++ /dev/null
@@ -1,126 +0,0 @@
- (string) cache_dir :
- * - Directory where to put the cache files
- *
- * =====> (boolean) file_locking :
- * - Enable / disable file_locking
- * - Can avoid cache corruption under bad circumstances but it doesn't work on multithread
- * webservers and on NFS filesystems for example
- *
- * =====> (boolean) read_control :
- * - Enable / disable read control
- * - If enabled, a control key is embeded in cache file and this key is compared with the one
- * calculated after the reading.
- *
- * =====> (string) read_control_type :
- * - Type of read control (only if read control is enabled). Available values are :
- * 'md5' for a md5 hash control (best but slowest)
- * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
- * 'adler32' for an adler32 hash control (excellent choice too, faster than crc32)
- * 'strlen' for a length only test (fastest)
- *
- * =====> (int) hashed_directory_level :
- * - Hashed directory level
- * - Set the hashed directory structure level. 0 means "no hashed directory
- * structure", 1 means "one level of directory", 2 means "two levels"...
- * This option can speed up the cache only when you have many thousands of
- * cache file. Only specific benchs can help you to choose the perfect value
- * for you. Maybe, 1 or 2 is a good start.
- *
- * =====> (int) hashed_directory_umask :
- * - deprecated
- * - Permissions for hashed directory structure
- *
- * =====> (int) hashed_directory_perm :
- * - Permissions for hashed directory structure
- *
- * =====> (string) file_name_prefix :
- * - prefix for cache files
- * - be really carefull with this option because a too generic value in a system cache dir
- * (like /tmp) can cause disasters when cleaning the cache
- *
- * =====> (int) cache_file_umask :
- * - deprecated
- * - Permissions for cache files
- *
- * =====> (int) cache_file_perm :
- * - Permissions for cache files
- *
- * =====> (int) metatadatas_array_max_size :
- * - max size for the metadatas array (don't change this value unless you
- * know what you are doing)
- *
- * @var array available options
- */
- protected $_options = array(
- 'cache_dir' => null,
- 'file_locking' => true,
- 'read_control' => true,
- 'read_control_type' => 'crc32',
- 'hashed_directory_level' => 0,
- 'hashed_directory_perm' => 0700,
- 'file_name_prefix' => 'zend_cache',
- 'cache_file_perm' => 0600,
- 'metadatas_array_max_size' => 100
- );
-
- /**
- * Array of metadatas (each item is an associative array)
- *
- * @var array
- */
- protected $_metadatasArray = array();
-
-
- /**
- * Constructor
- *
- * @param array $options associative array of options
- * @throws Zend_Cache_Exception
- */
- public function __construct(array $options = array())
- {
- parent::__construct($options);
- if ($this->_options['cache_dir'] !== null) { // particular case for this option
- $this->setCacheDir($this->_options['cache_dir']);
- } else {
- $this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false);
- }
- if (isset($this->_options['file_name_prefix'])) { // particular case for this option
- if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) {
- Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]');
- }
- }
- if ($this->_options['metadatas_array_max_size'] < 10) {
- Zend_Cache::throwException('Invalid metadatas_array_max_size, must be > 10');
- }
-
- if (isset($options['hashed_directory_umask'])) {
- // See #ZF-12047
- trigger_error("'hashed_directory_umask' is deprecated -> please use 'hashed_directory_perm' instead", E_USER_NOTICE);
- if (!isset($options['hashed_directory_perm'])) {
- $options['hashed_directory_perm'] = $options['hashed_directory_umask'];
- }
- }
- if (isset($options['hashed_directory_perm']) && is_string($options['hashed_directory_perm'])) {
- // See #ZF-4422
- $this->_options['hashed_directory_perm'] = octdec($this->_options['hashed_directory_perm']);
- }
-
- if (isset($options['cache_file_umask'])) {
- // See #ZF-12047
- trigger_error("'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", E_USER_NOTICE);
- if (!isset($options['cache_file_perm'])) {
- $options['cache_file_perm'] = $options['cache_file_umask'];
- }
- }
- if (isset($options['cache_file_perm']) && is_string($options['cache_file_perm'])) {
- // See #ZF-4422
- $this->_options['cache_file_perm'] = octdec($this->_options['cache_file_perm']);
- }
- }
-
- /**
- * Set the cache_dir (particular case of setOption() method)
- *
- * @param string $value
- * @param boolean $trailingSeparator If true, add a trailing separator is necessary
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setCacheDir($value, $trailingSeparator = true)
- {
- if (!is_dir($value)) {
- Zend_Cache::throwException(sprintf('cache_dir "%s" must be a directory', $value));
- }
- if (!is_writable($value)) {
- Zend_Cache::throwException(sprintf('cache_dir "%s" is not writable', $value));
- }
- if ($trailingSeparator) {
- // add a trailing DIRECTORY_SEPARATOR if necessary
- $value = rtrim(realpath($value), '\\/') . DIRECTORY_SEPARATOR;
- }
- $this->_options['cache_dir'] = $value;
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id cache id
- * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- if (!($this->_test($id, $doNotTestCacheValidity))) {
- // The cache is not hit !
- return false;
- }
- $metadatas = $this->_getMetadatas($id);
- $file = $this->_file($id);
- $data = $this->_fileGetContents($file);
- if ($this->_options['read_control']) {
- $hashData = $this->_hash($data, $this->_options['read_control_type']);
- $hashControl = $metadatas['hash'];
- if ($hashData != $hashControl) {
- // Problem detected by the read control !
- $this->_log('Zend_Cache_Backend_File::load() / read_control : stored hash and computed hash do not match');
- $this->remove($id);
- return false;
- }
- }
- return $data;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- clearstatcache();
- return $this->_test($id, false);
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param boolean|int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- clearstatcache();
- $file = $this->_file($id);
- $path = $this->_path($id);
- if ($this->_options['hashed_directory_level'] > 0) {
- if (!is_writable($path)) {
- // maybe, we just have to build the directory structure
- $this->_recursiveMkdirAndChmod($id);
- }
- if (!is_writable($path)) {
- return false;
- }
- }
- if ($this->_options['read_control']) {
- $hash = $this->_hash($data, $this->_options['read_control_type']);
- } else {
- $hash = '';
- }
- $metadatas = array(
- 'hash' => $hash,
- 'mtime' => time(),
- 'expire' => $this->_expireTime($this->getLifetime($specificLifetime)),
- 'tags' => $tags
- );
- $res = $this->_setMetadatas($id, $metadatas);
- if (!$res) {
- $this->_log('Zend_Cache_Backend_File::save() / error on saving metadata');
- return false;
- }
- $res = $this->_filePutContents($file, $data);
- return $res;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- $file = $this->_file($id);
- $boolRemove = $this->_remove($file);
- $boolMetadata = $this->_delMetadatas($id);
- return $boolMetadata && $boolRemove;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- *
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- // We use this protected method to hide the recursive stuff
- clearstatcache();
- return $this->_clean($this->_options['cache_dir'], $mode, $tags);
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return $this->_get($this->_options['cache_dir'], 'ids', array());
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return $this->_get($this->_options['cache_dir'], 'tags', array());
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- return $this->_get($this->_options['cache_dir'], 'matching', $tags);
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- return $this->_get($this->_options['cache_dir'], 'notMatching', $tags);
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- return $this->_get($this->_options['cache_dir'], 'matchingAny', $tags);
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $free = disk_free_space($this->_options['cache_dir']);
- $total = disk_total_space($this->_options['cache_dir']);
- if ($total == 0) {
- Zend_Cache::throwException('can\'t get disk_total_space');
- } else {
- if ($free >= $total) {
- return 100;
- }
- return ((int) (100. * ($total - $free) / $total));
- }
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $metadatas = $this->_getMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- if (time() > $metadatas['expire']) {
- return false;
- }
- return array(
- 'expire' => $metadatas['expire'],
- 'tags' => $metadatas['tags'],
- 'mtime' => $metadatas['mtime']
- );
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $metadatas = $this->_getMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- if (time() > $metadatas['expire']) {
- return false;
- }
- $newMetadatas = array(
- 'hash' => $metadatas['hash'],
- 'mtime' => time(),
- 'expire' => $metadatas['expire'] + $extraLifetime,
- 'tags' => $metadatas['tags']
- );
- $res = $this->_setMetadatas($id, $newMetadatas);
- if (!$res) {
- return false;
- }
- return true;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => true,
- 'priority' => false,
- 'infinite_lifetime' => true,
- 'get_list' => true
- );
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id cache id
- */
- public function ___expire($id)
- {
- $metadatas = $this->_getMetadatas($id);
- if ($metadatas) {
- $metadatas['expire'] = 1;
- $this->_setMetadatas($id, $metadatas);
- }
- }
-
- /**
- * Get a metadatas record
- *
- * @param string $id Cache id
- * @return array|false Associative array of metadatas
- */
- protected function _getMetadatas($id)
- {
- if (isset($this->_metadatasArray[$id])) {
- return $this->_metadatasArray[$id];
- } else {
- $metadatas = $this->_loadMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- $this->_setMetadatas($id, $metadatas, false);
- return $metadatas;
- }
- }
-
- /**
- * Set a metadatas record
- *
- * @param string $id Cache id
- * @param array $metadatas Associative array of metadatas
- * @param boolean $save optional pass false to disable saving to file
- * @return boolean True if no problem
- */
- protected function _setMetadatas($id, $metadatas, $save = true)
- {
- if (count($this->_metadatasArray) >= $this->_options['metadatas_array_max_size']) {
- $n = (int) ($this->_options['metadatas_array_max_size'] / 10);
- $this->_metadatasArray = array_slice($this->_metadatasArray, $n);
- }
- if ($save) {
- $result = $this->_saveMetadatas($id, $metadatas);
- if (!$result) {
- return false;
- }
- }
- $this->_metadatasArray[$id] = $metadatas;
- return true;
- }
-
- /**
- * Drop a metadata record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- protected function _delMetadatas($id)
- {
- if (isset($this->_metadatasArray[$id])) {
- unset($this->_metadatasArray[$id]);
- }
- $file = $this->_metadatasFile($id);
- return $this->_remove($file);
- }
-
- /**
- * Clear the metadatas array
- *
- * @return void
- */
- protected function _cleanMetadatas()
- {
- $this->_metadatasArray = array();
- }
-
- /**
- * Load metadatas from disk
- *
- * @param string $id Cache id
- * @return array|false Metadatas associative array
- */
- protected function _loadMetadatas($id)
- {
- $file = $this->_metadatasFile($id);
- $result = $this->_fileGetContents($file);
- if (!$result) {
- return false;
- }
- $tmp = @unserialize($result);
- return $tmp;
- }
-
- /**
- * Save metadatas to disk
- *
- * @param string $id Cache id
- * @param array $metadatas Associative array
- * @return boolean True if no problem
- */
- protected function _saveMetadatas($id, $metadatas)
- {
- $file = $this->_metadatasFile($id);
- $result = $this->_filePutContents($file, serialize($metadatas));
- if (!$result) {
- return false;
- }
- return true;
- }
-
- /**
- * Make and return a file name (with path) for metadatas
- *
- * @param string $id Cache id
- * @return string Metadatas file name (with path)
- */
- protected function _metadatasFile($id)
- {
- $path = $this->_path($id);
- $fileName = $this->_idToFileName('internal-metadatas---' . $id);
- return $path . $fileName;
- }
-
- /**
- * Check if the given filename is a metadatas one
- *
- * @param string $fileName File name
- * @return boolean True if it's a metadatas one
- */
- protected function _isMetadatasFile($fileName)
- {
- $id = $this->_fileNameToId($fileName);
- if (substr($id, 0, 21) == 'internal-metadatas---') {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Remove a file
- *
- * If we can't remove the file (because of locks or any problem), we will touch
- * the file to invalidate it
- *
- * @param string $file Complete file path
- * @return boolean True if ok
- */
- protected function _remove($file)
- {
- if (!is_file($file)) {
- return false;
- }
- if (!@unlink($file)) {
- # we can't remove the file (because of locks or any problem)
- $this->_log("Zend_Cache_Backend_File::_remove() : we can't remove $file");
- return false;
- }
- return true;
- }
-
- /**
- * Clean some cache records (protected method used for recursive stuff)
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $dir Directory to clean
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- protected function _clean($dir, $mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- if (!is_dir($dir)) {
- return false;
- }
- $result = true;
- $prefix = $this->_options['file_name_prefix'];
- $glob = @glob($dir . $prefix . '--*');
- if ($glob === false) {
- // On some systems it is impossible to distinguish between empty match and an error.
- return true;
- }
- $metadataFiles = array();
- foreach ($glob as $file) {
- if (is_file($file)) {
- $fileName = basename($file);
- if ($this->_isMetadatasFile($fileName)) {
- // In CLEANING_MODE_ALL, we drop anything, even remainings old metadatas files.
- // To do that, we need to save the list of the metadata files first.
- if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
- $metadataFiles[] = $file;
- }
- continue;
- }
- $id = $this->_fileNameToId($fileName);
- $metadatas = $this->_getMetadatas($id);
- if ($metadatas === FALSE) {
- $metadatas = array('expire' => 1, 'tags' => array());
- }
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $result = $result && $this->remove($id);
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- if (time() > $metadatas['expire']) {
- $result = $this->remove($id) && $result;
- }
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $matching = true;
- foreach ($tags as $tag) {
- if (!in_array($tag, $metadatas['tags'])) {
- $matching = false;
- break;
- }
- }
- if ($matching) {
- $result = $this->remove($id) && $result;
- }
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if (!$matching) {
- $result = $this->remove($id) && $result;
- }
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if ($matching) {
- $result = $this->remove($id) && $result;
- }
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
- if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
- // Recursive call
- $result = $this->_clean($file . DIRECTORY_SEPARATOR, $mode, $tags) && $result;
- if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
- // we try to drop the structure too
- @rmdir($file);
- }
- }
- }
-
- // cycle through metadataFiles and delete orphaned ones
- foreach ($metadataFiles as $file) {
- if (file_exists($file)) {
- $result = $this->_remove($file) && $result;
- }
- }
-
- return $result;
- }
-
- protected function _get($dir, $mode, $tags = array())
- {
- if (!is_dir($dir)) {
- return false;
- }
- $result = array();
- $prefix = $this->_options['file_name_prefix'];
- $glob = @glob($dir . $prefix . '--*');
- if ($glob === false) {
- // On some systems it is impossible to distinguish between empty match and an error.
- return array();
- }
- foreach ($glob as $file) {
- if (is_file($file)) {
- $fileName = basename($file);
- $id = $this->_fileNameToId($fileName);
- $metadatas = $this->_getMetadatas($id);
- if ($metadatas === FALSE) {
- continue;
- }
- if (time() > $metadatas['expire']) {
- continue;
- }
- switch ($mode) {
- case 'ids':
- $result[] = $id;
- break;
- case 'tags':
- $result = array_unique(array_merge($result, $metadatas['tags']));
- break;
- case 'matching':
- $matching = true;
- foreach ($tags as $tag) {
- if (!in_array($tag, $metadatas['tags'])) {
- $matching = false;
- break;
- }
- }
- if ($matching) {
- $result[] = $id;
- }
- break;
- case 'notMatching':
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if (!$matching) {
- $result[] = $id;
- }
- break;
- case 'matchingAny':
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if ($matching) {
- $result[] = $id;
- }
- break;
- default:
- Zend_Cache::throwException('Invalid mode for _get() method');
- break;
- }
- }
- if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
- // Recursive call
- $recursiveRs = $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags);
- if ($recursiveRs === false) {
- $this->_log('Zend_Cache_Backend_File::_get() / recursive call : can\'t list entries of "'.$file.'"');
- } else {
- $result = array_unique(array_merge($result, $recursiveRs));
- }
- }
- }
- return array_unique($result);
- }
-
- /**
- * Compute & return the expire time
- *
- * @param int $lifetime
- * @return int expire time (unix timestamp)
- */
- protected function _expireTime($lifetime)
- {
- if ($lifetime === null) {
- return 9999999999;
- }
- return time() + $lifetime;
- }
-
- /**
- * Make a control key with the string containing datas
- *
- * @param string $data Data
- * @param string $controlType Type of control 'md5', 'crc32' or 'strlen'
- * @throws Zend_Cache_Exception
- * @return string Control key
- */
- protected function _hash($data, $controlType)
- {
- switch ($controlType) {
- case 'md5':
- return md5($data);
- case 'crc32':
- return crc32($data);
- case 'strlen':
- return strlen($data);
- case 'adler32':
- return hash('adler32', $data);
- default:
- Zend_Cache::throwException("Incorrect hash function : $controlType");
- }
- }
-
- /**
- * Transform a cache id into a file name and return it
- *
- * @param string $id Cache id
- * @return string File name
- */
- protected function _idToFileName($id)
- {
- $prefix = $this->_options['file_name_prefix'];
- $result = $prefix . '---' . $id;
- return $result;
- }
-
- /**
- * Make and return a file name (with path)
- *
- * @param string $id Cache id
- * @return string File name (with path)
- */
- protected function _file($id)
- {
- $path = $this->_path($id);
- $fileName = $this->_idToFileName($id);
- return $path . $fileName;
- }
-
- /**
- * Return the complete directory path of a filename (including hashedDirectoryStructure)
- *
- * @param string $id Cache id
- * @param boolean $parts if true, returns array of directory parts instead of single string
- * @return string Complete directory path
- */
- protected function _path($id, $parts = false)
- {
- $partsArray = array();
- $root = $this->_options['cache_dir'];
- $prefix = $this->_options['file_name_prefix'];
- if ($this->_options['hashed_directory_level']>0) {
- $hash = hash('adler32', $id);
- for ($i=0 ; $i < $this->_options['hashed_directory_level'] ; $i++) {
- $root = $root . $prefix . '--' . substr($hash, 0, $i + 1) . DIRECTORY_SEPARATOR;
- $partsArray[] = $root;
- }
- }
- if ($parts) {
- return $partsArray;
- } else {
- return $root;
- }
- }
-
- /**
- * Make the directory strucuture for the given id
- *
- * @param string $id cache id
- * @return boolean true
- */
- protected function _recursiveMkdirAndChmod($id)
- {
- if ($this->_options['hashed_directory_level'] <=0) {
- return true;
- }
- $partsArray = $this->_path($id, true);
- foreach ($partsArray as $part) {
- if (!is_dir($part)) {
- @mkdir($part, $this->_options['hashed_directory_perm']);
- @chmod($part, $this->_options['hashed_directory_perm']); // see #ZF-320 (this line is required in some configurations)
- }
- }
- return true;
- }
-
- /**
- * Test if the given cache id is available (and still valid as a cache record)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return boolean|mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- protected function _test($id, $doNotTestCacheValidity)
- {
- $metadatas = $this->_getMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- if ($doNotTestCacheValidity || (time() <= $metadatas['expire'])) {
- return $metadatas['mtime'];
- }
- return false;
- }
-
- /**
- * Return the file content of the given file
- *
- * @param string $file File complete path
- * @return string File content (or false if problem)
- */
- protected function _fileGetContents($file)
- {
- $result = false;
- if (!is_file($file)) {
- return false;
- }
- $f = @fopen($file, 'rb');
- if ($f) {
- if ($this->_options['file_locking']) @flock($f, LOCK_SH);
- $result = stream_get_contents($f);
- if ($this->_options['file_locking']) @flock($f, LOCK_UN);
- @fclose($f);
- }
- return $result;
- }
-
- /**
- * Put the given string into the given file
- *
- * @param string $file File complete path
- * @param string $string String to put in file
- * @return boolean true if no problem
- */
- protected function _filePutContents($file, $string)
- {
- $result = false;
- $f = @fopen($file, 'ab+');
- if ($f) {
- if ($this->_options['file_locking']) @flock($f, LOCK_EX);
- fseek($f, 0);
- ftruncate($f, 0);
- $tmp = @fwrite($f, $string);
- if (!($tmp === FALSE)) {
- $result = true;
- }
- @fclose($f);
- }
- @chmod($file, $this->_options['cache_file_perm']);
- return $result;
- }
-
- /**
- * Transform a file name into cache id and return it
- *
- * @param string $fileName File name
- * @return string Cache id
- */
- protected function _fileNameToId($fileName)
- {
- $prefix = $this->_options['file_name_prefix'];
- return preg_replace('~^' . $prefix . '---(.*)$~', '$1', $fileName);
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/Interface.php b/lib/zend/Zend/Cache/Backend/Interface.php
deleted file mode 100644
index 1bd72d8c16361..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Interface.php
+++ /dev/null
@@ -1,99 +0,0 @@
- infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false);
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id);
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array());
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/Libmemcached.php b/lib/zend/Zend/Cache/Backend/Libmemcached.php
deleted file mode 100644
index 623e75776cc52..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Libmemcached.php
+++ /dev/null
@@ -1,484 +0,0 @@
- (array) servers :
- * an array of memcached server ; each memcached server is described by an associative array :
- * 'host' => (string) : the name of the memcached server
- * 'port' => (int) : the port of the memcached server
- * 'weight' => (int) : number of buckets to create for this server which in turn control its
- * probability of it being selected. The probability is relative to the total
- * weight of all servers.
- * =====> (array) client :
- * an array of memcached client options ; the memcached client is described by an associative array :
- * @see http://php.net/manual/memcached.constants.php
- * - The option name can be the name of the constant without the prefix 'OPT_'
- * or the integer value of this option constant
- *
- * @var array available options
- */
- protected $_options = array(
- 'servers' => array(array(
- 'host' => self::DEFAULT_HOST,
- 'port' => self::DEFAULT_PORT,
- 'weight' => self::DEFAULT_WEIGHT,
- )),
- 'client' => array()
- );
-
- /**
- * Memcached object
- *
- * @var mixed memcached object
- */
- protected $_memcache = null;
-
- /**
- * Constructor
- *
- * @param array $options associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- if (!extension_loaded('memcached')) {
- Zend_Cache::throwException('The memcached extension must be loaded for using this backend !');
- }
-
- // override default client options
- $this->_options['client'] = array(
- Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
- Memcached::OPT_HASH => Memcached::HASH_MD5,
- Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
- );
-
- parent::__construct($options);
-
- if (isset($this->_options['servers'])) {
- $value = $this->_options['servers'];
- if (isset($value['host'])) {
- // in this case, $value seems to be a simple associative array (one server only)
- $value = array(0 => $value); // let's transform it into a classical array of associative arrays
- }
- $this->setOption('servers', $value);
- }
- $this->_memcache = new Memcached;
-
- // setup memcached client options
- foreach ($this->_options['client'] as $name => $value) {
- $optId = null;
- if (is_int($name)) {
- $optId = $name;
- } else {
- $optConst = 'Memcached::OPT_' . strtoupper($name);
- if (defined($optConst)) {
- $optId = constant($optConst);
- } else {
- $this->_log("Unknown memcached client option '{$name}' ({$optConst})");
- }
- }
- if (null !== $optId) {
- if (!$this->_memcache->setOption($optId, $value)) {
- $this->_log("Setting memcached client option '{$optId}' failed");
- }
- }
- }
-
- // setup memcached servers
- $servers = array();
- foreach ($this->_options['servers'] as $server) {
- if (!array_key_exists('port', $server)) {
- $server['port'] = self::DEFAULT_PORT;
- }
- if (!array_key_exists('weight', $server)) {
- $server['weight'] = self::DEFAULT_WEIGHT;
- }
-
- $servers[] = array($server['host'], $server['port'], $server['weight']);
- }
- $this->_memcache->addServers($servers);
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $tmp = $this->_memcache->get($id);
- if (isset($tmp[0])) {
- return $tmp[0];
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id Cache id
- * @return int|false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $tmp = $this->_memcache->get($id);
- if (isset($tmp[0], $tmp[1])) {
- return (int)$tmp[1];
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean True if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
-
- // ZF-8856: using set because add needs a second request if item already exists
- $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $lifetime);
- if ($result === false) {
- $rsCode = $this->_memcache->getResultCode();
- $rsMsg = $this->_memcache->getResultMessage();
- $this->_log("Memcached::set() failed: [{$rsCode}] {$rsMsg}");
- }
-
- if (count($tags) > 0) {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
- }
-
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- return $this->_memcache->delete($id);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- return $this->_memcache->flush();
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Libmemcached::clean() : CLEANING_MODE_OLD is unsupported by the Libmemcached backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_LIBMEMCACHED_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
- /**
- * Set the frontend directives
- *
- * @param array $directives Assoc of directives
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setDirectives($directives)
- {
- parent::setDirectives($directives);
- $lifetime = $this->getLifetime(false);
- if ($lifetime > 2592000) {
- // #ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds)
- $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime');
- }
- if ($lifetime === null) {
- // #ZF-4614 : we tranform null to zero to get the maximal lifetime
- parent::setDirectives(array('lifetime' => 0));
- }
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $this->_log("Zend_Cache_Backend_Libmemcached::save() : getting the list of cache ids is unsupported by the Libmemcached backend");
- return array();
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $mems = $this->_memcache->getStats();
- if ($mems === false) {
- return 0;
- }
-
- $memSize = null;
- $memUsed = null;
- foreach ($mems as $key => $mem) {
- if ($mem === false) {
- $this->_log('can\'t get stat from ' . $key);
- continue;
- }
-
- $eachSize = $mem['limit_maxbytes'];
- $eachUsed = $mem['bytes'];
- if ($eachUsed > $eachSize) {
- $eachUsed = $eachSize;
- }
-
- $memSize += $eachSize;
- $memUsed += $eachUsed;
- }
-
- if ($memSize === null || $memUsed === null) {
- Zend_Cache::throwException('Can\'t get filling percentage');
- }
-
- return ((int) (100. * ($memUsed / $memSize)));
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tmp = $this->_memcache->get($id);
- if (isset($tmp[0], $tmp[1], $tmp[2])) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- $lifetime = $tmp[2];
- return array(
- 'expire' => $mtime + $lifetime,
- 'tags' => array(),
- 'mtime' => $mtime
- );
- }
-
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $tmp = $this->_memcache->get($id);
- if (isset($tmp[0], $tmp[1], $tmp[2])) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- $lifetime = $tmp[2];
- $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
- if ($newLifetime <=0) {
- return false;
- }
- // #ZF-5702 : we try replace() first becase set() seems to be slower
- if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $newLifetime))) {
- $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $newLifetime);
- if ($result === false) {
- $rsCode = $this->_memcache->getResultCode();
- $rsMsg = $this->_memcache->getResultMessage();
- $this->_log("Memcached::set() failed: [{$rsCode}] {$rsMsg}");
- }
- }
- return $result;
- }
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => false,
- 'tags' => false,
- 'expired_read' => false,
- 'priority' => false,
- 'infinite_lifetime' => false,
- 'get_list' => false
- );
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/Memcached.php b/lib/zend/Zend/Cache/Backend/Memcached.php
deleted file mode 100644
index 9cb9916dd8713..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Memcached.php
+++ /dev/null
@@ -1,509 +0,0 @@
- (array) servers :
- * an array of memcached server ; each memcached server is described by an associative array :
- * 'host' => (string) : the name of the memcached server
- * 'port' => (int) : the port of the memcached server
- * 'persistent' => (bool) : use or not persistent connections to this memcached server
- * 'weight' => (int) : number of buckets to create for this server which in turn control its
- * probability of it being selected. The probability is relative to the total
- * weight of all servers.
- * 'timeout' => (int) : value in seconds which will be used for connecting to the daemon. Think twice
- * before changing the default value of 1 second - you can lose all the
- * advantages of caching if your connection is too slow.
- * 'retry_interval' => (int) : controls how often a failed server will be retried, the default value
- * is 15 seconds. Setting this parameter to -1 disables automatic retry.
- * 'status' => (bool) : controls if the server should be flagged as online.
- * 'failure_callback' => (callback) : Allows the user to specify a callback function to run upon
- * encountering an error. The callback is run before failover
- * is attempted. The function takes two parameters, the hostname
- * and port of the failed server.
- *
- * =====> (boolean) compression :
- * true if you want to use on-the-fly compression
- *
- * =====> (boolean) compatibility :
- * true if you use old memcache server or extension
- *
- * @var array available options
- */
- protected $_options = array(
- 'servers' => array(array(
- 'host' => self::DEFAULT_HOST,
- 'port' => self::DEFAULT_PORT,
- 'persistent' => self::DEFAULT_PERSISTENT,
- 'weight' => self::DEFAULT_WEIGHT,
- 'timeout' => self::DEFAULT_TIMEOUT,
- 'retry_interval' => self::DEFAULT_RETRY_INTERVAL,
- 'status' => self::DEFAULT_STATUS,
- 'failure_callback' => self::DEFAULT_FAILURE_CALLBACK
- )),
- 'compression' => false,
- 'compatibility' => false,
- );
-
- /**
- * Memcache object
- *
- * @var mixed memcache object
- */
- protected $_memcache = null;
-
- /**
- * Constructor
- *
- * @param array $options associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- if (!extension_loaded('memcache')) {
- Zend_Cache::throwException('The memcache extension must be loaded for using this backend !');
- }
- parent::__construct($options);
- if (isset($this->_options['servers'])) {
- $value= $this->_options['servers'];
- if (isset($value['host'])) {
- // in this case, $value seems to be a simple associative array (one server only)
- $value = array(0 => $value); // let's transform it into a classical array of associative arrays
- }
- $this->setOption('servers', $value);
- }
- $this->_memcache = new Memcache;
- foreach ($this->_options['servers'] as $server) {
- if (!array_key_exists('port', $server)) {
- $server['port'] = self::DEFAULT_PORT;
- }
- if (!array_key_exists('persistent', $server)) {
- $server['persistent'] = self::DEFAULT_PERSISTENT;
- }
- if (!array_key_exists('weight', $server)) {
- $server['weight'] = self::DEFAULT_WEIGHT;
- }
- if (!array_key_exists('timeout', $server)) {
- $server['timeout'] = self::DEFAULT_TIMEOUT;
- }
- if (!array_key_exists('retry_interval', $server)) {
- $server['retry_interval'] = self::DEFAULT_RETRY_INTERVAL;
- }
- if (!array_key_exists('status', $server)) {
- $server['status'] = self::DEFAULT_STATUS;
- }
- if (!array_key_exists('failure_callback', $server)) {
- $server['failure_callback'] = self::DEFAULT_FAILURE_CALLBACK;
- }
- if ($this->_options['compatibility']) {
- // No status for compatibility mode (#ZF-5887)
- $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
- $server['weight'], $server['timeout'],
- $server['retry_interval']);
- } else {
- $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
- $server['weight'], $server['timeout'],
- $server['retry_interval'],
- $server['status'], $server['failure_callback']);
- }
- }
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp) && isset($tmp[0])) {
- return $tmp[0];
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id Cache id
- * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp)) {
- return $tmp[1];
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean True if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- if ($this->_options['compression']) {
- $flag = MEMCACHE_COMPRESSED;
- } else {
- $flag = 0;
- }
-
- // ZF-8856: using set because add needs a second request if item already exists
- $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime);
-
- if (count($tags) > 0) {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- }
-
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- return $this->_memcache->delete($id, 0);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- return $this->_memcache->flush();
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Memcached::clean() : CLEANING_MODE_OLD is unsupported by the Memcached backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_MEMCACHED_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
- /**
- * Set the frontend directives
- *
- * @param array $directives Assoc of directives
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setDirectives($directives)
- {
- parent::setDirectives($directives);
- $lifetime = $this->getLifetime(false);
- if ($lifetime > 2592000) {
- // #ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds)
- $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime');
- }
- if ($lifetime === null) {
- // #ZF-4614 : we tranform null to zero to get the maximal lifetime
- parent::setDirectives(array('lifetime' => 0));
- }
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $this->_log("Zend_Cache_Backend_Memcached::save() : getting the list of cache ids is unsupported by the Memcache backend");
- return array();
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $mems = $this->_memcache->getExtendedStats();
-
- $memSize = null;
- $memUsed = null;
- foreach ($mems as $key => $mem) {
- if ($mem === false) {
- $this->_log('can\'t get stat from ' . $key);
- continue;
- }
-
- $eachSize = $mem['limit_maxbytes'];
-
- /**
- * Couchbase 1.x uses 'mem_used' instead of 'bytes'
- * @see https://www.couchbase.com/issues/browse/MB-3466
- */
- $eachUsed = isset($mem['bytes']) ? $mem['bytes'] : $mem['mem_used'];
- if ($eachUsed > $eachSize) {
- $eachUsed = $eachSize;
- }
-
- $memSize += $eachSize;
- $memUsed += $eachUsed;
- }
-
- if ($memSize === null || $memUsed === null) {
- Zend_Cache::throwException('Can\'t get filling percentage');
- }
-
- return ((int) (100. * ($memUsed / $memSize)));
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- return array(
- 'expire' => $mtime + $lifetime,
- 'tags' => array(),
- 'mtime' => $mtime
- );
- }
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- if ($this->_options['compression']) {
- $flag = MEMCACHE_COMPRESSED;
- } else {
- $flag = 0;
- }
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
- if ($newLifetime <=0) {
- return false;
- }
- // #ZF-5702 : we try replace() first becase set() seems to be slower
- if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $flag, $newLifetime))) {
- $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime);
- }
- return $result;
- }
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => false,
- 'tags' => false,
- 'expired_read' => false,
- 'priority' => false,
- 'infinite_lifetime' => false,
- 'get_list' => false
- );
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/Sqlite.php b/lib/zend/Zend/Cache/Backend/Sqlite.php
deleted file mode 100644
index 3e8ac8276b93f..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Sqlite.php
+++ /dev/null
@@ -1,678 +0,0 @@
- (string) cache_db_complete_path :
- * - the complete path (filename included) of the SQLITE database
- *
- * ====> (int) automatic_vacuum_factor :
- * - Disable / Tune the automatic vacuum process
- * - The automatic vacuum process defragment the database file (and make it smaller)
- * when a clean() or delete() is called
- * 0 => no automatic vacuum
- * 1 => systematic vacuum (when delete() or clean() methods are called)
- * x (integer) > 1 => automatic vacuum randomly 1 times on x clean() or delete()
- *
- * @var array Available options
- */
- protected $_options = array(
- 'cache_db_complete_path' => null,
- 'automatic_vacuum_factor' => 10
- );
-
- /**
- * DB ressource
- *
- * @var mixed $_db
- */
- private $_db = null;
-
- /**
- * Boolean to store if the structure has benn checked or not
- *
- * @var boolean $_structureChecked
- */
- private $_structureChecked = false;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- parent::__construct($options);
- if ($this->_options['cache_db_complete_path'] === null) {
- Zend_Cache::throwException('cache_db_complete_path option has to set');
- }
- if (!extension_loaded('sqlite')) {
- Zend_Cache::throwException("Cannot use SQLite storage because the 'sqlite' extension is not loaded in the current PHP environment");
- }
- $this->_getConnection();
- }
-
- /**
- * Destructor
- *
- * @return void
- */
- public function __destruct()
- {
- @sqlite_close($this->_getConnection());
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false Cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $this->_checkAndBuildStructure();
- $sql = "SELECT content FROM cache WHERE id='$id'";
- if (!$doNotTestCacheValidity) {
- $sql = $sql . " AND (expire=0 OR expire>" . time() . ')';
- }
- $result = $this->_query($sql);
- $row = @sqlite_fetch_array($result);
- if ($row) {
- return $row['content'];
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id Cache id
- * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $this->_checkAndBuildStructure();
- $sql = "SELECT lastModified FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
- $result = $this->_query($sql);
- $row = @sqlite_fetch_array($result);
- if ($row) {
- return ((int) $row['lastModified']);
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $this->_checkAndBuildStructure();
- $lifetime = $this->getLifetime($specificLifetime);
- $data = @sqlite_escape_string($data);
- $mktime = time();
- if ($lifetime === null) {
- $expire = 0;
- } else {
- $expire = $mktime + $lifetime;
- }
- $this->_query("DELETE FROM cache WHERE id='$id'");
- $sql = "INSERT INTO cache (id, content, lastModified, expire) VALUES ('$id', '$data', $mktime, $expire)";
- $res = $this->_query($sql);
- if (!$res) {
- $this->_log("Zend_Cache_Backend_Sqlite::save() : impossible to store the cache id=$id");
- return false;
- }
- $res = true;
- foreach ($tags as $tag) {
- $res = $this->_registerTag($id, $tag) && $res;
- }
- return $res;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- $this->_checkAndBuildStructure();
- $res = $this->_query("SELECT COUNT(*) AS nbr FROM cache WHERE id='$id'");
- $result1 = @sqlite_fetch_single($res);
- $result2 = $this->_query("DELETE FROM cache WHERE id='$id'");
- $result3 = $this->_query("DELETE FROM tag WHERE id='$id'");
- $this->_automaticVacuum();
- return ($result1 && $result2 && $result3);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- $this->_checkAndBuildStructure();
- $return = $this->_clean($mode, $tags);
- $this->_automaticVacuum();
- return $return;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $this->_checkAndBuildStructure();
- $res = $this->_query("SELECT id FROM cache WHERE (expire=0 OR expire>" . time() . ")");
- $result = array();
- while ($id = @sqlite_fetch_single($res)) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_checkAndBuildStructure();
- $res = $this->_query("SELECT DISTINCT(name) AS name FROM tag");
- $result = array();
- while ($id = @sqlite_fetch_single($res)) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $first = true;
- $ids = array();
- foreach ($tags as $tag) {
- $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'");
- if (!$res) {
- return array();
- }
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- $ids2 = array();
- foreach ($rows as $row) {
- $ids2[] = $row['id'];
- }
- if ($first) {
- $ids = $ids2;
- $first = false;
- } else {
- $ids = array_intersect($ids, $ids2);
- }
- }
- $result = array();
- foreach ($ids as $id) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $res = $this->_query("SELECT id FROM cache");
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- $result = array();
- foreach ($rows as $row) {
- $id = $row['id'];
- $matching = false;
- foreach ($tags as $tag) {
- $res = $this->_query("SELECT COUNT(*) AS nbr FROM tag WHERE name='$tag' AND id='$id'");
- if (!$res) {
- return array();
- }
- $nbr = (int) @sqlite_fetch_single($res);
- if ($nbr > 0) {
- $matching = true;
- }
- }
- if (!$matching) {
- $result[] = $id;
- }
- }
- return $result;
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $first = true;
- $ids = array();
- foreach ($tags as $tag) {
- $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'");
- if (!$res) {
- return array();
- }
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- $ids2 = array();
- foreach ($rows as $row) {
- $ids2[] = $row['id'];
- }
- if ($first) {
- $ids = $ids2;
- $first = false;
- } else {
- $ids = array_merge($ids, $ids2);
- }
- }
- $result = array();
- foreach ($ids as $id) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $dir = dirname($this->_options['cache_db_complete_path']);
- $free = disk_free_space($dir);
- $total = disk_total_space($dir);
- if ($total == 0) {
- Zend_Cache::throwException('can\'t get disk_total_space');
- } else {
- if ($free >= $total) {
- return 100;
- }
- return ((int) (100. * ($total - $free) / $total));
- }
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tags = array();
- $res = $this->_query("SELECT name FROM tag WHERE id='$id'");
- if ($res) {
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- foreach ($rows as $row) {
- $tags[] = $row['name'];
- }
- }
- $this->_query('CREATE TABLE cache (id TEXT PRIMARY KEY, content BLOB, lastModified INTEGER, expire INTEGER)');
- $res = $this->_query("SELECT lastModified,expire FROM cache WHERE id='$id'");
- if (!$res) {
- return false;
- }
- $row = @sqlite_fetch_array($res, SQLITE_ASSOC);
- return array(
- 'tags' => $tags,
- 'mtime' => $row['lastModified'],
- 'expire' => $row['expire']
- );
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $sql = "SELECT expire FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
- $res = $this->_query($sql);
- if (!$res) {
- return false;
- }
- $expire = @sqlite_fetch_single($res);
- $newExpire = $expire + $extraLifetime;
- $res = $this->_query("UPDATE cache SET lastModified=" . time() . ", expire=$newExpire WHERE id='$id'");
- if ($res) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => true,
- 'priority' => false,
- 'infinite_lifetime' => true,
- 'get_list' => true
- );
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id Cache id
- */
- public function ___expire($id)
- {
- $time = time() - 1;
- $this->_query("UPDATE cache SET lastModified=$time, expire=$time WHERE id='$id'");
- }
-
- /**
- * Return the connection resource
- *
- * If we are not connected, the connection is made
- *
- * @throws Zend_Cache_Exception
- * @return resource Connection resource
- */
- private function _getConnection()
- {
- if (is_resource($this->_db)) {
- return $this->_db;
- } else {
- $this->_db = @sqlite_open($this->_options['cache_db_complete_path']);
- if (!(is_resource($this->_db))) {
- Zend_Cache::throwException("Impossible to open " . $this->_options['cache_db_complete_path'] . " cache DB file");
- }
- return $this->_db;
- }
- }
-
- /**
- * Execute an SQL query silently
- *
- * @param string $query SQL query
- * @return mixed|false query results
- */
- private function _query($query)
- {
- $db = $this->_getConnection();
- if (is_resource($db)) {
- $res = @sqlite_query($db, $query);
- if ($res === false) {
- return false;
- } else {
- return $res;
- }
- }
- return false;
- }
-
- /**
- * Deal with the automatic vacuum process
- *
- * @return void
- */
- private function _automaticVacuum()
- {
- if ($this->_options['automatic_vacuum_factor'] > 0) {
- $rand = rand(1, $this->_options['automatic_vacuum_factor']);
- if ($rand == 1) {
- $this->_query('VACUUM');
- }
- }
- }
-
- /**
- * Register a cache id with the given tag
- *
- * @param string $id Cache id
- * @param string $tag Tag
- * @return boolean True if no problem
- */
- private function _registerTag($id, $tag) {
- $res = $this->_query("DELETE FROM TAG WHERE name='$tag' AND id='$id'");
- $res = $this->_query("INSERT INTO tag (name, id) VALUES ('$tag', '$id')");
- if (!$res) {
- $this->_log("Zend_Cache_Backend_Sqlite::_registerTag() : impossible to register tag=$tag on id=$id");
- return false;
- }
- return true;
- }
-
- /**
- * Build the database structure
- *
- * @return false
- */
- private function _buildStructure()
- {
- $this->_query('DROP INDEX tag_id_index');
- $this->_query('DROP INDEX tag_name_index');
- $this->_query('DROP INDEX cache_id_expire_index');
- $this->_query('DROP TABLE version');
- $this->_query('DROP TABLE cache');
- $this->_query('DROP TABLE tag');
- $this->_query('CREATE TABLE version (num INTEGER PRIMARY KEY)');
- $this->_query('CREATE TABLE cache (id TEXT PRIMARY KEY, content BLOB, lastModified INTEGER, expire INTEGER)');
- $this->_query('CREATE TABLE tag (name TEXT, id TEXT)');
- $this->_query('CREATE INDEX tag_id_index ON tag(id)');
- $this->_query('CREATE INDEX tag_name_index ON tag(name)');
- $this->_query('CREATE INDEX cache_id_expire_index ON cache(id, expire)');
- $this->_query('INSERT INTO version (num) VALUES (1)');
- }
-
- /**
- * Check if the database structure is ok (with the good version)
- *
- * @return boolean True if ok
- */
- private function _checkStructureVersion()
- {
- $result = $this->_query("SELECT num FROM version");
- if (!$result) return false;
- $row = @sqlite_fetch_array($result);
- if (!$row) {
- return false;
- }
- if (((int) $row['num']) != 1) {
- // old cache structure
- $this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped');
- return false;
- }
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean True if no problem
- */
- private function _clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $res1 = $this->_query('DELETE FROM cache');
- $res2 = $this->_query('DELETE FROM tag');
- return $res1 && $res2;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $mktime = time();
- $res1 = $this->_query("DELETE FROM tag WHERE id IN (SELECT id FROM cache WHERE expire>0 AND expire<=$mktime)");
- $res2 = $this->_query("DELETE FROM cache WHERE expire>0 AND expire<=$mktime");
- return $res1 && $res2;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $ids = $this->getIdsMatchingTags($tags);
- $result = true;
- foreach ($ids as $id) {
- $result = $this->remove($id) && $result;
- }
- return $result;
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $ids = $this->getIdsNotMatchingTags($tags);
- $result = true;
- foreach ($ids as $id) {
- $result = $this->remove($id) && $result;
- }
- return $result;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $ids = $this->getIdsMatchingAnyTags($tags);
- $result = true;
- foreach ($ids as $id) {
- $result = $this->remove($id) && $result;
- }
- return $result;
- break;
- default:
- break;
- }
- return false;
- }
-
- /**
- * Check if the database structure is ok (with the good version), if no : build it
- *
- * @throws Zend_Cache_Exception
- * @return boolean True if ok
- */
- private function _checkAndBuildStructure()
- {
- if (!($this->_structureChecked)) {
- if (!$this->_checkStructureVersion()) {
- $this->_buildStructure();
- if (!$this->_checkStructureVersion()) {
- Zend_Cache::throwException("Impossible to build cache structure in " . $this->_options['cache_db_complete_path']);
- }
- }
- $this->_structureChecked = true;
- }
- return true;
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/Static.php b/lib/zend/Zend/Cache/Backend/Static.php
deleted file mode 100644
index 9e3c99036fb8b..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Static.php
+++ /dev/null
@@ -1,579 +0,0 @@
- null,
- 'sub_dir' => 'html',
- 'file_extension' => '.html',
- 'index_filename' => 'index',
- 'file_locking' => true,
- 'cache_file_perm' => 0600,
- 'cache_directory_perm' => 0700,
- 'debug_header' => false,
- 'tag_cache' => null,
- 'disable_caching' => false
- );
-
- /**
- * Cache for handling tags
- * @var Zend_Cache_Core
- */
- protected $_tagCache = null;
-
- /**
- * Tagged items
- * @var array
- */
- protected $_tagged = null;
-
- /**
- * Interceptor child method to handle the case where an Inner
- * Cache object is being set since it's not supported by the
- * standard backend interface
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Cache_Backend_Static
- */
- public function setOption($name, $value)
- {
- if ($name == 'tag_cache') {
- $this->setInnerCache($value);
- } else {
- // See #ZF-12047 and #GH-91
- if ($name == 'cache_file_umask') {
- trigger_error(
- "'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead",
- E_USER_NOTICE
- );
-
- $name = 'cache_file_perm';
- }
- if ($name == 'cache_directory_umask') {
- trigger_error(
- "'cache_directory_umask' is deprecated -> please use 'cache_directory_perm' instead",
- E_USER_NOTICE
- );
-
- $name = 'cache_directory_perm';
- }
-
- parent::setOption($name, $value);
- }
- return $this;
- }
-
- /**
- * Retrieve any option via interception of the parent's statically held
- * options including the local option for a tag cache.
- *
- * @param string $name
- * @return mixed
- */
- public function getOption($name)
- {
- $name = strtolower($name);
-
- if ($name == 'tag_cache') {
- return $this->getInnerCache();
- }
-
- return parent::getOption($name);
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * Note : return value is always "string" (unserialization is done by the core not by the backend)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- if (($id = (string)$id) === '') {
- $id = $this->_detectId();
- } else {
- $id = $this->_decodeId($id);
- }
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
- if ($doNotTestCacheValidity) {
- $this->_log("Zend_Cache_Backend_Static::load() : \$doNotTestCacheValidity=true is unsupported by the Static backend");
- }
-
- $fileName = basename($id);
- if ($fileName === '') {
- $fileName = $this->_options['index_filename'];
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
- $file = rtrim($pathName, '/') . '/' . $fileName . $this->_options['file_extension'];
- if (file_exists($file)) {
- $content = file_get_contents($file);
- return $content;
- }
-
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return bool
- */
- public function test($id)
- {
- $id = $this->_decodeId($id);
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
-
- $fileName = basename($id);
- if ($fileName === '') {
- $fileName = $this->_options['index_filename'];
- }
- if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif (!$this->_tagged) {
- return false;
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
-
- // Switch extension if needed
- if (isset($this->_tagged[$id])) {
- $extension = $this->_tagged[$id]['extension'];
- } else {
- $extension = $this->_options['file_extension'];
- }
- $file = $pathName . '/' . $fileName . $extension;
- if (file_exists($file)) {
- return true;
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- if ($this->_options['disable_caching']) {
- return true;
- }
- $extension = null;
- if ($this->_isSerialized($data)) {
- $data = unserialize($data);
- $extension = '.' . ltrim($data[1], '.');
- $data = $data[0];
- }
-
- clearstatcache();
- if (($id = (string)$id) === '') {
- $id = $this->_detectId();
- } else {
- $id = $this->_decodeId($id);
- }
-
- $fileName = basename($id);
- if ($fileName === '') {
- $fileName = $this->_options['index_filename'];
- }
-
- $pathName = realpath($this->_options['public_dir']) . dirname($id);
- $this->_createDirectoriesFor($pathName);
-
- if ($id === null || strlen($id) == 0) {
- $dataUnserialized = unserialize($data);
- $data = $dataUnserialized['data'];
- }
- $ext = $this->_options['file_extension'];
- if ($extension) $ext = $extension;
- $file = rtrim($pathName, '/') . '/' . $fileName . $ext;
- if ($this->_options['file_locking']) {
- $result = file_put_contents($file, $data, LOCK_EX);
- } else {
- $result = file_put_contents($file, $data);
- }
- @chmod($file, $this->_octdec($this->_options['cache_file_perm']));
-
- if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif ($this->_tagged === null) {
- $this->_tagged = array();
- }
- if (!isset($this->_tagged[$id])) {
- $this->_tagged[$id] = array();
- }
- if (!isset($this->_tagged[$id]['tags'])) {
- $this->_tagged[$id]['tags'] = array();
- }
- $this->_tagged[$id]['tags'] = array_unique(array_merge($this->_tagged[$id]['tags'], $tags));
- $this->_tagged[$id]['extension'] = $ext;
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- return (bool) $result;
- }
-
- /**
- * Recursively create the directories needed to write the static file
- */
- protected function _createDirectoriesFor($path)
- {
- if (!is_dir($path)) {
- $oldUmask = umask(0);
- if ( !@mkdir($path, $this->_octdec($this->_options['cache_directory_perm']), true)) {
- $lastErr = error_get_last();
- umask($oldUmask);
- Zend_Cache::throwException("Can't create directory: {$lastErr['message']}");
- }
- umask($oldUmask);
- }
- }
-
- /**
- * Detect serialization of data (cannot predict since this is the only way
- * to obey the interface yet pass in another parameter).
- *
- * In future, ZF 2.0, check if we can just avoid the interface restraints.
- *
- * This format is the only valid one possible for the class, so it's simple
- * to just run a regular expression for the starting serialized format.
- */
- protected function _isSerialized($data)
- {
- return preg_match("/a:2:\{i:0;s:\d+:\"/", $data);
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
- $fileName = basename($id);
- if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif (!$this->_tagged) {
- return false;
- }
- if (isset($this->_tagged[$id])) {
- $extension = $this->_tagged[$id]['extension'];
- } else {
- $extension = $this->_options['file_extension'];
- }
- if ($fileName === '') {
- $fileName = $this->_options['index_filename'];
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
- $file = realpath($pathName) . '/' . $fileName . $extension;
- if (!file_exists($file)) {
- return false;
- }
- return unlink($file);
- }
-
- /**
- * Remove a cache record recursively for the given directory matching a
- * REQUEST_URI based relative path (deletes the actual file matching this
- * in addition to the matching directory)
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function removeRecursively($id)
- {
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
- $fileName = basename($id);
- if ($fileName === '') {
- $fileName = $this->_options['index_filename'];
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
- $file = $pathName . '/' . $fileName . $this->_options['file_extension'];
- $directory = $pathName . '/' . $fileName;
- if (file_exists($directory)) {
- if (!is_writable($directory)) {
- return false;
- }
- if (is_dir($directory)) {
- foreach (new DirectoryIterator($directory) as $file) {
- if (true === $file->isFile()) {
- if (false === unlink($file->getPathName())) {
- return false;
- }
- }
- }
- }
- rmdir($directory);
- }
- if (file_exists($file)) {
- if (!is_writable($file)) {
- return false;
- }
- return unlink($file);
- }
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean true if no problem
- * @throws Zend_Exception
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- $result = false;
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- if (empty($tags)) {
- throw new Zend_Exception('Cannot use tag matching modes as no tags were defined');
- }
- if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif (!$this->_tagged) {
- return true;
- }
- foreach ($tags as $tag) {
- $urls = array_keys($this->_tagged);
- foreach ($urls as $url) {
- if (isset($this->_tagged[$url]['tags']) && in_array($tag, $this->_tagged[$url]['tags'])) {
- $this->remove($url);
- unset($this->_tagged[$url]);
- }
- }
- }
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- $result = true;
- break;
- case Zend_Cache::CLEANING_MODE_ALL:
- if ($this->_tagged === null) {
- $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME);
- $this->_tagged = $tagged;
- }
- if ($this->_tagged === null || empty($this->_tagged)) {
- return true;
- }
- $urls = array_keys($this->_tagged);
- foreach ($urls as $url) {
- $this->remove($url);
- unset($this->_tagged[$url]);
- }
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- $result = true;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Static : Selected Cleaning Mode Currently Unsupported By This Backend");
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- if (empty($tags)) {
- throw new Zend_Exception('Cannot use tag matching modes as no tags were defined');
- }
- if ($this->_tagged === null) {
- $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME);
- $this->_tagged = $tagged;
- }
- if ($this->_tagged === null || empty($this->_tagged)) {
- return true;
- }
- $urls = array_keys($this->_tagged);
- foreach ($urls as $url) {
- $difference = array_diff($tags, $this->_tagged[$url]['tags']);
- if (count($tags) == count($difference)) {
- $this->remove($url);
- unset($this->_tagged[$url]);
- }
- }
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- $result = true;
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- return $result;
- }
-
- /**
- * Set an Inner Cache, used here primarily to store Tags associated
- * with caches created by this backend. Note: If Tags are lost, the cache
- * should be completely cleaned as the mapping of tags to caches will
- * have been irrevocably lost.
- *
- * @param Zend_Cache_Core
- * @return void
- */
- public function setInnerCache(Zend_Cache_Core $cache)
- {
- $this->_tagCache = $cache;
- $this->_options['tag_cache'] = $cache;
- }
-
- /**
- * Get the Inner Cache if set
- *
- * @return Zend_Cache_Core
- */
- public function getInnerCache()
- {
- if ($this->_tagCache === null) {
- Zend_Cache::throwException('An Inner Cache has not been set; use setInnerCache()');
- }
- return $this->_tagCache;
- }
-
- /**
- * Verify path exists and is non-empty
- *
- * @param string $path
- * @return bool
- */
- protected function _verifyPath($path)
- {
- $path = realpath($path);
- $base = realpath($this->_options['public_dir']);
- return strncmp($path, $base, strlen($base)) !== 0;
- }
-
- /**
- * Determine the page to save from the request
- *
- * @return string
- */
- protected function _detectId()
- {
- return $_SERVER['REQUEST_URI'];
- }
-
- /**
- * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)
- *
- * Throw an exception if a problem is found
- *
- * @param string $string Cache id or tag
- * @throws Zend_Cache_Exception
- * @return void
- * @deprecated Not usable until perhaps ZF 2.0
- */
- protected static function _validateIdOrTag($string)
- {
- if (!is_string($string)) {
- Zend_Cache::throwException('Invalid id or tag : must be a string');
- }
-
- // Internal only checked in Frontend - not here!
- if (substr($string, 0, 9) == 'internal-') {
- return;
- }
-
- // Validation assumes no query string, fragments or scheme included - only the path
- if (!preg_match(
- '/^(?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*\'()\[\]:@&=+$,;])*)?)+$/',
- $string
- )
- ) {
- Zend_Cache::throwException("Invalid id or tag '$string' : must be a valid URL path");
- }
- }
-
- /**
- * Detect an octal string and return its octal value for file permission ops
- * otherwise return the non-string (assumed octal or decimal int already)
- *
- * @param string $val The potential octal in need of conversion
- * @return int
- */
- protected function _octdec($val)
- {
- if (is_string($val) && decoct(octdec($val)) == $val) {
- return octdec($val);
- }
- return $val;
- }
-
- /**
- * Decode a request URI from the provided ID
- *
- * @param string $id
- * @return string
- */
- protected function _decodeId($id)
- {
- return pack('H*', $id);
- }
-}
diff --git a/lib/zend/Zend/Cache/Backend/Test.php b/lib/zend/Zend/Cache/Backend/Test.php
deleted file mode 100644
index d94e9734410fc..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Test.php
+++ /dev/null
@@ -1,416 +0,0 @@
-_addLog('construct', array($options));
- }
-
- /**
- * Set the frontend directives
- *
- * @param array $directives assoc of directives
- * @return void
- */
- public function setDirectives($directives)
- {
- $this->_addLog('setDirectives', array($directives));
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * if $id == 'serialized', the method will return a serialized array
- * ('foo' else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string Cached datas (or false)
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $this->_addLog('get', array($id, $doNotTestCacheValidity));
-
- if ( $id == 'false'
- || $id == 'd8523b3ee441006261eeffa5c3d3a0a7'
- || $id == 'e83249ea22178277d5befc2c5e2e9ace'
- || $id == '40f649b94977c0a6e76902e2a0b43587'
- || $id == '88161989b73a4cbfd0b701c446115a99'
- || $id == '205fc79cba24f0f0018eb92c7c8b3ba4'
- || $id == '170720e35f38150b811f68a937fb042d')
- {
- return false;
- }
- if ($id=='serialized') {
- return serialize(array('foo'));
- }
- if ($id=='serialized2') {
- return serialize(array('headers' => array(), 'data' => 'foo'));
- }
- if ( $id == '71769f39054f75894288e397df04e445' || $id == '615d222619fb20b527168340cebd0578'
- || $id == '8a02d218a5165c467e7a5747cc6bd4b6' || $id == '648aca1366211d17cbf48e65dc570bee'
- || $id == '4a923ef02d7f997ca14d56dfeae25ea7') {
- return serialize(array('foo', 'bar'));
- }
- if ( $id == 'f53c7d912cc523d9a65834c8286eceb9') {
- return serialize(array('foobar'));
- }
- return 'foo';
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * (123456 else)
- *
- * @param string $id Cache id
- * @return mixed|false false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $this->_addLog('test', array($id));
- if ($id=='false') {
- return false;
- }
- if (($id=='3c439c922209e2cb0b54d6deffccd75a')) {
- return false;
- }
- return 123456;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * (true else)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean True if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $this->_addLog('save', array($data, $id, $tags));
- if (substr($id,-5)=='false') {
- return false;
- }
- return true;
- }
-
- /**
- * Remove a cache record
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * (true else)
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- $this->_addLog('remove', array($id));
- if (substr($id,-5)=='false') {
- return false;
- }
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * For this test backend only, if $mode == 'false', then the method will return false
- * (true else)
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- $this->_addLog('clean', array($mode, $tags));
- if ($mode=='false') {
- return false;
- }
- return true;
- }
-
- /**
- * Get the last log
- *
- * @return string The last log
- */
- public function getLastLog()
- {
- return $this->_log[$this->_index - 1];
- }
-
- /**
- * Get the log index
- *
- * @return int Log index
- */
- public function getLogIndex()
- {
- return $this->_index;
- }
-
- /**
- * Get the complete log array
- *
- * @return array Complete log array
- */
- public function getAllLogs()
- {
- return $this->_log;
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return true;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return array(
- 'prefix_id1', 'prefix_id2'
- );
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return array(
- 'tag1', 'tag2'
- );
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- if ($tags == array('tag1', 'tag2')) {
- return array('prefix_id1', 'prefix_id2');
- }
-
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- if ($tags == array('tag3', 'tag4')) {
- return array('prefix_id3', 'prefix_id4');
- }
-
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- if ($tags == array('tag5', 'tag6')) {
- return array('prefix_id5', 'prefix_id6');
- }
-
- return array();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- return 50;
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- return true;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => false,
- 'priority' => true,
- 'infinite_lifetime' => true,
- 'get_list' => true
- );
- }
-
- /**
- * Add an event to the log array
- *
- * @param string $methodName MethodName
- * @param array $args Arguments
- * @return void
- */
- private function _addLog($methodName, $args)
- {
- $this->_log[$this->_index] = array(
- 'methodName' => $methodName,
- 'args' => $args
- );
- $this->_index = $this->_index + 1;
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/TwoLevels.php b/lib/zend/Zend/Cache/Backend/TwoLevels.php
deleted file mode 100644
index 135ff6ad8de95..0000000000000
--- a/lib/zend/Zend/Cache/Backend/TwoLevels.php
+++ /dev/null
@@ -1,548 +0,0 @@
- (string) slow_backend :
- * - Slow backend name
- * - Must implement the Zend_Cache_Backend_ExtendedInterface
- * - Should provide a big storage
- *
- * =====> (string) fast_backend :
- * - Flow backend name
- * - Must implement the Zend_Cache_Backend_ExtendedInterface
- * - Must be much faster than slow_backend
- *
- * =====> (array) slow_backend_options :
- * - Slow backend options (see corresponding backend)
- *
- * =====> (array) fast_backend_options :
- * - Fast backend options (see corresponding backend)
- *
- * =====> (int) stats_update_factor :
- * - Disable / Tune the computation of the fast backend filling percentage
- * - When saving a record into cache :
- * 1 => systematic computation of the fast backend filling percentage
- * x (integer) > 1 => computation of the fast backend filling percentage randomly 1 times on x cache write
- *
- * =====> (boolean) slow_backend_custom_naming :
- * =====> (boolean) fast_backend_custom_naming :
- * =====> (boolean) slow_backend_autoload :
- * =====> (boolean) fast_backend_autoload :
- * - See Zend_Cache::factory() method
- *
- * =====> (boolean) auto_fill_fast_cache
- * - If true, automatically fill the fast cache when a cache record was not found in fast cache, but did
- * exist in slow cache. This can be usefull when a non-persistent cache like APC or Memcached got
- * purged for whatever reason.
- *
- * =====> (boolean) auto_refresh_fast_cache
- * - If true, auto refresh the fast cache when a cache record is hit
- *
- * @var array available options
- */
- protected $_options = array(
- 'slow_backend' => 'File',
- 'fast_backend' => 'Apc',
- 'slow_backend_options' => array(),
- 'fast_backend_options' => array(),
- 'stats_update_factor' => 10,
- 'slow_backend_custom_naming' => false,
- 'fast_backend_custom_naming' => false,
- 'slow_backend_autoload' => false,
- 'fast_backend_autoload' => false,
- 'auto_fill_fast_cache' => true,
- 'auto_refresh_fast_cache' => true
- );
-
- /**
- * Slow Backend
- *
- * @var Zend_Cache_Backend_ExtendedInterface
- */
- protected $_slowBackend;
-
- /**
- * Fast Backend
- *
- * @var Zend_Cache_Backend_ExtendedInterface
- */
- protected $_fastBackend;
-
- /**
- * Cache for the fast backend filling percentage
- *
- * @var int
- */
- protected $_fastBackendFillingPercentage = null;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- parent::__construct($options);
-
- if ($this->_options['slow_backend'] === null) {
- Zend_Cache::throwException('slow_backend option has to set');
- } elseif ($this->_options['slow_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) {
- $this->_slowBackend = $this->_options['slow_backend'];
- } else {
- $this->_slowBackend = Zend_Cache::_makeBackend(
- $this->_options['slow_backend'],
- $this->_options['slow_backend_options'],
- $this->_options['slow_backend_custom_naming'],
- $this->_options['slow_backend_autoload']
- );
- if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) {
- Zend_Cache::throwException('slow_backend must implement the Zend_Cache_Backend_ExtendedInterface interface');
- }
- }
-
- if ($this->_options['fast_backend'] === null) {
- Zend_Cache::throwException('fast_backend option has to set');
- } elseif ($this->_options['fast_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) {
- $this->_fastBackend = $this->_options['fast_backend'];
- } else {
- $this->_fastBackend = Zend_Cache::_makeBackend(
- $this->_options['fast_backend'],
- $this->_options['fast_backend_options'],
- $this->_options['fast_backend_custom_naming'],
- $this->_options['fast_backend_autoload']
- );
- if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) {
- Zend_Cache::throwException('fast_backend must implement the Zend_Cache_Backend_ExtendedInterface interface');
- }
- }
-
- $this->_slowBackend->setDirectives($this->_directives);
- $this->_fastBackend->setDirectives($this->_directives);
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $fastTest = $this->_fastBackend->test($id);
- if ($fastTest) {
- return $fastTest;
- } else {
- return $this->_slowBackend->test($id);
- }
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false, $priority = 8)
- {
- $usage = $this->_getFastFillingPercentage('saving');
- $boolFast = true;
- $lifetime = $this->getLifetime($specificLifetime);
- $preparedData = $this->_prepareData($data, $lifetime, $priority);
- if (($priority > 0) && (10 * $priority >= $usage)) {
- $fastLifetime = $this->_getFastLifetime($lifetime, $priority);
- $boolFast = $this->_fastBackend->save($preparedData, $id, array(), $fastLifetime);
- $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime);
- } else {
- $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime);
- if ($boolSlow === true) {
- $boolFast = $this->_fastBackend->remove($id);
- if (!$boolFast && !$this->_fastBackend->test($id)) {
- // some backends return false on remove() even if the key never existed. (and it won't if fast is full)
- // all we care about is that the key doesn't exist now
- $boolFast = true;
- }
- }
- }
-
- return ($boolFast && $boolSlow);
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * Note : return value is always "string" (unserialization is done by the core not by the backend)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $resultFast = $this->_fastBackend->load($id, $doNotTestCacheValidity);
- if ($resultFast === false) {
- $resultSlow = $this->_slowBackend->load($id, $doNotTestCacheValidity);
- if ($resultSlow === false) {
- // there is no cache at all for this id
- return false;
- }
- }
- $array = $resultFast !== false ? unserialize($resultFast) : unserialize($resultSlow);
-
- //In case no cache entry was found in the FastCache and auto-filling is enabled, copy data to FastCache
- if ($resultFast === false && $this->_options['auto_fill_fast_cache']) {
- $preparedData = $this->_prepareData($array['data'], $array['lifetime'], $array['priority']);
- $this->_fastBackend->save($preparedData, $id, array(), $array['lifetime']);
- }
- // maybe, we have to refresh the fast cache ?
- elseif ($this->_options['auto_refresh_fast_cache']) {
- if ($array['priority'] == 10) {
- // no need to refresh the fast cache with priority = 10
- return $array['data'];
- }
- $newFastLifetime = $this->_getFastLifetime($array['lifetime'], $array['priority'], time() - $array['expire']);
- // we have the time to refresh the fast cache
- $usage = $this->_getFastFillingPercentage('loading');
- if (($array['priority'] > 0) && (10 * $array['priority'] >= $usage)) {
- // we can refresh the fast cache
- $preparedData = $this->_prepareData($array['data'], $array['lifetime'], $array['priority']);
- $this->_fastBackend->save($preparedData, $id, array(), $newFastLifetime);
- }
- }
- return $array['data'];
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- $boolFast = $this->_fastBackend->remove($id);
- $boolSlow = $this->_slowBackend->remove($id);
- return $boolFast && $boolSlow;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $boolFast = $this->_fastBackend->clean(Zend_Cache::CLEANING_MODE_ALL);
- $boolSlow = $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_ALL);
- return $boolFast && $boolSlow;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- return $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_OLD);
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $ids = $this->_slowBackend->getIdsMatchingTags($tags);
- $res = true;
- foreach ($ids as $id) {
- $bool = $this->remove($id);
- $res = $res && $bool;
- }
- return $res;
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $ids = $this->_slowBackend->getIdsNotMatchingTags($tags);
- $res = true;
- foreach ($ids as $id) {
- $bool = $this->remove($id);
- $res = $res && $bool;
- }
- return $res;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $ids = $this->_slowBackend->getIdsMatchingAnyTags($tags);
- $res = true;
- foreach ($ids as $id) {
- $bool = $this->remove($id);
- $res = $res && $bool;
- }
- return $res;
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return $this->_slowBackend->getIds();
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return $this->_slowBackend->getTags();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- return $this->_slowBackend->getIdsMatchingTags($tags);
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- return $this->_slowBackend->getIdsNotMatchingTags($tags);
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- return $this->_slowBackend->getIdsMatchingAnyTags($tags);
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- return $this->_slowBackend->getFillingPercentage();
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- return $this->_slowBackend->getMetadatas($id);
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- return $this->_slowBackend->touch($id, $extraLifetime);
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- $slowBackendCapabilities = $this->_slowBackend->getCapabilities();
- return array(
- 'automatic_cleaning' => $slowBackendCapabilities['automatic_cleaning'],
- 'tags' => $slowBackendCapabilities['tags'],
- 'expired_read' => $slowBackendCapabilities['expired_read'],
- 'priority' => $slowBackendCapabilities['priority'],
- 'infinite_lifetime' => $slowBackendCapabilities['infinite_lifetime'],
- 'get_list' => $slowBackendCapabilities['get_list']
- );
- }
-
- /**
- * Prepare a serialized array to store datas and metadatas informations
- *
- * @param string $data data to store
- * @param int $lifetime original lifetime
- * @param int $priority priority
- * @return string serialize array to store into cache
- */
- private function _prepareData($data, $lifetime, $priority)
- {
- $lt = $lifetime;
- if ($lt === null) {
- $lt = 9999999999;
- }
- return serialize(array(
- 'data' => $data,
- 'lifetime' => $lifetime,
- 'expire' => time() + $lt,
- 'priority' => $priority
- ));
- }
-
- /**
- * Compute and return the lifetime for the fast backend
- *
- * @param int $lifetime original lifetime
- * @param int $priority priority
- * @param int $maxLifetime maximum lifetime
- * @return int lifetime for the fast backend
- */
- private function _getFastLifetime($lifetime, $priority, $maxLifetime = null)
- {
- if ($lifetime <= 0) {
- // if no lifetime, we have an infinite lifetime
- // we need to use arbitrary lifetimes
- $fastLifetime = (int) (2592000 / (11 - $priority));
- } else {
- // prevent computed infinite lifetime (0) by ceil
- $fastLifetime = (int) ceil($lifetime / (11 - $priority));
- }
-
- if ($maxLifetime >= 0 && $fastLifetime > $maxLifetime) {
- return $maxLifetime;
- }
-
- return $fastLifetime;
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id cache id
- */
- public function ___expire($id)
- {
- $this->_fastBackend->remove($id);
- $this->_slowBackend->___expire($id);
- }
-
- private function _getFastFillingPercentage($mode)
- {
-
- if ($mode == 'saving') {
- // mode saving
- if ($this->_fastBackendFillingPercentage === null) {
- $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
- } else {
- $rand = rand(1, $this->_options['stats_update_factor']);
- if ($rand == 1) {
- // we force a refresh
- $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
- }
- }
- } else {
- // mode loading
- // we compute the percentage only if it's not available in cache
- if ($this->_fastBackendFillingPercentage === null) {
- $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
- }
- }
- return $this->_fastBackendFillingPercentage;
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/WinCache.php b/lib/zend/Zend/Cache/Backend/WinCache.php
deleted file mode 100644
index 06843fa39af00..0000000000000
--- a/lib/zend/Zend/Cache/Backend/WinCache.php
+++ /dev/null
@@ -1,349 +0,0 @@
- infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- $result = wincache_ucache_set($id, array($data, time(), $lifetime), $lifetime);
- if (count($tags) > 0) {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
- }
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- return wincache_ucache_delete($id);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- return wincache_ucache_clear();
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_WinCache::clean() : CLEANING_MODE_OLD is unsupported by the WinCache backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * DEPRECATED : use getCapabilities() instead
- *
- * @deprecated
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $mem = wincache_ucache_meminfo();
- $memSize = $mem['memory_total'];
- $memUsed = $memSize - $mem['memory_free'];
- if ($memSize == 0) {
- Zend_Cache::throwException('can\'t get WinCache memory size');
- }
- if ($memUsed > $memSize) {
- return 100;
- }
- return ((int) (100. * ($memUsed / $memSize)));
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $res = array();
- $array = wincache_ucache_info();
- $records = $array['ucache_entries'];
- foreach ($records as $record) {
- $res[] = $record['key_name'];
- }
- return $res;
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tmp = wincache_ucache_get($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- return false;
- }
- $lifetime = $tmp[2];
- return array(
- 'expire' => $mtime + $lifetime,
- 'tags' => array(),
- 'mtime' => $mtime
- );
- }
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $tmp = wincache_ucache_get($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- return false;
- }
- $lifetime = $tmp[2];
- $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
- if ($newLifetime <=0) {
- return false;
- }
- return wincache_ucache_set($id, array($data, time(), $newLifetime), $newLifetime);
- }
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => false,
- 'tags' => false,
- 'expired_read' => false,
- 'priority' => false,
- 'infinite_lifetime' => false,
- 'get_list' => true
- );
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/Xcache.php b/lib/zend/Zend/Cache/Backend/Xcache.php
deleted file mode 100644
index 4bc077fc92394..0000000000000
--- a/lib/zend/Zend/Cache/Backend/Xcache.php
+++ /dev/null
@@ -1,221 +0,0 @@
- (string) user :
- * xcache.admin.user (necessary for the clean() method)
- *
- * =====> (string) password :
- * xcache.admin.pass (clear, not MD5) (necessary for the clean() method)
- *
- * @var array available options
- */
- protected $_options = array(
- 'user' => null,
- 'password' => null
- );
-
- /**
- * Constructor
- *
- * @param array $options associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- if (!extension_loaded('xcache')) {
- Zend_Cache::throwException('The xcache extension must be loaded for using this backend !');
- }
- parent::__construct($options);
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * WARNING $doNotTestCacheValidity=true is unsupported by the Xcache backend
- *
- * @param string $id cache id
- * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
- * @return string cached datas (or false)
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- if ($doNotTestCacheValidity) {
- $this->_log("Zend_Cache_Backend_Xcache::load() : \$doNotTestCacheValidity=true is unsupported by the Xcache backend");
- }
- $tmp = xcache_get($id);
- if (is_array($tmp)) {
- return $tmp[0];
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- if (xcache_isset($id)) {
- $tmp = xcache_get($id);
- if (is_array($tmp)) {
- return $tmp[1];
- }
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data datas to cache
- * @param string $id cache id
- * @param array $tags array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- $result = xcache_set($id, array($data, time()), $lifetime);
- if (count($tags) > 0) {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_XCACHE_BACKEND);
- }
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- return xcache_unset($id);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- // Necessary because xcache_clear_cache() need basic authentification
- $backup = array();
- if (isset($_SERVER['PHP_AUTH_USER'])) {
- $backup['PHP_AUTH_USER'] = $_SERVER['PHP_AUTH_USER'];
- }
- if (isset($_SERVER['PHP_AUTH_PW'])) {
- $backup['PHP_AUTH_PW'] = $_SERVER['PHP_AUTH_PW'];
- }
- if ($this->_options['user']) {
- $_SERVER['PHP_AUTH_USER'] = $this->_options['user'];
- }
- if ($this->_options['password']) {
- $_SERVER['PHP_AUTH_PW'] = $this->_options['password'];
- }
-
- $cnt = xcache_count(XC_TYPE_VAR);
- for ($i=0; $i < $cnt; $i++) {
- xcache_clear_cache(XC_TYPE_VAR, $i);
- }
-
- if (isset($backup['PHP_AUTH_USER'])) {
- $_SERVER['PHP_AUTH_USER'] = $backup['PHP_AUTH_USER'];
- $_SERVER['PHP_AUTH_PW'] = $backup['PHP_AUTH_PW'];
- }
- return true;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Xcache::clean() : CLEANING_MODE_OLD is unsupported by the Xcache backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_XCACHE_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/ZendPlatform.php b/lib/zend/Zend/Cache/Backend/ZendPlatform.php
deleted file mode 100644
index 31e9a7a22afb4..0000000000000
--- a/lib/zend/Zend/Cache/Backend/ZendPlatform.php
+++ /dev/null
@@ -1,317 +0,0 @@
-_directives['lifetime'];
- }
- $res = output_cache_get($id, $lifetime);
- if($res) {
- return $res[0];
- } else {
- return false;
- }
- }
-
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id Cache id
- * @return mixed|false false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $result = output_cache_get($id, $this->_directives['lifetime']);
- if ($result) {
- return $result[1];
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Data to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- if (!($specificLifetime === false)) {
- $this->_log("Zend_Cache_Backend_ZendPlatform::save() : non false specifc lifetime is unsuported for this backend");
- }
-
- $lifetime = $this->_directives['lifetime'];
- $result1 = output_cache_put($id, array($data, time()));
- $result2 = (count($tags) == 0);
-
- foreach ($tags as $tag) {
- $tagid = self::TAGS_PREFIX.$tag;
- $old_tags = output_cache_get($tagid, $lifetime);
- if ($old_tags === false) {
- $old_tags = array();
- }
- $old_tags[$id] = $id;
- output_cache_remove_key($tagid);
- $result2 = output_cache_put($tagid, $old_tags);
- }
-
- return $result1 && $result2;
- }
-
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- return output_cache_remove_key($id);
- }
-
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * This mode is not supported in this backend
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => unsupported
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- case Zend_Cache::CLEANING_MODE_OLD:
- $cache_dir = ini_get('zend_accelerator.output_cache_dir');
- if (!$cache_dir) {
- return false;
- }
- $cache_dir .= '/.php_cache_api/';
- return $this->_clean($cache_dir, $mode);
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $idlist = null;
- foreach ($tags as $tag) {
- $next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']);
- if ($idlist) {
- $idlist = array_intersect_assoc($idlist, $next_idlist);
- } else {
- $idlist = $next_idlist;
- }
- if (count($idlist) == 0) {
- // if ID list is already empty - we may skip checking other IDs
- $idlist = null;
- break;
- }
- }
- if ($idlist) {
- foreach ($idlist as $id) {
- output_cache_remove_key($id);
- }
- }
- return true;
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $this->_log("Zend_Cache_Backend_ZendPlatform::clean() : CLEANING_MODE_NOT_MATCHING_TAG is not supported by the Zend Platform backend");
- return false;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $idlist = null;
- foreach ($tags as $tag) {
- $next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']);
- if ($idlist) {
- $idlist = array_merge_recursive($idlist, $next_idlist);
- } else {
- $idlist = $next_idlist;
- }
- if (count($idlist) == 0) {
- // if ID list is already empty - we may skip checking other IDs
- $idlist = null;
- break;
- }
- }
- if ($idlist) {
- foreach ($idlist as $id) {
- output_cache_remove_key($id);
- }
- }
- return true;
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Clean a directory and recursivly go over it's subdirectories
- *
- * Remove all the cached files that need to be cleaned (according to mode and files mtime)
- *
- * @param string $dir Path of directory ot clean
- * @param string $mode The same parameter as in Zend_Cache_Backend_ZendPlatform::clean()
- * @return boolean True if ok
- */
- private function _clean($dir, $mode)
- {
- $d = @dir($dir);
- if (!$d) {
- return false;
- }
- $result = true;
- while (false !== ($file = $d->read())) {
- if ($file == '.' || $file == '..') {
- continue;
- }
- $file = $d->path . $file;
- if (is_dir($file)) {
- $result = ($this->_clean($file .'/', $mode)) && ($result);
- } else {
- if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
- $result = ($this->_remove($file)) && ($result);
- } else if ($mode == Zend_Cache::CLEANING_MODE_OLD) {
- // Files older than lifetime get deleted from cache
- if ($this->_directives['lifetime'] !== null) {
- if ((time() - @filemtime($file)) > $this->_directives['lifetime']) {
- $result = ($this->_remove($file)) && ($result);
- }
- }
- }
- }
- }
- $d->close();
- return $result;
- }
-
- /**
- * Remove a file
- *
- * If we can't remove the file (because of locks or any problem), we will touch
- * the file to invalidate it
- *
- * @param string $file Complete file path
- * @return boolean True if ok
- */
- private function _remove($file)
- {
- if (!@unlink($file)) {
- # If we can't remove the file (because of locks or any problem), we will touch
- # the file to invalidate it
- $this->_log("Zend_Cache_Backend_ZendPlatform::_remove() : we can't remove $file => we are going to try to invalidate it");
- if ($this->_directives['lifetime'] === null) {
- return false;
- }
- if (!file_exists($file)) {
- return false;
- }
- return @touch($file, time() - 2*abs($this->_directives['lifetime']));
- }
- return true;
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Backend/ZendServer.php b/lib/zend/Zend/Cache/Backend/ZendServer.php
deleted file mode 100644
index ededaf5a9bc62..0000000000000
--- a/lib/zend/Zend/Cache/Backend/ZendServer.php
+++ /dev/null
@@ -1,207 +0,0 @@
- (string) namespace :
- * Namespace to be used for chaching operations
- *
- * @var array available options
- */
- protected $_options = array(
- 'namespace' => 'zendframework'
- );
-
- /**
- * Store data
- *
- * @param mixed $data Object to store
- * @param string $id Cache id
- * @param int $timeToLive Time to live in seconds
- * @throws Zend_Cache_Exception
- */
- abstract protected function _store($data, $id, $timeToLive);
-
- /**
- * Fetch data
- *
- * @param string $id Cache id
- * @throws Zend_Cache_Exception
- */
- abstract protected function _fetch($id);
-
- /**
- * Unset data
- *
- * @param string $id Cache id
- */
- abstract protected function _unset($id);
-
- /**
- * Clear cache
- */
- abstract protected function _clear();
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id cache id
- * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
- * @return string cached datas (or false)
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $tmp = $this->_fetch($id);
- if ($tmp !== null) {
- return $tmp;
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- * @throws Zend_Cache_Exception
- */
- public function test($id)
- {
- $tmp = $this->_fetch('internal-metadatas---' . $id);
- if ($tmp !== false) {
- if (!is_array($tmp) || !isset($tmp['mtime'])) {
- Zend_Cache::throwException('Cache metadata for \'' . $id . '\' id is corrupted' );
- }
- return $tmp['mtime'];
- }
- return false;
- }
-
- /**
- * Compute & return the expire time
- *
- * @return int expire time (unix timestamp)
- */
- private function _expireTime($lifetime)
- {
- if ($lifetime === null) {
- return 9999999999;
- }
- return time() + $lifetime;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data datas to cache
- * @param string $id cache id
- * @param array $tags array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- $metadatas = array(
- 'mtime' => time(),
- 'expire' => $this->_expireTime($lifetime),
- );
-
- if (count($tags) > 0) {
- $this->_log('Zend_Cache_Backend_ZendServer::save() : tags are unsupported by the ZendServer backends');
- }
-
- return $this->_store($data, $id, $lifetime) &&
- $this->_store($metadatas, 'internal-metadatas---' . $id, $lifetime);
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- $result1 = $this->_unset($id);
- $result2 = $this->_unset('internal-metadatas---' . $id);
-
- return $result1 && $result2;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $this->_clear();
- return true;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_ZendServer::clean() : CLEANING_MODE_OLD is unsupported by the Zend Server backends.");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_clear();
- $this->_log('Zend_Cache_Backend_ZendServer::clean() : tags are unsupported by the Zend Server backends.');
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-}
diff --git a/lib/zend/Zend/Cache/Backend/ZendServer/Disk.php b/lib/zend/Zend/Cache/Backend/ZendServer/Disk.php
deleted file mode 100644
index 54914fefff4fb..0000000000000
--- a/lib/zend/Zend/Cache/Backend/ZendServer/Disk.php
+++ /dev/null
@@ -1,101 +0,0 @@
-_options['namespace'] . '::' . $id,
- $data,
- $timeToLive) === false) {
- $this->_log('Store operation failed.');
- return false;
- }
- return true;
- }
-
- /**
- * Fetch data
- *
- * @param string $id Cache id
- * @return mixed|null
- */
- protected function _fetch($id)
- {
- return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Unset data
- *
- * @param string $id Cache id
- * @return boolean true if no problem
- */
- protected function _unset($id)
- {
- return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Clear cache
- */
- protected function _clear()
- {
- zend_disk_cache_clear($this->_options['namespace']);
- }
-}
diff --git a/lib/zend/Zend/Cache/Backend/ZendServer/ShMem.php b/lib/zend/Zend/Cache/Backend/ZendServer/ShMem.php
deleted file mode 100644
index 83086dcd4ea1a..0000000000000
--- a/lib/zend/Zend/Cache/Backend/ZendServer/ShMem.php
+++ /dev/null
@@ -1,101 +0,0 @@
-_options['namespace'] . '::' . $id,
- $data,
- $timeToLive) === false) {
- $this->_log('Store operation failed.');
- return false;
- }
- return true;
- }
-
- /**
- * Fetch data
- *
- * @param string $id Cache id
- * @return mixed|null
- */
- protected function _fetch($id)
- {
- return zend_shm_cache_fetch($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Unset data
- *
- * @param string $id Cache id
- * @return boolean true if no problem
- */
- protected function _unset($id)
- {
- return zend_shm_cache_delete($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Clear cache
- */
- protected function _clear()
- {
- zend_shm_cache_clear($this->_options['namespace']);
- }
-}
diff --git a/lib/zend/Zend/Cache/Core.php b/lib/zend/Zend/Cache/Core.php
deleted file mode 100644
index 685d5d52b6582..0000000000000
--- a/lib/zend/Zend/Cache/Core.php
+++ /dev/null
@@ -1,765 +0,0 @@
- (boolean) write_control :
- * - Enable / disable write control (the cache is read just after writing to detect corrupt entries)
- * - Enable write control will lightly slow the cache writing but not the cache reading
- * Write control can detect some corrupt cache files but maybe it's not a perfect control
- *
- * ====> (boolean) caching :
- * - Enable / disable caching
- * (can be very useful for the debug of cached scripts)
- *
- * =====> (string) cache_id_prefix :
- * - prefix for cache ids (namespace)
- *
- * ====> (boolean) automatic_serialization :
- * - Enable / disable automatic serialization
- * - It can be used to save directly datas which aren't strings (but it's slower)
- *
- * ====> (int) automatic_cleaning_factor :
- * - Disable / Tune the automatic cleaning process
- * - The automatic cleaning process destroy too old (for the given life time)
- * cache files when a new cache file is written :
- * 0 => no automatic cache cleaning
- * 1 => systematic cache cleaning
- * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
- *
- * ====> (int) lifetime :
- * - Cache lifetime (in seconds)
- * - If null, the cache is valid forever.
- *
- * ====> (boolean) logging :
- * - If set to true, logging is activated (but the system is slower)
- *
- * ====> (boolean) ignore_user_abort
- * - If set to true, the core will set the ignore_user_abort PHP flag inside the
- * save() method to avoid cache corruptions in some cases (default false)
- *
- * @var array $_options available options
- */
- protected $_options = array(
- 'write_control' => true,
- 'caching' => true,
- 'cache_id_prefix' => null,
- 'automatic_serialization' => false,
- 'automatic_cleaning_factor' => 10,
- 'lifetime' => 3600,
- 'logging' => false,
- 'logger' => null,
- 'ignore_user_abort' => false
- );
-
- /**
- * Array of options which have to be transfered to backend
- *
- * @var array $_directivesList
- */
- protected static $_directivesList = array('lifetime', 'logging', 'logger');
-
- /**
- * Not used for the core, just a sort a hint to get a common setOption() method (for the core and for frontends)
- *
- * @var array $_specificOptions
- */
- protected $_specificOptions = array();
-
- /**
- * Last used cache id
- *
- * @var string $_lastId
- */
- private $_lastId = null;
-
- /**
- * True if the backend implements Zend_Cache_Backend_ExtendedInterface
- *
- * @var boolean $_extendedBackend
- */
- protected $_extendedBackend = false;
-
- /**
- * Array of capabilities of the backend (only if it implements Zend_Cache_Backend_ExtendedInterface)
- *
- * @var array
- */
- protected $_backendCapabilities = array();
-
- /**
- * Constructor
- *
- * @param array|Zend_Config $options Associative array of options or Zend_Config instance
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct($options = array())
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
- if (!is_array($options)) {
- Zend_Cache::throwException("Options passed were not an array"
- . " or Zend_Config instance.");
- }
- foreach ($options as $name => $value) {
- $this->setOption($name, $value);
- }
- $this->_loggerSanity();
- }
-
- /**
- * Set options using an instance of type Zend_Config
- *
- * @param Zend_Config $config
- * @return Zend_Cache_Core
- */
- public function setConfig(Zend_Config $config)
- {
- $options = $config->toArray();
- foreach ($options as $name => $value) {
- $this->setOption($name, $value);
- }
- return $this;
- }
-
- /**
- * Set the backend
- *
- * @param Zend_Cache_Backend $backendObject
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setBackend(Zend_Cache_Backend $backendObject)
- {
- $this->_backend= $backendObject;
- // some options (listed in $_directivesList) have to be given
- // to the backend too (even if they are not "backend specific")
- $directives = array();
- foreach (Zend_Cache_Core::$_directivesList as $directive) {
- $directives[$directive] = $this->_options[$directive];
- }
- $this->_backend->setDirectives($directives);
- if (in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_backend))) {
- $this->_extendedBackend = true;
- $this->_backendCapabilities = $this->_backend->getCapabilities();
- }
-
- }
-
- /**
- * Returns the backend
- *
- * @return Zend_Cache_Backend backend object
- */
- public function getBackend()
- {
- return $this->_backend;
- }
-
- /**
- * Public frontend to set an option
- *
- * There is an additional validation (relatively to the protected _setOption method)
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if (!is_string($name)) {
- Zend_Cache::throwException("Incorrect option name!");
- }
- $name = strtolower($name);
- if (array_key_exists($name, $this->_options)) {
- // This is a Core option
- $this->_setOption($name, $value);
- return;
- }
- if (array_key_exists($name, $this->_specificOptions)) {
- // This a specic option of this frontend
- $this->_specificOptions[$name] = $value;
- return;
- }
- }
-
- /**
- * Public frontend to get an option value
- *
- * @param string $name Name of the option
- * @throws Zend_Cache_Exception
- * @return mixed option value
- */
- public function getOption($name)
- {
- $name = strtolower($name);
-
- if (array_key_exists($name, $this->_options)) {
- // This is a Core option
- return $this->_options[$name];
- }
-
- if (array_key_exists($name, $this->_specificOptions)) {
- // This a specic option of this frontend
- return $this->_specificOptions[$name];
- }
-
- Zend_Cache::throwException("Incorrect option name : $name");
- }
-
- /**
- * Set an option
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- private function _setOption($name, $value)
- {
- if (!is_string($name) || !array_key_exists($name, $this->_options)) {
- Zend_Cache::throwException("Incorrect option name : $name");
- }
- if ($name == 'lifetime' && empty($value)) {
- $value = null;
- }
- $this->_options[$name] = $value;
- }
-
- /**
- * Force a new lifetime
- *
- * The new value is set for the core/frontend but for the backend too (directive)
- *
- * @param int $newLifetime New lifetime (in seconds)
- * @return void
- */
- public function setLifetime($newLifetime)
- {
- $this->_options['lifetime'] = $newLifetime;
- $this->_backend->setDirectives(array(
- 'lifetime' => $newLifetime
- ));
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @param boolean $doNotUnserialize Do not serialize (even if automatic_serialization is true) => for internal use
- * @return mixed|false Cached datas
- */
- public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false)
- {
- if (!$this->_options['caching']) {
- return false;
- }
- $id = $this->_id($id); // cache id may need prefix
- $this->_lastId = $id;
- $this->_validateIdOrTag($id);
-
- $this->_log("Zend_Cache_Core: load item '{$id}'", 7);
- $data = $this->_backend->load($id, $doNotTestCacheValidity);
- if ($data===false) {
- // no cache available
- return false;
- }
- if ((!$doNotUnserialize) && $this->_options['automatic_serialization']) {
- // we need to unserialize before sending the result
- return unserialize($data);
- }
- return $data;
- }
-
- /**
- * Test if a cache is available for the given id
- *
- * @param string $id Cache id
- * @return int|false Last modified time of cache entry if it is available, false otherwise
- */
- public function test($id)
- {
- if (!$this->_options['caching']) {
- return false;
- }
- $id = $this->_id($id); // cache id may need prefix
- $this->_validateIdOrTag($id);
- $this->_lastId = $id;
-
- $this->_log("Zend_Cache_Core: test item '{$id}'", 7);
- return $this->_backend->test($id);
- }
-
- /**
- * Save some data in a cache
- *
- * @param mixed $data Data to put in cache (can be another type than string if automatic_serialization is on)
- * @param string $id Cache id (if not set, the last cache id will be used)
- * @param array $tags Cache tags
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)
- {
- if (!$this->_options['caching']) {
- return true;
- }
- if ($id === null) {
- $id = $this->_lastId;
- } else {
- $id = $this->_id($id);
- }
- $this->_validateIdOrTag($id);
- $this->_validateTagsArray($tags);
- if ($this->_options['automatic_serialization']) {
- // we need to serialize datas before storing them
- $data = serialize($data);
- } else {
- if (!is_string($data)) {
- Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
- }
- }
-
- // automatic cleaning
- if ($this->_options['automatic_cleaning_factor'] > 0) {
- $rand = rand(1, $this->_options['automatic_cleaning_factor']);
- if ($rand==1) {
- // new way || deprecated way
- if ($this->_extendedBackend || method_exists($this->_backend, 'isAutomaticCleaningAvailable')) {
- $this->_log("Zend_Cache_Core::save(): automatic cleaning running", 7);
- $this->clean(Zend_Cache::CLEANING_MODE_OLD);
- } else {
- $this->_log("Zend_Cache_Core::save(): automatic cleaning is not available/necessary with current backend", 4);
- }
- }
- }
-
- $this->_log("Zend_Cache_Core: save item '{$id}'", 7);
- if ($this->_options['ignore_user_abort']) {
- $abort = ignore_user_abort(true);
- }
- if (($this->_extendedBackend) && ($this->_backendCapabilities['priority'])) {
- $result = $this->_backend->save($data, $id, $tags, $specificLifetime, $priority);
- } else {
- $result = $this->_backend->save($data, $id, $tags, $specificLifetime);
- }
- if ($this->_options['ignore_user_abort']) {
- ignore_user_abort($abort);
- }
-
- if (!$result) {
- // maybe the cache is corrupted, so we remove it !
- $this->_log("Zend_Cache_Core::save(): failed to save item '{$id}' -> removing it", 4);
- $this->_backend->remove($id);
- return false;
- }
-
- if ($this->_options['write_control']) {
- $data2 = $this->_backend->load($id, true);
- if ($data!=$data2) {
- $this->_log("Zend_Cache_Core::save(): write control of item '{$id}' failed -> removing it", 4);
- $this->_backend->remove($id);
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Remove a cache
- *
- * @param string $id Cache id to remove
- * @return boolean True if ok
- */
- public function remove($id)
- {
- if (!$this->_options['caching']) {
- return true;
- }
- $id = $this->_id($id); // cache id may need prefix
- $this->_validateIdOrTag($id);
-
- $this->_log("Zend_Cache_Core: remove item '{$id}'", 7);
- return $this->_backend->remove($id);
- }
-
- /**
- * Clean cache entries
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => remove too old cache entries ($tags is not used)
- * 'matchingTag' => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * 'notMatchingTag' => remove cache entries not matching one of the given tags
- * ($tags can be an array of strings or a single string)
- * 'matchingAnyTag' => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode
- * @param array|string $tags
- * @throws Zend_Cache_Exception
- * @return boolean True if ok
- */
- public function clean($mode = 'all', $tags = array())
- {
- if (!$this->_options['caching']) {
- return true;
- }
- if (!in_array($mode, array(Zend_Cache::CLEANING_MODE_ALL,
- Zend_Cache::CLEANING_MODE_OLD,
- Zend_Cache::CLEANING_MODE_MATCHING_TAG,
- Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG,
- Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG))) {
- Zend_Cache::throwException('Invalid cleaning mode');
- }
- $this->_validateTagsArray($tags);
-
- return $this->_backend->clean($mode, $tags);
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
- }
-
- $ids = $this->_backend->getIdsMatchingTags($tags);
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
- }
-
- $ids = $this->_backend->getIdsNotMatchingTags($tags);
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching any cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
- }
-
- $ids = $this->_backend->getIdsMatchingAnyTags($tags);
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
-
- $ids = $this->_backend->getIds();
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
- }
- return $this->_backend->getTags();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- return $this->_backend->getFillingPercentage();
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array will include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- $id = $this->_id($id); // cache id may need prefix
- return $this->_backend->getMetadatas($id);
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- $id = $this->_id($id); // cache id may need prefix
-
- $this->_log("Zend_Cache_Core: touch item '{$id}'", 7);
- return $this->_backend->touch($id, $extraLifetime);
- }
-
- /**
- * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)
- *
- * Throw an exception if a problem is found
- *
- * @param string $string Cache id or tag
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _validateIdOrTag($string)
- {
- if (!is_string($string)) {
- Zend_Cache::throwException('Invalid id or tag : must be a string');
- }
- if (substr($string, 0, 9) == 'internal-') {
- Zend_Cache::throwException('"internal-*" ids or tags are reserved');
- }
- if (!preg_match('~^[a-zA-Z0-9_]+$~D', $string)) {
- Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_]");
- }
- }
-
- /**
- * Validate a tags array (security, reliable filenames, reserved prefixes...)
- *
- * Throw an exception if a problem is found
- *
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _validateTagsArray($tags)
- {
- if (!is_array($tags)) {
- Zend_Cache::throwException('Invalid tags array : must be an array');
- }
- foreach($tags as $tag) {
- $this->_validateIdOrTag($tag);
- }
- reset($tags);
- }
-
- /**
- * Make sure if we enable logging that the Zend_Log class
- * is available.
- * Create a default log object if none is set.
- *
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _loggerSanity()
- {
- if (!isset($this->_options['logging']) || !$this->_options['logging']) {
- return;
- }
-
- if (isset($this->_options['logger']) && $this->_options['logger'] instanceof Zend_Log) {
- return;
- }
-
- // Create a default logger to the standard output stream
- require_once 'Zend/Log.php';
- require_once 'Zend/Log/Writer/Stream.php';
- require_once 'Zend/Log/Filter/Priority.php';
- $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
- $logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<='));
- $this->_options['logger'] = $logger;
- }
-
- /**
- * Log a message at the WARN (4) priority.
- *
- * @param string $message
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _log($message, $priority = 4)
- {
- if (!$this->_options['logging']) {
- return;
- }
- if (!(isset($this->_options['logger']) || $this->_options['logger'] instanceof Zend_Log)) {
- Zend_Cache::throwException('Logging is enabled but logger is not set');
- }
- $logger = $this->_options['logger'];
- $logger->log($message, $priority);
- }
-
- /**
- * Make and return a cache id
- *
- * Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null
- *
- * @param string $id Cache id
- * @return string Cache id (with or without prefix)
- */
- protected function _id($id)
- {
- if (($id !== null) && isset($this->_options['cache_id_prefix'])) {
- return $this->_options['cache_id_prefix'] . $id; // return with prefix
- }
- return $id; // no prefix, just return the $id passed
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Exception.php b/lib/zend/Zend/Cache/Exception.php
deleted file mode 100644
index ee53b20671bbe..0000000000000
--- a/lib/zend/Zend/Cache/Exception.php
+++ /dev/null
@@ -1,32 +0,0 @@
-_tags = $tags;
- $this->_extension = $extension;
- ob_start(array($this, '_flush'));
- ob_implicit_flush(false);
- $this->_idStack[] = $id;
- return false;
- }
-
- /**
- * callback for output buffering
- * (shouldn't really be called manually)
- *
- * @param string $data Buffered output
- * @return string Data to send to browser
- */
- public function _flush($data)
- {
- $id = array_pop($this->_idStack);
- if ($id === null) {
- Zend_Cache::throwException('use of _flush() without a start()');
- }
- if ($this->_extension) {
- $this->save(serialize(array($data, $this->_extension)), $id, $this->_tags);
- } else {
- $this->save($data, $id, $this->_tags);
- }
- return $data;
- }
-}
diff --git a/lib/zend/Zend/Cache/Frontend/Class.php b/lib/zend/Zend/Cache/Frontend/Class.php
deleted file mode 100644
index 4740402ac7338..0000000000000
--- a/lib/zend/Zend/Cache/Frontend/Class.php
+++ /dev/null
@@ -1,275 +0,0 @@
- (mixed) cached_entity :
- * - if set to a class name, we will cache an abstract class and will use only static calls
- * - if set to an object, we will cache this object methods
- *
- * ====> (boolean) cache_by_default :
- * - if true, method calls will be cached by default
- *
- * ====> (array) cached_methods :
- * - an array of method names which will be cached (even if cache_by_default = false)
- *
- * ====> (array) non_cached_methods :
- * - an array of method names which won't be cached (even if cache_by_default = true)
- *
- * @var array available options
- */
- protected $_specificOptions = array(
- 'cached_entity' => null,
- 'cache_by_default' => true,
- 'cached_methods' => array(),
- 'non_cached_methods' => array()
- );
-
- /**
- * Tags array
- *
- * @var array
- */
- protected $_tags = array();
-
- /**
- * SpecificLifetime value
- *
- * false => no specific life time
- *
- * @var bool|int
- */
- protected $_specificLifetime = false;
-
- /**
- * The cached object or the name of the cached abstract class
- *
- * @var mixed
- */
- protected $_cachedEntity = null;
-
- /**
- * The class name of the cached object or cached abstract class
- *
- * Used to differentiate between different classes with the same method calls.
- *
- * @var string
- */
- protected $_cachedEntityLabel = '';
-
- /**
- * Priority (used by some particular backends)
- *
- * @var int
- */
- protected $_priority = 8;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_Cache_Exception
- */
- public function __construct(array $options = array())
- {
- foreach ($options as $name => $value) {
- $this->setOption($name, $value);
- }
- if ($this->_specificOptions['cached_entity'] === null) {
- Zend_Cache::throwException('cached_entity must be set !');
- }
- $this->setCachedEntity($this->_specificOptions['cached_entity']);
- $this->setOption('automatic_serialization', true);
- }
-
- /**
- * Set a specific life time
- *
- * @param bool|int $specificLifetime
- * @return void
- */
- public function setSpecificLifetime($specificLifetime = false)
- {
- $this->_specificLifetime = $specificLifetime;
- }
-
- /**
- * Set the priority (used by some particular backends)
- *
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority)
- */
- public function setPriority($priority)
- {
- $this->_priority = $priority;
- }
-
- /**
- * Public frontend to set an option
- *
- * Just a wrapper to get a specific behaviour for cached_entity
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if ($name == 'cached_entity') {
- $this->setCachedEntity($value);
- } else {
- parent::setOption($name, $value);
- }
- }
-
- /**
- * Specific method to set the cachedEntity
- *
- * if set to a class name, we will cache an abstract class and will use only static calls
- * if set to an object, we will cache this object methods
- *
- * @param mixed $cachedEntity
- */
- public function setCachedEntity($cachedEntity)
- {
- if (!is_string($cachedEntity) && !is_object($cachedEntity)) {
- Zend_Cache::throwException(
- 'cached_entity must be an object or a class name'
- );
- }
-
- $this->_cachedEntity = $cachedEntity;
- $this->_specificOptions['cached_entity'] = $cachedEntity;
-
- if (is_string($this->_cachedEntity)) {
- $this->_cachedEntityLabel = $this->_cachedEntity;
- } else {
- $ro = new ReflectionObject($this->_cachedEntity);
- $this->_cachedEntityLabel = $ro->getName();
- }
- }
-
- /**
- * Set the cache array
- *
- * @param array $tags
- * @return void
- */
- public function setTagsArray($tags = array())
- {
- $this->_tags = $tags;
- }
-
- /**
- * Main method : call the specified method or get the result from cache
- *
- * @param string $name Method name
- * @param array $parameters Method parameters
- * @return mixed Result
- * @throws Exception
- */
- public function __call($name, $parameters)
- {
- $callback = array($this->_cachedEntity, $name);
-
- if (!is_callable($callback, false)) {
- Zend_Cache::throwException('Invalid callback');
- }
-
- $cacheBool1 = $this->_specificOptions['cache_by_default'];
- $cacheBool2 = in_array($name, $this->_specificOptions['cached_methods']);
- $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_methods']);
- $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
-
- if (!$cache) {
- // We do not have not cache
- return call_user_func_array($callback, $parameters);
- }
-
- $id = $this->makeId($name, $parameters);
- if (($rs = $this->load($id)) && (array_key_exists(0, $rs))
- && (array_key_exists(1, $rs))
- ) {
- // A cache is available
- $output = $rs[0];
- $return = $rs[1];
- } else {
- // A cache is not available (or not valid for this frontend)
- ob_start();
- ob_implicit_flush(false);
-
- try {
- $return = call_user_func_array($callback, $parameters);
- $output = ob_get_clean();
- $data = array($output, $return);
-
- $this->save(
- $data, $id, $this->_tags, $this->_specificLifetime,
- $this->_priority
- );
- } catch (Exception $e) {
- ob_end_clean();
- throw $e;
- }
- }
-
- echo $output;
- return $return;
- }
-
- /**
- * ZF-9970
- *
- * @deprecated
- */
- private function _makeId($name, $args)
- {
- return $this->makeId($name, $args);
- }
-
- /**
- * Make a cache id from the method name and parameters
- *
- * @param string $name Method name
- * @param array $args Method parameters
- * @return string Cache id
- */
- public function makeId($name, array $args = array())
- {
- return md5($this->_cachedEntityLabel . '__' . $name . '__' . serialize($args));
- }
-}
diff --git a/lib/zend/Zend/Cache/Frontend/File.php b/lib/zend/Zend/Cache/Frontend/File.php
deleted file mode 100644
index e5017c631ca70..0000000000000
--- a/lib/zend/Zend/Cache/Frontend/File.php
+++ /dev/null
@@ -1,222 +0,0 @@
- (string) master_file :
- * - a complete path of the master file
- * - deprecated (see master_files)
- *
- * ====> (array) master_files :
- * - an array of complete path of master files
- * - this option has to be set !
- *
- * ====> (string) master_files_mode :
- * - Zend_Cache_Frontend_File::MODE_AND or Zend_Cache_Frontend_File::MODE_OR
- * - if MODE_AND, then all master files have to be touched to get a cache invalidation
- * - if MODE_OR (default), then a single touched master file is enough to get a cache invalidation
- *
- * ====> (boolean) ignore_missing_master_files
- * - if set to true, missing master files are ignored silently
- * - if set to false (default), an exception is thrown if there is a missing master file
- * @var array available options
- */
- protected $_specificOptions = array(
- 'master_file' => null,
- 'master_files' => null,
- 'master_files_mode' => 'OR',
- 'ignore_missing_master_files' => false
- );
-
- /**
- * Master file mtimes
- *
- * Array of int
- *
- * @var array
- */
- private $_masterFile_mtimes = null;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- foreach ($options as $name => $value) {
- $this->setOption($name, $value);
- }
- if (!isset($this->_specificOptions['master_files'])) {
- Zend_Cache::throwException('master_files option must be set');
- }
- }
-
- /**
- * Change the master_files option
- *
- * @param array $masterFiles the complete paths and name of the master files
- */
- public function setMasterFiles(array $masterFiles)
- {
- $this->_specificOptions['master_file'] = null; // to keep a compatibility
- $this->_specificOptions['master_files'] = null;
- $this->_masterFile_mtimes = array();
-
- clearstatcache();
- $i = 0;
- foreach ($masterFiles as $masterFile) {
- if (file_exists($masterFile)) {
- $mtime = filemtime($masterFile);
- } else {
- $mtime = false;
- }
-
- if (!$this->_specificOptions['ignore_missing_master_files'] && !$mtime) {
- Zend_Cache::throwException('Unable to read master_file : ' . $masterFile);
- }
-
- $this->_masterFile_mtimes[$i] = $mtime;
- $this->_specificOptions['master_files'][$i] = $masterFile;
- if ($i === 0) { // to keep a compatibility
- $this->_specificOptions['master_file'] = $masterFile;
- }
-
- $i++;
- }
- }
-
- /**
- * Change the master_file option
- *
- * To keep the compatibility
- *
- * @deprecated
- * @param string $masterFile the complete path and name of the master file
- */
- public function setMasterFile($masterFile)
- {
- $this->setMasterFiles(array($masterFile));
- }
-
- /**
- * Public frontend to set an option
- *
- * Just a wrapper to get a specific behaviour for master_file
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if ($name == 'master_file') {
- $this->setMasterFile($value);
- } else if ($name == 'master_files') {
- $this->setMasterFiles($value);
- } else {
- parent::setOption($name, $value);
- }
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @param boolean $doNotUnserialize Do not serialize (even if automatic_serialization is true) => for internal use
- * @return mixed|false Cached datas
- */
- public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false)
- {
- if (!$doNotTestCacheValidity) {
- if ($this->test($id)) {
- return parent::load($id, true, $doNotUnserialize);
- }
- return false;
- }
- return parent::load($id, true, $doNotUnserialize);
- }
-
- /**
- * Test if a cache is available for the given id
- *
- * @param string $id Cache id
- * @return int|false Last modified time of cache entry if it is available, false otherwise
- */
- public function test($id)
- {
- $lastModified = parent::test($id);
- if ($lastModified) {
- if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) {
- // MODE_AND
- foreach($this->_masterFile_mtimes as $masterFileMTime) {
- if ($masterFileMTime) {
- if ($lastModified > $masterFileMTime) {
- return $lastModified;
- }
- }
- }
- } else {
- // MODE_OR
- $res = true;
- foreach($this->_masterFile_mtimes as $masterFileMTime) {
- if ($masterFileMTime) {
- if ($lastModified <= $masterFileMTime) {
- return false;
- }
- }
- }
- return $lastModified;
- }
- }
- return false;
- }
-
-}
-
diff --git a/lib/zend/Zend/Cache/Frontend/Function.php b/lib/zend/Zend/Cache/Frontend/Function.php
deleted file mode 100644
index 8af521bda69f9..0000000000000
--- a/lib/zend/Zend/Cache/Frontend/Function.php
+++ /dev/null
@@ -1,179 +0,0 @@
- (boolean) cache_by_default :
- * - if true, function calls will be cached by default
- *
- * ====> (array) cached_functions :
- * - an array of function names which will be cached (even if cache_by_default = false)
- *
- * ====> (array) non_cached_functions :
- * - an array of function names which won't be cached (even if cache_by_default = true)
- *
- * @var array options
- */
- protected $_specificOptions = array(
- 'cache_by_default' => true,
- 'cached_functions' => array(),
- 'non_cached_functions' => array()
- );
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @return void
- */
- public function __construct(array $options = array())
- {
- foreach ($options as $name => $value) {
- $this->setOption($name, $value);
- }
- $this->setOption('automatic_serialization', true);
- }
-
- /**
- * Main method : call the specified function or get the result from cache
- *
- * @param callback $callback A valid callback
- * @param array $parameters Function parameters
- * @param array $tags Cache tags
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @return mixed Result
- */
- public function call($callback, array $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8)
- {
- if (!is_callable($callback, true, $name)) {
- Zend_Cache::throwException('Invalid callback');
- }
-
- $cacheBool1 = $this->_specificOptions['cache_by_default'];
- $cacheBool2 = in_array($name, $this->_specificOptions['cached_functions']);
- $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_functions']);
- $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
- if (!$cache) {
- // Caching of this callback is disabled
- return call_user_func_array($callback, $parameters);
- }
-
- $id = $this->_makeId($callback, $parameters);
- if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1])) {
- // A cache is available
- $output = $rs[0];
- $return = $rs[1];
- } else {
- // A cache is not available (or not valid for this frontend)
- ob_start();
- ob_implicit_flush(false);
- $return = call_user_func_array($callback, $parameters);
- $output = ob_get_clean();
- $data = array($output, $return);
- $this->save($data, $id, $tags, $specificLifetime, $priority);
- }
-
- echo $output;
- return $return;
- }
-
- /**
- * ZF-9970
- *
- * @deprecated
- */
- private function _makeId($callback, array $args)
- {
- return $this->makeId($callback, $args);
- }
-
- /**
- * Make a cache id from the function name and parameters
- *
- * @param callback $callback A valid callback
- * @param array $args Function parameters
- * @throws Zend_Cache_Exception
- * @return string Cache id
- */
- public function makeId($callback, array $args = array())
- {
- if (!is_callable($callback, true, $name)) {
- Zend_Cache::throwException('Invalid callback');
- }
-
- // functions, methods and classnames are case-insensitive
- $name = strtolower($name);
-
- // generate a unique id for object callbacks
- if (is_object($callback)) { // Closures & __invoke
- $object = $callback;
- } elseif (isset($callback[0])) { // array($object, 'method')
- $object = $callback[0];
- }
- if (isset($object)) {
- try {
- $tmp = @serialize($callback);
- } catch (Exception $e) {
- Zend_Cache::throwException($e->getMessage());
- }
- if (!$tmp) {
- $lastErr = error_get_last();
- Zend_Cache::throwException("Can't serialize callback object to generate id: {$lastErr['message']}");
- }
- $name.= '__' . $tmp;
- }
-
- // generate a unique id for arguments
- $argsStr = '';
- if ($args) {
- try {
- $argsStr = @serialize(array_values($args));
- } catch (Exception $e) {
- Zend_Cache::throwException($e->getMessage());
- }
- if (!$argsStr) {
- $lastErr = error_get_last();
- throw Zend_Cache::throwException("Can't serialize arguments to generate id: {$lastErr['message']}");
- }
- }
-
- return md5($name . $argsStr);
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Frontend/Output.php b/lib/zend/Zend/Cache/Frontend/Output.php
deleted file mode 100644
index 99a8a64c9d8fc..0000000000000
--- a/lib/zend/Zend/Cache/Frontend/Output.php
+++ /dev/null
@@ -1,105 +0,0 @@
-_idStack = array();
- }
-
- /**
- * Start the cache
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @param boolean $echoData If set to true, datas are sent to the browser if the cache is hit (simply returned else)
- * @return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas)
- */
- public function start($id, $doNotTestCacheValidity = false, $echoData = true)
- {
- $data = $this->load($id, $doNotTestCacheValidity);
- if ($data !== false) {
- if ( $echoData ) {
- echo($data);
- return true;
- } else {
- return $data;
- }
- }
- ob_start();
- ob_implicit_flush(false);
- $this->_idStack[] = $id;
- return false;
- }
-
- /**
- * Stop the cache
- *
- * @param array $tags Tags array
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param string $forcedDatas If not null, force written datas with this
- * @param boolean $echoData If set to true, datas are sent to the browser
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @return void
- */
- public function end($tags = array(), $specificLifetime = false, $forcedDatas = null, $echoData = true, $priority = 8)
- {
- if ($forcedDatas === null) {
- $data = ob_get_clean();
- } else {
- $data =& $forcedDatas;
- }
- $id = array_pop($this->_idStack);
- if ($id === null) {
- Zend_Cache::throwException('use of end() without a start()');
- }
- $this->save($data, $id, $tags, $specificLifetime, $priority);
- if ($echoData) {
- echo($data);
- }
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Frontend/Page.php b/lib/zend/Zend/Cache/Frontend/Page.php
deleted file mode 100644
index cc253d559c8ac..0000000000000
--- a/lib/zend/Zend/Cache/Frontend/Page.php
+++ /dev/null
@@ -1,404 +0,0 @@
- (boolean) http_conditional :
- * - if true, http conditional mode is on
- * WARNING : http_conditional OPTION IS NOT IMPLEMENTED FOR THE MOMENT (TODO)
- *
- * ====> (boolean) debug_header :
- * - if true, a debug text is added before each cached pages
- *
- * ====> (boolean) content_type_memorization :
- * - deprecated => use memorize_headers instead
- * - if the Content-Type header is sent after the cache was started, the
- * corresponding value can be memorized and replayed when the cache is hit
- * (if false (default), the frontend doesn't take care of Content-Type header)
- *
- * ====> (array) memorize_headers :
- * - an array of strings corresponding to some HTTP headers name. Listed headers
- * will be stored with cache datas and "replayed" when the cache is hit
- *
- * ====> (array) default_options :
- * - an associative array of default options :
- * - (boolean) cache : cache is on by default if true
- * - (boolean) cacheWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') :
- * if true, cache is still on even if there are some variables in this superglobal array
- * if false, cache is off if there are some variables in this superglobal array
- * - (boolean) makeIdWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') :
- * if true, we have to use the content of this superglobal array to make a cache id
- * if false, the cache id won't be dependent of the content of this superglobal array
- * - (int) specific_lifetime : cache specific lifetime
- * (false => global lifetime is used, null => infinite lifetime,
- * integer => this lifetime is used), this "lifetime" is probably only
- * usefull when used with "regexps" array
- * - (array) tags : array of tags (strings)
- * - (int) priority : integer between 0 (very low priority) and 10 (maximum priority) used by
- * some particular backends
- *
- * ====> (array) regexps :
- * - an associative array to set options only for some REQUEST_URI
- * - keys are (pcre) regexps
- * - values are associative array with specific options to set if the regexp matchs on $_SERVER['REQUEST_URI']
- * (see default_options for the list of available options)
- * - if several regexps match the $_SERVER['REQUEST_URI'], only the last one will be used
- *
- * @var array options
- */
- protected $_specificOptions = array(
- 'http_conditional' => false,
- 'debug_header' => false,
- 'content_type_memorization' => false,
- 'memorize_headers' => array(),
- 'default_options' => array(
- 'cache_with_get_variables' => false,
- 'cache_with_post_variables' => false,
- 'cache_with_session_variables' => false,
- 'cache_with_files_variables' => false,
- 'cache_with_cookie_variables' => false,
- 'make_id_with_get_variables' => true,
- 'make_id_with_post_variables' => true,
- 'make_id_with_session_variables' => true,
- 'make_id_with_files_variables' => true,
- 'make_id_with_cookie_variables' => true,
- 'cache' => true,
- 'specific_lifetime' => false,
- 'tags' => array(),
- 'priority' => null
- ),
- 'regexps' => array()
- );
-
- /**
- * Internal array to store some options
- *
- * @var array associative array of options
- */
- protected $_activeOptions = array();
-
- /**
- * If true, the page won't be cached
- *
- * @var boolean
- */
- protected $_cancel = false;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- foreach ($options as $name => $value) {
- $name = strtolower($name);
- switch ($name) {
- case 'regexps':
- $this->_setRegexps($value);
- break;
- case 'default_options':
- $this->_setDefaultOptions($value);
- break;
- case 'content_type_memorization':
- $this->_setContentTypeMemorization($value);
- break;
- default:
- $this->setOption($name, $value);
- }
- }
- if (isset($this->_specificOptions['http_conditional'])) {
- if ($this->_specificOptions['http_conditional']) {
- Zend_Cache::throwException('http_conditional is not implemented for the moment !');
- }
- }
- $this->setOption('automatic_serialization', true);
- }
-
- /**
- * Specific setter for the 'default_options' option (with some additional tests)
- *
- * @param array $options Associative array
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _setDefaultOptions($options)
- {
- if (!is_array($options)) {
- Zend_Cache::throwException('default_options must be an array !');
- }
- foreach ($options as $key=>$value) {
- if (!is_string($key)) {
- Zend_Cache::throwException("invalid option [$key] !");
- }
- $key = strtolower($key);
- if (isset($this->_specificOptions['default_options'][$key])) {
- $this->_specificOptions['default_options'][$key] = $value;
- }
- }
- }
-
- /**
- * Set the deprecated contentTypeMemorization option
- *
- * @param boolean $value value
- * @return void
- * @deprecated
- */
- protected function _setContentTypeMemorization($value)
- {
- $found = null;
- foreach ($this->_specificOptions['memorize_headers'] as $key => $value) {
- if (strtolower($value) == 'content-type') {
- $found = $key;
- }
- }
- if ($value) {
- if (!$found) {
- $this->_specificOptions['memorize_headers'][] = 'Content-Type';
- }
- } else {
- if ($found) {
- unset($this->_specificOptions['memorize_headers'][$found]);
- }
- }
- }
-
- /**
- * Specific setter for the 'regexps' option (with some additional tests)
- *
- * @param array $options Associative array
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _setRegexps($regexps)
- {
- if (!is_array($regexps)) {
- Zend_Cache::throwException('regexps option must be an array !');
- }
- foreach ($regexps as $regexp=>$conf) {
- if (!is_array($conf)) {
- Zend_Cache::throwException('regexps option must be an array of arrays !');
- }
- $validKeys = array_keys($this->_specificOptions['default_options']);
- foreach ($conf as $key=>$value) {
- if (!is_string($key)) {
- Zend_Cache::throwException("unknown option [$key] !");
- }
- $key = strtolower($key);
- if (!in_array($key, $validKeys)) {
- unset($regexps[$regexp][$key]);
- }
- }
- }
- $this->setOption('regexps', $regexps);
- }
-
- /**
- * Start the cache
- *
- * @param string $id (optional) A cache id (if you set a value here, maybe you have to use Output frontend instead)
- * @param boolean $doNotDie For unit testing only !
- * @return boolean True if the cache is hit (false else)
- */
- public function start($id = false, $doNotDie = false)
- {
- $this->_cancel = false;
- $lastMatchingRegexp = null;
- if (isset($_SERVER['REQUEST_URI'])) {
- foreach ($this->_specificOptions['regexps'] as $regexp => $conf) {
- if (preg_match("`$regexp`", $_SERVER['REQUEST_URI'])) {
- $lastMatchingRegexp = $regexp;
- }
- }
- }
- $this->_activeOptions = $this->_specificOptions['default_options'];
- if ($lastMatchingRegexp !== null) {
- $conf = $this->_specificOptions['regexps'][$lastMatchingRegexp];
- foreach ($conf as $key=>$value) {
- $this->_activeOptions[$key] = $value;
- }
- }
- if (!($this->_activeOptions['cache'])) {
- return false;
- }
- if (!$id) {
- $id = $this->_makeId();
- if (!$id) {
- return false;
- }
- }
- $array = $this->load($id);
- if ($array !== false) {
- $data = $array['data'];
- $headers = $array['headers'];
- if (!headers_sent()) {
- foreach ($headers as $key=>$headerCouple) {
- $name = $headerCouple[0];
- $value = $headerCouple[1];
- header("$name: $value");
- }
- }
- if ($this->_specificOptions['debug_header']) {
- echo 'DEBUG HEADER : This is a cached page !';
- }
- echo $data;
- if ($doNotDie) {
- return true;
- }
- die();
- }
- ob_start(array($this, '_flush'));
- ob_implicit_flush(false);
- return false;
- }
-
- /**
- * Cancel the current caching process
- */
- public function cancel()
- {
- $this->_cancel = true;
- }
-
- /**
- * callback for output buffering
- * (shouldn't really be called manually)
- *
- * @param string $data Buffered output
- * @return string Data to send to browser
- */
- public function _flush($data)
- {
- if ($this->_cancel) {
- return $data;
- }
- $contentType = null;
- $storedHeaders = array();
- $headersList = headers_list();
- foreach($this->_specificOptions['memorize_headers'] as $key=>$headerName) {
- foreach ($headersList as $headerSent) {
- $tmp = explode(':', $headerSent);
- $headerSentName = trim(array_shift($tmp));
- if (strtolower($headerName) == strtolower($headerSentName)) {
- $headerSentValue = trim(implode(':', $tmp));
- $storedHeaders[] = array($headerSentName, $headerSentValue);
- }
- }
- }
- $array = array(
- 'data' => $data,
- 'headers' => $storedHeaders
- );
- $this->save($array, null, $this->_activeOptions['tags'], $this->_activeOptions['specific_lifetime'], $this->_activeOptions['priority']);
- return $data;
- }
-
- /**
- * Make an id depending on REQUEST_URI and superglobal arrays (depending on options)
- *
- * @return mixed|false a cache id (string), false if the cache should have not to be used
- */
- protected function _makeId()
- {
- $tmp = $_SERVER['REQUEST_URI'];
- $array = explode('?', $tmp, 2);
- $tmp = $array[0];
- foreach (array('Get', 'Post', 'Session', 'Files', 'Cookie') as $arrayName) {
- $tmp2 = $this->_makePartialId($arrayName, $this->_activeOptions['cache_with_' . strtolower($arrayName) . '_variables'], $this->_activeOptions['make_id_with_' . strtolower($arrayName) . '_variables']);
- if ($tmp2===false) {
- return false;
- }
- $tmp = $tmp . $tmp2;
- }
- return md5($tmp);
- }
-
- /**
- * Make a partial id depending on options
- *
- * @param string $arrayName Superglobal array name
- * @param bool $bool1 If true, cache is still on even if there are some variables in the superglobal array
- * @param bool $bool2 If true, we have to use the content of the superglobal array to make a partial id
- * @return mixed|false Partial id (string) or false if the cache should have not to be used
- */
- protected function _makePartialId($arrayName, $bool1, $bool2)
- {
- switch ($arrayName) {
- case 'Get':
- $var = $_GET;
- break;
- case 'Post':
- $var = $_POST;
- break;
- case 'Session':
- if (isset($_SESSION)) {
- $var = $_SESSION;
- } else {
- $var = null;
- }
- break;
- case 'Cookie':
- if (isset($_COOKIE)) {
- $var = $_COOKIE;
- } else {
- $var = null;
- }
- break;
- case 'Files':
- $var = $_FILES;
- break;
- default:
- return false;
- }
- if ($bool1) {
- if ($bool2) {
- return serialize($var);
- }
- return '';
- }
- if (count($var) > 0) {
- return false;
- }
- return '';
- }
-
-}
diff --git a/lib/zend/Zend/Cache/Manager.php b/lib/zend/Zend/Cache/Manager.php
deleted file mode 100644
index 330ea954e856a..0000000000000
--- a/lib/zend/Zend/Cache/Manager.php
+++ /dev/null
@@ -1,308 +0,0 @@
- array(
- 'frontend' => array(
- 'name' => 'Core',
- 'options' => array(
- 'automatic_serialization' => true,
- ),
- ),
- 'backend' => array(
- 'name' => 'File',
- 'options' => array(
- // use system temp dir by default of file backend
- // 'cache_dir' => '../cache',
- ),
- ),
- ),
-
- // Static Page HTML Cache
- 'page' => array(
- 'frontend' => array(
- 'name' => 'Capture',
- 'options' => array(
- 'ignore_user_abort' => true,
- ),
- ),
- 'backend' => array(
- 'name' => 'Static',
- 'options' => array(
- 'public_dir' => '../public',
- ),
- ),
- ),
-
- // Tag Cache
- 'pagetag' => array(
- 'frontend' => array(
- 'name' => 'Core',
- 'options' => array(
- 'automatic_serialization' => true,
- 'lifetime' => null
- ),
- ),
- 'backend' => array(
- 'name' => 'File',
- 'options' => array(
- // use system temp dir by default of file backend
- // 'cache_dir' => '../cache',
- // use default umask of file backend
- // 'cache_file_umask' => 0644
- ),
- ),
- ),
- );
-
- /**
- * Set a new cache for the Cache Manager to contain
- *
- * @param string $name
- * @param Zend_Cache_Core $cache
- * @return Zend_Cache_Manager
- */
- public function setCache($name, Zend_Cache_Core $cache)
- {
- $this->_caches[$name] = $cache;
- return $this;
- }
-
- /**
- * Check if the Cache Manager contains the named cache object, or a named
- * configuration template to lazy load the cache object
- *
- * @param string $name
- * @return bool
- */
- public function hasCache($name)
- {
- if (isset($this->_caches[$name])
- || $this->hasCacheTemplate($name)
- ) {
- return true;
- }
- return false;
- }
-
- /**
- * Fetch the named cache object, or instantiate and return a cache object
- * using a named configuration template
- *
- * @param string $name
- * @return Zend_Cache_Core
- */
- public function getCache($name)
- {
- if (isset($this->_caches[$name])) {
- return $this->_caches[$name];
- }
- if (isset($this->_optionTemplates[$name])) {
- if ($name == self::PAGECACHE
- && (!isset($this->_optionTemplates[$name]['backend']['options']['tag_cache'])
- || !$this->_optionTemplates[$name]['backend']['options']['tag_cache'] instanceof Zend_Cache_Core)
- ) {
- $this->_optionTemplates[$name]['backend']['options']['tag_cache']
- = $this->getCache(self::PAGETAGCACHE);
- }
-
- $this->_caches[$name] = Zend_Cache::factory(
- $this->_optionTemplates[$name]['frontend']['name'],
- $this->_optionTemplates[$name]['backend']['name'],
- isset($this->_optionTemplates[$name]['frontend']['options']) ? $this->_optionTemplates[$name]['frontend']['options'] : array(),
- isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array(),
- isset($this->_optionTemplates[$name]['frontend']['customFrontendNaming']) ? $this->_optionTemplates[$name]['frontend']['customFrontendNaming'] : false,
- isset($this->_optionTemplates[$name]['backend']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['customBackendNaming'] : false,
- isset($this->_optionTemplates[$name]['frontendBackendAutoload']) ? $this->_optionTemplates[$name]['frontendBackendAutoload'] : false
- );
-
- return $this->_caches[$name];
- }
- }
-
- /**
- * Fetch all available caches
- *
- * @return array An array of all available caches with it's names as key
- */
- public function getCaches()
- {
- $caches = $this->_caches;
- foreach ($this->_optionTemplates as $name => $tmp) {
- if (!isset($caches[$name])) {
- $caches[$name] = $this->getCache($name);
- }
- }
- return $caches;
- }
-
- /**
- * Set a named configuration template from which a cache object can later
- * be lazy loaded
- *
- * @param string $name
- * @param array $options
- * @return Zend_Cache_Manager
- * @throws Zend_Cache_Exception
- */
- public function setCacheTemplate($name, $options)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (!is_array($options)) {
- require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception('Options passed must be in'
- . ' an associative array or instance of Zend_Config');
- }
- $this->_optionTemplates[$name] = $options;
- return $this;
- }
-
- /**
- * Check if the named configuration template
- *
- * @param string $name
- * @return bool
- */
- public function hasCacheTemplate($name)
- {
- if (isset($this->_optionTemplates[$name])) {
- return true;
- }
- return false;
- }
-
- /**
- * Get the named configuration template
- *
- * @param string $name
- * @return array
- */
- public function getCacheTemplate($name)
- {
- if (isset($this->_optionTemplates[$name])) {
- return $this->_optionTemplates[$name];
- }
- }
-
- /**
- * Pass an array containing changes to be applied to a named
- * configuration
- * template
- *
- * @param string $name
- * @param array $options
- * @return Zend_Cache_Manager
- * @throws Zend_Cache_Exception for invalid options format or if option templates do not have $name
- */
- public function setTemplateOptions($name, $options)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (!is_array($options)) {
- require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception('Options passed must be in'
- . ' an associative array or instance of Zend_Config');
- }
- if (!isset($this->_optionTemplates[$name])) {
- throw new Zend_Cache_Exception('A cache configuration template'
- . 'does not exist with the name "' . $name . '"');
- }
- $this->_optionTemplates[$name]
- = $this->_mergeOptions($this->_optionTemplates[$name], $options);
- return $this;
- }
-
- /**
- * Simple method to merge two configuration arrays
- *
- * @param array $current
- * @param array $options
- * @return array
- */
- protected function _mergeOptions(array $current, array $options)
- {
- if (isset($options['frontend']['name'])) {
- $current['frontend']['name'] = $options['frontend']['name'];
- }
- if (isset($options['backend']['name'])) {
- $current['backend']['name'] = $options['backend']['name'];
- }
- if (isset($options['frontend']['options'])) {
- foreach ($options['frontend']['options'] as $key => $value) {
- $current['frontend']['options'][$key] = $value;
- }
- }
- if (isset($options['backend']['options'])) {
- foreach ($options['backend']['options'] as $key => $value) {
- $current['backend']['options'][$key] = $value;
- }
- }
- if (isset($options['frontend']['customFrontendNaming'])) {
- $current['frontend']['customFrontendNaming'] = $options['frontend']['customFrontendNaming'];
- }
- if (isset($options['backend']['customBackendNaming'])) {
- $current['backend']['customBackendNaming'] = $options['backend']['customBackendNaming'];
- }
- if (isset($options['frontendBackendAutoload'])) {
- $current['frontendBackendAutoload'] = $options['frontendBackendAutoload'];
- }
- return $current;
- }
-}
diff --git a/lib/zend/Zend/Config.php b/lib/zend/Zend/Config.php
deleted file mode 100644
index a39a1f22559d6..0000000000000
--- a/lib/zend/Zend/Config.php
+++ /dev/null
@@ -1,484 +0,0 @@
-_allowModifications = (boolean) $allowModifications;
- $this->_loadedSection = null;
- $this->_index = 0;
- $this->_data = array();
- foreach ($array as $key => $value) {
- if (is_array($value)) {
- $this->_data[$key] = new self($value, $this->_allowModifications);
- } else {
- $this->_data[$key] = $value;
- }
- }
- $this->_count = count($this->_data);
- }
-
- /**
- * Retrieve a value and return $default if there is no element set.
- *
- * @param string $name
- * @param mixed $default
- * @return mixed
- */
- public function get($name, $default = null)
- {
- $result = $default;
- if (array_key_exists($name, $this->_data)) {
- $result = $this->_data[$name];
- }
- return $result;
- }
-
- /**
- * Magic function so that $obj->value will work.
- *
- * @param string $name
- * @return mixed
- */
- public function __get($name)
- {
- return $this->get($name);
- }
-
- /**
- * Only allow setting of a property if $allowModifications
- * was set to true on construction. Otherwise, throw an exception.
- *
- * @param string $name
- * @param mixed $value
- * @throws Zend_Config_Exception
- * @return void
- */
- public function __set($name, $value)
- {
- if ($this->_allowModifications) {
- if (is_array($value)) {
- $this->_data[$name] = new self($value, true);
- } else {
- $this->_data[$name] = $value;
- }
- $this->_count = count($this->_data);
- } else {
- /** @see Zend_Config_Exception */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Zend_Config is read only');
- }
- }
-
- /**
- * Deep clone of this instance to ensure that nested Zend_Configs
- * are also cloned.
- *
- * @return void
- */
- public function __clone()
- {
- $array = array();
- foreach ($this->_data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $array[$key] = clone $value;
- } else {
- $array[$key] = $value;
- }
- }
- $this->_data = $array;
- }
-
- /**
- * Return an associative array of the stored data.
- *
- * @return array
- */
- public function toArray()
- {
- $array = array();
- $data = $this->_data;
- foreach ($data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $array[$key] = $value->toArray();
- } else {
- $array[$key] = $value;
- }
- }
- return $array;
- }
-
- /**
- * Support isset() overloading on PHP 5.1
- *
- * @param string $name
- * @return boolean
- */
- public function __isset($name)
- {
- return isset($this->_data[$name]);
- }
-
- /**
- * Support unset() overloading on PHP 5.1
- *
- * @param string $name
- * @throws Zend_Config_Exception
- * @return void
- */
- public function __unset($name)
- {
- if ($this->_allowModifications) {
- unset($this->_data[$name]);
- $this->_count = count($this->_data);
- $this->_skipNextIteration = true;
- } else {
- /** @see Zend_Config_Exception */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Zend_Config is read only');
- }
-
- }
-
- /**
- * Defined by Countable interface
- *
- * @return int
- */
- public function count()
- {
- return $this->_count;
- }
-
- /**
- * Defined by Iterator interface
- *
- * @return mixed
- */
- public function current()
- {
- $this->_skipNextIteration = false;
- return current($this->_data);
- }
-
- /**
- * Defined by Iterator interface
- *
- * @return mixed
- */
- public function key()
- {
- return key($this->_data);
- }
-
- /**
- * Defined by Iterator interface
- *
- */
- public function next()
- {
- if ($this->_skipNextIteration) {
- $this->_skipNextIteration = false;
- return;
- }
- next($this->_data);
- $this->_index++;
- }
-
- /**
- * Defined by Iterator interface
- *
- */
- public function rewind()
- {
- $this->_skipNextIteration = false;
- reset($this->_data);
- $this->_index = 0;
- }
-
- /**
- * Defined by Iterator interface
- *
- * @return boolean
- */
- public function valid()
- {
- return $this->_index < $this->_count;
- }
-
- /**
- * Returns the section name(s) loaded.
- *
- * @return mixed
- */
- public function getSectionName()
- {
- if(is_array($this->_loadedSection) && count($this->_loadedSection) == 1) {
- $this->_loadedSection = $this->_loadedSection[0];
- }
- return $this->_loadedSection;
- }
-
- /**
- * Returns true if all sections were loaded
- *
- * @return boolean
- */
- public function areAllSectionsLoaded()
- {
- return $this->_loadedSection === null;
- }
-
-
- /**
- * Merge another Zend_Config with this one. The items
- * in $merge will override the same named items in
- * the current config.
- *
- * @param Zend_Config $merge
- * @return Zend_Config
- */
- public function merge(Zend_Config $merge)
- {
- foreach($merge as $key => $item) {
- if(array_key_exists($key, $this->_data)) {
- if($item instanceof Zend_Config && $this->$key instanceof Zend_Config) {
- $this->$key = $this->$key->merge(new Zend_Config($item->toArray(), !$this->readOnly()));
- } else {
- $this->$key = $item;
- }
- } else {
- if($item instanceof Zend_Config) {
- $this->$key = new Zend_Config($item->toArray(), !$this->readOnly());
- } else {
- $this->$key = $item;
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Prevent any more modifications being made to this instance. Useful
- * after merge() has been used to merge multiple Zend_Config objects
- * into one object which should then not be modified again.
- *
- */
- public function setReadOnly()
- {
- $this->_allowModifications = false;
- foreach ($this->_data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $value->setReadOnly();
- }
- }
- }
-
- /**
- * Returns if this Zend_Config object is read only or not.
- *
- * @return boolean
- */
- public function readOnly()
- {
- return !$this->_allowModifications;
- }
-
- /**
- * Get the current extends
- *
- * @return array
- */
- public function getExtends()
- {
- return $this->_extends;
- }
-
- /**
- * Set an extend for Zend_Config_Writer
- *
- * @param string $extendingSection
- * @param string $extendedSection
- * @return void
- */
- public function setExtend($extendingSection, $extendedSection = null)
- {
- if ($extendedSection === null && isset($this->_extends[$extendingSection])) {
- unset($this->_extends[$extendingSection]);
- } else if ($extendedSection !== null) {
- $this->_extends[$extendingSection] = $extendedSection;
- }
- }
-
- /**
- * Throws an exception if $extendingSection may not extend $extendedSection,
- * and tracks the section extension if it is valid.
- *
- * @param string $extendingSection
- * @param string $extendedSection
- * @throws Zend_Config_Exception
- * @return void
- */
- protected function _assertValidExtend($extendingSection, $extendedSection)
- {
- // detect circular section inheritance
- $extendedSectionCurrent = $extendedSection;
- while (array_key_exists($extendedSectionCurrent, $this->_extends)) {
- if ($this->_extends[$extendedSectionCurrent] == $extendingSection) {
- /** @see Zend_Config_Exception */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Illegal circular inheritance detected');
- }
- $extendedSectionCurrent = $this->_extends[$extendedSectionCurrent];
- }
- // remember that this section extends another section
- $this->_extends[$extendingSection] = $extendedSection;
- }
-
- /**
- * Handle any errors from simplexml_load_file or parse_ini_file
- *
- * @param integer $errno
- * @param string $errstr
- * @param string $errfile
- * @param integer $errline
- */
- public function _loadFileErrorHandler($errno, $errstr, $errfile, $errline)
- {
- if ($this->_loadFileErrorStr === null) {
- $this->_loadFileErrorStr = $errstr;
- } else {
- $this->_loadFileErrorStr .= (PHP_EOL . $errstr);
- }
- }
-
- /**
- * Merge two arrays recursively, overwriting keys of the same name
- * in $firstArray with the value in $secondArray.
- *
- * @param mixed $firstArray First array
- * @param mixed $secondArray Second array to merge into first array
- * @return array
- */
- protected function _arrayMergeRecursive($firstArray, $secondArray)
- {
- if (is_array($firstArray) && is_array($secondArray)) {
- foreach ($secondArray as $key => $value) {
- if (isset($firstArray[$key])) {
- $firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key], $value);
- } else {
- if($key === 0) {
- $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray, $value));
- } else {
- $firstArray[$key] = $value;
- }
- }
- }
- } else {
- $firstArray = $secondArray;
- }
-
- return $firstArray;
- }
-}
diff --git a/lib/zend/Zend/Config/Exception.php b/lib/zend/Zend/Config/Exception.php
deleted file mode 100644
index 253b3346825cd..0000000000000
--- a/lib/zend/Zend/Config/Exception.php
+++ /dev/null
@@ -1,33 +0,0 @@
-hostname === "staging"
- * $data->db->connection === "database"
- *
- * The $options parameter may be provided as either a boolean or an array.
- * If provided as a boolean, this sets the $allowModifications option of
- * Zend_Config. If provided as an array, there are three configuration
- * directives that may be set. For example:
- *
- * $options = array(
- * 'allowModifications' => false,
- * 'nestSeparator' => ':',
- * 'skipExtends' => false,
- * );
- *
- * @param string $filename
- * @param mixed $section
- * @param boolean|array $options
- * @throws Zend_Config_Exception
- * @return void
- */
- public function __construct($filename, $section = null, $options = false)
- {
- if (empty($filename)) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Filename is not set');
- }
-
- $allowModifications = false;
- if (is_bool($options)) {
- $allowModifications = $options;
- } elseif (is_array($options)) {
- if (isset($options['allowModifications'])) {
- $allowModifications = (bool) $options['allowModifications'];
- }
- if (isset($options['nestSeparator'])) {
- $this->_nestSeparator = (string) $options['nestSeparator'];
- }
- if (isset($options['skipExtends'])) {
- $this->_skipExtends = (bool) $options['skipExtends'];
- }
- }
-
- $iniArray = $this->_loadIniFile($filename);
-
- if (null === $section) {
- // Load entire file
- $dataArray = array();
- foreach ($iniArray as $sectionName => $sectionData) {
- if(!is_array($sectionData)) {
- $dataArray = $this->_arrayMergeRecursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData));
- } else {
- $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName);
- }
- }
- parent::__construct($dataArray, $allowModifications);
- } else {
- // Load one or more sections
- if (!is_array($section)) {
- $section = array($section);
- }
- $dataArray = array();
- foreach ($section as $sectionName) {
- if (!isset($iniArray[$sectionName])) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $filename");
- }
- $dataArray = $this->_arrayMergeRecursive($this->_processSection($iniArray, $sectionName), $dataArray);
-
- }
- parent::__construct($dataArray, $allowModifications);
- }
-
- $this->_loadedSection = $section;
- }
-
- /**
- * Load the INI file from disk using parse_ini_file(). Use a private error
- * handler to convert any loading errors into a Zend_Config_Exception
- *
- * @param string $filename
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _parseIniFile($filename)
- {
- set_error_handler(array($this, '_loadFileErrorHandler'));
- $iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed
- restore_error_handler();
-
- // Check if there was a error while loading file
- if ($this->_loadFileErrorStr !== null) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception($this->_loadFileErrorStr);
- }
-
- return $iniArray;
- }
-
- /**
- * Load the ini file and preprocess the section separator (':' in the
- * section name (that is used for section extension) so that the resultant
- * array has the correct section names and the extension information is
- * stored in a sub-key called ';extends'. We use ';extends' as this can
- * never be a valid key name in an INI file that has been loaded using
- * parse_ini_file().
- *
- * @param string $filename
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _loadIniFile($filename)
- {
- $loaded = $this->_parseIniFile($filename);
- $iniArray = array();
- foreach ($loaded as $key => $data)
- {
- $pieces = explode($this->_sectionSeparator, $key);
- $thisSection = trim($pieces[0]);
- switch (count($pieces)) {
- case 1:
- $iniArray[$thisSection] = $data;
- break;
-
- case 2:
- $extendedSection = trim($pieces[1]);
- $iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
- break;
-
- default:
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections in $filename");
- }
- }
-
- return $iniArray;
- }
-
- /**
- * Process each element in the section and handle the ";extends" inheritance
- * key. Passes control to _processKey() to handle the nest separator
- * sub-property syntax that may be used within the key name.
- *
- * @param array $iniArray
- * @param string $section
- * @param array $config
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _processSection($iniArray, $section, $config = array())
- {
- $thisSection = $iniArray[$section];
-
- foreach ($thisSection as $key => $value) {
- if (strtolower($key) == ';extends') {
- if (isset($iniArray[$value])) {
- $this->_assertValidExtend($section, $value);
-
- if (!$this->_skipExtends) {
- $config = $this->_processSection($iniArray, $value, $config);
- }
- } else {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Parent section '$section' cannot be found");
- }
- } else {
- $config = $this->_processKey($config, $key, $value);
- }
- }
- return $config;
- }
-
- /**
- * Assign the key's value to the property list. Handles the
- * nest separator for sub-properties.
- *
- * @param array $config
- * @param string $key
- * @param string $value
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _processKey($config, $key, $value)
- {
- if (strpos($key, $this->_nestSeparator) !== false) {
- $pieces = explode($this->_nestSeparator, $key, 2);
- if (strlen($pieces[0]) && strlen($pieces[1])) {
- if (!isset($config[$pieces[0]])) {
- if ($pieces[0] === '0' && !empty($config)) {
- // convert the current values in $config into an array
- $config = array($pieces[0] => $config);
- } else {
- $config[$pieces[0]] = array();
- }
- } elseif (!is_array($config[$pieces[0]])) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists");
- }
- $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value);
- } else {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Invalid key '$key'");
- }
- } else {
- $config[$key] = $value;
- }
- return $config;
- }
-}
diff --git a/lib/zend/Zend/Config/Json.php b/lib/zend/Zend/Config/Json.php
deleted file mode 100644
index 2c31fdc014049..0000000000000
--- a/lib/zend/Zend/Config/Json.php
+++ /dev/null
@@ -1,242 +0,0 @@
- $value) {
- switch (strtolower($key)) {
- case 'allow_modifications':
- case 'allowmodifications':
- $allowModifications = (bool) $value;
- break;
- case 'skip_extends':
- case 'skipextends':
- $this->_skipExtends = (bool) $value;
- break;
- case 'ignore_constants':
- case 'ignoreconstants':
- $this->_ignoreConstants = (bool) $value;
- break;
- default:
- break;
- }
- }
- }
-
- set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
- if ($json[0] != '{') {
- $json = file_get_contents($json);
- }
- restore_error_handler();
-
- // Check if there was a error while loading file
- if ($this->_loadFileErrorStr !== null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception($this->_loadFileErrorStr);
- }
-
- // Replace constants
- if (!$this->_ignoreConstants) {
- $json = $this->_replaceConstants($json);
- }
-
- // Parse/decode
- try {
- $config = Zend_Json::decode($json);
- } catch (Zend_Json_Exception $e) {
- // decode failed
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Error parsing JSON data");
- }
-
- if ($section === null) {
- $dataArray = array();
- foreach ($config as $sectionName => $sectionData) {
- $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
- }
-
- parent::__construct($dataArray, $allowModifications);
- } elseif (is_array($section)) {
- $dataArray = array();
- foreach ($section as $sectionName) {
- if (!isset($config[$sectionName])) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $sectionName));
- }
-
- $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
- }
-
- parent::__construct($dataArray, $allowModifications);
- } else {
- if (!isset($config[$section])) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $section));
- }
-
- $dataArray = $this->_processExtends($config, $section);
- if (!is_array($dataArray)) {
- // Section in the JSON data contains just one top level string
- $dataArray = array($section => $dataArray);
- }
-
- parent::__construct($dataArray, $allowModifications);
- }
-
- $this->_loadedSection = $section;
- }
-
- /**
- * Helper function to process each element in the section and handle
- * the "_extends" inheritance attribute.
- *
- * @param array $data Data array to process
- * @param string $section Section to process
- * @param array $config Configuration which was parsed yet
- * @throws Zend_Config_Exception When $section cannot be found
- * @return array
- */
- protected function _processExtends(array $data, $section, array $config = array())
- {
- if (!isset($data[$section])) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $section));
- }
-
- $thisSection = $data[$section];
-
- if (is_array($thisSection) && isset($thisSection[self::EXTENDS_NAME])) {
- if (is_array($thisSection[self::EXTENDS_NAME])) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Invalid extends clause: must be a string; array received');
- }
- $this->_assertValidExtend($section, $thisSection[self::EXTENDS_NAME]);
-
- if (!$this->_skipExtends) {
- $config = $this->_processExtends($data, $thisSection[self::EXTENDS_NAME], $config);
- }
- unset($thisSection[self::EXTENDS_NAME]);
- }
-
- $config = $this->_arrayMergeRecursive($config, $thisSection);
-
- return $config;
- }
-
- /**
- * Replace any constants referenced in a string with their values
- *
- * @param string $value
- * @return string
- */
- protected function _replaceConstants($value)
- {
- foreach ($this->_getConstants() as $constant) {
- if (strstr($value, $constant)) {
- // handle backslashes that may represent windows path names for instance
- $replacement = str_replace('\\', '\\\\', constant($constant));
- $value = str_replace($constant, $replacement, $value);
- }
- }
- return $value;
- }
-
- /**
- * Get (reverse) sorted list of defined constant names
- *
- * @return array
- */
- protected function _getConstants()
- {
- $constants = array_keys(get_defined_constants());
- rsort($constants, SORT_STRING);
- return $constants;
- }
-}
diff --git a/lib/zend/Zend/Config/Writer.php b/lib/zend/Zend/Config/Writer.php
deleted file mode 100644
index 8c255b3c8476d..0000000000000
--- a/lib/zend/Zend/Config/Writer.php
+++ /dev/null
@@ -1,101 +0,0 @@
-setOptions($options);
- }
- }
-
- /**
- * Set options via a Zend_Config instance
- *
- * @param Zend_Config $config
- * @return Zend_Config_Writer
- */
- public function setConfig(Zend_Config $config)
- {
- $this->_config = $config;
-
- return $this;
- }
-
- /**
- * Set options via an array
- *
- * @param array $options
- * @return Zend_Config_Writer
- */
- public function setOptions(array $options)
- {
- foreach ($options as $key => $value) {
- if (in_array(strtolower($key), $this->_skipOptions)) {
- continue;
- }
-
- $method = 'set' . ucfirst($key);
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
-
- return $this;
- }
-
- /**
- * Write a Zend_Config object to it's target
- *
- * @return void
- */
- abstract public function write();
-}
diff --git a/lib/zend/Zend/Config/Writer/Array.php b/lib/zend/Zend/Config/Writer/Array.php
deleted file mode 100644
index 50c260e0cf06d..0000000000000
--- a/lib/zend/Zend/Config/Writer/Array.php
+++ /dev/null
@@ -1,55 +0,0 @@
-_config->toArray();
- $sectionName = $this->_config->getSectionName();
-
- if (is_string($sectionName)) {
- $data = array($sectionName => $data);
- }
-
- $arrayString = "_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 "";
- }
-}
diff --git a/lib/zend/Zend/Config/Writer/Ini.php b/lib/zend/Zend/Config/Writer/Ini.php
deleted file mode 100644
index 15344a5b74048..0000000000000
--- a/lib/zend/Zend/Config/Writer/Ini.php
+++ /dev/null
@@ -1,193 +0,0 @@
-_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);
- }
-}
diff --git a/lib/zend/Zend/Config/Writer/Json.php b/lib/zend/Zend/Config/Writer/Json.php
deleted file mode 100644
index 25da4a9038cb3..0000000000000
--- a/lib/zend/Zend/Config/Writer/Json.php
+++ /dev/null
@@ -1,106 +0,0 @@
-_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;
- }
-}
diff --git a/lib/zend/Zend/Config/Writer/Xml.php b/lib/zend/Zend/Config/Writer/Xml.php
deleted file mode 100644
index c73564b21906a..0000000000000
--- a/lib/zend/Zend/Config/Writer/Xml.php
+++ /dev/null
@@ -1,127 +0,0 @@
-');
- $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);
- }
- }
- }
- }
-}
diff --git a/lib/zend/Zend/Config/Writer/Yaml.php b/lib/zend/Zend/Config/Writer/Yaml.php
deleted file mode 100644
index 4d2b1fed44269..0000000000000
--- a/lib/zend/Zend/Config/Writer/Yaml.php
+++ /dev/null
@@ -1,144 +0,0 @@
-_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;
- }
-}
diff --git a/lib/zend/Zend/Config/Xml.php b/lib/zend/Zend/Config/Xml.php
deleted file mode 100644
index 4425a8b7059f2..0000000000000
--- a/lib/zend/Zend/Config/Xml.php
+++ /dev/null
@@ -1,314 +0,0 @@
- false,
- * 'skipExtends' => false
- * );
- *
- * @param string $xml XML file or string to process
- * @param mixed $section Section to process
- * @param array|boolean $options
- * @throws Zend_Config_Exception When xml is not set or cannot be loaded
- * @throws Zend_Config_Exception When section $sectionName cannot be found in $xml
- */
- public function __construct($xml, $section = null, $options = false)
- {
- if (empty($xml)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Filename is not set');
- }
-
- $allowModifications = false;
- if (is_bool($options)) {
- $allowModifications = $options;
- } elseif (is_array($options)) {
- if (isset($options['allowModifications'])) {
- $allowModifications = (bool) $options['allowModifications'];
- }
- if (isset($options['skipExtends'])) {
- $this->_skipExtends = (bool) $options['skipExtends'];
- }
- }
-
- set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
- if (strstr($xml, 'getMessage()
- );
- }
- }
-
- restore_error_handler();
- // Check if there was a error while loading file
- if ($this->_loadFileErrorStr !== null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception($this->_loadFileErrorStr);
- }
-
- if ($section === null) {
- $dataArray = array();
- foreach ($config as $sectionName => $sectionData) {
- $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
- }
-
- parent::__construct($dataArray, $allowModifications);
- } else if (is_array($section)) {
- $dataArray = array();
- foreach ($section as $sectionName) {
- if (!isset($config->$sectionName)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $xml");
- }
-
- $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
- }
-
- parent::__construct($dataArray, $allowModifications);
- } else {
- if (!isset($config->$section)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$section' cannot be found in $xml");
- }
-
- $dataArray = $this->_processExtends($config, $section);
- if (!is_array($dataArray)) {
- // Section in the XML file contains just one top level string
- $dataArray = array($section => $dataArray);
- }
-
- parent::__construct($dataArray, $allowModifications);
- }
-
- $this->_loadedSection = $section;
- }
-
- /**
- * Helper function to process each element in the section and handle
- * the "extends" inheritance attribute.
- *
- * @param SimpleXMLElement $element XML Element to process
- * @param string $section Section to process
- * @param array $config Configuration which was parsed yet
- * @throws Zend_Config_Exception When $section cannot be found
- * @return array
- */
- protected function _processExtends(SimpleXMLElement $element, $section, array $config = array())
- {
- if (!isset($element->$section)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$section' cannot be found");
- }
-
- $thisSection = $element->$section;
- $nsAttributes = $thisSection->attributes(self::XML_NAMESPACE);
-
- if (isset($thisSection['extends']) || isset($nsAttributes['extends'])) {
- $extendedSection = (string) (isset($nsAttributes['extends']) ? $nsAttributes['extends'] : $thisSection['extends']);
- $this->_assertValidExtend($section, $extendedSection);
-
- if (!$this->_skipExtends) {
- $config = $this->_processExtends($element, $extendedSection, $config);
- }
- }
-
- $config = $this->_arrayMergeRecursive($config, $this->_toArray($thisSection));
-
- return $config;
- }
-
- /**
- * Returns a string or an associative and possibly multidimensional array from
- * a SimpleXMLElement.
- *
- * @param SimpleXMLElement $xmlObject Convert a SimpleXMLElement into an array
- * @return array|string
- */
- protected function _toArray(SimpleXMLElement $xmlObject)
- {
- $config = array();
- $nsAttributes = $xmlObject->attributes(self::XML_NAMESPACE);
-
- // Search for parent node values
- if (count($xmlObject->attributes()) > 0) {
- foreach ($xmlObject->attributes() as $key => $value) {
- if ($key === 'extends') {
- continue;
- }
-
- $value = (string) $value;
-
- if (array_key_exists($key, $config)) {
- if (!is_array($config[$key])) {
- $config[$key] = array($config[$key]);
- }
-
- $config[$key][] = $value;
- } else {
- $config[$key] = $value;
- }
- }
- }
-
- // Search for local 'const' nodes and replace them
- if (count($xmlObject->children(self::XML_NAMESPACE)) > 0) {
- if (count($xmlObject->children()) > 0) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("A node with a 'const' childnode may not have any other children");
- }
-
- $dom = dom_import_simplexml($xmlObject);
- $namespaceChildNodes = array();
-
- // We have to store them in an array, as replacing nodes will
- // confuse the DOMNodeList later
- foreach ($dom->childNodes as $node) {
- if ($node instanceof DOMElement && $node->namespaceURI === self::XML_NAMESPACE) {
- $namespaceChildNodes[] = $node;
- }
- }
-
- foreach ($namespaceChildNodes as $node) {
- switch ($node->localName) {
- case 'const':
- if (!$node->hasAttributeNS(self::XML_NAMESPACE, 'name')) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Misssing 'name' attribute in 'const' node");
- }
-
- $constantName = $node->getAttributeNS(self::XML_NAMESPACE, 'name');
-
- if (!defined($constantName)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Constant with name '$constantName' was not defined");
- }
-
- $constantValue = constant($constantName);
-
- $dom->replaceChild($dom->ownerDocument->createTextNode($constantValue), $node);
- break;
-
- default:
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Unknown node with name '$node->localName' found");
- }
- }
-
- return (string) simplexml_import_dom($dom);
- }
-
- // Search for children
- if (count($xmlObject->children()) > 0) {
- foreach ($xmlObject->children() as $key => $value) {
- if (count($value->children()) > 0 || count($value->children(self::XML_NAMESPACE)) > 0) {
- $value = $this->_toArray($value);
- } else if (count($value->attributes()) > 0) {
- $attributes = $value->attributes();
- if (isset($attributes['value'])) {
- $value = (string) $attributes['value'];
- } else {
- $value = $this->_toArray($value);
- }
- } else {
- $value = (string) $value;
- }
-
- if (array_key_exists($key, $config)) {
- if (!is_array($config[$key]) || !array_key_exists(0, $config[$key])) {
- $config[$key] = array($config[$key]);
- }
-
- $config[$key][] = $value;
- } else {
- $config[$key] = $value;
- }
- }
- } else if (!isset($xmlObject['extends']) && !isset($nsAttributes['extends']) && (count($config) === 0)) {
- // Object has no children nor attributes and doesn't use the extends
- // attribute: it's a string
- $config = (string) $xmlObject;
- }
-
- return $config;
- }
-}
diff --git a/lib/zend/Zend/Config/Yaml.php b/lib/zend/Zend/Config/Yaml.php
deleted file mode 100644
index 0d107033eb811..0000000000000
--- a/lib/zend/Zend/Config/Yaml.php
+++ /dev/null
@@ -1,415 +0,0 @@
-_yamlDecoder;
- }
-
- /**
- * Set callback for decoding YAML
- *
- * @param callable $yamlDecoder the decoder to set
- * @return Zend_Config_Yaml
- */
- public function setYamlDecoder($yamlDecoder)
- {
- if (!is_callable($yamlDecoder)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Invalid parameter to setYamlDecoder() - must be callable');
- }
-
- $this->_yamlDecoder = $yamlDecoder;
- return $this;
- }
-
- /**
- * Loads the section $section from the config file encoded as YAML
- *
- * Sections are defined as properties of the main object
- *
- * In order to extend another section, a section defines the "_extends"
- * property having a value of the section name from which the extending
- * section inherits values.
- *
- * Note that the keys in $section will override any keys of the same
- * name in the sections that have been included via "_extends".
- *
- * Options may include:
- * - allow_modifications: whether or not the config object is mutable
- * - skip_extends: whether or not to skip processing of parent configuration
- * - yaml_decoder: a callback to use to decode the Yaml source
- *
- * @param string $yaml YAML file to process
- * @param mixed $section Section to process
- * @param array|boolean $options
- */
- public function __construct($yaml, $section = null, $options = false)
- {
- if (empty($yaml)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Filename is not set');
- }
-
- $ignoreConstants = $staticIgnoreConstants = self::ignoreConstants();
- $allowModifications = false;
- if (is_bool($options)) {
- $allowModifications = $options;
- } elseif (is_array($options)) {
- foreach ($options as $key => $value) {
- switch (strtolower($key)) {
- case 'allow_modifications':
- case 'allowmodifications':
- $allowModifications = (bool) $value;
- break;
- case 'skip_extends':
- case 'skipextends':
- $this->_skipExtends = (bool) $value;
- break;
- case 'ignore_constants':
- case 'ignoreconstants':
- $ignoreConstants = (bool) $value;
- break;
- case 'yaml_decoder':
- case 'yamldecoder':
- $this->setYamlDecoder($value);
- break;
- default:
- break;
- }
- }
- }
-
- // Suppress warnings and errors while loading file
- set_error_handler(array($this, '_loadFileErrorHandler'));
- $yaml = file_get_contents($yaml);
- restore_error_handler();
-
- // Check if there was a error while loading file
- if ($this->_loadFileErrorStr !== null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception($this->_loadFileErrorStr);
- }
-
- // Override static value for ignore_constants if provided in $options
- self::setIgnoreConstants($ignoreConstants);
-
- // Parse YAML
- $config = call_user_func($this->getYamlDecoder(), $yaml);
-
- // Reset original static state of ignore_constants
- self::setIgnoreConstants($staticIgnoreConstants);
-
- if (null === $config) {
- // decode failed
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Error parsing YAML data");
- }
-
- if (null === $section) {
- $dataArray = array();
- foreach ($config as $sectionName => $sectionData) {
- $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
- }
- parent::__construct($dataArray, $allowModifications);
- } elseif (is_array($section)) {
- $dataArray = array();
- foreach ($section as $sectionName) {
- if (!isset($config[$sectionName])) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception(sprintf(
- 'Section "%s" cannot be found',
- implode(' ', (array)$section)
- ));
- }
-
- $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
- }
- parent::__construct($dataArray, $allowModifications);
- } else {
- if (!isset($config[$section])) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception(sprintf(
- 'Section "%s" cannot be found',
- implode(' ', (array)$section)
- ));
- }
-
- $dataArray = $this->_processExtends($config, $section);
- if (!is_array($dataArray)) {
- // Section in the yaml data contains just one top level string
- $dataArray = array($section => $dataArray);
- }
- parent::__construct($dataArray, $allowModifications);
- }
-
- $this->_loadedSection = $section;
- }
-
- /**
- * Helper function to process each element in the section and handle
- * the "_extends" inheritance attribute.
- *
- * @param array $data Data array to process
- * @param string $section Section to process
- * @param array $config Configuration which was parsed yet
- * @return array
- * @throws Zend_Config_Exception When $section cannot be found
- */
- protected function _processExtends(array $data, $section, array $config = array())
- {
- if (!isset($data[$section])) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $section));
- }
-
- $thisSection = $data[$section];
-
- if (is_array($thisSection) && isset($thisSection[self::EXTENDS_NAME])) {
- $this->_assertValidExtend($section, $thisSection[self::EXTENDS_NAME]);
-
- if (!$this->_skipExtends) {
- $config = $this->_processExtends($data, $thisSection[self::EXTENDS_NAME], $config);
- }
- unset($thisSection[self::EXTENDS_NAME]);
- }
-
- $config = $this->_arrayMergeRecursive($config, $thisSection);
-
- return $config;
- }
-
- /**
- * Very dumb YAML parser
- *
- * Until we have Zend_Yaml...
- *
- * @param string $yaml YAML source
- * @return array Decoded data
- */
- public static function decode($yaml)
- {
- $lines = explode("\n", $yaml);
- reset($lines);
- return self::_decodeYaml(0, $lines);
- }
-
- /**
- * Service function to decode YAML
- *
- * @param int $currentIndent Current indent level
- * @param array $lines YAML lines
- * @return array|string
- */
- protected static function _decodeYaml($currentIndent, &$lines)
- {
- $config = array();
- $inIndent = false;
- while (list($n, $line) = each($lines)) {
- $lineno = $n + 1;
-
- $line = rtrim(preg_replace("/#.*$/", "", $line));
- if (strlen($line) == 0) {
- continue;
- }
-
- $indent = strspn($line, " ");
-
- // line without the spaces
- $line = trim($line);
- if (strlen($line) == 0) {
- continue;
- }
-
- if ($indent < $currentIndent) {
- // this level is done
- prev($lines);
- return $config;
- }
-
- if (!$inIndent) {
- $currentIndent = $indent;
- $inIndent = true;
- }
-
- if (preg_match("/(?!-)([\w\-]+):\s*(.*)/", $line, $m)) {
- // key: value
- if (strlen($m[2])) {
- // simple key: value
- $value = preg_replace("/#.*$/", "", $m[2]);
- $value = self::_parseValue($value);
- } else {
- // key: and then values on new lines
- $value = self::_decodeYaml($currentIndent + 1, $lines);
- if (is_array($value) && !count($value)) {
- $value = "";
- }
- }
- $config[$m[1]] = $value;
- } elseif ($line[0] == "-") {
- // item in the list:
- // - FOO
- if (strlen($line) > 2) {
- $value = substr($line, 2);
-
- $config[] = self::_parseValue($value);
- } else {
- $config[] = self::_decodeYaml($currentIndent + 1, $lines);
- }
- } else {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception(sprintf(
- 'Error parsing YAML at line %d - unsupported syntax: "%s"',
- $lineno, $line
- ));
- }
- }
- return $config;
- }
-
- /**
- * Parse values
- *
- * @param string $value
- * @return string
- */
- protected static function _parseValue($value)
- {
- $value = trim($value);
-
- // remove quotes from string.
- if ('"' == $value['0']) {
- if ('"' == $value[count($value) -1]) {
- $value = substr($value, 1, -1);
- }
- } elseif ('\'' == $value['0'] && '\'' == $value[count($value) -1]) {
- $value = strtr($value, array("''" => "'", "'" => ''));
- }
-
- // Check for booleans and constants
- if (preg_match('/^(t(rue)?|on|y(es)?)$/i', $value)) {
- $value = true;
- } elseif (preg_match('/^(f(alse)?|off|n(o)?)$/i', $value)) {
- $value = false;
- } elseif (strcasecmp($value, 'null') === 0) {
- $value = null;
- } elseif (!self::$_ignoreConstants) {
- // test for constants
- $value = self::_replaceConstants($value);
- }
-
- return $value;
- }
-
- /**
- * Replace any constants referenced in a string with their values
- *
- * @param string $value
- * @return string
- */
- protected static function _replaceConstants($value)
- {
- foreach (self::_getConstants() as $constant) {
- if (strstr($value, $constant)) {
- $value = str_replace($constant, constant($constant), $value);
- }
- }
- return $value;
- }
-
- /**
- * Get (reverse) sorted list of defined constant names
- *
- * @return array
- */
- protected static function _getConstants()
- {
- $constants = array_keys(get_defined_constants());
- rsort($constants, SORT_STRING);
- return $constants;
- }
-}
diff --git a/lib/zend/Zend/Controller/Action.php b/lib/zend/Zend/Controller/Action.php
deleted file mode 100644
index 9508e747119a1..0000000000000
--- a/lib/zend/Zend/Controller/Action.php
+++ /dev/null
@@ -1,798 +0,0 @@
-setRequest($request)
- ->setResponse($response)
- ->_setInvokeArgs($invokeArgs);
- $this->_helper = new Zend_Controller_Action_HelperBroker($this);
- $this->init();
- }
-
- /**
- * Initialize object
- *
- * Called from {@link __construct()} as final step of object instantiation.
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Initialize View object
- *
- * Initializes {@link $view} if not otherwise a Zend_View_Interface.
- *
- * If {@link $view} is not otherwise set, instantiates a new Zend_View
- * object, using the 'views' subdirectory at the same level as the
- * controller directory for the current module as the base directory.
- * It uses this to set the following:
- * - script path = views/scripts/
- * - helper path = views/helpers/
- * - filter path = views/filters/
- *
- * @return Zend_View_Interface
- * @throws Zend_Controller_Exception if base view directory does not exist
- */
- public function initView()
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- return $this->view;
- }
-
- require_once 'Zend/View/Interface.php';
- if (isset($this->view) && ($this->view instanceof Zend_View_Interface)) {
- return $this->view;
- }
-
- $request = $this->getRequest();
- $module = $request->getModuleName();
- $dirs = $this->getFrontController()->getControllerDirectory();
- if (empty($module) || !isset($dirs[$module])) {
- $module = $this->getFrontController()->getDispatcher()->getDefaultModule();
- }
- $baseDir = dirname($dirs[$module]) . DIRECTORY_SEPARATOR . 'views';
- if (!file_exists($baseDir) || !is_dir($baseDir)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Missing base view directory ("' . $baseDir . '")');
- }
-
- require_once 'Zend/View.php';
- $this->view = new Zend_View(array('basePath' => $baseDir));
-
- return $this->view;
- }
-
- /**
- * Render a view
- *
- * Renders a view. By default, views are found in the view script path as
- * /.phtml. You may change the script suffix by
- * resetting {@link $viewSuffix}. You may omit the controller directory
- * prefix by specifying boolean true for $noController.
- *
- * By default, the rendered contents are appended to the response. You may
- * specify the named body content segment to set by specifying a $name.
- *
- * @see Zend_Controller_Response_Abstract::appendBody()
- * @param string|null $action Defaults to action registered in request object
- * @param string|null $name Response object named path segment to use; defaults to null
- * @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script
- * @return void
- */
- public function render($action = null, $name = null, $noController = false)
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- return $this->_helper->viewRenderer->render($action, $name, $noController);
- }
-
- $view = $this->initView();
- $script = $this->getViewScript($action, $noController);
-
- $this->getResponse()->appendBody(
- $view->render($script),
- $name
- );
- }
-
- /**
- * Render a given view script
- *
- * Similar to {@link render()}, this method renders a view script. Unlike render(),
- * however, it does not autodetermine the view script via {@link getViewScript()},
- * but instead renders the script passed to it. Use this if you know the
- * exact view script name and path you wish to use, or if using paths that do not
- * conform to the spec defined with getViewScript().
- *
- * By default, the rendered contents are appended to the response. You may
- * specify the named body content segment to set by specifying a $name.
- *
- * @param string $script
- * @param string $name
- * @return void
- */
- public function renderScript($script, $name = null)
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- return $this->_helper->viewRenderer->renderScript($script, $name);
- }
-
- $view = $this->initView();
- $this->getResponse()->appendBody(
- $view->render($script),
- $name
- );
- }
-
- /**
- * Construct view script path
- *
- * Used by render() to determine the path to the view script.
- *
- * @param string $action Defaults to action registered in request object
- * @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script
- * @return string
- * @throws Zend_Controller_Exception with bad $action
- */
- public function getViewScript($action = null, $noController = null)
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- $viewRenderer = $this->_helper->getHelper('viewRenderer');
- if (null !== $noController) {
- $viewRenderer->setNoController($noController);
- }
- return $viewRenderer->getViewScript($action);
- }
-
- $request = $this->getRequest();
- if (null === $action) {
- $action = $request->getActionName();
- } elseif (!is_string($action)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid action specifier for view render');
- }
-
- if (null === $this->_delimiters) {
- $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
- $wordDelimiters = $dispatcher->getWordDelimiter();
- $pathDelimiters = $dispatcher->getPathDelimiter();
- $this->_delimiters = array_unique(array_merge($wordDelimiters, (array) $pathDelimiters));
- }
-
- $action = str_replace($this->_delimiters, '-', $action);
- $script = $action . '.' . $this->viewSuffix;
-
- if (!$noController) {
- $controller = $request->getControllerName();
- $controller = str_replace($this->_delimiters, '-', $controller);
- $script = $controller . DIRECTORY_SEPARATOR . $script;
- }
-
- return $script;
- }
-
- /**
- * Return the Request object
- *
- * @return Zend_Controller_Request_Abstract
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set the Request object
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return Zend_Controller_Action
- */
- public function setRequest(Zend_Controller_Request_Abstract $request)
- {
- $this->_request = $request;
- return $this;
- }
-
- /**
- * Return the Response object
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Set the Response object
- *
- * @param Zend_Controller_Response_Abstract $response
- * @return Zend_Controller_Action
- */
- public function setResponse(Zend_Controller_Response_Abstract $response)
- {
- $this->_response = $response;
- return $this;
- }
-
- /**
- * Set invocation arguments
- *
- * @param array $args
- * @return Zend_Controller_Action
- */
- protected function _setInvokeArgs(array $args = array())
- {
- $this->_invokeArgs = $args;
- return $this;
- }
-
- /**
- * Return the array of constructor arguments (minus the Request object)
- *
- * @return array
- */
- public function getInvokeArgs()
- {
- return $this->_invokeArgs;
- }
-
- /**
- * Return a single invocation argument
- *
- * @param string $key
- * @return mixed
- */
- public function getInvokeArg($key)
- {
- if (isset($this->_invokeArgs[$key])) {
- return $this->_invokeArgs[$key];
- }
-
- return null;
- }
-
- /**
- * Get a helper by name
- *
- * @param string $helperName
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function getHelper($helperName)
- {
- return $this->_helper->{$helperName};
- }
-
- /**
- * Get a clone of a helper by name
- *
- * @param string $helperName
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function getHelperCopy($helperName)
- {
- return clone $this->_helper->{$helperName};
- }
-
- /**
- * Set the front controller instance
- *
- * @param Zend_Controller_Front $front
- * @return Zend_Controller_Action
- */
- public function setFrontController(Zend_Controller_Front $front)
- {
- $this->_frontController = $front;
- return $this;
- }
-
- /**
- * Retrieve Front Controller
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- // Used cache version if found
- if (null !== $this->_frontController) {
- return $this->_frontController;
- }
-
- // Grab singleton instance, if class has been loaded
- if (class_exists('Zend_Controller_Front')) {
- $this->_frontController = Zend_Controller_Front::getInstance();
- return $this->_frontController;
- }
-
- // Throw exception in all other cases
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Front controller class has not been loaded');
- }
-
- /**
- * Pre-dispatch routines
- *
- * Called before action method. If using class with
- * {@link Zend_Controller_Front}, it may modify the
- * {@link $_request Request object} and reset its dispatched flag in order
- * to skip processing the current action.
- *
- * @return void
- */
- public function preDispatch()
- {
- }
-
- /**
- * Post-dispatch routines
- *
- * Called after action method execution. If using class with
- * {@link Zend_Controller_Front}, it may modify the
- * {@link $_request Request object} and reset its dispatched flag in order
- * to process an additional action.
- *
- * Common usages for postDispatch() include rendering content in a sitewide
- * template, link url correction, setting headers, etc.
- *
- * @return void
- */
- public function postDispatch()
- {
- }
-
- /**
- * Proxy for undefined methods. Default behavior is to throw an
- * exception on undefined methods, however this function can be
- * overridden to implement magic (dynamic) actions, or provide run-time
- * dispatching.
- *
- * @param string $methodName
- * @param array $args
- * @return void
- * @throws Zend_Controller_Action_Exception
- */
- public function __call($methodName, $args)
- {
- require_once 'Zend/Controller/Action/Exception.php';
- if ('Action' == substr($methodName, -6)) {
- $action = substr($methodName, 0, strlen($methodName) - 6);
- throw new Zend_Controller_Action_Exception(sprintf('Action "%s" does not exist and was not trapped in __call()', $action), 404);
- }
-
- throw new Zend_Controller_Action_Exception(sprintf('Method "%s" does not exist and was not trapped in __call()', $methodName), 500);
- }
-
- /**
- * Dispatch the requested action
- *
- * @param string $action Method name of action
- * @return void
- */
- public function dispatch($action)
- {
- // Notify helpers of action preDispatch state
- $this->_helper->notifyPreDispatch();
-
- $this->preDispatch();
- if ($this->getRequest()->isDispatched()) {
- if (null === $this->_classMethods) {
- $this->_classMethods = get_class_methods($this);
- }
-
- // If pre-dispatch hooks introduced a redirect then stop dispatch
- // @see ZF-7496
- if (!($this->getResponse()->isRedirect())) {
- // preDispatch() didn't change the action, so we can continue
- if ($this->getInvokeArg('useCaseSensitiveActions') || in_array($action, $this->_classMethods)) {
- if ($this->getInvokeArg('useCaseSensitiveActions')) {
- trigger_error('Using case sensitive actions without word separators is deprecated; please do not rely on this "feature"');
- }
- $this->$action();
- } else {
- $this->__call($action, array());
- }
- }
- $this->postDispatch();
- }
-
- // whats actually important here is that this action controller is
- // shutting down, regardless of dispatching; notify the helpers of this
- // state
- $this->_helper->notifyPostDispatch();
- }
-
- /**
- * Call the action specified in the request object, and return a response
- *
- * Not used in the Action Controller implementation, but left for usage in
- * Page Controller implementations. Dispatches a method based on the
- * request.
- *
- * Returns a Zend_Controller_Response_Abstract object, instantiating one
- * prior to execution if none exists in the controller.
- *
- * {@link preDispatch()} is called prior to the action,
- * {@link postDispatch()} is called following it.
- *
- * @param null|Zend_Controller_Request_Abstract $request Optional request
- * object to use
- * @param null|Zend_Controller_Response_Abstract $response Optional response
- * object to use
- * @return Zend_Controller_Response_Abstract
- */
- public function run(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
- {
- if (null !== $request) {
- $this->setRequest($request);
- } else {
- $request = $this->getRequest();
- }
-
- if (null !== $response) {
- $this->setResponse($response);
- }
-
- $action = $request->getActionName();
- if (empty($action)) {
- $action = 'index';
- }
- $action = $action . 'Action';
-
- $request->setDispatched(true);
- $this->dispatch($action);
-
- return $this->getResponse();
- }
-
- /**
- * Gets a parameter from the {@link $_request Request object}. If the
- * parameter does not exist, NULL will be returned.
- *
- * If the parameter does not exist and $default is set, then
- * $default will be returned instead of NULL.
- *
- * @param string $paramName
- * @param mixed $default
- * @return mixed
- */
- protected function _getParam($paramName, $default = null)
- {
- return $this->getParam($paramName, $default);
- }
-
- /**
- * Gets a parameter from the {@link $_request Request object}. If the
- * parameter does not exist, NULL will be returned.
- *
- * If the parameter does not exist and $default is set, then
- * $default will be returned instead of NULL.
- *
- * @param string $paramName
- * @param mixed $default
- * @return mixed
- */
- public function getParam($paramName, $default = null)
- {
- $value = $this->getRequest()->getParam($paramName);
- if ((null === $value || '' === $value) && (null !== $default)) {
- $value = $default;
- }
-
- return $value;
- }
-
- /**
- * Set a parameter in the {@link $_request Request object}.
- *
- * @param string $paramName
- * @param mixed $value
- * @return Zend_Controller_Action
- * @deprecated Deprecated as of Zend Framework 1.7. Use
- * setParam() instead.
- */
- protected function _setParam($paramName, $value)
- {
- return $this->setParam($paramName, $value);
- }
-
- /**
- * Set a parameter in the {@link $_request Request object}.
- *
- * @param string $paramName
- * @param mixed $value
- * @return Zend_Controller_Action
- */
- public function setParam($paramName, $value)
- {
- $this->getRequest()->setParam($paramName, $value);
-
- return $this;
- }
-
- /**
- * Determine whether a given parameter exists in the
- * {@link $_request Request object}.
- *
- * @param string $paramName
- * @return boolean
- * @deprecated Deprecated as of Zend Framework 1.7. Use
- * hasParam() instead.
- */
- protected function _hasParam($paramName)
- {
- return $this->hasParam($paramName);
- }
-
- /**
- * Determine whether a given parameter exists in the
- * {@link $_request Request object}.
- *
- * @param string $paramName
- * @return boolean
- */
- public function hasParam($paramName)
- {
- return null !== $this->getRequest()->getParam($paramName);
- }
-
- /**
- * Return all parameters in the {@link $_request Request object}
- * as an associative array.
- *
- * @return array
- * @deprecated Deprecated as of Zend Framework 1.7. Use
- * getAllParams() instead.
- */
- protected function _getAllParams()
- {
- return $this->getAllParams();
- }
-
- /**
- * Return all parameters in the {@link $_request Request object}
- * as an associative array.
- *
- * @return array
- */
- public function getAllParams()
- {
- return $this->getRequest()->getParams();
- }
-
-
- /**
- * Forward to another controller/action.
- *
- * It is important to supply the unformatted names, i.e. "article"
- * rather than "ArticleController". The dispatcher will do the
- * appropriate formatting when the request is received.
- *
- * If only an action name is provided, forwards to that action in this
- * controller.
- *
- * If an action and controller are specified, forwards to that action and
- * controller in this module.
- *
- * Specifying an action, controller, and module is the most specific way to
- * forward.
- *
- * A fourth argument, $params, will be used to set the request parameters.
- * If either the controller or module are unnecessary for forwarding,
- * simply pass null values for them before specifying the parameters.
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- * @deprecated Deprecated as of Zend Framework 1.7. Use
- * forward() instead.
- */
- final protected function _forward($action, $controller = null, $module = null, array $params = null)
- {
- $this->forward($action, $controller, $module, $params);
- }
-
- /**
- * Forward to another controller/action.
- *
- * It is important to supply the unformatted names, i.e. "article"
- * rather than "ArticleController". The dispatcher will do the
- * appropriate formatting when the request is received.
- *
- * If only an action name is provided, forwards to that action in this
- * controller.
- *
- * If an action and controller are specified, forwards to that action and
- * controller in this module.
- *
- * Specifying an action, controller, and module is the most specific way to
- * forward.
- *
- * A fourth argument, $params, will be used to set the request parameters.
- * If either the controller or module are unnecessary for forwarding,
- * simply pass null values for them before specifying the parameters.
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- final public function forward($action, $controller = null, $module = null, array $params = null)
- {
- $request = $this->getRequest();
-
- if (null !== $params) {
- $request->setParams($params);
- }
-
- if (null !== $controller) {
- $request->setControllerName($controller);
-
- // Module should only be reset if controller has been specified
- if (null !== $module) {
- $request->setModuleName($module);
- }
- }
-
- $request->setActionName($action)
- ->setDispatched(false);
- }
-
- /**
- * Redirect to another URL
- *
- * Proxies to {@link Zend_Controller_Action_Helper_Redirector::gotoUrl()}.
- *
- * @param string $url
- * @param array $options Options to be used when redirecting
- * @return void
- * @deprecated Deprecated as of Zend Framework 1.7. Use
- * redirect() instead.
- */
- protected function _redirect($url, array $options = array())
- {
- $this->redirect($url, $options);
- }
-
- /**
- * Redirect to another URL
- *
- * Proxies to {@link Zend_Controller_Action_Helper_Redirector::gotoUrl()}.
- *
- * @param string $url
- * @param array $options Options to be used when redirecting
- * @return void
- */
- public function redirect($url, array $options = array())
- {
- $this->_helper->redirector->gotoUrl($url, $options);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Exception.php b/lib/zend/Zend/Controller/Action/Exception.php
deleted file mode 100644
index 4cd9ce2a74bf1..0000000000000
--- a/lib/zend/Zend/Controller/Action/Exception.php
+++ /dev/null
@@ -1,38 +0,0 @@
-_actionController = $actionController;
- return $this;
- }
-
- /**
- * Retrieve current action controller
- *
- * @return Zend_Controller_Action
- */
- public function getActionController()
- {
- return $this->_actionController;
- }
-
- /**
- * Retrieve front controller instance
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- return Zend_Controller_Front::getInstance();
- }
-
- /**
- * Hook into action controller initialization
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Hook into action controller preDispatch() workflow
- *
- * @return void
- */
- public function preDispatch()
- {
- }
-
- /**
- * Hook into action controller postDispatch() workflow
- *
- * @return void
- */
- public function postDispatch()
- {
- }
-
- /**
- * getRequest() -
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- $controller = $this->getActionController();
- if (null === $controller) {
- $controller = $this->getFrontController();
- }
-
- return $controller->getRequest();
- }
-
- /**
- * getResponse() -
- *
- * @return Zend_Controller_Response_Abstract $response
- */
- public function getResponse()
- {
- $controller = $this->getActionController();
- if (null === $controller) {
- $controller = $this->getFrontController();
- }
-
- return $controller->getResponse();
- }
-
- /**
- * getName()
- *
- * @return string
- */
- public function getName()
- {
- $fullClassName = get_class($this);
- if (strpos($fullClassName, '_') !== false) {
- $helperName = strrchr($fullClassName, '_');
- return ltrim($helperName, '_');
- } elseif (strpos($fullClassName, '\\') !== false) {
- $helperName = strrchr($fullClassName, '\\');
- return ltrim($helperName, '\\');
- } else {
- return $fullClassName;
- }
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/ActionStack.php b/lib/zend/Zend/Controller/Action/Helper/ActionStack.php
deleted file mode 100644
index e22e8b8e7e41d..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/ActionStack.php
+++ /dev/null
@@ -1,138 +0,0 @@
-hasPlugin('Zend_Controller_Plugin_ActionStack')) {
- /**
- * @see Zend_Controller_Plugin_ActionStack
- */
- require_once 'Zend/Controller/Plugin/ActionStack.php';
- $this->_actionStack = new Zend_Controller_Plugin_ActionStack();
- $front->registerPlugin($this->_actionStack, 97);
- } else {
- $this->_actionStack = $front->getPlugin('Zend_Controller_Plugin_ActionStack');
- }
- }
-
- /**
- * Push onto the stack
- *
- * @param Zend_Controller_Request_Abstract $next
- * @return Zend_Controller_Action_Helper_ActionStack Provides a fluent interface
- */
- public function pushStack(Zend_Controller_Request_Abstract $next)
- {
- $this->_actionStack->pushStack($next);
- return $this;
- }
-
- /**
- * Push a new action onto the stack
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ActionStack
- */
- public function actionToStack($action, $controller = null, $module = null, array $params = array())
- {
- if ($action instanceof Zend_Controller_Request_Abstract) {
- return $this->pushStack($action);
- } elseif (!is_string($action)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('ActionStack requires either a request object or minimally a string action');
- }
-
- $request = $this->getRequest();
-
- if ($request instanceof Zend_Controller_Request_Abstract === false){
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Request object not set yet');
- }
-
- $controller = (null === $controller) ? $request->getControllerName() : $controller;
- $module = (null === $module) ? $request->getModuleName() : $module;
-
- /**
- * @see Zend_Controller_Request_Simple
- */
- require_once 'Zend/Controller/Request/Simple.php';
- $newRequest = new Zend_Controller_Request_Simple($action, $controller, $module, $params);
-
- return $this->pushStack($newRequest);
- }
-
- /**
- * Perform helper when called as $this->_helper->actionStack() from an action controller
- *
- * Proxies to {@link simple()}
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return boolean
- */
- public function direct($action, $controller = null, $module = null, array $params = array())
- {
- return $this->actionToStack($action, $controller, $module, $params);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/AjaxContext.php b/lib/zend/Zend/Controller/Action/Helper/AjaxContext.php
deleted file mode 100644
index dd4ca426d6751..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/AjaxContext.php
+++ /dev/null
@@ -1,80 +0,0 @@
-addContext('html', array('suffix' => 'ajax'));
- }
-
- /**
- * Initialize AJAX context switching
- *
- * Checks for XHR requests; if detected, attempts to perform context switch.
- *
- * @param string $format
- * @return void
- */
- public function initContext($format = null)
- {
- $this->_currentContext = null;
-
- $request = $this->getRequest();
- if (!method_exists($request, 'isXmlHttpRequest') ||
- !$this->getRequest()->isXmlHttpRequest())
- {
- return;
- }
-
- return parent::initContext($format);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/AutoComplete/Abstract.php b/lib/zend/Zend/Controller/Action/Helper/AutoComplete/Abstract.php
deleted file mode 100644
index 707545434b287..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/AutoComplete/Abstract.php
+++ /dev/null
@@ -1,149 +0,0 @@
-disableLayout();
- }
-
- Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
-
- return $this;
- }
-
- /**
- * Encode data to JSON
- *
- * @param mixed $data
- * @param bool $keepLayouts
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- public function encodeJson($data, $keepLayouts = false)
- {
- if ($this->validateData($data)) {
- return Zend_Controller_Action_HelperBroker::getStaticHelper('Json')->encodeJson($data, $keepLayouts);
- }
-
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid data passed for autocompletion');
- }
-
- /**
- * Send autocompletion data
- *
- * Calls prepareAutoCompletion, populates response body with this
- * information, and sends response.
- *
- * @param mixed $data
- * @param bool $keepLayouts
- * @return string|void
- */
- public function sendAutoCompletion($data, $keepLayouts = false)
- {
- $data = $this->prepareAutoCompletion($data, $keepLayouts);
-
- $response = $this->getResponse();
- $response->setBody($data);
-
- if (!$this->suppressExit) {
- $response->sendResponse();
- exit;
- }
-
- return $data;
- }
-
- /**
- * Strategy pattern: allow calling helper as broker method
- *
- * Prepares autocompletion data and, if $sendNow is true, immediately sends
- * response.
- *
- * @param mixed $data
- * @param bool $sendNow
- * @param bool $keepLayouts
- * @return string|void
- */
- public function direct($data, $sendNow = true, $keepLayouts = false)
- {
- if ($sendNow) {
- return $this->sendAutoCompletion($data, $keepLayouts);
- }
-
- return $this->prepareAutoCompletion($data, $keepLayouts);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/AutoCompleteDojo.php b/lib/zend/Zend/Controller/Action/Helper/AutoCompleteDojo.php
deleted file mode 100644
index 9027f0f8e62c9..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/AutoCompleteDojo.php
+++ /dev/null
@@ -1,87 +0,0 @@
- $value) {
- $items[] = array('label' => $value, 'name' => $value);
- }
- $data = new Zend_Dojo_Data('name', $items);
- }
-
- if (!$keepLayouts) {
- require_once 'Zend/Controller/Action/HelperBroker.php';
- Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
-
- require_once 'Zend/Layout.php';
- $layout = Zend_Layout::getMvcInstance();
- if ($layout instanceof Zend_Layout) {
- $layout->disableLayout();
- }
- }
-
- $response = Zend_Controller_Front::getInstance()->getResponse();
- $response->setHeader('Content-Type', 'application/json');
-
- return $data->toJson();
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php b/lib/zend/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php
deleted file mode 100644
index 098aed8b10c6e..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php
+++ /dev/null
@@ -1,82 +0,0 @@
-validateData($data)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid data passed for autocompletion');
- }
-
- $data = (array) $data;
- $data = '' . implode(' ', $data) . ' ';
-
- if (!$keepLayouts) {
- $this->disableLayouts();
- }
-
- return $data;
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/Cache.php b/lib/zend/Zend/Controller/Action/Helper/Cache.php
deleted file mode 100644
index 61c089ff5913f..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/Cache.php
+++ /dev/null
@@ -1,289 +0,0 @@
-getRequest()->getControllerName();
- $actions = array_unique($actions);
- if (!isset($this->_caching[$controller])) {
- $this->_caching[$controller] = array();
- }
- if (!empty($tags)) {
- $tags = array_unique($tags);
- if (!isset($this->_tags[$controller])) {
- $this->_tags[$controller] = array();
- }
- }
- foreach ($actions as $action) {
- $this->_caching[$controller][] = $action;
- if (!empty($tags)) {
- $this->_tags[$controller][$action] = array();
- foreach ($tags as $tag) {
- $this->_tags[$controller][$action][] = $tag;
- }
- }
- }
- if ($extension) {
- if (!isset($this->_extensions[$controller])) {
- $this->_extensions[$controller] = array();
- }
- foreach ($actions as $action) {
- $this->_extensions[$controller][$action] = $extension;
- }
- }
- }
-
- /**
- * Remove a specific page cache static file based on its
- * relative URL from the application's public directory.
- * The file extension is not required here; usually matches
- * the original REQUEST_URI that was cached.
- *
- * @param string $relativeUrl
- * @param bool $recursive
- * @return mixed
- */
- public function removePage($relativeUrl, $recursive = false)
- {
- $cache = $this->getCache(Zend_Cache_Manager::PAGECACHE);
- $encodedCacheId = $this->_encodeCacheId($relativeUrl);
-
- if ($recursive) {
- $backend = $cache->getBackend();
- if (($backend instanceof Zend_Cache_Backend)
- && method_exists($backend, 'removeRecursively')
- ) {
- $result = $backend->removeRecursively($encodedCacheId);
- if (is_null($result) ) {
- $result = $backend->removeRecursively($relativeUrl);
- }
- return $result;
- }
- }
-
- $result = $cache->remove($encodedCacheId);
- if (is_null($result) ) {
- $result = $cache->remove($relativeUrl);
- }
- return $result;
- }
-
- /**
- * Remove a specific page cache static file based on its
- * relative URL from the application's public directory.
- * The file extension is not required here; usually matches
- * the original REQUEST_URI that was cached.
- *
- * @param array $tags
- * @return mixed
- */
- public function removePagesTagged(array $tags)
- {
- return $this->getCache(Zend_Cache_Manager::PAGECACHE)
- ->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
- }
-
- /**
- * Commence page caching for any cacheable actions
- *
- * @return void
- */
- public function preDispatch()
- {
- $controller = $this->getRequest()->getControllerName();
- $action = $this->getRequest()->getActionName();
- $stats = ob_get_status(true);
- foreach ($stats as $status) {
- if ($status['name'] == 'Zend_Cache_Frontend_Page::_flush'
- || $status['name'] == 'Zend_Cache_Frontend_Capture::_flush') {
- $obStarted = true;
- }
- }
- if (!isset($obStarted) && isset($this->_caching[$controller]) &&
- in_array($action, $this->_caching[$controller])) {
- $reqUri = $this->getRequest()->getRequestUri();
- $tags = array();
- if (isset($this->_tags[$controller][$action])
- && !empty($this->_tags[$controller][$action])) {
- $tags = array_unique($this->_tags[$controller][$action]);
- }
- $extension = null;
- if (isset($this->_extensions[$controller][$action])) {
- $extension = $this->_extensions[$controller][$action];
- }
- $this->getCache(Zend_Cache_Manager::PAGECACHE)
- ->start($this->_encodeCacheId($reqUri), $tags, $extension);
- }
- }
-
- /**
- * Encode a Cache ID as hexadecimal. This is a workaround because Backend ID validation
- * is trapped in the Frontend classes. Will try to get this reversed for ZF 2.0
- * because it's a major annoyance to have IDs so restricted!
- *
- * @return string
- * @param string $requestUri
- */
- protected function _encodeCacheId($requestUri)
- {
- return bin2hex($requestUri);
- }
-
- /**
- * Set an instance of the Cache Manager for this helper
- *
- * @param Zend_Cache_Manager $manager
- * @return void
- */
- public function setManager(Zend_Cache_Manager $manager)
- {
- $this->_manager = $manager;
- return $this;
- }
-
- /**
- * Get the Cache Manager instance or instantiate the object if not
- * exists. Attempts to load from bootstrap if available.
- *
- * @return Zend_Cache_Manager
- */
- public function getManager()
- {
- if ($this->_manager !== null) {
- return $this->_manager;
- }
- $front = Zend_Controller_Front::getInstance();
- if ($front->getParam('bootstrap')
- && $front->getParam('bootstrap')->getResource('CacheManager')) {
- return $front->getParam('bootstrap')
- ->getResource('CacheManager');
- }
- $this->_manager = new Zend_Cache_Manager;
- return $this->_manager;
- }
-
- /**
- * Return a list of actions for the current Controller marked for
- * caching
- *
- * @return array
- */
- public function getCacheableActions()
- {
- return $this->_caching;
- }
-
- /**
- * Return a list of tags set for all cacheable actions
- *
- * @return array
- */
- public function getCacheableTags()
- {
- return $this->_tags;
- }
-
- /**
- * Proxy non-matched methods back to Zend_Cache_Manager where
- * appropriate
- *
- * @param string $method
- * @param array $args
- * @return mixed
- */
- public function __call($method, $args)
- {
- if (method_exists($this->getManager(), $method)) {
- return call_user_func_array(
- array($this->getManager(), $method), $args
- );
- }
- throw new Zend_Controller_Action_Exception('Method does not exist:'
- . $method);
- }
-
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/ContextSwitch.php b/lib/zend/Zend/Controller/Action/Helper/ContextSwitch.php
deleted file mode 100644
index fe9114bc6ebec..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/ContextSwitch.php
+++ /dev/null
@@ -1,1394 +0,0 @@
-setConfig($options);
- } elseif (is_array($options)) {
- $this->setOptions($options);
- }
-
- if (empty($this->_contexts)) {
- $this->addContexts(array(
- 'json' => array(
- 'suffix' => 'json',
- 'headers' => array('Content-Type' => 'application/json'),
- 'callbacks' => array(
- 'init' => 'initJsonContext',
- 'post' => 'postJsonContext'
- )
- ),
- 'xml' => array(
- 'suffix' => 'xml',
- 'headers' => array('Content-Type' => 'application/xml'),
- )
- ));
- }
-
- $this->init();
- }
-
- /**
- * Initialize at start of action controller
- *
- * Reset the view script suffix to the original state, or store the
- * original state.
- *
- * @return void
- */
- public function init()
- {
- if (null === $this->_viewSuffixOrig) {
- $this->_viewSuffixOrig = $this->_getViewRenderer()->getViewSuffix();
- } else {
- $this->_getViewRenderer()->setViewSuffix($this->_viewSuffixOrig);
- }
- }
-
- /**
- * Configure object from array of options
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setOptions(array $options)
- {
- if (isset($options['contexts'])) {
- $this->setContexts($options['contexts']);
- unset($options['contexts']);
- }
-
- foreach ($options as $key => $value) {
- $method = 'set' . ucfirst($key);
- if (in_array($method, $this->_unconfigurable)) {
- continue;
- }
-
- if (in_array($method, $this->_specialConfig)) {
- $method = '_' . $method;
- }
-
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
- return $this;
- }
-
- /**
- * Set object state from config object
- *
- * @param Zend_Config $config
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setConfig(Zend_Config $config)
- {
- return $this->setOptions($config->toArray());
- }
-
- /**
- * Strategy pattern: return object
- *
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function direct()
- {
- return $this;
- }
-
- /**
- * Initialize context detection and switching
- *
- * @param mixed $format
- * @throws Zend_Controller_Action_Exception
- * @return void
- */
- public function initContext($format = null)
- {
- $this->_currentContext = null;
-
- $controller = $this->getActionController();
- $request = $this->getRequest();
- $action = $request->getActionName();
-
- // Return if no context switching enabled, or no context switching
- // enabled for this action
- $contexts = $this->getActionContexts($action);
- if (empty($contexts)) {
- return;
- }
-
- // Return if no context parameter provided
- if (!$context = $request->getParam($this->getContextParam())) {
- if ($format === null) {
- return;
- }
- $context = $format;
- $format = null;
- }
-
- // Check if context allowed by action controller
- if (!$this->hasActionContext($action, $context)) {
- return;
- }
-
- // Return if invalid context parameter provided and no format or invalid
- // format provided
- if (!$this->hasContext($context)) {
- if (empty($format) || !$this->hasContext($format)) {
-
- return;
- }
- }
-
- // Use provided format if passed
- if (!empty($format) && $this->hasContext($format)) {
- $context = $format;
- }
-
- $suffix = $this->getSuffix($context);
-
- $this->_getViewRenderer()->setViewSuffix($suffix);
-
- $headers = $this->getHeaders($context);
- if (!empty($headers)) {
- $response = $this->getResponse();
- foreach ($headers as $header => $content) {
- $response->setHeader($header, $content);
- }
- }
-
- if ($this->getAutoDisableLayout()) {
- /**
- * @see Zend_Layout
- */
- require_once 'Zend/Layout.php';
- $layout = Zend_Layout::getMvcInstance();
- if (null !== $layout) {
- $layout->disableLayout();
- }
- }
-
- if (null !== ($callback = $this->getCallback($context, self::TRIGGER_INIT))) {
- if (is_string($callback) && method_exists($this, $callback)) {
- $this->$callback();
- } elseif (is_string($callback) && function_exists($callback)) {
- $callback();
- } elseif (is_array($callback)) {
- call_user_func($callback);
- } else {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid context callback registered for context "%s"', $context));
- }
- }
-
- $this->_currentContext = $context;
- }
-
- /**
- * JSON context extra initialization
- *
- * Turns off viewRenderer auto-rendering
- *
- * @return void
- */
- public function initJsonContext()
- {
- if (!$this->getAutoJsonSerialization()) {
- return;
- }
-
- $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
- $view = $viewRenderer->view;
- if ($view instanceof Zend_View_Interface) {
- $viewRenderer->setNoRender(true);
- }
- }
-
- /**
- * Should JSON contexts auto-serialize?
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setAutoJsonSerialization($flag)
- {
- $this->_autoJsonSerialization = (bool) $flag;
- return $this;
- }
-
- /**
- * Get JSON context auto-serialization flag
- *
- * @return boolean
- */
- public function getAutoJsonSerialization()
- {
- return $this->_autoJsonSerialization;
- }
-
- /**
- * Set suffix from array
- *
- * @param array $spec
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- protected function _setSuffix(array $spec)
- {
- foreach ($spec as $context => $suffixInfo) {
- if (!is_string($context)) {
- $context = null;
- }
-
- if (is_string($suffixInfo)) {
- $this->setSuffix($context, $suffixInfo);
- continue;
- } elseif (is_array($suffixInfo)) {
- if (isset($suffixInfo['suffix'])) {
- $suffix = $suffixInfo['suffix'];
- $prependViewRendererSuffix = true;
-
- if ((null === $context) && isset($suffixInfo['context'])) {
- $context = $suffixInfo['context'];
- }
-
- if (isset($suffixInfo['prependViewRendererSuffix'])) {
- $prependViewRendererSuffix = $suffixInfo['prependViewRendererSuffix'];
- }
-
- $this->setSuffix($context, $suffix, $prependViewRendererSuffix);
- continue;
- }
-
- $count = count($suffixInfo);
- switch (true) {
- case (($count < 2) && (null === $context)):
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid suffix information provided in config');
- case ($count < 2):
- $suffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix);
- break;
- case (($count < 3) && (null === $context)):
- $context = array_shift($suffixInfo);
- $suffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix);
- break;
- case (($count == 3) && (null === $context)):
- $context = array_shift($suffixInfo);
- $suffix = array_shift($suffixInfo);
- $prependViewRendererSuffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix, $prependViewRendererSuffix);
- break;
- case ($count >= 2):
- $suffix = array_shift($suffixInfo);
- $prependViewRendererSuffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix, $prependViewRendererSuffix);
- break;
- }
- }
- }
- return $this;
- }
-
- /**
- * Customize view script suffix to use when switching context.
- *
- * Passing an empty suffix value to the setters disables the view script
- * suffix change.
- *
- * @param string $context Context type for which to set suffix
- * @param string $suffix Suffix to use
- * @param boolean $prependViewRendererSuffix Whether or not to prepend the new suffix to the viewrenderer suffix
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setSuffix($context, $suffix, $prependViewRendererSuffix = true)
- {
- if (!isset($this->_contexts[$context])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot set suffix; invalid context type "%s"', $context));
- }
-
- if (empty($suffix)) {
- $suffix = '';
- }
-
- if (is_array($suffix)) {
- if (isset($suffix['prependViewRendererSuffix'])) {
- $prependViewRendererSuffix = $suffix['prependViewRendererSuffix'];
- }
- if (isset($suffix['suffix'])) {
- $suffix = $suffix['suffix'];
- } else {
- $suffix = '';
- }
- }
-
- $suffix = (string) $suffix;
-
- if ($prependViewRendererSuffix) {
- if (empty($suffix)) {
- $suffix = $this->_getViewRenderer()->getViewSuffix();
- } else {
- $suffix .= '.' . $this->_getViewRenderer()->getViewSuffix();
- }
- }
-
- $this->_contexts[$context]['suffix'] = $suffix;
- return $this;
- }
-
- /**
- * Retrieve suffix for given context type
- *
- * @param string $type Context type
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- public function getSuffix($type)
- {
- if (!isset($this->_contexts[$type])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot retrieve suffix; invalid context type "%s"', $type));
- }
-
- return $this->_contexts[$type]['suffix'];
- }
-
- /**
- * Does the given context exist?
- *
- * @param string $context
- * @param boolean $throwException
- * @throws Zend_Controller_Action_Exception if context does not exist and throwException is true
- * @return bool
- */
- public function hasContext($context, $throwException = false)
- {
- if (is_string($context)) {
- if (isset($this->_contexts[$context])) {
- return true;
- }
- } elseif (is_array($context)) {
- $error = false;
- foreach ($context as $test) {
- if (!isset($this->_contexts[$test])) {
- $error = (string) $test;
- break;
- }
- }
- if (false === $error) {
- return true;
- }
- $context = $error;
- } elseif (true === $context) {
- return true;
- }
-
- if ($throwException) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Context "%s" does not exist', $context));
- }
-
- return false;
- }
-
- /**
- * Add header to context
- *
- * @param string $context
- * @param string $header
- * @param string $content
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addHeader($context, $header, $content)
- {
- $context = (string) $context;
- $this->hasContext($context, true);
-
- $header = (string) $header;
- $content = (string) $content;
-
- if (isset($this->_contexts[$context]['headers'][$header])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot add "%s" header to context "%s": already exists', $header, $context));
- }
-
- $this->_contexts[$context]['headers'][$header] = $content;
- return $this;
- }
-
- /**
- * Customize response header to use when switching context
- *
- * Passing an empty header value to the setters disables the response
- * header.
- *
- * @param string $type Context type for which to set suffix
- * @param string $header Header to set
- * @param string $content Header content
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setHeader($context, $header, $content)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $header = (string) $header;
- $content = (string) $content;
-
- $this->_contexts[$context]['headers'][$header] = $content;
- return $this;
- }
-
- /**
- * Add multiple headers at once for a given context
- *
- * @param string $context
- * @param array $headers
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addHeaders($context, array $headers)
- {
- foreach ($headers as $header => $content) {
- $this->addHeader($context, $header, $content);
- }
-
- return $this;
- }
-
- /**
- * Set headers from context => headers pairs
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- protected function _setHeaders(array $options)
- {
- foreach ($options as $context => $headers) {
- if (!is_array($headers)) {
- continue;
- }
- $this->setHeaders($context, $headers);
- }
-
- return $this;
- }
-
- /**
- * Set multiple headers at once for a given context
- *
- * @param string $context
- * @param array $headers
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setHeaders($context, array $headers)
- {
- $this->clearHeaders($context);
- foreach ($headers as $header => $content) {
- $this->setHeader($context, $header, $content);
- }
-
- return $this;
- }
-
- /**
- * Retrieve context header
- *
- * Returns the value of a given header for a given context type
- *
- * @param string $context
- * @param string $header
- * @return string|null
- */
- public function getHeader($context, $header)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $header = (string) $header;
- if (isset($this->_contexts[$context]['headers'][$header])) {
- return $this->_contexts[$context]['headers'][$header];
- }
-
- return null;
- }
-
- /**
- * Retrieve context headers
- *
- * Returns all headers for a context as key/value pairs
- *
- * @param string $context
- * @return array
- */
- public function getHeaders($context)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- return $this->_contexts[$context]['headers'];
- }
-
- /**
- * Remove a single header from a context
- *
- * @param string $context
- * @param string $header
- * @return boolean
- */
- public function removeHeader($context, $header)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $header = (string) $header;
- if (isset($this->_contexts[$context]['headers'][$header])) {
- unset($this->_contexts[$context]['headers'][$header]);
- return true;
- }
-
- return false;
- }
-
- /**
- * Clear all headers for a given context
- *
- * @param string $context
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearHeaders($context)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $this->_contexts[$context]['headers'] = array();
- return $this;
- }
-
- /**
- * Validate trigger and return in normalized form
- *
- * @param string $trigger
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- protected function _validateTrigger($trigger)
- {
- $trigger = strtoupper($trigger);
- if ('TRIGGER_' !== substr($trigger, 0, 8)) {
- $trigger = 'TRIGGER_' . $trigger;
- }
-
- if (!in_array($trigger, array(self::TRIGGER_INIT, self::TRIGGER_POST))) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid trigger "%s"', $trigger));
- }
-
- return $trigger;
- }
-
- /**
- * Set a callback for a given context and trigger
- *
- * @param string $context
- * @param string $trigger
- * @param string|array $callback
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setCallback($context, $trigger, $callback)
- {
- $this->hasContext($context, true);
- $trigger = $this->_validateTrigger($trigger);
-
- if (!is_string($callback)) {
- if (!is_array($callback) || (2 != count($callback))) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid callback specified');
- }
- }
-
- $this->_contexts[$context]['callbacks'][$trigger] = $callback;
- return $this;
- }
-
- /**
- * Set callbacks from array of context => callbacks pairs
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- protected function _setCallbacks(array $options)
- {
- foreach ($options as $context => $callbacks) {
- if (!is_array($callbacks)) {
- continue;
- }
-
- $this->setCallbacks($context, $callbacks);
- }
- return $this;
- }
-
- /**
- * Set callbacks for a given context
- *
- * Callbacks should be in trigger/callback pairs.
- *
- * @param string $context
- * @param array $callbacks
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setCallbacks($context, array $callbacks)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- if (!isset($this->_contexts[$context]['callbacks'])) {
- $this->_contexts[$context]['callbacks'] = array();
- }
-
- foreach ($callbacks as $trigger => $callback) {
- $this->setCallback($context, $trigger, $callback);
- }
- return $this;
- }
-
- /**
- * Get a single callback for a given context and trigger
- *
- * @param string $context
- * @param string $trigger
- * @return string|array|null
- */
- public function getCallback($context, $trigger)
- {
- $this->hasContext($context, true);
- $trigger = $this->_validateTrigger($trigger);
- if (isset($this->_contexts[$context]['callbacks'][$trigger])) {
- return $this->_contexts[$context]['callbacks'][$trigger];
- }
-
- return null;
- }
-
- /**
- * Get all callbacks for a given context
- *
- * @param string $context
- * @return array
- */
- public function getCallbacks($context)
- {
- $this->hasContext($context, true);
- return $this->_contexts[$context]['callbacks'];
- }
-
- /**
- * Clear a callback for a given context and trigger
- *
- * @param string $context
- * @param string $trigger
- * @return boolean
- */
- public function removeCallback($context, $trigger)
- {
- $this->hasContext($context, true);
- $trigger = $this->_validateTrigger($trigger);
- if (isset($this->_contexts[$context]['callbacks'][$trigger])) {
- unset($this->_contexts[$context]['callbacks'][$trigger]);
- return true;
- }
-
- return false;
- }
-
- /**
- * Clear all callbacks for a given context
- *
- * @param string $context
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearCallbacks($context)
- {
- $this->hasContext($context, true);
- $this->_contexts[$context]['callbacks'] = array();
- return $this;
- }
-
- /**
- * Set name of parameter to use when determining context format
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setContextParam($name)
- {
- $this->_contextParam = (string) $name;
- return $this;
- }
-
- /**
- * Return context format request parameter name
- *
- * @return string
- */
- public function getContextParam()
- {
- return $this->_contextParam;
- }
-
- /**
- * Indicate default context to use when no context format provided
- *
- * @param string $type
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setDefaultContext($type)
- {
- if (!isset($this->_contexts[$type])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot set default context; invalid context type "%s"', $type));
- }
-
- $this->_defaultContext = $type;
- return $this;
- }
-
- /**
- * Return default context
- *
- * @return string
- */
- public function getDefaultContext()
- {
- return $this->_defaultContext;
- }
-
- /**
- * Set flag indicating if layout should be disabled
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setAutoDisableLayout($flag)
- {
- $this->_disableLayout = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve auto layout disable flag
- *
- * @return boolean
- */
- public function getAutoDisableLayout()
- {
- return $this->_disableLayout;
- }
-
- /**
- * Add new context
- *
- * @param string $context Context type
- * @param array $spec Context specification
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addContext($context, array $spec)
- {
- if ($this->hasContext($context)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot add context "%s"; already exists', $context));
- }
- $context = (string) $context;
-
- $this->_contexts[$context] = array();
-
- $this->setSuffix($context, (isset($spec['suffix']) ? $spec['suffix'] : ''))
- ->setHeaders($context, (isset($spec['headers']) ? $spec['headers'] : array()))
- ->setCallbacks($context, (isset($spec['callbacks']) ? $spec['callbacks'] : array()));
- return $this;
- }
-
- /**
- * Overwrite existing context
- *
- * @param string $context Context type
- * @param array $spec Context specification
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setContext($context, array $spec)
- {
- $this->removeContext($context);
- return $this->addContext($context, $spec);
- }
-
- /**
- * Add multiple contexts
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addContexts(array $contexts)
- {
- foreach ($contexts as $context => $spec) {
- $this->addContext($context, $spec);
- }
- return $this;
- }
-
- /**
- * Set multiple contexts, after first removing all
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setContexts(array $contexts)
- {
- $this->clearContexts();
- foreach ($contexts as $context => $spec) {
- $this->addContext($context, $spec);
- }
- return $this;
- }
-
- /**
- * Retrieve context specification
- *
- * @param string $context
- * @return array|null
- */
- public function getContext($context)
- {
- if ($this->hasContext($context)) {
- return $this->_contexts[(string) $context];
- }
- return null;
- }
-
- /**
- * Retrieve context definitions
- *
- * @return array
- */
- public function getContexts()
- {
- return $this->_contexts;
- }
-
- /**
- * Remove a context
- *
- * @param string $context
- * @return boolean
- */
- public function removeContext($context)
- {
- if ($this->hasContext($context)) {
- unset($this->_contexts[(string) $context]);
- return true;
- }
- return false;
- }
-
- /**
- * Remove all contexts
- *
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearContexts()
- {
- $this->_contexts = array();
- return $this;
- }
-
- /**
- * Return current context, if any
- *
- * @return null|string
- */
- public function getCurrentContext()
- {
- return $this->_currentContext;
- }
-
- /**
- * Post dispatch processing
- *
- * Execute postDispatch callback for current context, if available
- *
- * @throws Zend_Controller_Action_Exception
- * @return void
- */
- public function postDispatch()
- {
- $context = $this->getCurrentContext();
- if (null !== $context) {
- if (null !== ($callback = $this->getCallback($context, self::TRIGGER_POST))) {
- if (is_string($callback) && method_exists($this, $callback)) {
- $this->$callback();
- } elseif (is_string($callback) && function_exists($callback)) {
- $callback();
- } elseif (is_array($callback)) {
- call_user_func($callback);
- } else {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid postDispatch context callback registered for context "%s"', $context));
- }
- }
- }
- }
-
- /**
- * JSON post processing
- *
- * JSON serialize view variables to response body
- *
- * @return void
- */
- public function postJsonContext()
- {
- if (!$this->getAutoJsonSerialization()) {
- return;
- }
-
- $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
- $view = $viewRenderer->view;
- if ($view instanceof Zend_View_Interface) {
- /**
- * @see Zend_Json
- */
- if(method_exists($view, 'getVars')) {
- require_once 'Zend/Json.php';
- $vars = Zend_Json::encode($view->getVars());
- $this->getResponse()->setBody($vars);
- } else {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('View does not implement the getVars() method needed to encode the view into JSON');
- }
- }
- }
-
- /**
- * Add one or more contexts to an action
- *
- * @param string $action
- * @param string|array $context
- * @return Zend_Controller_Action_Helper_ContextSwitch|void Provides a fluent interface
- */
- public function addActionContext($action, $context)
- {
- $this->hasContext($context, true);
- $controller = $this->getActionController();
- if (null === $controller) {
- return;
- }
- $action = (string) $action;
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey)) {
- $controller->$contextKey = array();
- }
-
- if (true === $context) {
- $contexts = $this->getContexts();
- $controller->{$contextKey}[$action] = array_keys($contexts);
- return $this;
- }
-
- $context = (array) $context;
- if (!isset($controller->{$contextKey}[$action])) {
- $controller->{$contextKey}[$action] = $context;
- } else {
- $controller->{$contextKey}[$action] = array_merge(
- $controller->{$contextKey}[$action],
- $context
- );
- }
-
- return $this;
- }
-
- /**
- * Set a context as available for a given controller action
- *
- * @param string $action
- * @param string|array $context
- * @return Zend_Controller_Action_Helper_ContextSwitch|void Provides a fluent interface
- */
- public function setActionContext($action, $context)
- {
- $this->hasContext($context, true);
- $controller = $this->getActionController();
- if (null === $controller) {
- return;
- }
- $action = (string) $action;
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey)) {
- $controller->$contextKey = array();
- }
-
- if (true === $context) {
- $contexts = $this->getContexts();
- $controller->{$contextKey}[$action] = array_keys($contexts);
- } else {
- $controller->{$contextKey}[$action] = (array) $context;
- }
-
- return $this;
- }
-
- /**
- * Add multiple action/context pairs at once
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addActionContexts(array $contexts)
- {
- foreach ($contexts as $action => $context) {
- $this->addActionContext($action, $context);
- }
- return $this;
- }
-
- /**
- * Overwrite and set multiple action contexts at once
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setActionContexts(array $contexts)
- {
- foreach ($contexts as $action => $context) {
- $this->setActionContext($action, $context);
- }
- return $this;
- }
-
- /**
- * Does a particular controller action have the given context(s)?
- *
- * @param string $action
- * @param string|array $context
- * @throws Zend_Controller_Action_Exception
- * @return boolean
- */
- public function hasActionContext($action, $context)
- {
- $this->hasContext($context, true);
- $controller = $this->getActionController();
- if (null === $controller) {
- return false;
- }
- $action = (string) $action;
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->{$contextKey})) {
- return false;
- }
-
- $allContexts = $controller->{$contextKey};
-
- if (!is_array($allContexts)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception("Invalid contexts found for controller");
- }
-
- if (!isset($allContexts[$action])) {
- return false;
- }
-
- if (true === $allContexts[$action]) {
- return true;
- }
-
- $contexts = $allContexts[$action];
-
- if (!is_array($contexts)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf("Invalid contexts found for action '%s'", $action));
- }
-
- if (is_string($context) && in_array($context, $contexts)) {
- return true;
- } elseif (is_array($context)) {
- $found = true;
- foreach ($context as $test) {
- if (!in_array($test, $contexts)) {
- $found = false;
- break;
- }
- }
- return $found;
- }
-
- return false;
- }
-
- /**
- * Get contexts for a given action or all actions in the controller
- *
- * @param string $action
- * @return array
- */
- public function getActionContexts($action = null)
- {
- $controller = $this->getActionController();
- if (null === $controller) {
- return array();
- }
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey)) {
- return array();
- }
-
- if (null !== $action) {
- $action = (string) $action;
- if (isset($controller->{$contextKey}[$action])) {
- return $controller->{$contextKey}[$action];
- } else {
- return array();
- }
- }
-
- return $controller->$contextKey;
- }
-
- /**
- * Remove one or more contexts for a given controller action
- *
- * @param string $action
- * @param string|array $context
- * @return boolean
- */
- public function removeActionContext($action, $context)
- {
- if ($this->hasActionContext($action, $context)) {
- $controller = $this->getActionController();
- $contextKey = $this->_contextKey;
- $action = (string) $action;
- $contexts = $controller->$contextKey;
- $actionContexts = $contexts[$action];
- $contexts = (array) $context;
- foreach ($contexts as $context) {
- $index = array_search($context, $actionContexts);
- if (false !== $index) {
- unset($controller->{$contextKey}[$action][$index]);
- }
- }
- return true;
- }
- return false;
- }
-
- /**
- * Clear all contexts for a given controller action or all actions
- *
- * @param string $action
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearActionContexts($action = null)
- {
- $controller = $this->getActionController();
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey) || empty($controller->$contextKey)) {
- return $this;
- }
-
- if (null === $action) {
- $controller->$contextKey = array();
- return $this;
- }
-
- $action = (string) $action;
- if (isset($controller->{$contextKey}[$action])) {
- unset($controller->{$contextKey}[$action]);
- }
-
- return $this;
- }
-
- /**
- * Retrieve ViewRenderer
- *
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- protected function _getViewRenderer()
- {
- if (null === $this->_viewRenderer) {
- $this->_viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
- }
-
- return $this->_viewRenderer;
- }
-}
-
diff --git a/lib/zend/Zend/Controller/Action/Helper/FlashMessenger.php b/lib/zend/Zend/Controller/Action/Helper/FlashMessenger.php
deleted file mode 100644
index 57fe9ecdeebe7..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/FlashMessenger.php
+++ /dev/null
@@ -1,313 +0,0 @@
-getName());
- foreach (self::$_session as $namespace => $messages) {
- self::$_messages[$namespace] = $messages;
- unset(self::$_session->{$namespace});
- }
- }
- }
-
- /**
- * postDispatch() - runs after action is dispatched, in this
- * case, it is resetting the namespace in case we have forwarded to a different
- * action, Flashmessage will be 'clean' (default namespace)
- *
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function postDispatch()
- {
- $this->resetNamespace();
- return $this;
- }
-
- /**
- * setNamespace() - change the namespace messages are added to, useful for
- * per action controller messaging between requests
- *
- * @param string $namespace
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function setNamespace($namespace = 'default')
- {
- $this->_namespace = $namespace;
- return $this;
- }
-
- /**
- * getNamespace() - return the current namepsace
- *
- * @return string
- */
- public function getNamespace()
- {
- return $this->_namespace;
- }
-
- /**
- * resetNamespace() - reset the namespace to the default
- *
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function resetNamespace()
- {
- $this->setNamespace();
- return $this;
- }
-
- /**
- * addMessage() - Add a message to flash message
- *
- * @param string $message
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function addMessage($message, $namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- if (self::$_messageAdded === false) {
- self::$_session->setExpirationHops(1, null, true);
- }
-
- if (!is_array(self::$_session->{$namespace})) {
- self::$_session->{$namespace} = array();
- }
-
- self::$_session->{$namespace}[] = $message;
- self::$_messageAdded = true;
-
- return $this;
- }
-
- /**
- * hasMessages() - Wether a specific namespace has messages
- *
- * @return boolean
- */
- public function hasMessages($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- return isset(self::$_messages[$namespace]);
- }
-
- /**
- * getMessages() - Get messages from a specific namespace
- *
- * @return array
- */
- public function getMessages($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- if ($this->hasMessages($namespace)) {
- return self::$_messages[$namespace];
- }
-
- return array();
- }
-
- /**
- * Clear all messages from the previous request & current namespace
- *
- * @return boolean True if messages were cleared, false if none existed
- */
- public function clearMessages($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- if ($this->hasMessages($namespace)) {
- unset(self::$_messages[$namespace]);
- return true;
- }
-
- return false;
- }
-
- /**
- * hasCurrentMessages() - check to see if messages have been added to current
- * namespace within this request
- *
- * @return boolean
- */
- public function hasCurrentMessages($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- return isset(self::$_session->{$namespace});
- }
-
- /**
- * getCurrentMessages() - get messages that have been added to the current
- * namespace within this request
- *
- * @return array
- */
- public function getCurrentMessages($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- if ($this->hasCurrentMessages($namespace)) {
- return self::$_session->{$namespace};
- }
-
- return array();
- }
-
- /**
- * clear messages from the current request & current namespace
- *
- * @return boolean
- */
- public function clearCurrentMessages($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- if ($this->hasCurrentMessages($namespace)) {
- unset(self::$_session->{$namespace});
- return true;
- }
-
- return false;
- }
-
- /**
- * getIterator() - complete the IteratorAggregate interface, for iterating
- *
- * @return ArrayObject
- */
- public function getIterator($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- if ($this->hasMessages($namespace)) {
- return new ArrayObject($this->getMessages($namespace));
- }
-
- return new ArrayObject();
- }
-
- /**
- * count() - Complete the countable interface
- *
- * @return int
- */
- public function count($namespace = null)
- {
- if (!is_string($namespace) || $namespace == '') {
- $namespace = $this->getNamespace();
- }
-
- if ($this->hasMessages($namespace)) {
- return count($this->getMessages($namespace));
- }
-
- return 0;
- }
-
- /**
- * Strategy pattern: proxy to addMessage()
- *
- * @param string $message
- * @return void
- */
- public function direct($message, $namespace=NULL)
- {
- return $this->addMessage($message, $namespace);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/Json.php b/lib/zend/Zend/Controller/Action/Helper/Json.php
deleted file mode 100644
index 86a8b113c175a..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/Json.php
+++ /dev/null
@@ -1,133 +0,0 @@
-true|false
- * if $keepLayouts and parmas for Zend_Json::encode are required
- * then, the array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false
- * that will not be passed to Zend_Json::encode method but will be passed
- * to Zend_View_Helper_Json
- * @throws Zend_Controller_Action_Helper_Json
- * @return string
- */
- public function encodeJson($data, $keepLayouts = false, $encodeData = true)
- {
- /**
- * @see Zend_View_Helper_Json
- */
- require_once 'Zend/View/Helper/Json.php';
- $jsonHelper = new Zend_View_Helper_Json();
- $data = $jsonHelper->json($data, $keepLayouts, $encodeData);
-
- if (!$keepLayouts) {
- /**
- * @see Zend_Controller_Action_HelperBroker
- */
- require_once 'Zend/Controller/Action/HelperBroker.php';
- Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
- }
-
- return $data;
- }
-
- /**
- * Encode JSON response and immediately send
- *
- * @param mixed $data
- * @param boolean|array $keepLayouts
- * @param $encodeData Encode $data as JSON?
- * NOTE: if boolean, establish $keepLayouts to true|false
- * if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false
- * if $keepLayouts and parmas for Zend_Json::encode are required
- * then, the array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false
- * that will not be passed to Zend_Json::encode method but will be passed
- * to Zend_View_Helper_Json
- * @return string|void
- */
- public function sendJson($data, $keepLayouts = false, $encodeData = true)
- {
- $data = $this->encodeJson($data, $keepLayouts, $encodeData);
- $response = $this->getResponse();
- $response->setBody($data);
-
- if (!$this->suppressExit) {
- $response->sendResponse();
- exit;
- }
-
- return $data;
- }
-
- /**
- * Strategy pattern: call helper as helper broker method
- *
- * Allows encoding JSON. If $sendNow is true, immediately sends JSON
- * response.
- *
- * @param mixed $data
- * @param boolean $sendNow
- * @param boolean $keepLayouts
- * @param boolean $encodeData Encode $data as JSON?
- * @return string|void
- */
- public function direct($data, $sendNow = true, $keepLayouts = false, $encodeData = true)
- {
- if ($sendNow) {
- return $this->sendJson($data, $keepLayouts, $encodeData);
- }
- return $this->encodeJson($data, $keepLayouts, $encodeData);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/Redirector.php b/lib/zend/Zend/Controller/Action/Helper/Redirector.php
deleted file mode 100644
index 8c81646224df5..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/Redirector.php
+++ /dev/null
@@ -1,534 +0,0 @@
-_code;
- }
-
- /**
- * Validate HTTP status redirect code
- *
- * @param int $code
- * @throws Zend_Controller_Action_Exception on invalid HTTP status code
- * @return true
- */
- protected function _checkCode($code)
- {
- $code = (int)$code;
- if ((300 > $code) || (307 < $code) || (304 == $code) || (306 == $code)) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid redirect HTTP status code (' . $code . ')');
- }
-
- return true;
- }
-
- /**
- * Set HTTP status code for {@link _redirect()} behaviour
- *
- * @param int $code
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setCode($code)
- {
- $this->_checkCode($code);
- $this->_code = $code;
- return $this;
- }
-
- /**
- * Retrieve flag for whether or not {@link _redirect()} will exit when finished.
- *
- * @return boolean
- */
- public function getExit()
- {
- return $this->_exit;
- }
-
- /**
- * Set exit flag for {@link _redirect()} behaviour
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setExit($flag)
- {
- $this->_exit = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve flag for whether or not {@link _redirect()} will prepend the
- * base URL on relative URLs
- *
- * @return boolean
- */
- public function getPrependBase()
- {
- return $this->_prependBase;
- }
-
- /**
- * Set 'prepend base' flag for {@link _redirect()} behaviour
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setPrependBase($flag)
- {
- $this->_prependBase = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve flag for whether or not {@link redirectAndExit()} shall close the session before
- * exiting.
- *
- * @return boolean
- */
- public function getCloseSessionOnExit()
- {
- return $this->_closeSessionOnExit;
- }
-
- /**
- * Set flag for whether or not {@link redirectAndExit()} shall close the session before exiting.
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setCloseSessionOnExit($flag)
- {
- $this->_closeSessionOnExit = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Return use absolute URI flag
- *
- * @return boolean
- */
- public function getUseAbsoluteUri()
- {
- return $this->_useAbsoluteUri;
- }
-
- /**
- * Set use absolute URI flag
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setUseAbsoluteUri($flag = true)
- {
- $this->_useAbsoluteUri = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Set redirect in response object
- *
- * @return void
- */
- protected function _redirect($url)
- {
- if ($this->getUseAbsoluteUri() && !preg_match('#^(https?|ftp)://#', $url)) {
- $host = (isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:'');
- $proto = (isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=="off") ? 'https' : 'http';
- $port = (isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:80);
- $uri = $proto . '://' . $host;
- if ((('http' == $proto) && (80 != $port)) || (('https' == $proto) && (443 != $port))) {
- // do not append if HTTP_HOST already contains port
- if (strrchr($host, ':') === false) {
- $uri .= ':' . $port;
- }
- }
- $url = $uri . '/' . ltrim($url, '/');
- }
- $this->_redirectUrl = $url;
- $this->getResponse()->setRedirect($url, $this->getCode());
- }
-
- /**
- * Retrieve currently set URL for redirect
- *
- * @return string
- */
- public function getRedirectUrl()
- {
- return $this->_redirectUrl;
- }
-
- /**
- * Determine if the baseUrl should be prepended, and prepend if necessary
- *
- * @param string $url
- * @return string
- */
- protected function _prependBase($url)
- {
- if ($this->getPrependBase()) {
- $request = $this->getRequest();
- if ($request instanceof Zend_Controller_Request_Http) {
- $base = rtrim($request->getBaseUrl(), '/');
- if (!empty($base) && ('/' != $base)) {
- $url = $base . '/' . ltrim($url, '/');
- } else {
- $url = '/' . ltrim($url, '/');
- }
- }
- }
-
- return $url;
- }
-
- /**
- * Set a redirect URL of the form /module/controller/action/params
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- public function setGotoSimple($action, $controller = null, $module = null, array $params = array())
- {
- $dispatcher = $this->getFrontController()->getDispatcher();
- $request = $this->getRequest();
- $curModule = $request->getModuleName();
- $useDefaultController = false;
-
- if (null === $controller && null !== $module) {
- $useDefaultController = true;
- }
-
- if (null === $module) {
- $module = $curModule;
- }
-
- if ($module == $dispatcher->getDefaultModule()) {
- $module = '';
- }
-
- if (null === $controller && !$useDefaultController) {
- $controller = $request->getControllerName();
- if (empty($controller)) {
- $controller = $dispatcher->getDefaultControllerName();
- }
- }
-
- $params[$request->getModuleKey()] = $module;
- $params[$request->getControllerKey()] = $controller;
- $params[$request->getActionKey()] = $action;
-
- $router = $this->getFrontController()->getRouter();
- $url = $router->assemble($params, 'default', true);
-
- $this->_redirect($url);
- }
-
- /**
- * Build a URL based on a route
- *
- * @param array $urlOptions
- * @param string $name Route name
- * @param boolean $reset
- * @param boolean $encode
- * @return void
- */
- public function setGotoRoute(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
- {
- $router = $this->getFrontController()->getRouter();
- $url = $router->assemble($urlOptions, $name, $reset, $encode);
-
- $this->_redirect($url);
- }
-
- /**
- * Set a redirect URL string
- *
- * By default, emits a 302 HTTP status header, prepends base URL as defined
- * in request object if url is relative, and halts script execution by
- * calling exit().
- *
- * $options is an optional associative array that can be used to control
- * redirect behaviour. The available option keys are:
- * - exit: boolean flag indicating whether or not to halt script execution when done
- * - prependBase: boolean flag indicating whether or not to prepend the base URL when a relative URL is provided
- * - code: integer HTTP status code to use with redirect. Should be between 300 and 307.
- *
- * _redirect() sets the Location header in the response object. If you set
- * the exit flag to false, you can override this header later in code
- * execution.
- *
- * If the exit flag is true (true by default), _redirect() will write and
- * close the current session, if any.
- *
- * @param string $url
- * @param array $options
- * @return void
- */
- public function setGotoUrl($url, array $options = array())
- {
- // prevent header injections
- $url = str_replace(array("\n", "\r"), '', $url);
-
- if (null !== $options) {
- if (isset($options['exit'])) {
- $this->setExit(($options['exit']) ? true : false);
- }
- if (isset($options['prependBase'])) {
- $this->setPrependBase(($options['prependBase']) ? true : false);
- }
- if (isset($options['code'])) {
- $this->setCode($options['code']);
- }
- }
-
- // If relative URL, decide if we should prepend base URL
- if (!preg_match('|^[a-z]+://|', $url)) {
- $url = $this->_prependBase($url);
- }
-
- $this->_redirect($url);
- }
-
- /**
- * Perform a redirect to an action/controller/module with params
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- public function gotoSimple($action, $controller = null, $module = null, array $params = array())
- {
- $this->setGotoSimple($action, $controller, $module, $params);
-
- if ($this->getExit()) {
- $this->redirectAndExit();
- }
- }
-
- /**
- * Perform a redirect to an action/controller/module with params, forcing an immdiate exit
- *
- * @param mixed $action
- * @param mixed $controller
- * @param mixed $module
- * @param array $params
- * @return void
- */
- public function gotoSimpleAndExit($action, $controller = null, $module = null, array $params = array())
- {
- $this->setGotoSimple($action, $controller, $module, $params);
- $this->redirectAndExit();
- }
-
- /**
- * Redirect to a route-based URL
- *
- * Uses route's assemble method to build the URL; route is specified by $name;
- * default route is used if none provided.
- *
- * @param array $urlOptions Array of key/value pairs used to assemble URL
- * @param string $name
- * @param boolean $reset
- * @param boolean $encode
- * @return void
- */
- public function gotoRoute(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
- {
- $this->setGotoRoute($urlOptions, $name, $reset, $encode);
-
- if ($this->getExit()) {
- $this->redirectAndExit();
- }
- }
-
- /**
- * Redirect to a route-based URL, and immediately exit
- *
- * Uses route's assemble method to build the URL; route is specified by $name;
- * default route is used if none provided.
- *
- * @param array $urlOptions Array of key/value pairs used to assemble URL
- * @param string $name
- * @param boolean $reset
- * @return void
- */
- public function gotoRouteAndExit(array $urlOptions = array(), $name = null, $reset = false)
- {
- $this->setGotoRoute($urlOptions, $name, $reset);
- $this->redirectAndExit();
- }
-
- /**
- * Perform a redirect to a url
- *
- * @param string $url
- * @param array $options
- * @return void
- */
- public function gotoUrl($url, array $options = array())
- {
- $this->setGotoUrl($url, $options);
-
- if ($this->getExit()) {
- $this->redirectAndExit();
- }
- }
-
- /**
- * Set a URL string for a redirect, perform redirect, and immediately exit
- *
- * @param string $url
- * @param array $options
- * @return void
- */
- public function gotoUrlAndExit($url, array $options = array())
- {
- $this->setGotoUrl($url, $options);
- $this->redirectAndExit();
- }
-
- /**
- * exit(): Perform exit for redirector
- *
- * @return void
- */
- public function redirectAndExit()
- {
- if ($this->getCloseSessionOnExit()) {
- // Close session, if started
- if (class_exists('Zend_Session', false) && Zend_Session::isStarted()) {
- Zend_Session::writeClose();
- } elseif (isset($_SESSION)) {
- session_write_close();
- }
- }
-
- $this->getResponse()->sendHeaders();
- exit();
- }
-
- /**
- * direct(): Perform helper when called as
- * $this->_helper->redirector($action, $controller, $module, $params)
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- public function direct($action, $controller = null, $module = null, array $params = array())
- {
- $this->gotoSimple($action, $controller, $module, $params);
- }
-
- /**
- * Overloading
- *
- * Overloading for old 'goto', 'setGoto', and 'gotoAndExit' methods
- *
- * @param string $method
- * @param array $args
- * @return mixed
- * @throws Zend_Controller_Action_Exception for invalid methods
- */
- public function __call($method, $args)
- {
- $method = strtolower($method);
- if ('goto' == $method) {
- return call_user_func_array(array($this, 'gotoSimple'), $args);
- }
- if ('setgoto' == $method) {
- return call_user_func_array(array($this, 'setGotoSimple'), $args);
- }
- if ('gotoandexit' == $method) {
- return call_user_func_array(array($this, 'gotoSimpleAndExit'), $args);
- }
-
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid method "%s" called on redirector', $method));
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/Url.php b/lib/zend/Zend/Controller/Action/Helper/Url.php
deleted file mode 100644
index 7b8c69ac12a6a..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/Url.php
+++ /dev/null
@@ -1,117 +0,0 @@
-getRequest();
-
- if (null === $controller) {
- $controller = $request->getControllerName();
- }
-
- if (null === $module) {
- $module = $request->getModuleName();
- }
-
- $url = $controller . '/' . $action;
- if ($module != $this->getFrontController()->getDispatcher()->getDefaultModule()) {
- $url = $module . '/' . $url;
- }
-
- if ('' !== ($baseUrl = $this->getFrontController()->getBaseUrl())) {
- $url = $baseUrl . '/' . $url;
- }
-
- if (null !== $params) {
- $paramPairs = array();
- foreach ($params as $key => $value) {
- $paramPairs[] = urlencode($key) . '/' . urlencode($value);
- }
- $paramString = implode('/', $paramPairs);
- $url .= '/' . $paramString;
- }
-
- $url = '/' . ltrim($url, '/');
-
- return $url;
- }
-
- /**
- * Assembles a URL based on a given route
- *
- * This method will typically be used for more complex operations, as it
- * ties into the route objects registered with the router.
- *
- * @param array $urlOptions Options passed to the assemble method of the Route object.
- * @param mixed $name The name of a Route to use. If null it will use the current Route
- * @param boolean $reset
- * @param boolean $encode
- * @return string Url for the link href attribute.
- */
- public function url($urlOptions = array(), $name = null, $reset = false, $encode = true)
- {
- $router = $this->getFrontController()->getRouter();
- return $router->assemble($urlOptions, $name, $reset, $encode);
- }
-
- /**
- * Perform helper when called as $this->_helper->url() from an action controller
- *
- * Proxies to {@link simple()}
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return string
- */
- public function direct($action, $controller = null, $module = null, array $params = null)
- {
- return $this->simple($action, $controller, $module, $params);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/Helper/ViewRenderer.php b/lib/zend/Zend/Controller/Action/Helper/ViewRenderer.php
deleted file mode 100644
index a66c12a466596..0000000000000
--- a/lib/zend/Zend/Controller/Action/Helper/ViewRenderer.php
+++ /dev/null
@@ -1,1004 +0,0 @@
-
- * // In your bootstrap:
- * Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer());
- *
- * // In your action controller methods:
- * $viewHelper = $this->_helper->getHelper('view');
- *
- * // Don't use controller subdirectories
- * $viewHelper->setNoController(true);
- *
- * // Specify a different script to render:
- * $this->_helper->viewRenderer('form');
- *
- *
- *
- * @uses Zend_Controller_Action_Helper_Abstract
- * @package Zend_Controller
- * @subpackage Zend_Controller_Action_Helper
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Controller_Action_Helper_ViewRenderer extends Zend_Controller_Action_Helper_Abstract
-{
- /**
- * @var Zend_View_Interface
- */
- public $view;
-
- /**
- * Word delimiters
- * @var array
- */
- protected $_delimiters;
-
- /**
- * @var Zend_Filter_Inflector
- */
- protected $_inflector;
-
- /**
- * Inflector target
- * @var string
- */
- protected $_inflectorTarget = '';
-
- /**
- * Current module directory
- * @var string
- */
- protected $_moduleDir = '';
-
- /**
- * Whether or not to autorender using controller name as subdirectory;
- * global setting (not reset at next invocation)
- * @var boolean
- */
- protected $_neverController = false;
-
- /**
- * Whether or not to autorender postDispatch; global setting (not reset at
- * next invocation)
- * @var boolean
- */
- protected $_neverRender = false;
-
- /**
- * Whether or not to use a controller name as a subdirectory when rendering
- * @var boolean
- */
- protected $_noController = false;
-
- /**
- * Whether or not to autorender postDispatch; per controller/action setting (reset
- * at next invocation)
- * @var boolean
- */
- protected $_noRender = false;
-
- /**
- * Characters representing path delimiters in the controller
- * @var string|array
- */
- protected $_pathDelimiters;
-
- /**
- * Which named segment of the response to utilize
- * @var string
- */
- protected $_responseSegment = null;
-
- /**
- * Which action view script to render
- * @var string
- */
- protected $_scriptAction = null;
-
- /**
- * View object basePath
- * @var string
- */
- protected $_viewBasePathSpec = ':moduleDir/views';
-
- /**
- * View script path specification string
- * @var string
- */
- protected $_viewScriptPathSpec = ':controller/:action.:suffix';
-
- /**
- * View script path specification string, minus controller segment
- * @var string
- */
- protected $_viewScriptPathNoControllerSpec = ':action.:suffix';
-
- /**
- * View script suffix
- * @var string
- */
- protected $_viewSuffix = 'phtml';
-
- /**
- * Constructor
- *
- * Optionally set view object and options.
- *
- * @param Zend_View_Interface $view
- * @param array $options
- * @return void
- */
- public function __construct(Zend_View_Interface $view = null, array $options = array())
- {
- if (null !== $view) {
- $this->setView($view);
- }
-
- if (!empty($options)) {
- $this->_setOptions($options);
- }
- }
-
- /**
- * Clone - also make sure the view is cloned.
- *
- * @return void
- */
- public function __clone()
- {
- if (isset($this->view) && $this->view instanceof Zend_View_Interface) {
- $this->view = clone $this->view;
-
- }
- }
-
- /**
- * Set the view object
- *
- * @param Zend_View_Interface $view
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setView(Zend_View_Interface $view)
- {
- $this->view = $view;
- return $this;
- }
-
- /**
- * Get current module name
- *
- * @return string
- */
- public function getModule()
- {
- $request = $this->getRequest();
- $module = $request->getModuleName();
- if (null === $module) {
- $module = $this->getFrontController()->getDispatcher()->getDefaultModule();
- }
-
- return $module;
- }
-
- /**
- * Get module directory
- *
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- public function getModuleDirectory()
- {
- $module = $this->getModule();
- $moduleDir = $this->getFrontController()->getControllerDirectory($module);
- if ((null === $moduleDir) || is_array($moduleDir)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('ViewRenderer cannot locate module directory for module "' . $module . '"');
- }
- $this->_moduleDir = dirname($moduleDir);
- return $this->_moduleDir;
- }
-
- /**
- * Get inflector
- *
- * @return Zend_Filter_Inflector
- */
- public function getInflector()
- {
- if (null === $this->_inflector) {
- /**
- * @see Zend_Filter_Inflector
- */
- require_once 'Zend/Filter/Inflector.php';
- /**
- * @see Zend_Filter_PregReplace
- */
- require_once 'Zend/Filter/PregReplace.php';
- /**
- * @see Zend_Filter_Word_UnderscoreToSeparator
- */
- require_once 'Zend/Filter/Word/UnderscoreToSeparator.php';
- $this->_inflector = new Zend_Filter_Inflector();
- $this->_inflector->setStaticRuleReference('moduleDir', $this->_moduleDir) // moduleDir must be specified before the less specific 'module'
- ->addRules(array(
- ':module' => array('Word_CamelCaseToDash', 'StringToLower'),
- ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower', new Zend_Filter_PregReplace('/\./', '-')),
- ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('#[^a-z0-9' . preg_quote('/', '#') . ']+#i', '-'), 'StringToLower'),
- ))
- ->setStaticRuleReference('suffix', $this->_viewSuffix)
- ->setTargetReference($this->_inflectorTarget);
- }
-
- // Ensure that module directory is current
- $this->getModuleDirectory();
-
- return $this->_inflector;
- }
-
- /**
- * Set inflector
- *
- * @param Zend_Filter_Inflector $inflector
- * @param boolean $reference Whether the moduleDir, target, and suffix should be set as references to ViewRenderer properties
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setInflector(Zend_Filter_Inflector $inflector, $reference = false)
- {
- $this->_inflector = $inflector;
- if ($reference) {
- $this->_inflector->setStaticRuleReference('suffix', $this->_viewSuffix)
- ->setStaticRuleReference('moduleDir', $this->_moduleDir)
- ->setTargetReference($this->_inflectorTarget);
- }
- return $this;
- }
-
- /**
- * Set inflector target
- *
- * @param string $target
- * @return void
- */
- protected function _setInflectorTarget($target)
- {
- $this->_inflectorTarget = (string) $target;
- }
-
- /**
- * Set internal module directory representation
- *
- * @param string $dir
- * @return void
- */
- protected function _setModuleDir($dir)
- {
- $this->_moduleDir = (string) $dir;
- }
-
- /**
- * Get internal module directory representation
- *
- * @return string
- */
- protected function _getModuleDir()
- {
- return $this->_moduleDir;
- }
-
- /**
- * Generate a class prefix for helper and filter classes
- *
- * @return string
- */
- protected function _generateDefaultPrefix()
- {
- $default = 'Zend_View';
- if (null === $this->_actionController) {
- return $default;
- }
-
- $class = get_class($this->_actionController);
-
- if (!strstr($class, '_')) {
- return $default;
- }
-
- $module = $this->getModule();
- if ('default' == $module) {
- return $default;
- }
-
- $prefix = substr($class, 0, strpos($class, '_')) . '_View';
-
- return $prefix;
- }
-
- /**
- * Retrieve base path based on location of current action controller
- *
- * @return string
- */
- protected function _getBasePath()
- {
- if (null === $this->_actionController) {
- return './views';
- }
-
- $inflector = $this->getInflector();
- $this->_setInflectorTarget($this->getViewBasePathSpec());
-
- $dispatcher = $this->getFrontController()->getDispatcher();
- $request = $this->getRequest();
-
- $parts = array(
- 'module' => (($moduleName = $request->getModuleName()) != '') ? $dispatcher->formatModuleName($moduleName) : $moduleName,
- 'controller' => $request->getControllerName(),
- 'action' => $dispatcher->formatActionName($request->getActionName())
- );
-
- $path = $inflector->filter($parts);
- return $path;
- }
-
- /**
- * Set options
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- protected function _setOptions(array $options)
- {
- foreach ($options as $key => $value)
- {
- switch ($key) {
- case 'neverRender':
- case 'neverController':
- case 'noController':
- case 'noRender':
- $property = '_' . $key;
- $this->{$property} = ($value) ? true : false;
- break;
- case 'responseSegment':
- case 'scriptAction':
- case 'viewBasePathSpec':
- case 'viewScriptPathSpec':
- case 'viewScriptPathNoControllerSpec':
- case 'viewSuffix':
- $property = '_' . $key;
- $this->{$property} = (string) $value;
- break;
- default:
- break;
- }
- }
-
- return $this;
- }
-
- /**
- * Initialize the view object
- *
- * $options may contain the following keys:
- * - neverRender - flag dis/enabling postDispatch() autorender (affects all subsequent calls)
- * - noController - flag indicating whether or not to look for view scripts in subdirectories named after the controller
- * - noRender - flag indicating whether or not to autorender postDispatch()
- * - responseSegment - which named response segment to render a view script to
- * - scriptAction - what action script to render
- * - viewBasePathSpec - specification to use for determining view base path
- * - viewScriptPathSpec - specification to use for determining view script paths
- * - viewScriptPathNoControllerSpec - specification to use for determining view script paths when noController flag is set
- * - viewSuffix - what view script filename suffix to use
- *
- * @param string $path
- * @param string $prefix
- * @param array $options
- * @throws Zend_Controller_Action_Exception
- * @return void
- */
- public function initView($path = null, $prefix = null, array $options = array())
- {
- if (null === $this->view) {
- $this->setView(new Zend_View());
- }
-
- // Reset some flags every time
- $options['noController'] = (isset($options['noController'])) ? $options['noController'] : false;
- $options['noRender'] = (isset($options['noRender'])) ? $options['noRender'] : false;
- $this->_scriptAction = null;
- $this->_responseSegment = null;
-
- // Set options first; may be used to determine other initializations
- $this->_setOptions($options);
-
- // Get base view path
- if (empty($path)) {
- $path = $this->_getBasePath();
- if (empty($path)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('ViewRenderer initialization failed: retrieved view base path is empty');
- }
- }
-
- if (null === $prefix) {
- $prefix = $this->_generateDefaultPrefix();
- }
-
- // Determine if this path has already been registered
- $currentPaths = $this->view->getScriptPaths();
- $path = str_replace(array('/', '\\'), '/', $path);
- $pathExists = false;
- foreach ($currentPaths as $tmpPath) {
- $tmpPath = str_replace(array('/', '\\'), '/', $tmpPath);
- if (strstr($tmpPath, $path)) {
- $pathExists = true;
- break;
- }
- }
- if (!$pathExists) {
- $this->view->addBasePath($path, $prefix);
- }
-
- // Register view with action controller (unless already registered)
- if ((null !== $this->_actionController) && (null === $this->_actionController->view)) {
- $this->_actionController->view = $this->view;
- $this->_actionController->viewSuffix = $this->_viewSuffix;
- }
- }
-
- /**
- * init - initialize view
- *
- * @return void
- */
- public function init()
- {
- if ($this->getFrontController()->getParam('noViewRenderer')) {
- return;
- }
-
- $this->initView();
- }
-
- /**
- * Set view basePath specification
- *
- * Specification can contain one or more of the following:
- * - :moduleDir - current module directory
- * - :controller - name of current controller in the request
- * - :action - name of current action in the request
- * - :module - name of current module in the request
- *
- * @param string $path
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewBasePathSpec($path)
- {
- $this->_viewBasePathSpec = (string) $path;
- return $this;
- }
-
- /**
- * Retrieve the current view basePath specification string
- *
- * @return string
- */
- public function getViewBasePathSpec()
- {
- return $this->_viewBasePathSpec;
- }
-
- /**
- * Set view script path specification
- *
- * Specification can contain one or more of the following:
- * - :moduleDir - current module directory
- * - :controller - name of current controller in the request
- * - :action - name of current action in the request
- * - :module - name of current module in the request
- *
- * @param string $path
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewScriptPathSpec($path)
- {
- $this->_viewScriptPathSpec = (string) $path;
- return $this;
- }
-
- /**
- * Retrieve the current view script path specification string
- *
- * @return string
- */
- public function getViewScriptPathSpec()
- {
- return $this->_viewScriptPathSpec;
- }
-
- /**
- * Set view script path specification (no controller variant)
- *
- * Specification can contain one or more of the following:
- * - :moduleDir - current module directory
- * - :controller - name of current controller in the request
- * - :action - name of current action in the request
- * - :module - name of current module in the request
- *
- * :controller will likely be ignored in this variant.
- *
- * @param string $path
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewScriptPathNoControllerSpec($path)
- {
- $this->_viewScriptPathNoControllerSpec = (string) $path;
- return $this;
- }
-
- /**
- * Retrieve the current view script path specification string (no controller variant)
- *
- * @return string
- */
- public function getViewScriptPathNoControllerSpec()
- {
- return $this->_viewScriptPathNoControllerSpec;
- }
-
- /**
- * Get a view script based on an action and/or other variables
- *
- * Uses values found in current request if no values passed in $vars.
- *
- * If {@link $_noController} is set, uses {@link $_viewScriptPathNoControllerSpec};
- * otherwise, uses {@link $_viewScriptPathSpec}.
- *
- * @param string $action
- * @param array $vars
- * @return string
- */
- public function getViewScript($action = null, array $vars = array())
- {
- $request = $this->getRequest();
- if ((null === $action) && (!isset($vars['action']))) {
- $action = $this->getScriptAction();
- if (null === $action) {
- $action = $request->getActionName();
- }
- $vars['action'] = $action;
- } elseif (null !== $action) {
- $vars['action'] = $action;
- }
-
- $replacePattern = array('/[^a-z0-9]+$/i', '/^[^a-z0-9]+/i');
- $vars['action'] = preg_replace($replacePattern, '', $vars['action']);
-
- $inflector = $this->getInflector();
- if ($this->getNoController() || $this->getNeverController()) {
- $this->_setInflectorTarget($this->getViewScriptPathNoControllerSpec());
- } else {
- $this->_setInflectorTarget($this->getViewScriptPathSpec());
- }
- return $this->_translateSpec($vars);
- }
-
- /**
- * Set the neverRender flag (i.e., globally dis/enable autorendering)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNeverRender($flag = true)
- {
- $this->_neverRender = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve neverRender flag value
- *
- * @return boolean
- */
- public function getNeverRender()
- {
- return $this->_neverRender;
- }
-
- /**
- * Set the noRender flag (i.e., whether or not to autorender)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNoRender($flag = true)
- {
- $this->_noRender = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve noRender flag value
- *
- * @return boolean
- */
- public function getNoRender()
- {
- return $this->_noRender;
- }
-
- /**
- * Set the view script to use
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setScriptAction($name)
- {
- $this->_scriptAction = (string) $name;
- return $this;
- }
-
- /**
- * Retrieve view script name
- *
- * @return string
- */
- public function getScriptAction()
- {
- return $this->_scriptAction;
- }
-
- /**
- * Set the response segment name
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setResponseSegment($name)
- {
- if (null === $name) {
- $this->_responseSegment = null;
- } else {
- $this->_responseSegment = (string) $name;
- }
-
- return $this;
- }
-
- /**
- * Retrieve named response segment name
- *
- * @return string
- */
- public function getResponseSegment()
- {
- return $this->_responseSegment;
- }
-
- /**
- * Set the noController flag (i.e., whether or not to render into controller subdirectories)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNoController($flag = true)
- {
- $this->_noController = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve noController flag value
- *
- * @return boolean
- */
- public function getNoController()
- {
- return $this->_noController;
- }
-
- /**
- * Set the neverController flag (i.e., whether or not to render into controller subdirectories)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNeverController($flag = true)
- {
- $this->_neverController = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve neverController flag value
- *
- * @return boolean
- */
- public function getNeverController()
- {
- return $this->_neverController;
- }
-
- /**
- * Set view script suffix
- *
- * @param string $suffix
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewSuffix($suffix)
- {
- $this->_viewSuffix = (string) $suffix;
- return $this;
- }
-
- /**
- * Get view script suffix
- *
- * @return string
- */
- public function getViewSuffix()
- {
- return $this->_viewSuffix;
- }
-
- /**
- * Set options for rendering a view script
- *
- * @param string $action View script to render
- * @param string $name Response named segment to render to
- * @param boolean $noController Whether or not to render within a subdirectory named after the controller
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setRender($action = null, $name = null, $noController = null)
- {
- if (null !== $action) {
- $this->setScriptAction($action);
- }
-
- if (null !== $name) {
- $this->setResponseSegment($name);
- }
-
- if (null !== $noController) {
- $this->setNoController($noController);
- }
-
- return $this;
- }
-
- /**
- * Inflect based on provided vars
- *
- * Allowed variables are:
- * - :moduleDir - current module directory
- * - :module - current module name
- * - :controller - current controller name
- * - :action - current action name
- * - :suffix - view script file suffix
- *
- * @param array $vars
- * @return string
- */
- protected function _translateSpec(array $vars = array())
- {
- $inflector = $this->getInflector();
- $request = $this->getRequest();
- $dispatcher = $this->getFrontController()->getDispatcher();
-
- // Format module name
- $module = $dispatcher->formatModuleName($request->getModuleName());
-
- // Format controller name
- require_once 'Zend/Filter/Word/CamelCaseToDash.php';
- $filter = new Zend_Filter_Word_CamelCaseToDash();
- $controller = $filter->filter($request->getControllerName());
- $controller = $dispatcher->formatControllerName($controller);
- if ('Controller' == substr($controller, -10)) {
- $controller = substr($controller, 0, -10);
- }
-
- // Format action name
- $action = $dispatcher->formatActionName($request->getActionName());
-
- $params = compact('module', 'controller', 'action');
- foreach ($vars as $key => $value) {
- switch ($key) {
- case 'module':
- case 'controller':
- case 'action':
- case 'moduleDir':
- case 'suffix':
- $params[$key] = (string) $value;
- break;
- default:
- break;
- }
- }
-
- if (isset($params['suffix'])) {
- $origSuffix = $this->getViewSuffix();
- $this->setViewSuffix($params['suffix']);
- }
- if (isset($params['moduleDir'])) {
- $origModuleDir = $this->_getModuleDir();
- $this->_setModuleDir($params['moduleDir']);
- }
-
- $filtered = $inflector->filter($params);
-
- if (isset($params['suffix'])) {
- $this->setViewSuffix($origSuffix);
- }
- if (isset($params['moduleDir'])) {
- $this->_setModuleDir($origModuleDir);
- }
-
- return $filtered;
- }
-
- /**
- * Render a view script (optionally to a named response segment)
- *
- * Sets the noRender flag to true when called.
- *
- * @param string $script
- * @param string $name
- * @return void
- */
- public function renderScript($script, $name = null)
- {
- if (null === $name) {
- $name = $this->getResponseSegment();
- }
-
- $this->getResponse()->appendBody(
- $this->view->render($script),
- $name
- );
-
- $this->setNoRender();
- }
-
- /**
- * Render a view based on path specifications
- *
- * Renders a view based on the view script path specifications.
- *
- * @param string $action
- * @param string $name
- * @param boolean $noController
- * @return void
- */
- public function render($action = null, $name = null, $noController = null)
- {
- $this->setRender($action, $name, $noController);
- $path = $this->getViewScript();
- $this->renderScript($path, $name);
- }
-
- /**
- * Render a script based on specification variables
- *
- * Pass an action, and one or more specification variables (view script suffix)
- * to determine the view script path, and render that script.
- *
- * @param string $action
- * @param array $vars
- * @param string $name
- * @return void
- */
- public function renderBySpec($action = null, array $vars = array(), $name = null)
- {
- if (null !== $name) {
- $this->setResponseSegment($name);
- }
-
- $path = $this->getViewScript($action, $vars);
-
- $this->renderScript($path);
- }
-
- /**
- * postDispatch - auto render a view
- *
- * Only autorenders if:
- * - _noRender is false
- * - action controller is present
- * - request has not been re-dispatched (i.e., _forward() has not been called)
- * - response is not a redirect
- *
- * @return void
- */
- public function postDispatch()
- {
- if ($this->_shouldRender()) {
- $this->render();
- }
- }
-
- /**
- * Should the ViewRenderer render a view script?
- *
- * @return boolean
- */
- protected function _shouldRender()
- {
- return (!$this->getFrontController()->getParam('noViewRenderer')
- && !$this->_neverRender
- && !$this->_noRender
- && (null !== $this->_actionController)
- && $this->getRequest()->isDispatched()
- && !$this->getResponse()->isRedirect()
- );
- }
-
- /**
- * Use this helper as a method; proxies to setRender()
- *
- * @param string $action
- * @param string $name
- * @param boolean $noController
- * @return void
- */
- public function direct($action = null, $name = null, $noController = null)
- {
- $this->setRender($action, $name, $noController);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/HelperBroker.php b/lib/zend/Zend/Controller/Action/HelperBroker.php
deleted file mode 100644
index f911c7035e695..0000000000000
--- a/lib/zend/Zend/Controller/Action/HelperBroker.php
+++ /dev/null
@@ -1,381 +0,0 @@
- 'Zend/Controller/Action/Helper/',
- ));
- }
- return self::$_pluginLoader;
- }
-
- /**
- * addPrefix() - Add repository of helpers by prefix
- *
- * @param string $prefix
- */
- static public function addPrefix($prefix)
- {
- $prefix = rtrim($prefix, '_');
- $path = str_replace('_', DIRECTORY_SEPARATOR, $prefix);
- self::getPluginLoader()->addPrefixPath($prefix, $path);
- }
-
- /**
- * addPath() - Add path to repositories where Action_Helpers could be found.
- *
- * @param string $path
- * @param string $prefix Optional; defaults to 'Zend_Controller_Action_Helper'
- * @return void
- */
- static public function addPath($path, $prefix = 'Zend_Controller_Action_Helper')
- {
- self::getPluginLoader()->addPrefixPath($prefix, $path);
- }
-
- /**
- * addHelper() - Add helper objects
- *
- * @param Zend_Controller_Action_Helper_Abstract $helper
- * @return void
- */
- static public function addHelper(Zend_Controller_Action_Helper_Abstract $helper)
- {
- self::getStack()->push($helper);
- return;
- }
-
- /**
- * resetHelpers()
- *
- * @return void
- */
- static public function resetHelpers()
- {
- self::$_stack = null;
- return;
- }
-
- /**
- * Retrieve or initialize a helper statically
- *
- * Retrieves a helper object statically, loading on-demand if the helper
- * does not already exist in the stack. Always returns a helper, unless
- * the helper class cannot be found.
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public static function getStaticHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
-
- if (!isset($stack->{$name})) {
- self::_loadHelper($name);
- }
-
- return $stack->{$name};
- }
-
- /**
- * getExistingHelper() - get helper by name
- *
- * Static method to retrieve helper object. Only retrieves helpers already
- * initialized with the broker (either via addHelper() or on-demand loading
- * via getHelper()).
- *
- * Throws an exception if the referenced helper does not exist in the
- * stack; use {@link hasHelper()} to check if the helper is registered
- * prior to retrieving it.
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- * @throws Zend_Controller_Action_Exception
- */
- public static function getExistingHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
-
- if (!isset($stack->{$name})) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Action helper "' . $name . '" has not been registered with the helper broker');
- }
-
- return $stack->{$name};
- }
-
- /**
- * Return all registered helpers as helper => object pairs
- *
- * @return array
- */
- public static function getExistingHelpers()
- {
- return self::getStack()->getHelpersByName();
- }
-
- /**
- * Is a particular helper loaded in the broker?
- *
- * @param string $name
- * @return boolean
- */
- public static function hasHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- return isset(self::getStack()->{$name});
- }
-
- /**
- * Remove a particular helper from the broker
- *
- * @param string $name
- * @return boolean
- */
- public static function removeHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
- if (isset($stack->{$name})) {
- unset($stack->{$name});
- }
-
- return false;
- }
-
- /**
- * Lazy load the priority stack and return it
- *
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public static function getStack()
- {
- if (self::$_stack == null) {
- self::$_stack = new Zend_Controller_Action_HelperBroker_PriorityStack();
- }
-
- return self::$_stack;
- }
-
- /**
- * Constructor
- *
- * @param Zend_Controller_Action $actionController
- * @return void
- */
- public function __construct(Zend_Controller_Action $actionController)
- {
- $this->_actionController = $actionController;
- foreach (self::getStack() as $helper) {
- $helper->setActionController($actionController);
- $helper->init();
- }
- }
-
- /**
- * notifyPreDispatch() - called by action controller dispatch method
- *
- * @return void
- */
- public function notifyPreDispatch()
- {
- foreach (self::getStack() as $helper) {
- $helper->preDispatch();
- }
- }
-
- /**
- * notifyPostDispatch() - called by action controller dispatch method
- *
- * @return void
- */
- public function notifyPostDispatch()
- {
- foreach (self::getStack() as $helper) {
- $helper->postDispatch();
- }
- }
-
- /**
- * getHelper() - get helper by name
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function getHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
-
- if (!isset($stack->{$name})) {
- self::_loadHelper($name);
- }
-
- $helper = $stack->{$name};
-
- $initialize = false;
- if (null === ($actionController = $helper->getActionController())) {
- $initialize = true;
- } elseif ($actionController !== $this->_actionController) {
- $initialize = true;
- }
-
- if ($initialize) {
- $helper->setActionController($this->_actionController)
- ->init();
- }
-
- return $helper;
- }
-
- /**
- * Method overloading
- *
- * @param string $method
- * @param array $args
- * @return mixed
- * @throws Zend_Controller_Action_Exception if helper does not have a direct() method
- */
- public function __call($method, $args)
- {
- $helper = $this->getHelper($method);
- if (!method_exists($helper, 'direct')) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Helper "' . $method . '" does not support overloading via direct()');
- }
- return call_user_func_array(array($helper, 'direct'), $args);
- }
-
- /**
- * Retrieve helper by name as object property
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function __get($name)
- {
- return $this->getHelper($name);
- }
-
- /**
- * Normalize helper name for lookups
- *
- * @param string $name
- * @return string
- */
- protected static function _normalizeHelperName($name)
- {
- if (strpos($name, '_') !== false) {
- $name = str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
- }
-
- return ucfirst($name);
- }
-
- /**
- * Load a helper
- *
- * @param string $name
- * @return void
- */
- protected static function _loadHelper($name)
- {
- try {
- $class = self::getPluginLoader()->load($name);
- } catch (Zend_Loader_PluginLoader_Exception $e) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Action Helper by name ' . $name . ' not found', 0, $e);
- }
-
- $helper = new $class();
-
- if (!$helper instanceof Zend_Controller_Action_Helper_Abstract) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Helper name ' . $name . ' -> class ' . $class . ' is not of type Zend_Controller_Action_Helper_Abstract');
- }
-
- self::getStack()->push($helper);
- }
-}
diff --git a/lib/zend/Zend/Controller/Action/HelperBroker/PriorityStack.php b/lib/zend/Zend/Controller/Action/HelperBroker/PriorityStack.php
deleted file mode 100644
index d510b74ee5845..0000000000000
--- a/lib/zend/Zend/Controller/Action/HelperBroker/PriorityStack.php
+++ /dev/null
@@ -1,280 +0,0 @@
-_helpersByNameRef)) {
- return false;
- }
-
- return $this->_helpersByNameRef[$helperName];
- }
-
- /**
- * Magic property overloading for returning if helper is set by name
- *
- * @param string $helperName The helper name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function __isset($helperName)
- {
- return array_key_exists($helperName, $this->_helpersByNameRef);
- }
-
- /**
- * Magic property overloading for unsetting if helper is exists by name
- *
- * @param string $helperName The helper name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function __unset($helperName)
- {
- return $this->offsetUnset($helperName);
- }
-
- /**
- * push helper onto the stack
- *
- * @param Zend_Controller_Action_Helper_Abstract $helper
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function push(Zend_Controller_Action_Helper_Abstract $helper)
- {
- $this->offsetSet($this->getNextFreeHigherPriority(), $helper);
- return $this;
- }
-
- /**
- * Return something iterable
- *
- * @return array
- */
- public function getIterator()
- {
- return new ArrayObject($this->_helpersByPriority);
- }
-
- /**
- * offsetExists()
- *
- * @param int|string $priorityOrHelperName
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetExists($priorityOrHelperName)
- {
- if (is_string($priorityOrHelperName)) {
- return array_key_exists($priorityOrHelperName, $this->_helpersByNameRef);
- } else {
- return array_key_exists($priorityOrHelperName, $this->_helpersByPriority);
- }
- }
-
- /**
- * offsetGet()
- *
- * @param int|string $priorityOrHelperName
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetGet($priorityOrHelperName)
- {
- if (!$this->offsetExists($priorityOrHelperName)) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('A helper with priority ' . $priorityOrHelperName . ' does not exist.');
- }
-
- if (is_string($priorityOrHelperName)) {
- return $this->_helpersByNameRef[$priorityOrHelperName];
- } else {
- return $this->_helpersByPriority[$priorityOrHelperName];
- }
- }
-
- /**
- * offsetSet()
- *
- * @param int $priority
- * @param Zend_Controller_Action_Helper_Abstract $helper
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetSet($priority, $helper)
- {
- $priority = (int) $priority;
-
- if (!$helper instanceof Zend_Controller_Action_Helper_Abstract) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('$helper must extend Zend_Controller_Action_Helper_Abstract.');
- }
-
- if (array_key_exists($helper->getName(), $this->_helpersByNameRef)) {
- // remove any object with the same name to retain BC compailitbility
- // @todo At ZF 2.0 time throw an exception here.
- $this->offsetUnset($helper->getName());
- }
-
- if (array_key_exists($priority, $this->_helpersByPriority)) {
- $priority = $this->getNextFreeHigherPriority($priority); // ensures LIFO
- trigger_error("A helper with the same priority already exists, reassigning to $priority", E_USER_WARNING);
- }
-
- $this->_helpersByPriority[$priority] = $helper;
- $this->_helpersByNameRef[$helper->getName()] = $helper;
-
- if ($priority == ($nextFreeDefault = $this->getNextFreeHigherPriority($this->_nextDefaultPriority))) {
- $this->_nextDefaultPriority = $nextFreeDefault;
- }
-
- krsort($this->_helpersByPriority); // always make sure priority and LIFO are both enforced
- return $this;
- }
-
- /**
- * offsetUnset()
- *
- * @param int|string $priorityOrHelperName Priority integer or the helper name
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetUnset($priorityOrHelperName)
- {
- if (!$this->offsetExists($priorityOrHelperName)) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('A helper with priority or name ' . $priorityOrHelperName . ' does not exist.');
- }
-
- if (is_string($priorityOrHelperName)) {
- $helperName = $priorityOrHelperName;
- $helper = $this->_helpersByNameRef[$helperName];
- $priority = array_search($helper, $this->_helpersByPriority, true);
- } else {
- $priority = $priorityOrHelperName;
- $helperName = $this->_helpersByPriority[$priorityOrHelperName]->getName();
- }
-
- unset($this->_helpersByNameRef[$helperName]);
- unset($this->_helpersByPriority[$priority]);
- return $this;
- }
-
- /**
- * return the count of helpers
- *
- * @return int
- */
- public function count()
- {
- return count($this->_helpersByPriority);
- }
-
- /**
- * Find the next free higher priority. If an index is given, it will
- * find the next free highest priority after it.
- *
- * @param int $indexPriority OPTIONAL
- * @return int
- */
- public function getNextFreeHigherPriority($indexPriority = null)
- {
- if ($indexPriority == null) {
- $indexPriority = $this->_nextDefaultPriority;
- }
-
- $priorities = array_keys($this->_helpersByPriority);
-
- while (in_array($indexPriority, $priorities)) {
- $indexPriority++;
- }
-
- return $indexPriority;
- }
-
- /**
- * Find the next free lower priority. If an index is given, it will
- * find the next free lower priority before it.
- *
- * @param int $indexPriority
- * @return int
- */
- public function getNextFreeLowerPriority($indexPriority = null)
- {
- if ($indexPriority == null) {
- $indexPriority = $this->_nextDefaultPriority;
- }
-
- $priorities = array_keys($this->_helpersByPriority);
-
- while (in_array($indexPriority, $priorities)) {
- $indexPriority--;
- }
-
- return $indexPriority;
- }
-
- /**
- * return the highest priority
- *
- * @return int
- */
- public function getHighestPriority()
- {
- return max(array_keys($this->_helpersByPriority));
- }
-
- /**
- * return the lowest priority
- *
- * @return int
- */
- public function getLowestPriority()
- {
- return min(array_keys($this->_helpersByPriority));
- }
-
- /**
- * return the helpers referenced by name
- *
- * @return array
- */
- public function getHelpersByName()
- {
- return $this->_helpersByNameRef;
- }
-
-}
diff --git a/lib/zend/Zend/Controller/Action/Interface.php b/lib/zend/Zend/Controller/Action/Interface.php
deleted file mode 100644
index db354637a105d..0000000000000
--- a/lib/zend/Zend/Controller/Action/Interface.php
+++ /dev/null
@@ -1,69 +0,0 @@
-setParams($params);
- }
-
- /**
- * Formats a string into a controller name. This is used to take a raw
- * controller name, such as one stored inside a Zend_Controller_Request_Abstract
- * object, and reformat it to a proper class name that a class extending
- * Zend_Controller_Action would use.
- *
- * @param string $unformatted
- * @return string
- */
- public function formatControllerName($unformatted)
- {
- return ucfirst($this->_formatName($unformatted)) . 'Controller';
- }
-
- /**
- * Formats a string into an action name. This is used to take a raw
- * action name, such as one that would be stored inside a Zend_Controller_Request_Abstract
- * object, and reformat into a proper method name that would be found
- * inside a class extending Zend_Controller_Action.
- *
- * @param string $unformatted
- * @return string
- */
- public function formatActionName($unformatted)
- {
- $formatted = $this->_formatName($unformatted, true);
- return strtolower(substr($formatted, 0, 1)) . substr($formatted, 1) . 'Action';
- }
-
- /**
- * Verify delimiter
- *
- * Verify a delimiter to use in controllers or actions. May be a single
- * string or an array of strings.
- *
- * @param string|array $spec
- * @return array
- * @throws Zend_Controller_Dispatcher_Exception with invalid delimiters
- */
- public function _verifyDelimiter($spec)
- {
- if (is_string($spec)) {
- return (array) $spec;
- } elseif (is_array($spec)) {
- $allStrings = true;
- foreach ($spec as $delim) {
- if (!is_string($delim)) {
- $allStrings = false;
- break;
- }
- }
-
- if (!$allStrings) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Word delimiter array must contain only strings');
- }
-
- return $spec;
- }
-
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid word delimiter');
- }
-
- /**
- * Retrieve the word delimiter character(s) used in
- * controller or action names
- *
- * @return array
- */
- public function getWordDelimiter()
- {
- return $this->_wordDelimiter;
- }
-
- /**
- * Set word delimiter
- *
- * Set the word delimiter to use in controllers and actions. May be a
- * single string or an array of strings.
- *
- * @param string|array $spec
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setWordDelimiter($spec)
- {
- $spec = $this->_verifyDelimiter($spec);
- $this->_wordDelimiter = $spec;
-
- return $this;
- }
-
- /**
- * Retrieve the path delimiter character(s) used in
- * controller names
- *
- * @return array
- */
- public function getPathDelimiter()
- {
- return $this->_pathDelimiter;
- }
-
- /**
- * Set path delimiter
- *
- * Set the path delimiter to use in controllers. May be a single string or
- * an array of strings.
- *
- * @param string $spec
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setPathDelimiter($spec)
- {
- if (!is_string($spec)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid path delimiter');
- }
- $this->_pathDelimiter = $spec;
-
- return $this;
- }
-
- /**
- * Formats a string from a URI into a PHP-friendly name.
- *
- * By default, replaces words separated by the word separator character(s)
- * with camelCaps. If $isAction is false, it also preserves replaces words
- * separated by the path separation character with an underscore, making
- * the following word Title cased. All non-alphanumeric characters are
- * removed.
- *
- * @param string $unformatted
- * @param boolean $isAction Defaults to false
- * @return string
- */
- protected function _formatName($unformatted, $isAction = false)
- {
- // preserve directories
- if (!$isAction) {
- $segments = explode($this->getPathDelimiter(), $unformatted);
- } else {
- $segments = (array) $unformatted;
- }
-
- foreach ($segments as $key => $segment) {
- $segment = str_replace($this->getWordDelimiter(), ' ', strtolower($segment));
- $segment = preg_replace('/[^a-z0-9 ]/', '', $segment);
- $segments[$key] = str_replace(' ', '', ucwords($segment));
- }
-
- return implode('_', $segments);
- }
-
- /**
- * Retrieve front controller instance
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- if (null === $this->_frontController) {
- require_once 'Zend/Controller/Front.php';
- $this->_frontController = Zend_Controller_Front::getInstance();
- }
-
- return $this->_frontController;
- }
-
- /**
- * Set front controller instance
- *
- * @param Zend_Controller_Front $controller
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setFrontController(Zend_Controller_Front $controller)
- {
- $this->_frontController = $controller;
- return $this;
- }
-
- /**
- * Add or modify a parameter to use when instantiating an action controller
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setParam($name, $value)
- {
- $name = (string) $name;
- $this->_invokeParams[$name] = $value;
- return $this;
- }
-
- /**
- * Set parameters to pass to action controller constructors
- *
- * @param array $params
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setParams(array $params)
- {
- $this->_invokeParams = array_merge($this->_invokeParams, $params);
- return $this;
- }
-
- /**
- * Retrieve a single parameter from the controller parameter stack
- *
- * @param string $name
- * @return mixed
- */
- public function getParam($name)
- {
- if(isset($this->_invokeParams[$name])) {
- return $this->_invokeParams[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve action controller instantiation parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_invokeParams;
- }
-
- /**
- * Clear the controller parameter stack
- *
- * By default, clears all parameters. If a parameter name is given, clears
- * only that parameter; if an array of parameter names is provided, clears
- * each.
- *
- * @param null|string|array single key or array of keys for params to clear
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function clearParams($name = null)
- {
- if (null === $name) {
- $this->_invokeParams = array();
- } elseif (is_string($name) && isset($this->_invokeParams[$name])) {
- unset($this->_invokeParams[$name]);
- } elseif (is_array($name)) {
- foreach ($name as $key) {
- if (is_string($key) && isset($this->_invokeParams[$key])) {
- unset($this->_invokeParams[$key]);
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Set response object to pass to action controllers
- *
- * @param Zend_Controller_Response_Abstract|null $response
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setResponse(Zend_Controller_Response_Abstract $response = null)
- {
- $this->_response = $response;
- return $this;
- }
-
- /**
- * Return the registered response object
- *
- * @return Zend_Controller_Response_Abstract|null
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Set the default controller (minus any formatting)
- *
- * @param string $controller
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setDefaultControllerName($controller)
- {
- $this->_defaultController = (string) $controller;
- return $this;
- }
-
- /**
- * Retrieve the default controller name (minus formatting)
- *
- * @return string
- */
- public function getDefaultControllerName()
- {
- return $this->_defaultController;
- }
-
- /**
- * Set the default action (minus any formatting)
- *
- * @param string $action
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setDefaultAction($action)
- {
- $this->_defaultAction = (string) $action;
- return $this;
- }
-
- /**
- * Retrieve the default action name (minus formatting)
- *
- * @return string
- */
- public function getDefaultAction()
- {
- return $this->_defaultAction;
- }
-
- /**
- * Set the default module
- *
- * @param string $module
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setDefaultModule($module)
- {
- $this->_defaultModule = (string) $module;
- return $this;
- }
-
- /**
- * Retrieve the default module
- *
- * @return string
- */
- public function getDefaultModule()
- {
- return $this->_defaultModule;
- }
-}
diff --git a/lib/zend/Zend/Controller/Dispatcher/Exception.php b/lib/zend/Zend/Controller/Dispatcher/Exception.php
deleted file mode 100644
index 4240444966391..0000000000000
--- a/lib/zend/Zend/Controller/Dispatcher/Exception.php
+++ /dev/null
@@ -1,37 +0,0 @@
-_curModule = $this->getDefaultModule();
- }
-
- /**
- * Add a single path to the controller directory stack
- *
- * @param string $path
- * @param string $module
- * @return Zend_Controller_Dispatcher_Standard
- */
- public function addControllerDirectory($path, $module = null)
- {
- if (null === $module) {
- $module = $this->_defaultModule;
- }
-
- $module = (string) $module;
- $path = rtrim((string) $path, '/\\');
-
- $this->_controllerDirectory[$module] = $path;
- return $this;
- }
-
- /**
- * Set controller directory
- *
- * @param array|string $directory
- * @return Zend_Controller_Dispatcher_Standard
- */
- public function setControllerDirectory($directory, $module = null)
- {
- $this->_controllerDirectory = array();
-
- if (is_string($directory)) {
- $this->addControllerDirectory($directory, $module);
- } elseif (is_array($directory)) {
- foreach ((array) $directory as $module => $path) {
- $this->addControllerDirectory($path, $module);
- }
- } else {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Controller directory spec must be either a string or an array');
- }
-
- return $this;
- }
-
- /**
- * Return the currently set directories for Zend_Controller_Action class
- * lookup
- *
- * If a module is specified, returns just that directory.
- *
- * @param string $module Module name
- * @return array|string Returns array of all directories by default, single
- * module directory if module argument provided
- */
- public function getControllerDirectory($module = null)
- {
- if (null === $module) {
- return $this->_controllerDirectory;
- }
-
- $module = (string) $module;
- if (array_key_exists($module, $this->_controllerDirectory)) {
- return $this->_controllerDirectory[$module];
- }
-
- return null;
- }
-
- /**
- * Remove a controller directory by module name
- *
- * @param string $module
- * @return bool
- */
- public function removeControllerDirectory($module)
- {
- $module = (string) $module;
- if (array_key_exists($module, $this->_controllerDirectory)) {
- unset($this->_controllerDirectory[$module]);
- return true;
- }
- return false;
- }
-
- /**
- * Format the module name.
- *
- * @param string $unformatted
- * @return string
- */
- public function formatModuleName($unformatted)
- {
- if (($this->_defaultModule == $unformatted) && !$this->getParam('prefixDefaultModule')) {
- return $unformatted;
- }
-
- return ucfirst($this->_formatName($unformatted));
- }
-
- /**
- * Format action class name
- *
- * @param string $moduleName Name of the current module
- * @param string $className Name of the action class
- * @return string Formatted class name
- */
- public function formatClassName($moduleName, $className)
- {
- return $this->formatModuleName($moduleName) . '_' . $className;
- }
-
- /**
- * Convert a class name to a filename
- *
- * @param string $class
- * @return string
- */
- public function classToFilename($class)
- {
- return str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
- }
-
- /**
- * Returns TRUE if the Zend_Controller_Request_Abstract object can be
- * dispatched to a controller.
- *
- * Use this method wisely. By default, the dispatcher will fall back to the
- * default controller (either in the module specified or the global default)
- * if a given controller does not exist. This method returning false does
- * not necessarily indicate the dispatcher will not still dispatch the call.
- *
- * @param Zend_Controller_Request_Abstract $action
- * @return boolean
- */
- public function isDispatchable(Zend_Controller_Request_Abstract $request)
- {
- $className = $this->getControllerClass($request);
- if (!$className) {
- return false;
- }
-
- $finalClass = $className;
- if (($this->_defaultModule != $this->_curModule)
- || $this->getParam('prefixDefaultModule'))
- {
- $finalClass = $this->formatClassName($this->_curModule, $className);
- }
- if (class_exists($finalClass, false)) {
- return true;
- }
-
- $fileSpec = $this->classToFilename($className);
- $dispatchDir = $this->getDispatchDirectory();
- $test = $dispatchDir . DIRECTORY_SEPARATOR . $fileSpec;
- return Zend_Loader::isReadable($test);
- }
-
- /**
- * Dispatch to a controller/action
- *
- * By default, if a controller is not dispatchable, dispatch() will throw
- * an exception. If you wish to use the default controller instead, set the
- * param 'useDefaultControllerAlways' via {@link setParam()}.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @param Zend_Controller_Response_Abstract $response
- * @return void
- * @throws Zend_Controller_Dispatcher_Exception
- */
- public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)
- {
- $this->setResponse($response);
-
- /**
- * Get controller class
- */
- if (!$this->isDispatchable($request)) {
- $controller = $request->getControllerName();
- if (!$this->getParam('useDefaultControllerAlways') && !empty($controller)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid controller specified (' . $request->getControllerName() . ')');
- }
-
- $className = $this->getDefaultControllerClass($request);
- } else {
- $className = $this->getControllerClass($request);
- if (!$className) {
- $className = $this->getDefaultControllerClass($request);
- }
- }
-
- /**
- * If we're in a module or prefixDefaultModule is on, we must add the module name
- * prefix to the contents of $className, as getControllerClass does not do that automatically.
- * We must keep a separate variable because modules are not strictly PSR-0: We need the no-module-prefix
- * class name to do the class->file mapping, but the full class name to insantiate the controller
- */
- $moduleClassName = $className;
- if (($this->_defaultModule != $this->_curModule)
- || $this->getParam('prefixDefaultModule'))
- {
- $moduleClassName = $this->formatClassName($this->_curModule, $className);
- }
-
- /**
- * Load the controller class file
- */
- $className = $this->loadClass($className);
-
- /**
- * Instantiate controller with request, response, and invocation
- * arguments; throw exception if it's not an action controller
- */
- $controller = new $moduleClassName($request, $this->getResponse(), $this->getParams());
- if (!($controller instanceof Zend_Controller_Action_Interface) &&
- !($controller instanceof Zend_Controller_Action)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception(
- 'Controller "' . $moduleClassName . '" is not an instance of Zend_Controller_Action_Interface'
- );
- }
-
- /**
- * Retrieve the action name
- */
- $action = $this->getActionMethod($request);
-
- /**
- * Dispatch the method call
- */
- $request->setDispatched(true);
-
- // by default, buffer output
- $disableOb = $this->getParam('disableOutputBuffering');
- $obLevel = ob_get_level();
- if (empty($disableOb)) {
- ob_start();
- }
-
- try {
- $controller->dispatch($action);
- } catch (Exception $e) {
- // Clean output buffer on error
- $curObLevel = ob_get_level();
- if ($curObLevel > $obLevel) {
- do {
- ob_get_clean();
- $curObLevel = ob_get_level();
- } while ($curObLevel > $obLevel);
- }
- throw $e;
- }
-
- if (empty($disableOb)) {
- $content = ob_get_clean();
- $response->appendBody($content);
- }
-
- // Destroy the page controller instance and reflection objects
- $controller = null;
- }
-
- /**
- * Load a controller class
- *
- * Attempts to load the controller class file from
- * {@link getControllerDirectory()}. If the controller belongs to a
- * module, looks for the module prefix to the controller class.
- *
- * @param string $className
- * @return string Class name loaded
- * @throws Zend_Controller_Dispatcher_Exception if class not loaded
- */
- public function loadClass($className)
- {
- $finalClass = $className;
- if (($this->_defaultModule != $this->_curModule)
- || $this->getParam('prefixDefaultModule'))
- {
- $finalClass = $this->formatClassName($this->_curModule, $className);
- }
- if (class_exists($finalClass, false)) {
- return $finalClass;
- }
-
- $dispatchDir = $this->getDispatchDirectory();
- $loadFile = $dispatchDir . DIRECTORY_SEPARATOR . $this->classToFilename($className);
-
- if (Zend_Loader::isReadable($loadFile)) {
- include_once $loadFile;
- } else {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Cannot load controller class "' . $className . '" from file "' . $loadFile . "'");
- }
-
- if (!class_exists($finalClass, false)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid controller class ("' . $finalClass . '")');
- }
-
- return $finalClass;
- }
-
- /**
- * Get controller class name
- *
- * Try request first; if not found, try pulling from request parameter;
- * if still not found, fallback to default
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return string|false Returns class name on success
- */
- public function getControllerClass(Zend_Controller_Request_Abstract $request)
- {
- $controllerName = $request->getControllerName();
- if (empty($controllerName)) {
- if (!$this->getParam('useDefaultControllerAlways')) {
- return false;
- }
- $controllerName = $this->getDefaultControllerName();
- $request->setControllerName($controllerName);
- }
-
- $className = $this->formatControllerName($controllerName);
-
- $controllerDirs = $this->getControllerDirectory();
- $module = $request->getModuleName();
- if ($this->isValidModule($module)) {
- $this->_curModule = $module;
- $this->_curDirectory = $controllerDirs[$module];
- } elseif ($this->isValidModule($this->_defaultModule)) {
- $request->setModuleName($this->_defaultModule);
- $this->_curModule = $this->_defaultModule;
- $this->_curDirectory = $controllerDirs[$this->_defaultModule];
- } else {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('No default module defined for this application');
- }
-
- return $className;
- }
-
- /**
- * Determine if a given module is valid
- *
- * @param string $module
- * @return bool
- */
- public function isValidModule($module)
- {
- if (!is_string($module)) {
- return false;
- }
-
- $module = strtolower($module);
- $controllerDir = $this->getControllerDirectory();
- foreach (array_keys($controllerDir) as $moduleName) {
- if ($module == strtolower($moduleName)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve default controller class
- *
- * Determines whether the default controller to use lies within the
- * requested module, or if the global default should be used.
- *
- * By default, will only use the module default unless that controller does
- * not exist; if this is the case, it falls back to the default controller
- * in the default module.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return string
- */
- public function getDefaultControllerClass(Zend_Controller_Request_Abstract $request)
- {
- $controller = $this->getDefaultControllerName();
- $default = $this->formatControllerName($controller);
- $request->setControllerName($controller)
- ->setActionName(null);
-
- $module = $request->getModuleName();
- $controllerDirs = $this->getControllerDirectory();
- $this->_curModule = $this->_defaultModule;
- $this->_curDirectory = $controllerDirs[$this->_defaultModule];
- if ($this->isValidModule($module)) {
- $found = false;
- if (class_exists($default, false)) {
- $found = true;
- } else {
- $moduleDir = $controllerDirs[$module];
- $fileSpec = $moduleDir . DIRECTORY_SEPARATOR . $this->classToFilename($default);
- if (Zend_Loader::isReadable($fileSpec)) {
- $found = true;
- $this->_curDirectory = $moduleDir;
- }
- }
- if ($found) {
- $request->setModuleName($module);
- $this->_curModule = $this->formatModuleName($module);
- }
- } else {
- $request->setModuleName($this->_defaultModule);
- }
-
- return $default;
- }
-
- /**
- * Return the value of the currently selected dispatch directory (as set by
- * {@link getController()})
- *
- * @return string
- */
- public function getDispatchDirectory()
- {
- return $this->_curDirectory;
- }
-
- /**
- * Determine the action name
- *
- * First attempt to retrieve from request; then from request params
- * using action key; default to default action
- *
- * Returns formatted action name
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return string
- */
- public function getActionMethod(Zend_Controller_Request_Abstract $request)
- {
- $action = $request->getActionName();
- if (empty($action)) {
- $action = $this->getDefaultAction();
- $request->setActionName($action);
- }
-
- return $this->formatActionName($action);
- }
-}
diff --git a/lib/zend/Zend/Controller/Exception.php b/lib/zend/Zend/Controller/Exception.php
deleted file mode 100644
index b36853c425c79..0000000000000
--- a/lib/zend/Zend/Controller/Exception.php
+++ /dev/null
@@ -1,35 +0,0 @@
-_plugins = new Zend_Controller_Plugin_Broker();
- }
-
- /**
- * Enforce singleton; disallow cloning
- *
- * @return void
- */
- private function __clone()
- {
- }
-
- /**
- * Singleton instance
- *
- * @return Zend_Controller_Front
- */
- public static function getInstance()
- {
- if (null === self::$_instance) {
- self::$_instance = new self();
- }
-
- return self::$_instance;
- }
-
- /**
- * Resets all object properties of the singleton instance
- *
- * Primarily used for testing; could be used to chain front controllers.
- *
- * Also resets action helper broker, clearing all registered helpers.
- *
- * @return void
- */
- public function resetInstance()
- {
- $reflection = new ReflectionObject($this);
- foreach ($reflection->getProperties() as $property) {
- $name = $property->getName();
- switch ($name) {
- case '_instance':
- break;
- case '_controllerDir':
- case '_invokeParams':
- $this->{$name} = array();
- break;
- case '_plugins':
- $this->{$name} = new Zend_Controller_Plugin_Broker();
- break;
- case '_throwExceptions':
- case '_returnResponse':
- $this->{$name} = false;
- break;
- case '_moduleControllerDirectoryName':
- $this->{$name} = 'controllers';
- break;
- default:
- $this->{$name} = null;
- break;
- }
- }
- Zend_Controller_Action_HelperBroker::resetHelpers();
- }
-
- /**
- * Convenience feature, calls setControllerDirectory()->setRouter()->dispatch()
- *
- * In PHP 5.1.x, a call to a static method never populates $this -- so run()
- * may actually be called after setting up your front controller.
- *
- * @param string|array $controllerDirectory Path to Zend_Controller_Action
- * controller classes or array of such paths
- * @return void
- * @throws Zend_Controller_Exception if called from an object instance
- */
- public static function run($controllerDirectory)
- {
- self::getInstance()
- ->setControllerDirectory($controllerDirectory)
- ->dispatch();
- }
-
- /**
- * Add a controller directory to the controller directory stack
- *
- * If $args is presented and is a string, uses it for the array key mapping
- * to the directory specified.
- *
- * @param string $directory
- * @param string $module Optional argument; module with which to associate directory. If none provided, assumes 'default'
- * @return Zend_Controller_Front
- * @throws Zend_Controller_Exception if directory not found or readable
- */
- public function addControllerDirectory($directory, $module = null)
- {
- $this->getDispatcher()->addControllerDirectory($directory, $module);
- return $this;
- }
-
- /**
- * Set controller directory
- *
- * Stores controller directory(ies) in dispatcher. May be an array of
- * directories or a string containing a single directory.
- *
- * @param string|array $directory Path to Zend_Controller_Action controller
- * classes or array of such paths
- * @param string $module Optional module name to use with string $directory
- * @return Zend_Controller_Front
- */
- public function setControllerDirectory($directory, $module = null)
- {
- $this->getDispatcher()->setControllerDirectory($directory, $module);
- return $this;
- }
-
- /**
- * Retrieve controller directory
- *
- * Retrieves:
- * - Array of all controller directories if no $name passed
- * - String path if $name passed and exists as a key in controller directory array
- * - null if $name passed but does not exist in controller directory keys
- *
- * @param string $name Default null
- * @return array|string|null
- */
- public function getControllerDirectory($name = null)
- {
- return $this->getDispatcher()->getControllerDirectory($name);
- }
-
- /**
- * Remove a controller directory by module name
- *
- * @param string $module
- * @return bool
- */
- public function removeControllerDirectory($module)
- {
- return $this->getDispatcher()->removeControllerDirectory($module);
- }
-
- /**
- * Specify a directory as containing modules
- *
- * Iterates through the directory, adding any subdirectories as modules;
- * the subdirectory within each module named after {@link $_moduleControllerDirectoryName}
- * will be used as the controller directory path.
- *
- * @param string $path
- * @return Zend_Controller_Front
- */
- public function addModuleDirectory($path)
- {
- try{
- $dir = new DirectoryIterator($path);
- } catch(Exception $e) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception("Directory $path not readable", 0, $e);
- }
- foreach ($dir as $file) {
- if ($file->isDot() || !$file->isDir()) {
- continue;
- }
-
- $module = $file->getFilename();
-
- // Don't use SCCS directories as modules
- if (preg_match('/^[^a-z]/i', $module) || ('CVS' == $module)) {
- continue;
- }
-
- $moduleDir = $file->getPathname() . DIRECTORY_SEPARATOR . $this->getModuleControllerDirectoryName();
- $this->addControllerDirectory($moduleDir, $module);
- }
-
- return $this;
- }
-
- /**
- * Return the path to a module directory (but not the controllers directory within)
- *
- * @param string $module
- * @return string|null
- */
- public function getModuleDirectory($module = null)
- {
- if (null === $module) {
- $request = $this->getRequest();
- if (null !== $request) {
- $module = $this->getRequest()->getModuleName();
- }
- if (empty($module)) {
- $module = $this->getDispatcher()->getDefaultModule();
- }
- }
-
- $controllerDir = $this->getControllerDirectory($module);
-
- if ((null === $controllerDir) || !is_string($controllerDir)) {
- return null;
- }
-
- return dirname($controllerDir);
- }
-
- /**
- * Set the directory name within a module containing controllers
- *
- * @param string $name
- * @return Zend_Controller_Front
- */
- public function setModuleControllerDirectoryName($name = 'controllers')
- {
- $this->_moduleControllerDirectoryName = (string) $name;
-
- return $this;
- }
-
- /**
- * Return the directory name within a module containing controllers
- *
- * @return string
- */
- public function getModuleControllerDirectoryName()
- {
- return $this->_moduleControllerDirectoryName;
- }
-
- /**
- * Set the default controller (unformatted string)
- *
- * @param string $controller
- * @return Zend_Controller_Front
- */
- public function setDefaultControllerName($controller)
- {
- $dispatcher = $this->getDispatcher();
- $dispatcher->setDefaultControllerName($controller);
- return $this;
- }
-
- /**
- * Retrieve the default controller (unformatted string)
- *
- * @return string
- */
- public function getDefaultControllerName()
- {
- return $this->getDispatcher()->getDefaultControllerName();
- }
-
- /**
- * Set the default action (unformatted string)
- *
- * @param string $action
- * @return Zend_Controller_Front
- */
- public function setDefaultAction($action)
- {
- $dispatcher = $this->getDispatcher();
- $dispatcher->setDefaultAction($action);
- return $this;
- }
-
- /**
- * Retrieve the default action (unformatted string)
- *
- * @return string
- */
- public function getDefaultAction()
- {
- return $this->getDispatcher()->getDefaultAction();
- }
-
- /**
- * Set the default module name
- *
- * @param string $module
- * @return Zend_Controller_Front
- */
- public function setDefaultModule($module)
- {
- $dispatcher = $this->getDispatcher();
- $dispatcher->setDefaultModule($module);
- return $this;
- }
-
- /**
- * Retrieve the default module
- *
- * @return string
- */
- public function getDefaultModule()
- {
- return $this->getDispatcher()->getDefaultModule();
- }
-
- /**
- * Set request class/object
- *
- * Set the request object. The request holds the request environment.
- *
- * If a class name is provided, it will instantiate it
- *
- * @param string|Zend_Controller_Request_Abstract $request
- * @throws Zend_Controller_Exception if invalid request class
- * @return Zend_Controller_Front
- */
- public function setRequest($request)
- {
- if (is_string($request)) {
- if (!class_exists($request)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($request);
- }
- $request = new $request();
- }
- if (!$request instanceof Zend_Controller_Request_Abstract) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid request class');
- }
-
- $this->_request = $request;
-
- return $this;
- }
-
- /**
- * Return the request object.
- *
- * @return null|Zend_Controller_Request_Abstract
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set router class/object
- *
- * Set the router object. The router is responsible for mapping
- * the request to a controller and action.
- *
- * If a class name is provided, instantiates router with any parameters
- * registered via {@link setParam()} or {@link setParams()}.
- *
- * @param string|Zend_Controller_Router_Interface $router
- * @throws Zend_Controller_Exception if invalid router class
- * @return Zend_Controller_Front
- */
- public function setRouter($router)
- {
- if (is_string($router)) {
- if (!class_exists($router)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($router);
- }
- $router = new $router();
- }
-
- if (!$router instanceof Zend_Controller_Router_Interface) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid router class');
- }
-
- $router->setFrontController($this);
- $this->_router = $router;
-
- return $this;
- }
-
- /**
- * Return the router object.
- *
- * Instantiates a Zend_Controller_Router_Rewrite object if no router currently set.
- *
- * @return Zend_Controller_Router_Interface
- */
- public function getRouter()
- {
- if (null == $this->_router) {
- require_once 'Zend/Controller/Router/Rewrite.php';
- $this->setRouter(new Zend_Controller_Router_Rewrite());
- }
-
- return $this->_router;
- }
-
- /**
- * Set the base URL used for requests
- *
- * Use to set the base URL segment of the REQUEST_URI to use when
- * determining PATH_INFO, etc. Examples:
- * - /admin
- * - /myapp
- * - /subdir/index.php
- *
- * Note that the URL should not include the full URI. Do not use:
- * - http://example.com/admin
- * - http://example.com/myapp
- * - http://example.com/subdir/index.php
- *
- * If a null value is passed, this can be used as well for autodiscovery (default).
- *
- * @param string $base
- * @return Zend_Controller_Front
- * @throws Zend_Controller_Exception for non-string $base
- */
- public function setBaseUrl($base = null)
- {
- if (!is_string($base) && (null !== $base)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Rewrite base must be a string');
- }
-
- $this->_baseUrl = $base;
-
- if ((null !== ($request = $this->getRequest())) && (method_exists($request, 'setBaseUrl'))) {
- $request->setBaseUrl($base);
- }
-
- return $this;
- }
-
- /**
- * Retrieve the currently set base URL
- *
- * @return string
- */
- public function getBaseUrl()
- {
- $request = $this->getRequest();
- if ((null !== $request) && method_exists($request, 'getBaseUrl')) {
- return $request->getBaseUrl();
- }
-
- return $this->_baseUrl;
- }
-
- /**
- * Set the dispatcher object. The dispatcher is responsible for
- * taking a Zend_Controller_Dispatcher_Token object, instantiating the controller, and
- * call the action method of the controller.
- *
- * @param Zend_Controller_Dispatcher_Interface $dispatcher
- * @return Zend_Controller_Front
- */
- public function setDispatcher(Zend_Controller_Dispatcher_Interface $dispatcher)
- {
- $this->_dispatcher = $dispatcher;
- return $this;
- }
-
- /**
- * Return the dispatcher object.
- *
- * @return Zend_Controller_Dispatcher_Interface
- */
- public function getDispatcher()
- {
- /**
- * Instantiate the default dispatcher if one was not set.
- */
- if (!$this->_dispatcher instanceof Zend_Controller_Dispatcher_Interface) {
- require_once 'Zend/Controller/Dispatcher/Standard.php';
- $this->_dispatcher = new Zend_Controller_Dispatcher_Standard();
- }
- return $this->_dispatcher;
- }
-
- /**
- * Set response class/object
- *
- * Set the response object. The response is a container for action
- * responses and headers. Usage is optional.
- *
- * If a class name is provided, instantiates a response object.
- *
- * @param string|Zend_Controller_Response_Abstract $response
- * @throws Zend_Controller_Exception if invalid response class
- * @return Zend_Controller_Front
- */
- public function setResponse($response)
- {
- if (is_string($response)) {
- if (!class_exists($response)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($response);
- }
- $response = new $response();
- }
- if (!$response instanceof Zend_Controller_Response_Abstract) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid response class');
- }
-
- $this->_response = $response;
-
- return $this;
- }
-
- /**
- * Return the response object.
- *
- * @return null|Zend_Controller_Response_Abstract
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Add or modify a parameter to use when instantiating an action controller
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Front
- */
- public function setParam($name, $value)
- {
- $name = (string) $name;
- $this->_invokeParams[$name] = $value;
- return $this;
- }
-
- /**
- * Set parameters to pass to action controller constructors
- *
- * @param array $params
- * @return Zend_Controller_Front
- */
- public function setParams(array $params)
- {
- $this->_invokeParams = array_merge($this->_invokeParams, $params);
- return $this;
- }
-
- /**
- * Retrieve a single parameter from the controller parameter stack
- *
- * @param string $name
- * @return mixed
- */
- public function getParam($name)
- {
- if(isset($this->_invokeParams[$name])) {
- return $this->_invokeParams[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve action controller instantiation parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_invokeParams;
- }
-
- /**
- * Clear the controller parameter stack
- *
- * By default, clears all parameters. If a parameter name is given, clears
- * only that parameter; if an array of parameter names is provided, clears
- * each.
- *
- * @param null|string|array single key or array of keys for params to clear
- * @return Zend_Controller_Front
- */
- public function clearParams($name = null)
- {
- if (null === $name) {
- $this->_invokeParams = array();
- } elseif (is_string($name) && isset($this->_invokeParams[$name])) {
- unset($this->_invokeParams[$name]);
- } elseif (is_array($name)) {
- foreach ($name as $key) {
- if (is_string($key) && isset($this->_invokeParams[$key])) {
- unset($this->_invokeParams[$key]);
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Register a plugin.
- *
- * @param Zend_Controller_Plugin_Abstract $plugin
- * @param int $stackIndex Optional; stack index for plugin
- * @return Zend_Controller_Front
- */
- public function registerPlugin(Zend_Controller_Plugin_Abstract $plugin, $stackIndex = null)
- {
- $this->_plugins->registerPlugin($plugin, $stackIndex);
- return $this;
- }
-
- /**
- * Unregister a plugin.
- *
- * @param string|Zend_Controller_Plugin_Abstract $plugin Plugin class or object to unregister
- * @return Zend_Controller_Front
- */
- public function unregisterPlugin($plugin)
- {
- $this->_plugins->unregisterPlugin($plugin);
- return $this;
- }
-
- /**
- * Is a particular plugin registered?
- *
- * @param string $class
- * @return bool
- */
- public function hasPlugin($class)
- {
- return $this->_plugins->hasPlugin($class);
- }
-
- /**
- * Retrieve a plugin or plugins by class
- *
- * @param string $class
- * @return false|Zend_Controller_Plugin_Abstract|array
- */
- public function getPlugin($class)
- {
- return $this->_plugins->getPlugin($class);
- }
-
- /**
- * Retrieve all plugins
- *
- * @return array
- */
- public function getPlugins()
- {
- return $this->_plugins->getPlugins();
- }
-
- /**
- * Set the throwExceptions flag and retrieve current status
- *
- * Set whether exceptions encounted in the dispatch loop should be thrown
- * or caught and trapped in the response object.
- *
- * Default behaviour is to trap them in the response object; call this
- * method to have them thrown.
- *
- * Passing no value will return the current value of the flag; passing a
- * boolean true or false value will set the flag and return the current
- * object instance.
- *
- * @param boolean $flag Defaults to null (return flag state)
- * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
- */
- public function throwExceptions($flag = null)
- {
- if ($flag !== null) {
- $this->_throwExceptions = (bool) $flag;
- return $this;
- }
-
- return $this->_throwExceptions;
- }
-
- /**
- * Set whether {@link dispatch()} should return the response without first
- * rendering output. By default, output is rendered and dispatch() returns
- * nothing.
- *
- * @param boolean $flag
- * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
- */
- public function returnResponse($flag = null)
- {
- if (true === $flag) {
- $this->_returnResponse = true;
- return $this;
- } elseif (false === $flag) {
- $this->_returnResponse = false;
- return $this;
- }
-
- return $this->_returnResponse;
- }
-
- /**
- * Dispatch an HTTP request to a controller/action.
- *
- * @param Zend_Controller_Request_Abstract|null $request
- * @param Zend_Controller_Response_Abstract|null $response
- * @return void|Zend_Controller_Response_Abstract Returns response object if returnResponse() is true
- */
- public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
- {
- if (!$this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) {
- // Register with stack index of 100
- require_once 'Zend/Controller/Plugin/ErrorHandler.php';
- $this->_plugins->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100);
- }
-
- if (!$this->getParam('noViewRenderer') && !Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
- require_once 'Zend/Controller/Action/Helper/ViewRenderer.php';
- Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new Zend_Controller_Action_Helper_ViewRenderer());
- }
-
- /**
- * Instantiate default request object (HTTP version) if none provided
- */
- if (null !== $request) {
- $this->setRequest($request);
- } elseif ((null === $request) && (null === ($request = $this->getRequest()))) {
- require_once 'Zend/Controller/Request/Http.php';
- $request = new Zend_Controller_Request_Http();
- $this->setRequest($request);
- }
-
- /**
- * Set base URL of request object, if available
- */
- if (is_callable(array($this->_request, 'setBaseUrl'))) {
- if (null !== $this->_baseUrl) {
- $this->_request->setBaseUrl($this->_baseUrl);
- }
- }
-
- /**
- * Instantiate default response object (HTTP version) if none provided
- */
- if (null !== $response) {
- $this->setResponse($response);
- } elseif ((null === $this->_response) && (null === ($this->_response = $this->getResponse()))) {
- require_once 'Zend/Controller/Response/Http.php';
- $response = new Zend_Controller_Response_Http();
- $this->setResponse($response);
- }
-
- /**
- * Register request and response objects with plugin broker
- */
- $this->_plugins
- ->setRequest($this->_request)
- ->setResponse($this->_response);
-
- /**
- * Initialize router
- */
- $router = $this->getRouter();
- $router->setParams($this->getParams());
-
- /**
- * Initialize dispatcher
- */
- $dispatcher = $this->getDispatcher();
- $dispatcher->setParams($this->getParams())
- ->setResponse($this->_response);
-
- // Begin dispatch
- try {
- /**
- * Route request to controller/action, if a router is provided
- */
-
- /**
- * Notify plugins of router startup
- */
- $this->_plugins->routeStartup($this->_request);
-
- try {
- $router->route($this->_request);
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
-
- $this->_response->setException($e);
- }
-
- /**
- * Notify plugins of router completion
- */
- $this->_plugins->routeShutdown($this->_request);
-
- /**
- * Notify plugins of dispatch loop startup
- */
- $this->_plugins->dispatchLoopStartup($this->_request);
-
- /**
- * Attempt to dispatch the controller/action. If the $this->_request
- * indicates that it needs to be dispatched, move to the next
- * action in the request.
- */
- do {
- $this->_request->setDispatched(true);
-
- /**
- * Notify plugins of dispatch startup
- */
- $this->_plugins->preDispatch($this->_request);
-
- /**
- * Skip requested action if preDispatch() has reset it
- */
- if (!$this->_request->isDispatched()) {
- continue;
- }
-
- /**
- * Dispatch request
- */
- try {
- $dispatcher->dispatch($this->_request, $this->_response);
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
- $this->_response->setException($e);
- }
-
- /**
- * Notify plugins of dispatch completion
- */
- $this->_plugins->postDispatch($this->_request);
- } while (!$this->_request->isDispatched());
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
-
- $this->_response->setException($e);
- }
-
- /**
- * Notify plugins of dispatch loop completion
- */
- try {
- $this->_plugins->dispatchLoopShutdown();
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
-
- $this->_response->setException($e);
- }
-
- if ($this->returnResponse()) {
- return $this->_response;
- }
-
- $this->_response->sendResponse();
- }
-}
diff --git a/lib/zend/Zend/Controller/Plugin/Abstract.php b/lib/zend/Zend/Controller/Plugin/Abstract.php
deleted file mode 100644
index 7e590b7eef0f2..0000000000000
--- a/lib/zend/Zend/Controller/Plugin/Abstract.php
+++ /dev/null
@@ -1,151 +0,0 @@
-_request = $request;
- return $this;
- }
-
- /**
- * Get request object
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set response object
- *
- * @param Zend_Controller_Response_Abstract $response
- * @return Zend_Controller_Plugin_Abstract
- */
- public function setResponse(Zend_Controller_Response_Abstract $response)
- {
- $this->_response = $response;
- return $this;
- }
-
- /**
- * Get response object
- *
- * @return Zend_Controller_Response_Abstract $response
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Called before Zend_Controller_Front begins evaluating the
- * request against its routes.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeStartup(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called after Zend_Controller_Router exits.
- *
- * Called after Zend_Controller_Front exits from the router.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called before Zend_Controller_Front enters its dispatch loop.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called before an action is dispatched by Zend_Controller_Dispatcher.
- *
- * This callback allows for proxy or filter behavior. By altering the
- * request and resetting its dispatched flag (via
- * {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
- * the current action may be skipped.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function preDispatch(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called after an action is dispatched by Zend_Controller_Dispatcher.
- *
- * This callback allows for proxy or filter behavior. By altering the
- * request and resetting its dispatched flag (via
- * {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
- * a new action may be specified for dispatching.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called before Zend_Controller_Front exits its dispatch loop.
- *
- * @return void
- */
- public function dispatchLoopShutdown()
- {}
-}
diff --git a/lib/zend/Zend/Controller/Plugin/ActionStack.php b/lib/zend/Zend/Controller/Plugin/ActionStack.php
deleted file mode 100644
index 12c62de1127d5..0000000000000
--- a/lib/zend/Zend/Controller/Plugin/ActionStack.php
+++ /dev/null
@@ -1,280 +0,0 @@
-setRegistry($registry);
-
- if (null !== $key) {
- $this->setRegistryKey($key);
- } else {
- $key = $this->getRegistryKey();
- }
-
- $registry[$key] = array();
- }
-
- /**
- * Set registry object
- *
- * @param Zend_Registry $registry
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function setRegistry(Zend_Registry $registry)
- {
- $this->_registry = $registry;
- return $this;
- }
-
- /**
- * Retrieve registry object
- *
- * @return Zend_Registry
- */
- public function getRegistry()
- {
- return $this->_registry;
- }
-
- /**
- * Retrieve registry key
- *
- * @return string
- */
- public function getRegistryKey()
- {
- return $this->_registryKey;
- }
-
- /**
- * Set registry key
- *
- * @param string $key
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function setRegistryKey($key)
- {
- $this->_registryKey = (string) $key;
- return $this;
- }
-
- /**
- * Set clearRequestParams flag
- *
- * @param bool $clearRequestParams
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function setClearRequestParams($clearRequestParams)
- {
- $this->_clearRequestParams = (bool) $clearRequestParams;
- return $this;
- }
-
- /**
- * Retrieve clearRequestParams flag
- *
- * @return bool
- */
- public function getClearRequestParams()
- {
- return $this->_clearRequestParams;
- }
-
- /**
- * Retrieve action stack
- *
- * @return array
- */
- public function getStack()
- {
- $registry = $this->getRegistry();
- $stack = $registry[$this->getRegistryKey()];
- return $stack;
- }
-
- /**
- * Save stack to registry
- *
- * @param array $stack
- * @return Zend_Controller_Plugin_ActionStack
- */
- protected function _saveStack(array $stack)
- {
- $registry = $this->getRegistry();
- $registry[$this->getRegistryKey()] = $stack;
- return $this;
- }
-
- /**
- * Push an item onto the stack
- *
- * @param Zend_Controller_Request_Abstract $next
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function pushStack(Zend_Controller_Request_Abstract $next)
- {
- $stack = $this->getStack();
- array_push($stack, $next);
- return $this->_saveStack($stack);
- }
-
- /**
- * Pop an item off the action stack
- *
- * @return false|Zend_Controller_Request_Abstract
- */
- public function popStack()
- {
- $stack = $this->getStack();
- if (0 == count($stack)) {
- return false;
- }
-
- $next = array_pop($stack);
- $this->_saveStack($stack);
-
- if (!$next instanceof Zend_Controller_Request_Abstract) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('ArrayStack should only contain request objects');
- }
- $action = $next->getActionName();
- if (empty($action)) {
- return $this->popStack($stack);
- }
-
- $request = $this->getRequest();
- $controller = $next->getControllerName();
- if (empty($controller)) {
- $next->setControllerName($request->getControllerName());
- }
-
- $module = $next->getModuleName();
- if (empty($module)) {
- $next->setModuleName($request->getModuleName());
- }
-
- return $next;
- }
-
- /**
- * postDispatch() plugin hook -- check for actions in stack, and dispatch if any found
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- // Don't move on to next request if this is already an attempt to
- // forward
- if (!$request->isDispatched()) {
- return;
- }
-
- $this->setRequest($request);
- $stack = $this->getStack();
- if (empty($stack)) {
- return;
- }
- $next = $this->popStack();
- if (!$next) {
- return;
- }
-
- $this->forward($next);
- }
-
- /**
- * Forward request with next action
- *
- * @param array $next
- * @return void
- */
- public function forward(Zend_Controller_Request_Abstract $next)
- {
- $request = $this->getRequest();
- if ($this->getClearRequestParams()) {
- $request->clearParams();
- }
-
- $request->setModuleName($next->getModuleName())
- ->setControllerName($next->getControllerName())
- ->setActionName($next->getActionName())
- ->setParams($next->getParams())
- ->setDispatched(false);
- }
-}
diff --git a/lib/zend/Zend/Controller/Plugin/Broker.php b/lib/zend/Zend/Controller/Plugin/Broker.php
deleted file mode 100644
index 1214583eb305f..0000000000000
--- a/lib/zend/Zend/Controller/Plugin/Broker.php
+++ /dev/null
@@ -1,365 +0,0 @@
-_plugins, true)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Plugin already registered');
- }
-
- $stackIndex = (int) $stackIndex;
-
- if ($stackIndex) {
- if (isset($this->_plugins[$stackIndex])) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Plugin with stackIndex "' . $stackIndex . '" already registered');
- }
- $this->_plugins[$stackIndex] = $plugin;
- } else {
- $stackIndex = count($this->_plugins);
- while (isset($this->_plugins[$stackIndex])) {
- ++$stackIndex;
- }
- $this->_plugins[$stackIndex] = $plugin;
- }
-
- $request = $this->getRequest();
- if ($request) {
- $this->_plugins[$stackIndex]->setRequest($request);
- }
- $response = $this->getResponse();
- if ($response) {
- $this->_plugins[$stackIndex]->setResponse($response);
- }
-
- ksort($this->_plugins);
-
- return $this;
- }
-
- /**
- * Unregister a plugin.
- *
- * @param string|Zend_Controller_Plugin_Abstract $plugin Plugin object or class name
- * @return Zend_Controller_Plugin_Broker
- */
- public function unregisterPlugin($plugin)
- {
- if ($plugin instanceof Zend_Controller_Plugin_Abstract) {
- // Given a plugin object, find it in the array
- $key = array_search($plugin, $this->_plugins, true);
- if (false === $key) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Plugin never registered.');
- }
- unset($this->_plugins[$key]);
- } elseif (is_string($plugin)) {
- // Given a plugin class, find all plugins of that class and unset them
- foreach ($this->_plugins as $key => $_plugin) {
- $type = get_class($_plugin);
- if ($plugin == $type) {
- unset($this->_plugins[$key]);
- }
- }
- }
- return $this;
- }
-
- /**
- * Is a plugin of a particular class registered?
- *
- * @param string $class
- * @return bool
- */
- public function hasPlugin($class)
- {
- foreach ($this->_plugins as $plugin) {
- $type = get_class($plugin);
- if ($class == $type) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve a plugin or plugins by class
- *
- * @param string $class Class name of plugin(s) desired
- * @return false|Zend_Controller_Plugin_Abstract|array Returns false if none found, plugin if only one found, and array of plugins if multiple plugins of same class found
- */
- public function getPlugin($class)
- {
- $found = array();
- foreach ($this->_plugins as $plugin) {
- $type = get_class($plugin);
- if ($class == $type) {
- $found[] = $plugin;
- }
- }
-
- switch (count($found)) {
- case 0:
- return false;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Retrieve all plugins
- *
- * @return array
- */
- public function getPlugins()
- {
- return $this->_plugins;
- }
-
- /**
- * Set request object, and register with each plugin
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return Zend_Controller_Plugin_Broker
- */
- public function setRequest(Zend_Controller_Request_Abstract $request)
- {
- $this->_request = $request;
-
- foreach ($this->_plugins as $plugin) {
- $plugin->setRequest($request);
- }
-
- return $this;
- }
-
- /**
- * Get request object
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set response object
- *
- * @param Zend_Controller_Response_Abstract $response
- * @return Zend_Controller_Plugin_Broker
- */
- public function setResponse(Zend_Controller_Response_Abstract $response)
- {
- $this->_response = $response;
-
- foreach ($this->_plugins as $plugin) {
- $plugin->setResponse($response);
- }
-
-
- return $this;
- }
-
- /**
- * Get response object
- *
- * @return Zend_Controller_Response_Abstract $response
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
-
- /**
- * Called before Zend_Controller_Front begins evaluating the
- * request against its routes.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeStartup(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->routeStartup($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw new Zend_Controller_Exception($e->getMessage() . $e->getTraceAsString(), $e->getCode(), $e);
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before Zend_Controller_Front exits its iterations over
- * the route set.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->routeShutdown($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw new Zend_Controller_Exception($e->getMessage() . $e->getTraceAsString(), $e->getCode(), $e);
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before Zend_Controller_Front enters its dispatch loop.
- *
- * During the dispatch loop, Zend_Controller_Front keeps a
- * Zend_Controller_Request_Abstract object, and uses
- * Zend_Controller_Dispatcher to dispatch the
- * Zend_Controller_Request_Abstract object to controllers/actions.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->dispatchLoopStartup($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw new Zend_Controller_Exception($e->getMessage() . $e->getTraceAsString(), $e->getCode(), $e);
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before an action is dispatched by Zend_Controller_Dispatcher.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function preDispatch(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->preDispatch($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw new Zend_Controller_Exception($e->getMessage() . $e->getTraceAsString(), $e->getCode(), $e);
- } else {
- $this->getResponse()->setException($e);
- // skip rendering of normal dispatch give the error handler a try
- $this->getRequest()->setDispatched(false);
- }
- }
- }
- }
-
-
- /**
- * Called after an action is dispatched by Zend_Controller_Dispatcher.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->postDispatch($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw new Zend_Controller_Exception($e->getMessage() . $e->getTraceAsString(), $e->getCode(), $e);
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before Zend_Controller_Front exits its dispatch loop.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function dispatchLoopShutdown()
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->dispatchLoopShutdown();
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw new Zend_Controller_Exception($e->getMessage() . $e->getTraceAsString(), $e->getCode(), $e);
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-}
diff --git a/lib/zend/Zend/Controller/Plugin/ErrorHandler.php b/lib/zend/Zend/Controller/Plugin/ErrorHandler.php
deleted file mode 100644
index 42da1633c6447..0000000000000
--- a/lib/zend/Zend/Controller/Plugin/ErrorHandler.php
+++ /dev/null
@@ -1,300 +0,0 @@
-setErrorHandler($options);
- }
-
- /**
- * setErrorHandler() - setup the error handling options
- *
- * @param array $options
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandler(Array $options = array())
- {
- if (isset($options['module'])) {
- $this->setErrorHandlerModule($options['module']);
- }
- if (isset($options['controller'])) {
- $this->setErrorHandlerController($options['controller']);
- }
- if (isset($options['action'])) {
- $this->setErrorHandlerAction($options['action']);
- }
- return $this;
- }
-
- /**
- * Set the module name for the error handler
- *
- * @param string $module
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandlerModule($module)
- {
- $this->_errorModule = (string) $module;
- return $this;
- }
-
- /**
- * Retrieve the current error handler module
- *
- * @return string
- */
- public function getErrorHandlerModule()
- {
- if (null === $this->_errorModule) {
- $this->_errorModule = Zend_Controller_Front::getInstance()->getDispatcher()->getDefaultModule();
- }
- return $this->_errorModule;
- }
-
- /**
- * Set the controller name for the error handler
- *
- * @param string $controller
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandlerController($controller)
- {
- $this->_errorController = (string) $controller;
- return $this;
- }
-
- /**
- * Retrieve the current error handler controller
- *
- * @return string
- */
- public function getErrorHandlerController()
- {
- return $this->_errorController;
- }
-
- /**
- * Set the action name for the error handler
- *
- * @param string $action
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandlerAction($action)
- {
- $this->_errorAction = (string) $action;
- return $this;
- }
-
- /**
- * Retrieve the current error handler action
- *
- * @return string
- */
- public function getErrorHandlerAction()
- {
- return $this->_errorAction;
- }
-
- /**
- * Route shutdown hook -- Ccheck for router exceptions
- *
- * @param Zend_Controller_Request_Abstract $request
- */
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {
- $this->_handleError($request);
- }
-
- /**
- * Pre dispatch hook -- check for exceptions and dispatch error handler if
- * necessary
- *
- * @param Zend_Controller_Request_Abstract $request
- */
- public function preDispatch(Zend_Controller_Request_Abstract $request)
- {
- $this->_handleError($request);
- }
-
- /**
- * Post dispatch hook -- check for exceptions and dispatch error handler if
- * necessary
- *
- * @param Zend_Controller_Request_Abstract $request
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- $this->_handleError($request);
- }
-
- /**
- * Handle errors and exceptions
- *
- * If the 'noErrorHandler' front controller flag has been set,
- * returns early.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- protected function _handleError(Zend_Controller_Request_Abstract $request)
- {
- $frontController = Zend_Controller_Front::getInstance();
- if ($frontController->getParam('noErrorHandler')) {
- return;
- }
-
- $response = $this->getResponse();
-
- if ($this->_isInsideErrorHandlerLoop) {
- $exceptions = $response->getException();
- if (count($exceptions) > $this->_exceptionCountAtFirstEncounter) {
- // Exception thrown by error handler; tell the front controller to throw it
- $frontController->throwExceptions(true);
- throw array_pop($exceptions);
- }
- }
-
- // check for an exception AND allow the error handler controller the option to forward
- if (($response->isException()) && (!$this->_isInsideErrorHandlerLoop)) {
- $this->_isInsideErrorHandlerLoop = true;
-
- // Get exception information
- $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
- $exceptions = $response->getException();
- $exception = $exceptions[0];
- $exceptionType = get_class($exception);
- $error->exception = $exception;
- switch ($exceptionType) {
- case 'Zend_Controller_Router_Exception':
- if (404 == $exception->getCode()) {
- $error->type = self::EXCEPTION_NO_ROUTE;
- } else {
- $error->type = self::EXCEPTION_OTHER;
- }
- break;
- case 'Zend_Controller_Dispatcher_Exception':
- $error->type = self::EXCEPTION_NO_CONTROLLER;
- break;
- case 'Zend_Controller_Action_Exception':
- if (404 == $exception->getCode()) {
- $error->type = self::EXCEPTION_NO_ACTION;
- } else {
- $error->type = self::EXCEPTION_OTHER;
- }
- break;
- default:
- $error->type = self::EXCEPTION_OTHER;
- break;
- }
-
- // Keep a copy of the original request
- $error->request = clone $request;
-
- // get a count of the number of exceptions encountered
- $this->_exceptionCountAtFirstEncounter = count($exceptions);
-
- // Forward to the error handler
- $request->setParam('error_handler', $error)
- ->setModuleName($this->getErrorHandlerModule())
- ->setControllerName($this->getErrorHandlerController())
- ->setActionName($this->getErrorHandlerAction())
- ->setDispatched(false);
- }
- }
-}
diff --git a/lib/zend/Zend/Controller/Plugin/PutHandler.php b/lib/zend/Zend/Controller/Plugin/PutHandler.php
deleted file mode 100644
index 3b5f57b910289..0000000000000
--- a/lib/zend/Zend/Controller/Plugin/PutHandler.php
+++ /dev/null
@@ -1,60 +0,0 @@
-_request->isPut()) {
- $putParams = array();
- parse_str($this->_request->getRawBody(), $putParams);
- $request->setParams($putParams);
- }
- }
-}
diff --git a/lib/zend/Zend/Controller/Request/Abstract.php b/lib/zend/Zend/Controller/Request/Abstract.php
deleted file mode 100644
index d57238f46bec2..0000000000000
--- a/lib/zend/Zend/Controller/Request/Abstract.php
+++ /dev/null
@@ -1,356 +0,0 @@
-_module) {
- $this->_module = $this->getParam($this->getModuleKey());
- }
-
- return $this->_module;
- }
-
- /**
- * Set the module name to use
- *
- * @param string $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setModuleName($value)
- {
- $this->_module = $value;
- return $this;
- }
-
- /**
- * Retrieve the controller name
- *
- * @return string
- */
- public function getControllerName()
- {
- if (null === $this->_controller) {
- $this->_controller = $this->getParam($this->getControllerKey());
- }
-
- return $this->_controller;
- }
-
- /**
- * Set the controller name to use
- *
- * @param string $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setControllerName($value)
- {
- $this->_controller = $value;
- return $this;
- }
-
- /**
- * Retrieve the action name
- *
- * @return string
- */
- public function getActionName()
- {
- if (null === $this->_action) {
- $this->_action = $this->getParam($this->getActionKey());
- }
-
- return $this->_action;
- }
-
- /**
- * Set the action name
- *
- * @param string $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setActionName($value)
- {
- $this->_action = $value;
- /**
- * @see ZF-3465
- */
- if (null === $value) {
- $this->setParam($this->getActionKey(), $value);
- }
- return $this;
- }
-
- /**
- * Retrieve the module key
- *
- * @return string
- */
- public function getModuleKey()
- {
- return $this->_moduleKey;
- }
-
- /**
- * Set the module key
- *
- * @param string $key
- * @return Zend_Controller_Request_Abstract
- */
- public function setModuleKey($key)
- {
- $this->_moduleKey = (string) $key;
- return $this;
- }
-
- /**
- * Retrieve the controller key
- *
- * @return string
- */
- public function getControllerKey()
- {
- return $this->_controllerKey;
- }
-
- /**
- * Set the controller key
- *
- * @param string $key
- * @return Zend_Controller_Request_Abstract
- */
- public function setControllerKey($key)
- {
- $this->_controllerKey = (string) $key;
- return $this;
- }
-
- /**
- * Retrieve the action key
- *
- * @return string
- */
- public function getActionKey()
- {
- return $this->_actionKey;
- }
-
- /**
- * Set the action key
- *
- * @param string $key
- * @return Zend_Controller_Request_Abstract
- */
- public function setActionKey($key)
- {
- $this->_actionKey = (string) $key;
- return $this;
- }
-
- /**
- * Get an action parameter
- *
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed
- */
- public function getParam($key, $default = null)
- {
- $key = (string) $key;
- if (isset($this->_params[$key])) {
- return $this->_params[$key];
- }
-
- return $default;
- }
-
- /**
- * Retrieve only user params (i.e, any param specific to the object and not the environment)
- *
- * @return array
- */
- public function getUserParams()
- {
- return $this->_params;
- }
-
- /**
- * Retrieve a single user param (i.e, a param specific to the object and not the environment)
- *
- * @param string $key
- * @param string $default Default value to use if key not found
- * @return mixed
- */
- public function getUserParam($key, $default = null)
- {
- if (isset($this->_params[$key])) {
- return $this->_params[$key];
- }
-
- return $default;
- }
-
- /**
- * Set an action parameter
- *
- * A $value of null will unset the $key if it exists
- *
- * @param string $key
- * @param mixed $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setParam($key, $value)
- {
- $key = (string) $key;
-
- if ((null === $value) && isset($this->_params[$key])) {
- unset($this->_params[$key]);
- } elseif (null !== $value) {
- $this->_params[$key] = $value;
- }
-
- return $this;
- }
-
- /**
- * Get all action parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_params;
- }
-
- /**
- * Set action parameters en masse; does not overwrite
- *
- * Null values will unset the associated key.
- *
- * @param array $array
- * @return Zend_Controller_Request_Abstract
- */
- public function setParams(array $array)
- {
- $this->_params = $this->_params + (array) $array;
-
- foreach ($array as $key => $value) {
- if (null === $value) {
- unset($this->_params[$key]);
- }
- }
-
- return $this;
- }
-
- /**
- * Unset all user parameters
- *
- * @return Zend_Controller_Request_Abstract
- */
- public function clearParams()
- {
- $this->_params = array();
- return $this;
- }
-
- /**
- * Set flag indicating whether or not request has been dispatched
- *
- * @param boolean $flag
- * @return Zend_Controller_Request_Abstract
- */
- public function setDispatched($flag = true)
- {
- $this->_dispatched = $flag ? true : false;
- return $this;
- }
-
- /**
- * Determine if the request has been dispatched
- *
- * @return boolean
- */
- public function isDispatched()
- {
- return $this->_dispatched;
- }
-}
diff --git a/lib/zend/Zend/Controller/Request/Apache404.php b/lib/zend/Zend/Controller/Request/Apache404.php
deleted file mode 100644
index 3c4dd7ac487ec..0000000000000
--- a/lib/zend/Zend/Controller/Request/Apache404.php
+++ /dev/null
@@ -1,82 +0,0 @@
-_requestUri = $requestUri;
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Controller/Request/Exception.php b/lib/zend/Zend/Controller/Request/Exception.php
deleted file mode 100644
index a7e3629fdab3d..0000000000000
--- a/lib/zend/Zend/Controller/Request/Exception.php
+++ /dev/null
@@ -1,37 +0,0 @@
-valid()) {
- $path = $uri->getPath();
- $query = $uri->getQuery();
- if (!empty($query)) {
- $path .= '?' . $query;
- }
-
- $this->setRequestUri($path);
- } else {
- require_once 'Zend/Controller/Request/Exception.php';
- throw new Zend_Controller_Request_Exception('Invalid URI provided to constructor');
- }
- } else {
- $this->setRequestUri();
- }
- }
-
- /**
- * Access values contained in the superglobals as public members
- * Order of precedence: 1. GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV
- *
- * @see http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx
- * @param string $key
- * @return mixed
- */
- public function __get($key)
- {
- switch (true) {
- case isset($this->_params[$key]):
- return $this->_params[$key];
- case isset($_GET[$key]):
- return $_GET[$key];
- case isset($_POST[$key]):
- return $_POST[$key];
- case isset($_COOKIE[$key]):
- return $_COOKIE[$key];
- case ($key == 'REQUEST_URI'):
- return $this->getRequestUri();
- case ($key == 'PATH_INFO'):
- return $this->getPathInfo();
- case isset($_SERVER[$key]):
- return $_SERVER[$key];
- case isset($_ENV[$key]):
- return $_ENV[$key];
- default:
- return null;
- }
- }
-
- /**
- * Alias to __get
- *
- * @param string $key
- * @return mixed
- */
- public function get($key)
- {
- return $this->__get($key);
- }
-
- /**
- * Set values
- *
- * In order to follow {@link __get()}, which operates on a number of
- * superglobals, setting values through overloading is not allowed and will
- * raise an exception. Use setParam() instead.
- *
- * @param string $key
- * @param mixed $value
- * @return void
- * @throws Zend_Controller_Request_Exception
- */
- public function __set($key, $value)
- {
- require_once 'Zend/Controller/Request/Exception.php';
- throw new Zend_Controller_Request_Exception('Setting values in superglobals not allowed; please use setParam()');
- }
-
- /**
- * Alias to __set()
- *
- * @param string $key
- * @param mixed $value
- * @return void
- */
- public function set($key, $value)
- {
- return $this->__set($key, $value);
- }
-
- /**
- * Check to see if a property is set
- *
- * @param string $key
- * @return boolean
- */
- public function __isset($key)
- {
- switch (true) {
- case isset($this->_params[$key]):
- return true;
- case isset($_GET[$key]):
- return true;
- case isset($_POST[$key]):
- return true;
- case isset($_COOKIE[$key]):
- return true;
- case isset($_SERVER[$key]):
- return true;
- case isset($_ENV[$key]):
- return true;
- default:
- return false;
- }
- }
-
- /**
- * Alias to __isset()
- *
- * @param string $key
- * @return boolean
- */
- public function has($key)
- {
- return $this->__isset($key);
- }
-
- /**
- * Set GET values
- *
- * @param string|array $spec
- * @param null|mixed $value
- * @return Zend_Controller_Request_Http
- */
- public function setQuery($spec, $value = null)
- {
- if ((null === $value) && !is_array($spec)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid value passed to setQuery(); must be either array of values or key/value pair');
- }
- if ((null === $value) && is_array($spec)) {
- foreach ($spec as $key => $value) {
- $this->setQuery($key, $value);
- }
- return $this;
- }
- $_GET[(string) $spec] = $value;
- return $this;
- }
-
- /**
- * Retrieve a member of the $_GET superglobal
- *
- * If no $key is passed, returns the entire $_GET array.
- *
- * @todo How to retrieve from nested arrays
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getQuery($key = null, $default = null)
- {
- if (null === $key) {
- return $_GET;
- }
-
- return (isset($_GET[$key])) ? $_GET[$key] : $default;
- }
-
- /**
- * Set POST values
- *
- * @param string|array $spec
- * @param null|mixed $value
- * @return Zend_Controller_Request_Http
- */
- public function setPost($spec, $value = null)
- {
- if ((null === $value) && !is_array($spec)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid value passed to setPost(); must be either array of values or key/value pair');
- }
- if ((null === $value) && is_array($spec)) {
- foreach ($spec as $key => $value) {
- $this->setPost($key, $value);
- }
- return $this;
- }
- $_POST[(string) $spec] = $value;
- return $this;
- }
-
- /**
- * Retrieve a member of the $_POST superglobal
- *
- * If no $key is passed, returns the entire $_POST array.
- *
- * @todo How to retrieve from nested arrays
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getPost($key = null, $default = null)
- {
- if (null === $key) {
- return $_POST;
- }
-
- return (isset($_POST[$key])) ? $_POST[$key] : $default;
- }
-
- /**
- * Retrieve a member of the $_COOKIE superglobal
- *
- * If no $key is passed, returns the entire $_COOKIE array.
- *
- * @todo How to retrieve from nested arrays
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getCookie($key = null, $default = null)
- {
- if (null === $key) {
- return $_COOKIE;
- }
-
- return (isset($_COOKIE[$key])) ? $_COOKIE[$key] : $default;
- }
-
- /**
- * Retrieve a member of the $_SERVER superglobal
- *
- * If no $key is passed, returns the entire $_SERVER array.
- *
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getServer($key = null, $default = null)
- {
- if (null === $key) {
- return $_SERVER;
- }
-
- return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;
- }
-
- /**
- * Retrieve a member of the $_ENV superglobal
- *
- * If no $key is passed, returns the entire $_ENV array.
- *
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getEnv($key = null, $default = null)
- {
- if (null === $key) {
- return $_ENV;
- }
-
- return (isset($_ENV[$key])) ? $_ENV[$key] : $default;
- }
-
- /**
- * Set the REQUEST_URI on which the instance operates
- *
- * If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'],
- * $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].
- *
- * @param string $requestUri
- * @return Zend_Controller_Request_Http
- */
- public function setRequestUri($requestUri = null)
- {
- if ($requestUri === null) {
- if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
- // IIS with Microsoft Rewrite Module
- $requestUri = $_SERVER['HTTP_X_ORIGINAL_URL'];
- } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
- // IIS with ISAPI_Rewrite
- $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
- } elseif (
- // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
- isset($_SERVER['IIS_WasUrlRewritten'])
- && $_SERVER['IIS_WasUrlRewritten'] == '1'
- && isset($_SERVER['UNENCODED_URL'])
- && $_SERVER['UNENCODED_URL'] != ''
- ) {
- $requestUri = $_SERVER['UNENCODED_URL'];
- } elseif (isset($_SERVER['REQUEST_URI'])) {
- $requestUri = $_SERVER['REQUEST_URI'];
- // Http proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
- $schemeAndHttpHost = $this->getScheme() . '://' . $this->getHttpHost();
- if (strpos($requestUri, $schemeAndHttpHost) === 0) {
- $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
- }
- } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI
- $requestUri = $_SERVER['ORIG_PATH_INFO'];
- if (!empty($_SERVER['QUERY_STRING'])) {
- $requestUri .= '?' . $_SERVER['QUERY_STRING'];
- }
- } else {
- return $this;
- }
- } elseif (!is_string($requestUri)) {
- return $this;
- } else {
- // Set GET items, if available
- if (false !== ($pos = strpos($requestUri, '?'))) {
- // Get key => value pairs and set $_GET
- $query = substr($requestUri, $pos + 1);
- parse_str($query, $vars);
- $this->setQuery($vars);
- }
- }
-
- $this->_requestUri = $requestUri;
- return $this;
- }
-
- /**
- * Returns the REQUEST_URI taking into account
- * platform differences between Apache and IIS
- *
- * @return string
- */
- public function getRequestUri()
- {
- if (empty($this->_requestUri)) {
- $this->setRequestUri();
- }
-
- return $this->_requestUri;
- }
-
- /**
- * Set the base URL of the request; i.e., the segment leading to the script name
- *
- * E.g.:
- * - /admin
- * - /myapp
- * - /subdir/index.php
- *
- * Do not use the full URI when providing the base. The following are
- * examples of what not to use:
- * - http://example.com/admin (should be just /admin)
- * - http://example.com/subdir/index.php (should be just /subdir/index.php)
- *
- * If no $baseUrl is provided, attempts to determine the base URL from the
- * environment, using SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, and
- * ORIG_SCRIPT_NAME in its determination.
- *
- * @param mixed $baseUrl
- * @return Zend_Controller_Request_Http
- */
- public function setBaseUrl($baseUrl = null)
- {
- if ((null !== $baseUrl) && !is_string($baseUrl)) {
- return $this;
- }
-
- if ($baseUrl === null) {
- $filename = (isset($_SERVER['SCRIPT_FILENAME'])) ? basename($_SERVER['SCRIPT_FILENAME']) : '';
-
- if (isset($_SERVER['SCRIPT_NAME']) && basename($_SERVER['SCRIPT_NAME']) === $filename) {
- $baseUrl = $_SERVER['SCRIPT_NAME'];
- } elseif (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) === $filename) {
- $baseUrl = $_SERVER['PHP_SELF'];
- } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $filename) {
- $baseUrl = $_SERVER['ORIG_SCRIPT_NAME']; // 1and1 shared hosting compatibility
- } else {
- // Backtrack up the script_filename to find the portion matching
- // php_self
- $path = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '';
- $file = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '';
- $segs = explode('/', trim($file, '/'));
- $segs = array_reverse($segs);
- $index = 0;
- $last = count($segs);
- $baseUrl = '';
- do {
- $seg = $segs[$index];
- $baseUrl = '/' . $seg . $baseUrl;
- ++$index;
- } while (($last > $index) && (false !== ($pos = strpos($path, $baseUrl))) && (0 != $pos));
- }
-
- // Does the baseUrl have anything in common with the request_uri?
- $requestUri = $this->getRequestUri();
-
- if (0 === strpos($requestUri, $baseUrl)) {
- // full $baseUrl matches
- $this->_baseUrl = $baseUrl;
- return $this;
- }
-
- if (0 === strpos($requestUri, dirname($baseUrl))) {
- // directory portion of $baseUrl matches
- $this->_baseUrl = rtrim(dirname($baseUrl), '/');
- return $this;
- }
-
- $truncatedRequestUri = $requestUri;
- if (($pos = strpos($requestUri, '?')) !== false) {
- $truncatedRequestUri = substr($requestUri, 0, $pos);
- }
-
- $basename = basename($baseUrl);
- if (empty($basename) || !strpos($truncatedRequestUri, $basename)) {
- // no match whatsoever; set it blank
- $this->_baseUrl = '';
- return $this;
- }
-
- // If using mod_rewrite or ISAPI_Rewrite strip the script filename
- // out of baseUrl. $pos !== 0 makes sure it is not matching a value
- // from PATH_INFO or QUERY_STRING
- if ((strlen($requestUri) >= strlen($baseUrl))
- && ((false !== ($pos = strpos($requestUri, $baseUrl))) && ($pos !== 0)))
- {
- $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
- }
- }
-
- $this->_baseUrl = rtrim($baseUrl, '/');
- return $this;
- }
-
- /**
- * Everything in REQUEST_URI before PATH_INFO
- *
- *
- * @return string
- */
- public function getBaseUrl($raw = false)
- {
- if (null === $this->_baseUrl) {
- $this->setBaseUrl();
- }
-
- return (($raw == false) ? urldecode($this->_baseUrl) : $this->_baseUrl);
- }
-
- /**
- * Set the base path for the URL
- *
- * @param string|null $basePath
- * @return Zend_Controller_Request_Http
- */
- public function setBasePath($basePath = null)
- {
- if ($basePath === null) {
- $filename = (isset($_SERVER['SCRIPT_FILENAME']))
- ? basename($_SERVER['SCRIPT_FILENAME'])
- : '';
-
- $baseUrl = $this->getBaseUrl();
- if (empty($baseUrl)) {
- $this->_basePath = '';
- return $this;
- }
-
- if (basename($baseUrl) === $filename) {
- $basePath = dirname($baseUrl);
- } else {
- $basePath = $baseUrl;
- }
- }
-
- if (substr(PHP_OS, 0, 3) === 'WIN') {
- $basePath = str_replace('\\', '/', $basePath);
- }
-
- $this->_basePath = rtrim($basePath, '/');
- return $this;
- }
-
- /**
- * Everything in REQUEST_URI before PATH_INFO not including the filename
- *
- *
- * @return string
- */
- public function getBasePath()
- {
- if (null === $this->_basePath) {
- $this->setBasePath();
- }
-
- return $this->_basePath;
- }
-
- /**
- * Set the PATH_INFO string
- *
- * @param string|null $pathInfo
- * @return Zend_Controller_Request_Http
- */
- public function setPathInfo($pathInfo = null)
- {
- if ($pathInfo === null) {
- $baseUrl = $this->getBaseUrl(); // this actually calls setBaseUrl() & setRequestUri()
- $baseUrlRaw = $this->getBaseUrl(false);
- $baseUrlEncoded = urlencode($baseUrlRaw);
-
- if (null === ($requestUri = $this->getRequestUri())) {
- return $this;
- }
-
- // Remove the query string from REQUEST_URI
- if ($pos = strpos($requestUri, '?')) {
- $requestUri = substr($requestUri, 0, $pos);
- }
-
- if (!empty($baseUrl) || !empty($baseUrlRaw)) {
- if (strpos($requestUri, $baseUrl) === 0) {
- $pathInfo = substr($requestUri, strlen($baseUrl));
- } elseif (strpos($requestUri, $baseUrlRaw) === 0) {
- $pathInfo = substr($requestUri, strlen($baseUrlRaw));
- } elseif (strpos($requestUri, $baseUrlEncoded) === 0) {
- $pathInfo = substr($requestUri, strlen($baseUrlEncoded));
- } else {
- $pathInfo = $requestUri;
- }
- } else {
- $pathInfo = $requestUri;
- }
-
- }
-
- $this->_pathInfo = (string) $pathInfo;
- return $this;
- }
-
- /**
- * Returns everything between the BaseUrl and QueryString.
- * This value is calculated instead of reading PATH_INFO
- * directly from $_SERVER due to cross-platform differences.
- *
- * @return string
- */
- public function getPathInfo()
- {
- if (empty($this->_pathInfo)) {
- $this->setPathInfo();
- }
-
- return $this->_pathInfo;
- }
-
- /**
- * Set allowed parameter sources
- *
- * Can be empty array, or contain one or more of '_GET' or '_POST'.
- *
- * @param array $paramSoures
- * @return Zend_Controller_Request_Http
- */
- public function setParamSources(array $paramSources = array())
- {
- $this->_paramSources = $paramSources;
- return $this;
- }
-
- /**
- * Get list of allowed parameter sources
- *
- * @return array
- */
- public function getParamSources()
- {
- return $this->_paramSources;
- }
-
- /**
- * Set a userland parameter
- *
- * Uses $key to set a userland parameter. If $key is an alias, the actual
- * key will be retrieved and used to set the parameter.
- *
- * @param mixed $key
- * @param mixed $value
- * @return Zend_Controller_Request_Http
- */
- public function setParam($key, $value)
- {
- $key = (null !== ($alias = $this->getAlias($key))) ? $alias : $key;
- parent::setParam($key, $value);
- return $this;
- }
-
- /**
- * Retrieve a parameter
- *
- * Retrieves a parameter from the instance. Priority is in the order of
- * userland parameters (see {@link setParam()}), $_GET, $_POST. If a
- * parameter matching the $key is not found, null is returned.
- *
- * If the $key is an alias, the actual key aliased will be used.
- *
- * @param mixed $key
- * @param mixed $default Default value to use if key not found
- * @return mixed
- */
- public function getParam($key, $default = null)
- {
- $keyName = (null !== ($alias = $this->getAlias($key))) ? $alias : $key;
-
- $paramSources = $this->getParamSources();
- if (isset($this->_params[$keyName])) {
- return $this->_params[$keyName];
- } elseif (in_array('_GET', $paramSources) && (isset($_GET[$keyName]))) {
- return $_GET[$keyName];
- } elseif (in_array('_POST', $paramSources) && (isset($_POST[$keyName]))) {
- return $_POST[$keyName];
- }
-
- return $default;
- }
-
- /**
- * Retrieve an array of parameters
- *
- * Retrieves a merged array of parameters, with precedence of userland
- * params (see {@link setParam()}), $_GET, $_POST (i.e., values in the
- * userland params will take precedence over all others).
- *
- * @return array
- */
- public function getParams()
- {
- $return = $this->_params;
- $paramSources = $this->getParamSources();
- if (in_array('_GET', $paramSources)
- && isset($_GET)
- && is_array($_GET)
- ) {
- $return += $_GET;
- }
- if (in_array('_POST', $paramSources)
- && isset($_POST)
- && is_array($_POST)
- ) {
- $return += $_POST;
- }
- return $return;
- }
-
- /**
- * Set parameters
- *
- * Set one or more parameters. Parameters are set as userland parameters,
- * using the keys specified in the array.
- *
- * @param array $params
- * @return Zend_Controller_Request_Http
- */
- public function setParams(array $params)
- {
- foreach ($params as $key => $value) {
- $this->setParam($key, $value);
- }
- return $this;
- }
-
- /**
- * Set a key alias
- *
- * Set an alias used for key lookups. $name specifies the alias, $target
- * specifies the actual key to use.
- *
- * @param string $name
- * @param string $target
- * @return Zend_Controller_Request_Http
- */
- public function setAlias($name, $target)
- {
- $this->_aliases[$name] = $target;
- return $this;
- }
-
- /**
- * Retrieve an alias
- *
- * Retrieve the actual key represented by the alias $name.
- *
- * @param string $name
- * @return string|null Returns null when no alias exists
- */
- public function getAlias($name)
- {
- if (isset($this->_aliases[$name])) {
- return $this->_aliases[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve the list of all aliases
- *
- * @return array
- */
- public function getAliases()
- {
- return $this->_aliases;
- }
-
- /**
- * Return the method by which the request was made
- *
- * @return string
- */
- public function getMethod()
- {
- return $this->getServer('REQUEST_METHOD');
- }
-
- /**
- * Was the request made by POST?
- *
- * @return boolean
- */
- public function isPost()
- {
- if ('POST' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by GET?
- *
- * @return boolean
- */
- public function isGet()
- {
- if ('GET' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by PUT?
- *
- * @return boolean
- */
- public function isPut()
- {
- if ('PUT' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by DELETE?
- *
- * @return boolean
- */
- public function isDelete()
- {
- if ('DELETE' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by HEAD?
- *
- * @return boolean
- */
- public function isHead()
- {
- if ('HEAD' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by OPTIONS?
- *
- * @return boolean
- */
- public function isOptions()
- {
- if ('OPTIONS' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by PATCH?
- *
- * @return boolean
- */
- public function isPatch()
- {
- if ('PATCH' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Is the request a Javascript XMLHttpRequest?
- *
- * Should work with Prototype/Script.aculo.us, possibly others.
- *
- * @return boolean
- */
- public function isXmlHttpRequest()
- {
- return ($this->getHeader('X_REQUESTED_WITH') == 'XMLHttpRequest');
- }
-
- /**
- * Is this a Flash request?
- *
- * @return boolean
- */
- public function isFlashRequest()
- {
- $header = strtolower($this->getHeader('USER_AGENT'));
- return (strstr($header, ' flash')) ? true : false;
- }
-
- /**
- * Is https secure request
- *
- * @return boolean
- */
- public function isSecure()
- {
- return ($this->getScheme() === self::SCHEME_HTTPS);
- }
-
- /**
- * Return the raw body of the request, if present
- *
- * @return string|false Raw body, or false if not present
- */
- public function getRawBody()
- {
- if (null === $this->_rawBody) {
- $body = file_get_contents('php://input');
-
- if (strlen(trim($body)) > 0) {
- $this->_rawBody = $body;
- } else {
- $this->_rawBody = false;
- }
- }
- return $this->_rawBody;
- }
-
- /**
- * Return the value of the given HTTP header. Pass the header name as the
- * plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the
- * Accept header, 'Accept-Encoding' to get the Accept-Encoding header.
- *
- * @param string $header HTTP header name
- * @return string|false HTTP header value, or false if not found
- * @throws Zend_Controller_Request_Exception
- */
- public function getHeader($header)
- {
- if (empty($header)) {
- require_once 'Zend/Controller/Request/Exception.php';
- throw new Zend_Controller_Request_Exception('An HTTP header name is required');
- }
-
- // Try to get it from the $_SERVER array first
- $temp = strtoupper(str_replace('-', '_', $header));
- if (isset($_SERVER['HTTP_' . $temp])) {
- return $_SERVER['HTTP_' . $temp];
- }
-
- /*
- * Try to get it from the $_SERVER array on POST request or CGI environment
- * @see https://www.ietf.org/rfc/rfc3875 (4.1.2. and 4.1.3.)
- */
- if (isset($_SERVER[$temp])
- && in_array($temp, array('CONTENT_TYPE', 'CONTENT_LENGTH'))
- ) {
- return $_SERVER[$temp];
- }
-
- // This seems to be the only way to get the Authorization header on
- // Apache
- if (function_exists('apache_request_headers')) {
- $headers = apache_request_headers();
- if (isset($headers[$header])) {
- return $headers[$header];
- }
- $header = strtolower($header);
- foreach ($headers as $key => $value) {
- if (strtolower($key) == $header) {
- return $value;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Get the request URI scheme
- *
- * @return string
- */
- public function getScheme()
- {
- return ($this->getServer('HTTPS') == 'on') ? self::SCHEME_HTTPS : self::SCHEME_HTTP;
- }
-
- /**
- * Get the HTTP host.
- *
- * "Host" ":" host [ ":" port ] ; Section 3.2.2
- * Note the HTTP Host header is not the same as the URI host.
- * It includes the port while the URI host doesn't.
- *
- * @return string
- */
- public function getHttpHost()
- {
- $host = $this->getServer('HTTP_HOST');
- if (!empty($host)) {
- return $host;
- }
-
- $scheme = $this->getScheme();
- $name = $this->getServer('SERVER_NAME');
- $port = $this->getServer('SERVER_PORT');
-
- if(null === $name) {
- return '';
- }
- elseif (($scheme == self::SCHEME_HTTP && $port == 80) || ($scheme == self::SCHEME_HTTPS && $port == 443)) {
- return $name;
- } else {
- return $name . ':' . $port;
- }
- }
-
- /**
- * Get the client's IP addres
- *
- * @param boolean $checkProxy
- * @return string
- */
- public function getClientIp($checkProxy = true)
- {
- if ($checkProxy && $this->getServer('HTTP_CLIENT_IP') != null) {
- $ip = $this->getServer('HTTP_CLIENT_IP');
- } else if ($checkProxy && $this->getServer('HTTP_X_FORWARDED_FOR') != null) {
- $ip = $this->getServer('HTTP_X_FORWARDED_FOR');
- } else {
- $ip = $this->getServer('REMOTE_ADDR');
- }
-
- return $ip;
- }
-}
diff --git a/lib/zend/Zend/Controller/Request/HttpTestCase.php b/lib/zend/Zend/Controller/Request/HttpTestCase.php
deleted file mode 100644
index 58b9bd3936a99..0000000000000
--- a/lib/zend/Zend/Controller/Request/HttpTestCase.php
+++ /dev/null
@@ -1,277 +0,0 @@
-_rawBody = (string) $content;
- return $this;
- }
-
- /**
- * Get RAW POST body
- *
- * @return string|null
- */
- public function getRawBody()
- {
- return $this->_rawBody;
- }
-
- /**
- * Clear raw POST body
- *
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function clearRawBody()
- {
- $this->_rawBody = null;
- return $this;
- }
-
- /**
- * Set a cookie
- *
- * @param string $key
- * @param mixed $value
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setCookie($key, $value)
- {
- $_COOKIE[(string) $key] = $value;
- return $this;
- }
-
- /**
- * Set multiple cookies at once
- *
- * @param array $cookies
- * @return void
- */
- public function setCookies(array $cookies)
- {
- foreach ($cookies as $key => $value) {
- $_COOKIE[$key] = $value;
- }
- return $this;
- }
-
- /**
- * Clear all cookies
- *
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function clearCookies()
- {
- $_COOKIE = array();
- return $this;
- }
-
- /**
- * Set request method
- *
- * @param string $type
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setMethod($type)
- {
- $type = strtoupper(trim((string) $type));
- if (!in_array($type, $this->_validMethodTypes)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid request method specified');
- }
- $this->_method = $type;
- return $this;
- }
-
- /**
- * Get request method
- *
- * @return string|null
- */
- public function getMethod()
- {
- return $this->_method;
- }
-
- /**
- * Set a request header
- *
- * @param string $key
- * @param string $value
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setHeader($key, $value)
- {
- $key = $this->_normalizeHeaderName($key);
- $this->_headers[$key] = (string) $value;
- return $this;
- }
-
- /**
- * Set request headers
- *
- * @param array $headers
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setHeaders(array $headers)
- {
- foreach ($headers as $key => $value) {
- $this->setHeader($key, $value);
- }
- return $this;
- }
-
- /**
- * Get request header
- *
- * @param string $header
- * @param mixed $default
- * @return string|null
- */
- public function getHeader($header, $default = null)
- {
- $header = $this->_normalizeHeaderName($header);
- if (array_key_exists($header, $this->_headers)) {
- return $this->_headers[$header];
- }
- return $default;
- }
-
- /**
- * Get all request headers
- *
- * @return array
- */
- public function getHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Clear request headers
- *
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function clearHeaders()
- {
- $this->_headers = array();
- return $this;
- }
-
- /**
- * Get REQUEST_URI
- *
- * @return null|string
- */
- public function getRequestUri()
- {
- return $this->_requestUri;
- }
-
- /**
- * Normalize a header name for setting and retrieval
- *
- * @param string $name
- * @return string
- */
- protected function _normalizeHeaderName($name)
- {
- $name = strtoupper((string) $name);
- $name = str_replace('-', '_', $name);
- return $name;
- }
-}
diff --git a/lib/zend/Zend/Controller/Request/Simple.php b/lib/zend/Zend/Controller/Request/Simple.php
deleted file mode 100644
index 74e4b0c4a1031..0000000000000
--- a/lib/zend/Zend/Controller/Request/Simple.php
+++ /dev/null
@@ -1,55 +0,0 @@
-setActionName($action);
- }
-
- if ($controller) {
- $this->setControllerName($controller);
- }
-
- if ($module) {
- $this->setModuleName($module);
- }
-
- if ($params) {
- $this->setParams($params);
- }
- }
-
-}
diff --git a/lib/zend/Zend/Controller/Response/Abstract.php b/lib/zend/Zend/Controller/Response/Abstract.php
deleted file mode 100644
index 9fcc22693e570..0000000000000
--- a/lib/zend/Zend/Controller/Response/Abstract.php
+++ /dev/null
@@ -1,796 +0,0 @@
-canSendHeaders(true);
- $name = $this->_normalizeHeader($name);
- $value = (string) $value;
-
- if ($replace) {
- foreach ($this->_headers as $key => $header) {
- if ($name == $header['name']) {
- unset($this->_headers[$key]);
- }
- }
- }
-
- $this->_headers[] = array(
- 'name' => $name,
- 'value' => $value,
- 'replace' => $replace
- );
-
- return $this;
- }
-
- /**
- * Set redirect URL
- *
- * Sets Location header and response code. Forces replacement of any prior
- * redirects.
- *
- * @param string $url
- * @param int $code
- * @return Zend_Controller_Response_Abstract
- */
- public function setRedirect($url, $code = 302)
- {
- $this->canSendHeaders(true);
- $this->setHeader('Location', $url, true)
- ->setHttpResponseCode($code);
-
- return $this;
- }
-
- /**
- * Is this a redirect?
- *
- * @return boolean
- */
- public function isRedirect()
- {
- return $this->_isRedirect;
- }
-
- /**
- * Return array of headers; see {@link $_headers} for format
- *
- * @return array
- */
- public function getHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Clear headers
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function clearHeaders()
- {
- $this->_headers = array();
-
- return $this;
- }
-
- /**
- * Clears the specified HTTP header
- *
- * @param string $name
- * @return Zend_Controller_Response_Abstract
- */
- public function clearHeader($name)
- {
- if (! count($this->_headers)) {
- return $this;
- }
-
- foreach ($this->_headers as $index => $header) {
- if ($name == $header['name']) {
- unset($this->_headers[$index]);
- }
- }
-
- return $this;
- }
-
- /**
- * Set raw HTTP header
- *
- * Allows setting non key => value headers, such as status codes
- *
- * @param string $value
- * @return Zend_Controller_Response_Abstract
- */
- public function setRawHeader($value)
- {
- $this->canSendHeaders(true);
- if ('Location' == substr($value, 0, 8)) {
- $this->_isRedirect = true;
- }
- $this->_headersRaw[] = (string) $value;
- return $this;
- }
-
- /**
- * Retrieve all {@link setRawHeader() raw HTTP headers}
- *
- * @return array
- */
- public function getRawHeaders()
- {
- return $this->_headersRaw;
- }
-
- /**
- * Clear all {@link setRawHeader() raw HTTP headers}
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function clearRawHeaders()
- {
- $this->_headersRaw = array();
- return $this;
- }
-
- /**
- * Clears the specified raw HTTP header
- *
- * @param string $headerRaw
- * @return Zend_Controller_Response_Abstract
- */
- public function clearRawHeader($headerRaw)
- {
- if (! count($this->_headersRaw)) {
- return $this;
- }
-
- $key = array_search($headerRaw, $this->_headersRaw);
- if ($key !== false) {
- unset($this->_headersRaw[$key]);
- }
-
- return $this;
- }
-
- /**
- * Clear all headers, normal and raw
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function clearAllHeaders()
- {
- return $this->clearHeaders()
- ->clearRawHeaders();
- }
-
- /**
- * Set HTTP response code to use with headers
- *
- * @param int $code
- * @return Zend_Controller_Response_Abstract
- */
- public function setHttpResponseCode($code)
- {
- if (!is_int($code) || (100 > $code) || (599 < $code)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid HTTP response code');
- }
-
- if ((300 <= $code) && (307 >= $code)) {
- $this->_isRedirect = true;
- } else {
- $this->_isRedirect = false;
- }
-
- $this->_httpResponseCode = $code;
- return $this;
- }
-
- /**
- * Retrieve HTTP response code
- *
- * @return int
- */
- public function getHttpResponseCode()
- {
- return $this->_httpResponseCode;
- }
-
- /**
- * Can we send headers?
- *
- * @param boolean $throw Whether or not to throw an exception if headers have been sent; defaults to false
- * @return boolean
- * @throws Zend_Controller_Response_Exception
- */
- public function canSendHeaders($throw = false)
- {
- $ok = headers_sent($file, $line);
- if ($ok && $throw && $this->headersSentThrowsException) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Cannot send headers; headers already sent in ' . $file . ', line ' . $line);
- }
-
- return !$ok;
- }
-
- /**
- * Send all headers
- *
- * Sends any headers specified. If an {@link setHttpResponseCode() HTTP response code}
- * has been specified, it is sent with the first header.
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function sendHeaders()
- {
- // Only check if we can send headers if we have headers to send
- if (count($this->_headersRaw) || count($this->_headers) || (200 != $this->_httpResponseCode)) {
- $this->canSendHeaders(true);
- } elseif (200 == $this->_httpResponseCode) {
- // Haven't changed the response code, and we have no headers
- return $this;
- }
-
- $httpCodeSent = false;
-
- foreach ($this->_headersRaw as $header) {
- if (!$httpCodeSent && $this->_httpResponseCode) {
- header($header, true, $this->_httpResponseCode);
- $httpCodeSent = true;
- } else {
- header($header);
- }
- }
-
- foreach ($this->_headers as $header) {
- if (!$httpCodeSent && $this->_httpResponseCode) {
- header($header['name'] . ': ' . $header['value'], $header['replace'], $this->_httpResponseCode);
- $httpCodeSent = true;
- } else {
- header($header['name'] . ': ' . $header['value'], $header['replace']);
- }
- }
-
- if (!$httpCodeSent) {
- header('HTTP/1.1 ' . $this->_httpResponseCode);
- $httpCodeSent = true;
- }
-
- return $this;
- }
-
- /**
- * Set body content
- *
- * If $name is not passed, or is not a string, resets the entire body and
- * sets the 'default' key to $content.
- *
- * If $name is a string, sets the named segment in the body array to
- * $content.
- *
- * @param string $content
- * @param null|string $name
- * @return Zend_Controller_Response_Abstract
- */
- public function setBody($content, $name = null)
- {
- if ((null === $name) || !is_string($name)) {
- $this->_body = array('default' => (string) $content);
- } else {
- $this->_body[$name] = (string) $content;
- }
-
- return $this;
- }
-
- /**
- * Append content to the body content
- *
- * @param string $content
- * @param null|string $name
- * @return Zend_Controller_Response_Abstract
- */
- public function appendBody($content, $name = null)
- {
- if ((null === $name) || !is_string($name)) {
- if (isset($this->_body['default'])) {
- $this->_body['default'] .= (string) $content;
- } else {
- return $this->append('default', $content);
- }
- } elseif (isset($this->_body[$name])) {
- $this->_body[$name] .= (string) $content;
- } else {
- return $this->append($name, $content);
- }
-
- return $this;
- }
-
- /**
- * Clear body array
- *
- * With no arguments, clears the entire body array. Given a $name, clears
- * just that named segment; if no segment matching $name exists, returns
- * false to indicate an error.
- *
- * @param string $name Named segment to clear
- * @return boolean
- */
- public function clearBody($name = null)
- {
- if (null !== $name) {
- $name = (string) $name;
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- return true;
- }
-
- return false;
- }
-
- $this->_body = array();
- return true;
- }
-
- /**
- * Return the body content
- *
- * If $spec is false, returns the concatenated values of the body content
- * array. If $spec is boolean true, returns the body content array. If
- * $spec is a string and matches a named segment, returns the contents of
- * that segment; otherwise, returns null.
- *
- * @param boolean $spec
- * @return string|array|null
- */
- public function getBody($spec = false)
- {
- if (false === $spec) {
- ob_start();
- $this->outputBody();
- return ob_get_clean();
- } elseif (true === $spec) {
- return $this->_body;
- } elseif (is_string($spec) && isset($this->_body[$spec])) {
- return $this->_body[$spec];
- }
-
- return null;
- }
-
- /**
- * Append a named body segment to the body content array
- *
- * If segment already exists, replaces with $content and places at end of
- * array.
- *
- * @param string $name
- * @param string $content
- * @return Zend_Controller_Response_Abstract
- */
- public function append($name, $content)
- {
- if (!is_string($name)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment key ("' . gettype($name) . '")');
- }
-
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- }
- $this->_body[$name] = (string) $content;
- return $this;
- }
-
- /**
- * Prepend a named body segment to the body content array
- *
- * If segment already exists, replaces with $content and places at top of
- * array.
- *
- * @param string $name
- * @param string $content
- * @return void
- */
- public function prepend($name, $content)
- {
- if (!is_string($name)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment key ("' . gettype($name) . '")');
- }
-
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- }
-
- $new = array($name => (string) $content);
- $this->_body = $new + $this->_body;
-
- return $this;
- }
-
- /**
- * Insert a named segment into the body content array
- *
- * @param string $name
- * @param string $content
- * @param string $parent
- * @param boolean $before Whether to insert the new segment before or
- * after the parent. Defaults to false (after)
- * @return Zend_Controller_Response_Abstract
- */
- public function insert($name, $content, $parent = null, $before = false)
- {
- if (!is_string($name)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment key ("' . gettype($name) . '")');
- }
-
- if ((null !== $parent) && !is_string($parent)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment parent key ("' . gettype($parent) . '")');
- }
-
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- }
-
- if ((null === $parent) || !isset($this->_body[$parent])) {
- return $this->append($name, $content);
- }
-
- $ins = array($name => (string) $content);
- $keys = array_keys($this->_body);
- $loc = array_search($parent, $keys);
- if (!$before) {
- // Increment location if not inserting before
- ++$loc;
- }
-
- if (0 === $loc) {
- // If location of key is 0, we're prepending
- $this->_body = $ins + $this->_body;
- } elseif ($loc >= (count($this->_body))) {
- // If location of key is maximal, we're appending
- $this->_body = $this->_body + $ins;
- } else {
- // Otherwise, insert at location specified
- $pre = array_slice($this->_body, 0, $loc);
- $post = array_slice($this->_body, $loc);
- $this->_body = $pre + $ins + $post;
- }
-
- return $this;
- }
-
- /**
- * Echo the body segments
- *
- * @return void
- */
- public function outputBody()
- {
- $body = implode('', $this->_body);
- echo $body;
- }
-
- /**
- * Register an exception with the response
- *
- * @param Exception $e
- * @return Zend_Controller_Response_Abstract
- */
- public function setException(Exception $e)
- {
- $this->_exceptions[] = $e;
- return $this;
- }
-
- /**
- * Retrieve the exception stack
- *
- * @return array
- */
- public function getException()
- {
- return $this->_exceptions;
- }
-
- /**
- * Has an exception been registered with the response?
- *
- * @return boolean
- */
- public function isException()
- {
- return !empty($this->_exceptions);
- }
-
- /**
- * Does the response object contain an exception of a given type?
- *
- * @param string $type
- * @return boolean
- */
- public function hasExceptionOfType($type)
- {
- foreach ($this->_exceptions as $e) {
- if ($e instanceof $type) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Does the response object contain an exception with a given message?
- *
- * @param string $message
- * @return boolean
- */
- public function hasExceptionOfMessage($message)
- {
- foreach ($this->_exceptions as $e) {
- if ($message == $e->getMessage()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Does the response object contain an exception with a given code?
- *
- * @param int $code
- * @return boolean
- */
- public function hasExceptionOfCode($code)
- {
- $code = (int) $code;
- foreach ($this->_exceptions as $e) {
- if ($code == $e->getCode()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve all exceptions of a given type
- *
- * @param string $type
- * @return false|array
- */
- public function getExceptionByType($type)
- {
- $exceptions = array();
- foreach ($this->_exceptions as $e) {
- if ($e instanceof $type) {
- $exceptions[] = $e;
- }
- }
-
- if (empty($exceptions)) {
- $exceptions = false;
- }
-
- return $exceptions;
- }
-
- /**
- * Retrieve all exceptions of a given message
- *
- * @param string $message
- * @return false|array
- */
- public function getExceptionByMessage($message)
- {
- $exceptions = array();
- foreach ($this->_exceptions as $e) {
- if ($message == $e->getMessage()) {
- $exceptions[] = $e;
- }
- }
-
- if (empty($exceptions)) {
- $exceptions = false;
- }
-
- return $exceptions;
- }
-
- /**
- * Retrieve all exceptions of a given code
- *
- * @param mixed $code
- * @return void
- */
- public function getExceptionByCode($code)
- {
- $code = (int) $code;
- $exceptions = array();
- foreach ($this->_exceptions as $e) {
- if ($code == $e->getCode()) {
- $exceptions[] = $e;
- }
- }
-
- if (empty($exceptions)) {
- $exceptions = false;
- }
-
- return $exceptions;
- }
-
- /**
- * Whether or not to render exceptions (off by default)
- *
- * If called with no arguments or a null argument, returns the value of the
- * flag; otherwise, sets it and returns the current value.
- *
- * @param boolean $flag Optional
- * @return boolean
- */
- public function renderExceptions($flag = null)
- {
- if (null !== $flag) {
- $this->_renderExceptions = $flag ? true : false;
- }
-
- return $this->_renderExceptions;
- }
-
- /**
- * Send the response, including all headers, rendering exceptions if so
- * requested.
- *
- * @return void
- */
- public function sendResponse()
- {
- $this->sendHeaders();
-
- if ($this->isException() && $this->renderExceptions()) {
- $exceptions = '';
- foreach ($this->getException() as $e) {
- $exceptions .= $e->__toString() . "\n";
- }
- echo $exceptions;
- return;
- }
-
- $this->outputBody();
- }
-
- /**
- * Magic __toString functionality
- *
- * Proxies to {@link sendResponse()} and returns response value as string
- * using output buffering.
- *
- * @return string
- */
- public function __toString()
- {
- ob_start();
- $this->sendResponse();
- return ob_get_clean();
- }
-}
diff --git a/lib/zend/Zend/Controller/Response/Cli.php b/lib/zend/Zend/Controller/Response/Cli.php
deleted file mode 100644
index ed141659fa866..0000000000000
--- a/lib/zend/Zend/Controller/Response/Cli.php
+++ /dev/null
@@ -1,68 +0,0 @@
-isException() && $this->renderExceptions()) {
- $exceptions = '';
- foreach ($this->getException() as $e) {
- $exceptions .= $e->__toString() . "\n";
- }
- return $exceptions;
- }
-
- return $this->_body;
- }
-}
diff --git a/lib/zend/Zend/Controller/Response/Exception.php b/lib/zend/Zend/Controller/Response/Exception.php
deleted file mode 100644
index 9829fb66bc403..0000000000000
--- a/lib/zend/Zend/Controller/Response/Exception.php
+++ /dev/null
@@ -1,36 +0,0 @@
-_headersRaw as $header) {
- $headers[] = $header;
- }
- foreach ($this->_headers as $header) {
- $name = $header['name'];
- $key = strtolower($name);
- if (array_key_exists($name, $headers)) {
- if ($header['replace']) {
- $headers[$key] = $header['name'] . ': ' . $header['value'];
- }
- } else {
- $headers[$key] = $header['name'] . ': ' . $header['value'];
- }
- }
- return $headers;
- }
-
- /**
- * Can we send headers?
- *
- * @param bool $throw
- * @return void
- */
- public function canSendHeaders($throw = false)
- {
- return true;
- }
-
- /**
- * Return the concatenated body segments
- *
- * @return string
- */
- public function outputBody()
- {
- $fullContent = '';
- foreach ($this->_body as $content) {
- $fullContent .= $content;
- }
- return $fullContent;
- }
-
- /**
- * Get body and/or body segments
- *
- * @param bool|string $spec
- * @return string|array|null
- */
- public function getBody($spec = false)
- {
- if (false === $spec) {
- return $this->outputBody();
- } elseif (true === $spec) {
- return $this->_body;
- } elseif (is_string($spec) && isset($this->_body[$spec])) {
- return $this->_body[$spec];
- }
-
- return null;
- }
-
- /**
- * "send" Response
- *
- * Concats all response headers, and then final body (separated by two
- * newlines)
- *
- * @return string
- */
- public function sendResponse()
- {
- $headers = $this->sendHeaders();
- $content = implode("\n", $headers) . "\n\n";
-
- if ($this->isException() && $this->renderExceptions()) {
- $exceptions = '';
- foreach ($this->getException() as $e) {
- $exceptions .= $e->__toString() . "\n";
- }
- $content .= $exceptions;
- } else {
- $content .= $this->outputBody();
- }
-
- return $content;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Abstract.php b/lib/zend/Zend/Controller/Router/Abstract.php
deleted file mode 100644
index 71ed9473de56a..0000000000000
--- a/lib/zend/Zend/Controller/Router/Abstract.php
+++ /dev/null
@@ -1,178 +0,0 @@
-setParams($params);
- }
-
- /**
- * Add or modify a parameter to use when instantiating an action controller
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Router_Abstract
- */
- public function setParam($name, $value)
- {
- $name = (string)$name;
- $this->_invokeParams[$name] = $value;
-
- return $this;
- }
-
- /**
- * Set parameters to pass to action controller constructors
- *
- * @param array $params
- * @return Zend_Controller_Router_Abstract
- */
- public function setParams(array $params)
- {
- $this->_invokeParams = array_merge($this->_invokeParams, $params);
-
- return $this;
- }
-
- /**
- * Retrieve a single parameter from the controller parameter stack
- *
- * @param string $name
- * @return mixed
- */
- public function getParam($name)
- {
- if (isset($this->_invokeParams[$name])) {
- return $this->_invokeParams[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve action controller instantiation parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_invokeParams;
- }
-
- /**
- * Clear the controller parameter stack
- *
- * By default, clears all parameters. If a parameter name is given, clears
- * only that parameter; if an array of parameter names is provided, clears
- * each.
- *
- * @param null|string|array single key or array of keys for params to clear
- * @return Zend_Controller_Router_Abstract
- */
- public function clearParams($name = null)
- {
- if (null === $name) {
- $this->_invokeParams = array();
- } elseif (is_string($name) && isset($this->_invokeParams[$name])) {
- unset($this->_invokeParams[$name]);
- } elseif (is_array($name)) {
- foreach ($name as $key) {
- if (is_string($key) && isset($this->_invokeParams[$key])) {
- unset($this->_invokeParams[$key]);
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Retrieve Front Controller
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- // Used cache version if found
- if (null !== $this->_frontController) {
- return $this->_frontController;
- }
-
- require_once 'Zend/Controller/Front.php';
- $this->_frontController = Zend_Controller_Front::getInstance();
-
- return $this->_frontController;
- }
-
- /**
- * Set Front Controller
- *
- * @param Zend_Controller_Front $controller
- * @return Zend_Controller_Router_Interface
- */
- public function setFrontController(Zend_Controller_Front $controller)
- {
- $this->_frontController = $controller;
-
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Exception.php b/lib/zend/Zend/Controller/Router/Exception.php
deleted file mode 100644
index 2d0363330601b..0000000000000
--- a/lib/zend/Zend/Controller/Router/Exception.php
+++ /dev/null
@@ -1,35 +0,0 @@
-hasRoute('default')) {
- $dispatcher = $this->getFrontController()->getDispatcher();
- $request = $this->getFrontController()->getRequest();
-
- require_once 'Zend/Controller/Router/Route/Module.php';
- $compat = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request);
-
- $this->_routes = array('default' => $compat) + $this->_routes;
- }
-
- return $this;
- }
-
- /**
- * Add route to the route chain
- *
- * If route contains method setRequest(), it is initialized with a request object
- *
- * @param string $name Name of the route
- * @param Zend_Controller_Router_Route_Interface $route Instance of the route
- * @return Zend_Controller_Router_Rewrite
- */
- public function addRoute($name, Zend_Controller_Router_Route_Interface $route)
- {
- if (method_exists($route, 'setRequest')) {
- $route->setRequest($this->getFrontController()->getRequest());
- }
-
- $this->_routes[$name] = $route;
-
- return $this;
- }
-
- /**
- * Add routes to the route chain
- *
- * @param array $routes Array of routes with names as keys and routes as values
- * @return Zend_Controller_Router_Rewrite
- */
- public function addRoutes($routes)
- {
- foreach ($routes as $name => $route) {
- $this->addRoute($name, $route);
- }
-
- return $this;
- }
-
- /**
- * Create routes out of Zend_Config configuration
- *
- * Example INI:
- * routes.archive.route = "archive/:year/*"
- * routes.archive.defaults.controller = archive
- * routes.archive.defaults.action = show
- * routes.archive.defaults.year = 2000
- * routes.archive.reqs.year = "\d+"
- *
- * routes.news.type = "Zend_Controller_Router_Route_Static"
- * routes.news.route = "news"
- * routes.news.defaults.controller = "news"
- * routes.news.defaults.action = "list"
- *
- * And finally after you have created a Zend_Config with above ini:
- * $router = new Zend_Controller_Router_Rewrite();
- * $router->addConfig($config, 'routes');
- *
- * @param Zend_Config $config Configuration object
- * @param string $section Name of the config section containing route's definitions
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Rewrite
- */
- public function addConfig(Zend_Config $config, $section = null)
- {
- if ($section !== null) {
- if ($config->{$section} === null) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("No route configuration in section '{$section}'");
- }
-
- $config = $config->{$section};
- }
-
- foreach ($config as $name => $info) {
- $route = $this->_getRouteFromConfig($info);
-
- if ($route instanceof Zend_Controller_Router_Route_Chain) {
- if (!isset($info->chain)) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("No chain defined");
- }
-
- if ($info->chain instanceof Zend_Config) {
- $childRouteNames = $info->chain;
- } else {
- $childRouteNames = explode(',', $info->chain);
- }
-
- foreach ($childRouteNames as $childRouteName) {
- $childRoute = $this->getRoute(trim($childRouteName));
- $route->chain($childRoute);
- }
-
- $this->addRoute($name, $route);
- } elseif (isset($info->chains) && $info->chains instanceof Zend_Config) {
- $this->_addChainRoutesFromConfig($name, $route, $info->chains);
- } else {
- $this->addRoute($name, $route);
- }
- }
-
- return $this;
- }
-
- /**
- * Get a route frm a config instance
- *
- * @param Zend_Config $info
- * @return Zend_Controller_Router_Route_Interface
- */
- protected function _getRouteFromConfig(Zend_Config $info)
- {
- $class = (isset($info->type)) ? $info->type : 'Zend_Controller_Router_Route';
- if (!class_exists($class)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($class);
- }
-
- $route = call_user_func(
- array(
- $class,
- 'getInstance'
- ), $info
- );
-
- if (isset($info->abstract) && $info->abstract && method_exists($route, 'isAbstract')) {
- $route->isAbstract(true);
- }
-
- return $route;
- }
-
- /**
- * Add chain routes from a config route
- *
- * @param string $name
- * @param Zend_Controller_Router_Route_Interface $route
- * @param Zend_Config $childRoutesInfo
- * @return void
- */
- protected function _addChainRoutesFromConfig(
- $name,
- Zend_Controller_Router_Route_Interface $route,
- Zend_Config $childRoutesInfo
- )
- {
- foreach ($childRoutesInfo as $childRouteName => $childRouteInfo) {
- if (is_string($childRouteInfo)) {
- $childRouteName = $childRouteInfo;
- $childRoute = $this->getRoute($childRouteName);
- } else {
- $childRoute = $this->_getRouteFromConfig($childRouteInfo);
- }
-
- if ($route instanceof Zend_Controller_Router_Route_Chain) {
- $chainRoute = clone $route;
- $chainRoute->chain($childRoute);
- } else {
- $chainRoute = $route->chain($childRoute);
- }
-
- $chainName = $name . $this->_chainNameSeparator . $childRouteName;
-
- if (isset($childRouteInfo->chains)) {
- $this->_addChainRoutesFromConfig($chainName, $chainRoute, $childRouteInfo->chains);
- } else {
- $this->addRoute($chainName, $chainRoute);
- }
- }
- }
-
- /**
- * Remove a route from the route chain
- *
- * @param string $name Name of the route
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Rewrite
- */
- public function removeRoute($name)
- {
- if (!isset($this->_routes[$name])) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Route $name is not defined");
- }
-
- unset($this->_routes[$name]);
-
- return $this;
- }
-
- /**
- * Remove all standard default routes
- *
- * @return Zend_Controller_Router_Rewrite
- */
- public function removeDefaultRoutes()
- {
- $this->_useDefaultRoutes = false;
-
- return $this;
- }
-
- /**
- * Check if named route exists
- *
- * @param string $name Name of the route
- * @return boolean
- */
- public function hasRoute($name)
- {
- return isset($this->_routes[$name]);
- }
-
- /**
- * Retrieve a named route
- *
- * @param string $name Name of the route
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Route_Interface Route object
- */
- public function getRoute($name)
- {
- if (!isset($this->_routes[$name])) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Route $name is not defined");
- }
-
- return $this->_routes[$name];
- }
-
- /**
- * Retrieve a currently matched route
- *
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Route_Interface Route object
- */
- public function getCurrentRoute()
- {
- if (!isset($this->_currentRoute)) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Current route is not defined");
- }
-
- return $this->getRoute($this->_currentRoute);
- }
-
- /**
- * Retrieve a name of currently matched route
- *
- * @throws Zend_Controller_Router_Exception
- * @return string Route name
- */
- public function getCurrentRouteName()
- {
- if (!isset($this->_currentRoute)) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Current route is not defined");
- }
-
- return $this->_currentRoute;
- }
-
- /**
- * Retrieve an array of routes added to the route chain
- *
- * @return array All of the defined routes
- */
- public function getRoutes()
- {
- return $this->_routes;
- }
-
- /**
- * Find a matching route to the current PATH_INFO and inject
- * returning values to the Request object.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Request_Abstract Request object
- */
- public function route(Zend_Controller_Request_Abstract $request)
- {
- if (!$request instanceof Zend_Controller_Request_Http) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception(
- 'Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object'
- );
- }
-
- if ($this->_useDefaultRoutes) {
- $this->addDefaultRoutes();
- }
-
- // Find the matching route
- $routeMatched = false;
-
- foreach (array_reverse($this->_routes, true) as $name => $route) {
- // TODO: Should be an interface method. Hack for 1.0 BC
- if (method_exists($route, 'isAbstract') && $route->isAbstract()) {
- continue;
- }
-
- // TODO: Should be an interface method. Hack for 1.0 BC
- if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
- $match = $request->getPathInfo();
- } else {
- $match = $request;
- }
-
- if ($params = $route->match($match)) {
- $this->_setRequestParams($request, $params);
- $this->_currentRoute = $name;
- $routeMatched = true;
- break;
- }
- }
-
- if (!$routeMatched) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('No route matched the request', 404);
- }
-
- if ($this->_useCurrentParamsAsGlobal) {
- $params = $request->getParams();
- foreach ($params as $param => $value) {
- $this->setGlobalParam($param, $value);
- }
- }
-
- return $request;
- }
-
- /**
- * Sets parameters for request object
- *
- * Module name, controller name and action name
- *
- * @param Zend_Controller_Request_Abstract $request
- * @param array $params
- */
- protected function _setRequestParams($request, $params)
- {
- foreach ($params as $param => $value) {
-
- $request->setParam($param, $value);
-
- if ($param === $request->getModuleKey()) {
- $request->setModuleName($value);
- }
- if ($param === $request->getControllerKey()) {
- $request->setControllerName($value);
- }
- if ($param === $request->getActionKey()) {
- $request->setActionName($value);
- }
- }
- }
-
- /**
- * Generates a URL path that can be used in URL creation, redirection, etc.
- *
- * @param array $userParams Options passed by a user used to override parameters
- * @param mixed $name The name of a Route to use
- * @param bool $reset Whether to reset to the route defaults ignoring URL params
- * @param bool $encode Tells to encode URL parts on output
- * @throws Zend_Controller_Router_Exception
- * @return string Resulting absolute URL path
- */
- public function assemble($userParams, $name = null, $reset = false, $encode = true)
- {
- if (!is_array($userParams)) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('userParams must be an array');
- }
-
- if ($name == null) {
- try {
- $name = $this->getCurrentRouteName();
- } catch (Zend_Controller_Router_Exception $e) {
- $name = 'default';
- }
- }
-
- // Use UNION (+) in order to preserve numeric keys
- $params = $userParams + $this->_globalParams;
-
- $route = $this->getRoute($name);
- $url = $route->assemble($params, $reset, $encode);
-
- if (!preg_match('|^[a-z]+://|', $url)) {
- $url = rtrim($this->getFrontController()->getBaseUrl(), self::URI_DELIMITER) . self::URI_DELIMITER . $url;
- }
-
- return $url;
- }
-
- /**
- * Set a global parameter
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Router_Rewrite
- */
- public function setGlobalParam($name, $value)
- {
- $this->_globalParams[$name] = $value;
-
- return $this;
- }
-
- /**
- * Set the separator to use with chain names
- *
- * @param string $separator The separator to use
- * @return Zend_Controller_Router_Rewrite
- */
- public function setChainNameSeparator($separator)
- {
- $this->_chainNameSeparator = $separator;
-
- return $this;
- }
-
- /**
- * Get the separator to use for chain names
- *
- * @return string
- */
- public function getChainNameSeparator()
- {
- return $this->_chainNameSeparator;
- }
-
- /**
- * Determines/returns whether to use the request parameters as global parameters.
- *
- * @param boolean|null $use
- * Null/unset when you want to retrieve the current state.
- * True when request parameters should be global, false otherwise
- * @return boolean|Zend_Controller_Router_Rewrite
- * Returns a boolean if first param isn't set, returns an
- * instance of Zend_Controller_Router_Rewrite otherwise.
- *
- */
- public function useRequestParametersAsGlobal($use = null)
- {
- if ($use === null) {
- return $this->_useCurrentParamsAsGlobal;
- }
-
- $this->_useCurrentParamsAsGlobal = (bool)$use;
-
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Route.php b/lib/zend/Zend/Controller/Router/Route.php
deleted file mode 100644
index 927b97b3d342f..0000000000000
--- a/lib/zend/Zend/Controller/Router/Route.php
+++ /dev/null
@@ -1,605 +0,0 @@
-reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
- $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
-
- return new self($config->route, $defs, $reqs);
- }
-
- /**
- * Prepares the route for mapping by splitting (exploding) it
- * to a corresponding atomic parts. These parts are assigned
- * a position which is later used for matching and preparing values.
- *
- * @param string $route Map used to match with later submitted URL path
- * @param array $defaults Defaults for map variables with keys as variable names
- * @param array $reqs Regular expression requirements for variables (keys as variable names)
- * @param Zend_Translate $translator Translator to use for this instance
- * @param mixed|null $locale
- */
- public function __construct(
- $route, $defaults = array(), $reqs = array(), Zend_Translate $translator = null, $locale = null
- )
- {
- $route = trim($route, $this->_urlDelimiter);
- $this->_defaults = (array)$defaults;
- $this->_requirements = (array)$reqs;
- $this->_translator = $translator;
- $this->_locale = $locale;
-
- if ($route !== '') {
- foreach (explode($this->_urlDelimiter, $route) as $pos => $part) {
- if (substr($part, 0, 1) == $this->_urlVariable && substr($part, 1, 1) != $this->_urlVariable) {
- $name = substr($part, 1);
-
- if (substr($name, 0, 1) === '@' && substr($name, 1, 1) !== '@') {
- $name = substr($name, 1);
- $this->_translatable[] = $name;
- $this->_isTranslated = true;
- }
-
- $this->_parts[$pos] = (isset($reqs[$name]) ? $reqs[$name] : $this->_defaultRegex);
- $this->_variables[$pos] = $name;
- } else {
- if (substr($part, 0, 1) == $this->_urlVariable) {
- $part = substr($part, 1);
- }
-
- if (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@') {
- $this->_isTranslated = true;
- }
-
- $this->_parts[$pos] = $part;
-
- if ($part !== '*') {
- $this->_staticCount++;
- }
- }
- }
- }
- }
-
- /**
- * Matches a user submitted path with parts defined by a map. Assigns and
- * returns an array of variables on a successful match.
- *
- * @param string $path Path used to match against this routing map
- * @param boolean $partial
- * @throws Zend_Controller_Router_Exception
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- if ($this->_isTranslated) {
- $translateMessages = $this->getTranslator()->getMessages();
- }
-
- $pathStaticCount = 0;
- $values = array();
- $matchedPath = '';
-
- if (!$partial) {
- $path = trim($path, $this->_urlDelimiter);
- }
-
- if ($path !== '') {
- $path = explode($this->_urlDelimiter, $path);
-
- foreach ($path as $pos => $pathPart) {
- // Path is longer than a route, it's not a match
- if (!array_key_exists($pos, $this->_parts)) {
- if ($partial) {
- break;
- } else {
- return false;
- }
- }
-
- $matchedPath .= $pathPart . $this->_urlDelimiter;
-
- // If it's a wildcard, get the rest of URL as wildcard data and stop matching
- if ($this->_parts[$pos] == '*') {
- $count = count($path);
- for ($i = $pos; $i < $count; $i += 2) {
- $var = urldecode($path[$i]);
- if (!isset($this->_wildcardData[$var]) && !isset($this->_defaults[$var])
- && !isset($values[$var])
- ) {
- $this->_wildcardData[$var] = (isset($path[$i + 1])) ? urldecode($path[$i + 1]) : null;
- }
- }
-
- $matchedPath = implode($this->_urlDelimiter, $path);
- break;
- }
-
- $name = isset($this->_variables[$pos]) ? $this->_variables[$pos] : null;
- $pathPart = urldecode($pathPart);
-
- // Translate value if required
- $part = $this->_parts[$pos];
- if ($this->_isTranslated
- && (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@'
- && $name === null)
- || $name !== null && in_array($name, $this->_translatable)
- ) {
- if (substr($part, 0, 1) === '@') {
- $part = substr($part, 1);
- }
-
- if (($originalPathPart = array_search($pathPart, $translateMessages)) !== false) {
- $pathPart = $originalPathPart;
- }
- }
-
- if (substr($part, 0, 2) === '@@') {
- $part = substr($part, 1);
- }
-
- // If it's a static part, match directly
- if ($name === null && $part != $pathPart) {
- return false;
- }
-
- // If it's a variable with requirement, match a regex. If not - everything matches
- if ($part !== null
- && !preg_match(
- $this->_regexDelimiter . '^' . $part . '$' . $this->_regexDelimiter . 'iu', $pathPart
- )
- ) {
- return false;
- }
-
- // If it's a variable store it's value for later
- if ($name !== null) {
- $values[$name] = $pathPart;
- } else {
- $pathStaticCount++;
- }
- }
- }
-
- // Check if all static mappings have been matched
- if ($this->_staticCount != $pathStaticCount) {
- return false;
- }
-
- $return = $values + $this->_wildcardData + $this->_defaults;
-
- // Check if all map variables have been initialized
- foreach ($this->_variables as $var) {
- if (!array_key_exists($var, $return)) {
- return false;
- } elseif ($return[$var] == '' || $return[$var] === null) {
- // Empty variable? Replace with the default value.
- $return[$var] = $this->_defaults[$var];
- }
- }
-
- $this->setMatchedPath(rtrim($matchedPath, $this->_urlDelimiter));
-
- $this->_values = $values;
-
- return $return;
- }
-
- /**
- * Assembles user submitted parameters forming a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @param boolean $reset Whether or not to set route defaults with those provided in $data
- * @param boolean $encode
- * @param boolean $partial
- * @throws Zend_Controller_Router_Exception
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- if ($this->_isTranslated) {
- $translator = $this->getTranslator();
-
- if (isset($data['@locale'])) {
- $locale = $data['@locale'];
- unset($data['@locale']);
- } else {
- $locale = $this->getLocale();
- }
- }
-
- $url = array();
- $flag = false;
-
- foreach ($this->_parts as $key => $part) {
- $name = isset($this->_variables[$key]) ? $this->_variables[$key] : null;
-
- $useDefault = false;
- if (isset($name) && array_key_exists($name, $data) && $data[$name] === null) {
- $useDefault = true;
- }
-
- if (isset($name)) {
- if (isset($data[$name]) && !$useDefault) {
- $value = $data[$name];
- unset($data[$name]);
- } elseif (!$reset && !$useDefault && isset($this->_values[$name])) {
- $value = $this->_values[$name];
- } elseif (!$reset && !$useDefault && isset($this->_wildcardData[$name])) {
- $value = $this->_wildcardData[$name];
- } elseif (array_key_exists($name, $this->_defaults)) {
- $value = $this->_defaults[$name];
- } else {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception($name . ' is not specified');
- }
-
- if ($this->_isTranslated && in_array($name, $this->_translatable)) {
- $url[$key] = $translator->translate($value, $locale);
- } else {
- $url[$key] = $value;
- }
- } elseif ($part != '*') {
- if ($this->_isTranslated && substr($part, 0, 1) === '@') {
- if (substr($part, 1, 1) !== '@') {
- $url[$key] = $translator->translate(substr($part, 1), $locale);
- } else {
- $url[$key] = substr($part, 1);
- }
- } else {
- if (substr($part, 0, 2) === '@@') {
- $part = substr($part, 1);
- }
-
- $url[$key] = $part;
- }
- } else {
- if (!$reset) {
- $data += $this->_wildcardData;
- }
- $defaults = $this->getDefaults();
- foreach ($data as $var => $value) {
- if ($value !== null && (!isset($defaults[$var]) || $value != $defaults[$var])) {
- $url[$key++] = $var;
- $url[$key++] = $value;
- $flag = true;
- }
- }
- }
- }
-
- $return = '';
-
- foreach (array_reverse($url, true) as $key => $value) {
- $defaultValue = null;
-
- if (isset($this->_variables[$key])) {
- $defaultValue = $this->getDefault($this->_variables[$key]);
-
- if ($this->_isTranslated && $defaultValue !== null
- && isset($this->_translatable[$this->_variables[$key]])
- ) {
- $defaultValue = $translator->translate($defaultValue, $locale);
- }
- }
-
- if ($flag || $value !== $defaultValue || $partial) {
- if ($encode) {
- $value = urlencode($value);
- }
- $return = $this->_urlDelimiter . $value . $return;
- $flag = true;
- }
- }
-
- return trim($return, $this->_urlDelimiter);
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name)
- {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
-
- return null;
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults()
- {
- return $this->_defaults;
- }
-
- /**
- * Get all variables which are used by the route
- *
- * @return array
- */
- public function getVariables()
- {
- return $this->_variables;
- }
-
- /**
- * Set a default translator
- *
- * @param Zend_Translate $translator
- * @return void
- */
- public static function setDefaultTranslator(Zend_Translate $translator = null)
- {
- self::$_defaultTranslator = $translator;
- }
-
- /**
- * Get the default translator
- *
- * @return Zend_Translate
- */
- public static function getDefaultTranslator()
- {
- return self::$_defaultTranslator;
- }
-
- /**
- * Set a translator
- *
- * @param Zend_Translate $translator
- * @return void
- */
- public function setTranslator(Zend_Translate $translator)
- {
- $this->_translator = $translator;
- }
-
- /**
- * Get the translator
- *
- * @throws Zend_Controller_Router_Exception When no translator can be found
- * @return Zend_Translate
- */
- public function getTranslator()
- {
- if ($this->_translator !== null) {
- return $this->_translator;
- } else {
- if (($translator = self::getDefaultTranslator()) !== null) {
- return $translator;
- } else {
- try {
- $translator = Zend_Registry::get('Zend_Translate');
- } catch (Zend_Exception $e) {
- $translator = null;
- }
-
- if ($translator instanceof Zend_Translate) {
- return $translator;
- }
- }
- }
-
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('Could not find a translator');
- }
-
- /**
- * Set a default locale
- *
- * @param mixed $locale
- * @return void
- */
- public static function setDefaultLocale($locale = null)
- {
- self::$_defaultLocale = $locale;
- }
-
- /**
- * Get the default locale
- *
- * @return mixed
- */
- public static function getDefaultLocale()
- {
- return self::$_defaultLocale;
- }
-
- /**
- * Set a locale
- *
- * @param mixed $locale
- * @return void
- */
- public function setLocale($locale)
- {
- $this->_locale = $locale;
- }
-
- /**
- * Get the locale
- *
- * @return mixed
- */
- public function getLocale()
- {
- if ($this->_locale !== null) {
- return $this->_locale;
- } else {
- if (($locale = self::getDefaultLocale()) !== null) {
- return $locale;
- } else {
- try {
- $locale = Zend_Registry::get('Zend_Locale');
- } catch (Zend_Exception $e) {
- $locale = null;
- }
-
- if ($locale !== null) {
- return $locale;
- }
- }
- }
-
- return null;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Route/Abstract.php b/lib/zend/Zend/Controller/Router/Route/Abstract.php
deleted file mode 100644
index 2f6dc84807f41..0000000000000
--- a/lib/zend/Zend/Controller/Router/Route/Abstract.php
+++ /dev/null
@@ -1,121 +0,0 @@
-_matchedPath = $path;
- }
-
- /**
- * Get partially matched path
- *
- * @return string
- */
- public function getMatchedPath()
- {
- return $this->_matchedPath;
- }
-
- /**
- * Check or set wether this is an abstract route or not
- *
- * @param boolean $flag
- * @return boolean
- */
- public function isAbstract($flag = null)
- {
- if ($flag !== null) {
- $this->_isAbstract = $flag;
- }
-
- return $this->_isAbstract;
- }
-
- /**
- * Create a new chain
- *
- * @param Zend_Controller_Router_Route_Abstract $route
- * @param string $separator
- * @return Zend_Controller_Router_Route_Chain
- */
- public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/')
- {
- require_once 'Zend/Controller/Router/Route/Chain.php';
-
- $chain = new Zend_Controller_Router_Route_Chain();
- $chain->chain($this)->chain($route, $separator);
-
- return $chain;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Route/Chain.php b/lib/zend/Zend/Controller/Router/Route/Chain.php
deleted file mode 100644
index a474931ac51fd..0000000000000
--- a/lib/zend/Zend/Controller/Router/Route/Chain.php
+++ /dev/null
@@ -1,229 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
-
- return new self($config->route, $defs);
- }
-
- /**
- * Add a route to this chain
- *
- * @param Zend_Controller_Router_Route_Abstract $route
- * @param string $separator
- * @return Zend_Controller_Router_Route_Chain
- */
- public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = self::URI_DELIMITER)
- {
- $this->_routes[] = $route;
- $this->_separators[] = $separator;
-
- return $this;
- }
-
- /**
- * Matches a user submitted path with a previously defined route.
- * Assigns and returns an array of defaults on a successful match.
- *
- * @param Zend_Controller_Request_Http $request Request to get the path info from
- * @param null $partial
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($request, $partial = null)
- {
- $rawPath = $request->getPathInfo();
- $path = trim($request->getPathInfo(), self::URI_DELIMITER);
- $subPath = $path;
- $values = array();
- $matchedPath = null;
-
- foreach ($this->_routes as $key => $route) {
- if ($key > 0
- && $matchedPath !== null
- && $subPath !== ''
- && $subPath !== false
- ) {
- $separator = substr($subPath, 0, strlen($this->_separators[$key]));
-
- if ($separator !== $this->_separators[$key]) {
- $request->setPathInfo($rawPath);
- return false;
- }
-
- $subPath = substr($subPath, strlen($separator));
- }
- // TODO: Should be an interface method. Hack for 1.0 BC
- if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
- $match = $subPath;
- } else {
- $request->setPathInfo($subPath);
- $match = $request;
- }
-
- $res = $route->match($match, true);
-
- if ($res === false) {
- $request->setPathInfo($rawPath);
- return false;
- }
-
- $matchedPath = $route->getMatchedPath();
-
- if ($matchedPath !== null) {
- $subPath = substr($subPath, strlen($matchedPath));
- }
-
- $values = $res + $values;
- }
-
- $request->setPathInfo($path);
-
- if ($subPath !== '' && $subPath !== false) {
- return false;
- }
-
- return $values;
- }
-
- /**
- * Assembles a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @param bool $reset
- * @param bool $encode
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false)
- {
- $value = '';
- $numRoutes = count($this->_routes);
-
- foreach ($this->_routes as $key => $route) {
- if ($key > 0) {
- $value .= $this->_separators[$key];
- }
-
- $value .= $route->assemble($data, $reset, $encode, (($numRoutes - 1) > $key));
-
- if (method_exists($route, 'getVariables')) {
- $variables = $route->getVariables();
-
- foreach ($variables as $variable) {
- $data[$variable] = null;
- }
- }
- }
-
- return $value;
- }
-
- /**
- * Set the request object for this and the child routes
- *
- * @param Zend_Controller_Request_Abstract|null $request
- * @return void
- */
- public function setRequest(Zend_Controller_Request_Abstract $request = null)
- {
- $this->_request = $request;
-
- foreach ($this->_routes as $route) {
- if (method_exists($route, 'setRequest')) {
- $route->setRequest($request);
- }
- }
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name)
- {
- $default = null;
- foreach ($this->_routes as $route) {
- if (method_exists($route, 'getDefault')) {
- $current = $route->getDefault($name);
- if (null !== $current) {
- $default = $current;
- }
- }
- }
-
- return $default;
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults()
- {
- $defaults = array();
- foreach ($this->_routes as $route) {
- if (method_exists($route, 'getDefaults')) {
- $defaults = array_merge($defaults, $route->getDefaults());
- }
- }
-
- return $defaults;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Route/Hostname.php b/lib/zend/Zend/Controller/Router/Route/Hostname.php
deleted file mode 100644
index 2d33c61811a23..0000000000000
--- a/lib/zend/Zend/Controller/Router/Route/Hostname.php
+++ /dev/null
@@ -1,380 +0,0 @@
-_request = $request;
- }
-
- /**
- * Get the request object
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- if ($this->_request === null) {
- require_once 'Zend/Controller/Front.php';
- $this->_request = Zend_Controller_Front::getInstance()->getRequest();
- }
-
- return $this->_request;
- }
-
- /**
- * Instantiates route based on passed Zend_Config structure
- *
- * @param Zend_Config $config Configuration object
- * @return Zend_Controller_Router_Route_Hostname
- */
- public static function getInstance(Zend_Config $config)
- {
- $reqs = ($config->reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
- $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- $scheme = (isset($config->scheme)) ? $config->scheme : null;
-
- return new self($config->route, $defs, $reqs, $scheme);
- }
-
- /**
- * Prepares the route for mapping by splitting (exploding) it
- * to a corresponding atomic parts. These parts are assigned
- * a position which is later used for matching and preparing values.
- *
- * @param string $route Map used to match with later submitted hostname
- * @param array $defaults Defaults for map variables with keys as variable names
- * @param array $reqs Regular expression requirements for variables (keys as variable names)
- * @param string $scheme
- */
- public function __construct($route, $defaults = array(), $reqs = array(), $scheme = null)
- {
- $route = trim($route, '.');
- $this->_defaults = (array) $defaults;
- $this->_requirements = (array) $reqs;
- $this->_scheme = $scheme;
-
- if ($route != '') {
- foreach (explode('.', $route) as $pos => $part) {
- if (substr($part, 0, 1) == $this->_hostVariable) {
- $name = substr($part, 1);
- $this->_parts[$pos] = (isset($reqs[$name]) ? $reqs[$name] : $this->_defaultRegex);
- $this->_variables[$pos] = $name;
- } else {
- $this->_parts[$pos] = $part;
- $this->_staticCount++;
- }
- }
- }
- }
-
- /**
- * Matches a user submitted path with parts defined by a map. Assigns and
- * returns an array of variables on a successful match.
- *
- * @param Zend_Controller_Request_Http $request Request to get the host from
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($request)
- {
- // Check the scheme if required
- if ($this->_scheme !== null) {
- $scheme = $request->getScheme();
-
- if ($scheme !== $this->_scheme) {
- return false;
- }
- }
-
- // Get the host and remove unnecessary port information
- $host = $request->getHttpHost();
- if (preg_match('#:\d+$#', $host, $result) === 1) {
- $host = substr($host, 0, -strlen($result[0]));
- }
-
- $hostStaticCount = 0;
- $values = array();
-
- $host = trim($host, '.');
-
- if ($host != '') {
- $host = explode('.', $host);
-
- foreach ($host as $pos => $hostPart) {
- // Host is longer than a route, it's not a match
- if (!array_key_exists($pos, $this->_parts)) {
- return false;
- }
-
- $name = isset($this->_variables[$pos]) ? $this->_variables[$pos] : null;
- $hostPart = urldecode($hostPart);
-
- // If it's a static part, match directly
- if ($name === null && $this->_parts[$pos] != $hostPart) {
- return false;
- }
-
- // If it's a variable with requirement, match a regex. If not - everything matches
- if ($this->_parts[$pos] !== null
- && !preg_match(
- $this->_regexDelimiter . '^' . $this->_parts[$pos] . '$' . $this->_regexDelimiter . 'iu',
- $hostPart
- )
- ) {
- return false;
- }
-
- // If it's a variable store it's value for later
- if ($name !== null) {
- $values[$name] = $hostPart;
- } else {
- $hostStaticCount++;
- }
- }
- }
-
- // Check if all static mappings have been matched
- if ($this->_staticCount != $hostStaticCount) {
- return false;
- }
-
- $return = $values + $this->_defaults;
-
- // Check if all map variables have been initialized
- foreach ($this->_variables as $var) {
- if (!array_key_exists($var, $return)) {
- return false;
- }
- }
-
- $this->_values = $values;
-
- return $return;
- }
-
- /**
- * Assembles user submitted parameters forming a hostname defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @param boolean $reset Whether or not to set route defaults with those provided in $data
- * @param boolean $encode
- * @param boolean $partial
- * @throws Zend_Controller_Router_Exception
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- $host = array();
- $flag = false;
-
- foreach ($this->_parts as $key => $part) {
- $name = isset($this->_variables[$key]) ? $this->_variables[$key] : null;
-
- $useDefault = false;
- if (isset($name) && array_key_exists($name, $data) && $data[$name] === null) {
- $useDefault = true;
- }
-
- if (isset($name)) {
- if (isset($data[$name]) && !$useDefault) {
- $host[$key] = $data[$name];
- unset($data[$name]);
- } elseif (!$reset && !$useDefault && isset($this->_values[$name])) {
- $host[$key] = $this->_values[$name];
- } elseif (isset($this->_defaults[$name])) {
- $host[$key] = $this->_defaults[$name];
- } else {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception($name . ' is not specified');
- }
- } else {
- $host[$key] = $part;
- }
- }
-
- $return = '';
-
- foreach (array_reverse($host, true) as $key => $value) {
- if ($flag || !isset($this->_variables[$key]) || $value !== $this->getDefault($this->_variables[$key])
- || $partial
- ) {
- if ($encode) {
- $value = urlencode($value);
- }
- $return = '.' . $value . $return;
- $flag = true;
- }
- }
-
- $url = trim($return, '.');
-
- if ($this->_scheme !== null) {
- $scheme = $this->_scheme;
- } else {
- $request = $this->getRequest();
- if ($request instanceof Zend_Controller_Request_Http) {
- $scheme = $request->getScheme();
- } else {
- $scheme = 'http';
- }
- }
-
- $url = $scheme . '://' . $url;
-
- return $url;
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name)
- {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
-
- return null;
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults()
- {
- return $this->_defaults;
- }
-
- /**
- * Get all variables which are used by the route
- *
- * @return array
- */
- public function getVariables()
- {
- return $this->_variables;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Route/Interface.php b/lib/zend/Zend/Controller/Router/Route/Interface.php
deleted file mode 100644
index 6e82990f55738..0000000000000
--- a/lib/zend/Zend/Controller/Router/Route/Interface.php
+++ /dev/null
@@ -1,39 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- $dispatcher = $frontController->getDispatcher();
- $request = $frontController->getRequest();
-
- return new self($defs, $dispatcher, $request);
- }
-
- /**
- * Constructor
- *
- * @param array $defaults Defaults for map variables with keys as variable names
- * @param Zend_Controller_Dispatcher_Interface $dispatcher Dispatcher object
- * @param Zend_Controller_Request_Abstract $request Request object
- */
- public function __construct(
- array $defaults = array(),
- Zend_Controller_Dispatcher_Interface $dispatcher = null,
- Zend_Controller_Request_Abstract $request = null
- )
- {
- $this->_defaults = $defaults;
-
- if (isset($request)) {
- $this->_request = $request;
- }
-
- if (isset($dispatcher)) {
- $this->_dispatcher = $dispatcher;
- }
- }
-
- /**
- * Set request keys based on values in request object
- *
- * @return void
- */
- protected function _setRequestKeys()
- {
- if (null !== $this->_request) {
- $this->_moduleKey = $this->_request->getModuleKey();
- $this->_controllerKey = $this->_request->getControllerKey();
- $this->_actionKey = $this->_request->getActionKey();
- }
-
- if (null !== $this->_dispatcher) {
- $this->_defaults += array(
- $this->_controllerKey => $this->_dispatcher->getDefaultControllerName(),
- $this->_actionKey => $this->_dispatcher->getDefaultAction(),
- $this->_moduleKey => $this->_dispatcher->getDefaultModule()
- );
- }
-
- $this->_keysSet = true;
- }
-
- /**
- * Matches a user submitted path. Assigns and returns an array of variables
- * on a successful match.
- *
- * If a request object is registered, it uses its setModuleName(),
- * setControllerName(), and setActionName() accessors to set those values.
- * Always returns the values as an array.
- *
- * @param string $path Path used to match against this routing map
- * @param boolean $partial
- * @return array An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- $this->_setRequestKeys();
-
- $values = array();
- $params = array();
-
- if (!$partial) {
- $path = trim($path, self::URI_DELIMITER);
- } else {
- $matchedPath = $path;
- }
-
- if ($path != '') {
- $path = explode(self::URI_DELIMITER, $path);
-
- if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) {
- $values[$this->_moduleKey] = array_shift($path);
- $this->_moduleValid = true;
- }
-
- if (count($path) && !empty($path[0])) {
- $values[$this->_controllerKey] = array_shift($path);
- }
-
- if (count($path) && !empty($path[0])) {
- $values[$this->_actionKey] = array_shift($path);
- }
-
- if ($numSegs = count($path)) {
- for ($i = 0; $i < $numSegs; $i = $i + 2) {
- $key = urldecode($path[$i]);
- $val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
- $params[$key] = (isset($params[$key]) ? (array_merge((array)$params[$key], array($val))) : $val);
- }
- }
- }
-
- if ($partial) {
- $this->setMatchedPath($matchedPath);
- }
-
- $this->_values = $values + $params;
-
- return $this->_values + $this->_defaults;
- }
-
- /**
- * Assembles user submitted parameters forming a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @param boolean $reset Weither to reset the current params
- * @param boolean $encode
- * @param boolean $partial
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = true, $partial = false)
- {
- if (!$this->_keysSet) {
- $this->_setRequestKeys();
- }
-
- $params = (!$reset) ? $this->_values : array();
-
- foreach ($data as $key => $value) {
- if ($value !== null) {
- $params[$key] = $value;
- } elseif (isset($params[$key])) {
- unset($params[$key]);
- }
- }
-
- $params += $this->_defaults;
-
- $url = '';
-
- if ($this->_moduleValid || array_key_exists($this->_moduleKey, $data)) {
- if ($params[$this->_moduleKey] != $this->_defaults[$this->_moduleKey]) {
- $module = $params[$this->_moduleKey];
- }
- }
- unset($params[$this->_moduleKey]);
-
- $controller = $params[$this->_controllerKey];
- unset($params[$this->_controllerKey]);
-
- $action = $params[$this->_actionKey];
- unset($params[$this->_actionKey]);
-
- foreach ($params as $key => $value) {
- $key = ($encode) ? urlencode($key) : $key;
- if (is_array($value)) {
- foreach ($value as $arrayValue) {
- $arrayValue = ($encode) ? urlencode($arrayValue) : $arrayValue;
- $url .= self::URI_DELIMITER . $key;
- $url .= self::URI_DELIMITER . $arrayValue;
- }
- } else {
- if ($encode) {
- $value = urlencode($value);
- }
- $url .= self::URI_DELIMITER . $key;
- $url .= self::URI_DELIMITER . $value;
- }
- }
-
- if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) {
- if ($encode) {
- $action = urlencode($action);
- }
- $url = self::URI_DELIMITER . $action . $url;
- }
-
- if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) {
- if ($encode) {
- $controller = urlencode($controller);
- }
- $url = self::URI_DELIMITER . $controller . $url;
- }
-
- if (isset($module)) {
- if ($encode) {
- $module = urlencode($module);
- }
- $url = self::URI_DELIMITER . $module . $url;
- }
-
- return ltrim($url, self::URI_DELIMITER);
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name)
- {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults()
- {
- return $this->_defaults;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Route/Regex.php b/lib/zend/Zend/Controller/Router/Route/Regex.php
deleted file mode 100644
index e012357d7b3a1..0000000000000
--- a/lib/zend/Zend/Controller/Router/Route/Regex.php
+++ /dev/null
@@ -1,319 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- $map = ($config->map instanceof Zend_Config) ? $config->map->toArray() : array();
- $reverse = (isset($config->reverse)) ? $config->reverse : null;
-
- return new self($config->route, $defs, $map, $reverse);
- }
-
- /**
- * Constructor
- *
- * @param $route
- * @param array $defaults
- * @param array $map
- * @param null $reverse
- */
- public function __construct($route, $defaults = array(), $map = array(), $reverse = null)
- {
- $this->_regex = $route;
- $this->_defaults = (array) $defaults;
- $this->_map = (array) $map;
- $this->_reverse = $reverse;
- }
-
- /**
- * Get the version of the route
- *
- * @return int
- */
- public function getVersion()
- {
- return 1;
- }
-
- /**
- * Matches a user submitted path with a previously defined route.
- * Assigns and returns an array of defaults on a successful match.
- *
- * @param string $path Path used to match against this routing map
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- if (!$partial) {
- $path = trim(urldecode($path), self::URI_DELIMITER);
- $regex = '#^' . $this->_regex . '$#i';
- } else {
- $regex = '#^' . $this->_regex . '#i';
- }
-
- $res = preg_match($regex, $path, $values);
-
- if ($res === 0) {
- return false;
- }
-
- if ($partial) {
- $this->setMatchedPath($values[0]);
- }
-
- // array_filter_key()? Why isn't this in a standard PHP function set yet? :)
- foreach ($values as $i => $value) {
- if (!is_int($i) || $i === 0) {
- unset($values[$i]);
- }
- }
-
- $this->_values = $values;
-
- $values = $this->_getMappedValues($values);
- $defaults = $this->_getMappedValues($this->_defaults, false, true);
- $return = $values + $defaults;
-
- return $return;
- }
-
- /**
- * Maps numerically indexed array values to it's associative mapped counterpart.
- * Or vice versa. Uses user provided map array which consists of index => name
- * parameter mapping. If map is not found, it returns original array.
- *
- * Method strips destination type of keys form source array. Ie. if source array is
- * indexed numerically then every associative key will be stripped. Vice versa if reversed
- * is set to true.
- *
- * @param array $values Indexed or associative array of values to map
- * @param boolean $reversed False means translation of index to association. True means reverse.
- * @param boolean $preserve Should wrong type of keys be preserved or stripped.
- * @return array An array of mapped values
- */
- protected function _getMappedValues($values, $reversed = false, $preserve = false)
- {
- if (count($this->_map) == 0) {
- return $values;
- }
-
- $return = array();
-
- foreach ($values as $key => $value) {
- if (is_int($key) && !$reversed) {
- if (array_key_exists($key, $this->_map)) {
- $index = $this->_map[$key];
- } elseif (false === ($index = array_search($key, $this->_map))) {
- $index = $key;
- }
- $return[$index] = $values[$key];
- } elseif ($reversed) {
- $index = $key;
- if (!is_int($key)) {
- if (array_key_exists($key, $this->_map)) {
- $index = $this->_map[$key];
- } else {
- $index = array_search($key, $this->_map, true);
- }
- }
- if (false !== $index) {
- $return[$index] = $values[$key];
- }
- } elseif ($preserve) {
- $return[$key] = $value;
- }
- }
-
- return $return;
- }
-
- /**
- * Assembles a URL path defined by this route
- *
- * @param array $data An array of name (or index) and value pairs used as parameters
- * @param boolean $reset
- * @param boolean $encode
- * @param boolean $partial
- * @throws Zend_Controller_Router_Exception
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- if ($this->_reverse === null) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('Cannot assemble. Reversed route is not specified.');
- }
-
- $defaultValuesMapped = $this->_getMappedValues($this->_defaults, true, false);
- $matchedValuesMapped = $this->_getMappedValues($this->_values, true, false);
- $dataValuesMapped = $this->_getMappedValues($data, true, false);
-
- // handle resets, if so requested (By null value) to do so
- if (($resetKeys = array_search(null, $dataValuesMapped, true)) !== false) {
- foreach ((array)$resetKeys as $resetKey) {
- if (isset($matchedValuesMapped[$resetKey])) {
- unset($matchedValuesMapped[$resetKey]);
- unset($dataValuesMapped[$resetKey]);
- }
- }
- }
-
- // merge all the data together, first defaults, then values matched, then supplied
- $mergedData = $defaultValuesMapped;
- $mergedData = $this->_arrayMergeNumericKeys($mergedData, $matchedValuesMapped);
- $mergedData = $this->_arrayMergeNumericKeys($mergedData, $dataValuesMapped);
-
- if ($encode) {
- foreach ($mergedData as $key => &$value) {
- $value = urlencode($value);
- }
- }
-
- ksort($mergedData);
-
- $return = @vsprintf($this->_reverse, $mergedData);
-
- if ($return === false) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('Cannot assemble. Too few arguments?');
- }
-
- return $return;
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name)
- {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults()
- {
- return $this->_defaults;
- }
-
- /**
- * Get all variables which are used by the route
- *
- * @return array
- */
- public function getVariables()
- {
- $variables = array();
-
- foreach ($this->_map as $key => $value) {
- if (is_numeric($key)) {
- $variables[] = $value;
- } else {
- $variables[] = $key;
- }
- }
-
- return $variables;
- }
-
- /**
- * _arrayMergeNumericKeys() - allows for a strict key (numeric's included) array_merge.
- * php's array_merge() lacks the ability to merge with numeric keys.
- *
- * @param array $array1
- * @param array $array2
- * @return array
- */
- protected function _arrayMergeNumericKeys(Array $array1, Array $array2)
- {
- $returnArray = $array1;
- foreach ($array2 as $array2Index => $array2Value) {
- $returnArray[$array2Index] = $array2Value;
- }
-
- return $returnArray;
- }
-}
diff --git a/lib/zend/Zend/Controller/Router/Route/Static.php b/lib/zend/Zend/Controller/Router/Route/Static.php
deleted file mode 100644
index 4acd9f572ed27..0000000000000
--- a/lib/zend/Zend/Controller/Router/Route/Static.php
+++ /dev/null
@@ -1,149 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
-
- return new self($config->route, $defs);
- }
-
- /**
- * Prepares the route for mapping.
- *
- * @param string $route Map used to match with later submitted URL path
- * @param array $defaults Defaults for map variables with keys as variable names
- */
- public function __construct($route, $defaults = array())
- {
- $this->_route = trim($route, self::URI_DELIMITER);
- $this->_defaults = (array) $defaults;
- }
-
- /**
- * Matches a user submitted path with a previously defined route.
- * Assigns and returns an array of defaults on a successful match.
- *
- * @param string $path Path used to match against this routing map
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- if ($partial) {
- if ((empty($path) && empty($this->_route))
- || (substr($path, 0, strlen($this->_route)) === $this->_route)
- ) {
- $this->setMatchedPath($this->_route);
-
- return $this->_defaults;
- }
- } else {
- if (trim($path, self::URI_DELIMITER) == $this->_route) {
- return $this->_defaults;
- }
- }
-
- return false;
- }
-
- /**
- * Assembles a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- return $this->_route;
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name)
- {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
-
- return null;
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults()
- {
- return $this->_defaults;
- }
-}
diff --git a/lib/zend/Zend/Crypt.php b/lib/zend/Zend/Crypt.php
deleted file mode 100644
index 0ceeac71e33df..0000000000000
--- a/lib/zend/Zend/Crypt.php
+++ /dev/null
@@ -1,168 +0,0 @@
-setPrime($prime);
- $this->setGenerator($generator);
- if ($privateKey !== null) {
- $this->setPrivateKey($privateKey, $privateKeyType);
- }
- $this->setBigIntegerMath();
- }
-
- /**
- * Generate own public key. If a private number has not already been
- * set, one will be generated at this stage.
- *
- * @return Zend_Crypt_DiffieHellman
- */
- public function generateKeys()
- {
- if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
- $details = array();
- $details['p'] = $this->getPrime();
- $details['g'] = $this->getGenerator();
- if ($this->hasPrivateKey()) {
- $details['priv_key'] = $this->getPrivateKey();
- }
- $opensslKeyResource = openssl_pkey_new( array('dh' => $details) );
- $data = openssl_pkey_get_details($opensslKeyResource);
- $this->setPrivateKey($data['dh']['priv_key'], self::BINARY);
- $this->setPublicKey($data['dh']['pub_key'], self::BINARY);
- } else {
- // Private key is lazy generated in the absence of PHP 5.3's ext/openssl
- $publicKey = $this->_math->powmod($this->getGenerator(), $this->getPrivateKey(), $this->getPrime());
- $this->setPublicKey($publicKey);
- }
- return $this;
- }
-
- /**
- * Setter for the value of the public number
- *
- * @param string $number
- * @param string $type
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return Zend_Crypt_DiffieHellman
- */
- public function setPublicKey($number, $type = self::NUMBER)
- {
- if ($type == self::BINARY) {
- $number = $this->_math->fromBinary($number);
- }
- if (!preg_match("/^\d+$/", $number)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
- }
- $this->_publicKey = (string) $number;
- return $this;
- }
-
- /**
- * Returns own public key for communication to the second party to this
- * transaction.
- *
- * @param string $type
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return string
- */
- public function getPublicKey($type = self::NUMBER)
- {
- if ($this->_publicKey === null) {
- require_once 'Zend/Crypt/DiffieHellman/Exception.php';
- throw new Zend_Crypt_DiffieHellman_Exception('A public key has not yet been generated using a prior call to generateKeys()');
- }
- if ($type == self::BINARY) {
- return $this->_math->toBinary($this->_publicKey);
- } elseif ($type == self::BTWOC) {
- return $this->_math->btwoc($this->_math->toBinary($this->_publicKey));
- }
- return $this->_publicKey;
- }
-
- /**
- * Compute the shared secret key based on the public key received from the
- * the second party to this transaction. This should agree to the secret
- * key the second party computes on our own public key.
- * Once in agreement, the key is known to only to both parties.
- * By default, the function expects the public key to be in binary form
- * which is the typical format when being transmitted.
- *
- * If you need the binary form of the shared secret key, call
- * getSharedSecretKey() with the optional parameter for Binary output.
- *
- * @param string $publicKey
- * @param string $type
- * @param string $output
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return mixed
- */
- public function computeSecretKey($publicKey, $type = self::NUMBER, $output = self::NUMBER)
- {
- if ($type == self::BINARY) {
- $publicKey = $this->_math->fromBinary($publicKey);
- }
- if (!preg_match("/^\d+$/", $publicKey)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
- }
- if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
- $this->_secretKey = openssl_dh_compute_key($publicKey, $this->getPublicKey());
- } else {
- $this->_secretKey = $this->_math->powmod($publicKey, $this->getPrivateKey(), $this->getPrime());
- }
- return $this->getSharedSecretKey($output);
- }
-
- /**
- * Return the computed shared secret key from the DiffieHellman transaction
- *
- * @param string $type
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return string
- */
- public function getSharedSecretKey($type = self::NUMBER)
- {
- if (!isset($this->_secretKey)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('A secret key has not yet been computed; call computeSecretKey()');
- }
- if ($type == self::BINARY) {
- return $this->_math->toBinary($this->_secretKey);
- } elseif ($type == self::BTWOC) {
- return $this->_math->btwoc($this->_math->toBinary($this->_secretKey));
- }
- return $this->_secretKey;
- }
-
- /**
- * Setter for the value of the prime number
- *
- * @param string $number
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return Zend_Crypt_DiffieHellman
- */
- public function setPrime($number)
- {
- if (!preg_match("/^\d+$/", $number) || $number < 11) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number or too small: should be a large natural number prime');
- }
- $this->_prime = (string) $number;
- return $this;
- }
-
- /**
- * Getter for the value of the prime number
- *
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return string
- */
- public function getPrime()
- {
- if (!isset($this->_prime)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('No prime number has been set');
- }
- return $this->_prime;
- }
-
- /**
- * Setter for the value of the generator number
- *
- * @param string $number
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return Zend_Crypt_DiffieHellman
- */
- public function setGenerator($number)
- {
- if (!preg_match("/^\d+$/", $number) || $number < 2) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number greater than 1');
- }
- $this->_generator = (string) $number;
- return $this;
- }
-
- /**
- * Getter for the value of the generator number
- *
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return string
- */
- public function getGenerator()
- {
- if (!isset($this->_generator)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('No generator number has been set');
- }
- return $this->_generator;
- }
-
- /**
- * Setter for the value of the private number
- *
- * @param string $number
- * @param string $type
- * @throws Zend_Crypt_DiffieHellman_Exception
- * @return Zend_Crypt_DiffieHellman
- */
- public function setPrivateKey($number, $type = self::NUMBER)
- {
- if ($type == self::BINARY) {
- $number = $this->_math->fromBinary($number);
- }
- if (!preg_match("/^\d+$/", $number)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
- }
- $this->_privateKey = (string) $number;
- return $this;
- }
-
- /**
- * Getter for the value of the private number
- *
- * @param string $type
- * @return string
- */
- public function getPrivateKey($type = self::NUMBER)
- {
- if (!$this->hasPrivateKey()) {
- $this->setPrivateKey($this->_generatePrivateKey(), self::BINARY);
- }
- if ($type == self::BINARY) {
- return $this->_math->toBinary($this->_privateKey);
- } elseif ($type == self::BTWOC) {
- return $this->_math->btwoc($this->_math->toBinary($this->_privateKey));
- }
- return $this->_privateKey;
- }
-
- /**
- * Check whether a private key currently exists.
- *
- * @return boolean
- */
- public function hasPrivateKey()
- {
- return isset($this->_privateKey);
- }
-
- /**
- * Setter to pass an extension parameter which is used to create
- * a specific BigInteger instance for a specific extension type.
- * Allows manual setting of the class in case of an extension
- * problem or bug.
- *
- * @param string $extension
- * @return void
- */
- public function setBigIntegerMath($extension = null)
- {
- /**
- * @see Zend_Crypt_Math
- */
- require_once 'Zend/Crypt/Math.php';
- $this->_math = new Zend_Crypt_Math($extension);
- }
-
- /**
- * In the event a private number/key has not been set by the user,
- * or generated by ext/openssl, a best attempt will be made to
- * generate a random key. Having a random number generator installed
- * on linux/bsd is highly recommended! The alternative is not recommended
- * for production unless without any other option.
- *
- * @return string
- */
- protected function _generatePrivateKey()
- {
- $rand = $this->_math->rand($this->getGenerator(), $this->getPrime());
- return $rand;
- }
-
-}
diff --git a/lib/zend/Zend/Crypt/DiffieHellman/Exception.php b/lib/zend/Zend/Crypt/DiffieHellman/Exception.php
deleted file mode 100644
index 9afa43d671321..0000000000000
--- a/lib/zend/Zend/Crypt/DiffieHellman/Exception.php
+++ /dev/null
@@ -1,36 +0,0 @@
-80 using internal algo)
- * @todo Check if mhash() is a required alternative (will be PECL-only soon)
- * @category Zend
- * @package Zend_Crypt
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Crypt_Hmac extends Zend_Crypt
-{
-
- /**
- * The key to use for the hash
- *
- * @var string
- */
- protected static $_key = null;
-
- /**
- * pack() format to be used for current hashing method
- *
- * @var string
- */
- protected static $_packFormat = null;
-
- /**
- * Hashing algorithm; can be the md5/sha1 functions or any algorithm name
- * listed in the output of PHP 5.1.2+ hash_algos().
- *
- * @var string
- */
- protected static $_hashAlgorithm = 'md5';
-
- /**
- * List of algorithms supported my mhash()
- *
- * @var array
- */
- protected static $_supportedMhashAlgorithms = array('adler32',' crc32', 'crc32b', 'gost',
- 'haval128', 'haval160', 'haval192', 'haval256', 'md4', 'md5', 'ripemd160',
- 'sha1', 'sha256', 'tiger', 'tiger128', 'tiger160');
-
- /**
- * Constants representing the output mode of the hash algorithm
- */
- const STRING = 'string';
- const BINARY = 'binary';
-
- /**
- * Performs a HMAC computation given relevant details such as Key, Hashing
- * algorithm, the data to compute MAC of, and an output format of String,
- * Binary notation or BTWOC.
- *
- * @param string $key
- * @param string $hash
- * @param string $data
- * @param string $output
- * @throws Zend_Crypt_Hmac_Exception
- * @return string
- */
- public static function compute($key, $hash, $data, $output = self::STRING)
- {
- // set the key
- if (!isset($key) || empty($key)) {
- require_once 'Zend/Crypt/Hmac/Exception.php';
- throw new Zend_Crypt_Hmac_Exception('provided key is null or empty');
- }
- self::$_key = $key;
-
- // set the hash
- self::_setHashAlgorithm($hash);
-
- // perform hashing and return
- return self::_hash($data, $output);
- }
-
- /**
- * Setter for the hash method.
- *
- * @param string $hash
- * @throws Zend_Crypt_Hmac_Exception
- * @return Zend_Crypt_Hmac
- */
- protected static function _setHashAlgorithm($hash)
- {
- if (!isset($hash) || empty($hash)) {
- require_once 'Zend/Crypt/Hmac/Exception.php';
- throw new Zend_Crypt_Hmac_Exception('provided hash string is null or empty');
- }
-
- $hash = strtolower($hash);
- $hashSupported = false;
-
- if (function_exists('hash_algos') && in_array($hash, hash_algos())) {
- $hashSupported = true;
- }
-
- if ($hashSupported === false && function_exists('mhash') && in_array($hash, self::$_supportedAlgosMhash)) {
- $hashSupported = true;
- }
-
- if ($hashSupported === false) {
- require_once 'Zend/Crypt/Hmac/Exception.php';
- throw new Zend_Crypt_Hmac_Exception('hash algorithm provided is not supported on this PHP installation; please enable the hash or mhash extensions');
- }
- self::$_hashAlgorithm = $hash;
- }
-
- /**
- * Perform HMAC and return the keyed data
- *
- * @param string $data
- * @param string $output
- * @param bool $internal Option to not use hash() functions for testing
- * @return string
- */
- protected static function _hash($data, $output = self::STRING, $internal = false)
- {
- if (function_exists('hash_hmac')) {
- if ($output == self::BINARY) {
- return hash_hmac(self::$_hashAlgorithm, $data, self::$_key, true);
- }
- return hash_hmac(self::$_hashAlgorithm, $data, self::$_key);
- }
-
- if (function_exists('mhash')) {
- if ($output == self::BINARY) {
- return mhash(self::_getMhashDefinition(self::$_hashAlgorithm), $data, self::$_key);
- }
- $bin = mhash(self::_getMhashDefinition(self::$_hashAlgorithm), $data, self::$_key);
- return bin2hex($bin);
- }
- }
-
- /**
- * Since MHASH accepts an integer constant representing the hash algorithm
- * we need to make a small detour to get the correct integer matching our
- * algorithm's name.
- *
- * @param string $hashAlgorithm
- * @return integer
- */
- protected static function _getMhashDefinition($hashAlgorithm)
- {
- for ($i = 0; $i <= mhash_count(); $i++)
- {
- $types[mhash_get_hash_name($i)] = $i;
- }
- return $types[strtoupper($hashAlgorithm)];
- }
-
-}
diff --git a/lib/zend/Zend/Crypt/Hmac/Exception.php b/lib/zend/Zend/Crypt/Hmac/Exception.php
deleted file mode 100644
index 36acda37e765b..0000000000000
--- a/lib/zend/Zend/Crypt/Hmac/Exception.php
+++ /dev/null
@@ -1,36 +0,0 @@
- 127) {
- return "\x00" . $long;
- }
- return $long;
- }
-
- /**
- * Translate a binary form into a big integer string
- *
- * @param string $binary
- * @return string
- */
- public function fromBinary($binary) {
- return $this->_math->binaryToInteger($binary);
- }
-
- /**
- * Translate a big integer string into a binary form
- *
- * @param string $integer
- * @return string
- */
- public function toBinary($integer)
- {
- return $this->_math->integerToBinary($integer);
- }
-
-}
diff --git a/lib/zend/Zend/Crypt/Math/BigInteger.php b/lib/zend/Zend/Crypt/Math/BigInteger.php
deleted file mode 100644
index e066f608513ce..0000000000000
--- a/lib/zend/Zend/Crypt/Math/BigInteger.php
+++ /dev/null
@@ -1,118 +0,0 @@
-_loadAdapter($extension);
- }
-
- /**
- * Redirect all public method calls to the wrapped extension object.
- *
- * @param string $methodName
- * @param array $args
- * @return mixed
- * @throws Zend_Crypt_Math_BigInteger_Exception
- */
- public function __call($methodName, $args)
- {
- if(!method_exists($this->_math, $methodName)) {
- require_once 'Zend/Crypt/Math/BigInteger/Exception.php';
- throw new Zend_Crypt_Math_BigInteger_Exception('invalid method call: ' . get_class($this->_math) . '::' . $methodName . '() does not exist');
- }
- return call_user_func_array(array($this->_math, $methodName), $args);
- }
-
- /**
- * @param string $extension
- * @throws Zend_Crypt_Math_BigInteger_Exception
- */
- protected function _loadAdapter($extension = null)
- {
- if ($extension === null) {
- if (extension_loaded('gmp')) {
- $extension = 'gmp';
- //} elseif (extension_loaded('big_int')) {
- // $extension = 'big_int';
- } else {
- $extension = 'bcmath';
- }
- }
- if($extension == 'gmp' && extension_loaded('gmp')) {
- require_once 'Zend/Crypt/Math/BigInteger/Gmp.php';
- $this->_math = new Zend_Crypt_Math_BigInteger_Gmp();
- //} elseif($extension == 'bigint' && extension_loaded('big_int')) {
- // require_once 'Zend/Crypt_Math/BigInteger/Bigint.php';
- // $this->_math = new Zend_Crypt_Math_BigInteger_Bigint();
- } elseif ($extension == 'bcmath' && extension_loaded('bcmath')) {
- require_once 'Zend/Crypt/Math/BigInteger/Bcmath.php';
- $this->_math = new Zend_Crypt_Math_BigInteger_Bcmath();
- } else {
- require_once 'Zend/Crypt/Math/BigInteger/Exception.php';
- throw new Zend_Crypt_Math_BigInteger_Exception($extension . ' big integer precision math support not detected');
- }
- }
-
-}
diff --git a/lib/zend/Zend/Crypt/Math/BigInteger/Bcmath.php b/lib/zend/Zend/Crypt/Math/BigInteger/Bcmath.php
deleted file mode 100644
index 40154b6fbb05e..0000000000000
--- a/lib/zend/Zend/Crypt/Math/BigInteger/Bcmath.php
+++ /dev/null
@@ -1,227 +0,0 @@
- 0) {
- $return = chr(bcmod($operand, 256)) . $return;
- $operand = bcdiv($operand, 256);
- }
- if (ord($return[0]) > 127) {
- $return = "\0" . $return;
- }
- return $return;
- }
-
- /**public function integerToBinary($operand)
- {
- $return = '';
- while(bccomp($operand, '0')) {
- $return .= chr(bcmod($operand, '256'));
- $operand = bcdiv($operand, '256');
- }
- return $return;
- }**/ // Prior version for referenced offset
-
- /**
- * @param string $operand
- * @return string
- */
- public function hexToDecimal($operand)
- {
- $return = '0';
- while(strlen($hex)) {
- $hex = hexdec(substr($operand, 0, 4));
- $dec = bcadd(bcmul($return, 65536), $hex);
- $operand = substr($operand, 4);
- }
- return $return;
- }
-}
diff --git a/lib/zend/Zend/Crypt/Math/BigInteger/Exception.php b/lib/zend/Zend/Crypt/Math/BigInteger/Exception.php
deleted file mode 100644
index d5ee2e6ddf0af..0000000000000
--- a/lib/zend/Zend/Crypt/Math/BigInteger/Exception.php
+++ /dev/null
@@ -1,36 +0,0 @@
- '7') {
- $bigInt = '00' . $bigInt;
- }
- $return = pack("H*", $bigInt);
- return $return;
- }
-
- /**
- * @param string $operand
- * @return string
- */
- public function hexToDecimal($operand)
- {
- $return = '0';
- while(strlen($hex)) {
- $hex = hexdec(substr($operand, 0, 4));
- $dec = gmp_add(gmp_mul($return, 65536), $hex);
- $operand = substr($operand, 4);
- }
- return $return;
- }
-
-}
diff --git a/lib/zend/Zend/Crypt/Math/BigInteger/Interface.php b/lib/zend/Zend/Crypt/Math/BigInteger/Interface.php
deleted file mode 100644
index 9fa92815e30d0..0000000000000
--- a/lib/zend/Zend/Crypt/Math/BigInteger/Interface.php
+++ /dev/null
@@ -1,51 +0,0 @@
-_hashAlgorithm = OPENSSL_ALGO_SHA1;
-
- if (isset($options)) {
- $this->setOptions($options);
- }
- }
-
- public function setOptions(array $options)
- {
- if (isset($options['passPhrase'])) {
- $this->_passPhrase = $options['passPhrase'];
- }
- foreach ($options as $option=>$value) {
- switch ($option) {
- case 'pemString':
- $this->setPemString($value);
- break;
- case 'pemPath':
- $this->setPemPath($value);
- break;
- case 'certificateString':
- $this->setCertificateString($value);
- break;
- case 'certificatePath':
- $this->setCertificatePath($value);
- break;
- case 'hashAlgorithm':
- $this->setHashAlgorithm($value);
- break;
- }
- }
- }
-
- public function getPrivateKey()
- {
- return $this->_privateKey;
- }
-
- public function getPublicKey()
- {
- return $this->_publicKey;
- }
-
- /**
- * @param string $data
- * @param Zend_Crypt_Rsa_Key_Private $privateKey
- * @param string $format
- * @return string
- */
- public function sign($data, Zend_Crypt_Rsa_Key_Private $privateKey = null, $format = null)
- {
- $signature = '';
- if (isset($privateKey)) {
- $opensslKeyResource = $privateKey->getOpensslKeyResource();
- } else {
- $opensslKeyResource = $this->_privateKey->getOpensslKeyResource();
- }
- $result = openssl_sign(
- $data, $signature,
- $opensslKeyResource,
- $this->getHashAlgorithm()
- );
- if ($format == self::BASE64) {
- return base64_encode($signature);
- }
- return $signature;
- }
-
- /**
- * @param string $data
- * @param string $signature
- * @param string $format
- * @return string
- */
- public function verifySignature($data, $signature, $format = null)
- {
- if ($format == self::BASE64) {
- $signature = base64_decode($signature);
- }
- $result = openssl_verify($data, $signature,
- $this->getPublicKey()->getOpensslKeyResource(),
- $this->getHashAlgorithm());
- return $result;
- }
-
- /**
- * @param string $data
- * @param Zend_Crypt_Rsa_Key $key
- * @param string $format
- * @return string
- */
- public function encrypt($data, Zend_Crypt_Rsa_Key $key, $format = null)
- {
- $encrypted = '';
- $function = 'openssl_public_encrypt';
- if ($key instanceof Zend_Crypt_Rsa_Key_Private) {
- $function = 'openssl_private_encrypt';
- }
- $function($data, $encrypted, $key->getOpensslKeyResource());
- if ($format == self::BASE64) {
- return base64_encode($encrypted);
- }
- return $encrypted;
- }
-
- /**
- * @param string $data
- * @param Zend_Crypt_Rsa_Key $key
- * @param string $format
- * @return string
- */
- public function decrypt($data, Zend_Crypt_Rsa_Key $key, $format = null)
- {
- $decrypted = '';
- if ($format == self::BASE64) {
- $data = base64_decode($data);
- }
- $function = 'openssl_private_decrypt';
- if ($key instanceof Zend_Crypt_Rsa_Key_Public) {
- $function = 'openssl_public_decrypt';
- }
- $function($data, $decrypted, $key->getOpensslKeyResource());
- return $decrypted;
- }
-
- /**
- * @param array $configargs
- *
- * @throws Zend_Crypt_Rsa_Exception
- *
- * @return ArrayObject
- */
- public function generateKeys(array $configargs = null)
- {
- $config = null;
- $passPhrase = null;
- if ($configargs !== null) {
- if (isset($configargs['passPhrase'])) {
- $passPhrase = $configargs['passPhrase'];
- unset($configargs['passPhrase']);
- }
- $config = $this->_parseConfigArgs($configargs);
- }
- $privateKey = null;
- $publicKey = null;
- $resource = openssl_pkey_new($config);
- if (!$resource) {
- require_once 'Zend/Crypt/Rsa/Exception.php';
- throw new Zend_Crypt_Rsa_Exception('Failed to generate a new private key');
- }
- // above fails on PHP 5.3
- openssl_pkey_export($resource, $private, $passPhrase);
- $privateKey = new Zend_Crypt_Rsa_Key_Private($private, $passPhrase);
- $details = openssl_pkey_get_details($resource);
- $publicKey = new Zend_Crypt_Rsa_Key_Public($details['key']);
- $return = new ArrayObject(array(
- 'privateKey'=>$privateKey,
- 'publicKey'=>$publicKey
- ), ArrayObject::ARRAY_AS_PROPS);
- return $return;
- }
-
- /**
- * @param string $value
- */
- public function setPemString($value)
- {
- $this->_pemString = $value;
- try {
- $this->_privateKey = new Zend_Crypt_Rsa_Key_Private($this->_pemString, $this->_passPhrase);
- $this->_publicKey = $this->_privateKey->getPublicKey();
- } catch (Zend_Crypt_Exception $e) {
- $this->_privateKey = null;
- $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_pemString);
- }
- }
-
- public function setPemPath($value)
- {
- $this->_pemPath = $value;
- $this->setPemString(file_get_contents($this->_pemPath));
- }
-
- public function setCertificateString($value)
- {
- $this->_certificateString = $value;
- $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_certificateString, $this->_passPhrase);
- }
-
- public function setCertificatePath($value)
- {
- $this->_certificatePath = $value;
- $this->setCertificateString(file_get_contents($this->_certificatePath));
- }
-
- public function setHashAlgorithm($name)
- {
- switch (strtolower($name)) {
- case 'md2':
- $this->_hashAlgorithm = OPENSSL_ALGO_MD2;
- break;
- case 'md4':
- $this->_hashAlgorithm = OPENSSL_ALGO_MD4;
- break;
- case 'md5':
- $this->_hashAlgorithm = OPENSSL_ALGO_MD5;
- break;
- case 'sha1':
- $this->_hashAlgorithm = OPENSSL_ALGO_SHA1;
- break;
- case 'dss1':
- $this->_hashAlgorithm = OPENSSL_ALGO_DSS1;
- break;
- }
- }
-
- /**
- * @return string
- */
- public function getPemString()
- {
- return $this->_pemString;
- }
-
- public function getPemPath()
- {
- return $this->_pemPath;
- }
-
- public function getCertificateString()
- {
- return $this->_certificateString;
- }
-
- public function getCertificatePath()
- {
- return $this->_certificatePath;
- }
-
- public function getHashAlgorithm()
- {
- return $this->_hashAlgorithm;
- }
-
- protected function _parseConfigArgs(array $config = null)
- {
- $configs = array();
- if (isset($config['private_key_bits'])) {
- $configs['private_key_bits'] = $config['private_key_bits'];
- }
- if (isset($config['privateKeyBits'])) {
- $configs['private_key_bits'] = $config['privateKeyBits'];
- }
- if (!empty($configs)) {
- return $configs;
- }
- return null;
- }
-
-}
diff --git a/lib/zend/Zend/Crypt/Rsa/Exception.php b/lib/zend/Zend/Crypt/Rsa/Exception.php
deleted file mode 100644
index f1cf65e86acb5..0000000000000
--- a/lib/zend/Zend/Crypt/Rsa/Exception.php
+++ /dev/null
@@ -1,36 +0,0 @@
-_opensslKeyResource;
- }
-
- /**
- * @return string
- * @throws Zend_Crypt_Exception
- */
- public function toString()
- {
- if (!empty($this->_pemString)) {
- return $this->_pemString;
- } elseif (!empty($this->_certificateString)) {
- return $this->_certificateString;
- }
- /**
- * @see Zend_Crypt_Exception
- */
- require_once 'Zend/Crypt/Exception.php';
- throw new Zend_Crypt_Exception('No public key string representation is available');
- }
-
- /**
- * @return string
- */
- public function __toString()
- {
- return $this->toString();
- }
-
- public function count()
- {
- return $this->_details['bits'];
- }
-
- public function getType()
- {
- return $this->_details['type'];
- }
-}
diff --git a/lib/zend/Zend/Crypt/Rsa/Key/Private.php b/lib/zend/Zend/Crypt/Rsa/Key/Private.php
deleted file mode 100644
index 98b2e026c2455..0000000000000
--- a/lib/zend/Zend/Crypt/Rsa/Key/Private.php
+++ /dev/null
@@ -1,75 +0,0 @@
-_pemString = $pemString;
- $this->_parse($passPhrase);
- }
-
- /**
- * @param string $passPhrase
- * @throws Zend_Crypt_Exception
- */
- protected function _parse($passPhrase)
- {
- $result = openssl_get_privatekey($this->_pemString, $passPhrase);
- if (!$result) {
- /**
- * @see Zend_Crypt_Exception
- */
- require_once 'Zend/Crypt/Exception.php';
- throw new Zend_Crypt_Exception('Unable to load private key');
- }
- $this->_opensslKeyResource = $result;
- $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
- }
-
- public function getPublicKey()
- {
- if ($this->_publicKey === null) {
- /**
- * @see Zend_Crypt_Rsa_Key_Public
- */
- require_once 'Zend/Crypt/Rsa/Key/Public.php';
- $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_details['key']);
- }
- return $this->_publicKey;
- }
-
-}
diff --git a/lib/zend/Zend/Crypt/Rsa/Key/Public.php b/lib/zend/Zend/Crypt/Rsa/Key/Public.php
deleted file mode 100644
index 9694342d17bc2..0000000000000
--- a/lib/zend/Zend/Crypt/Rsa/Key/Public.php
+++ /dev/null
@@ -1,74 +0,0 @@
-_parse($string);
- }
-
- /**
- * @param string $string
- * @throws Zend_Crypt_Exception
- */
- protected function _parse($string)
- {
- if (preg_match("/^-----BEGIN CERTIFICATE-----/", $string)) {
- $this->_certificateString = $string;
- } else {
- $this->_pemString = $string;
- }
- $result = openssl_get_publickey($string);
- if (!$result) {
- /**
- * @see Zend_Crypt_Exception
- */
- require_once 'Zend/Crypt/Exception.php';
- throw new Zend_Crypt_Exception('Unable to load public key');
- }
- //openssl_pkey_export($result, $public);
- //$this->_pemString = $public;
- $this->_opensslKeyResource = $result;
- $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
- }
-
- public function getCertificate()
- {
- return $this->_certificateString;
- }
-
-}
diff --git a/lib/zend/Zend/Currency.php b/lib/zend/Zend/Currency.php
deleted file mode 100644
index 9abc8b1998990..0000000000000
--- a/lib/zend/Zend/Currency.php
+++ /dev/null
@@ -1,902 +0,0 @@
- Position for the currency sign
- * 'script' => Script for the output
- * 'format' => Locale for numeric output
- * 'display' => Currency detail to show
- * 'precision' => Precision for the currency
- * 'name' => Name for this currency
- * 'currency' => 3 lettered international abbreviation
- * 'symbol' => Currency symbol
- * 'locale' => Locale for this currency
- * 'value' => Money value
- * 'service' => Exchange service to use
- *
- * @var array
- * @see Zend_Locale
- */
- protected $_options = array(
- 'position' => self::STANDARD,
- 'script' => null,
- 'format' => null,
- 'display' => self::NO_SYMBOL,
- 'precision' => 2,
- 'name' => null,
- 'currency' => null,
- 'symbol' => null,
- 'locale' => null,
- 'value' => 0,
- 'service' => null,
- 'tag' => 'Zend_Locale'
- );
-
- /**
- * Creates a currency instance. Every supressed parameter is used from the actual or the given locale.
- *
- * @param string|array $options OPTIONAL Options array or currency short name
- * when string is given
- * @param string|Zend_Locale $locale OPTIONAL locale name
- * @throws Zend_Currency_Exception When currency is invalid
- */
- public function __construct($options = null, $locale = null)
- {
- $calloptions = $options;
- if (is_array($options) && isset($options['display'])) {
- $this->_options['display'] = $options['display'];
- }
-
- if (is_array($options)) {
- $this->setLocale($locale);
- $this->setFormat($options);
- } else if (Zend_Locale::isLocale($options, false, false)) {
- $this->setLocale($options);
- $options = $locale;
- } else {
- $this->setLocale($locale);
- }
-
- // Get currency details
- if (!isset($this->_options['currency']) || !is_array($options)) {
- $this->_options['currency'] = self::getShortName($options, $this->_options['locale']);
- }
-
- if (!isset($this->_options['name']) || !is_array($options)) {
- $this->_options['name'] = self::getName($options, $this->_options['locale']);
- }
-
- if (!isset($this->_options['symbol']) || !is_array($options)) {
- $this->_options['symbol'] = self::getSymbol($options, $this->_options['locale']);
- }
-
- if (($this->_options['currency'] === null) and ($this->_options['name'] === null)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Currency '$options' not found");
- }
-
- // Get the format
- if ((is_array($calloptions) && !isset($calloptions['display']))
- || (!is_array($calloptions) && $this->_options['display'] == self::NO_SYMBOL)) {
- if (!empty($this->_options['symbol'])) {
- $this->_options['display'] = self::USE_SYMBOL;
- } else if (!empty($this->_options['currency'])) {
- $this->_options['display'] = self::USE_SHORTNAME;
- }
- }
- }
-
- /**
- * Returns a localized currency string
- *
- * @param integer|float $value OPTIONAL Currency value
- * @param array $options OPTIONAL options to set temporary
- * @throws Zend_Currency_Exception When the value is not a number
- * @return string
- */
- public function toCurrency($value = null, array $options = array())
- {
- if ($value === null) {
- if (is_array($options) && isset($options['value'])) {
- $value = $options['value'];
- } else {
- $value = $this->_options['value'];
- }
- }
-
- if (is_array($value)) {
- $options += $value;
- if (isset($options['value'])) {
- $value = $options['value'];
- }
- }
-
- // Validate the passed number
- if (!(isset($value)) or (is_numeric($value) === false)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Value '$value' has to be numeric");
- }
-
- if (isset($options['currency'])) {
- if (!isset($options['locale'])) {
- $options['locale'] = $this->_options['locale'];
- }
-
- $options['currency'] = self::getShortName($options['currency'], $options['locale']);
- $options['name'] = self::getName($options['currency'], $options['locale']);
- $options['symbol'] = self::getSymbol($options['currency'], $options['locale']);
- }
-
- $options = $this->_checkOptions($options) + $this->_options;
-
- // Format the number
- $format = $options['format'];
- $locale = $options['locale'];
- if (empty($format)) {
- $format = Zend_Locale_Data::getContent($locale, 'currencynumber');
- } else if (Zend_Locale::isLocale($format, true, false)) {
- $locale = $format;
- $format = Zend_Locale_Data::getContent($format, 'currencynumber');
- }
-
- $original = $value;
- $value = Zend_Locale_Format::toNumber($value, array('locale' => $locale,
- 'number_format' => $format,
- 'precision' => $options['precision']));
-
- if ($options['position'] !== self::STANDARD) {
- $value = str_replace('¤', '', $value);
- $space = '';
- if (iconv_strpos($value, ' ') !== false) {
- $value = str_replace(' ', '', $value);
- $space = ' ';
- }
-
- if ($options['position'] == self::LEFT) {
- $value = '¤' . $space . $value;
- } else {
- $value = $value . $space . '¤';
- }
- }
-
- // Localize the number digits
- if (empty($options['script']) === false) {
- $value = Zend_Locale_Format::convertNumerals($value, 'Latn', $options['script']);
- }
-
- // Get the sign to be placed next to the number
- if (is_numeric($options['display']) === false) {
- $sign = $options['display'];
- } else {
- switch($options['display']) {
- case self::USE_SYMBOL:
- $sign = $this->_extractPattern($options['symbol'], $original);
- break;
-
- case self::USE_SHORTNAME:
- $sign = $options['currency'];
- break;
-
- case self::USE_NAME:
- $sign = $options['name'];
- break;
-
- default:
- $sign = '';
- $value = str_replace(' ', '', $value);
- break;
- }
- }
-
- $value = str_replace('¤', $sign, $value);
- return $value;
- }
-
- /**
- * Internal method to extract the currency pattern
- * when a choice is given based on the given value
- *
- * @param string $pattern
- * @param float|integer $value
- * @return string
- */
- private function _extractPattern($pattern, $value)
- {
- if (strpos($pattern, '|') === false) {
- return $pattern;
- }
-
- $patterns = explode('|', $pattern);
- $token = $pattern;
- $value = trim(str_replace('¤', '', $value));
- krsort($patterns);
- foreach($patterns as $content) {
- if (strpos($content, '<') !== false) {
- $check = iconv_substr($content, 0, iconv_strpos($content, '<'));
- $token = iconv_substr($content, iconv_strpos($content, '<') + 1);
- if ($check < $value) {
- return $token;
- }
- } else {
- $check = iconv_substr($content, 0, iconv_strpos($content, '≤'));
- $token = iconv_substr($content, iconv_strpos($content, '≤') + 1);
- if ($check <= $value) {
- return $token;
- }
- }
-
- }
-
- return $token;
- }
-
- /**
- * Sets the formating options of the localized currency string
- * If no parameter is passed, the standard setting of the
- * actual set locale will be used
- *
- * @param array $options (Optional) Options to set
- * @return Zend_Currency
- */
- public function setFormat(array $options = array())
- {
- $this->_options = $this->_checkOptions($options) + $this->_options;
- return $this;
- }
-
- /**
- * Internal function for checking static given locale parameter
- *
- * @param string $currency (Optional) Currency name
- * @param string|Zend_Locale $locale (Optional) Locale to display informations
- * @throws Zend_Currency_Exception When locale contains no region
- * @return string The extracted locale representation as string
- */
- private function _checkParams($currency = null, $locale = null)
- {
- // Manage the params
- if ((empty($locale)) and (!empty($currency)) and
- (Zend_Locale::isLocale($currency, true, false))) {
- $locale = $currency;
- $currency = null;
- }
-
- // Validate the locale and get the country short name
- $country = null;
- if ((Zend_Locale::isLocale($locale, true, false)) and (strlen($locale) > 4)) {
- $country = substr($locale, (strpos($locale, '_') + 1));
- } else {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("No region found within the locale '" . (string) $locale . "'");
- }
-
- // Get the available currencies for this country
- $data = Zend_Locale_Data::getContent($locale, 'currencytoregion', $country);
- if ((empty($currency) === false) and (empty($data) === false)) {
- $abbreviation = $currency;
- } else {
- $abbreviation = $data;
- }
-
- return array('locale' => $locale, 'currency' => $currency, 'name' => $abbreviation, 'country' => $country);
- }
-
- /**
- * Returns the actual or details of other currency symbols,
- * when no symbol is available it returns the currency shortname (f.e. FIM for Finnian Mark)
- *
- * @param string $currency (Optional) Currency name
- * @param string|Zend_Locale $locale (Optional) Locale to display informations
- * @return string
- */
- public function getSymbol($currency = null, $locale = null)
- {
- if (($currency === null) and ($locale === null)) {
- return $this->_options['symbol'];
- }
-
- $params = self::_checkParams($currency, $locale);
-
- // Get the symbol
- $symbol = Zend_Locale_Data::getContent($params['locale'], 'currencysymbol', $params['currency']);
- if (empty($symbol) === true) {
- $symbol = Zend_Locale_Data::getContent($params['locale'], 'currencysymbol', $params['name']);
- }
-
- if (empty($symbol) === true) {
- return null;
- }
-
- return $symbol;
- }
-
- /**
- * Returns the actual or details of other currency shortnames
- *
- * @param string $currency OPTIONAL Currency's name
- * @param string|Zend_Locale $locale OPTIONAL The locale
- * @return string
- */
- public function getShortName($currency = null, $locale = null)
- {
- if (($currency === null) and ($locale === null)) {
- return $this->_options['currency'];
- }
-
- $params = self::_checkParams($currency, $locale);
-
- // Get the shortname
- if (empty($params['currency']) === true) {
- return $params['name'];
- }
-
- $list = Zend_Locale_Data::getContent($params['locale'], 'currencytoname', $params['currency']);
- if (empty($list) === true) {
- $list = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['currency']);
- if (empty($list) === false) {
- $list = $params['currency'];
- }
- }
-
- if (empty($list) === true) {
- return null;
- }
-
- return $list;
- }
-
- /**
- * Returns the actual or details of other currency names
- *
- * @param string $currency (Optional) Currency's short name
- * @param string|Zend_Locale $locale (Optional) The locale
- * @return string
- */
- public function getName($currency = null, $locale = null)
- {
- if (($currency === null) and ($locale === null)) {
- return $this->_options['name'];
- }
-
- $params = self::_checkParams($currency, $locale);
-
- // Get the name
- $name = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['currency']);
- if (empty($name) === true) {
- $name = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['name']);
- }
-
- if (empty($name) === true) {
- return null;
- }
-
- return $name;
- }
-
- /**
- * Returns a list of regions where this currency is or was known
- *
- * @param string $currency OPTIONAL Currency's short name
- * @throws Zend_Currency_Exception When no currency was defined
- * @return array List of regions
- */
- public function getRegionList($currency = null)
- {
- if ($currency === null) {
- $currency = $this->_options['currency'];
- }
-
- if (empty($currency) === true) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception('No currency defined');
- }
-
- $data = Zend_Locale_Data::getContent($this->_options['locale'], 'regiontocurrency', $currency);
-
- $result = explode(' ', $data);
- return $result;
- }
-
- /**
- * Returns a list of currencies which are used in this region
- * a region name should be 2 charachters only (f.e. EG, DE, US)
- * If no region is given, the actual region is used
- *
- * @param string $region OPTIONAL Region to return the currencies for
- * @return array List of currencies
- */
- public function getCurrencyList($region = null)
- {
- if (empty($region) === true) {
- if (strlen($this->_options['locale']) > 4) {
- $region = substr($this->_options['locale'], (strpos($this->_options['locale'], '_') + 1));
- }
- }
-
- $data = Zend_Locale_Data::getContent($this->_options['locale'], 'currencytoregion', $region);
-
- $result = explode(' ', $data);
- return $result;
- }
-
- /**
- * Returns the actual currency name
- *
- * @return string
- */
- public function toString()
- {
- return $this->toCurrency();
- }
-
- /**
- * Returns the currency name
- *
- * @return string
- */
- public function __toString()
- {
- return $this->toString();
- }
-
- /**
- * Returns the set cache
- *
- * @return Zend_Cache_Core The set cache
- */
- public static function getCache()
- {
- return Zend_Locale_Data::getCache();
- }
-
- /**
- * Sets a cache for Zend_Currency
- *
- * @param Zend_Cache_Core $cache Cache to set
- * @return void
- */
- public static function setCache(Zend_Cache_Core $cache)
- {
- Zend_Locale_Data::setCache($cache);
- }
-
- /**
- * Returns true when a cache is set
- *
- * @return boolean
- */
- public static function hasCache()
- {
- return Zend_Locale_Data::hasCache();
- }
-
- /**
- * Removes any set cache
- *
- * @return void
- */
- public static function removeCache()
- {
- Zend_Locale_Data::removeCache();
- }
-
- /**
- * Clears all set cache data
- *
- * @param string $tag Tag to clear when the default tag name is not used
- * @return void
- */
- public static function clearCache($tag = null)
- {
- Zend_Locale_Data::clearCache($tag);
- }
-
- /**
- * Sets a new locale for data retreivement
- * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist
- * 'xx_YY' will be set to 'root' because 'xx' does not exist
- *
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @throws Zend_Currency_Exception When the given locale does not exist
- * @return Zend_Currency Provides fluent interface
- */
- public function setLocale($locale = null)
- {
- require_once 'Zend/Locale.php';
- try {
- $locale = Zend_Locale::findLocale($locale);
- if (strlen($locale) > 4) {
- $this->_options['locale'] = $locale;
- } else {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("No region found within the locale '" . (string) $locale . "'");
- }
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception($e->getMessage());
- }
-
- // Get currency details
- $this->_options['currency'] = $this->getShortName(null, $this->_options['locale']);
- $this->_options['name'] = $this->getName(null, $this->_options['locale']);
- $this->_options['symbol'] = $this->getSymbol(null, $this->_options['locale']);
-
- return $this;
- }
-
- /**
- * Returns the actual set locale
- *
- * @return string
- */
- public function getLocale()
- {
- return $this->_options['locale'];
- }
-
- /**
- * Returns the value
- *
- * @return float
- */
- public function getValue()
- {
- return $this->_options['value'];
- }
-
- /**
- * Adds a currency
- *
- * @param float|integer|Zend_Currency $value Add this value to currency
- * @param string|Zend_Currency $currency The currency to add
- * @return Zend_Currency
- */
- public function setValue($value, $currency = null)
- {
- $this->_options['value'] = $this->_exchangeCurrency($value, $currency);
- return $this;
- }
-
- /**
- * Adds a currency
- *
- * @param float|integer|Zend_Currency $value Add this value to currency
- * @param string|Zend_Currency $currency The currency to add
- * @return Zend_Currency
- */
- public function add($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] += (float) $value;
- return $this;
- }
-
- /**
- * Substracts a currency
- *
- * @param float|integer|Zend_Currency $value Substracts this value from currency
- * @param string|Zend_Currency $currency The currency to substract
- * @return Zend_Currency
- */
- public function sub($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] -= (float) $value;
- return $this;
- }
-
- /**
- * Divides a currency
- *
- * @param float|integer|Zend_Currency $value Divides this value from currency
- * @param string|Zend_Currency $currency The currency to divide
- * @return Zend_Currency
- */
- public function div($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] /= (float) $value;
- return $this;
- }
-
- /**
- * Multiplies a currency
- *
- * @param float|integer|Zend_Currency $value Multiplies this value from currency
- * @param string|Zend_Currency $currency The currency to multiply
- * @return Zend_Currency
- */
- public function mul($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] *= (float) $value;
- return $this;
- }
-
- /**
- * Calculates the modulo from a currency
- *
- * @param float|integer|Zend_Currency $value Calculate modulo from this value
- * @param string|Zend_Currency $currency The currency to calculate the modulo
- * @return Zend_Currency
- */
- public function mod($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] %= (float) $value;
- return $this;
- }
-
- /**
- * Compares two currencies
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return Zend_Currency
- */
- public function compare($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $value = $this->_options['value'] - $value;
- if ($value < 0) {
- return -1;
- } else if ($value > 0) {
- return 1;
- }
-
- return 0;
- }
-
- /**
- * Returns true when the two currencies are equal
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return boolean
- */
- public function equals($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] == $value) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true when the currency is more than the given value
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return boolean
- */
- public function isMore($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] > $value) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true when the currency is less than the given value
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return boolean
- */
- public function isLess($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] < $value) {
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Internal method which calculates the exchanges currency
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return unknown
- */
- protected function _exchangeCurrency($value, $currency)
- {
- if ($value instanceof Zend_Currency) {
- $currency = $value->getShortName();
- $value = $value->getValue();
- } else {
- $currency = $this->getShortName($currency, $this->getLocale());
- }
-
- $rate = 1;
- if ($currency !== $this->getShortName()) {
- $service = $this->getService();
- if (!($service instanceof Zend_Currency_CurrencyInterface)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception('No exchange service applied');
- }
-
- $rate = $service->getRate($currency, $this->getShortName());
- }
-
- $value *= $rate;
- return $value;
- }
-
- /**
- * Returns the set service class
- *
- * @return Zend_Service
- */
- public function getService()
- {
- return $this->_options['service'];
- }
-
- /**
- * Sets a new exchange service
- *
- * @param string|Zend_Currency_CurrencyInterface $service Service class
- * @return Zend_Currency
- */
- public function setService($service)
- {
- if (is_string($service)) {
- require_once 'Zend/Loader.php';
- if (!class_exists($service)) {
- $file = str_replace('_', DIRECTORY_SEPARATOR, $service) . '.php';
- if (Zend_Loader::isReadable($file)) {
- Zend_Loader::loadClass($service);
- }
- }
-
- $service = new $service;
- }
-
- if (!($service instanceof Zend_Currency_CurrencyInterface)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception('A currency service must implement Zend_Currency_CurrencyInterface');
- }
-
- $this->_options['service'] = $service;
- return $this;
- }
-
- /**
- * Internal method for checking the options array
- *
- * @param array $options Options to check
- * @throws Zend_Currency_Exception On unknown position
- * @throws Zend_Currency_Exception On unknown locale
- * @throws Zend_Currency_Exception On unknown display
- * @throws Zend_Currency_Exception On precision not between -1 and 30
- * @throws Zend_Currency_Exception On problem with script conversion
- * @throws Zend_Currency_Exception On unknown options
- * @return array
- */
- protected function _checkOptions(array $options = array())
- {
- if (count($options) === 0) {
- return $this->_options;
- }
-
- foreach ($options as $name => $value) {
- $name = strtolower($name);
- if ($name !== 'format') {
- if (gettype($value) === 'string') {
- $value = strtolower($value);
- }
- }
-
- switch($name) {
- case 'position':
- if (($value !== self::STANDARD) and ($value !== self::RIGHT) and ($value !== self::LEFT)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Unknown position '" . $value . "'");
- }
-
- break;
-
- case 'format':
- if ((empty($value) === false) and (Zend_Locale::isLocale($value, null, false) === false)) {
- if (!is_string($value) || (strpos($value, '0') === false)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("'" .
- ((gettype($value) === 'object') ? get_class($value) : $value)
- . "' is no format token");
- }
- }
- break;
-
- case 'display':
- if (is_numeric($value) and ($value !== self::NO_SYMBOL) and ($value !== self::USE_SYMBOL) and
- ($value !== self::USE_SHORTNAME) and ($value !== self::USE_NAME)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Unknown display '$value'");
- }
- break;
-
- case 'precision':
- if ($value === null) {
- $value = -1;
- }
-
- if (($value < -1) or ($value > 30)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("'$value' precision has to be between -1 and 30.");
- }
- break;
-
- case 'script':
- try {
- Zend_Locale_Format::convertNumerals(0, $options['script']);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception($e->getMessage());
- }
- break;
-
- default:
- break;
- }
- }
-
- return $options;
- }
-}
diff --git a/lib/zend/Zend/Currency/CurrencyInterface.php b/lib/zend/Zend/Currency/CurrencyInterface.php
deleted file mode 100644
index 8e828864b8c06..0000000000000
--- a/lib/zend/Zend/Currency/CurrencyInterface.php
+++ /dev/null
@@ -1,39 +0,0 @@
- 'iso', // format for date strings 'iso' or 'php'
- 'fix_dst' => true, // fix dst on summer/winter time change
- 'extend_month' => false, // false - addMonth like SQL, true like excel
- 'cache' => null, // cache to set
- 'timesync' => null // timesync server to set
- );
-
- // Class wide Date Constants
- const DAY = 'dd';
- const DAY_SHORT = 'd';
- const DAY_SUFFIX = 'SS';
- const DAY_OF_YEAR = 'D';
- const WEEKDAY = 'EEEE';
- const WEEKDAY_SHORT = 'EEE';
- const WEEKDAY_NARROW = 'E';
- const WEEKDAY_NAME = 'EE';
- const WEEKDAY_8601 = 'eee';
- const WEEKDAY_DIGIT = 'e';
- const WEEK = 'ww';
- const MONTH = 'MM';
- const MONTH_SHORT = 'M';
- const MONTH_DAYS = 'ddd';
- const MONTH_NAME = 'MMMM';
- const MONTH_NAME_SHORT = 'MMM';
- const MONTH_NAME_NARROW = 'MMMMM';
- const YEAR = 'y';
- const YEAR_SHORT = 'yy';
- const YEAR_8601 = 'Y';
- const YEAR_SHORT_8601 = 'YY';
- const LEAPYEAR = 'l';
- const MERIDIEM = 'a';
- const SWATCH = 'B';
- const HOUR = 'HH';
- const HOUR_SHORT = 'H';
- const HOUR_AM = 'hh';
- const HOUR_SHORT_AM = 'h';
- const MINUTE = 'mm';
- const MINUTE_SHORT = 'm';
- const SECOND = 'ss';
- const SECOND_SHORT = 's';
- const MILLISECOND = 'S';
- const TIMEZONE_NAME = 'zzzz';
- const DAYLIGHT = 'I';
- const GMT_DIFF = 'Z';
- const GMT_DIFF_SEP = 'ZZZZ';
- const TIMEZONE = 'z';
- const TIMEZONE_SECS = 'X';
- const ISO_8601 = 'c';
- const RFC_2822 = 'r';
- const TIMESTAMP = 'U';
- const ERA = 'G';
- const ERA_NAME = 'GGGG';
- const ERA_NARROW = 'GGGGG';
- const DATES = 'F';
- const DATE_FULL = 'FFFFF';
- const DATE_LONG = 'FFFF';
- const DATE_MEDIUM = 'FFF';
- const DATE_SHORT = 'FF';
- const TIMES = 'WW';
- const TIME_FULL = 'TTTTT';
- const TIME_LONG = 'TTTT';
- const TIME_MEDIUM = 'TTT';
- const TIME_SHORT = 'TT';
- const DATETIME = 'K';
- const DATETIME_FULL = 'KKKKK';
- const DATETIME_LONG = 'KKKK';
- const DATETIME_MEDIUM = 'KKK';
- const DATETIME_SHORT = 'KK';
- const ATOM = 'OOO';
- const COOKIE = 'CCC';
- const RFC_822 = 'R';
- const RFC_850 = 'RR';
- const RFC_1036 = 'RRR';
- const RFC_1123 = 'RRRR';
- const RFC_3339 = 'RRRRR';
- const RSS = 'SSS';
- const W3C = 'WWW';
-
- /**
- * Generates the standard date object, could be a unix timestamp, localized date,
- * string, integer, array and so on. Also parts of dates or time are supported
- * Always set the default timezone: http://php.net/date_default_timezone_set
- * For example, in your bootstrap: date_default_timezone_set('America/Los_Angeles');
- * For detailed instructions please look in the docu.
- *
- * @param string|integer|Zend_Date|array $date OPTIONAL Date value or value of date part to set
- * ,depending on $part. If null the actual time is set
- * @param string $part OPTIONAL Defines the input format of $date
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- * @throws Zend_Date_Exception
- */
- public function __construct($date = null, $part = null, $locale = null)
- {
- if (is_object($date) and !($date instanceof Zend_TimeSync_Protocol) and
- !($date instanceof Zend_Date)) {
- if ($locale instanceof Zend_Locale) {
- $locale = $date;
- $date = null;
- $part = null;
- } else {
- $date = (string) $date;
- }
- }
-
- if (($date !== null) and !is_array($date) and !($date instanceof Zend_TimeSync_Protocol) and
- !($date instanceof Zend_Date) and !defined($date) and Zend_Locale::isLocale($date, true, false)) {
- $locale = $date;
- $date = null;
- $part = null;
- } else if (($part !== null) and !defined($part) and Zend_Locale::isLocale($part, true, false)) {
- $locale = $part;
- $part = null;
- }
-
- $this->setLocale($locale);
- if (is_string($date) && ($part === null) && (strlen($date) <= 5)) {
- $part = $date;
- $date = null;
- }
-
- if ($date === null) {
- if ($part === null) {
- $date = time();
- } else if ($part !== self::TIMESTAMP) {
- $date = self::now($locale);
- $date = $date->get($part);
- }
- }
-
- if ($date instanceof Zend_TimeSync_Protocol) {
- $date = $date->getInfo();
- $date = $this->_getTime($date['offset']);
- $part = null;
- } else if (parent::$_defaultOffset != 0) {
- $date = $this->_getTime(parent::$_defaultOffset);
- }
-
- // set the timezone and offset for $this
- $zone = @date_default_timezone_get();
- $this->setTimezone($zone);
-
- // try to get timezone from date-string
- if (!is_int($date)) {
- $zone = $this->getTimezoneFromString($date);
- $this->setTimezone($zone);
- }
-
- // set datepart
- if (($part !== null && $part !== self::TIMESTAMP) or (!is_numeric($date))) {
- // switch off dst handling for value setting
- $this->setUnixTimestamp($this->getGmtOffset());
- $this->set($date, $part, $this->_locale);
-
- // DST fix
- if (is_array($date) === true) {
- if (!isset($date['hour'])) {
- $date['hour'] = 0;
- }
-
- $hour = $this->toString('H', 'iso', true);
- $hour = $date['hour'] - $hour;
- switch ($hour) {
- case 1 :
- case -23 :
- $this->addTimestamp(3600);
- break;
- case -1 :
- case 23 :
- $this->subTimestamp(3600);
- break;
- case 2 :
- case -22 :
- $this->addTimestamp(7200);
- break;
- case -2 :
- case 22 :
- $this->subTimestamp(7200);
- break;
- }
- }
- } else {
- $this->setUnixTimestamp($date);
- }
- }
-
- /**
- * Sets class wide options, if no option was given, the actual set options will be returned
- *
- * @param array $options Options to set
- * @throws Zend_Date_Exception
- * @return Options array if no option was given
- */
- public static function setOptions(array $options = array())
- {
- if (empty($options)) {
- return self::$_options;
- }
-
- foreach ($options as $name => $value) {
- $name = strtolower($name);
-
- if (array_key_exists($name, self::$_options)) {
- switch($name) {
- case 'format_type' :
- if ((strtolower($value) != 'php') && (strtolower($value) != 'iso')) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Unknown format type ($value) for dates, only 'iso' and 'php' supported", 0, null, $value);
- }
- break;
- case 'fix_dst' :
- if (!is_bool($value)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("'fix_dst' has to be boolean", 0, null, $value);
- }
- break;
- case 'extend_month' :
- if (!is_bool($value)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("'extend_month' has to be boolean", 0, null, $value);
- }
- break;
- case 'cache' :
- if ($value === null) {
- parent::$_cache = null;
- } else {
- if (!$value instanceof Zend_Cache_Core) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Instance of Zend_Cache expected");
- }
-
- parent::$_cache = $value;
- parent::$_cacheTags = Zend_Date_DateObject::_getTagSupportForCache();
- Zend_Locale_Data::setCache($value);
- }
- break;
- case 'timesync' :
- if ($value === null) {
- parent::$_defaultOffset = 0;
- } else {
- if (!$value instanceof Zend_TimeSync_Protocol) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Instance of Zend_TimeSync expected");
- }
-
- $date = $value->getInfo();
- parent::$_defaultOffset = $date['offset'];
- }
- break;
- }
- self::$_options[$name] = $value;
- }
- else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Unknown option: $name = $value");
- }
- }
- }
-
- /**
- * Returns this object's internal UNIX timestamp (equivalent to Zend_Date::TIMESTAMP).
- * If the timestamp is too large for integers, then the return value will be a string.
- * This function does not return the timestamp as an object.
- * Use clone() or copyPart() instead.
- *
- * @return integer|string UNIX timestamp
- */
- public function getTimestamp()
- {
- return $this->getUnixTimestamp();
- }
-
- /**
- * Returns the calculated timestamp
- * HINT: timestamps are always GMT
- *
- * @param string $calc Type of calculation to make
- * @param string|integer|array|Zend_Date $stamp Timestamp to calculate, when null the actual timestamp is calculated
- * @return Zend_Date|integer
- * @throws Zend_Date_Exception
- */
- private function _timestamp($calc, $stamp)
- {
- if ($stamp instanceof Zend_Date) {
- // extract timestamp from object
- $stamp = $stamp->getTimestamp();
- }
-
- if (is_array($stamp)) {
- if (isset($stamp['timestamp']) === true) {
- $stamp = $stamp['timestamp'];
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('no timestamp given in array');
- }
- }
-
- if ($calc === 'set') {
- $return = $this->setUnixTimestamp($stamp);
- } else {
- $return = $this->_calcdetail($calc, $stamp, self::TIMESTAMP, null);
- }
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
- /**
- * Sets a new timestamp
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to set
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setTimestamp($timestamp)
- {
- return $this->_timestamp('set', $timestamp);
- }
-
- /**
- * Adds a timestamp
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to add
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addTimestamp($timestamp)
- {
- return $this->_timestamp('add', $timestamp);
- }
-
- /**
- * Subtracts a timestamp
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to sub
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subTimestamp($timestamp)
- {
- return $this->_timestamp('sub', $timestamp);
- }
-
- /**
- * Compares two timestamps, returning the difference as integer
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to compare
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareTimestamp($timestamp)
- {
- return $this->_timestamp('cmp', $timestamp);
- }
-
- /**
- * Returns a string representation of the object
- * Supported format tokens are:
- * G - era, y - year, Y - ISO year, M - month, w - week of year, D - day of year, d - day of month
- * E - day of week, e - number of weekday (1-7), h - hour 1-12, H - hour 0-23, m - minute, s - second
- * A - milliseconds of day, z - timezone, Z - timezone offset, S - fractional second, a - period of day
- *
- * Additionally format tokens but non ISO conform are:
- * SS - day suffix, eee - php number of weekday(0-6), ddd - number of days per month
- * l - Leap year, B - swatch internet time, I - daylight saving time, X - timezone offset in seconds
- * r - RFC2822 format, U - unix timestamp
- *
- * Not supported ISO tokens are
- * u - extended year, Q - quarter, q - quarter, L - stand alone month, W - week of month
- * F - day of week of month, g - modified julian, c - stand alone weekday, k - hour 0-11, K - hour 1-24
- * v - wall zone
- *
- * @param string $format OPTIONAL Rule for formatting output. If null the default date format is used
- * @param string $type OPTIONAL Type for the format string which overrides the standard setting
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string
- */
- public function toString($format = null, $type = null, $locale = null)
- {
- if (is_object($format)) {
- if ($format instanceof Zend_Locale) {
- $locale = $format;
- $format = null;
- } else {
- $format = (string) $format;
- }
- }
-
- if (is_object($type)) {
- if ($type instanceof Zend_Locale) {
- $locale = $type;
- $type = null;
- } else {
- $type = (string) $type;
- }
- }
-
- if (($format !== null) && !defined($format)
- && ($format != 'ee') && ($format != 'ss') && ($format != 'GG') && ($format != 'MM') && ($format != 'EE') && ($format != 'TT')
- && Zend_Locale::isLocale($format, null, false)) {
- $locale = $format;
- $format = null;
- }
-
- if (($type !== null) and ($type != 'php') and ($type != 'iso') and
- Zend_Locale::isLocale($type, null, false)) {
- $locale = $type;
- $type = null;
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($format === null) {
- $format = Zend_Locale_Format::getDateFormat($locale) . ' ' . Zend_Locale_Format::getTimeFormat($locale);
- } else if (((self::$_options['format_type'] == 'php') && ($type === null)) or ($type == 'php')) {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
-
- return $this->date($this->_toToken($format, $locale), $this->getUnixTimestamp(), false);
- }
-
- /**
- * Returns a string representation of the date which is equal with the timestamp
- *
- * @return string
- */
- public function __toString()
- {
- return $this->toString(null, $this->_locale);
- }
-
- /**
- * Returns a integer representation of the object
- * But returns false when the given part is no value f.e. Month-Name
- *
- * @param string|integer|Zend_Date $part OPTIONAL Defines the date or datepart to return as integer
- * @return integer|false
- */
- public function toValue($part = null)
- {
- $result = $this->get($part);
- if (is_numeric($result)) {
- return intval("$result");
- } else {
- return false;
- }
- }
-
- /**
- * Returns an array representation of the object
- *
- * @return array
- */
- public function toArray()
- {
- return array('day' => $this->toString(self::DAY_SHORT, 'iso'),
- 'month' => $this->toString(self::MONTH_SHORT, 'iso'),
- 'year' => $this->toString(self::YEAR, 'iso'),
- 'hour' => $this->toString(self::HOUR_SHORT, 'iso'),
- 'minute' => $this->toString(self::MINUTE_SHORT, 'iso'),
- 'second' => $this->toString(self::SECOND_SHORT, 'iso'),
- 'timezone' => $this->toString(self::TIMEZONE, 'iso'),
- 'timestamp' => $this->toString(self::TIMESTAMP, 'iso'),
- 'weekday' => $this->toString(self::WEEKDAY_8601, 'iso'),
- 'dayofyear' => $this->toString(self::DAY_OF_YEAR, 'iso'),
- 'week' => $this->toString(self::WEEK, 'iso'),
- 'gmtsecs' => $this->toString(self::TIMEZONE_SECS, 'iso'));
- }
-
- /**
- * Returns a representation of a date or datepart
- * This could be for example a localized monthname, the time without date,
- * the era or only the fractional seconds. There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu
- *
- * @param string $part OPTIONAL Part of the date to return, if null the timestamp is returned
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string date or datepart
- */
- public function get($part = null, $locale = null)
- {
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if (($part !== null) && !defined($part)
- && ($part != 'ee') && ($part != 'ss') && ($part != 'GG') && ($part != 'MM') && ($part != 'EE') && ($part != 'TT')
- && Zend_Locale::isLocale($part, null, false)) {
- $locale = $part;
- $part = null;
- }
-
- if ($part === null) {
- $part = self::TIMESTAMP;
- } else if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- return $this->date($this->_toToken($part, $locale), $this->getUnixTimestamp(), false);
- }
-
- /**
- * Internal method to apply tokens
- *
- * @param string $part
- * @param string $locale
- * @return string
- */
- private function _toToken($part, $locale) {
- // get format tokens
- $comment = false;
- $format = '';
- $orig = '';
- for ($i = 0; isset($part[$i]); ++$i) {
- if ($part[$i] == "'") {
- $comment = $comment ? false : true;
- if (isset($part[$i+1]) && ($part[$i+1] == "'")) {
- $comment = $comment ? false : true;
- $format .= "\\'";
- ++$i;
- }
-
- $orig = '';
- continue;
- }
-
- if ($comment) {
- $format .= '\\' . $part[$i];
- $orig = '';
- } else {
- $orig .= $part[$i];
- if (!isset($part[$i+1]) || (isset($orig[0]) && ($orig[0] != $part[$i+1]))) {
- $format .= $this->_parseIsoToDate($orig, $locale);
- $orig = '';
- }
- }
- }
-
- return $format;
- }
-
- /**
- * Internal parsing method
- *
- * @param string $token
- * @param string $locale
- * @return string
- */
- private function _parseIsoToDate($token, $locale) {
- switch($token) {
- case self::DAY :
- return 'd';
- break;
-
- case self::WEEKDAY_SHORT :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday));
- return $this->_toComment(iconv_substr($day, 0, 3, 'UTF-8'));
- break;
-
- case self::DAY_SHORT :
- return 'j';
- break;
-
- case self::WEEKDAY :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday)));
- break;
-
- case self::WEEKDAY_8601 :
- return 'N';
- break;
-
- case 'ee' :
- return $this->_toComment(str_pad($this->date('N', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::DAY_SUFFIX :
- return 'S';
- break;
-
- case self::WEEKDAY_DIGIT :
- return 'w';
- break;
-
- case self::DAY_OF_YEAR :
- return 'z';
- break;
-
- case 'DDD' :
- return $this->_toComment(str_pad($this->date('z', $this->getUnixTimestamp(), false), 3, '0', STR_PAD_LEFT));
- break;
-
- case 'DD' :
- return $this->_toComment(str_pad($this->date('z', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::WEEKDAY_NARROW :
- case 'EEEEE' :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday));
- return $this->_toComment(iconv_substr($day, 0, 1, 'UTF-8'));
- break;
-
- case self::WEEKDAY_NAME :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday)));
- break;
-
- case 'w' :
- $week = $this->date('W', $this->getUnixTimestamp(), false);
- return $this->_toComment(($week[0] == '0') ? $week[1] : $week);
- break;
-
- case self::WEEK :
- return 'W';
- break;
-
- case self::MONTH_NAME :
- $month = $this->date('n', $this->getUnixTimestamp(), false);
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'wide', $month)));
- break;
-
- case self::MONTH :
- return 'm';
- break;
-
- case self::MONTH_NAME_SHORT :
- $month = $this->date('n', $this->getUnixTimestamp(), false);
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month)));
- break;
-
- case self::MONTH_SHORT :
- return 'n';
- break;
-
- case self::MONTH_DAYS :
- return 't';
- break;
-
- case self::MONTH_NAME_NARROW :
- $month = $this->date('n', $this->getUnixTimestamp(), false);
- $mon = Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month));
- return $this->_toComment(iconv_substr($mon, 0, 1, 'UTF-8'));
- break;
-
- case self::LEAPYEAR :
- return 'L';
- break;
-
- case self::YEAR_8601 :
- return 'o';
- break;
-
- case self::YEAR :
- return 'Y';
- break;
-
- case self::YEAR_SHORT :
- return 'y';
- break;
-
- case self::YEAR_SHORT_8601 :
- return $this->_toComment(substr($this->date('o', $this->getUnixTimestamp(), false), -2, 2));
- break;
-
- case self::MERIDIEM :
- $am = $this->date('a', $this->getUnixTimestamp(), false);
- if ($am == 'am') {
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'am'));
- }
-
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'pm'));
- break;
-
- case self::SWATCH :
- return 'B';
- break;
-
- case self::HOUR_SHORT_AM :
- return 'g';
- break;
-
- case self::HOUR_SHORT :
- return 'G';
- break;
-
- case self::HOUR_AM :
- return 'h';
- break;
-
- case self::HOUR :
- return 'H';
- break;
-
- case self::MINUTE :
- return $this->_toComment(str_pad($this->date('i', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::SECOND :
- return $this->_toComment(str_pad($this->date('s', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::MINUTE_SHORT :
- return 'i';
- break;
-
- case self::SECOND_SHORT :
- return 's';
- break;
-
- case self::MILLISECOND :
- return $this->_toComment($this->getMilliSecond());
- break;
-
- case self::TIMEZONE_NAME :
- case 'vvvv' :
- return 'e';
- break;
-
- case self::DAYLIGHT :
- return 'I';
- break;
-
- case self::GMT_DIFF :
- case 'ZZ' :
- case 'ZZZ' :
- return 'O';
- break;
-
- case self::GMT_DIFF_SEP :
- return 'P';
- break;
-
- case self::TIMEZONE :
- case 'v' :
- case 'zz' :
- case 'zzz' :
- return 'T';
- break;
-
- case self::TIMEZONE_SECS :
- return 'Z';
- break;
-
- case self::ISO_8601 :
- return 'c';
- break;
-
- case self::RFC_2822 :
- return 'r';
- break;
-
- case self::TIMESTAMP :
- return 'U';
- break;
-
- case self::ERA :
- case 'GG' :
- case 'GGG' :
- $year = $this->date('Y', $this->getUnixTimestamp(), false);
- if ($year < 0) {
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '0')));
- }
-
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '1')));
- break;
-
- case self::ERA_NARROW :
- $year = $this->date('Y', $this->getUnixTimestamp(), false);
- if ($year < 0) {
- return $this->_toComment(iconv_substr(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '0')), 0, 1, 'UTF-8')) . '.';
- }
-
- return $this->_toComment(iconv_substr(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '1')), 0, 1, 'UTF-8')) . '.';
- break;
-
- case self::ERA_NAME :
- $year = $this->date('Y', $this->getUnixTimestamp(), false);
- if ($year < 0) {
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Names', '0')));
- }
-
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Names', '1')));
- break;
-
- case self::DATES :
- return $this->_toToken(Zend_Locale_Format::getDateFormat($locale), $locale);
- break;
-
- case self::DATE_FULL :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'full')), $locale);
- break;
-
- case self::DATE_LONG :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'long')), $locale);
- break;
-
- case self::DATE_MEDIUM :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'medium')), $locale);
- break;
-
- case self::DATE_SHORT :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'short')), $locale);
- break;
-
- case self::TIMES :
- return $this->_toToken(Zend_Locale_Format::getTimeFormat($locale), $locale);
- break;
-
- case self::TIME_FULL :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'full'), $locale);
- break;
-
- case self::TIME_LONG :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'long'), $locale);
- break;
-
- case self::TIME_MEDIUM :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'medium'), $locale);
- break;
-
- case self::TIME_SHORT :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'short'), $locale);
- break;
-
- case self::DATETIME :
- return $this->_toToken(Zend_Locale_Format::getDateTimeFormat($locale), $locale);
- break;
-
- case self::DATETIME_FULL :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'full')), $locale);
- break;
-
- case self::DATETIME_LONG :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'long')), $locale);
- break;
-
- case self::DATETIME_MEDIUM :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'medium')), $locale);
- break;
-
- case self::DATETIME_SHORT :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'short')), $locale);
- break;
-
- case self::ATOM :
- return 'Y\-m\-d\TH\:i\:sP';
- break;
-
- case self::COOKIE :
- return 'l\, d\-M\-y H\:i\:s e';
- break;
-
- case self::RFC_822 :
- return 'D\, d M y H\:i\:s O';
- break;
-
- case self::RFC_850 :
- return 'l\, d\-M\-y H\:i\:s e';
- break;
-
- case self::RFC_1036 :
- return 'D\, d M y H\:i\:s O';
- break;
-
- case self::RFC_1123 :
- return 'D\, d M Y H\:i\:s O';
- break;
-
- case self::RFC_3339 :
- return 'Y\-m\-d\TH\:i\:sP';
- break;
-
- case self::RSS :
- return 'D\, d M Y H\:i\:s O';
- break;
-
- case self::W3C :
- return 'Y\-m\-d\TH\:i\:sP';
- break;
- }
-
- if ($token == '') {
- return '';
- }
-
- switch ($token[0]) {
- case 'y' :
- if ((strlen($token) == 4) && (abs($this->getUnixTimestamp()) <= 0x7FFFFFFF)) {
- return 'Y';
- }
-
- $length = iconv_strlen($token, 'UTF-8');
- return $this->_toComment(str_pad($this->date('Y', $this->getUnixTimestamp(), false), $length, '0', STR_PAD_LEFT));
- break;
-
- case 'Y' :
- if ((strlen($token) == 4) && (abs($this->getUnixTimestamp()) <= 0x7FFFFFFF)) {
- return 'o';
- }
-
- $length = iconv_strlen($token, 'UTF-8');
- return $this->_toComment(str_pad($this->date('o', $this->getUnixTimestamp(), false), $length, '0', STR_PAD_LEFT));
- break;
-
- case 'A' :
- $length = iconv_strlen($token, 'UTF-8');
- $result = substr($this->getMilliSecond(), 0, 3);
- $result += $this->date('s', $this->getUnixTimestamp(), false) * 1000;
- $result += $this->date('i', $this->getUnixTimestamp(), false) * 60000;
- $result += $this->date('H', $this->getUnixTimestamp(), false) * 3600000;
-
- return $this->_toComment(str_pad($result, $length, '0', STR_PAD_LEFT));
- break;
- }
-
- return $this->_toComment($token);
- }
-
- /**
- * Private function to make a comment of a token
- *
- * @param string $token
- * @return string
- */
- private function _toComment($token)
- {
- $token = str_split($token);
- $result = '';
- foreach ($token as $tok) {
- $result .= '\\' . $tok;
- }
-
- return $result;
- }
-
- /**
- * Return digit from standard names (english)
- * Faster implementation than locale aware searching
- *
- * @param string $name
- * @return integer Number of this month
- * @throws Zend_Date_Exception
- */
- private function _getDigitFromName($name)
- {
- switch($name) {
- case "Jan":
- return 1;
-
- case "Feb":
- return 2;
-
- case "Mar":
- return 3;
-
- case "Apr":
- return 4;
-
- case "May":
- return 5;
-
- case "Jun":
- return 6;
-
- case "Jul":
- return 7;
-
- case "Aug":
- return 8;
-
- case "Sep":
- return 9;
-
- case "Oct":
- return 10;
-
- case "Nov":
- return 11;
-
- case "Dec":
- return 12;
-
- default:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Month ($name) is not a known month');
- }
- }
-
- /**
- * Counts the exact year number
- * < 70 - 2000 added, >70 < 100 - 1900, others just returned
- *
- * @param integer $value year number
- * @return integer Number of year
- */
- public static function getFullYear($value)
- {
- if ($value >= 0) {
- if ($value < 70) {
- $value += 2000;
- } else if ($value < 100) {
- $value += 1900;
- }
- }
- return $value;
- }
-
- /**
- * Sets the given date as new date or a given datepart as new datepart returning the new datepart
- * This could be for example a localized dayname, the date without time,
- * the month or only the seconds. There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to set
- * @param string $part OPTIONAL Part of the date to set, if null the timestamp is set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function set($date, $part = null, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $zone = $this->getTimezoneFromString($date);
- $this->setTimezone($zone);
-
- $this->_calculate('set', $date, $part, $locale);
- return $this;
- }
-
- /**
- * Adds a date or datepart to the existing date, by extracting $part from $date,
- * and modifying this object by adding that part. The $part is then extracted from
- * this object and returned as an integer or numeric string (for large values, or $part's
- * corresponding to pre-defined formatted date strings).
- * This could be for example a ISO 8601 date, the hour the monthname or only the minute.
- * There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu.
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to add
- * @param string $part OPTIONAL Part of the date to add, if null the timestamp is added
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function add($date, $part = self::TIMESTAMP, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $this->_calculate('add', $date, $part, $locale);
- return $this;
- }
-
- /**
- * Subtracts a date from another date.
- * This could be for example a RFC2822 date, the time,
- * the year or only the timestamp. There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu
- * Be aware: Adding -2 Months is not equal to Subtracting 2 Months !!!
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to subtract
- * @param string $part OPTIONAL Part of the date to sub, if null the timestamp is subtracted
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function sub($date, $part = self::TIMESTAMP, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $this->_calculate('sub', $date, $part, $locale);
- return $this;
- }
-
- /**
- * Compares a date or datepart with the existing one.
- * Returns -1 if earlier, 0 if equal and 1 if later.
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to compare with the date object
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is subtracted
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compare($date, $part = self::TIMESTAMP, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $compare = $this->_calculate('cmp', $date, $part, $locale);
-
- if ($compare > 0) {
- return 1;
- } else if ($compare < 0) {
- return -1;
- }
- return 0;
- }
-
- /**
- * Returns a new instance of Zend_Date with the selected part copied.
- * To make an exact copy, use PHP's clone keyword.
- * For a complete list of supported date part values look into the docu.
- * If a date part is copied, all other date parts are set to standard values.
- * For example: If only YEAR is copied, the returned date object is equal to
- * 01-01-YEAR 00:00:00 (01-01-1970 00:00:00 is equal to timestamp 0)
- * If only HOUR is copied, the returned date object is equal to
- * 01-01-1970 HOUR:00:00 (so $this contains a timestamp equal to a timestamp of 0 plus HOUR).
- *
- * @param string $part Part of the date to compare, if null the timestamp is subtracted
- * @param string|Zend_Locale $locale OPTIONAL New object's locale. No adjustments to timezone are made.
- * @return Zend_Date New clone with requested part
- */
- public function copyPart($part, $locale = null)
- {
- $clone = clone $this; // copy all instance variables
- $clone->setUnixTimestamp(0); // except the timestamp
- if ($locale != null) {
- $clone->setLocale($locale); // set an other locale if selected
- }
- $clone->set($this, $part);
- return $clone;
- }
-
- /**
- * Internal function, returns the offset of a given timezone
- *
- * @param string $zone
- * @return integer
- */
- public function getTimezoneFromString($zone)
- {
- if (is_array($zone)) {
- return $this->getTimezone();
- }
-
- if ($zone instanceof Zend_Date) {
- return $zone->getTimezone();
- }
-
- $match = array();
- preg_match('/\dZ$/', $zone, $match);
- if (!empty($match)) {
- return "Etc/UTC";
- }
-
- preg_match('/([+-]\d{2}):{0,1}\d{2}/', $zone, $match);
- if (!empty($match) and ($match[count($match) - 1] <= 14) and ($match[count($match) - 1] >= -12)) {
- $zone = "Etc/GMT";
- $zone .= ($match[count($match) - 1] < 0) ? "+" : "-";
- $zone .= (int) abs($match[count($match) - 1]);
- return $zone;
- }
-
- preg_match('/([[:alpha:]\/_]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);
- try {
- if (!empty($match) and (!is_int($match[count($match) - 1]))) {
- $oldzone = $this->getTimezone();
- $this->setTimezone($match[count($match) - 1]);
- $result = $this->getTimezone();
- $this->setTimezone($oldzone);
- if ($result !== $oldzone) {
- return $match[count($match) - 1];
- }
- }
- } catch (Exception $e) {
- // fall through
- }
-
- return $this->getTimezone();
- }
-
- /**
- * Calculates the date or object
- *
- * @param string $calc Calculation to make
- * @param string|integer $date Date for calculation
- * @param string|integer $comp Second date for calculation
- * @param boolean|integer $dst Use dst correction if option is set
- * @return integer|string|Zend_Date new timestamp or Zend_Date depending on calculation
- */
- private function _assign($calc, $date, $comp = 0, $dst = false)
- {
- switch ($calc) {
- case 'set' :
- if (!empty($comp)) {
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$sub, $this->getUnixTimestamp(), $comp));
- }
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$add, $this->getUnixTimestamp(), $date));
- $value = $this->getUnixTimestamp();
- break;
- case 'add' :
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$add, $this->getUnixTimestamp(), $date));
- $value = $this->getUnixTimestamp();
- break;
- case 'sub' :
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$sub, $this->getUnixTimestamp(), $date));
- $value = $this->getUnixTimestamp();
- break;
- default :
- // cmp - compare
- return call_user_func(Zend_Locale_Math::$comp, $comp, $date);
- break;
- }
-
- // dst-correction if 'fix_dst' = true and dst !== false but only for non UTC and non GMT
- if ((self::$_options['fix_dst'] === true) and ($dst !== false) and ($this->_dst === true)) {
- $hour = $this->toString(self::HOUR, 'iso');
- if ($hour != $dst) {
- if (($dst == ($hour + 1)) or ($dst == ($hour - 23))) {
- $value += 3600;
- } else if (($dst == ($hour - 1)) or ($dst == ($hour + 23))) {
- $value -= 3600;
- }
- $this->setUnixTimestamp($value);
- }
- }
- return $this->getUnixTimestamp();
- }
-
-
- /**
- * Calculates the date or object
- *
- * @param string $calc Calculation to make, one of: 'add'|'sub'|'cmp'|'copy'|'set'
- * @param string|integer|array|Zend_Date $date Date or datepart to calculate with
- * @param string $part Part of the date to calculate, if null the timestamp is used
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|string|Zend_Date new timestamp
- * @throws Zend_Date_Exception
- */
- private function _calculate($calc, $date, $part, $locale)
- {
- if ($date === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $date must be set, null is not allowed');
- }
-
- if (($part !== null) && (strlen($part) !== 2) && (Zend_Locale::isLocale($part, null, false))) {
- $locale = $part;
- $part = null;
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- $locale = (string) $locale;
-
- // Create date parts
- $year = $this->toString(self::YEAR, 'iso');
- $month = $this->toString(self::MONTH_SHORT, 'iso');
- $day = $this->toString(self::DAY_SHORT, 'iso');
- $hour = $this->toString(self::HOUR_SHORT, 'iso');
- $minute = $this->toString(self::MINUTE_SHORT, 'iso');
- $second = $this->toString(self::SECOND_SHORT, 'iso');
- // If object extract value
- if ($date instanceof Zend_Date) {
- $date = $date->toString($part, 'iso', $locale);
- }
-
- if (is_array($date) === true) {
- if (empty($part) === false) {
- switch($part) {
- // Fall through
- case self::DAY:
- case self::DAY_SHORT:
- if (isset($date['day']) === true) {
- $date = $date['day'];
- }
- break;
- // Fall through
- case self::WEEKDAY_SHORT:
- case self::WEEKDAY:
- case self::WEEKDAY_8601:
- case self::WEEKDAY_DIGIT:
- case self::WEEKDAY_NARROW:
- case self::WEEKDAY_NAME:
- if (isset($date['weekday']) === true) {
- $date = $date['weekday'];
- $part = self::WEEKDAY_DIGIT;
- }
- break;
- case self::DAY_OF_YEAR:
- if (isset($date['day_of_year']) === true) {
- $date = $date['day_of_year'];
- }
- break;
- // Fall through
- case self::MONTH:
- case self::MONTH_SHORT:
- case self::MONTH_NAME:
- case self::MONTH_NAME_SHORT:
- case self::MONTH_NAME_NARROW:
- if (isset($date['month']) === true) {
- $date = $date['month'];
- }
- break;
- // Fall through
- case self::YEAR:
- case self::YEAR_SHORT:
- case self::YEAR_8601:
- case self::YEAR_SHORT_8601:
- if (isset($date['year']) === true) {
- $date = $date['year'];
- }
- break;
- // Fall through
- case self::HOUR:
- case self::HOUR_AM:
- case self::HOUR_SHORT:
- case self::HOUR_SHORT_AM:
- if (isset($date['hour']) === true) {
- $date = $date['hour'];
- }
- break;
- // Fall through
- case self::MINUTE:
- case self::MINUTE_SHORT:
- if (isset($date['minute']) === true) {
- $date = $date['minute'];
- }
- break;
- // Fall through
- case self::SECOND:
- case self::SECOND_SHORT:
- if (isset($date['second']) === true) {
- $date = $date['second'];
- }
- break;
- // Fall through
- case self::TIMEZONE:
- case self::TIMEZONE_NAME:
- if (isset($date['timezone']) === true) {
- $date = $date['timezone'];
- }
- break;
- case self::TIMESTAMP:
- if (isset($date['timestamp']) === true) {
- $date = $date['timestamp'];
- }
- break;
- case self::WEEK:
- if (isset($date['week']) === true) {
- $date = $date['week'];
- }
- break;
- case self::TIMEZONE_SECS:
- if (isset($date['gmtsecs']) === true) {
- $date = $date['gmtsecs'];
- }
- break;
- default:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("datepart for part ($part) not found in array");
- break;
- }
- } else {
- $hours = 0;
- if (isset($date['hour']) === true) {
- $hours = $date['hour'];
- }
- $minutes = 0;
- if (isset($date['minute']) === true) {
- $minutes = $date['minute'];
- }
- $seconds = 0;
- if (isset($date['second']) === true) {
- $seconds = $date['second'];
- }
- $months = 0;
- if (isset($date['month']) === true) {
- $months = $date['month'];
- }
- $days = 0;
- if (isset($date['day']) === true) {
- $days = $date['day'];
- }
- $years = 0;
- if (isset($date['year']) === true) {
- $years = $date['year'];
- }
- return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, $months, $days, $years, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), $hour);
- }
- }
-
- // $date as object, part of foreign date as own date
- switch($part) {
-
- // day formats
- case self::DAY:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, day expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_SHORT:
- $daylist = Zend_Locale_Data::getList($locale, 'day');
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
-
- foreach ($daylist as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 3, 'UTF-8')) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::DAY_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, day expected", 0, null, $date);
- break;
-
- case self::WEEKDAY:
- $daylist = Zend_Locale_Data::getList($locale, 'day');
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
-
- foreach ($daylist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_8601:
- $weekday = (int) $this->toString(self::WEEKDAY_8601, 'iso', $locale);
- if ((intval($date) > 0) and (intval($date) < 8)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::DAY_SUFFIX:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('day suffix not supported', 0, null, $date);
- break;
-
- case self::WEEKDAY_DIGIT:
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- if (is_numeric($date) and (intval($date) >= 0) and (intval($date) < 7)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $date, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::DAY_OF_YEAR:
- if (is_numeric($date)) {
- if (($calc == 'add') || ($calc == 'sub')) {
- $year = 1970;
- ++$date;
- ++$day;
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, $date, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, day expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_NARROW:
- $daylist = Zend_Locale_Data::getList($locale, 'day', array('gregorian', 'format', 'abbreviated'));
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
- foreach ($daylist as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_NAME:
- $daylist = Zend_Locale_Data::getList($locale, 'day', array('gregorian', 'format', 'abbreviated'));
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
- foreach ($daylist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- // week formats
- case self::WEEK:
- if (is_numeric($date)) {
- $week = (int) $this->toString(self::WEEK, 'iso', $locale);
- return $this->_assign($calc, parent::mktime(0, 0, 0, 1, 1 + ($date * 7), 1970, true),
- parent::mktime(0, 0, 0, 1, 1 + ($week * 7), 1970, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, week expected", 0, null, $date);
- break;
-
- // month formats
- case self::MONTH_NAME:
- $monthlist = Zend_Locale_Data::getList($locale, 'month');
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $key;
- break;
- }
- ++$cnt;
- }
- $date = array_search($date, $monthlist);
-
- // Monthname found
- if ($cnt < 12) {
- $fixday = 0;
- if ($calc == 'add') {
- $date += $found;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc == 'sub') {
- $date = $month - $found;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- // Monthname not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH:
- if (is_numeric($date)) {
- $fixday = 0;
- if ($calc == 'add') {
- $date += $month;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc == 'sub') {
- $date = $month - $date;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH_NAME_SHORT:
- $monthlist = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $key;
- break;
- }
- ++$cnt;
- }
- $date = array_search($date, $monthlist);
-
- // Monthname found
- if ($cnt < 12) {
- $fixday = 0;
- if ($calc == 'add') {
- $date += $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc == 'sub') {
- $date = $month - $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- // Monthname not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH_SHORT:
- if (is_numeric($date) === true) {
- $fixday = 0;
- if ($calc === 'add') {
- $date += $month;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc === 'sub') {
- $date = $month - $date;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH_DAYS:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('month days not supported', 0, null, $date);
- break;
-
- case self::MONTH_NAME_NARROW:
- $monthlist = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'stand-alone', 'narrow'));
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) === strtoupper($date)) {
- $found = $key;
- break;
- }
- ++$cnt;
- }
- $date = array_search($date, $monthlist);
-
- // Monthname found
- if ($cnt < 12) {
- $fixday = 0;
- if ($calc === 'add') {
- $date += $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc === 'sub') {
- $date = $month - $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- // Monthname not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- // year formats
- case self::LEAPYEAR:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('leap year not supported', 0, null, $date);
- break;
-
- case self::YEAR_8601:
- if (is_numeric($date)) {
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- case self::YEAR:
- if (is_numeric($date)) {
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- case self::YEAR_SHORT:
- if (is_numeric($date)) {
- $date = intval($date);
- if (($calc == 'set') || ($calc == 'cmp')) {
- $date = self::getFullYear($date);
- }
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- case self::YEAR_SHORT_8601:
- if (is_numeric($date)) {
- $date = intval($date);
- if (($calc === 'set') || ($calc === 'cmp')) {
- $date = self::getFullYear($date);
- }
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- // time formats
- case self::MERIDIEM:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('meridiem not supported', 0, null, $date);
- break;
-
- case self::SWATCH:
- if (is_numeric($date)) {
- $rest = intval($date);
- $hours = floor($rest * 24 / 1000);
- $rest = $rest - ($hours * 1000 / 24);
- $minutes = floor($rest * 1440 / 1000);
- $rest = $rest - ($minutes * 1000 / 1440);
- $seconds = floor($rest * 86400 / 1000);
- return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1, 1, 1970, true),
- $this->mktime($hour, $minute, $second, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, swatchstamp expected", 0, null, $date);
- break;
-
- case self::HOUR_SHORT_AM:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::HOUR_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::HOUR_AM:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::HOUR:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::MINUTE:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true),
- $this->mktime(0, $minute, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, minute expected", 0, null, $date);
- break;
-
- case self::SECOND:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true),
- $this->mktime(0, 0, $second, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, second expected", 0, null, $date);
- break;
-
- case self::MILLISECOND:
- if (is_numeric($date)) {
- switch($calc) {
- case 'set' :
- return $this->setMillisecond($date);
- break;
- case 'add' :
- return $this->addMillisecond($date);
- break;
- case 'sub' :
- return $this->subMillisecond($date);
- break;
- }
-
- return $this->compareMillisecond($date);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, milliseconds expected", 0, null, $date);
- break;
-
- case self::MINUTE_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true),
- $this->mktime(0, $minute, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, minute expected", 0, null, $date);
- break;
-
- case self::SECOND_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true),
- $this->mktime(0, 0, $second, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, second expected", 0, null, $date);
- break;
-
- // timezone formats
- // break intentionally omitted
- case self::TIMEZONE_NAME:
- case self::TIMEZONE:
- case self::TIMEZONE_SECS:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('timezone not supported', 0, null, $date);
- break;
-
- case self::DAYLIGHT:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('daylight not supported', 0, null, $date);
- break;
-
- case self::GMT_DIFF:
- case self::GMT_DIFF_SEP:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('gmtdiff not supported', 0, null, $date);
- break;
-
- // date strings
- case self::ISO_8601:
- // (-)YYYY-MM-dd
- preg_match('/^(-{0,1}\d{4})-(\d{2})-(\d{2})/', $date, $datematch);
- // (-)YY-MM-dd
- if (empty($datematch)) {
- preg_match('/^(-{0,1}\d{2})-(\d{2})-(\d{2})/', $date, $datematch);
- }
- // (-)YYYYMMdd
- if (empty($datematch)) {
- preg_match('/^(-{0,1}\d{4})(\d{2})(\d{2})/', $date, $datematch);
- }
- // (-)YYMMdd
- if (empty($datematch)) {
- preg_match('/^(-{0,1}\d{2})(\d{2})(\d{2})/', $date, $datematch);
- }
- $tmpdate = $date;
- if (!empty($datematch)) {
- $dateMatchCharCount = iconv_strlen($datematch[0], 'UTF-8');
- $tmpdate = iconv_substr($date,
- $dateMatchCharCount,
- iconv_strlen($date, 'UTF-8') - $dateMatchCharCount,
- 'UTF-8');
- }
- // (T)hh:mm:ss
- preg_match('/[T,\s]{0,1}(\d{2}):(\d{2}):(\d{2})/', $tmpdate, $timematch);
- // (T)hhmmss
- if (empty($timematch)) {
- preg_match('/[T,\s]{0,1}(\d{2})(\d{2})(\d{2})/', $tmpdate, $timematch);
- }
- // (T)hh:mm
- if (empty($timematch)) {
- preg_match('/[T,\s]{0,1}(\d{2}):(\d{2})/', $tmpdate, $timematch);
- }
- // (T)hhmm
- if (empty($timematch)) {
- preg_match('/[T,\s]{0,1}(\d{2})(\d{2})/', $tmpdate, $timematch);
- }
- if (empty($datematch) and empty($timematch)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
- }
- if (!empty($timematch)) {
- $timeMatchCharCount = iconv_strlen($timematch[0], 'UTF-8');
- $tmpdate = iconv_substr($tmpdate,
- $timeMatchCharCount,
- iconv_strlen($tmpdate, 'UTF-8') - $timeMatchCharCount,
- 'UTF-8');
- }
- if (empty($datematch)) {
- $datematch[1] = 1970;
- $datematch[2] = 1;
- $datematch[3] = 1;
- } else if (iconv_strlen($datematch[1], 'UTF-8') == 2) {
- $datematch[1] = self::getFullYear($datematch[1]);
- }
- if (empty($timematch)) {
- $timematch[1] = 0;
- $timematch[2] = 0;
- $timematch[3] = 0;
- }
- if (!isset($timematch[3])) {
- $timematch[3] = 0;
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$datematch[2];
- --$month;
- --$datematch[3];
- --$day;
- $datematch[1] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($timematch[1], $timematch[2], $timematch[3], 1 + $datematch[2], 1 + $datematch[3], 1970 + $datematch[1], false),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false), false);
- break;
-
- case self::RFC_2822:
- $result = preg_match('/^\w{3},\s(\d{1,2})\s(\w{3})\s(\d{4})\s'
- . '(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]'
- . '{1}\d{4}|\w{1,20})$/', $date, $match);
-
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no RFC 2822 format ($date)", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], false),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false), false);
- break;
-
- case self::TIMESTAMP:
- if (is_numeric($date)) {
- return $this->_assign($calc, $date, $this->getUnixTimestamp());
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, timestamp expected", 0, null, $date);
- break;
-
- // additional formats
- // break intentionally omitted
- case self::ERA:
- case self::ERA_NAME:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('era not supported', 0, null, $date);
- break;
-
- case self::DATES:
- try {
- $parsed = Zend_Locale_Format::getDate($date, array('locale' => $locale, 'format_type' => 'iso', 'fix_date' => true));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_FULL:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'full'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_LONG:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'long'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')){
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_MEDIUM:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'medium'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_SHORT:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'short'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- $parsed['year'] = self::getFullYear($parsed['year']);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIMES:
- try {
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
- $parsed = Zend_Locale_Format::getTime($date, array('locale' => $locale, 'format_type' => 'iso', 'fix_date' => true));
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_FULL:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'full'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_LONG:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'long'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_MEDIUM:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'medium'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_SHORT:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'short'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME:
- try {
- $parsed = Zend_Locale_Format::getDateTime($date, array('locale' => $locale, 'format_type' => 'iso', 'fix_date' => true));
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_FULL:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'full'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_LONG:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'long'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')){
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_MEDIUM:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'medium'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_SHORT:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'short'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- $parsed['year'] = self::getFullYear($parsed['year']);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- // ATOM and RFC_3339 are identical
- case self::ATOM:
- case self::RFC_3339:
- $result = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\d{0,4}([+-]{1}\d{2}:\d{2}|Z)$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, ATOM format expected", 0, null, $date);
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$match[2];
- --$month;
- --$match[3];
- --$day;
- $match[1] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $match[2], 1 + $match[3], 1970 + $match[1], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::COOKIE:
- $result = preg_match("/^\w{6,9},\s(\d{2})-(\w{3})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})\s.{3,20}$/", $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, COOKIE format expected", 0, null, $date);
- }
- $matchStartPos = iconv_strpos($match[0], ' ', 0, 'UTF-8') + 1;
- $match[0] = iconv_substr($match[0],
- $matchStartPos,
- iconv_strlen($match[0], 'UTF-8') - $matchStartPos,
- 'UTF-8');
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::RFC_822:
- case self::RFC_1036:
- // new RFC 822 format, identical to RFC 1036 standard
- $result = preg_match('/^\w{0,3},{0,1}\s{0,1}(\d{1,2})\s(\w{3})\s(\d{2})\s(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]{1}\d{4}|\w{1,20})$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RFC 822 date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], false),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false), false);
- break;
-
- case self::RFC_850:
- $result = preg_match('/^\w{6,9},\s(\d{2})-(\w{3})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})\s.{3,21}$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RFC 850 date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::RFC_1123:
- $result = preg_match('/^\w{0,3},{0,1}\s{0,1}(\d{1,2})\s(\w{3})\s(\d{2,4})\s(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]{1}\d{4}|\w{1,20})$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RFC 1123 date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::RSS:
- $result = preg_match('/^\w{3},\s(\d{2})\s(\w{3})\s(\d{2,4})\s(\d{1,2}):(\d{2}):(\d{2})\s.{1,21}$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RSS date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::W3C:
- $result = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})[+-]{1}\d{2}:\d{2}$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, W3C date format expected", 0, null, $date);
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$match[2];
- --$month;
- --$match[3];
- --$day;
- $match[1] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $match[2], 1 + $match[3], 1970 + $match[1], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- default:
- if (!is_numeric($date) || !empty($part)) {
- try {
- if (empty($part)) {
- $part = Zend_Locale_Format::getDateFormat($locale) . " ";
- $part .= Zend_Locale_Format::getTimeFormat($locale);
- }
-
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $part, 'locale' => $locale, 'fix_date' => true, 'format_type' => 'iso'));
- if ((strpos(strtoupper($part), 'YY') !== false) and (strpos(strtoupper($part), 'YYYY') === false)) {
- $parsed['year'] = self::getFullYear($parsed['year']);
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- if (isset($parsed['month'])) {
- --$parsed['month'];
- } else {
- $parsed['month'] = 0;
- }
-
- if (isset($parsed['day'])) {
- --$parsed['day'];
- } else {
- $parsed['day'] = 0;
- }
-
- if (!isset($parsed['year'])) {
- $parsed['year'] = 1970;
- }
- }
-
- return $this->_assign($calc, $this->mktime(
- isset($parsed['hour']) ? $parsed['hour'] : 0,
- isset($parsed['minute']) ? $parsed['minute'] : 0,
- isset($parsed['second']) ? $parsed['second'] : 0,
- isset($parsed['month']) ? (1 + $parsed['month']) : 1,
- isset($parsed['day']) ? (1 + $parsed['day']) : 1,
- $parsed['year'],
- false), $this->getUnixTimestamp(), false);
- } catch (Zend_Locale_Exception $e) {
- if (!is_numeric($date)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- }
- }
-
- return $this->_assign($calc, $date, $this->getUnixTimestamp(), false);
- break;
- }
- }
-
- /**
- * Returns true when both date objects or date parts are equal.
- * For example:
- * 15.May.2000 <-> 15.June.2000 Equals only for Day or Year... all other will return false
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to equal with
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return boolean
- * @throws Zend_Date_Exception
- */
- public function equals($date, $part = self::TIMESTAMP, $locale = null)
- {
- $result = $this->compare($date, $part, $locale);
-
- if ($result == 0) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns if the given date or datepart is earlier
- * For example:
- * 15.May.2000 <-> 13.June.1999 will return true for day, year and date, but not for month
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to compare with
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return boolean
- * @throws Zend_Date_Exception
- */
- public function isEarlier($date, $part = null, $locale = null)
- {
- $result = $this->compare($date, $part, $locale);
-
- if ($result == -1) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns if the given date or datepart is later
- * For example:
- * 15.May.2000 <-> 13.June.1999 will return true for month but false for day, year and date
- * Returns if the given date is later
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to compare with
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return boolean
- * @throws Zend_Date_Exception
- */
- public function isLater($date, $part = null, $locale = null)
- {
- $result = $this->compare($date, $part, $locale);
-
- if ($result == 1) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns only the time of the date as new Zend_Date object
- * For example:
- * 15.May.2000 10:11:23 will return a dateobject equal to 01.Jan.1970 10:11:23
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getTime($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'H:i:s';
- } else {
- $format = self::TIME_MEDIUM;
- }
-
- return $this->copyPart($format, $locale);
- }
-
- /**
- * Returns the calculated time
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $time Time to calculate with, if null the actual time is taken
- * @param string $format Timeformat for parsing input
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|Zend_Date new time
- * @throws Zend_Date_Exception
- */
- private function _time($calc, $time, $format, $locale)
- {
- if ($time === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $time must be set, null is not allowed');
- }
-
- if ($time instanceof Zend_Date) {
- // extract time from object
- $time = $time->toString('HH:mm:ss', 'iso');
- } else {
- if (is_array($time)) {
- if ((isset($time['hour']) === true) or (isset($time['minute']) === true) or
- (isset($time['second']) === true)) {
- $parsed = $time;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no hour, minute or second given in array");
- }
- } else {
- if (self::$_options['format_type'] == 'php') {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
- try {
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- $parsed = Zend_Locale_Format::getTime($time, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e);
- }
- }
-
- if (!array_key_exists('hour', $parsed)) {
- $parsed['hour'] = 0;
- }
-
- if (!array_key_exists('minute', $parsed)) {
- $parsed['minute'] = 0;
- }
-
- if (!array_key_exists('second', $parsed)) {
- $parsed['second'] = 0;
- }
-
- $time = str_pad($parsed['hour'], 2, '0', STR_PAD_LEFT) . ":";
- $time .= str_pad($parsed['minute'], 2, '0', STR_PAD_LEFT) . ":";
- $time .= str_pad($parsed['second'], 2, '0', STR_PAD_LEFT);
- }
-
- $return = $this->_calcdetail($calc, $time, self::TIMES, 'de');
- if ($calc != 'cmp') {
- return $this;
- }
-
- return $return;
- }
-
-
- /**
- * Sets a new time for the date object. Format defines how to parse the time string.
- * Also a complete date can be given, but only the time is used for setting.
- * For example: dd.MMMM.yyTHH:mm' and 'ss sec'-> 10.May.07T25:11 and 44 sec => 1h11min44sec + 1 day
- * Returned is the new date object and the existing date is left as it was before
- *
- * @param string|integer|array|Zend_Date $time Time to set
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setTime($time, $format = null, $locale = null)
- {
- return $this->_time('set', $time, $format, $locale);
- }
-
-
- /**
- * Adds a time to the existing date. Format defines how to parse the time string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: HH:mm:ss -> 10 -> +10 hours
- *
- * @param string|integer|array|Zend_Date $time Time to add
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addTime($time, $format = null, $locale = null)
- {
- return $this->_time('add', $time, $format, $locale);
- }
-
-
- /**
- * Subtracts a time from the existing date. Format defines how to parse the time string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: HH:mm:ss -> 10 -> -10 hours
- *
- * @param string|integer|array|Zend_Date $time Time to sub
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent inteface
- * @throws Zend_Date_Exception
- */
- public function subTime($time, $format = null, $locale = null)
- {
- return $this->_time('sub', $time, $format, $locale);
- }
-
-
- /**
- * Compares the time from the existing date. Format defines how to parse the time string.
- * If only parts are given the other parts are set to default.
- * If no format us given, the standardformat of this locale is used.
- * For example: HH:mm:ss -> 10 -> 10 hours
- *
- * @param string|integer|array|Zend_Date $time Time to compare
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareTime($time, $format = null, $locale = null)
- {
- return $this->_time('cmp', $time, $format, $locale);
- }
-
- /**
- * Returns a clone of $this, with the time part set to 00:00:00.
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getDate($locale = null)
- {
- $orig = self::$_options['format_type'];
- if (self::$_options['format_type'] == 'php') {
- self::$_options['format_type'] = 'iso';
- }
-
- $date = $this->copyPart(self::DATE_MEDIUM, $locale);
- $date->addTimestamp($this->getGmtOffset());
- self::$_options['format_type'] = $orig;
-
- return $date;
- }
-
- /**
- * Returns the calculated date
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $date Date to calculate with, if null the actual date is taken
- * @param string $format Date format for parsing
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|Zend_Date new date
- * @throws Zend_Date_Exception
- */
- private function _date($calc, $date, $format, $locale)
- {
- if ($date === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $date must be set, null is not allowed');
- }
-
- if ($date instanceof Zend_Date) {
- // extract date from object
- $date = $date->toString('d.M.y', 'iso');
- } else {
- if (is_array($date)) {
- if ((isset($date['year']) === true) or (isset($date['month']) === true) or
- (isset($date['day']) === true)) {
- $parsed = $date;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no day,month or year given in array");
- }
- } else {
- if ((self::$_options['format_type'] == 'php') && !defined($format)) {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
- try {
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
- if ((strpos(strtoupper($format), 'YY') !== false) and (strpos(strtoupper($format), 'YYYY') === false)) {
- $parsed['year'] = self::getFullYear($parsed['year']);
- }
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e);
- }
- }
-
- if (!array_key_exists('day', $parsed)) {
- $parsed['day'] = 1;
- }
-
- if (!array_key_exists('month', $parsed)) {
- $parsed['month'] = 1;
- }
-
- if (!array_key_exists('year', $parsed)) {
- $parsed['year'] = 0;
- }
-
- $date = $parsed['day'] . "." . $parsed['month'] . "." . $parsed['year'];
- }
-
- $return = $this->_calcdetail($calc, $date, self::DATE_MEDIUM, 'de');
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new date for the date object. Format defines how to parse the date string.
- * Also a complete date with time can be given, but only the date is used for setting.
- * For example: MMMM.yy HH:mm-> May.07 22:11 => 01.May.07 00:00
- * Returned is the new date object and the existing time is left as it was before
- *
- * @param string|integer|array|Zend_Date $date Date to set
- * @param string $format OPTIONAL Date format for parsing
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setDate($date, $format = null, $locale = null)
- {
- return $this->_date('set', $date, $format, $locale);
- }
-
-
- /**
- * Adds a date to the existing date object. Format defines how to parse the date string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: MM.dd.YYYY -> 10 -> +10 months
- *
- * @param string|integer|array|Zend_Date $date Date to add
- * @param string $format OPTIONAL Date format for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addDate($date, $format = null, $locale = null)
- {
- return $this->_date('add', $date, $format, $locale);
- }
-
-
- /**
- * Subtracts a date from the existing date object. Format defines how to parse the date string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: MM.dd.YYYY -> 10 -> -10 months
- * Be aware: Subtracting 2 months is not equal to Adding -2 months !!!
- *
- * @param string|integer|array|Zend_Date $date Date to sub
- * @param string $format OPTIONAL Date format for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subDate($date, $format = null, $locale = null)
- {
- return $this->_date('sub', $date, $format, $locale);
- }
-
-
- /**
- * Compares the date from the existing date object, ignoring the time.
- * Format defines how to parse the date string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: 10.01.2000 => 10.02.1999 -> false
- *
- * @param string|integer|array|Zend_Date $date Date to compare
- * @param string $format OPTIONAL Date format for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareDate($date, $format = null, $locale = null)
- {
- return $this->_date('cmp', $date, $format, $locale);
- }
-
-
- /**
- * Returns the full ISO 8601 date from the date object.
- * Always the complete ISO 8601 specifiction is used. If an other ISO date is needed
- * (ISO 8601 defines several formats) use toString() instead.
- * This function does not return the ISO date as object. Use copy() instead.
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string
- */
- public function getIso($locale = null)
- {
- return $this->toString(self::ISO_8601, 'iso', $locale);
- }
-
-
- /**
- * Sets a new date for the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> 01.Sept.2005 00:00:00, 20050201T10:00:30 -> 01.Feb.2005 10h00m30s
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date ISO Date to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setIso($date, $locale = null)
- {
- return $this->_calcvalue('set', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Adds a ISO date to the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> + 01.Sept.2005 00:00:00, 10:00:00 -> +10h
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date ISO Date to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addIso($date, $locale = null)
- {
- return $this->_calcvalue('add', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Subtracts a ISO date from the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date ISO Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subIso($date, $locale = null)
- {
- return $this->_calcvalue('sub', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Compares a ISO date with the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h
- * Returns if equal, earlier or later
- *
- * @param string|integer|Zend_Date $date ISO Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareIso($date, $locale = null)
- {
- return $this->_calcvalue('cmp', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Returns a RFC 822 compilant datestring from the date object.
- * This function does not return the RFC date as object. Use copy() instead.
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string
- */
- public function getArpa($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'D\, d M y H\:i\:s O';
- } else {
- $format = self::RFC_822;
- }
-
- return $this->toString($format, 'iso', $locale);
- }
-
-
- /**
- * Sets a RFC 822 date as new date for the date object.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date RFC 822 to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setArpa($date, $locale = null)
- {
- return $this->_calcvalue('set', $date, 'arpa', self::RFC_822, $locale);
- }
-
-
- /**
- * Adds a RFC 822 date to the date object.
- * ARPA messages are used in emails or HTTP Headers.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date RFC 822 Date to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addArpa($date, $locale = null)
- {
- return $this->_calcvalue('add', $date, 'arpa', self::RFC_822, $locale);
- }
-
-
- /**
- * Subtracts a RFC 822 date from the date object.
- * ARPA messages are used in emails or HTTP Headers.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date RFC 822 Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subArpa($date, $locale = null)
- {
- return $this->_calcvalue('sub', $date, 'arpa', self::RFC_822, $locale);
- }
-
-
- /**
- * Compares a RFC 822 compilant date with the date object.
- * ARPA messages are used in emails or HTTP Headers.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returns if equal, earlier or later
- *
- * @param string|integer|Zend_Date $date RFC 822 Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareArpa($date, $locale = null)
- {
- return $this->_calcvalue('cmp', $date, 'arpa', self::RFC_822, $locale);
- }
-
- /**
- * Check if location is supported
- *
- * @param array $location locations array
- * @throws Zend_Date_Exception
- * @return float $horizon float
- */
- private function _checkLocation($location)
- {
- if (!isset($location['longitude']) or !isset($location['latitude'])) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Location must include \'longitude\' and \'latitude\'', 0, null, $location);
- }
- if (($location['longitude'] > 180) or ($location['longitude'] < -180)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Longitude must be between -180 and 180', 0, null, $location);
- }
- if (($location['latitude'] > 90) or ($location['latitude'] < -90)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Latitude must be between -90 and 90', 0, null, $location);
- }
-
- if (!isset($location['horizon'])){
- $location['horizon'] = 'effective';
- }
-
- switch ($location['horizon']) {
- case 'civil' :
- return -0.104528;
- break;
- case 'nautic' :
- return -0.207912;
- break;
- case 'astronomic' :
- return -0.309017;
- break;
- default :
- return -0.0145439;
- break;
- }
- }
-
-
- /**
- * Returns the time of sunrise for this date and a given location as new date object
- * For a list of cities and correct locations use the class Zend_Date_Cities
- *
- * @param array $location location of sunrise
- * ['horizon'] -> civil, nautic, astronomical, effective (default)
- * ['longitude'] -> longitude of location
- * ['latitude'] -> latitude of location
- * @return Zend_Date
- * @throws Zend_Date_Exception
- */
- public function getSunrise($location)
- {
- $horizon = $this->_checkLocation($location);
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, true), self::TIMESTAMP);
- return $result;
- }
-
-
- /**
- * Returns the time of sunset for this date and a given location as new date object
- * For a list of cities and correct locations use the class Zend_Date_Cities
- *
- * @param array $location location of sunset
- * ['horizon'] -> civil, nautic, astronomical, effective (default)
- * ['longitude'] -> longitude of location
- * ['latitude'] -> latitude of location
- * @return Zend_Date
- * @throws Zend_Date_Exception
- */
- public function getSunset($location)
- {
- $horizon = $this->_checkLocation($location);
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, false), self::TIMESTAMP);
- return $result;
- }
-
-
- /**
- * Returns an array with the sunset and sunrise dates for all horizon types
- * For a list of cities and correct locations use the class Zend_Date_Cities
- *
- * @param array $location location of suninfo
- * ['horizon'] -> civil, nautic, astronomical, effective (default)
- * ['longitude'] -> longitude of location
- * ['latitude'] -> latitude of location
- * @return array - [sunset|sunrise][effective|civil|nautic|astronomic]
- * @throws Zend_Date_Exception
- */
- public function getSunInfo($location)
- {
- $suninfo = array();
- for ($i = 0; $i < 4; ++$i) {
- switch ($i) {
- case 0 :
- $location['horizon'] = 'effective';
- break;
- case 1 :
- $location['horizon'] = 'civil';
- break;
- case 2 :
- $location['horizon'] = 'nautic';
- break;
- case 3 :
- $location['horizon'] = 'astronomic';
- break;
- }
- $horizon = $this->_checkLocation($location);
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, true), self::TIMESTAMP);
- $suninfo['sunrise'][$location['horizon']] = $result;
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, false), self::TIMESTAMP);
- $suninfo['sunset'][$location['horizon']] = $result;
- }
- return $suninfo;
- }
-
- /**
- * Check a given year for leap year.
- *
- * @param integer|array|Zend_Date $year Year to check
- * @throws Zend_Date_Exception
- * @return boolean
- */
- public static function checkLeapYear($year)
- {
- if ($year instanceof Zend_Date) {
- $year = (int) $year->toString(self::YEAR, 'iso');
- }
-
- if (is_array($year)) {
- if (isset($year['year']) === true) {
- $year = $year['year'];
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no year given in array");
- }
- }
-
- if (!is_numeric($year)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("year ($year) has to be integer for checkLeapYear()", 0, null, $year);
- }
-
- return (bool) parent::isYearLeapYear($year);
- }
-
-
- /**
- * Returns true, if the year is a leap year.
- *
- * @return boolean
- */
- public function isLeapYear()
- {
- return self::checkLeapYear($this);
- }
-
-
- /**
- * Returns if the set date is todays date
- *
- * @return boolean
- */
- public function isToday()
- {
- $today = $this->date('Ymd', $this->_getTime());
- $day = $this->date('Ymd', $this->getUnixTimestamp());
- return ($today == $day);
- }
-
-
- /**
- * Returns if the set date is yesterdays date
- *
- * @return boolean
- */
- public function isYesterday()
- {
- list($year, $month, $day) = explode('-', $this->date('Y-m-d', $this->_getTime()));
- // adjusts for leap days and DST changes that are timezone specific
- $yesterday = $this->date('Ymd', $this->mktime(0, 0, 0, $month, $day -1, $year));
- $day = $this->date('Ymd', $this->getUnixTimestamp());
- return $day == $yesterday;
- }
-
-
- /**
- * Returns if the set date is tomorrows date
- *
- * @return boolean
- */
- public function isTomorrow()
- {
- list($year, $month, $day) = explode('-', $this->date('Y-m-d', $this->_getTime()));
- // adjusts for leap days and DST changes that are timezone specific
- $tomorrow = $this->date('Ymd', $this->mktime(0, 0, 0, $month, $day +1, $year));
- $day = $this->date('Ymd', $this->getUnixTimestamp());
- return $day == $tomorrow;
- }
-
- /**
- * Returns the actual date as new date object
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public static function now($locale = null)
- {
- return new Zend_Date(time(), self::TIMESTAMP, $locale);
- }
-
- /**
- * Calculate date details
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $date Date or Part to calculate
- * @param string $type Datepart for Calculation
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|string new date
- * @throws Zend_Date_Exception
- */
- private function _calcdetail($calc, $date, $type, $locale)
- {
- $old = false;
- if (self::$_options['format_type'] == 'php') {
- self::$_options['format_type'] = 'iso';
- $old = true;
- }
-
- switch($calc) {
- case 'set' :
- $return = $this->set($date, $type, $locale);
- break;
- case 'add' :
- $return = $this->add($date, $type, $locale);
- break;
- case 'sub' :
- $return = $this->sub($date, $type, $locale);
- break;
- default :
- $return = $this->compare($date, $type, $locale);
- break;
- }
-
- if ($old) {
- self::$_options['format_type'] = 'php';
- }
-
- return $return;
- }
-
- /**
- * Internal calculation, returns the requested date type
- *
- * @param string $calc Calculation to make
- * @param string|integer|Zend_Date $value Datevalue to calculate with, if null the actual value is taken
- * @param string $type
- * @param string $parameter
- * @param string|Zend_Locale $locale Locale for parsing input
- * @throws Zend_Date_Exception
- * @return integer|Zend_Date new date
- */
- private function _calcvalue($calc, $value, $type, $parameter, $locale)
- {
- if ($value === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("parameter $type must be set, null is not allowed");
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($value instanceof Zend_Date) {
- // extract value from object
- $value = $value->toString($parameter, 'iso', $locale);
- } else if (!is_array($value) && !is_numeric($value) && ($type != 'iso') && ($type != 'arpa')) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid $type ($value) operand", 0, null, $value);
- }
-
- $return = $this->_calcdetail($calc, $value, $parameter, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Returns only the year from the date object as new object.
- * For example: 10.May.2000 10:30:00 -> 01.Jan.2000 00:00:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getYear($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'Y';
- } else {
- $format = self::YEAR;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets a new year
- * If the year is between 0 and 69, 2000 will be set (2000-2069)
- * If the year if between 70 and 99, 1999 will be set (1970-1999)
- * 3 or 4 digit years are set as expected. If you need to set year 0-99
- * use set() instead.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $year Year to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setYear($year, $locale = null)
- {
- return $this->_calcvalue('set', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Adds the year to the existing date object
- * If the year is between 0 and 69, 2000 will be added (2000-2069)
- * If the year if between 70 and 99, 1999 will be added (1970-1999)
- * 3 or 4 digit years are added as expected. If you need to add years from 0-99
- * use add() instead.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $year Year to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addYear($year, $locale = null)
- {
- return $this->_calcvalue('add', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Subs the year from the existing date object
- * If the year is between 0 and 69, 2000 will be subtracted (2000-2069)
- * If the year if between 70 and 99, 1999 will be subtracted (1970-1999)
- * 3 or 4 digit years are subtracted as expected. If you need to subtract years from 0-99
- * use sub() instead.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $year Year to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subYear($year, $locale = null)
- {
- return $this->_calcvalue('sub', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Compares the year with the existing date object, ignoring other date parts.
- * For example: 10.03.2000 -> 15.02.2000 -> true
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $year Year to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareYear($year, $locale = null)
- {
- return $this->_calcvalue('cmp', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Returns only the month from the date object as new object.
- * For example: 10.May.2000 10:30:00 -> 01.May.1970 00:00:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getMonth($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'm';
- } else {
- $format = self::MONTH;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Returns the calculated month
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $month Month to calculate with, if null the actual month is taken
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|Zend_Date new time
- * @throws Zend_Date_Exception
- */
- private function _month($calc, $month, $locale)
- {
- if ($month === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $month must be set, null is not allowed');
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($month instanceof Zend_Date) {
- // extract month from object
- $found = $month->toString(self::MONTH_SHORT, 'iso', $locale);
- } else {
- if (is_numeric($month)) {
- $found = $month;
- } else if (is_array($month)) {
- if (isset($month['month']) === true) {
- $month = $month['month'];
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no month given in array");
- }
- } else {
- $monthlist = Zend_Locale_Data::getList($locale, 'month');
- $monthlist2 = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
-
- $monthlist = array_merge($monthlist, $monthlist2);
- $found = 0;
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($month)) {
- $found = ($key % 12) + 1;
- break;
- }
- ++$cnt;
- }
- if ($found == 0) {
- foreach ($monthlist2 as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($month)) {
- $found = $key + 1;
- break;
- }
- ++$cnt;
- }
- }
- if ($found == 0) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("unknown month name ($month)", 0, null, $month);
- }
- }
- }
- $return = $this->_calcdetail($calc, $found, self::MONTH_SHORT, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new month
- * The month can be a number or a string. Setting months lower then 0 and greater then 12
- * will result in adding or subtracting the relevant year. (12 months equal one year)
- * If a localized monthname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $month Month to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setMonth($month, $locale = null)
- {
- return $this->_month('set', $month, $locale);
- }
-
-
- /**
- * Adds months to the existing date object.
- * The month can be a number or a string. Adding months lower then 0 and greater then 12
- * will result in adding or subtracting the relevant year. (12 months equal one year)
- * If a localized monthname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $month Month to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addMonth($month, $locale = null)
- {
- return $this->_month('add', $month, $locale);
- }
-
-
- /**
- * Subtracts months from the existing date object.
- * The month can be a number or a string. Subtracting months lower then 0 and greater then 12
- * will result in adding or subtracting the relevant year. (12 months equal one year)
- * If a localized monthname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $month Month to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subMonth($month, $locale = null)
- {
- return $this->_month('sub', $month, $locale);
- }
-
-
- /**
- * Compares the month with the existing date object, ignoring other date parts.
- * For example: 10.03.2000 -> 15.03.1950 -> true
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $month Month to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareMonth($month, $locale = null)
- {
- return $this->_month('cmp', $month, $locale);
- }
-
-
- /**
- * Returns the day as new date object
- * Example: 20.May.1986 -> 20.Jan.1970 00:00:00
- *
- * @param Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getDay($locale = null)
- {
- return $this->copyPart(self::DAY_SHORT, $locale);
- }
-
- /**
- * Returns the calculated day
- *
- * @param string $calc Type of calculation to make
- * @param Zend_Date $day Day to calculate, when null the actual day is calculated
- * @param Zend_Locale $locale Locale for parsing input
- * @throws Zend_Date_Exception
- * @return Zend_Date|integer
- */
- private function _day($calc, $day, $locale)
- {
- if ($day === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $day must be set, null is not allowed');
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($day instanceof Zend_Date) {
- $day = $day->toString(self::DAY_SHORT, 'iso', $locale);
- }
-
- if (is_numeric($day)) {
- $type = self::DAY_SHORT;
- } else if (is_array($day)) {
- if (isset($day['day']) === true) {
- $day = $day['day'];
- $type = self::WEEKDAY;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no day given in array");
- }
- } else {
- switch (iconv_strlen($day, 'UTF-8')) {
- case 1 :
- $type = self::WEEKDAY_NARROW;
- break;
- case 2:
- $type = self::WEEKDAY_NAME;
- break;
- case 3:
- $type = self::WEEKDAY_SHORT;
- break;
- default:
- $type = self::WEEKDAY;
- break;
- }
- }
- $return = $this->_calcdetail($calc, $day, $type, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new day
- * The day can be a number or a string. Setting days lower then 0 or greater than the number of this months days
- * will result in adding or subtracting the relevant month.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- * Example: setDay('Montag', 'de_AT'); will set the monday of this week as day.
- *
- * @param string|integer|array|Zend_Date $day Day to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setDay($day, $locale = null)
- {
- return $this->_day('set', $day, $locale);
- }
-
-
- /**
- * Adds days to the existing date object.
- * The day can be a number or a string. Adding days lower then 0 or greater than the number of this months days
- * will result in adding or subtracting the relevant month.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- *
- * @param string|integer|array|Zend_Date $day Day to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addDay($day, $locale = null)
- {
- return $this->_day('add', $day, $locale);
- }
-
-
- /**
- * Subtracts days from the existing date object.
- * The day can be a number or a string. Subtracting days lower then 0 or greater than the number of this months days
- * will result in adding or subtracting the relevant month.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- *
- * @param string|integer|array|Zend_Date $day Day to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subDay($day, $locale = null)
- {
- return $this->_day('sub', $day, $locale);
- }
-
-
- /**
- * Compares the day with the existing date object, ignoring other date parts.
- * For example: 'Monday', 'en' -> 08.Jan.2007 -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $day Day to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareDay($day, $locale = null)
- {
- return $this->_day('cmp', $day, $locale);
- }
-
-
- /**
- * Returns the weekday as new date object
- * Weekday is always from 1-7
- * Example: 09-Jan-2007 -> 2 = Tuesday -> 02-Jan-1970 (when 02.01.1970 is also Tuesday)
- *
- * @param Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getWeekday($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'l';
- } else {
- $format = self::WEEKDAY;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Returns the calculated weekday
- *
- * @param string $calc Type of calculation to make
- * @param Zend_Date $weekday Weekday to calculate, when null the actual weekday is calculated
- * @param Zend_Locale $locale Locale for parsing input
- * @return Zend_Date|integer
- * @throws Zend_Date_Exception
- */
- private function _weekday($calc, $weekday, $locale)
- {
- if ($weekday === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $weekday must be set, null is not allowed');
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($weekday instanceof Zend_Date) {
- $weekday = $weekday->toString(self::WEEKDAY_8601, 'iso', $locale);
- }
-
- if (is_numeric($weekday)) {
- $type = self::WEEKDAY_8601;
- } else if (is_array($weekday)) {
- if (isset($weekday['weekday']) === true) {
- $weekday = $weekday['weekday'];
- $type = self::WEEKDAY;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no weekday given in array");
- }
- } else {
- switch(iconv_strlen($weekday, 'UTF-8')) {
- case 1:
- $type = self::WEEKDAY_NARROW;
- break;
- case 2:
- $type = self::WEEKDAY_NAME;
- break;
- case 3:
- $type = self::WEEKDAY_SHORT;
- break;
- default:
- $type = self::WEEKDAY;
- break;
- }
- }
- $return = $this->_calcdetail($calc, $weekday, $type, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new weekday
- * The weekday can be a number or a string. If a localized weekday name is given,
- * then it will be parsed as a date in $locale (defaults to the same locale as $this).
- * Returned is the new date object.
- * Example: setWeekday(3); will set the wednesday of this week as day.
- *
- * @param string|integer|array|Zend_Date $weekday Weekday to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setWeekday($weekday, $locale = null)
- {
- return $this->_weekday('set', $weekday, $locale);
- }
-
-
- /**
- * Adds weekdays to the existing date object.
- * The weekday can be a number or a string.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- * Example: addWeekday(3); will add the difference of days from the begining of the month until
- * wednesday.
- *
- * @param string|integer|array|Zend_Date $weekday Weekday to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addWeekday($weekday, $locale = null)
- {
- return $this->_weekday('add', $weekday, $locale);
- }
-
-
- /**
- * Subtracts weekdays from the existing date object.
- * The weekday can be a number or a string.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- * Example: subWeekday(3); will subtract the difference of days from the begining of the month until
- * wednesday.
- *
- * @param string|integer|array|Zend_Date $weekday Weekday to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subWeekday($weekday, $locale = null)
- {
- return $this->_weekday('sub', $weekday, $locale);
- }
-
-
- /**
- * Compares the weekday with the existing date object, ignoring other date parts.
- * For example: 'Monday', 'en' -> 08.Jan.2007 -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $weekday Weekday to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareWeekday($weekday, $locale = null)
- {
- return $this->_weekday('cmp', $weekday, $locale);
- }
-
-
- /**
- * Returns the day of year as new date object
- * Example: 02.Feb.1986 10:00:00 -> 02.Feb.1970 00:00:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getDayOfYear($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'D';
- } else {
- $format = self::DAY_OF_YEAR;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets a new day of year
- * The day of year is always a number.
- * Returned is the new date object
- * Example: 04.May.2004 -> setDayOfYear(10) -> 10.Jan.2004
- *
- * @param string|integer|array|Zend_Date $day Day of Year to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('set', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Adds a day of year to the existing date object.
- * The day of year is always a number.
- * Returned is the new date object
- * Example: addDayOfYear(10); will add 10 days to the existing date object.
- *
- * @param string|integer|array|Zend_Date $day Day of Year to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('add', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Subtracts a day of year from the existing date object.
- * The day of year is always a number.
- * Returned is the new date object
- * Example: subDayOfYear(10); will subtract 10 days from the existing date object.
- *
- * @param string|integer|array|Zend_Date $day Day of Year to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('sub', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Compares the day of year with the existing date object.
- * For example: compareDayOfYear(33) -> 02.Feb.2007 -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $day Day of Year to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('cmp', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Returns the hour as new date object
- * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 10:00:00
- *
- * @param Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getHour($locale = null)
- {
- return $this->copyPart(self::HOUR, $locale);
- }
-
-
- /**
- * Sets a new hour
- * The hour is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> setHour(7); -> 04.May.1993 07:07:25
- *
- * @param string|integer|array|Zend_Date $hour Hour to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setHour($hour, $locale = null)
- {
- return $this->_calcvalue('set', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Adds hours to the existing date object.
- * The hour is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> addHour(12); -> 05.May.1993 01:07:25
- *
- * @param string|integer|array|Zend_Date $hour Hour to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addHour($hour, $locale = null)
- {
- return $this->_calcvalue('add', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Subtracts hours from the existing date object.
- * The hour is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> subHour(6); -> 05.May.1993 07:07:25
- *
- * @param string|integer|array|Zend_Date $hour Hour to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subHour($hour, $locale = null)
- {
- return $this->_calcvalue('sub', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Compares the hour with the existing date object.
- * For example: 10:30:25 -> compareHour(10) -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $hour Hour to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareHour($hour, $locale = null)
- {
- return $this->_calcvalue('cmp', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Returns the minute as new date object
- * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:30:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getMinute($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'i';
- } else {
- $format = self::MINUTE;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets a new minute
- * The minute is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> setMinute(29); -> 04.May.1993 13:29:25
- *
- * @param string|integer|array|Zend_Date $minute Minute to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setMinute($minute, $locale = null)
- {
- return $this->_calcvalue('set', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Adds minutes to the existing date object.
- * The minute is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> addMinute(65); -> 04.May.1993 13:12:25
- *
- * @param string|integer|array|Zend_Date $minute Minute to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addMinute($minute, $locale = null)
- {
- return $this->_calcvalue('add', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Subtracts minutes from the existing date object.
- * The minute is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> subMinute(9); -> 04.May.1993 12:58:25
- *
- * @param string|integer|array|Zend_Date $minute Minute to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subMinute($minute, $locale = null)
- {
- return $this->_calcvalue('sub', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Compares the minute with the existing date object.
- * For example: 10:30:25 -> compareMinute(30) -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $minute Hour to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareMinute($minute, $locale = null)
- {
- return $this->_calcvalue('cmp', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Returns the second as new date object
- * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:00:25
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getSecond($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 's';
- } else {
- $format = self::SECOND;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets new seconds to the existing date object.
- * The second is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> setSecond(100); -> 04.May.1993 13:08:40
- *
- * @param string|integer|array|Zend_Date $second Second to set
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setSecond($second, $locale = null)
- {
- return $this->_calcvalue('set', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Adds seconds to the existing date object.
- * The second is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> addSecond(65); -> 04.May.1993 13:08:30
- *
- * @param string|integer|array|Zend_Date $second Second to add
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addSecond($second, $locale = null)
- {
- return $this->_calcvalue('add', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Subtracts seconds from the existing date object.
- * The second is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> subSecond(10); -> 04.May.1993 13:07:15
- *
- * @param string|integer|array|Zend_Date $second Second to sub
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subSecond($second, $locale = null)
- {
- return $this->_calcvalue('sub', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Compares the second with the existing date object.
- * For example: 10:30:25 -> compareSecond(25) -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $second Second to compare
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareSecond($second, $locale = null)
- {
- return $this->_calcvalue('cmp', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Returns the precision for fractional seconds
- *
- * @return integer
- */
- public function getFractionalPrecision()
- {
- return $this->_precision;
- }
-
-
- /**
- * Sets a new precision for fractional seconds
- *
- * @param integer $precision Precision for the fractional datepart 3 = milliseconds
- * @throws Zend_Date_Exception
- * @return Zend_Date Provides a fluent interface
- */
- public function setFractionalPrecision($precision)
- {
- if (!intval($precision) or ($precision < 0) or ($precision > 9)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
- }
-
- $this->_precision = (int) $precision;
- if ($this->_precision < strlen($this->_fractional)) {
- $this->_fractional = substr($this->_fractional, 0, $this->_precision);
- } else {
- $this->_fractional = str_pad($this->_fractional, $this->_precision, '0', STR_PAD_RIGHT);
- }
-
- return $this;
- }
-
-
- /**
- * Returns the milliseconds of the date object
- *
- * @return string
- */
- public function getMilliSecond()
- {
- return $this->_fractional;
- }
-
- /**
- * Sets new milliseconds for the date object
- * Example: setMilliSecond(550, 2) -> equals +5 Sec +50 MilliSec
- *
- * @param integer|Zend_Date $milli (Optional) Millisecond to set, when null the actual millisecond is set
- * @param integer $precision (Optional) Fraction precision of the given milliseconds
- * @throws Zend_Date_Exception
- * @return Zend_Date Provides a fluent interface
- */
- public function setMilliSecond($milli = null, $precision = null)
- {
- if ($milli === null) {
- list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- $precision = 6;
- } else if (!is_numeric($milli)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
- }
-
- if ($precision === null) {
- $precision = $this->_precision;
- }
-
- if (!is_int($precision) || $precision < 1 || $precision > 9) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
- }
-
- $this->_fractional = 0;
- $this->addMilliSecond($milli, $precision);
- return $this;
- }
-
- /**
- * Adds milliseconds to the date object
- *
- * @param integer|Zend_Date $milli (Optional) Millisecond to add, when null the actual millisecond is added
- * @param integer $precision (Optional) Fractional precision for the given milliseconds
- * @throws Zend_Date_Exception
- * @return Zend_Date Provides a fluent interface
- */
- public function addMilliSecond($milli = null, $precision = null)
- {
- if ($milli === null) {
- list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- } else if (!is_numeric($milli)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
- }
-
- if ($precision === null) {
- // Use internal default precision
- // Is not as logic as using the length of the input. But this would break tests and maybe other things
- // as an input value of integer 10, which is used in tests, must be parsed as 10 milliseconds (real milliseconds, precision 3)
- // but with auto-detect of precision, 100 milliseconds would be added.
- $precision = $this->_precision;
- }
-
- if (!is_int($precision) || $precision < 1 || $precision > 9) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception(
- "precision ($precision) must be a positive integer less than 10", 0, null, $precision
- );
- }
-
- if ($this->_precision > $precision) {
- $milli = $milli * pow(10, $this->_precision - $precision);
- } elseif ($this->_precision < $precision) {
- $milli = round($milli / pow(10, $precision - $this->_precision));
- }
-
- $this->_fractional += $milli;
-
- // Add/sub milliseconds + add/sub seconds
- $max = pow(10, $this->_precision);
- // Milli includes seconds
- if ($this->_fractional >= $max) {
- while ($this->_fractional >= $max) {
- $this->addSecond(1);
- $this->_fractional -= $max;
- }
- }
-
- if ($this->_fractional < 0) {
- while ($this->_fractional < 0) {
- $this->subSecond(1);
- $this->_fractional += $max;
- }
- }
-
- if ($this->_precision > strlen($this->_fractional)) {
- $this->_fractional = str_pad($this->_fractional, $this->_precision, '0', STR_PAD_LEFT);
- }
-
- return $this;
- }
-
-
- /**
- * Subtracts a millisecond
- *
- * @param integer|Zend_Date $milli (Optional) Millisecond to sub, when null the actual millisecond is subtracted
- * @param integer $precision (Optional) Fractional precision for the given milliseconds
- * @return Zend_Date Provides a fluent interface
- */
- public function subMilliSecond($milli = null, $precision = null)
- {
- $this->addMilliSecond(0 - $milli, $precision);
- return $this;
- }
-
- /**
- * Compares only the millisecond part, returning the difference
- *
- * @param integer|Zend_Date $milli OPTIONAL Millisecond to compare, when null the actual millisecond is compared
- * @param integer $precision OPTIONAL Fractional precision for the given milliseconds
- * @throws Zend_Date_Exception On invalid input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- */
- public function compareMilliSecond($milli = null, $precision = null)
- {
- if ($milli === null) {
- list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- } else if (is_numeric($milli) === false) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
- }
-
- if ($precision === null) {
- $precision = strlen($milli);
- } else if (!is_int($precision) || $precision < 1 || $precision > 9) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
- }
-
- if ($precision === 0) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('precision is 0');
- }
-
- if ($precision != $this->_precision) {
- if ($precision > $this->_precision) {
- $diff = $precision - $this->_precision;
- $milli = (int) ($milli / (10 * $diff));
- } else {
- $diff = $this->_precision - $precision;
- $milli = (int) ($milli * (10 * $diff));
- }
- }
-
- $comp = $this->_fractional - $milli;
- if ($comp < 0) {
- return -1;
- } else if ($comp > 0) {
- return 1;
- }
- return 0;
- }
-
- /**
- * Returns the week as new date object using monday as begining of the week
- * Example: 12.Jan.2007 -> 08.Jan.1970 00:00:00
- *
- * @param Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getWeek($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'W';
- } else {
- $format = self::WEEK;
- }
-
- return $this->copyPart($format, $locale);
- }
-
- /**
- * Sets a new week. The week is always a number. The day of week is not changed.
- * Returned is the new date object
- * Example: 09.Jan.2007 13:07:25 -> setWeek(1); -> 02.Jan.2007 13:07:25
- *
- * @param string|integer|array|Zend_Date $week Week to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function setWeek($week, $locale = null)
- {
- return $this->_calcvalue('set', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Adds a week. The week is always a number. The day of week is not changed.
- * Returned is the new date object
- * Example: 09.Jan.2007 13:07:25 -> addWeek(1); -> 16.Jan.2007 13:07:25
- *
- * @param string|integer|array|Zend_Date $week Week to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function addWeek($week, $locale = null)
- {
- return $this->_calcvalue('add', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Subtracts a week. The week is always a number. The day of week is not changed.
- * Returned is the new date object
- * Example: 09.Jan.2007 13:07:25 -> subWeek(1); -> 02.Jan.2007 13:07:25
- *
- * @param string|integer|array|Zend_Date $week Week to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides a fluent interface
- * @throws Zend_Date_Exception
- */
- public function subWeek($week, $locale = null)
- {
- return $this->_calcvalue('sub', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Compares only the week part, returning the difference
- * Returned is the new date object
- * Returns if equal, earlier or later
- * Example: 09.Jan.2007 13:07:25 -> compareWeek(2); -> 0
- *
- * @param string|integer|array|Zend_Date $week Week to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- */
- public function compareWeek($week, $locale = null)
- {
- return $this->_calcvalue('cmp', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Sets a new standard locale for the date object.
- * This locale will be used for all functions
- * Returned is the really set locale.
- * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist
- * 'xx_YY' will be set to 'root' because 'xx' does not exist
- *
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @throws Zend_Date_Exception When the given locale does not exist
- * @return Zend_Date Provides fluent interface
- */
- public function setLocale($locale = null)
- {
- try {
- $this->_locale = Zend_Locale::findLocale($locale);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e);
- }
-
- return $this;
- }
-
- /**
- * Returns the actual set locale
- *
- * @return string
- */
- public function getLocale()
- {
- return $this->_locale;
- }
-
- /**
- * Checks if the given date is a real date or datepart.
- * Returns false if a expected datepart is missing or a datepart exceeds its possible border.
- * But the check will only be done for the expected dateparts which are given by format.
- * If no format is given the standard dateformat for the actual locale is used.
- * f.e. 30.February.2007 will return false if format is 'dd.MMMM.YYYY'
- *
- * @param string|array|Zend_Date $date Date to parse for correctness
- * @param string $format (Optional) Format for parsing the date string
- * @param string|Zend_Locale $locale (Optional) Locale for parsing date parts
- * @return boolean True when all date parts are correct
- */
- public static function isDate($date, $format = null, $locale = null)
- {
- if (!is_string($date) && !is_numeric($date) && !($date instanceof Zend_Date) &&
- !is_array($date)) {
- return false;
- }
-
- if (($format !== null) && ($format != 'ee') && ($format != 'ss') && ($format != 'GG') && ($format != 'MM') && ($format != 'EE') && ($format != 'TT')
- && (Zend_Locale::isLocale($format, null, false))) {
- $locale = $format;
- $format = null;
- }
-
- $locale = Zend_Locale::findLocale($locale);
-
- if ($format === null) {
- $format = Zend_Locale_Format::getDateFormat($locale);
- } else if ((self::$_options['format_type'] == 'php') && !defined($format)) {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
-
- $format = self::_getLocalizedToken($format, $locale);
- if (!is_array($date)) {
- try {
- $parsed = Zend_Locale_Format::getDate($date, array('locale' => $locale,
- 'date_format' => $format, 'format_type' => 'iso',
- 'fix_date' => false));
- } catch (Zend_Locale_Exception $e) {
- // Date can not be parsed
- return false;
- }
- } else {
- $parsed = $date;
- }
-
- if (((strpos($format, 'Y') !== false) or (strpos($format, 'y') !== false)) and
- (!isset($parsed['year']))) {
- // Year expected but not found
- return false;
- }
-
- if ((strpos($format, 'M') !== false) and (!isset($parsed['month']))) {
- // Month expected but not found
- return false;
- }
-
- if ((strpos($format, 'd') !== false) and (!isset($parsed['day']))) {
- // Day expected but not found
- return false;
- }
-
- if (((strpos($format, 'H') !== false) or (strpos($format, 'h') !== false)) and
- (!isset($parsed['hour']))) {
- // Hour expected but not found
- return false;
- }
-
- if ((strpos($format, 'm') !== false) and (!isset($parsed['minute']))) {
- // Minute expected but not found
- return false;
- }
-
- if ((strpos($format, 's') !== false) and (!isset($parsed['second']))) {
- // Second expected but not found
- return false;
- }
-
- // Set not given dateparts
- if (isset($parsed['hour']) === false) {
- $parsed['hour'] = 12;
- }
-
- if (isset($parsed['minute']) === false) {
- $parsed['minute'] = 0;
- }
-
- if (isset($parsed['second']) === false) {
- $parsed['second'] = 0;
- }
-
- if (isset($parsed['month']) === false) {
- $parsed['month'] = 1;
- }
-
- if (isset($parsed['day']) === false) {
- $parsed['day'] = 1;
- }
-
- if (isset($parsed['year']) === false) {
- $parsed['year'] = 1970;
- }
-
- if (self::isYearLeapYear($parsed['year'])) {
- $parsed['year'] = 1972;
- } else {
- $parsed['year'] = 1971;
- }
-
- $date = new self($parsed, null, $locale);
- $timestamp = $date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'],
- $parsed['month'], $parsed['day'], $parsed['year']);
-
- if ($parsed['year'] != $date->date('Y', $timestamp)) {
- // Given year differs from parsed year
- return false;
- }
-
- if ($parsed['month'] != $date->date('n', $timestamp)) {
- // Given month differs from parsed month
- return false;
- }
-
- if ($parsed['day'] != $date->date('j', $timestamp)) {
- // Given day differs from parsed day
- return false;
- }
-
- if ($parsed['hour'] != $date->date('G', $timestamp)) {
- // Given hour differs from parsed hour
- return false;
- }
-
- if ($parsed['minute'] != $date->date('i', $timestamp)) {
- // Given minute differs from parsed minute
- return false;
- }
-
- if ($parsed['second'] != $date->date('s', $timestamp)) {
- // Given second differs from parsed second
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns the ISO Token for all localized constants
- *
- * @param string $token Token to normalize
- * @param string $locale Locale to search
- * @return string
- */
- protected static function _getLocalizedToken($token, $locale)
- {
- switch($token) {
- case self::ISO_8601 :
- return "yyyy-MM-ddThh:mm:ss";
- break;
- case self::RFC_2822 :
- return "EEE, dd MMM yyyy HH:mm:ss";
- break;
- case self::DATES :
- return Zend_Locale_Data::getContent($locale, 'date');
- break;
- case self::DATE_FULL :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'full'));
- break;
- case self::DATE_LONG :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'long'));
- break;
- case self::DATE_MEDIUM :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'medium'));
- break;
- case self::DATE_SHORT :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'short'));
- break;
- case self::TIMES :
- return Zend_Locale_Data::getContent($locale, 'time');
- break;
- case self::TIME_FULL :
- return Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'full'));
- break;
- case self::TIME_LONG :
- return Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'long'));
- break;
- case self::TIME_MEDIUM :
- return Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'medium'));
- break;
- case self::TIME_SHORT :
- return Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'short'));
- break;
- case self::DATETIME :
- return Zend_Locale_Data::getContent($locale, 'datetime');
- break;
- case self::DATETIME_FULL :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'full'));
- break;
- case self::DATETIME_LONG :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'long'));
- break;
- case self::DATETIME_MEDIUM :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'medium'));
- break;
- case self::DATETIME_SHORT :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'short'));
- break;
- case self::ATOM :
- case self::RFC_3339 :
- case self::W3C :
- return "yyyy-MM-DD HH:mm:ss";
- break;
- case self::COOKIE :
- case self::RFC_850 :
- return "EEEE, dd-MM-yyyy HH:mm:ss";
- break;
- case self::RFC_822 :
- case self::RFC_1036 :
- case self::RFC_1123 :
- case self::RSS :
- return "EEE, dd MM yyyy HH:mm:ss";
- break;
- }
-
- return $token;
- }
-}
diff --git a/lib/zend/Zend/Date/Cities.php b/lib/zend/Zend/Date/Cities.php
deleted file mode 100644
index 6934d690e056b..0000000000000
--- a/lib/zend/Zend/Date/Cities.php
+++ /dev/null
@@ -1,322 +0,0 @@
- array('latitude' => 5.3411111, 'longitude' => -4.0280556),
- 'Abu Dhabi' => array('latitude' => 24.4666667, 'longitude' => 54.3666667),
- 'Abuja' => array('latitude' => 9.1758333, 'longitude' => 7.1808333),
- 'Accra' => array('latitude' => 5.55, 'longitude' => -0.2166667),
- 'Adamstown' => array('latitude' => -25.0666667, 'longitude' => -130.0833333),
- 'Addis Ababa' => array('latitude' => 9.0333333, 'longitude' => 38.7),
- 'Adelaide' => array('latitude' => -34.9333333, 'longitude' => 138.6),
- 'Algiers' => array('latitude' => 36.7630556, 'longitude' => 3.0505556),
- 'Alofi' => array('latitude' => -19.0166667, 'longitude' => -169.9166667),
- 'Amman' => array('latitude' => 31.95, 'longitude' => 35.9333333),
- 'Amsterdam' => array('latitude' => 52.35, 'longitude' => 4.9166667),
- 'Andorra la Vella' => array('latitude' => 42.5, 'longitude' => 1.5166667),
- 'Ankara' => array('latitude' => 39.9272222, 'longitude' => 32.8644444),
- 'Antananarivo' => array('latitude' => -18.9166667, 'longitude' => 47.5166667),
- 'Apia' => array('latitude' => -13.8333333, 'longitude' => -171.7333333),
- 'Ashgabat' => array('latitude' => 37.95, 'longitude' => 58.3833333),
- 'Asmara' => array('latitude' => 15.3333333, 'longitude' => 38.9333333),
- 'Astana' => array('latitude' => 51.1811111, 'longitude' => 71.4277778),
- 'Asunción' => array('latitude' => -25.2666667, 'longitude' => -57.6666667),
- 'Athens' => array('latitude' => 37.9833333, 'longitude' => 23.7333333),
- 'Auckland' => array('latitude' => -36.8666667, 'longitude' => 174.7666667),
- 'Avarua' => array('latitude' => -21.2, 'longitude' => -159.7666667),
- 'Baghdad' => array('latitude' => 33.3386111, 'longitude' => 44.3938889),
- 'Baku' => array('latitude' => 40.3952778, 'longitude' => 49.8822222),
- 'Bamako' => array('latitude' => 12.65, 'longitude' => -8),
- 'Bandar Seri Begawan' => array('latitude' => 4.8833333, 'longitude' => 114.9333333),
- 'Bankok' => array('latitude' => 13.5833333, 'longitude' => 100.2166667),
- 'Bangui' => array('latitude' => 4.3666667, 'longitude' => 18.5833333),
- 'Banjul' => array('latitude' => 13.4530556, 'longitude' => -16.5775),
- 'Basel' => array('latitude' => 47.5666667, 'longitude' => 7.6),
- 'Basseterre' => array('latitude' => 17.3, 'longitude' => -62.7166667),
- 'Beijing' => array('latitude' => 39.9288889, 'longitude' => 116.3883333),
- 'Beirut' => array('latitude' => 33.8719444, 'longitude' => 35.5097222),
- 'Belgrade' => array('latitude' => 44.8186111, 'longitude' => 20.4680556),
- 'Belmopan' => array('latitude' => 17.25, 'longitude' => -88.7666667),
- 'Berlin' => array('latitude' => 52.5166667, 'longitude' => 13.4),
- 'Bern' => array('latitude' => 46.9166667, 'longitude' => 7.4666667),
- 'Bishkek' => array('latitude' => 42.8730556, 'longitude' => 74.6002778),
- 'Bissau' => array('latitude' => 11.85, 'longitude' => -15.5833333),
- 'Bloemfontein' => array('latitude' => -29.1333333, 'longitude' => 26.2),
- 'Bogotá' => array('latitude' => 4.6, 'longitude' => -74.0833333),
- 'Brasilia' => array('latitude' => -15.7833333, 'longitude' => -47.9166667),
- 'Bratislava' => array('latitude' => 48.15, 'longitude' => 17.1166667),
- 'Brazzaville' => array('latitude' => -4.2591667, 'longitude' => 15.2847222),
- 'Bridgetown' => array('latitude' => 13.1, 'longitude' => -59.6166667),
- 'Brisbane' => array('latitude' => -27.5, 'longitude' => 153.0166667),
- 'Brussels' => array('latitude' => 50.8333333, 'longitude' => 4.3333333),
- 'Bucharest' => array('latitude' => 44.4333333, 'longitude' => 26.1),
- 'Budapest' => array('latitude' => 47.5, 'longitude' => 19.0833333),
- 'Buenos Aires' => array('latitude' => -34.5875, 'longitude' => -58.6725),
- 'Bujumbura' => array('latitude' => -3.3761111, 'longitude' => 29.36),
- 'Cairo' => array('latitude' => 30.05, 'longitude' => 31.25),
- 'Calgary' => array('latitude' => 51.0833333, 'longitude' => -114.0833333),
- 'Canberra' => array('latitude' => -35.2833333, 'longitude' => 149.2166667),
- 'Cape Town' => array('latitude' => -33.9166667, 'longitude' => 18.4166667),
- 'Caracas' => array('latitude' => 10.5, 'longitude' => -66.9166667),
- 'Castries' => array('latitude' => 14, 'longitude' => -61),
- 'Charlotte Amalie' => array('latitude' => 18.34389, 'longitude' => -64.93111),
- 'Chicago' => array('latitude' => 41.85, 'longitude' => -87.65),
- 'Chisinau' => array('latitude' => 47.055556, 'longitude' => 28.8575),
- 'Cockburn Town' => array('latitude' => 21.4666667, 'longitude' => -71.1333333),
- 'Colombo' => array('latitude' => 6.9319444, 'longitude' => 79.8477778),
- 'Conakry' => array('latitude' => 9.5091667, 'longitude' => -13.7122222),
- 'Copenhagen' => array('latitude' => 55.6666667, 'longitude' => 12.5833333),
- 'Cotonou' => array('latitude' => 6.35, 'longitude' => 2.4333333),
- 'Dakar' => array('latitude' => 14.6708333, 'longitude' => -17.4380556),
- 'Damascus' => array('latitude' => 33.5, 'longitude' => 36.3),
- 'Dar es Salaam' => array('latitude' => -6.8, 'longitude' => 39.2833333),
- 'Dhaka' => array('latitude' => 23.7230556, 'longitude' => 90.4086111),
- 'Dili' => array('latitude' => -8.5586111, 'longitude' => 125.5736111),
- 'Djibouti' => array('latitude' => 11.595, 'longitude' => 43.1480556),
- 'Dodoma' => array('latitude' => -6.1833333, 'longitude' => 35.75),
- 'Doha' => array('latitude' => 25.2866667, 'longitude' => 51.5333333),
- 'Dubai' => array('latitude' => 25.2522222, 'longitude' => 55.28),
- 'Dublin' => array('latitude' => 53.3330556, 'longitude' => -6.2488889),
- 'Dushanbe' => array('latitude' => 38.56, 'longitude' => 68.7738889 ),
- 'Fagatogo' => array('latitude' => -14.2825, 'longitude' => -170.69),
- 'Fongafale' => array('latitude' => -8.5166667, 'longitude' => 179.2166667),
- 'Freetown' => array('latitude' => 8.49, 'longitude' => -13.2341667),
- 'Gaborone' => array('latitude' => -24.6463889, 'longitude' => 25.9119444),
- 'Geneva' => array('latitude' => 46.2, 'longitude' => 6.1666667),
- 'George Town' => array('latitude' => 19.3, 'longitude' => -81.3833333),
- 'Georgetown' => array('latitude' => 6.8, 'longitude' => -58.1666667),
- 'Gibraltar' => array('latitude' => 36.1333333, 'longitude' => -5.35),
- 'Glasgow' => array('latitude' => 55.8333333, 'longitude' => -4.25),
- 'Guatemala la Nueva' => array('latitude' => 14.6211111, 'longitude' => -90.5269444),
- 'Hagatna' => array('latitude' => 13.47417, 'longitude' => 144.74778),
- 'The Hague' => array('latitude' => 52.0833333, 'longitude' => 4.3),
- 'Hamilton' => array('latitude' => 32.2941667, 'longitude' => -64.7838889),
- 'Hanoi' => array('latitude' => 21.0333333, 'longitude' => 105.85),
- 'Harare' => array('latitude' => -17.8177778, 'longitude' => 31.0447222),
- 'Havana' => array('latitude' => 23.1319444, 'longitude' => -82.3641667),
- 'Helsinki' => array('latitude' => 60.1755556, 'longitude' => 24.9341667),
- 'Honiara' => array('latitude' => -9.4333333, 'longitude' => 159.95),
- 'Islamabad' => array('latitude' => 30.8486111, 'longitude' => 72.4944444),
- 'Istanbul' => array('latitude' => 41.0186111, 'longitude' => 28.9647222),
- 'Jakarta' => array('latitude' => -6.1744444, 'longitude' => 106.8294444),
- 'Jamestown' => array('latitude' => -15.9333333, 'longitude' => -5.7166667),
- 'Jerusalem' => array('latitude' => 31.7666667, 'longitude' => 35.2333333),
- 'Johannesburg' => array('latitude' => -26.2, 'longitude' => 28.0833333),
- 'Kabul' => array('latitude' => 34.5166667, 'longitude' => 69.1833333),
- 'Kampala' => array('latitude' => 0.3155556, 'longitude' => 32.5655556),
- 'Kathmandu' => array('latitude' => 27.7166667, 'longitude' => 85.3166667),
- 'Khartoum' => array('latitude' => 15.5880556, 'longitude' => 32.5341667),
- 'Kigali' => array('latitude' => -1.9536111, 'longitude' => 30.0605556),
- 'Kingston' => array('latitude' => -29.05, 'longitude' => 167.95),
- 'Kingstown' => array('latitude' => 13.1333333, 'longitude' => -61.2166667),
- 'Kinshasa' => array('latitude' => -4.3, 'longitude' => 15.3),
- 'Kolkata' => array('latitude' => 22.5697222, 'longitude' => 88.3697222),
- 'Kuala Lumpur' => array('latitude' => 3.1666667, 'longitude' => 101.7),
- 'Kuwait City' => array('latitude' => 29.3697222, 'longitude' => 47.9783333),
- 'Kiev' => array('latitude' => 50.4333333, 'longitude' => 30.5166667),
- 'La Paz' => array('latitude' => -16.5, 'longitude' => -68.15),
- 'Libreville' => array('latitude' => 0.3833333, 'longitude' => 9.45),
- 'Lilongwe' => array('latitude' => -13.9833333, 'longitude' => 33.7833333),
- 'Lima' => array('latitude' => -12.05, 'longitude' => -77.05),
- 'Lisbon' => array('latitude' => 38.7166667, 'longitude' => -9.1333333),
- 'Ljubljana' => array('latitude' => 46.0552778, 'longitude' => 14.5144444),
- 'Lobamba' => array('latitude' => -26.4666667, 'longitude' => 31.2),
- 'Lomé' => array('latitude' => 9.7166667, 'longitude' => 38.3),
- 'London' => array('latitude' => 51.5, 'longitude' => -0.1166667),
- 'Los Angeles' => array('latitude' => 34.05222, 'longitude' => -118.24278),
- 'Luanda' => array('latitude' => -8.8383333, 'longitude' => 13.2344444),
- 'Lusaka' => array('latitude' => -15.4166667, 'longitude' => 28.2833333),
- 'Luxembourg' => array('latitude' => 49.6116667, 'longitude' => 6.13),
- 'Madrid' => array('latitude' => 40.4, 'longitude' => -3.6833333),
- 'Majuro' => array('latitude' => 7.1, 'longitude' => 171.3833333),
- 'Malabo' => array('latitude' => 3.75, 'longitude' => 8.7833333),
- 'Managua' => array('latitude' => 12.1508333, 'longitude' => -86.2683333),
- 'Manama' => array('latitude' => 26.2361111, 'longitude' => 50.5830556),
- 'Manila' => array('latitude' => 14.6041667, 'longitude' => 120.9822222),
- 'Maputo' => array('latitude' => -25.9652778, 'longitude' => 32.5891667),
- 'Maseru' => array('latitude' => -29.3166667, 'longitude' => 27.4833333),
- 'Mbabane' => array('latitude' => -26.3166667, 'longitude' => 31.1333333),
- 'Melbourne' => array('latitude' => -37.8166667, 'longitude' => 144.9666667),
- 'Melekeok' => array('latitude' => 7.4933333, 'longitude' => 134.6341667),
- 'Mexiko City' => array('latitude' => 19.4341667, 'longitude' => -99.1386111),
- 'Minsk' => array('latitude' => 53.9, 'longitude' => 27.5666667),
- 'Mogadishu' => array('latitude' => 2.0666667, 'longitude' => 45.3666667),
- 'Monaco' => array('latitude' => 43.7333333, 'longitude' => 7.4166667),
- 'Monrovia' => array('latitude' => 6.3105556, 'longitude' => -10.8047222),
- 'Montevideo' => array('latitude' => -34.8580556, 'longitude' => -56.1708333),
- 'Montreal' => array('latitude' => 45.5, 'longitude' => -73.5833333),
- 'Moroni' => array('latitude' => -11.7041667, 'longitude' => 43.2402778),
- 'Moscow' => array('latitude' => 55.7522222, 'longitude' => 37.6155556),
- 'Muscat' => array('latitude' => 23.6133333, 'longitude' => 58.5933333),
- 'Nairobi' => array('latitude' => -1.3166667, 'longitude' => 36.8333333),
- 'Nassau' => array('latitude' => 25.0833333, 'longitude' => -77.35),
- 'N´Djamena' => array('latitude' => 12.1130556, 'longitude' => 15.0491667),
- 'New Dehli' => array('latitude' => 28.6, 'longitude' => 77.2),
- 'New York' => array('latitude' => 40.71417, 'longitude' => -74.00639),
- 'Newcastle' => array('latitude' => -32.9166667, 'longitude' => 151.75),
- 'Niamey' => array('latitude' => 13.6666667, 'longitude' => 1.7833333),
- 'Nicosia' => array('latitude' => 35.1666667, 'longitude' => 33.3666667),
- 'Nouakchott' => array('latitude' => 18.0863889, 'longitude' => -15.9752778),
- 'Noumea' => array('latitude' => -22.2666667, 'longitude' => 166.45),
- 'Nuku´alofa' => array('latitude' => -21.1333333, 'longitude' => -175.2),
- 'Nuuk' => array('latitude' => 64.1833333, 'longitude' => -51.75),
- 'Oranjestad' => array('latitude' => 12.5166667, 'longitude' => -70.0333333),
- 'Oslo' => array('latitude' => 59.9166667, 'longitude' => 10.75),
- 'Ouagadougou' => array('latitude' => 12.3702778, 'longitude' => -1.5247222),
- 'Palikir' => array('latitude' => 6.9166667, 'longitude' => 158.15),
- 'Panama City' => array('latitude' => 8.9666667, 'longitude' => -79.5333333),
- 'Papeete' => array('latitude' => -17.5333333, 'longitude' => -149.5666667),
- 'Paramaribo' => array('latitude' => 5.8333333, 'longitude' => -55.1666667),
- 'Paris' => array('latitude' => 48.8666667, 'longitude' => 2.3333333),
- 'Perth' => array('latitude' => -31.9333333, 'longitude' => 115.8333333),
- 'Phnom Penh' => array('latitude' => 11.55, 'longitude' => 104.9166667),
- 'Podgorica' => array('latitude' => 43.7752778, 'longitude' => 19.6827778),
- 'Port Louis' => array('latitude' => -20.1666667, 'longitude' => 57.5),
- 'Port Moresby' => array('latitude' => -9.4647222, 'longitude' => 147.1925),
- 'Port-au-Prince' => array('latitude' => 18.5391667, 'longitude' => -72.335),
- 'Port of Spain' => array('latitude' => 10.6666667, 'longitude' => -61.5),
- 'Porto-Novo' => array('latitude' => 6.4833333, 'longitude' => 2.6166667),
- 'Prague' => array('latitude' => 50.0833333, 'longitude' => 14.4666667),
- 'Praia' => array('latitude' => 14.9166667, 'longitude' => -23.5166667),
- 'Pretoria' => array('latitude' => -25.7069444, 'longitude' => 28.2294444),
- 'Pyongyang' => array('latitude' => 39.0194444, 'longitude' => 125.7547222),
- 'Quito' => array('latitude' => -0.2166667, 'longitude' => -78.5),
- 'Rabat' => array('latitude' => 34.0252778, 'longitude' => -6.8361111),
- 'Reykjavik' => array('latitude' => 64.15, 'longitude' => -21.95),
- 'Riga' => array('latitude' => 56.95, 'longitude' => 24.1),
- 'Rio de Janero' => array('latitude' => -22.9, 'longitude' => -43.2333333),
- 'Road Town' => array('latitude' => 18.4166667, 'longitude' => -64.6166667),
- 'Rome' => array('latitude' => 41.9, 'longitude' => 12.4833333),
- 'Roseau' => array('latitude' => 15.3, 'longitude' => -61.4),
- 'Rotterdam' => array('latitude' => 51.9166667, 'longitude' => 4.5),
- 'Salvador' => array('latitude' => -12.9833333, 'longitude' => -38.5166667),
- 'San José' => array('latitude' => 9.9333333, 'longitude' => -84.0833333),
- 'San Juan' => array('latitude' => 18.46833, 'longitude' => -66.10611),
- 'San Marino' => array('latitude' => 43.5333333, 'longitude' => 12.9666667),
- 'San Salvador' => array('latitude' => 13.7086111, 'longitude' => -89.2030556),
- 'Sanaá' => array('latitude' => 15.3547222, 'longitude' => 44.2066667),
- 'Santa Cruz' => array('latitude' => -17.8, 'longitude' => -63.1666667),
- 'Santiago' => array('latitude' => -33.45, 'longitude' => -70.6666667),
- 'Santo Domingo' => array('latitude' => 18.4666667, 'longitude' => -69.9),
- 'Sao Paulo' => array('latitude' => -23.5333333, 'longitude' => -46.6166667),
- 'Sarajevo' => array('latitude' => 43.85, 'longitude' => 18.3833333),
- 'Seoul' => array('latitude' => 37.5663889, 'longitude' => 126.9997222),
- 'Shanghai' => array('latitude' => 31.2222222, 'longitude' => 121.4580556),
- 'Sydney' => array('latitude' => -33.8833333, 'longitude' => 151.2166667),
- 'Singapore' => array('latitude' => 1.2930556, 'longitude' => 103.8558333),
- 'Skopje' => array('latitude' => 42, 'longitude' => 21.4333333),
- 'Sofia' => array('latitude' => 42.6833333, 'longitude' => 23.3166667),
- 'St. George´s' => array('latitude' => 12.05, 'longitude' => -61.75),
- 'St. John´s' => array('latitude' => 17.1166667, 'longitude' => -61.85),
- 'Stanley' => array('latitude' => -51.7, 'longitude' => -57.85),
- 'Stockholm' => array('latitude' => 59.3333333, 'longitude' => 18.05),
- 'Suva' => array('latitude' => -18.1333333, 'longitude' => 178.4166667),
- 'Taipei' => array('latitude' => 25.0166667, 'longitude' => 121.45),
- 'Tallinn' => array('latitude' => 59.4338889, 'longitude' => 24.7280556),
- 'Tashkent' => array('latitude' => 41.3166667, 'longitude' => 69.25),
- 'Tbilisi' => array('latitude' => 41.725, 'longitude' => 44.7908333),
- 'Tegucigalpa' => array('latitude' => 14.1, 'longitude' => -87.2166667),
- 'Tehran' => array('latitude' => 35.6719444, 'longitude' => 51.4244444),
- 'The Hague' => array('latitude' => 52.0833333, 'longitude' => 4.3),
- 'Thimphu' => array('latitude' => 27.4833333, 'longitude' => 89.6),
- 'Tirana' => array('latitude' => 41.3275, 'longitude' => 19.8188889),
- 'Tiraspol' => array('latitude' => 46.8402778, 'longitude' => 29.6433333),
- 'Tokyo' => array('latitude' => 35.685, 'longitude' => 139.7513889),
- 'Toronto' => array('latitude' => 43.6666667, 'longitude' => -79.4166667),
- 'Tórshavn' => array('latitude' => 62.0166667, 'longitude' => -6.7666667),
- 'Tripoli' => array('latitude' => 32.8925, 'longitude' => 13.18),
- 'Tunis' => array('latitude' => 36.8027778, 'longitude' => 10.1797222),
- 'Ulaanbaatar' => array('latitude' => 47.9166667, 'longitude' => 106.9166667),
- 'Vaduz' => array('latitude' => 47.1333333, 'longitude' => 9.5166667),
- 'Valletta' => array('latitude' => 35.8997222, 'longitude' => 14.5147222),
- 'Valparaiso' => array('latitude' => -33.0477778, 'longitude' => -71.6011111),
- 'Vancouver' => array('latitude' => 49.25, 'longitude' => -123.1333333),
- 'Vatican City' => array('latitude' => 41.9, 'longitude' => 12.4833333),
- 'Victoria' => array('latitude' => -4.6166667, 'longitude' => 55.45),
- 'Vienna' => array('latitude' => 48.2, 'longitude' => 16.3666667),
- 'Vientaine' => array('latitude' => 17.9666667, 'longitude' => 102.6),
- 'Vilnius' => array('latitude' => 54.6833333, 'longitude' => 25.3166667),
- 'Warsaw' => array('latitude' => 52.25, 'longitude' => 21),
- 'Washington dc' => array('latitude' => 38.895, 'longitude' => -77.03667),
- 'Wellington' => array('latitude' => -41.3, 'longitude' => 174.7833333),
- 'Willemstad' => array('latitude' => 12.1, 'longitude' => -68.9166667),
- 'Windhoek' => array('latitude' => -22.57, 'longitude' => 17.0836111),
- 'Yamoussoukro' => array('latitude' => 6.8166667, 'longitude' => -5.2833333),
- 'Yaoundé' => array('latitude' => 3.8666667, 'longitude' => 11.5166667),
- 'Yerevan' => array('latitude' => 40.1811111, 'longitude' => 44.5136111),
- 'Zürich' => array('latitude' => 47.3666667, 'longitude' => 8.55),
- 'Zagreb' => array('latitude' => 45.8, 'longitude' => 16)
- );
-
- /**
- * Returns the location from the selected city
- *
- * @param string $city City to get location for
- * @param string $horizon Horizon to use :
- * default: effective
- * others are civil, nautic, astronomic
- * @return array
- * @throws Zend_Date_Exception When city is unknown
- */
- public static function City($city, $horizon = false)
- {
- foreach (self::$cities as $key => $value) {
- if (strtolower($key) === strtolower($city)) {
- $return = $value;
- $return['horizon'] = $horizon;
- return $return;
- }
- }
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('unknown city');
- }
-
- /**
- * Return a list with all known cities
- *
- * @return array
- */
- public static function getCityList()
- {
- return array_keys(self::$cities);
- }
-}
diff --git a/lib/zend/Zend/Date/DateObject.php b/lib/zend/Zend/Date/DateObject.php
deleted file mode 100644
index 0ec9fce9fc2d0..0000000000000
--- a/lib/zend/Zend/Date/DateObject.php
+++ /dev/null
@@ -1,1096 +0,0 @@
- 0, 1960 => -315619200, 1950 => -631152000,
- 1940 => -946771200, 1930 => -1262304000, 1920 => -1577923200,
- 1910 => -1893456000, 1900 => -2208988800, 1890 => -2524521600,
- 1880 => -2840140800, 1870 => -3155673600, 1860 => -3471292800,
- 1850 => -3786825600, 1840 => -4102444800, 1830 => -4417977600,
- 1820 => -4733596800, 1810 => -5049129600, 1800 => -5364662400,
- 1790 => -5680195200, 1780 => -5995814400, 1770 => -6311347200,
- 1760 => -6626966400, 1750 => -6942499200, 1740 => -7258118400,
- 1730 => -7573651200, 1720 => -7889270400, 1710 => -8204803200,
- 1700 => -8520336000, 1690 => -8835868800, 1680 => -9151488000,
- 1670 => -9467020800, 1660 => -9782640000, 1650 => -10098172800,
- 1640 => -10413792000, 1630 => -10729324800, 1620 => -11044944000,
- 1610 => -11360476800, 1600 => -11676096000);
-
- /**
- * Set this object to have a new UNIX timestamp.
- *
- * @param string|integer $timestamp OPTIONAL timestamp; defaults to local time using time()
- * @return string|integer old timestamp
- * @throws Zend_Date_Exception
- */
- protected function setUnixTimestamp($timestamp = null)
- {
- $old = $this->_unixTimestamp;
-
- if (is_numeric($timestamp)) {
- $this->_unixTimestamp = $timestamp;
- } else if ($timestamp === null) {
- $this->_unixTimestamp = time();
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('\'' . $timestamp . '\' is not a valid UNIX timestamp', 0, null, $timestamp);
- }
-
- return $old;
- }
-
- /**
- * Returns this object's UNIX timestamp
- * A timestamp greater then the integer range will be returned as string
- * This function does not return the timestamp as object. Use copy() instead.
- *
- * @return integer|string timestamp
- */
- protected function getUnixTimestamp()
- {
- if ($this->_unixTimestamp === intval($this->_unixTimestamp)) {
- return (int) $this->_unixTimestamp;
- } else {
- return (string) $this->_unixTimestamp;
- }
- }
-
- /**
- * Internal function.
- * Returns time(). This method exists to allow unit tests to work-around methods that might otherwise
- * be hard-coded to use time(). For example, this makes it possible to test isYesterday() in Date.php.
- *
- * @param integer $sync OPTIONAL time syncronisation value
- * @return integer timestamp
- */
- protected function _getTime($sync = null)
- {
- if ($sync !== null) {
- $this->_syncronised = round($sync);
- }
- return (time() + $this->_syncronised);
- }
-
- /**
- * Internal mktime function used by Zend_Date.
- * The timestamp returned by mktime() can exceed the precision of traditional UNIX timestamps,
- * by allowing PHP to auto-convert to using a float value.
- *
- * Returns a timestamp relative to 1970/01/01 00:00:00 GMT/UTC.
- * DST (Summer/Winter) is depriciated since php 5.1.0.
- * Year has to be 4 digits otherwise it would be recognised as
- * year 70 AD instead of 1970 AD as expected !!
- *
- * @param integer $hour
- * @param integer $minute
- * @param integer $second
- * @param integer $month
- * @param integer $day
- * @param integer $year
- * @param boolean $gmt OPTIONAL true = other arguments are for UTC time, false = arguments are for local time/date
- * @return integer|float timestamp (number of seconds elapsed relative to 1970/01/01 00:00:00 GMT/UTC)
- */
- protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = false)
- {
- // complete date but in 32bit timestamp - use PHP internal
- if ((1901 < $year) and ($year < 2038)) {
-
- $oldzone = @date_default_timezone_get();
- // Timezone also includes DST settings, therefor substracting the GMT offset is not enough
- // We have to set the correct timezone to get the right value
- if (($this->_timezone != $oldzone) and ($gmt === false)) {
- date_default_timezone_set($this->_timezone);
- }
- $result = ($gmt) ? @gmmktime($hour, $minute, $second, $month, $day, $year)
- : @mktime($hour, $minute, $second, $month, $day, $year);
- date_default_timezone_set($oldzone);
-
- return $result;
- }
-
- if ($gmt !== true) {
- $second += $this->_offset;
- }
-
- if (isset(self::$_cache)) {
- $id = strtr('Zend_DateObject_mkTime_' . $this->_offset . '_' . $year.$month.$day.'_'.$hour.$minute.$second . '_'.(int)$gmt, '-','_');
- if ($result = self::$_cache->load($id)) {
- return unserialize($result);
- }
- }
-
- // date to integer
- $day = intval($day);
- $month = intval($month);
- $year = intval($year);
-
- // correct months > 12 and months < 1
- if ($month > 12) {
- $overlap = floor($month / 12);
- $year += $overlap;
- $month -= $overlap * 12;
- } else {
- $overlap = ceil((1 - $month) / 12);
- $year -= $overlap;
- $month += $overlap * 12;
- }
-
- $date = 0;
- if ($year >= 1970) {
-
- // Date is after UNIX epoch
- // go through leapyears
- // add months from latest given year
- for ($count = 1970; $count <= $year; $count++) {
-
- $leapyear = self::isYearLeapYear($count);
- if ($count < $year) {
-
- $date += 365;
- if ($leapyear === true) {
- $date++;
- }
-
- } else {
-
- for ($mcount = 0; $mcount < ($month - 1); $mcount++) {
- $date += self::$_monthTable[$mcount];
- if (($leapyear === true) and ($mcount == 1)) {
- $date++;
- }
-
- }
- }
- }
-
- $date += $day - 1;
- $date = (($date * 86400) + ($hour * 3600) + ($minute * 60) + $second);
- } else {
-
- // Date is before UNIX epoch
- // go through leapyears
- // add months from latest given year
- for ($count = 1969; $count >= $year; $count--) {
-
- $leapyear = self::isYearLeapYear($count);
- if ($count > $year)
- {
- $date += 365;
- if ($leapyear === true)
- $date++;
- } else {
-
- for ($mcount = 11; $mcount > ($month - 1); $mcount--) {
- $date += self::$_monthTable[$mcount];
- if (($leapyear === true) and ($mcount == 2)) {
- $date++;
- }
-
- }
- }
- }
-
- $date += (self::$_monthTable[$month - 1] - $day);
- $date = -(($date * 86400) + (86400 - (($hour * 3600) + ($minute * 60) + $second)));
-
- // gregorian correction for 5.Oct.1582
- if ($date < -12220185600) {
- $date += 864000;
- } else if ($date < -12219321600) {
- $date = -12219321600;
- }
- }
-
- if (isset(self::$_cache)) {
- if (self::$_cacheTags) {
- self::$_cache->save( serialize($date), $id, array('Zend_Date'));
- } else {
- self::$_cache->save( serialize($date), $id);
- }
- }
-
- return $date;
- }
-
- /**
- * Returns true, if given $year is a leap year.
- *
- * @param integer $year
- * @return boolean true, if year is leap year
- */
- protected static function isYearLeapYear($year)
- {
- // all leapyears can be divided through 4
- if (($year % 4) != 0) {
- return false;
- }
-
- // all leapyears can be divided through 400
- if ($year % 400 == 0) {
- return true;
- } else if (($year > 1582) and ($year % 100 == 0)) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Internal mktime function used by Zend_Date for handling 64bit timestamps.
- *
- * Returns a formatted date for a given timestamp.
- *
- * @param string $format format for output
- * @param mixed $timestamp
- * @param boolean $gmt OPTIONAL true = other arguments are for UTC time, false = arguments are for local time/date
- * @return string
- */
- protected function date($format, $timestamp = null, $gmt = false)
- {
- $oldzone = @date_default_timezone_get();
- if ($this->_timezone != $oldzone) {
- date_default_timezone_set($this->_timezone);
- }
-
- if ($timestamp === null) {
- $result = ($gmt) ? @gmdate($format) : @date($format);
- date_default_timezone_set($oldzone);
- return $result;
- }
-
- if (abs($timestamp) <= 0x7FFFFFFF) {
- // See ZF-11992
- // "o" will sometimes resolve to the previous year (see
- // http://php.net/date ; it's part of the ISO 8601
- // standard). However, this is not desired, so replacing
- // all occurrences of "o" not preceded by a backslash
- // with "Y"
- $format = preg_replace('/(?_offset . '_'. $timestamp . '_'.(int)$gmt, '-','_');
- if ($result2 = self::$_cache->load($idstamp)) {
- $timestamp = unserialize($result2);
- $jump = true;
- }
- }
-
- // check on false or null alone fails
- if (empty($gmt) and empty($jump)) {
- $tempstamp = $timestamp;
- if ($tempstamp > 0) {
- while (abs($tempstamp) > 0x7FFFFFFF) {
- $tempstamp -= (86400 * 23376);
- }
-
- $dst = date("I", $tempstamp);
- if ($dst === 1) {
- $timestamp += 3600;
- }
-
- $temp = date('Z', $tempstamp);
- $timestamp += $temp;
- }
-
- if (isset(self::$_cache)) {
- if (self::$_cacheTags) {
- self::$_cache->save( serialize($timestamp), $idstamp, array('Zend_Date'));
- } else {
- self::$_cache->save( serialize($timestamp), $idstamp);
- }
- }
- }
-
- if (($timestamp < 0) and ($gmt !== true)) {
- $timestamp -= $this->_offset;
- }
-
- date_default_timezone_set($oldzone);
- $date = $this->getDateParts($timestamp, true);
- $length = strlen($format);
- $output = '';
-
- for ($i = 0; $i < $length; $i++) {
- switch($format[$i]) {
- // day formats
- case 'd': // day of month, 2 digits, with leading zero, 01 - 31
- $output .= (($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday']);
- break;
-
- case 'D': // day of week, 3 letters, Mon - Sun
- $output .= date('D', 86400 * (3 + self::dayOfWeek($date['year'], $date['mon'], $date['mday'])));
- break;
-
- case 'j': // day of month, without leading zero, 1 - 31
- $output .= $date['mday'];
- break;
-
- case 'l': // day of week, full string name, Sunday - Saturday
- $output .= date('l', 86400 * (3 + self::dayOfWeek($date['year'], $date['mon'], $date['mday'])));
- break;
-
- case 'N': // ISO 8601 numeric day of week, 1 - 7
- $day = self::dayOfWeek($date['year'], $date['mon'], $date['mday']);
- if ($day == 0) {
- $day = 7;
- }
- $output .= $day;
- break;
-
- case 'S': // english suffix for day of month, st nd rd th
- if (($date['mday'] % 10) == 1) {
- $output .= 'st';
- } else if ((($date['mday'] % 10) == 2) and ($date['mday'] != 12)) {
- $output .= 'nd';
- } else if (($date['mday'] % 10) == 3) {
- $output .= 'rd';
- } else {
- $output .= 'th';
- }
- break;
-
- case 'w': // numeric day of week, 0 - 6
- $output .= self::dayOfWeek($date['year'], $date['mon'], $date['mday']);
- break;
-
- case 'z': // day of year, 0 - 365
- $output .= $date['yday'];
- break;
-
-
- // week formats
- case 'W': // ISO 8601, week number of year
- $output .= $this->weekNumber($date['year'], $date['mon'], $date['mday']);
- break;
-
-
- // month formats
- case 'F': // string month name, january - december
- $output .= date('F', mktime(0, 0, 0, $date['mon'], 2, 1971));
- break;
-
- case 'm': // number of month, with leading zeros, 01 - 12
- $output .= (($date['mon'] < 10) ? '0' . $date['mon'] : $date['mon']);
- break;
-
- case 'M': // 3 letter month name, Jan - Dec
- $output .= date('M',mktime(0, 0, 0, $date['mon'], 2, 1971));
- break;
-
- case 'n': // number of month, without leading zeros, 1 - 12
- $output .= $date['mon'];
- break;
-
- case 't': // number of day in month
- $output .= self::$_monthTable[$date['mon'] - 1];
- break;
-
-
- // year formats
- case 'L': // is leap year ?
- $output .= (self::isYearLeapYear($date['year'])) ? '1' : '0';
- break;
-
- case 'o': // ISO 8601 year number
- $week = $this->weekNumber($date['year'], $date['mon'], $date['mday']);
- if (($week > 50) and ($date['mon'] == 1)) {
- $output .= ($date['year'] - 1);
- } else {
- $output .= $date['year'];
- }
- break;
-
- case 'Y': // year number, 4 digits
- $output .= $date['year'];
- break;
-
- case 'y': // year number, 2 digits
- $output .= substr($date['year'], strlen($date['year']) - 2, 2);
- break;
-
-
- // time formats
- case 'a': // lower case am/pm
- $output .= (($date['hours'] >= 12) ? 'pm' : 'am');
- break;
-
- case 'A': // upper case am/pm
- $output .= (($date['hours'] >= 12) ? 'PM' : 'AM');
- break;
-
- case 'B': // swatch internet time
- $dayseconds = ($date['hours'] * 3600) + ($date['minutes'] * 60) + $date['seconds'];
- if ($gmt === true) {
- $dayseconds += 3600;
- }
- $output .= (int) (($dayseconds % 86400) / 86.4);
- break;
-
- case 'g': // hours without leading zeros, 12h format
- if ($date['hours'] > 12) {
- $hour = $date['hours'] - 12;
- } else {
- if ($date['hours'] == 0) {
- $hour = '12';
- } else {
- $hour = $date['hours'];
- }
- }
- $output .= $hour;
- break;
-
- case 'G': // hours without leading zeros, 24h format
- $output .= $date['hours'];
- break;
-
- case 'h': // hours with leading zeros, 12h format
- if ($date['hours'] > 12) {
- $hour = $date['hours'] - 12;
- } else {
- if ($date['hours'] == 0) {
- $hour = '12';
- } else {
- $hour = $date['hours'];
- }
- }
- $output .= (($hour < 10) ? '0'.$hour : $hour);
- break;
-
- case 'H': // hours with leading zeros, 24h format
- $output .= (($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours']);
- break;
-
- case 'i': // minutes with leading zeros
- $output .= (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']);
- break;
-
- case 's': // seconds with leading zeros
- $output .= (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']);
- break;
-
-
- // timezone formats
- case 'e': // timezone identifier
- if ($gmt === true) {
- $output .= gmdate('e', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- } else {
- $output .= date('e', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- }
- break;
-
- case 'I': // daylight saving time or not
- if ($gmt === true) {
- $output .= gmdate('I', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- } else {
- $output .= date('I', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- }
- break;
-
- case 'O': // difference to GMT in hours
- $gmtstr = ($gmt === true) ? 0 : $this->getGmtOffset();
- $output .= sprintf('%s%04d', ($gmtstr <= 0) ? '+' : '-', abs($gmtstr) / 36);
- break;
-
- case 'P': // difference to GMT with colon
- $gmtstr = ($gmt === true) ? 0 : $this->getGmtOffset();
- $gmtstr = sprintf('%s%04d', ($gmtstr <= 0) ? '+' : '-', abs($gmtstr) / 36);
- $output = $output . substr($gmtstr, 0, 3) . ':' . substr($gmtstr, 3);
- break;
-
- case 'T': // timezone settings
- if ($gmt === true) {
- $output .= gmdate('T', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- } else {
- $output .= date('T', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- }
- break;
-
- case 'Z': // timezone offset in seconds
- $output .= ($gmt === true) ? 0 : -$this->getGmtOffset();
- break;
-
-
- // complete time formats
- case 'c': // ISO 8601 date format
- $difference = $this->getGmtOffset();
- $difference = sprintf('%s%04d', ($difference <= 0) ? '+' : '-', abs($difference) / 36);
- $difference = substr($difference, 0, 3) . ':' . substr($difference, 3);
- $output .= $date['year'] . '-'
- . (($date['mon'] < 10) ? '0' . $date['mon'] : $date['mon']) . '-'
- . (($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday']) . 'T'
- . (($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours']) . ':'
- . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':'
- . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds'])
- . $difference;
- break;
-
- case 'r': // RFC 2822 date format
- $difference = $this->getGmtOffset();
- $difference = sprintf('%s%04d', ($difference <= 0) ? '+' : '-', abs($difference) / 36);
- $output .= gmdate('D', 86400 * (3 + self::dayOfWeek($date['year'], $date['mon'], $date['mday']))) . ', '
- . (($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday']) . ' '
- . date('M', mktime(0, 0, 0, $date['mon'], 2, 1971)) . ' '
- . $date['year'] . ' '
- . (($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours']) . ':'
- . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':'
- . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']) . ' '
- . $difference;
- break;
-
- case 'U': // Unix timestamp
- $output .= $origstamp;
- break;
-
-
- // special formats
- case "\\": // next letter to print with no format
- $i++;
- if ($i < $length) {
- $output .= $format[$i];
- }
- break;
-
- default: // letter is no format so add it direct
- $output .= $format[$i];
- break;
- }
- }
-
- return (string) $output;
- }
-
- /**
- * Returns the day of week for a Gregorian calendar date.
- * 0 = sunday, 6 = saturday
- *
- * @param integer $year
- * @param integer $month
- * @param integer $day
- * @return integer dayOfWeek
- */
- protected static function dayOfWeek($year, $month, $day)
- {
- if ((1901 < $year) and ($year < 2038)) {
- return (int) date('w', mktime(0, 0, 0, $month, $day, $year));
- }
-
- // gregorian correction
- $correction = 0;
- if (($year < 1582) or (($year == 1582) and (($month < 10) or (($month == 10) && ($day < 15))))) {
- $correction = 3;
- }
-
- if ($month > 2) {
- $month -= 2;
- } else {
- $month += 10;
- $year--;
- }
-
- $day = floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4);
- $day += floor(($year / 100) / 4) - 2 * floor($year / 100) + 77 + $correction;
-
- return (int) ($day - 7 * floor($day / 7));
- }
-
- /**
- * Internal getDateParts function for handling 64bit timestamps, similar to:
- * http://www.php.net/getdate
- *
- * Returns an array of date parts for $timestamp, relative to 1970/01/01 00:00:00 GMT/UTC.
- *
- * $fast specifies ALL date parts should be returned (slower)
- * Default is false, and excludes $dayofweek, weekday, month and timestamp from parts returned.
- *
- * @param mixed $timestamp
- * @param boolean $fast OPTIONAL defaults to fast (false), resulting in fewer date parts
- * @return array
- */
- protected function getDateParts($timestamp = null, $fast = null)
- {
-
- // actual timestamp
- if (!is_numeric($timestamp)) {
- return getdate();
- }
-
- // 32bit timestamp
- if (abs($timestamp) <= 0x7FFFFFFF) {
- return @getdate((int) $timestamp);
- }
-
- if (isset(self::$_cache)) {
- $id = strtr('Zend_DateObject_getDateParts_' . $timestamp.'_'.(int)$fast, '-','_');
- if ($result = self::$_cache->load($id)) {
- return unserialize($result);
- }
- }
-
- $otimestamp = $timestamp;
- $numday = 0;
- $month = 0;
- // gregorian correction
- if ($timestamp < -12219321600) {
- $timestamp -= 864000;
- }
-
- // timestamp lower 0
- if ($timestamp < 0) {
- $sec = 0;
- $act = 1970;
-
- // iterate through 10 years table, increasing speed
- foreach(self::$_yearTable as $year => $seconds) {
- if ($timestamp >= $seconds) {
- $i = $act;
- break;
- }
- $sec = $seconds;
- $act = $year;
- }
-
- $timestamp -= $sec;
- if (!isset($i)) {
- $i = $act;
- }
-
- // iterate the max last 10 years
- do {
- --$i;
- $day = $timestamp;
-
- $timestamp += 31536000;
- $leapyear = self::isYearLeapYear($i);
- if ($leapyear === true) {
- $timestamp += 86400;
- }
-
- if ($timestamp >= 0) {
- $year = $i;
- break;
- }
- } while ($timestamp < 0);
-
- $secondsPerYear = 86400 * ($leapyear ? 366 : 365) + $day;
-
- $timestamp = $day;
- // iterate through months
- for ($i = 12; --$i >= 0;) {
- $day = $timestamp;
-
- $timestamp += self::$_monthTable[$i] * 86400;
- if (($leapyear === true) and ($i == 1)) {
- $timestamp += 86400;
- }
-
- if ($timestamp >= 0) {
- $month = $i;
- $numday = self::$_monthTable[$i];
- if (($leapyear === true) and ($i == 1)) {
- ++$numday;
- }
- break;
- }
- }
-
- $timestamp = $day;
- $numberdays = $numday + ceil(($timestamp + 1) / 86400);
-
- $timestamp += ($numday - $numberdays + 1) * 86400;
- $hours = floor($timestamp / 3600);
- } else {
-
- // iterate through years
- for ($i = 1970;;$i++) {
- $day = $timestamp;
-
- $timestamp -= 31536000;
- $leapyear = self::isYearLeapYear($i);
- if ($leapyear === true) {
- $timestamp -= 86400;
- }
-
- if ($timestamp < 0) {
- $year = $i;
- break;
- }
- }
-
- $secondsPerYear = $day;
-
- $timestamp = $day;
- // iterate through months
- for ($i = 0; $i <= 11; $i++) {
- $day = $timestamp;
- $timestamp -= self::$_monthTable[$i] * 86400;
-
- if (($leapyear === true) and ($i == 1)) {
- $timestamp -= 86400;
- }
-
- if ($timestamp < 0) {
- $month = $i;
- $numday = self::$_monthTable[$i];
- if (($leapyear === true) and ($i == 1)) {
- ++$numday;
- }
- break;
- }
- }
-
- $timestamp = $day;
- $numberdays = ceil(($timestamp + 1) / 86400);
- $timestamp = $timestamp - ($numberdays - 1) * 86400;
- $hours = floor($timestamp / 3600);
- }
-
- $timestamp -= $hours * 3600;
-
- $month += 1;
- $minutes = floor($timestamp / 60);
- $seconds = $timestamp - $minutes * 60;
-
- if ($fast === true) {
- $array = array(
- 'seconds' => $seconds,
- 'minutes' => $minutes,
- 'hours' => $hours,
- 'mday' => $numberdays,
- 'mon' => $month,
- 'year' => $year,
- 'yday' => floor($secondsPerYear / 86400),
- );
- } else {
-
- $dayofweek = self::dayOfWeek($year, $month, $numberdays);
- $array = array(
- 'seconds' => $seconds,
- 'minutes' => $minutes,
- 'hours' => $hours,
- 'mday' => $numberdays,
- 'wday' => $dayofweek,
- 'mon' => $month,
- 'year' => $year,
- 'yday' => floor($secondsPerYear / 86400),
- 'weekday' => gmdate('l', 86400 * (3 + $dayofweek)),
- 'month' => gmdate('F', mktime(0, 0, 0, $month, 1, 1971)),
- 0 => $otimestamp
- );
- }
-
- if (isset(self::$_cache)) {
- if (self::$_cacheTags) {
- self::$_cache->save( serialize($array), $id, array('Zend_Date'));
- } else {
- self::$_cache->save( serialize($array), $id);
- }
- }
-
- return $array;
- }
-
- /**
- * Internal getWeekNumber function for handling 64bit timestamps
- *
- * Returns the ISO 8601 week number of a given date
- *
- * @param integer $year
- * @param integer $month
- * @param integer $day
- * @return integer
- */
- protected function weekNumber($year, $month, $day)
- {
- if ((1901 < $year) and ($year < 2038)) {
- return (int) date('W', mktime(0, 0, 0, $month, $day, $year));
- }
-
- $dayofweek = self::dayOfWeek($year, $month, $day);
- $firstday = self::dayOfWeek($year, 1, 1);
- if (($month == 1) and (($firstday < 1) or ($firstday > 4)) and ($day < 4)) {
- $firstday = self::dayOfWeek($year - 1, 1, 1);
- $month = 12;
- $day = 31;
-
- } else if (($month == 12) and ((self::dayOfWeek($year + 1, 1, 1) < 5) and
- (self::dayOfWeek($year + 1, 1, 1) > 0))) {
- return 1;
- }
-
- return intval (((self::dayOfWeek($year, 1, 1) < 5) and (self::dayOfWeek($year, 1, 1) > 0)) +
- 4 * ($month - 1) + (2 * ($month - 1) + ($day - 1) + $firstday - $dayofweek + 6) * 36 / 256);
- }
-
- /**
- * Internal _range function
- * Sets the value $a to be in the range of [0, $b]
- *
- * @param float $a - value to correct
- * @param float $b - maximum range to set
- */
- private function _range($a, $b) {
- while ($a < 0) {
- $a += $b;
- }
- while ($a >= $b) {
- $a -= $b;
- }
- return $a;
- }
-
- /**
- * Calculates the sunrise or sunset based on a location
- *
- * @param array $location Location for calculation MUST include 'latitude', 'longitude', 'horizon'
- * @param bool $horizon true: sunrise; false: sunset
- * @return mixed - false: midnight sun, integer:
- */
- protected function calcSun($location, $horizon, $rise = false)
- {
- // timestamp within 32bit
- if (abs($this->_unixTimestamp) <= 0x7FFFFFFF) {
- if ($rise === false) {
- return date_sunset($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location['latitude'],
- $location['longitude'], 90 + $horizon, $this->getGmtOffset() / 3600);
- }
- return date_sunrise($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location['latitude'],
- $location['longitude'], 90 + $horizon, $this->getGmtOffset() / 3600);
- }
-
- // self calculation - timestamp bigger than 32bit
- // fix circle values
- $quarterCircle = 0.5 * M_PI;
- $halfCircle = M_PI;
- $threeQuarterCircle = 1.5 * M_PI;
- $fullCircle = 2 * M_PI;
-
- // radiant conversion for coordinates
- $radLatitude = $location['latitude'] * $halfCircle / 180;
- $radLongitude = $location['longitude'] * $halfCircle / 180;
-
- // get solar coordinates
- $tmpRise = $rise ? $quarterCircle : $threeQuarterCircle;
- $radDay = $this->date('z',$this->_unixTimestamp) + ($tmpRise - $radLongitude) / $fullCircle;
-
- // solar anomoly and longitude
- $solAnomoly = $radDay * 0.017202 - 0.0574039;
- $solLongitude = $solAnomoly + 0.0334405 * sin($solAnomoly);
- $solLongitude += 4.93289 + 3.49066E-4 * sin(2 * $solAnomoly);
-
- // get quadrant
- $solLongitude = $this->_range($solLongitude, $fullCircle);
-
- if (($solLongitude / $quarterCircle) - intval($solLongitude / $quarterCircle) == 0) {
- $solLongitude += 4.84814E-6;
- }
-
- // solar ascension
- $solAscension = sin($solLongitude) / cos($solLongitude);
- $solAscension = atan2(0.91746 * $solAscension, 1);
-
- // adjust quadrant
- if ($solLongitude > $threeQuarterCircle) {
- $solAscension += $fullCircle;
- } else if ($solLongitude > $quarterCircle) {
- $solAscension += $halfCircle;
- }
-
- // solar declination
- $solDeclination = 0.39782 * sin($solLongitude);
- $solDeclination /= sqrt(-$solDeclination * $solDeclination + 1);
- $solDeclination = atan2($solDeclination, 1);
-
- $solHorizon = $horizon - sin($solDeclination) * sin($radLatitude);
- $solHorizon /= cos($solDeclination) * cos($radLatitude);
-
- // midnight sun, always night
- if (abs($solHorizon) > 1) {
- return false;
- }
-
- $solHorizon /= sqrt(-$solHorizon * $solHorizon + 1);
- $solHorizon = $quarterCircle - atan2($solHorizon, 1);
-
- if ($rise) {
- $solHorizon = $fullCircle - $solHorizon;
- }
-
- // time calculation
- $localTime = $solHorizon + $solAscension - 0.0172028 * $radDay - 1.73364;
- $universalTime = $localTime - $radLongitude;
-
- // determinate quadrant
- $universalTime = $this->_range($universalTime, $fullCircle);
-
- // radiant to hours
- $universalTime *= 24 / $fullCircle;
-
- // convert to time
- $hour = intval($universalTime);
- $universalTime = ($universalTime - $hour) * 60;
- $min = intval($universalTime);
- $universalTime = ($universalTime - $min) * 60;
- $sec = intval($universalTime);
-
- return $this->mktime($hour, $min, $sec, $this->date('m', $this->_unixTimestamp),
- $this->date('j', $this->_unixTimestamp), $this->date('Y', $this->_unixTimestamp),
- -1, true);
- }
-
- /**
- * Sets a new timezone for calculation of $this object's gmt offset.
- * For a list of supported timezones look here: http://php.net/timezones
- * If no timezone can be detected or the given timezone is wrong UTC will be set.
- *
- * @param string $zone OPTIONAL timezone for date calculation; defaults to date_default_timezone_get()
- * @return Zend_Date_DateObject Provides fluent interface
- * @throws Zend_Date_Exception
- */
- public function setTimezone($zone = null)
- {
- $oldzone = @date_default_timezone_get();
- if ($zone === null) {
- $zone = $oldzone;
- }
-
- // throw an error on false input, but only if the new date extension is available
- if (function_exists('timezone_open')) {
- if (!@timezone_open($zone)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("timezone ($zone) is not a known timezone", 0, null, $zone);
- }
- }
- // this can generate an error if the date extension is not available and a false timezone is given
- $result = @date_default_timezone_set($zone);
- if ($result === true) {
- $this->_offset = mktime(0, 0, 0, 1, 2, 1970) - gmmktime(0, 0, 0, 1, 2, 1970);
- $this->_timezone = $zone;
- }
- date_default_timezone_set($oldzone);
-
- if (($zone == 'UTC') or ($zone == 'GMT')) {
- $this->_dst = false;
- } else {
- $this->_dst = true;
- }
-
- return $this;
- }
-
- /**
- * Return the timezone of $this object.
- * The timezone is initially set when the object is instantiated.
- *
- * @return string actual set timezone string
- */
- public function getTimezone()
- {
- return $this->_timezone;
- }
-
- /**
- * Return the offset to GMT of $this object's timezone.
- * The offset to GMT is initially set when the object is instantiated using the currently,
- * in effect, default timezone for PHP functions.
- *
- * @return integer seconds difference between GMT timezone and timezone when object was instantiated
- */
- public function getGmtOffset()
- {
- $date = $this->getDateParts($this->getUnixTimestamp(), true);
- $zone = @date_default_timezone_get();
- $result = @date_default_timezone_set($this->_timezone);
- if ($result === true) {
- $offset = $this->mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], $date['year'], false)
- - $this->mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], $date['year'], true);
- }
- date_default_timezone_set($zone);
-
- return $offset;
- }
-
- /**
- * Internal method to check if the given cache supports tags
- *
- * @param Zend_Cache $cache
- */
- protected static function _getTagSupportForCache()
- {
- $backend = self::$_cache->getBackend();
- if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) {
- $cacheOptions = $backend->getCapabilities();
- self::$_cacheTags = $cacheOptions['tags'];
- } else {
- self::$_cacheTags = false;
- }
-
- return self::$_cacheTags;
- }
-}
diff --git a/lib/zend/Zend/Date/Exception.php b/lib/zend/Zend/Date/Exception.php
deleted file mode 100644
index f4573b38ce509..0000000000000
--- a/lib/zend/Zend/Date/Exception.php
+++ /dev/null
@@ -1,49 +0,0 @@
-operand = $op;
- parent::__construct($message, $code, $e);
- }
-
- public function getOperand()
- {
- return $this->operand;
- }
-}
diff --git a/lib/zend/Zend/Exception.php b/lib/zend/Zend/Exception.php
deleted file mode 100644
index d97acb0f92cd5..0000000000000
--- a/lib/zend/Zend/Exception.php
+++ /dev/null
@@ -1,96 +0,0 @@
-_previous = $previous;
- } else {
- parent::__construct($msg, (int) $code, $previous);
- }
- }
-
- /**
- * Overloading
- *
- * For PHP < 5.3.0, provides access to the getPrevious() method.
- *
- * @param string $method
- * @param array $args
- * @return mixed
- */
- public function __call($method, array $args)
- {
- if ('getprevious' == strtolower($method)) {
- return $this->_getPrevious();
- }
- return null;
- }
-
- /**
- * String representation of the exception
- *
- * @return string
- */
- public function __toString()
- {
- if (version_compare(PHP_VERSION, '5.3.0', '<')) {
- if (null !== ($e = $this->getPrevious())) {
- return $e->__toString()
- . "\n\nNext "
- . parent::__toString();
- }
- }
- return parent::__toString();
- }
-
- /**
- * Returns previous Exception
- *
- * @return Exception|null
- */
- protected function _getPrevious()
- {
- return $this->_previous;
- }
-}
diff --git a/lib/zend/Zend/Filter.php b/lib/zend/Zend/Filter.php
deleted file mode 100644
index 1256ff9bd6bf8..0000000000000
--- a/lib/zend/Zend/Filter.php
+++ /dev/null
@@ -1,239 +0,0 @@
-_filters, $filter);
- } else {
- $this->_filters[] = $filter;
- }
- return $this;
- }
-
- /**
- * Add a filter to the end of the chain
- *
- * @param Zend_Filter_Interface $filter
- * @return Zend_Filter Provides a fluent interface
- */
- public function appendFilter(Zend_Filter_Interface $filter)
- {
- return $this->addFilter($filter, self::CHAIN_APPEND);
- }
-
- /**
- * Add a filter to the start of the chain
- *
- * @param Zend_Filter_Interface $filter
- * @return Zend_Filter Provides a fluent interface
- */
- public function prependFilter(Zend_Filter_Interface $filter)
- {
- return $this->addFilter($filter, self::CHAIN_PREPEND);
- }
-
- /**
- * Get all the filters
- *
- * @return array
- */
- public function getFilters()
- {
- return $this->_filters;
- }
-
- /**
- * Returns $value filtered through each filter in the chain
- *
- * Filters are run in the order in which they were added to the chain (FIFO)
- *
- * @param mixed $value
- * @return mixed
- */
- public function filter($value)
- {
- $valueFiltered = $value;
- foreach ($this->_filters as $filter) {
- $valueFiltered = $filter->filter($valueFiltered);
- }
- return $valueFiltered;
- }
-
- /**
- * Returns the set default namespaces
- *
- * @return array
- */
- public static function getDefaultNamespaces()
- {
- return self::$_defaultNamespaces;
- }
-
- /**
- * Sets new default namespaces
- *
- * @param array|string $namespace
- * @return null
- */
- public static function setDefaultNamespaces($namespace)
- {
- if (!is_array($namespace)) {
- $namespace = array((string) $namespace);
- }
-
- self::$_defaultNamespaces = $namespace;
- }
-
- /**
- * Adds a new default namespace
- *
- * @param array|string $namespace
- * @return null
- */
- public static function addDefaultNamespaces($namespace)
- {
- if (!is_array($namespace)) {
- $namespace = array((string) $namespace);
- }
-
- self::$_defaultNamespaces = array_unique(array_merge(self::$_defaultNamespaces, $namespace));
- }
-
- /**
- * Returns true when defaultNamespaces are set
- *
- * @return boolean
- */
- public static function hasDefaultNamespaces()
- {
- return (!empty(self::$_defaultNamespaces));
- }
-
- /**
- * @deprecated
- * @see Zend_Filter::filterStatic()
- *
- * @param mixed $value
- * @param string $classBaseName
- * @param array $args OPTIONAL
- * @param array|string $namespaces OPTIONAL
- * @return mixed
- * @throws Zend_Filter_Exception
- */
- public static function get($value, $classBaseName, array $args = array(), $namespaces = array())
- {
- trigger_error(
- 'Zend_Filter::get() is deprecated as of 1.9.0; please update your code to utilize Zend_Filter::filterStatic()',
- E_USER_NOTICE
- );
-
- return self::filterStatic($value, $classBaseName, $args, $namespaces);
- }
-
- /**
- * Returns a value filtered through a specified filter class, without requiring separate
- * instantiation of the filter object.
- *
- * The first argument of this method is a data input value, that you would have filtered.
- * The second argument is a string, which corresponds to the basename of the filter class,
- * relative to the Zend_Filter namespace. This method automatically loads the class,
- * creates an instance, and applies the filter() method to the data input. You can also pass
- * an array of constructor arguments, if they are needed for the filter class.
- *
- * @param mixed $value
- * @param string $classBaseName
- * @param array $args OPTIONAL
- * @param array|string $namespaces OPTIONAL
- * @return mixed
- * @throws Zend_Filter_Exception
- */
- public static function filterStatic($value, $classBaseName, array $args = array(), $namespaces = array())
- {
- require_once 'Zend/Loader.php';
- $namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('Zend_Filter'));
- foreach ($namespaces as $namespace) {
- $className = $namespace . '_' . ucfirst($classBaseName);
- if (!class_exists($className, false)) {
- try {
- $file = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
- if (Zend_Loader::isReadable($file)) {
- Zend_Loader::loadClass($className);
- } else {
- continue;
- }
- } catch (Zend_Exception $ze) {
- continue;
- }
- }
-
- $class = new ReflectionClass($className);
- if ($class->implementsInterface('Zend_Filter_Interface')) {
- if ($class->hasMethod('__construct')) {
- $object = $class->newInstanceArgs($args);
- } else {
- $object = $class->newInstance();
- }
- return $object->filter($value);
- }
- }
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Filter class not found from basename '$classBaseName'");
- }
-}
diff --git a/lib/zend/Zend/Filter/Alnum.php b/lib/zend/Zend/Filter/Alnum.php
deleted file mode 100644
index 7455dafe45c77..0000000000000
--- a/lib/zend/Zend/Filter/Alnum.php
+++ /dev/null
@@ -1,146 +0,0 @@
-toArray();
- } else if (is_array($allowWhiteSpace)) {
- if (array_key_exists('allowwhitespace', $allowWhiteSpace)) {
- $allowWhiteSpace = $allowWhiteSpace['allowwhitespace'];
- } else {
- $allowWhiteSpace = false;
- }
- }
-
- $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
- if (null === self::$_unicodeEnabled) {
- self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
- }
-
- if (null === self::$_meansEnglishAlphabet) {
- $this->_locale = new Zend_Locale('auto');
- self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(),
- array('ja', 'ko', 'zh')
- );
- }
-
- }
-
- /**
- * Returns the allowWhiteSpace option
- *
- * @return boolean
- */
- public function getAllowWhiteSpace()
- {
- return $this->allowWhiteSpace;
- }
-
- /**
- * Sets the allowWhiteSpace option
- *
- * @param boolean $allowWhiteSpace
- * @return Zend_Filter_Alnum Provides a fluent interface
- */
- public function setAllowWhiteSpace($allowWhiteSpace)
- {
- $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns the string $value, removing all but alphabetic and digit characters
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- $whiteSpace = $this->allowWhiteSpace ? '\s' : '';
- if (!self::$_unicodeEnabled) {
- // POSIX named classes are not supported, use alternative a-zA-Z0-9 match
- $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/';
- } else if (self::$_meansEnglishAlphabet) {
- //The Alphabet means english alphabet.
- $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/u';
- } else {
- //The Alphabet means each language's alphabet.
- $pattern = '/[^\p{L}\p{N}' . $whiteSpace . ']/u';
- }
-
- return preg_replace($pattern, '', (string) $value);
- }
-}
diff --git a/lib/zend/Zend/Filter/Alpha.php b/lib/zend/Zend/Filter/Alpha.php
deleted file mode 100644
index 7374da1665e13..0000000000000
--- a/lib/zend/Zend/Filter/Alpha.php
+++ /dev/null
@@ -1,146 +0,0 @@
-toArray();
- } else if (is_array($allowWhiteSpace)) {
- if (array_key_exists('allowwhitespace', $allowWhiteSpace)) {
- $allowWhiteSpace = $allowWhiteSpace['allowwhitespace'];
- } else {
- $allowWhiteSpace = false;
- }
- }
-
- $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
- if (null === self::$_unicodeEnabled) {
- self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
- }
-
- if (null === self::$_meansEnglishAlphabet) {
- $this->_locale = new Zend_Locale('auto');
- self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(),
- array('ja', 'ko', 'zh')
- );
- }
-
- }
-
- /**
- * Returns the allowWhiteSpace option
- *
- * @return boolean
- */
- public function getAllowWhiteSpace()
- {
- return $this->allowWhiteSpace;
- }
-
- /**
- * Sets the allowWhiteSpace option
- *
- * @param boolean $allowWhiteSpace
- * @return Zend_Filter_Alpha Provides a fluent interface
- */
- public function setAllowWhiteSpace($allowWhiteSpace)
- {
- $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns the string $value, removing all but alphabetic characters
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- $whiteSpace = $this->allowWhiteSpace ? '\s' : '';
- if (!self::$_unicodeEnabled) {
- // POSIX named classes are not supported, use alternative a-zA-Z match
- $pattern = '/[^a-zA-Z' . $whiteSpace . ']/';
- } else if (self::$_meansEnglishAlphabet) {
- //The Alphabet means english alphabet.
- $pattern = '/[^a-zA-Z' . $whiteSpace . ']/u';
- } else {
- //The Alphabet means each language's alphabet.
- $pattern = '/[^\p{L}' . $whiteSpace . ']/u';
- }
-
- return preg_replace($pattern, '', (string) $value);
- }
-}
diff --git a/lib/zend/Zend/Filter/BaseName.php b/lib/zend/Zend/Filter/BaseName.php
deleted file mode 100644
index 8d6a6da5607dd..0000000000000
--- a/lib/zend/Zend/Filter/BaseName.php
+++ /dev/null
@@ -1,50 +0,0 @@
- 'boolean',
- self::INTEGER => 'integer',
- self::FLOAT => 'float',
- self::STRING => 'string',
- self::ZERO => 'zero',
- self::EMPTY_ARRAY => 'array',
- self::NULL => 'null',
- self::PHP => 'php',
- self::FALSE_STRING => 'false',
- self::YES => 'yes',
- self::ALL => 'all',
- );
-
- /**
- * Internal type to detect
- *
- * @var integer
- */
- protected $_type = self::PHP;
-
- /**
- * Internal locale
- *
- * @var array
- */
- protected $_locale = array('auto');
-
- /**
- * Internal mode
- *
- * @var boolean
- */
- protected $_casting = true;
-
- /**
- * Constructor
- *
- * @param string|array|Zend_Config $options OPTIONAL
- */
- public function __construct($options = null)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (!is_array($options)) {
- $options = func_get_args();
- $temp = array();
- if (!empty($options)) {
- $temp['type'] = array_shift($options);
- }
-
- if (!empty($options)) {
- $temp['casting'] = array_shift($options);
- }
-
- if (!empty($options)) {
- $temp['locale'] = array_shift($options);
- }
-
- $options = $temp;
- }
-
- if (array_key_exists('type', $options)) {
- $this->setType($options['type']);
- }
-
- if (array_key_exists('casting', $options)) {
- $this->setCasting($options['casting']);
- }
-
- if (array_key_exists('locale', $options)) {
- $this->setLocale($options['locale']);
- }
- }
-
- /**
- * Returns the set null types
- *
- * @return int
- */
- public function getType()
- {
- return $this->_type;
- }
-
- /**
- * Set the null types
- *
- * @param integer|array $type
- * @throws Zend_Filter_Exception
- * @return Zend_Filter_Boolean
- */
- public function setType($type = null)
- {
- if (is_array($type)) {
- $detected = 0;
- foreach($type as $value) {
- if (is_int($value)) {
- $detected += $value;
- } elseif (in_array($value, $this->_constants)) {
- $detected += array_search($value, $this->_constants);
- }
- }
-
- $type = $detected;
- } elseif (is_string($type) && in_array($type, $this->_constants)) {
- $type = array_search($type, $this->_constants);
- }
-
- if (!is_int($type) || ($type < 0) || ($type > self::ALL)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Unknown type');
- }
-
- $this->_type = $type;
- return $this;
- }
-
- /**
- * Returns the set locale
- *
- * @return array
- */
- public function getLocale()
- {
- return $this->_locale;
- }
-
- /**
- * Set the locales which are accepted
- *
- * @param string|array|Zend_Locale $locale
- * @throws Zend_Filter_Exception
- * @return Zend_Filter_Boolean
- */
- public function setLocale($locale = null)
- {
- if (is_string($locale)) {
- $locale = array($locale);
- } elseif ($locale instanceof Zend_Locale) {
- $locale = array($locale->toString());
- } elseif (!is_array($locale)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Locale has to be string, array or an instance of Zend_Locale');
- }
-
- require_once 'Zend/Locale.php';
- foreach ($locale as $single) {
- if (!Zend_Locale::isLocale($single)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Unknown locale '$single'");
- }
- }
-
- $this->_locale = $locale;
- return $this;
- }
-
- /**
- * Returns the casting option
- *
- * @return boolean
- */
- public function getCasting()
- {
- return $this->_casting;
- }
-
- /**
- * Set the working mode
- *
- * @param boolean $locale When true this filter works like cast
- * When false it recognises only true and false
- * and all other values are returned as is
- * @throws Zend_Filter_Exception
- * @return Zend_Filter_Boolean
- */
- public function setCasting($casting = true)
- {
- $this->_casting = (boolean) $casting;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns a boolean representation of $value
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- $type = $this->getType();
- $casting = $this->getCasting();
-
- // STRING YES (Localized)
- if ($type >= self::YES) {
- $type -= self::YES;
- if (is_string($value)) {
- require_once 'Zend/Locale.php';
- $locales = $this->getLocale();
- foreach ($locales as $locale) {
- if ($this->_getLocalizedQuestion($value, false, $locale) === false) {
- return false;
- }
-
- if (!$casting && ($this->_getLocalizedQuestion($value, true, $locale) === true)) {
- return true;
- }
- }
- }
- }
-
- // STRING FALSE ('false')
- if ($type >= self::FALSE_STRING) {
- $type -= self::FALSE_STRING;
- if (is_string($value) && (strtolower($value) == 'false')) {
- return false;
- }
-
- if ((!$casting) && is_string($value) && (strtolower($value) == 'true')) {
- return true;
- }
- }
-
- // NULL (null)
- if ($type >= self::NULL) {
- $type -= self::NULL;
- if ($value === null) {
- return false;
- }
- }
-
- // EMPTY_ARRAY (array())
- if ($type >= self::EMPTY_ARRAY) {
- $type -= self::EMPTY_ARRAY;
- if (is_array($value) && ($value == array())) {
- return false;
- }
- }
-
- // ZERO ('0')
- if ($type >= self::ZERO) {
- $type -= self::ZERO;
- if (is_string($value) && ($value == '0')) {
- return false;
- }
-
- if ((!$casting) && (is_string($value)) && ($value == '1')) {
- return true;
- }
- }
-
- // STRING ('')
- if ($type >= self::STRING) {
- $type -= self::STRING;
- if (is_string($value) && ($value == '')) {
- return false;
- }
- }
-
- // FLOAT (0.0)
- if ($type >= self::FLOAT) {
- $type -= self::FLOAT;
- if (is_float($value) && ($value == 0.0)) {
- return false;
- }
-
- if ((!$casting) && is_float($value) && ($value == 1.0)) {
- return true;
- }
- }
-
- // INTEGER (0)
- if ($type >= self::INTEGER) {
- $type -= self::INTEGER;
- if (is_int($value) && ($value == 0)) {
- return false;
- }
-
- if ((!$casting) && is_int($value) && ($value == 1)) {
- return true;
- }
- }
-
- // BOOLEAN (false)
- if ($type >= self::BOOLEAN) {
- $type -= self::BOOLEAN;
- if (is_bool($value)) {
- return $value;
- }
- }
-
- if ($casting) {
- return true;
- }
-
- return $value;
- }
-
- /**
- * Determine the value of a localized string, and compare it to a given value
- *
- * @param string $value
- * @param boolean $yes
- * @param array $locale
- * @return boolean
- */
- protected function _getLocalizedQuestion($value, $yes, $locale)
- {
- if ($yes == true) {
- $question = 'yes';
- $return = true;
- } else {
- $question = 'no';
- $return = false;
- }
- $str = Zend_Locale::getTranslation($question, 'question', $locale);
- $str = explode(':', $str);
- if (!empty($str)) {
- foreach($str as $no) {
- if (($no == $value) || (strtolower($no) == strtolower($value))) {
- return $return;
- }
- }
- }
- }
-}
diff --git a/lib/zend/Zend/Filter/Callback.php b/lib/zend/Zend/Filter/Callback.php
deleted file mode 100644
index f7961ea511088..0000000000000
--- a/lib/zend/Zend/Filter/Callback.php
+++ /dev/null
@@ -1,152 +0,0 @@
-toArray();
- } else if (!is_array($options) || !array_key_exists('callback', $options)) {
- $options = func_get_args();
- $temp['callback'] = array_shift($options);
- if (!empty($options)) {
- $temp['options'] = array_shift($options);
- }
-
- $options = $temp;
- }
-
- if (!array_key_exists('callback', $options)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Missing callback to use');
- }
-
- $this->setCallback($options['callback']);
- if (array_key_exists('options', $options)) {
- $this->setOptions($options['options']);
- }
- }
-
- /**
- * Returns the set callback
- *
- * @return string|array Set callback
- */
- public function getCallback()
- {
- return $this->_callback;
- }
-
- /**
- * Sets a new callback for this filter
- *
- * @param unknown_type $callback
- * @return unknown
- */
- public function setCallback($callback, $options = null)
- {
- if (!is_callable($callback)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Callback can not be accessed');
- }
-
- $this->_callback = $callback;
- $this->setOptions($options);
- return $this;
- }
-
- /**
- * Returns the set default options
- *
- * @return mixed
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Sets new default options to the callback filter
- *
- * @param mixed $options Default options to set
- * @return Zend_Filter_Callback
- */
- public function setOptions($options)
- {
- $this->_options = $options;
- return $this;
- }
-
- /**
- * Calls the filter per callback
- *
- * @param mixed $value Options for the set callback
- * @return mixed Result from the filter which was callbacked
- */
- public function filter($value)
- {
- $options = array();
-
- if ($this->_options !== null) {
- if (!is_array($this->_options)) {
- $options = array($this->_options);
- } else {
- $options = $this->_options;
- }
- }
-
- array_unshift($options, $value);
-
- return call_user_func_array($this->_callback, $options);
- }
-}
diff --git a/lib/zend/Zend/Filter/Compress.php b/lib/zend/Zend/Filter/Compress.php
deleted file mode 100644
index e9361f7a43771..0000000000000
--- a/lib/zend/Zend/Filter/Compress.php
+++ /dev/null
@@ -1,197 +0,0 @@
-toArray();
- }
- if (is_string($options)) {
- $this->setAdapter($options);
- } elseif ($options instanceof Zend_Filter_Compress_CompressInterface) {
- $this->setAdapter($options);
- } elseif (is_array($options)) {
- $this->setOptions($options);
- }
- }
-
- /**
- * Set filter setate
- *
- * @param array $options
- * @return Zend_Filter_Compress
- */
- public function setOptions(array $options)
- {
- foreach ($options as $key => $value) {
- if ($key == 'options') {
- $key = 'adapterOptions';
- }
- $method = 'set' . ucfirst($key);
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
- return $this;
- }
-
- /**
- * Returns the current adapter, instantiating it if necessary
- *
- * @return string
- */
- public function getAdapter()
- {
- if ($this->_adapter instanceof Zend_Filter_Compress_CompressInterface) {
- return $this->_adapter;
- }
-
- $adapter = $this->_adapter;
- $options = $this->getAdapterOptions();
- if (!class_exists($adapter)) {
- require_once 'Zend/Loader.php';
- if (Zend_Loader::isReadable('Zend/Filter/Compress/' . ucfirst($adapter) . '.php')) {
- $adapter = 'Zend_Filter_Compress_' . ucfirst($adapter);
- }
- Zend_Loader::loadClass($adapter);
- }
-
- $this->_adapter = new $adapter($options);
- if (!$this->_adapter instanceof Zend_Filter_Compress_CompressInterface) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Compression adapter '" . $adapter . "' does not implement Zend_Filter_Compress_CompressInterface");
- }
- return $this->_adapter;
- }
-
- /**
- * Retrieve adapter name
- *
- * @return string
- */
- public function getAdapterName()
- {
- return $this->getAdapter()->toString();
- }
-
- /**
- * Sets compression adapter
- *
- * @param string|Zend_Filter_Compress_CompressInterface $adapter Adapter to use
- * @return Zend_Filter_Compress
- */
- public function setAdapter($adapter)
- {
- if ($adapter instanceof Zend_Filter_Compress_CompressInterface) {
- $this->_adapter = $adapter;
- return $this;
- }
- if (!is_string($adapter)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Invalid adapter provided; must be string or instance of Zend_Filter_Compress_CompressInterface');
- }
- $this->_adapter = $adapter;
-
- return $this;
- }
-
- /**
- * Retrieve adapter options
- *
- * @return array
- */
- public function getAdapterOptions()
- {
- return $this->_adapterOptions;
- }
-
- /**
- * Set adapter options
- *
- * @param array $options
- * @return void
- */
- public function setAdapterOptions(array $options)
- {
- $this->_adapterOptions = $options;
- return $this;
- }
-
- /**
- * Calls adapter methods
- *
- * @param string $method Method to call
- * @param string|array $options Options for this method
- */
- public function __call($method, $options)
- {
- $adapter = $this->getAdapter();
- if (!method_exists($adapter, $method)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Unknown method '{$method}'");
- }
-
- return call_user_func_array(array($adapter, $method), $options);
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Compresses the content $value with the defined settings
- *
- * @param string $value Content to compress
- * @return string The compressed content
- */
- public function filter($value)
- {
- return $this->getAdapter()->compress($value);
- }
-}
diff --git a/lib/zend/Zend/Filter/Compress/Bz2.php b/lib/zend/Zend/Filter/Compress/Bz2.php
deleted file mode 100644
index 6bd4451f7bdb5..0000000000000
--- a/lib/zend/Zend/Filter/Compress/Bz2.php
+++ /dev/null
@@ -1,188 +0,0 @@
- Blocksize to use from 0-9
- * 'archive' => Archive to use
- * )
- *
- * @var array
- */
- protected $_options = array(
- 'blocksize' => 4,
- 'archive' => null,
- );
-
- /**
- * Class constructor
- *
- * @param array|Zend_Config $options (Optional) Options to set
- */
- public function __construct($options = null)
- {
- if (!extension_loaded('bz2')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This filter needs the bz2 extension');
- }
- parent::__construct($options);
- }
-
- /**
- * Returns the set blocksize
- *
- * @return integer
- */
- public function getBlocksize()
- {
- return $this->_options['blocksize'];
- }
-
- /**
- * Sets a new blocksize
- *
- * @param integer $level
- * @return Zend_Filter_Compress_Bz2
- */
- public function setBlocksize($blocksize)
- {
- if (($blocksize < 0) || ($blocksize > 9)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Blocksize must be between 0 and 9');
- }
-
- $this->_options['blocksize'] = (int) $blocksize;
- return $this;
- }
-
- /**
- * Returns the set archive
- *
- * @return string
- */
- public function getArchive()
- {
- return $this->_options['archive'];
- }
-
- /**
- * Sets the archive to use for de-/compression
- *
- * @param string $archive Archive to use
- * @return Zend_Filter_Compress_Bz2
- */
- public function setArchive($archive)
- {
- $this->_options['archive'] = (string) $archive;
- return $this;
- }
-
- /**
- * Compresses the given content
- *
- * @param string $content
- * @return string
- */
- public function compress($content)
- {
- $archive = $this->getArchive();
- if (!empty($archive)) {
- $file = bzopen($archive, 'w');
- if (!$file) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Error opening the archive '" . $archive . "'");
- }
-
- bzwrite($file, $content);
- bzclose($file);
- $compressed = true;
- } else {
- $compressed = bzcompress($content, $this->getBlocksize());
- }
-
- if (is_int($compressed)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error during compression');
- }
-
- return $compressed;
- }
-
- /**
- * Decompresses the given content
- *
- * @param string $content
- * @return string
- */
- public function decompress($content)
- {
- $archive = $this->getArchive();
- if (@file_exists($content)) {
- $archive = $content;
- }
-
- if (@file_exists($archive)) {
- $file = bzopen($archive, 'r');
- if (!$file) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Error opening the archive '" . $content . "'");
- }
-
- $compressed = bzread($file);
- bzclose($file);
- } else {
- $compressed = bzdecompress($content);
- }
-
- if (is_int($compressed)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error during decompression');
- }
-
- return $compressed;
- }
-
- /**
- * Returns the adapter name
- *
- * @return string
- */
- public function toString()
- {
- return 'Bz2';
- }
-}
diff --git a/lib/zend/Zend/Filter/Compress/CompressAbstract.php b/lib/zend/Zend/Filter/Compress/CompressAbstract.php
deleted file mode 100644
index 2b20ac6f0716c..0000000000000
--- a/lib/zend/Zend/Filter/Compress/CompressAbstract.php
+++ /dev/null
@@ -1,89 +0,0 @@
-toArray();
- }
-
- if (is_array($options)) {
- $this->setOptions($options);
- }
- }
-
- /**
- * Returns one or all set options
- *
- * @param string $option (Optional) Option to return
- * @return mixed
- */
- public function getOptions($option = null)
- {
- if ($option === null) {
- return $this->_options;
- }
-
- if (!array_key_exists($option, $this->_options)) {
- return null;
- }
-
- return $this->_options[$option];
- }
-
- /**
- * Sets all or one option
- *
- * @param array $options
- * @return Zend_Filter_Compress_Bz2
- */
- public function setOptions(array $options)
- {
- foreach ($options as $key => $option) {
- $method = 'set' . $key;
- if (method_exists($this, $method)) {
- $this->$method($option);
- }
- }
-
- return $this;
- }
-}
diff --git a/lib/zend/Zend/Filter/Compress/CompressInterface.php b/lib/zend/Zend/Filter/Compress/CompressInterface.php
deleted file mode 100644
index 75f0a4063bc36..0000000000000
--- a/lib/zend/Zend/Filter/Compress/CompressInterface.php
+++ /dev/null
@@ -1,54 +0,0 @@
- Compression level 0-9
- * 'mode' => Compression mode, can be 'compress', 'deflate'
- * 'archive' => Archive to use
- * )
- *
- * @var array
- */
- protected $_options = array(
- 'level' => 9,
- 'mode' => 'compress',
- 'archive' => null,
- );
-
- /**
- * Class constructor
- *
- * @param array|Zend_Config|null $options (Optional) Options to set
- */
- public function __construct($options = null)
- {
- if (!extension_loaded('zlib')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This filter needs the zlib extension');
- }
- parent::__construct($options);
- }
-
- /**
- * Returns the set compression level
- *
- * @return integer
- */
- public function getLevel()
- {
- return $this->_options['level'];
- }
-
- /**
- * Sets a new compression level
- *
- * @param integer $level
- * @return Zend_Filter_Compress_Gz
- */
- public function setLevel($level)
- {
- if (($level < 0) || ($level > 9)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Level must be between 0 and 9');
- }
-
- $this->_options['level'] = (int) $level;
- return $this;
- }
-
- /**
- * Returns the set compression mode
- *
- * @return string
- */
- public function getMode()
- {
- return $this->_options['mode'];
- }
-
- /**
- * Sets a new compression mode
- *
- * @param string $mode Supported are 'compress', 'deflate' and 'file'
- */
- public function setMode($mode)
- {
- if (($mode != 'compress') && ($mode != 'deflate')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Given compression mode not supported');
- }
-
- $this->_options['mode'] = $mode;
- return $this;
- }
-
- /**
- * Returns the set archive
- *
- * @return string
- */
- public function getArchive()
- {
- return $this->_options['archive'];
- }
-
- /**
- * Sets the archive to use for de-/compression
- *
- * @param string $archive Archive to use
- * @return Zend_Filter_Compress_Gz
- */
- public function setArchive($archive)
- {
- $this->_options['archive'] = (string) $archive;
- return $this;
- }
-
- /**
- * Compresses the given content
- *
- * @param string $content
- * @return string
- */
- public function compress($content)
- {
- $archive = $this->getArchive();
- if (!empty($archive)) {
- $file = gzopen($archive, 'w' . $this->getLevel());
- if (!$file) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Error opening the archive '" . $this->_options['archive'] . "'");
- }
-
- gzwrite($file, $content);
- gzclose($file);
- $compressed = true;
- } else if ($this->_options['mode'] == 'deflate') {
- $compressed = gzdeflate($content, $this->getLevel());
- } else {
- $compressed = gzcompress($content, $this->getLevel());
- }
-
- if (!$compressed) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error during compression');
- }
-
- return $compressed;
- }
-
- /**
- * Decompresses the given content
- *
- * @param string $content
- * @return string
- */
- public function decompress($content)
- {
- $archive = $this->getArchive();
- $mode = $this->getMode();
- if (@file_exists($content)) {
- $archive = $content;
- }
-
- if (@file_exists($archive)) {
- $handler = fopen($archive, "rb");
- if (!$handler) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Error opening the archive '" . $archive . "'");
- }
-
- fseek($handler, -4, SEEK_END);
- $packet = fread($handler, 4);
- $bytes = unpack("V", $packet);
- $size = end($bytes);
- fclose($handler);
-
- $file = gzopen($archive, 'r');
- $compressed = gzread($file, $size);
- gzclose($file);
- } else if ($mode == 'deflate') {
- $compressed = gzinflate($content);
- } else {
- $compressed = gzuncompress($content);
- }
-
- if (!$compressed) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error during compression');
- }
-
- return $compressed;
- }
-
- /**
- * Returns the adapter name
- *
- * @return string
- */
- public function toString()
- {
- return 'Gz';
- }
-}
diff --git a/lib/zend/Zend/Filter/Compress/Lzf.php b/lib/zend/Zend/Filter/Compress/Lzf.php
deleted file mode 100644
index 33115105a0037..0000000000000
--- a/lib/zend/Zend/Filter/Compress/Lzf.php
+++ /dev/null
@@ -1,91 +0,0 @@
- Callback for compression
- * 'archive' => Archive to use
- * 'password' => Password to use
- * 'target' => Target to write the files to
- * )
- *
- * @var array
- */
- protected $_options = array(
- 'callback' => null,
- 'archive' => null,
- 'password' => null,
- 'target' => '.',
- );
-
- /**
- * Class constructor
- *
- * @param array $options (Optional) Options to set
- */
- public function __construct($options = null)
- {
- if (!extension_loaded('rar')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This filter needs the rar extension');
- }
- parent::__construct($options);
- }
-
- /**
- * Returns the set callback for compression
- *
- * @return string
- */
- public function getCallback()
- {
- return $this->_options['callback'];
- }
-
- /**
- * Sets the callback to use
- *
- * @param string $callback
- * @return Zend_Filter_Compress_Rar
- */
- public function setCallback($callback)
- {
- if (!is_callable($callback)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Callback can not be accessed');
- }
-
- $this->_options['callback'] = $callback;
- return $this;
- }
-
- /**
- * Returns the set archive
- *
- * @return string
- */
- public function getArchive()
- {
- return $this->_options['archive'];
- }
-
- /**
- * Sets the archive to use for de-/compression
- *
- * @param string $archive Archive to use
- * @return Zend_Filter_Compress_Rar
- */
- public function setArchive($archive)
- {
- $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive);
- $this->_options['archive'] = (string) $archive;
-
- return $this;
- }
-
- /**
- * Returns the set password
- *
- * @return string
- */
- public function getPassword()
- {
- return $this->_options['password'];
- }
-
- /**
- * Sets the password to use
- *
- * @param string $password
- * @return Zend_Filter_Compress_Rar
- */
- public function setPassword($password)
- {
- $this->_options['password'] = (string) $password;
- return $this;
- }
-
- /**
- * Returns the set targetpath
- *
- * @return string
- */
- public function getTarget()
- {
- return $this->_options['target'];
- }
-
- /**
- * Sets the targetpath to use
- *
- * @param string $target
- * @return Zend_Filter_Compress_Rar
- */
- public function setTarget($target)
- {
- if (!file_exists(dirname($target))) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The directory '$target' does not exist");
- }
-
- $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target);
- $this->_options['target'] = (string) $target;
- return $this;
- }
-
- /**
- * Compresses the given content
- *
- * @param string|array $content
- * @return string
- */
- public function compress($content)
- {
- $callback = $this->getCallback();
- if ($callback === null) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('No compression callback available');
- }
-
- $options = $this->getOptions();
- unset($options['callback']);
-
- $result = call_user_func($callback, $options, $content);
- if ($result !== true) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error compressing the RAR Archive');
- }
-
- return $this->getArchive();
- }
-
- /**
- * Decompresses the given content
- *
- * @param string $content
- * @return boolean
- */
- public function decompress($content)
- {
- $archive = $this->getArchive();
- if (file_exists($content)) {
- $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
- } elseif (empty($archive) || !file_exists($archive)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('RAR Archive not found');
- }
-
- $password = $this->getPassword();
- if ($password !== null) {
- $archive = rar_open($archive, $password);
- } else {
- $archive = rar_open($archive);
- }
-
- if (!$archive) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Error opening the RAR Archive");
- }
-
- $target = $this->getTarget();
- if (!is_dir($target)) {
- $target = dirname($target);
- }
-
- $filelist = rar_list($archive);
- if (!$filelist) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Error reading the RAR Archive");
- }
-
- foreach($filelist as $file) {
- $file->extract($target);
- }
-
- rar_close($archive);
- return true;
- }
-
- /**
- * Returns the adapter name
- *
- * @return string
- */
- public function toString()
- {
- return 'Rar';
- }
-}
diff --git a/lib/zend/Zend/Filter/Compress/Tar.php b/lib/zend/Zend/Filter/Compress/Tar.php
deleted file mode 100644
index d2ce0d89a9b54..0000000000000
--- a/lib/zend/Zend/Filter/Compress/Tar.php
+++ /dev/null
@@ -1,245 +0,0 @@
- Archive to use
- * 'target' => Target to write the files to
- * )
- *
- * @var array
- */
- protected $_options = array(
- 'archive' => null,
- 'target' => '.',
- 'mode' => null,
- );
-
- /**
- * Class constructor
- *
- * @param array $options (Optional) Options to set
- */
- public function __construct($options = null)
- {
- if (!class_exists('Archive_Tar')) {
- require_once 'Zend/Loader.php';
- try {
- Zend_Loader::loadClass('Archive_Tar');
- } catch (Zend_Exception $e) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This filter needs PEARs Archive_Tar', 0, $e);
- }
- }
-
- parent::__construct($options);
- }
-
- /**
- * Returns the set archive
- *
- * @return string
- */
- public function getArchive()
- {
- return $this->_options['archive'];
- }
-
- /**
- * Sets the archive to use for de-/compression
- *
- * @param string $archive Archive to use
- * @return Zend_Filter_Compress_Tar
- */
- public function setArchive($archive)
- {
- $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive);
- $this->_options['archive'] = (string) $archive;
-
- return $this;
- }
-
- /**
- * Returns the set targetpath
- *
- * @return string
- */
- public function getTarget()
- {
- return $this->_options['target'];
- }
-
- /**
- * Sets the targetpath to use
- *
- * @param string $target
- * @return Zend_Filter_Compress_Tar
- */
- public function setTarget($target)
- {
- if (!file_exists(dirname($target))) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The directory '$target' does not exist");
- }
-
- $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target);
- $this->_options['target'] = (string) $target;
- return $this;
- }
-
- /**
- * Returns the set compression mode
- */
- public function getMode()
- {
- return $this->_options['mode'];
- }
-
- /**
- * Compression mode to use
- * Eighter Gz or Bz2
- *
- * @param string $mode
- */
- public function setMode($mode)
- {
- $mode = ucfirst(strtolower($mode));
- if (($mode != 'Bz2') && ($mode != 'Gz')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The mode '$mode' is unknown");
- }
-
- if (($mode == 'Bz2') && (!extension_loaded('bz2'))) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This mode needs the bz2 extension');
- }
-
- if (($mode == 'Gz') && (!extension_loaded('zlib'))) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This mode needs the zlib extension');
- }
- }
-
- /**
- * Compresses the given content
- *
- * @param string $content
- * @return string
- */
- public function compress($content)
- {
- $archive = new Archive_Tar($this->getArchive(), $this->getMode());
- if (!file_exists($content)) {
- $file = $this->getTarget();
- if (is_dir($file)) {
- $file .= DIRECTORY_SEPARATOR . "tar.tmp";
- }
-
- $result = file_put_contents($file, $content);
- if ($result === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error creating the temporary file');
- }
-
- $content = $file;
- }
-
- if (is_dir($content)) {
- // collect all file infos
- foreach (new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator($content, RecursiveDirectoryIterator::KEY_AS_PATHNAME),
- RecursiveIteratorIterator::SELF_FIRST
- ) as $directory => $info
- ) {
- if ($info->isFile()) {
- $file[] = $directory;
- }
- }
-
- $content = $file;
- }
-
- $result = $archive->create($content);
- if ($result === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error creating the Tar archive');
- }
-
- return $this->getArchive();
- }
-
- /**
- * Decompresses the given content
- *
- * @param string $content
- * @return boolean
- */
- public function decompress($content)
- {
- $archive = $this->getArchive();
- if (file_exists($content)) {
- $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
- } elseif (empty($archive) || !file_exists($archive)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Tar Archive not found');
- }
-
- $archive = new Archive_Tar($archive, $this->getMode());
- $target = $this->getTarget();
- if (!is_dir($target)) {
- $target = dirname($target);
- }
-
- $result = $archive->extract($target);
- if ($result === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Error while extracting the Tar archive');
- }
-
- return true;
- }
-
- /**
- * Returns the adapter name
- *
- * @return string
- */
- public function toString()
- {
- return 'Tar';
- }
-}
diff --git a/lib/zend/Zend/Filter/Compress/Zip.php b/lib/zend/Zend/Filter/Compress/Zip.php
deleted file mode 100644
index 9921fe9648aea..0000000000000
--- a/lib/zend/Zend/Filter/Compress/Zip.php
+++ /dev/null
@@ -1,355 +0,0 @@
- Archive to use
- * 'password' => Password to use
- * 'target' => Target to write the files to
- * )
- *
- * @var array
- */
- protected $_options = array(
- 'archive' => null,
- 'target' => null,
- );
-
- /**
- * Class constructor
- *
- * @param string|array $options (Optional) Options to set
- */
- public function __construct($options = null)
- {
- if (!extension_loaded('zip')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This filter needs the zip extension');
- }
- parent::__construct($options);
- }
-
- /**
- * Returns the set archive
- *
- * @return string
- */
- public function getArchive()
- {
- return $this->_options['archive'];
- }
-
- /**
- * Sets the archive to use for de-/compression
- *
- * @param string $archive Archive to use
- * @return Zend_Filter_Compress_Rar
- */
- public function setArchive($archive)
- {
- $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive);
- $this->_options['archive'] = (string) $archive;
-
- return $this;
- }
-
- /**
- * Returns the set targetpath
- *
- * @return string
- */
- public function getTarget()
- {
- return $this->_options['target'];
- }
-
- /**
- * Sets the target to use
- *
- * @param string $target
- * @return Zend_Filter_Compress_Rar
- */
- public function setTarget($target)
- {
- if (!file_exists(dirname($target))) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The directory '$target' does not exist");
- }
-
- $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target);
- $this->_options['target'] = (string) $target;
- return $this;
- }
-
- /**
- * Compresses the given content
- *
- * @param string $content
- * @return string Compressed archive
- */
- public function compress($content)
- {
- $zip = new ZipArchive();
- $res = $zip->open($this->getArchive(), ZipArchive::CREATE | ZipArchive::OVERWRITE);
-
- if ($res !== true) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception($this->_errorString($res));
- }
-
- if (file_exists($content)) {
- $content = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
- $basename = substr($content, strrpos($content, DIRECTORY_SEPARATOR) + 1);
- if (is_dir($content)) {
- $index = strrpos($content, DIRECTORY_SEPARATOR) + 1;
- $content .= DIRECTORY_SEPARATOR;
- $stack = array($content);
- while (!empty($stack)) {
- $current = array_pop($stack);
- $files = array();
-
- $dir = dir($current);
- while (false !== ($node = $dir->read())) {
- if (($node == '.') || ($node == '..')) {
- continue;
- }
-
- if (is_dir($current . $node)) {
- array_push($stack, $current . $node . DIRECTORY_SEPARATOR);
- }
-
- if (is_file($current . $node)) {
- $files[] = $node;
- }
- }
-
- $local = substr($current, $index);
- $zip->addEmptyDir(substr($local, 0, -1));
-
- foreach ($files as $file) {
- $zip->addFile($current . $file, $local . $file);
- if ($res !== true) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception($this->_errorString($res));
- }
- }
- }
- } else {
- $res = $zip->addFile($content, $basename);
- if ($res !== true) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception($this->_errorString($res));
- }
- }
- } else {
- $file = $this->getTarget();
- if (!is_dir($file)) {
- $file = basename($file);
- } else {
- $file = "zip.tmp";
- }
-
- $res = $zip->addFromString($file, $content);
- if ($res !== true) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception($this->_errorString($res));
- }
- }
-
- $zip->close();
- return $this->_options['archive'];
- }
-
- /**
- * Decompresses the given content
- *
- * @param string $content
- * @return string
- */
- public function decompress($content)
- {
- $archive = $this->getArchive();
- if (file_exists($content)) {
- $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
- } elseif (empty($archive) || !file_exists($archive)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('ZIP Archive not found');
- }
-
- $zip = new ZipArchive();
- $res = $zip->open($archive);
-
- $target = $this->getTarget();
-
- if (!empty($target) && !is_dir($target)) {
- $target = dirname($target);
- }
-
- if (!empty($target)) {
- $target = rtrim($target, '/\\') . DIRECTORY_SEPARATOR;
- }
-
- if (empty($target) || !is_dir($target)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('No target for ZIP decompression set');
- }
-
- if ($res !== true) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception($this->_errorString($res));
- }
-
- if (version_compare(PHP_VERSION, '5.2.8', '<')) {
- for ($i = 0; $i < $zip->numFiles; $i++) {
- $statIndex = $zip->statIndex($i);
- $currName = $statIndex['name'];
- if (($currName{0} == '/') ||
- (substr($currName, 0, 2) == '..') ||
- (substr($currName, 0, 4) == './..')
- )
- {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Upward directory traversal was detected inside ' . $archive
- . ' please use PHP 5.2.8 or greater to take advantage of path resolution features of '
- . 'the zip extension in this decompress() method.'
- );
- }
- }
- }
-
- $res = @$zip->extractTo($target);
- if ($res !== true) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception($this->_errorString($res));
- }
-
- $zip->close();
- return $target;
- }
-
- /**
- * Returns the proper string based on the given error constant
- *
- * @param string $error
- */
- protected function _errorString($error)
- {
- switch($error) {
- case ZipArchive::ER_MULTIDISK :
- return 'Multidisk ZIP Archives not supported';
-
- case ZipArchive::ER_RENAME :
- return 'Failed to rename the temporary file for ZIP';
-
- case ZipArchive::ER_CLOSE :
- return 'Failed to close the ZIP Archive';
-
- case ZipArchive::ER_SEEK :
- return 'Failure while seeking the ZIP Archive';
-
- case ZipArchive::ER_READ :
- return 'Failure while reading the ZIP Archive';
-
- case ZipArchive::ER_WRITE :
- return 'Failure while writing the ZIP Archive';
-
- case ZipArchive::ER_CRC :
- return 'CRC failure within the ZIP Archive';
-
- case ZipArchive::ER_ZIPCLOSED :
- return 'ZIP Archive already closed';
-
- case ZipArchive::ER_NOENT :
- return 'No such file within the ZIP Archive';
-
- case ZipArchive::ER_EXISTS :
- return 'ZIP Archive already exists';
-
- case ZipArchive::ER_OPEN :
- return 'Can not open ZIP Archive';
-
- case ZipArchive::ER_TMPOPEN :
- return 'Failure creating temporary ZIP Archive';
-
- case ZipArchive::ER_ZLIB :
- return 'ZLib Problem';
-
- case ZipArchive::ER_MEMORY :
- return 'Memory allocation problem while working on a ZIP Archive';
-
- case ZipArchive::ER_CHANGED :
- return 'ZIP Entry has been changed';
-
- case ZipArchive::ER_COMPNOTSUPP :
- return 'Compression method not supported within ZLib';
-
- case ZipArchive::ER_EOF :
- return 'Premature EOF within ZIP Archive';
-
- case ZipArchive::ER_INVAL :
- return 'Invalid argument for ZLIB';
-
- case ZipArchive::ER_NOZIP :
- return 'Given file is no zip archive';
-
- case ZipArchive::ER_INTERNAL :
- return 'Internal error while working on a ZIP Archive';
-
- case ZipArchive::ER_INCONS :
- return 'Inconsistent ZIP archive';
-
- case ZipArchive::ER_REMOVE :
- return 'Can not remove ZIP Archive';
-
- case ZipArchive::ER_DELETED :
- return 'ZIP Entry has been deleted';
-
- default :
- return 'Unknown error within ZIP Archive';
- }
- }
-
- /**
- * Returns the adapter name
- *
- * @return string
- */
- public function toString()
- {
- return 'Zip';
- }
-}
diff --git a/lib/zend/Zend/Filter/Decompress.php b/lib/zend/Zend/Filter/Decompress.php
deleted file mode 100644
index 02e9a8e5d4f76..0000000000000
--- a/lib/zend/Zend/Filter/Decompress.php
+++ /dev/null
@@ -1,49 +0,0 @@
-getAdapter()->decompress($value);
- }
-}
diff --git a/lib/zend/Zend/Filter/Decrypt.php b/lib/zend/Zend/Filter/Decrypt.php
deleted file mode 100644
index 844d95b86f721..0000000000000
--- a/lib/zend/Zend/Filter/Decrypt.php
+++ /dev/null
@@ -1,49 +0,0 @@
-_adapter->decrypt($value);
- }
-}
diff --git a/lib/zend/Zend/Filter/Digits.php b/lib/zend/Zend/Filter/Digits.php
deleted file mode 100644
index 01c3ed5a73321..0000000000000
--- a/lib/zend/Zend/Filter/Digits.php
+++ /dev/null
@@ -1,82 +0,0 @@
-toArray();
- }
-
- $this->setAdapter($options);
- }
-
- /**
- * Returns the name of the set adapter
- *
- * @return string
- */
- public function getAdapter()
- {
- return $this->_adapter->toString();
- }
-
- /**
- * Sets new encryption options
- *
- * @param string|array $options (Optional) Encryption options
- * @return Zend_Filter_Encrypt
- */
- public function setAdapter($options = null)
- {
- if (is_string($options)) {
- $adapter = $options;
- } else if (isset($options['adapter'])) {
- $adapter = $options['adapter'];
- unset($options['adapter']);
- } else {
- $adapter = 'Mcrypt';
- }
-
- if (!is_array($options)) {
- $options = array();
- }
-
- if (Zend_Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter). '.php')) {
- $adapter = 'Zend_Filter_Encrypt_' . ucfirst($adapter);
- }
-
- if (!class_exists($adapter)) {
- Zend_Loader::loadClass($adapter);
- }
-
- $this->_adapter = new $adapter($options);
- if (!$this->_adapter instanceof Zend_Filter_Encrypt_Interface) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Encoding adapter '" . $adapter . "' does not implement Zend_Filter_Encrypt_Interface");
- }
-
- return $this;
- }
-
- /**
- * Calls adapter methods
- *
- * @param string $method Method to call
- * @param string|array $options Options for this method
- */
- public function __call($method, $options)
- {
- $part = substr($method, 0, 3);
- if ((($part != 'get') and ($part != 'set')) or !method_exists($this->_adapter, $method)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Unknown method '{$method}'");
- }
-
- return call_user_func_array(array($this->_adapter, $method), $options);
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Encrypts the content $value with the defined settings
- *
- * @param string $value Content to encrypt
- * @return string The encrypted content
- */
- public function filter($value)
- {
- return $this->_adapter->encrypt($value);
- }
-}
diff --git a/lib/zend/Zend/Filter/Encrypt/Interface.php b/lib/zend/Zend/Filter/Encrypt/Interface.php
deleted file mode 100644
index 1510e7ff90fef..0000000000000
--- a/lib/zend/Zend/Filter/Encrypt/Interface.php
+++ /dev/null
@@ -1,47 +0,0 @@
- encryption key string
- * 'algorithm' => algorithm to use
- * 'algorithm_directory' => directory where to find the algorithm
- * 'mode' => encryption mode to use
- * 'modedirectory' => directory where to find the mode
- * )
- */
- protected $_encryption = array(
- 'key' => 'ZendFramework',
- 'algorithm' => 'blowfish',
- 'algorithm_directory' => '',
- 'mode' => 'cbc',
- 'mode_directory' => '',
- 'vector' => null,
- 'salt' => false
- );
-
- /**
- * Internal compression
- *
- * @var array
- */
- protected $_compression;
-
- protected static $_srandCalled = false;
-
- /**
- * Class constructor
- *
- * @param string|array|Zend_Config $options Cryption Options
- */
- public function __construct($options)
- {
- if (!extension_loaded('mcrypt')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This filter needs the mcrypt extension');
- }
-
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (is_string($options)) {
- $options = array('key' => $options);
- } elseif (!is_array($options)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Invalid options argument provided to filter');
- }
-
- if (array_key_exists('compression', $options)) {
- $this->setCompression($options['compression']);
- unset($options['compress']);
- }
-
- $this->setEncryption($options);
- }
-
- /**
- * Returns the set encryption options
- *
- * @return array
- */
- public function getEncryption()
- {
- return $this->_encryption;
- }
-
- /**
- * Sets new encryption options
- *
- * @param string|array $options Encryption options
- * @return Zend_Filter_File_Encryption
- */
- public function setEncryption($options)
- {
- if (is_string($options)) {
- $options = array('key' => $options);
- }
-
- if (!is_array($options)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Invalid options argument provided to filter');
- }
-
- $options = $options + $this->getEncryption();
- $algorithms = mcrypt_list_algorithms($options['algorithm_directory']);
- if (!in_array($options['algorithm'], $algorithms)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The algorithm '{$options['algorithm']}' is not supported");
- }
-
- $modes = mcrypt_list_modes($options['mode_directory']);
- if (!in_array($options['mode'], $modes)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The mode '{$options['mode']}' is not supported");
- }
-
- if (!mcrypt_module_self_test($options['algorithm'], $options['algorithm_directory'])) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('The given algorithm can not be used due an internal mcrypt problem');
- }
-
- if (!isset($options['vector'])) {
- $options['vector'] = null;
- }
-
- $this->_encryption = $options;
- $this->setVector($options['vector']);
-
- return $this;
- }
-
- /**
- * Returns the set vector
- *
- * @return string
- */
- public function getVector()
- {
- return $this->_encryption['vector'];
- }
-
- /**
- * Sets the initialization vector
- *
- * @param string $vector (Optional) Vector to set
- * @return Zend_Filter_Encrypt_Mcrypt
- */
- public function setVector($vector = null)
- {
- $cipher = $this->_openCipher();
- $size = mcrypt_enc_get_iv_size($cipher);
- if (empty($vector)) {
- $this->_srand();
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<')) {
- $method = MCRYPT_RAND;
- } else {
- if (file_exists('/dev/urandom') || (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) {
- $method = MCRYPT_DEV_URANDOM;
- } elseif (file_exists('/dev/random')) {
- $method = MCRYPT_DEV_RANDOM;
- } else {
- $method = MCRYPT_RAND;
- }
- }
- $vector = mcrypt_create_iv($size, $method);
- } else if (strlen($vector) != $size) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('The given vector has a wrong size for the set algorithm');
- }
-
- $this->_encryption['vector'] = $vector;
- $this->_closeCipher($cipher);
-
- return $this;
- }
-
- /**
- * Returns the compression
- *
- * @return array
- */
- public function getCompression()
- {
- return $this->_compression;
- }
-
- /**
- * Sets a internal compression for values to encrypt
- *
- * @param string|array $compression
- * @return Zend_Filter_Encrypt_Mcrypt
- */
- public function setCompression($compression)
- {
- if (is_string($this->_compression)) {
- $compression = array('adapter' => $compression);
- }
-
- $this->_compression = $compression;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Encrypts $value with the defined settings
- *
- * @param string $value The content to encrypt
- * @return string The encrypted content
- */
- public function encrypt($value)
- {
- // compress prior to encryption
- if (!empty($this->_compression)) {
- require_once 'Zend/Filter/Compress.php';
- $compress = new Zend_Filter_Compress($this->_compression);
- $value = $compress->filter($value);
- }
-
- $cipher = $this->_openCipher();
- $this->_initCipher($cipher);
- $encrypted = mcrypt_generic($cipher, $value);
- mcrypt_generic_deinit($cipher);
- $this->_closeCipher($cipher);
-
- return $encrypted;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Decrypts $value with the defined settings
- *
- * @param string $value Content to decrypt
- * @return string The decrypted content
- */
- public function decrypt($value)
- {
- $cipher = $this->_openCipher();
- $this->_initCipher($cipher);
- $decrypted = mdecrypt_generic($cipher, $value);
- mcrypt_generic_deinit($cipher);
- $this->_closeCipher($cipher);
-
- // decompress after decryption
- if (!empty($this->_compression)) {
- require_once 'Zend/Filter/Decompress.php';
- $decompress = new Zend_Filter_Decompress($this->_compression);
- $decrypted = $decompress->filter($decrypted);
- }
-
- return $decrypted;
- }
-
- /**
- * Returns the adapter name
- *
- * @return string
- */
- public function toString()
- {
- return 'Mcrypt';
- }
-
- /**
- * Open a cipher
- *
- * @throws Zend_Filter_Exception When the cipher can not be opened
- * @return resource Returns the opened cipher
- */
- protected function _openCipher()
- {
- $cipher = mcrypt_module_open(
- $this->_encryption['algorithm'],
- $this->_encryption['algorithm_directory'],
- $this->_encryption['mode'],
- $this->_encryption['mode_directory']);
-
- if ($cipher === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Mcrypt can not be opened with your settings');
- }
-
- return $cipher;
- }
-
- /**
- * Close a cipher
- *
- * @param resource $cipher Cipher to close
- * @return Zend_Filter_Encrypt_Mcrypt
- */
- protected function _closeCipher($cipher)
- {
- mcrypt_module_close($cipher);
-
- return $this;
- }
-
- /**
- * Initialises the cipher with the set key
- *
- * @param resource $cipher
- * @throws
- * @return resource
- */
- protected function _initCipher($cipher)
- {
- $key = $this->_encryption['key'];
-
- $keysizes = mcrypt_enc_get_supported_key_sizes($cipher);
- if (empty($keysizes) || ($this->_encryption['salt'] == true)) {
- $this->_srand();
- $keysize = mcrypt_enc_get_key_size($cipher);
- $key = substr(md5($key), 0, $keysize);
- } else if (!in_array(strlen($key), $keysizes)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('The given key has a wrong size for the set algorithm');
- }
-
- $result = mcrypt_generic_init($cipher, $key, $this->_encryption['vector']);
- if ($result < 0) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Mcrypt could not be initialize with the given setting');
- }
-
- return $this;
- }
-
- /**
- * _srand() interception
- *
- * @see ZF-8742
- */
- protected function _srand()
- {
- if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
- return;
- }
-
- if (!self::$_srandCalled) {
- srand((double) microtime() * 1000000);
- self::$_srandCalled = true;
- }
- }
-}
diff --git a/lib/zend/Zend/Filter/Encrypt/Openssl.php b/lib/zend/Zend/Filter/Encrypt/Openssl.php
deleted file mode 100644
index 7d1f70bd0aecf..0000000000000
--- a/lib/zend/Zend/Filter/Encrypt/Openssl.php
+++ /dev/null
@@ -1,492 +0,0 @@
- public keys
- * 'private' => private keys
- * 'envelope' => resulting envelope keys
- * )
- */
- protected $_keys = array(
- 'public' => array(),
- 'private' => array(),
- 'envelope' => array()
- );
-
- /**
- * Internal passphrase
- *
- * @var string
- */
- protected $_passphrase;
-
- /**
- * Internal compression
- *
- * @var array
- */
- protected $_compression;
-
- /**
- * Internal create package
- *
- * @var boolean
- */
- protected $_package = false;
-
- /**
- * Class constructor
- * Available options
- * 'public' => public key
- * 'private' => private key
- * 'envelope' => envelope key
- * 'passphrase' => passphrase
- * 'compression' => compress value with this compression adapter
- * 'package' => pack envelope keys into encrypted string, simplifies decryption
- *
- * @param string|array $options Options for this adapter
- */
- public function __construct($options = array())
- {
- if (!extension_loaded('openssl')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('This filter needs the openssl extension');
- }
-
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
-
- if (!is_array($options)) {
- $options = array('public' => $options);
- }
-
- if (array_key_exists('passphrase', $options)) {
- $this->setPassphrase($options['passphrase']);
- unset($options['passphrase']);
- }
-
- if (array_key_exists('compression', $options)) {
- $this->setCompression($options['compression']);
- unset($options['compress']);
- }
-
- if (array_key_exists('package', $options)) {
- $this->setPackage($options['package']);
- unset($options['package']);
- }
-
- $this->_setKeys($options);
- }
-
- /**
- * Sets the encryption keys
- *
- * @param string|array $keys Key with type association
- * @return Zend_Filter_Encrypt_Openssl
- */
- protected function _setKeys($keys)
- {
- if (!is_array($keys)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Invalid options argument provided to filter');
- }
-
- foreach ($keys as $type => $key) {
- if (ctype_print($key) && is_file(realpath($key)) && is_readable($key)) {
- $file = fopen($key, 'r');
- $cert = fread($file, 8192);
- fclose($file);
- } else {
- $cert = $key;
- $key = count($this->_keys[$type]);
- }
-
- switch ($type) {
- case 'public':
- $test = openssl_pkey_get_public($cert);
- if ($test === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Public key '{$cert}' not valid");
- }
-
- openssl_free_key($test);
- $this->_keys['public'][$key] = $cert;
- break;
- case 'private':
- $test = openssl_pkey_get_private($cert, $this->_passphrase);
- if ($test === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Private key '{$cert}' not valid");
- }
-
- openssl_free_key($test);
- $this->_keys['private'][$key] = $cert;
- break;
- case 'envelope':
- $this->_keys['envelope'][$key] = $cert;
- break;
- default:
- break;
- }
- }
-
- return $this;
- }
-
- /**
- * Returns all public keys
- *
- * @return array
- */
- public function getPublicKey()
- {
- $key = $this->_keys['public'];
- return $key;
- }
-
- /**
- * Sets public keys
- *
- * @param string|array $key Public keys
- * @return Zend_Filter_Encrypt_Openssl
- */
- public function setPublicKey($key)
- {
- if (is_array($key)) {
- foreach($key as $type => $option) {
- if ($type !== 'public') {
- $key['public'] = $option;
- unset($key[$type]);
- }
- }
- } else {
- $key = array('public' => $key);
- }
-
- return $this->_setKeys($key);
- }
-
- /**
- * Returns all private keys
- *
- * @return array
- */
- public function getPrivateKey()
- {
- $key = $this->_keys['private'];
- return $key;
- }
-
- /**
- * Sets private keys
- *
- * @param string $key Private key
- * @param string $passphrase
- * @return Zend_Filter_Encrypt_Openssl
- */
- public function setPrivateKey($key, $passphrase = null)
- {
- if (is_array($key)) {
- foreach($key as $type => $option) {
- if ($type !== 'private') {
- $key['private'] = $option;
- unset($key[$type]);
- }
- }
- } else {
- $key = array('private' => $key);
- }
-
- if ($passphrase !== null) {
- $this->setPassphrase($passphrase);
- }
-
- return $this->_setKeys($key);
- }
-
- /**
- * Returns all envelope keys
- *
- * @return array
- */
- public function getEnvelopeKey()
- {
- $key = $this->_keys['envelope'];
- return $key;
- }
-
- /**
- * Sets envelope keys
- *
- * @param string|array $options Envelope keys
- * @return Zend_Filter_Encrypt_Openssl
- */
- public function setEnvelopeKey($key)
- {
- if (is_array($key)) {
- foreach($key as $type => $option) {
- if ($type !== 'envelope') {
- $key['envelope'] = $option;
- unset($key[$type]);
- }
- }
- } else {
- $key = array('envelope' => $key);
- }
-
- return $this->_setKeys($key);
- }
-
- /**
- * Returns the passphrase
- *
- * @return string
- */
- public function getPassphrase()
- {
- return $this->_passphrase;
- }
-
- /**
- * Sets a new passphrase
- *
- * @param string $passphrase
- * @return Zend_Filter_Encrypt_Openssl
- */
- public function setPassphrase($passphrase)
- {
- $this->_passphrase = $passphrase;
- return $this;
- }
-
- /**
- * Returns the compression
- *
- * @return array
- */
- public function getCompression()
- {
- return $this->_compression;
- }
-
- /**
- * Sets a internal compression for values to encrypt
- *
- * @param string|array $compression
- * @return Zend_Filter_Encrypt_Openssl
- */
- public function setCompression($compression)
- {
- if (is_string($this->_compression)) {
- $compression = array('adapter' => $compression);
- }
-
- $this->_compression = $compression;
- return $this;
- }
-
- /**
- * Returns if header should be packaged
- *
- * @return boolean
- */
- public function getPackage()
- {
- return $this->_package;
- }
-
- /**
- * Sets if the envelope keys should be included in the encrypted value
- *
- * @param boolean $package
- * @return Zend_Filter_Encrypt_Openssl
- */
- public function setPackage($package)
- {
- $this->_package = (boolean) $package;
- return $this;
- }
-
- /**
- * Encrypts $value with the defined settings
- * Note that you also need the "encrypted" keys to be able to decrypt
- *
- * @param string $value Content to encrypt
- * @return string The encrypted content
- * @throws Zend_Filter_Exception
- */
- public function encrypt($value)
- {
- $encrypted = array();
- $encryptedkeys = array();
-
- if (count($this->_keys['public']) == 0) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Openssl can not encrypt without public keys');
- }
-
- $keys = array();
- $fingerprints = array();
- $count = -1;
- foreach($this->_keys['public'] as $key => $cert) {
- $keys[$key] = openssl_pkey_get_public($cert);
- if ($this->_package) {
- $details = openssl_pkey_get_details($keys[$key]);
- if ($details === false) {
- $details = array('key' => 'ZendFramework');
- }
-
- ++$count;
- $fingerprints[$count] = md5($details['key']);
- }
- }
-
- // compress prior to encryption
- if (!empty($this->_compression)) {
- require_once 'Zend/Filter/Compress.php';
- $compress = new Zend_Filter_Compress($this->_compression);
- $value = $compress->filter($value);
- }
-
- $crypt = openssl_seal($value, $encrypted, $encryptedkeys, $keys);
- foreach ($keys as $key) {
- openssl_free_key($key);
- }
-
- if ($crypt === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Openssl was not able to encrypt your content with the given options');
- }
-
- $this->_keys['envelope'] = $encryptedkeys;
-
- // Pack data and envelope keys into single string
- if ($this->_package) {
- $header = pack('n', count($this->_keys['envelope']));
- foreach($this->_keys['envelope'] as $key => $envKey) {
- $header .= pack('H32n', $fingerprints[$key], strlen($envKey)) . $envKey;
- }
-
- $encrypted = $header . $encrypted;
- }
-
- return $encrypted;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Decrypts $value with the defined settings
- *
- * @param string $value Content to decrypt
- * @return string The decrypted content
- * @throws Zend_Filter_Exception
- */
- public function decrypt($value)
- {
- $decrypted = "";
- $envelope = current($this->getEnvelopeKey());
-
- if (count($this->_keys['private']) !== 1) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Please give a private key for decryption with Openssl');
- }
-
- if (!$this->_package && empty($envelope)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Please give a envelope key for decryption with Openssl');
- }
-
- foreach($this->_keys['private'] as $key => $cert) {
- $keys = openssl_pkey_get_private($cert, $this->getPassphrase());
- }
-
- if ($this->_package) {
- $details = openssl_pkey_get_details($keys);
- if ($details !== false) {
- $fingerprint = md5($details['key']);
- } else {
- $fingerprint = md5("ZendFramework");
- }
-
- $count = unpack('ncount', $value);
- $count = $count['count'];
- $length = 2;
- for($i = $count; $i > 0; --$i) {
- $header = unpack('H32print/nsize', substr($value, $length, 18));
- $length += 18;
- if ($header['print'] == $fingerprint) {
- $envelope = substr($value, $length, $header['size']);
- }
-
- $length += $header['size'];
- }
-
- // remainder of string is the value to decrypt
- $value = substr($value, $length);
- }
-
- $crypt = openssl_open($value, $decrypted, $envelope, $keys);
- openssl_free_key($keys);
-
- if ($crypt === false) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Openssl was not able to decrypt you content with the given options');
- }
-
- // decompress after decryption
- if (!empty($this->_compression)) {
- require_once 'Zend/Filter/Decompress.php';
- $decompress = new Zend_Filter_Decompress($this->_compression);
- $decrypted = $decompress->filter($decrypted);
- }
-
- return $decrypted;
- }
-
- /**
- * Returns the adapter name
- *
- * @return string
- */
- public function toString()
- {
- return 'Openssl';
- }
-}
diff --git a/lib/zend/Zend/Filter/Exception.php b/lib/zend/Zend/Filter/Exception.php
deleted file mode 100644
index 5763b2456ec0b..0000000000000
--- a/lib/zend/Zend/Filter/Exception.php
+++ /dev/null
@@ -1,37 +0,0 @@
-_filename;
- }
-
- /**
- * Sets the new filename where the content will be stored
- *
- * @param string $filename (Optional) New filename to set
- * @return Zend_Filter_File_Encryt
- */
- public function setFilename($filename = null)
- {
- $this->_filename = $filename;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Decrypts the file $value with the defined settings
- *
- * @param string $value Full path of file to change
- * @return string The filename which has been set, or false when there were errors
- */
- public function filter($value)
- {
- if (!file_exists($value)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '$value' not found");
- }
-
- if (!isset($this->_filename)) {
- $this->_filename = $value;
- }
-
- if (file_exists($this->_filename) and !is_writable($this->_filename)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable");
- }
-
- $content = file_get_contents($value);
- if (!$content) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while reading file '$value'");
- }
-
- $decrypted = parent::filter($content);
- $result = file_put_contents($this->_filename, $decrypted);
-
- if (!$result) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'");
- }
-
- return $this->_filename;
- }
-}
diff --git a/lib/zend/Zend/Filter/File/Encrypt.php b/lib/zend/Zend/Filter/File/Encrypt.php
deleted file mode 100644
index 23c71b4b0aad3..0000000000000
--- a/lib/zend/Zend/Filter/File/Encrypt.php
+++ /dev/null
@@ -1,106 +0,0 @@
-_filename;
- }
-
- /**
- * Sets the new filename where the content will be stored
- *
- * @param string $filename (Optional) New filename to set
- * @return Zend_Filter_File_Encryt
- */
- public function setFilename($filename = null)
- {
- $this->_filename = $filename;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Encrypts the file $value with the defined settings
- *
- * @param string $value Full path of file to change
- * @return string The filename which has been set, or false when there were errors
- */
- public function filter($value)
- {
- if (!file_exists($value)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '$value' not found");
- }
-
- if (!isset($this->_filename)) {
- $this->_filename = $value;
- }
-
- if (file_exists($this->_filename) and !is_writable($this->_filename)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable");
- }
-
- $content = file_get_contents($value);
- if (!$content) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while reading file '$value'");
- }
-
- $encrypted = parent::filter($content);
- $result = file_put_contents($this->_filename, $encrypted);
-
- if (!$result) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'");
- }
-
- return $this->_filename;
- }
-}
diff --git a/lib/zend/Zend/Filter/File/LowerCase.php b/lib/zend/Zend/Filter/File/LowerCase.php
deleted file mode 100644
index dd34321dea71c..0000000000000
--- a/lib/zend/Zend/Filter/File/LowerCase.php
+++ /dev/null
@@ -1,84 +0,0 @@
-setEncoding($options);
- }
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Does a lowercase on the content of the given file
- *
- * @param string $value Full path of file to change
- * @return string The given $value
- * @throws Zend_Filter_Exception
- */
- public function filter($value)
- {
- if (!file_exists($value)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '$value' not found");
- }
-
- if (!is_writable($value)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '$value' is not writable");
- }
-
- $content = file_get_contents($value);
- if (!$content) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while reading file '$value'");
- }
-
- $content = parent::filter($content);
- $result = file_put_contents($value, $content);
-
- if (!$result) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while writing file '$value'");
- }
-
- return $value;
- }
-}
diff --git a/lib/zend/Zend/Filter/File/Rename.php b/lib/zend/Zend/Filter/File/Rename.php
deleted file mode 100644
index b70acbe301fc6..0000000000000
--- a/lib/zend/Zend/Filter/File/Rename.php
+++ /dev/null
@@ -1,309 +0,0 @@
- Source filename or directory which will be renamed
- * 'target' => Target filename or directory, the new name of the sourcefile
- * 'overwrite' => Shall existing files be overwritten ?
- *
- * @param string|array $options Target file or directory to be renamed
- * @param string $target Source filename or directory (deprecated)
- * @param bool $overwrite Should existing files be overwritten (deprecated)
- * @return void
- */
- public function __construct($options)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (is_string($options)) {
- $options = array('target' => $options);
- } elseif (!is_array($options)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Invalid options argument provided to filter');
- }
-
- if (1 < func_num_args()) {
- $argv = func_get_args();
- array_shift($argv);
- $source = array_shift($argv);
- $overwrite = false;
- if (!empty($argv)) {
- $overwrite = array_shift($argv);
- }
- $options['source'] = $source;
- $options['overwrite'] = $overwrite;
- }
-
- $this->setFile($options);
- }
-
- /**
- * Returns the files to rename and their new name and location
- *
- * @return array
- */
- public function getFile()
- {
- return $this->_files;
- }
-
- /**
- * Sets a new file or directory as target, deleting existing ones
- *
- * Array accepts the following keys:
- * 'source' => Source filename or directory which will be renamed
- * 'target' => Target filename or directory, the new name of the sourcefile
- * 'overwrite' => Shall existing files be overwritten ?
- *
- * @param string|array $options Old file or directory to be rewritten
- * @return Zend_Filter_File_Rename
- */
- public function setFile($options)
- {
- $this->_files = array();
- $this->addFile($options);
-
- return $this;
- }
-
- /**
- * Adds a new file or directory as target to the existing ones
- *
- * Array accepts the following keys:
- * 'source' => Source filename or directory which will be renamed
- * 'target' => Target filename or directory, the new name of the sourcefile
- * 'overwrite' => Shall existing files be overwritten ?
- *
- * @param string|array $options Old file or directory to be rewritten
- * @return Zend_Filter_File_Rename
- */
- public function addFile($options)
- {
- if (is_string($options)) {
- $options = array('target' => $options);
- } elseif (!is_array($options)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception ('Invalid options to rename filter provided');
- }
-
- $this->_convertOptions($options);
-
- return $this;
- }
-
- /**
- * Returns only the new filename without moving it
- * But existing files will be erased when the overwrite option is true
- *
- * @param string $value Full path of file to change
- * @param boolean $source Return internal informations
- * @return string The new filename which has been set
- */
- public function getNewName($value, $source = false)
- {
- $file = $this->_getFileName($value);
-
- if (!is_array($file) || !array_key_exists('source', $file) || !array_key_exists('target', $file)) {
- return $value;
- }
-
- if ($file['source'] == $file['target']) {
- return $value;
- }
-
- if (!file_exists($file['source'])) {
- return $value;
- }
-
- if (($file['overwrite'] == true) && (file_exists($file['target']))) {
- unlink($file['target']);
- }
-
- if (file_exists($file['target'])) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception(sprintf("File '%s' could not be renamed. It already exists.", $value));
- }
-
- if ($source) {
- return $file;
- }
-
- return $file['target'];
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Renames the file $value to the new name set before
- * Returns the file $value, removing all but digit characters
- *
- * @param string $value Full path of file to change
- * @throws Zend_Filter_Exception
- * @return string The new filename which has been set, or false when there were errors
- */
- public function filter($value)
- {
- $file = $this->getNewName($value, true);
- if (is_string($file)) {
- return $file;
- }
-
- $result = rename($file['source'], $file['target']);
-
- if ($result === true) {
- return $file['target'];
- }
-
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception(sprintf("File '%s' could not be renamed. An error occured while processing the file.", $value));
- }
-
- /**
- * Internal method for creating the file array
- * Supports single and nested arrays
- *
- * @param array $options
- * @return array
- */
- protected function _convertOptions($options) {
- $files = array();
- foreach ($options as $key => $value) {
- if (is_array($value)) {
- $this->_convertOptions($value);
- continue;
- }
-
- switch ($key) {
- case "source":
- $files['source'] = (string) $value;
- break;
-
- case 'target' :
- $files['target'] = (string) $value;
- break;
-
- case 'overwrite' :
- $files['overwrite'] = (boolean) $value;
- break;
-
- default:
- break;
- }
- }
-
- if (empty($files)) {
- return $this;
- }
-
- if (empty($files['source'])) {
- $files['source'] = '*';
- }
-
- if (empty($files['target'])) {
- $files['target'] = '*';
- }
-
- if (empty($files['overwrite'])) {
- $files['overwrite'] = false;
- }
-
- $found = false;
- foreach ($this->_files as $key => $value) {
- if ($value['source'] == $files['source']) {
- $this->_files[$key] = $files;
- $found = true;
- }
- }
-
- if (!$found) {
- $count = count($this->_files);
- $this->_files[$count] = $files;
- }
-
- return $this;
- }
-
- /**
- * Internal method to resolve the requested source
- * and return all other related parameters
- *
- * @param string $file Filename to get the informations for
- * @return array
- */
- protected function _getFileName($file)
- {
- $rename = array();
- foreach ($this->_files as $value) {
- if ($value['source'] == '*') {
- if (!isset($rename['source'])) {
- $rename = $value;
- $rename['source'] = $file;
- }
- }
-
- if ($value['source'] == $file) {
- $rename = $value;
- }
- }
-
- if (!isset($rename['source'])) {
- return $file;
- }
-
- if (!isset($rename['target']) or ($rename['target'] == '*')) {
- $rename['target'] = $rename['source'];
- }
-
- if (is_dir($rename['target'])) {
- $name = basename($rename['source']);
- $last = $rename['target'][strlen($rename['target']) - 1];
- if (($last != '/') and ($last != '\\')) {
- $rename['target'] .= DIRECTORY_SEPARATOR;
- }
-
- $rename['target'] .= $name;
- }
-
- return $rename;
- }
-}
diff --git a/lib/zend/Zend/Filter/File/UpperCase.php b/lib/zend/Zend/Filter/File/UpperCase.php
deleted file mode 100644
index e65453e0fdb8f..0000000000000
--- a/lib/zend/Zend/Filter/File/UpperCase.php
+++ /dev/null
@@ -1,84 +0,0 @@
-setEncoding($options);
- }
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Does a lowercase on the content of the given file
- *
- * @param string $value Full path of file to change
- * @return string The given $value
- * @throws Zend_Filter_Exception
- */
- public function filter($value)
- {
- if (!file_exists($value)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '$value' not found");
- }
-
- if (!is_writable($value)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("File '$value' is not writable");
- }
-
- $content = file_get_contents($value);
- if (!$content) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while reading file '$value'");
- }
-
- $content = parent::filter($content);
- $result = file_put_contents($value, $content);
-
- if (!$result) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Problem while writing file '$value'");
- }
-
- return $value;
- }
-}
diff --git a/lib/zend/Zend/Filter/HtmlEntities.php b/lib/zend/Zend/Filter/HtmlEntities.php
deleted file mode 100644
index 0c1dfecb956fc..0000000000000
--- a/lib/zend/Zend/Filter/HtmlEntities.php
+++ /dev/null
@@ -1,216 +0,0 @@
-toArray();
- } else if (!is_array($options)) {
- $options = func_get_args();
- $temp['quotestyle'] = array_shift($options);
- if (!empty($options)) {
- $temp['charset'] = array_shift($options);
- }
-
- $options = $temp;
- }
-
- if (!isset($options['quotestyle'])) {
- $options['quotestyle'] = ENT_COMPAT;
- }
-
- if (!isset($options['encoding'])) {
- $options['encoding'] = 'UTF-8';
- }
- if (isset($options['charset'])) {
- $options['encoding'] = $options['charset'];
- }
-
- if (!isset($options['doublequote'])) {
- $options['doublequote'] = true;
- }
-
- $this->setQuoteStyle($options['quotestyle']);
- $this->setEncoding($options['encoding']);
- $this->setDoubleQuote($options['doublequote']);
- }
-
- /**
- * Returns the quoteStyle option
- *
- * @return integer
- */
- public function getQuoteStyle()
- {
- return $this->_quoteStyle;
- }
-
- /**
- * Sets the quoteStyle option
- *
- * @param integer $quoteStyle
- * @return Zend_Filter_HtmlEntities Provides a fluent interface
- */
- public function setQuoteStyle($quoteStyle)
- {
- $this->_quoteStyle = $quoteStyle;
- return $this;
- }
-
-
- /**
- * Get encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Set encoding
- *
- * @param string $value
- * @return Zend_Filter_HtmlEntities
- */
- public function setEncoding($value)
- {
- $this->_encoding = (string) $value;
- return $this;
- }
-
- /**
- * Returns the charSet option
- *
- * Proxies to {@link getEncoding()}
- *
- * @return string
- */
- public function getCharSet()
- {
- return $this->getEncoding();
- }
-
- /**
- * Sets the charSet option
- *
- * Proxies to {@link setEncoding()}
- *
- * @param string $charSet
- * @return Zend_Filter_HtmlEntities Provides a fluent interface
- */
- public function setCharSet($charSet)
- {
- return $this->setEncoding($charSet);
- }
-
- /**
- * Returns the doubleQuote option
- *
- * @return boolean
- */
- public function getDoubleQuote()
- {
- return $this->_doubleQuote;
- }
-
- /**
- * Sets the doubleQuote option
- *
- * @param boolean $doubleQuote
- * @return Zend_Filter_HtmlEntities Provides a fluent interface
- */
- public function setDoubleQuote($doubleQuote)
- {
- $this->_doubleQuote = (boolean) $doubleQuote;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns the string $value, converting characters to their corresponding HTML entity
- * equivalents where they exist
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- $filtered = htmlentities((string) $value, $this->getQuoteStyle(), $this->getEncoding(), $this->getDoubleQuote());
- if (strlen((string) $value) && !strlen($filtered)) {
- if (!function_exists('iconv')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Encoding mismatch has resulted in htmlentities errors');
- }
- $enc = $this->getEncoding();
- $value = iconv('', $enc . '//IGNORE', (string) $value);
- $filtered = htmlentities($value, $this->getQuoteStyle(), $enc, $this->getDoubleQuote());
- if (!strlen($filtered)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Encoding mismatch has resulted in htmlentities errors');
- }
- }
- return $filtered;
- }
-}
diff --git a/lib/zend/Zend/Filter/Inflector.php b/lib/zend/Zend/Filter/Inflector.php
deleted file mode 100644
index 00eea7d64b26b..0000000000000
--- a/lib/zend/Zend/Filter/Inflector.php
+++ /dev/null
@@ -1,527 +0,0 @@
-toArray();
- } else if (!is_array($options)) {
- $options = func_get_args();
- $temp = array();
-
- if (!empty($options)) {
- $temp['target'] = array_shift($options);
- }
-
- if (!empty($options)) {
- $temp['rules'] = array_shift($options);
- }
-
- if (!empty($options)) {
- $temp['throwTargetExceptionsOn'] = array_shift($options);
- }
-
- if (!empty($options)) {
- $temp['targetReplacementIdentifier'] = array_shift($options);
- }
-
- $options = $temp;
- }
-
- $this->setOptions($options);
- }
-
- /**
- * Retreive PluginLoader
- *
- * @return Zend_Loader_PluginLoader_Interface
- */
- public function getPluginLoader()
- {
- if (!$this->_pluginLoader instanceof Zend_Loader_PluginLoader_Interface) {
- $this->_pluginLoader = new Zend_Loader_PluginLoader(array('Zend_Filter_' => 'Zend/Filter/'), __CLASS__);
- }
-
- return $this->_pluginLoader;
- }
-
- /**
- * Set PluginLoader
- *
- * @param Zend_Loader_PluginLoader_Interface $pluginLoader
- * @return Zend_Filter_Inflector
- */
- public function setPluginLoader(Zend_Loader_PluginLoader_Interface $pluginLoader)
- {
- $this->_pluginLoader = $pluginLoader;
- return $this;
- }
-
- /**
- * Use Zend_Config object to set object state
- *
- * @deprecated Use setOptions() instead
- * @param Zend_Config $config
- * @return Zend_Filter_Inflector
- */
- public function setConfig(Zend_Config $config)
- {
- return $this->setOptions($config);
- }
-
- /**
- * Set options
- *
- * @param array $options
- * @return Zend_Filter_Inflector
- */
- public function setOptions($options) {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
-
- // Set Präfix Path
- if (array_key_exists('filterPrefixPath', $options)) {
- if (!is_scalar($options['filterPrefixPath'])) {
- foreach ($options['filterPrefixPath'] as $prefix => $path) {
- $this->addFilterPrefixPath($prefix, $path);
- }
- }
- }
-
- if (array_key_exists('throwTargetExceptionsOn', $options)) {
- $this->setThrowTargetExceptionsOn($options['throwTargetExceptionsOn']);
- }
-
- if (array_key_exists('targetReplacementIdentifier', $options)) {
- $this->setTargetReplacementIdentifier($options['targetReplacementIdentifier']);
- }
-
- if (array_key_exists('target', $options)) {
- $this->setTarget($options['target']);
- }
-
- if (array_key_exists('rules', $options)) {
- $this->addRules($options['rules']);
- }
-
- return $this;
- }
-
- /**
- * Convienence method to add prefix and path to PluginLoader
- *
- * @param string $prefix
- * @param string $path
- * @return Zend_Filter_Inflector
- */
- public function addFilterPrefixPath($prefix, $path)
- {
- $this->getPluginLoader()->addPrefixPath($prefix, $path);
- return $this;
- }
-
- /**
- * Set Whether or not the inflector should throw an exception when a replacement
- * identifier is still found within an inflected target.
- *
- * @param bool $throwTargetExceptions
- * @return Zend_Filter_Inflector
- */
- public function setThrowTargetExceptionsOn($throwTargetExceptionsOn)
- {
- $this->_throwTargetExceptionsOn = ($throwTargetExceptionsOn == true) ? true : false;
- return $this;
- }
-
- /**
- * Will exceptions be thrown?
- *
- * @return bool
- */
- public function isThrowTargetExceptionsOn()
- {
- return $this->_throwTargetExceptionsOn;
- }
-
- /**
- * Set the Target Replacement Identifier, by default ':'
- *
- * @param string $targetReplacementIdentifier
- * @return Zend_Filter_Inflector
- */
- public function setTargetReplacementIdentifier($targetReplacementIdentifier)
- {
- if ($targetReplacementIdentifier) {
- $this->_targetReplacementIdentifier = (string) $targetReplacementIdentifier;
- }
-
- return $this;
- }
-
- /**
- * Get Target Replacement Identifier
- *
- * @return string
- */
- public function getTargetReplacementIdentifier()
- {
- return $this->_targetReplacementIdentifier;
- }
-
- /**
- * Set a Target
- * ex: 'scripts/:controller/:action.:suffix'
- *
- * @param string
- * @return Zend_Filter_Inflector
- */
- public function setTarget($target)
- {
- $this->_target = (string) $target;
- return $this;
- }
-
- /**
- * Retrieve target
- *
- * @return string
- */
- public function getTarget()
- {
- return $this->_target;
- }
-
- /**
- * Set Target Reference
- *
- * @param reference $target
- * @return Zend_Filter_Inflector
- */
- public function setTargetReference(&$target)
- {
- $this->_target =& $target;
- return $this;
- }
-
- /**
- * SetRules() is the same as calling addRules() with the exception that it
- * clears the rules before adding them.
- *
- * @param array $rules
- * @return Zend_Filter_Inflector
- */
- public function setRules(Array $rules)
- {
- $this->clearRules();
- $this->addRules($rules);
- return $this;
- }
-
- /**
- * AddRules(): multi-call to setting filter rules.
- *
- * If prefixed with a ":" (colon), a filter rule will be added. If not
- * prefixed, a static replacement will be added.
- *
- * ex:
- * array(
- * ':controller' => array('CamelCaseToUnderscore','StringToLower'),
- * ':action' => array('CamelCaseToUnderscore','StringToLower'),
- * 'suffix' => 'phtml'
- * );
- *
- * @param array
- * @return Zend_Filter_Inflector
- */
- public function addRules(Array $rules)
- {
- $keys = array_keys($rules);
- foreach ($keys as $spec) {
- if ($spec[0] == ':') {
- $this->addFilterRule($spec, $rules[$spec]);
- } else {
- $this->setStaticRule($spec, $rules[$spec]);
- }
- }
-
- return $this;
- }
-
- /**
- * Get rules
- *
- * By default, returns all rules. If a $spec is provided, will return those
- * rules if found, false otherwise.
- *
- * @param string $spec
- * @return array|false
- */
- public function getRules($spec = null)
- {
- if (null !== $spec) {
- $spec = $this->_normalizeSpec($spec);
- if (isset($this->_rules[$spec])) {
- return $this->_rules[$spec];
- }
- return false;
- }
-
- return $this->_rules;
- }
-
- /**
- * getRule() returns a rule set by setFilterRule(), a numeric index must be provided
- *
- * @param string $spec
- * @param int $index
- * @return Zend_Filter_Interface|false
- */
- public function getRule($spec, $index)
- {
- $spec = $this->_normalizeSpec($spec);
- if (isset($this->_rules[$spec]) && is_array($this->_rules[$spec])) {
- if (isset($this->_rules[$spec][$index])) {
- return $this->_rules[$spec][$index];
- }
- }
- return false;
- }
-
- /**
- * ClearRules() clears the rules currently in the inflector
- *
- * @return Zend_Filter_Inflector
- */
- public function clearRules()
- {
- $this->_rules = array();
- return $this;
- }
-
- /**
- * Set a filtering rule for a spec. $ruleSet can be a string, Filter object
- * or an array of strings or filter objects.
- *
- * @param string $spec
- * @param array|string|Zend_Filter_Interface $ruleSet
- * @return Zend_Filter_Inflector
- */
- public function setFilterRule($spec, $ruleSet)
- {
- $spec = $this->_normalizeSpec($spec);
- $this->_rules[$spec] = array();
- return $this->addFilterRule($spec, $ruleSet);
- }
-
- /**
- * Add a filter rule for a spec
- *
- * @param mixed $spec
- * @param mixed $ruleSet
- * @return void
- */
- public function addFilterRule($spec, $ruleSet)
- {
- $spec = $this->_normalizeSpec($spec);
- if (!isset($this->_rules[$spec])) {
- $this->_rules[$spec] = array();
- }
-
- if (!is_array($ruleSet)) {
- $ruleSet = array($ruleSet);
- }
-
- if (is_string($this->_rules[$spec])) {
- $temp = $this->_rules[$spec];
- $this->_rules[$spec] = array();
- $this->_rules[$spec][] = $temp;
- }
-
- foreach ($ruleSet as $rule) {
- $this->_rules[$spec][] = $this->_getRule($rule);
- }
-
- return $this;
- }
-
- /**
- * Set a static rule for a spec. This is a single string value
- *
- * @param string $name
- * @param string $value
- * @return Zend_Filter_Inflector
- */
- public function setStaticRule($name, $value)
- {
- $name = $this->_normalizeSpec($name);
- $this->_rules[$name] = (string) $value;
- return $this;
- }
-
- /**
- * Set Static Rule Reference.
- *
- * This allows a consuming class to pass a property or variable
- * in to be referenced when its time to build the output string from the
- * target.
- *
- * @param string $name
- * @param mixed $reference
- * @return Zend_Filter_Inflector
- */
- public function setStaticRuleReference($name, &$reference)
- {
- $name = $this->_normalizeSpec($name);
- $this->_rules[$name] =& $reference;
- return $this;
- }
-
- /**
- * Inflect
- *
- * @param string|array $source
- * @return string
- */
- public function filter($source)
- {
- // clean source
- foreach ( (array) $source as $sourceName => $sourceValue) {
- $source[ltrim($sourceName, ':')] = $sourceValue;
- }
-
- $pregQuotedTargetReplacementIdentifier = preg_quote($this->_targetReplacementIdentifier, '#');
- $processedParts = array();
-
- foreach ($this->_rules as $ruleName => $ruleValue) {
- if (isset($source[$ruleName])) {
- if (is_string($ruleValue)) {
- // overriding the set rule
- $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $source[$ruleName]);
- } elseif (is_array($ruleValue)) {
- $processedPart = $source[$ruleName];
- foreach ($ruleValue as $ruleFilter) {
- $processedPart = $ruleFilter->filter($processedPart);
- }
- $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $processedPart);
- }
- } elseif (is_string($ruleValue)) {
- $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $ruleValue);
- }
- }
-
- // all of the values of processedParts would have been str_replace('\\', '\\\\', ..)'d to disable preg_replace backreferences
- $inflectedTarget = preg_replace(array_keys($processedParts), array_values($processedParts), $this->_target);
-
- if ($this->_throwTargetExceptionsOn && (preg_match('#(?='.$pregQuotedTargetReplacementIdentifier.'[A-Za-z]{1})#', $inflectedTarget) == true)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('A replacement identifier ' . $this->_targetReplacementIdentifier . ' was found inside the inflected target, perhaps a rule was not satisfied with a target source? Unsatisfied inflected target: ' . $inflectedTarget);
- }
-
- return $inflectedTarget;
- }
-
- /**
- * Normalize spec string
- *
- * @param string $spec
- * @return string
- */
- protected function _normalizeSpec($spec)
- {
- return ltrim((string) $spec, ':&');
- }
-
- /**
- * Resolve named filters and convert them to filter objects.
- *
- * @param string $rule
- * @return Zend_Filter_Interface
- */
- protected function _getRule($rule)
- {
- if ($rule instanceof Zend_Filter_Interface) {
- return $rule;
- }
-
- $rule = (string) $rule;
-
- $className = $this->getPluginLoader()->load($rule);
- $ruleObject = new $className();
- if (!$ruleObject instanceof Zend_Filter_Interface) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('No class named ' . $rule . ' implementing Zend_Filter_Interface could be found');
- }
-
- return $ruleObject;
- }
-}
diff --git a/lib/zend/Zend/Filter/Input.php b/lib/zend/Zend/Filter/Input.php
deleted file mode 100644
index c3229fa6fb4e5..0000000000000
--- a/lib/zend/Zend/Filter/Input.php
+++ /dev/null
@@ -1,1209 +0,0 @@
- false,
- self::BREAK_CHAIN => false,
- self::ESCAPE_FILTER => 'HtmlEntities',
- self::MISSING_MESSAGE => "Field '%field%' is required by rule '%rule%', but the field is missing",
- self::NOT_EMPTY_MESSAGE => "You must give a non-empty value for field '%field%'",
- self::PRESENCE => self::PRESENCE_OPTIONAL
- );
-
- /**
- * @var boolean Set to False initially, this is set to True after the
- * input data have been processed. Reset to False in setData() method.
- */
- protected $_processed = false;
-
- /**
- * Translation object
- * @var Zend_Translate
- */
- protected $_translator;
-
- /**
- * Is translation disabled?
- * @var Boolean
- */
- protected $_translatorDisabled = false;
-
- /**
- * @param array $filterRules
- * @param array $validatorRules
- * @param array $data OPTIONAL
- * @param array $options OPTIONAL
- */
- public function __construct($filterRules, $validatorRules, array $data = null, array $options = null)
- {
- if ($options) {
- $this->setOptions($options);
- }
-
- $this->_filterRules = (array) $filterRules;
- $this->_validatorRules = (array) $validatorRules;
-
- if ($data) {
- $this->setData($data);
- }
- }
-
- /**
- * @param mixed $namespaces
- * @return Zend_Filter_Input
- * @deprecated since 1.5.0RC1 - use addFilterPrefixPath() or addValidatorPrefixPath instead.
- */
- public function addNamespace($namespaces)
- {
- if (!is_array($namespaces)) {
- $namespaces = array($namespaces);
- }
-
- foreach ($namespaces as $namespace) {
- $prefix = $namespace;
- $path = str_replace('_', DIRECTORY_SEPARATOR, $prefix);
- $this->addFilterPrefixPath($prefix, $path);
- $this->addValidatorPrefixPath($prefix, $path);
- }
-
- return $this;
- }
-
- /**
- * Add prefix path for all elements
- *
- * @param string $prefix
- * @param string $path
- * @return Zend_Filter_Input
- */
- public function addFilterPrefixPath($prefix, $path)
- {
- $this->getPluginLoader(self::FILTER)->addPrefixPath($prefix, $path);
-
- return $this;
- }
-
- /**
- * Add prefix path for all elements
- *
- * @param string $prefix
- * @param string $path
- * @return Zend_Filter_Input
- */
- public function addValidatorPrefixPath($prefix, $path)
- {
- $this->getPluginLoader(self::VALIDATE)->addPrefixPath($prefix, $path);
-
- return $this;
- }
-
- /**
- * Set plugin loaders for use with decorators and elements
- *
- * @param Zend_Loader_PluginLoader_Interface $loader
- * @param string $type 'filter' or 'validate'
- * @return Zend_Filter_Input
- * @throws Zend_Filter_Exception on invalid type
- */
- public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader, $type)
- {
- $type = strtolower($type);
- switch ($type) {
- case self::FILTER:
- case self::VALIDATE:
- $this->_loaders[$type] = $loader;
- return $this;
- default:
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception(sprintf('Invalid type "%s" provided to setPluginLoader()', $type));
- }
-
- return $this;
- }
-
- /**
- * Retrieve plugin loader for given type
- *
- * $type may be one of:
- * - filter
- * - validator
- *
- * If a plugin loader does not exist for the given type, defaults are
- * created.
- *
- * @param string $type 'filter' or 'validate'
- * @return Zend_Loader_PluginLoader_Interface
- * @throws Zend_Filter_Exception on invalid type
- */
- public function getPluginLoader($type)
- {
- $type = strtolower($type);
- if (!isset($this->_loaders[$type])) {
- switch ($type) {
- case self::FILTER:
- $prefixSegment = 'Zend_Filter_';
- $pathSegment = 'Zend/Filter/';
- break;
- case self::VALIDATE:
- $prefixSegment = 'Zend_Validate_';
- $pathSegment = 'Zend/Validate/';
- break;
- default:
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception(sprintf('Invalid type "%s" provided to getPluginLoader()', $type));
- }
-
- require_once 'Zend/Loader/PluginLoader.php';
- $this->_loaders[$type] = new Zend_Loader_PluginLoader(
- array($prefixSegment => $pathSegment)
- );
- }
-
- return $this->_loaders[$type];
- }
-
- /**
- * @return array
- */
- public function getMessages()
- {
- $this->_process();
- return array_merge($this->_invalidMessages, $this->_missingFields);
- }
-
- /**
- * @return array
- */
- public function getErrors()
- {
- $this->_process();
- return $this->_invalidErrors;
- }
-
- /**
- * @return array
- */
- public function getInvalid()
- {
- $this->_process();
- return $this->_invalidMessages;
- }
-
- /**
- * @return array
- */
- public function getMissing()
- {
- $this->_process();
- return $this->_missingFields;
- }
-
- /**
- * @return array
- */
- public function getUnknown()
- {
- $this->_process();
- return $this->_unknownFields;
- }
-
- /**
- * @param string $fieldName OPTIONAL
- * @return mixed
- */
- public function getEscaped($fieldName = null)
- {
- $this->_process();
- $this->_getDefaultEscapeFilter();
-
- if ($fieldName === null) {
- return $this->_escapeRecursive($this->_validFields);
- }
- if (array_key_exists($fieldName, $this->_validFields)) {
- return $this->_escapeRecursive($this->_validFields[$fieldName]);
- }
- return null;
- }
-
- /**
- * @param mixed $value
- * @return mixed
- */
- protected function _escapeRecursive($data)
- {
- if($data === null) {
- return $data;
- }
-
- if (!is_array($data)) {
- return $this->_getDefaultEscapeFilter()->filter($data);
- }
- foreach ($data as &$element) {
- $element = $this->_escapeRecursive($element);
- }
- return $data;
- }
-
- /**
- * @param string $fieldName OPTIONAL
- * @return mixed
- */
- public function getUnescaped($fieldName = null)
- {
- $this->_process();
- if ($fieldName === null) {
- return $this->_validFields;
- }
- if (array_key_exists($fieldName, $this->_validFields)) {
- return $this->_validFields[$fieldName];
- }
- return null;
- }
-
- /**
- * @param string $fieldName
- * @return mixed
- */
- public function __get($fieldName)
- {
- return $this->getEscaped($fieldName);
- }
-
- /**
- * @return boolean
- */
- public function hasInvalid()
- {
- $this->_process();
- return !(empty($this->_invalidMessages));
- }
-
- /**
- * @return boolean
- */
- public function hasMissing()
- {
- $this->_process();
- return !(empty($this->_missingFields));
- }
-
- /**
- * @return boolean
- */
- public function hasUnknown()
- {
- $this->_process();
- return !(empty($this->_unknownFields));
- }
-
- /**
- * @return boolean
- */
- public function hasValid()
- {
- $this->_process();
- return !(empty($this->_validFields));
- }
-
- /**
- * @param string $fieldName
- * @return boolean
- */
- public function isValid($fieldName = null)
- {
- $this->_process();
- if ($fieldName === null) {
- return !($this->hasMissing() || $this->hasInvalid());
- }
- return array_key_exists($fieldName, $this->_validFields);
- }
-
- /**
- * @param string $fieldName
- * @return boolean
- */
- public function __isset($fieldName)
- {
- $this->_process();
- return isset($this->_validFields[$fieldName]);
- }
-
- /**
- * @return Zend_Filter_Input
- * @throws Zend_Filter_Exception
- */
- public function process()
- {
- $this->_process();
- if ($this->hasInvalid()) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Input has invalid fields");
- }
- if ($this->hasMissing()) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Input has missing fields");
- }
-
- return $this;
- }
-
- /**
- * @param array $data
- * @return Zend_Filter_Input
- */
- public function setData(array $data)
- {
- $this->_data = $data;
-
- /**
- * Reset to initial state
- */
- $this->_validFields = array();
- $this->_invalidMessages = array();
- $this->_invalidErrors = array();
- $this->_missingFields = array();
- $this->_unknownFields = array();
-
- $this->_processed = false;
-
- return $this;
- }
-
- /**
- * @param mixed $escapeFilter
- * @return Zend_Filter_Interface
- */
- public function setDefaultEscapeFilter($escapeFilter)
- {
- if (is_string($escapeFilter) || is_array($escapeFilter)) {
- $escapeFilter = $this->_getFilter($escapeFilter);
- }
- if (!$escapeFilter instanceof Zend_Filter_Interface) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Escape filter specified does not implement Zend_Filter_Interface');
- }
- $this->_defaultEscapeFilter = $escapeFilter;
- return $escapeFilter;
- }
-
- /**
- * @param array $options
- * @return Zend_Filter_Input
- * @throws Zend_Filter_Exception if an unknown option is given
- */
- public function setOptions(array $options)
- {
- foreach ($options as $option => $value) {
- switch ($option) {
- case self::ESCAPE_FILTER:
- $this->setDefaultEscapeFilter($value);
- break;
- case self::INPUT_NAMESPACE:
- $this->addNamespace($value);
- break;
- case self::VALIDATOR_NAMESPACE:
- if(is_string($value)) {
- $value = array($value);
- }
-
- foreach($value AS $prefix) {
- $this->addValidatorPrefixPath(
- $prefix,
- str_replace('_', DIRECTORY_SEPARATOR, $prefix)
- );
- }
- break;
- case self::FILTER_NAMESPACE:
- if(is_string($value)) {
- $value = array($value);
- }
-
- foreach($value AS $prefix) {
- $this->addFilterPrefixPath(
- $prefix,
- str_replace('_', DIRECTORY_SEPARATOR, $prefix)
- );
- }
- break;
- case self::ALLOW_EMPTY:
- case self::BREAK_CHAIN:
- case self::MISSING_MESSAGE:
- case self::NOT_EMPTY_MESSAGE:
- case self::PRESENCE:
- $this->_defaults[$option] = $value;
- break;
- default:
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Unknown option '$option'");
- break;
- }
- }
-
- return $this;
- }
-
- /**
- * Set translation object
- *
- * @param Zend_Translate|Zend_Translate_Adapter|null $translator
- * @return Zend_Filter_Input
- */
- public function setTranslator($translator = null)
- {
- if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) {
- $this->_translator = $translator;
- } elseif ($translator instanceof Zend_Translate) {
- $this->_translator = $translator->getAdapter();
- } else {
- require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception('Invalid translator specified');
- }
-
- return $this;
- }
-
- /**
- * Return translation object
- *
- * @return Zend_Translate_Adapter|null
- */
- public function getTranslator()
- {
- if ($this->translatorIsDisabled()) {
- return null;
- }
-
- if ($this->_translator === null) {
- require_once 'Zend/Registry.php';
- if (Zend_Registry::isRegistered('Zend_Translate')) {
- $translator = Zend_Registry::get('Zend_Translate');
- if ($translator instanceof Zend_Translate_Adapter) {
- return $translator;
- } elseif ($translator instanceof Zend_Translate) {
- return $translator->getAdapter();
- }
- }
- }
-
- return $this->_translator;
- }
-
- /**
- * Indicate whether or not translation should be disabled
- *
- * @param bool $flag
- * @return Zend_Filter_Input
- */
- public function setDisableTranslator($flag)
- {
- $this->_translatorDisabled = (bool) $flag;
- return $this;
- }
-
- /**
- * Is translation disabled?
- *
- * @return bool
- */
- public function translatorIsDisabled()
- {
- return $this->_translatorDisabled;
- }
-
- /*
- * Protected methods
- */
-
- /**
- * @return void
- */
- protected function _filter()
- {
- foreach ($this->_filterRules as $ruleName => &$filterRule) {
- /**
- * Make sure we have an array representing this filter chain.
- * Don't typecast to (array) because it might be a Zend_Filter object
- */
- if (!is_array($filterRule)) {
- $filterRule = array($filterRule);
- }
-
- /**
- * Filters are indexed by integer, metacommands are indexed by string.
- * Pick out the filters.
- */
- $filterList = array();
- foreach ($filterRule as $key => $value) {
- if (is_int($key)) {
- $filterList[] = $value;
- }
- }
-
- /**
- * Use defaults for filter metacommands.
- */
- $filterRule[self::RULE] = $ruleName;
- if (!isset($filterRule[self::FIELDS])) {
- $filterRule[self::FIELDS] = $ruleName;
- }
-
- /**
- * Load all the filter classes and add them to the chain.
- */
- if (!isset($filterRule[self::FILTER_CHAIN])) {
- $filterRule[self::FILTER_CHAIN] = new Zend_Filter();
- foreach ($filterList as $filter) {
- if (is_string($filter) || is_array($filter)) {
- $filter = $this->_getFilter($filter);
- }
- $filterRule[self::FILTER_CHAIN]->addFilter($filter);
- }
- }
-
- /**
- * If the ruleName is the special wildcard rule,
- * then apply the filter chain to all input data.
- * Else just process the field named by the rule.
- */
- if ($ruleName == self::RULE_WILDCARD) {
- foreach (array_keys($this->_data) as $field) {
- $this->_filterRule(array_merge($filterRule, array(self::FIELDS => $field)));
- }
- } else {
- $this->_filterRule($filterRule);
- }
- }
- }
-
- /**
- * @param array $filterRule
- * @return void
- */
- protected function _filterRule(array $filterRule)
- {
- $field = $filterRule[self::FIELDS];
- if (!array_key_exists($field, $this->_data)) {
- return;
- }
- if (is_array($this->_data[$field])) {
- foreach ($this->_data[$field] as $key => $value) {
- $this->_data[$field][$key] = $filterRule[self::FILTER_CHAIN]->filter($value);
- }
- } else {
- $this->_data[$field] =
- $filterRule[self::FILTER_CHAIN]->filter($this->_data[$field]);
- }
- }
-
- /**
- * @return Zend_Filter_Interface
- */
- protected function _getDefaultEscapeFilter()
- {
- if ($this->_defaultEscapeFilter !== null) {
- return $this->_defaultEscapeFilter;
- }
- return $this->setDefaultEscapeFilter($this->_defaults[self::ESCAPE_FILTER]);
- }
-
- /**
- * @param string $rule
- * @param string $field
- * @return string
- */
- protected function _getMissingMessage($rule, $field)
- {
- $message = $this->_defaults[self::MISSING_MESSAGE];
-
- if (null !== ($translator = $this->getTranslator())) {
- if ($translator->isTranslated(self::MISSING_MESSAGE)) {
- $message = $translator->translate(self::MISSING_MESSAGE);
- } else {
- $message = $translator->translate($message);
- }
- }
-
- $message = str_replace('%rule%', $rule, $message);
- $message = str_replace('%field%', $field, $message);
- return $message;
- }
-
- /**
- * @return string
- */
- protected function _getNotEmptyMessage($rule, $field)
- {
- $message = $this->_defaults[self::NOT_EMPTY_MESSAGE];
-
- if (null !== ($translator = $this->getTranslator())) {
- if ($translator->isTranslated(self::NOT_EMPTY_MESSAGE)) {
- $message = $translator->translate(self::NOT_EMPTY_MESSAGE);
- } else {
- $message = $translator->translate($message);
- }
- }
-
- $message = str_replace('%rule%', $rule, $message);
- $message = str_replace('%field%', $field, $message);
- return $message;
- }
-
- /**
- * @return void
- */
- protected function _process()
- {
- if ($this->_processed === false) {
- $this->_filter();
- $this->_validate();
- $this->_processed = true;
- }
- }
-
- /**
- * @return void
- */
- protected function _validate()
- {
- /**
- * Special case: if there are no validators, treat all fields as valid.
- */
- if (!$this->_validatorRules) {
- $this->_validFields = $this->_data;
- $this->_data = array();
- return;
- }
-
- // remember the default not empty message in case we want to temporarily change it
- $preserveDefaultNotEmptyMessage = $this->_defaults[self::NOT_EMPTY_MESSAGE];
-
- foreach ($this->_validatorRules as $ruleName => &$validatorRule) {
- /**
- * Make sure we have an array representing this validator chain.
- * Don't typecast to (array) because it might be a Zend_Validate object
- */
- if (!is_array($validatorRule)) {
- $validatorRule = array($validatorRule);
- }
-
- /**
- * Validators are indexed by integer, metacommands are indexed by string.
- * Pick out the validators.
- */
- $validatorList = array();
- foreach ($validatorRule as $key => $value) {
- if (is_int($key)) {
- $validatorList[$key] = $value;
- }
- }
-
- /**
- * Use defaults for validation metacommands.
- */
- $validatorRule[self::RULE] = $ruleName;
- if (!isset($validatorRule[self::FIELDS])) {
- $validatorRule[self::FIELDS] = $ruleName;
- }
- if (!isset($validatorRule[self::BREAK_CHAIN])) {
- $validatorRule[self::BREAK_CHAIN] = $this->_defaults[self::BREAK_CHAIN];
- }
- if (!isset($validatorRule[self::PRESENCE])) {
- $validatorRule[self::PRESENCE] = $this->_defaults[self::PRESENCE];
- }
- if (!isset($validatorRule[self::ALLOW_EMPTY])) {
- $foundNotEmptyValidator = false;
-
- foreach ($validatorRule as $rule) {
- if ($rule === 'NotEmpty') {
- $foundNotEmptyValidator = true;
- // field may not be empty, we are ready
- break 1;
- }
-
- if (is_array($rule)) {
- $keys = array_keys($rule);
- $classKey = array_shift($keys);
- if (isset($rule[$classKey])) {
- $ruleClass = $rule[$classKey];
- if ($ruleClass === 'NotEmpty') {
- $foundNotEmptyValidator = true;
- // field may not be empty, we are ready
- break 1;
- }
- }
- }
-
- // we must check if it is an object before using instanceof
- if (!is_object($rule)) {
- // it cannot be a NotEmpty validator, skip this one
- continue;
- }
-
- if($rule instanceof Zend_Validate_NotEmpty) {
- $foundNotEmptyValidator = true;
- // field may not be empty, we are ready
- break 1;
- }
- }
-
- if (!$foundNotEmptyValidator) {
- $validatorRule[self::ALLOW_EMPTY] = $this->_defaults[self::ALLOW_EMPTY];
- } else {
- $validatorRule[self::ALLOW_EMPTY] = false;
- }
- }
-
- if (!isset($validatorRule[self::MESSAGES])) {
- $validatorRule[self::MESSAGES] = array();
- } else if (!is_array($validatorRule[self::MESSAGES])) {
- $validatorRule[self::MESSAGES] = array($validatorRule[self::MESSAGES]);
- } else if (array_intersect_key($validatorList, $validatorRule[self::MESSAGES])) {
- // this seems pointless... it just re-adds what it already has...
- // I can disable all this and not a single unit test fails...
- // There are now corresponding numeric keys in the validation rule messages array
- // Treat it as a named messages list for all rule validators
- $unifiedMessages = $validatorRule[self::MESSAGES];
- $validatorRule[self::MESSAGES] = array();
-
- foreach ($validatorList as $key => $validator) {
- if (array_key_exists($key, $unifiedMessages)) {
- $validatorRule[self::MESSAGES][$key] = $unifiedMessages[$key];
- }
- }
- }
-
- /**
- * Load all the validator classes and add them to the chain.
- */
- if (!isset($validatorRule[self::VALIDATOR_CHAIN])) {
- $validatorRule[self::VALIDATOR_CHAIN] = new Zend_Validate();
-
- foreach ($validatorList as $key => $validator) {
- if (is_string($validator) || is_array($validator)) {
- $validator = $this->_getValidator($validator);
- }
-
- if (isset($validatorRule[self::MESSAGES][$key])) {
- $value = $validatorRule[self::MESSAGES][$key];
- if (is_array($value)) {
- $validator->setMessages($value);
- } else {
- $validator->setMessage($value);
- }
-
- if ($validator instanceof Zend_Validate_NotEmpty) {
- /** we are changing the defaults here, this is alright if all subsequent validators are also a not empty
- * validator, but it goes wrong if one of them is not AND is required!!!
- * that is why we restore the default value at the end of this loop
- */
- if (is_array($value)) {
- $temp = $value; // keep the original value
- $this->_defaults[self::NOT_EMPTY_MESSAGE] = array_pop($temp);
- unset($temp);
- } else {
- $this->_defaults[self::NOT_EMPTY_MESSAGE] = $value;
- }
- }
- }
-
- $validatorRule[self::VALIDATOR_CHAIN]->addValidator($validator, $validatorRule[self::BREAK_CHAIN]);
- }
- $validatorRule[self::VALIDATOR_CHAIN_COUNT] = count($validatorList);
- }
-
- /**
- * If the ruleName is the special wildcard rule,
- * then apply the validator chain to all input data.
- * Else just process the field named by the rule.
- */
- if ($ruleName == self::RULE_WILDCARD) {
- foreach (array_keys($this->_data) as $field) {
- $this->_validateRule(array_merge($validatorRule, array(self::FIELDS => $field)));
- }
- } else {
- $this->_validateRule($validatorRule);
- }
-
- // reset the default not empty message
- $this->_defaults[self::NOT_EMPTY_MESSAGE] = $preserveDefaultNotEmptyMessage;
- }
-
-
-
- /**
- * Unset fields in $_data that have been added to other arrays.
- * We have to wait until all rules have been processed because
- * a given field may be referenced by multiple rules.
- */
- foreach (array_merge(array_keys($this->_missingFields), array_keys($this->_invalidMessages)) as $rule) {
- foreach ((array) $this->_validatorRules[$rule][self::FIELDS] as $field) {
- unset($this->_data[$field]);
- }
- }
- foreach ($this->_validFields as $field => $value) {
- unset($this->_data[$field]);
- }
-
- /**
- * Anything left over in $_data is an unknown field.
- */
- $this->_unknownFields = $this->_data;
- }
-
- /**
- * @param array $validatorRule
- * @return void
- */
- protected function _validateRule(array $validatorRule)
- {
- /**
- * Get one or more data values from input, and check for missing fields.
- * Apply defaults if fields are missing.
- */
- $data = array();
- foreach ((array) $validatorRule[self::FIELDS] as $key => $field) {
- if (array_key_exists($field, $this->_data)) {
- $data[$field] = $this->_data[$field];
- } else if (isset($validatorRule[self::DEFAULT_VALUE])) {
- /** @todo according to this code default value can't be an array. It has to be reviewed */
- if (!is_array($validatorRule[self::DEFAULT_VALUE])) {
- // Default value is a scalar
- $data[$field] = $validatorRule[self::DEFAULT_VALUE];
- } else {
- // Default value is an array. Search for corresponding key
- if (isset($validatorRule[self::DEFAULT_VALUE][$key])) {
- $data[$field] = $validatorRule[self::DEFAULT_VALUE][$key];
- } else if ($validatorRule[self::PRESENCE] == self::PRESENCE_REQUIRED) {
- // Default value array is provided, but it doesn't have an entry for current field
- // and presence is required
- $this->_missingFields[$validatorRule[self::RULE]][] =
- $this->_getMissingMessage($validatorRule[self::RULE], $field);
- }
- }
- } else if ($validatorRule[self::PRESENCE] == self::PRESENCE_REQUIRED) {
- $this->_missingFields[$validatorRule[self::RULE]][] =
- $this->_getMissingMessage($validatorRule[self::RULE], $field);
- }
- }
-
- /**
- * If any required fields are missing, break the loop.
- */
- if (isset($this->_missingFields[$validatorRule[self::RULE]]) && count($this->_missingFields[$validatorRule[self::RULE]]) > 0) {
- return;
- }
-
- /**
- * Evaluate the inputs against the validator chain.
- */
- if (count((array) $validatorRule[self::FIELDS]) > 1) {
- if (!$validatorRule[self::ALLOW_EMPTY]) {
- $emptyFieldsFound = false;
- $errorsList = array();
- $messages = array();
-
- foreach ($data as $fieldKey => $field) {
- // if there is no Zend_Validate_NotEmpty instance in the rules, we will use the default
- if (!($notEmptyValidator = $this->_getNotEmptyValidatorInstance($validatorRule))) {
- $notEmptyValidator = $this->_getValidator('NotEmpty');
- $notEmptyValidator->setMessage($this->_getNotEmptyMessage($validatorRule[self::RULE], $fieldKey));
- }
-
- if (!$notEmptyValidator->isValid($field)) {
- foreach ($notEmptyValidator->getMessages() as $messageKey => $message) {
- if (!isset($messages[$messageKey])) {
- $messages[$messageKey] = $message;
- } else {
- $messages[] = $message;
- }
- }
- $errorsList[] = $notEmptyValidator->getErrors();
- $emptyFieldsFound = true;
- }
- }
-
- if ($emptyFieldsFound) {
- $this->_invalidMessages[$validatorRule[self::RULE]] = $messages;
- $this->_invalidErrors[$validatorRule[self::RULE]] = array_unique(call_user_func_array('array_merge', $errorsList));
- return;
- }
- }
-
- if (!$validatorRule[self::VALIDATOR_CHAIN]->isValid($data)) {
- $this->_invalidMessages[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getMessages();
- $this->_invalidErrors[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getErrors();
- return;
- }
- } else if (count($data) > 0) {
- // $data is actually a one element array
- $fieldNames = array_keys($data);
- $fieldName = reset($fieldNames);
- $field = reset($data);
-
- $failed = false;
- if (!is_array($field)) {
- $field = array($field);
- }
-
- // if there is no Zend_Validate_NotEmpty instance in the rules, we will use the default
- if (!($notEmptyValidator = $this->_getNotEmptyValidatorInstance($validatorRule))) {
- $notEmptyValidator = $this->_getValidator('NotEmpty');
- $notEmptyValidator->setMessage($this->_getNotEmptyMessage($validatorRule[self::RULE], $fieldName));
- }
-
- if ($validatorRule[self::ALLOW_EMPTY]) {
- $validatorChain = $validatorRule[self::VALIDATOR_CHAIN];
- } else {
- $validatorChain = new Zend_Validate();
- $validatorChain->addValidator($notEmptyValidator, true /* Always break on failure */);
- $validatorChain->addValidator($validatorRule[self::VALIDATOR_CHAIN]);
- }
-
- foreach ($field as $key => $value) {
- if ($validatorRule[self::ALLOW_EMPTY] && !$notEmptyValidator->isValid($value)) {
- // Field is empty AND it's allowed. Do nothing.
- continue;
- }
-
- if (!$validatorChain->isValid($value)) {
- if (isset($this->_invalidMessages[$validatorRule[self::RULE]])) {
- $collectedMessages = $this->_invalidMessages[$validatorRule[self::RULE]];
- } else {
- $collectedMessages = array();
- }
-
- foreach ($validatorChain->getMessages() as $messageKey => $message) {
- if (!isset($collectedMessages[$messageKey])) {
- $collectedMessages[$messageKey] = $message;
- } else {
- $collectedMessages[] = $message;
- }
- }
-
- $this->_invalidMessages[$validatorRule[self::RULE]] = $collectedMessages;
- if (isset($this->_invalidErrors[$validatorRule[self::RULE]])) {
- $this->_invalidErrors[$validatorRule[self::RULE]] = array_merge($this->_invalidErrors[$validatorRule[self::RULE]],
- $validatorChain->getErrors());
- } else {
- $this->_invalidErrors[$validatorRule[self::RULE]] = $validatorChain->getErrors();
- }
- unset($this->_validFields[$fieldName]);
- $failed = true;
- if ($validatorRule[self::BREAK_CHAIN]) {
- return;
- }
- }
- }
- if ($failed) {
- return;
- }
- }
-
- /**
- * If we got this far, the inputs for this rule pass validation.
- */
- foreach ((array) $validatorRule[self::FIELDS] as $field) {
- if (array_key_exists($field, $data)) {
- $this->_validFields[$field] = $data[$field];
- }
- }
- }
-
- /**
- * Check a validatorRule for the presence of a NotEmpty validator instance.
- * The purpose is to preserve things like a custom message, that may have been
- * set on the validator outside Zend_Filter_Input.
- * @param array $validatorRule
- * @return mixed false if none is found, Zend_Validate_NotEmpty instance if found
- */
- protected function _getNotEmptyValidatorInstance($validatorRule) {
- foreach ($validatorRule as $rule => $value) {
- if (is_object($value) and $value instanceof Zend_Validate_NotEmpty) {
- return $value;
- }
- }
-
- return false;
- }
-
- /**
- * @param mixed $classBaseName
- * @return Zend_Filter_Interface
- */
- protected function _getFilter($classBaseName)
- {
- return $this->_getFilterOrValidator(self::FILTER, $classBaseName);
- }
-
- /**
- * @param mixed $classBaseName
- * @return Zend_Validate_Interface
- */
- protected function _getValidator($classBaseName)
- {
- return $this->_getFilterOrValidator(self::VALIDATE, $classBaseName);
- }
-
- /**
- * @param string $type
- * @param mixed $classBaseName
- * @return Zend_Filter_Interface|Zend_Validate_Interface
- * @throws Zend_Filter_Exception
- */
- protected function _getFilterOrValidator($type, $classBaseName)
- {
- $args = array();
-
- if (is_array($classBaseName)) {
- $args = $classBaseName;
- $classBaseName = array_shift($args);
- }
-
- $interfaceName = 'Zend_' . ucfirst($type) . '_Interface';
- $className = $this->getPluginLoader($type)->load(ucfirst($classBaseName));
-
- $class = new ReflectionClass($className);
-
- if (!$class->implementsInterface($interfaceName)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("Class '$className' based on basename '$classBaseName' must implement the '$interfaceName' interface");
- }
-
- if ($class->hasMethod('__construct')) {
- $object = $class->newInstanceArgs($args);
- } else {
- $object = $class->newInstance();
- }
-
- return $object;
- }
-
-}
diff --git a/lib/zend/Zend/Filter/Int.php b/lib/zend/Zend/Filter/Int.php
deleted file mode 100644
index ee20702559e52..0000000000000
--- a/lib/zend/Zend/Filter/Int.php
+++ /dev/null
@@ -1,50 +0,0 @@
- null,
- 'date_format' => null,
- 'precision' => null
- );
-
- /**
- * Class constructor
- *
- * @param string|Zend_Locale $locale (Optional) Locale to set
- */
- public function __construct($options = null)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
-
- if (null !== $options) {
- $this->setOptions($options);
- }
- }
-
- /**
- * Returns the set options
- *
- * @return array
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Sets options to use
- *
- * @param array $options (Optional) Options to use
- * @return Zend_Filter_LocalizedToNormalized
- */
- public function setOptions(array $options = null)
- {
- $this->_options = $options + $this->_options;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Normalizes the given input
- *
- * @param string $value Value to normalized
- * @return string|array The normalized value
- */
- public function filter($value)
- {
- if (Zend_Locale_Format::isNumber($value, $this->_options)) {
- return Zend_Locale_Format::getNumber($value, $this->_options);
- } else if (($this->_options['date_format'] === null) && (strpos($value, ':') !== false)) {
- // Special case, no date format specified, detect time input
- return Zend_Locale_Format::getTime($value, $this->_options);
- } else if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) {
- // Detect date or time input
- return Zend_Locale_Format::getDate($value, $this->_options);
- }
-
- return $value;
- }
-}
diff --git a/lib/zend/Zend/Filter/NormalizedToLocalized.php b/lib/zend/Zend/Filter/NormalizedToLocalized.php
deleted file mode 100644
index 60dbb9e06574a..0000000000000
--- a/lib/zend/Zend/Filter/NormalizedToLocalized.php
+++ /dev/null
@@ -1,111 +0,0 @@
- null,
- 'date_format' => null,
- 'precision' => null
- );
-
- /**
- * Class constructor
- *
- * @param string|Zend_Locale $locale (Optional) Locale to set
- */
- public function __construct($options = null)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
-
- if (null !== $options) {
- $this->setOptions($options);
- }
- }
-
- /**
- * Returns the set options
- *
- * @return array
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Sets options to use
- *
- * @param array $options (Optional) Options to use
- * @return Zend_Filter_LocalizedToNormalized
- */
- public function setOptions(array $options = null)
- {
- $this->_options = $options + $this->_options;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Normalizes the given input
- *
- * @param string $value Value to normalized
- * @return string|array The normalized value
- */
- public function filter($value)
- {
- if (is_array($value)) {
- require_once 'Zend/Date.php';
- $date = new Zend_Date($value, $this->_options['locale']);
- return $date->toString($this->_options['date_format']);
- } else if ($this->_options['precision'] === 0) {
- return Zend_Locale_Format::toInteger($value, $this->_options);
- } else if ($this->_options['precision'] === null) {
- return Zend_Locale_Format::toFloat($value, $this->_options);
- }
-
- return Zend_Locale_Format::toNumber($value, $this->_options);
- }
-}
diff --git a/lib/zend/Zend/Filter/Null.php b/lib/zend/Zend/Filter/Null.php
deleted file mode 100644
index c798800416035..0000000000000
--- a/lib/zend/Zend/Filter/Null.php
+++ /dev/null
@@ -1,183 +0,0 @@
- 'boolean',
- self::INTEGER => 'integer',
- self::EMPTY_ARRAY => 'array',
- self::STRING => 'string',
- self::ZERO => 'zero',
- self::ALL => 'all'
- );
-
- /**
- * Internal type to detect
- *
- * @var integer
- */
- protected $_type = self::ALL;
-
- /**
- * Constructor
- *
- * @param string|array|Zend_Config $options OPTIONAL
- */
- public function __construct($options = null)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } else if (!is_array($options)) {
- $options = func_get_args();
- $temp = array();
- if (!empty($options)) {
- $temp = array_shift($options);
- }
- $options = $temp;
- } else if (is_array($options) && array_key_exists('type', $options)) {
- $options = $options['type'];
- }
-
- if (!empty($options)) {
- $this->setType($options);
- }
- }
-
- /**
- * Returns the set null types
- *
- * @return array
- */
- public function getType()
- {
- return $this->_type;
- }
-
- /**
- * Set the null types
- *
- * @param integer|array $type
- * @throws Zend_Filter_Exception
- * @return Zend_Filter_Null
- */
- public function setType($type = null)
- {
- if (is_array($type)) {
- $detected = 0;
- foreach($type as $value) {
- if (is_int($value)) {
- $detected += $value;
- } else if (in_array($value, $this->_constants)) {
- $detected += array_search($value, $this->_constants);
- }
- }
-
- $type = $detected;
- } else if (is_string($type)) {
- if (in_array($type, $this->_constants)) {
- $type = array_search($type, $this->_constants);
- }
- }
-
- if (!is_int($type) || ($type < 0) || ($type > self::ALL)) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('Unknown type');
- }
-
- $this->_type = $type;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns null representation of $value, if value is empty and matches
- * types that should be considered null.
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- $type = $this->getType();
-
- // STRING ZERO ('0')
- if ($type >= self::ZERO) {
- $type -= self::ZERO;
- if (is_string($value) && ($value == '0')) {
- return null;
- }
- }
-
- // STRING ('')
- if ($type >= self::STRING) {
- $type -= self::STRING;
- if (is_string($value) && ($value == '')) {
- return null;
- }
- }
-
- // EMPTY_ARRAY (array())
- if ($type >= self::EMPTY_ARRAY) {
- $type -= self::EMPTY_ARRAY;
- if (is_array($value) && ($value == array())) {
- return null;
- }
- }
-
- // INTEGER (0)
- if ($type >= self::INTEGER) {
- $type -= self::INTEGER;
- if (is_int($value) && ($value == 0)) {
- return null;
- }
- }
-
- // BOOLEAN (false)
- if ($type >= self::BOOLEAN) {
- $type -= self::BOOLEAN;
- if (is_bool($value) && ($value == false)) {
- return null;
- }
- }
-
- return $value;
- }
-}
diff --git a/lib/zend/Zend/Filter/PregReplace.php b/lib/zend/Zend/Filter/PregReplace.php
deleted file mode 100644
index 7100c3717d852..0000000000000
--- a/lib/zend/Zend/Filter/PregReplace.php
+++ /dev/null
@@ -1,174 +0,0 @@
- matching pattern
- * 'replace' => replace with this
- *
- * @param string|array $options
- * @return void
- */
- public function __construct($options = null)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } else if (!is_array($options)) {
- $options = func_get_args();
- $temp = array();
- if (!empty($options)) {
- $temp['match'] = array_shift($options);
- }
-
- if (!empty($options)) {
- $temp['replace'] = array_shift($options);
- }
-
- $options = $temp;
- }
-
- if (array_key_exists('match', $options)) {
- $this->setMatchPattern($options['match']);
- }
-
- if (array_key_exists('replace', $options)) {
- $this->setReplacement($options['replace']);
- }
- }
-
- /**
- * Set the match pattern for the regex being called within filter()
- *
- * @param mixed $match - same as the first argument of preg_replace
- * @return Zend_Filter_PregReplace
- */
- public function setMatchPattern($match)
- {
- $this->_matchPattern = $match;
- return $this;
- }
-
- /**
- * Get currently set match pattern
- *
- * @return string
- */
- public function getMatchPattern()
- {
- return $this->_matchPattern;
- }
-
- /**
- * Set the Replacement pattern/string for the preg_replace called in filter
- *
- * @param mixed $replacement - same as the second argument of preg_replace
- * @return Zend_Filter_PregReplace
- */
- public function setReplacement($replacement)
- {
- $this->_replacement = $replacement;
- return $this;
- }
-
- /**
- * Get currently set replacement value
- *
- * @return string
- */
- public function getReplacement()
- {
- return $this->_replacement;
- }
-
- /**
- * Perform regexp replacement as filter
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- if ($this->_matchPattern == null) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception(get_class($this) . ' does not have a valid MatchPattern set.');
- }
-
- return preg_replace($this->_matchPattern, $this->_replacement, $value);
- }
-
-}
diff --git a/lib/zend/Zend/Filter/RealPath.php b/lib/zend/Zend/Filter/RealPath.php
deleted file mode 100644
index 00881de5f5292..0000000000000
--- a/lib/zend/Zend/Filter/RealPath.php
+++ /dev/null
@@ -1,134 +0,0 @@
-setExists($options);
- }
-
- /**
- * Returns true if the filtered path must exist
- *
- * @return boolean
- */
- public function getExists()
- {
- return $this->_exists;
- }
-
- /**
- * Sets if the path has to exist
- * TRUE when the path must exist
- * FALSE when not existing paths can be given
- *
- * @param boolean|Zend_Config $exists Path must exist
- * @return Zend_Filter_RealPath
- */
- public function setExists($exists)
- {
- if ($exists instanceof Zend_Config) {
- $exists = $exists->toArray();
- }
-
- if (is_array($exists)) {
- if (isset($exists['exists'])) {
- $exists = (boolean) $exists['exists'];
- }
- }
-
- $this->_exists = (boolean) $exists;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns realpath($value)
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- $path = (string) $value;
- if ($this->_exists) {
- return realpath($path);
- }
-
- $realpath = @realpath($path);
- if ($realpath) {
- return $realpath;
- }
-
- $drive = '';
- if (substr(PHP_OS, 0, 3) == 'WIN') {
- $path = preg_replace('/[\\\\\/]/', DIRECTORY_SEPARATOR, $path);
- if (preg_match('/([a-zA-Z]\:)(.*)/', $path, $matches)) {
- list($fullMatch, $drive, $path) = $matches;
- } else {
- $cwd = getcwd();
- $drive = substr($cwd, 0, 2);
- if (substr($path, 0, 1) != DIRECTORY_SEPARATOR) {
- $path = substr($cwd, 3) . DIRECTORY_SEPARATOR . $path;
- }
- }
- } elseif (substr($path, 0, 1) != DIRECTORY_SEPARATOR) {
- $path = getcwd() . DIRECTORY_SEPARATOR . $path;
- }
-
- $stack = array();
- $parts = explode(DIRECTORY_SEPARATOR, $path);
- foreach ($parts as $dir) {
- if (strlen($dir) && $dir !== '.') {
- if ($dir == '..') {
- array_pop($stack);
- } else {
- array_push($stack, $dir);
- }
- }
- }
-
- return $drive . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $stack);
- }
-}
diff --git a/lib/zend/Zend/Filter/StringToLower.php b/lib/zend/Zend/Filter/StringToLower.php
deleted file mode 100644
index b208cfe77a189..0000000000000
--- a/lib/zend/Zend/Filter/StringToLower.php
+++ /dev/null
@@ -1,121 +0,0 @@
-toArray();
- } else if (!is_array($options)) {
- $options = func_get_args();
- $temp = array();
- if (!empty($options)) {
- $temp['encoding'] = array_shift($options);
- }
- $options = $temp;
- }
-
- if (!array_key_exists('encoding', $options) && function_exists('mb_internal_encoding')) {
- $options['encoding'] = mb_internal_encoding();
- }
-
- if (array_key_exists('encoding', $options)) {
- $this->setEncoding($options['encoding']);
- }
- }
-
- /**
- * Returns the set encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Set the input encoding for the given string
- *
- * @param string $encoding
- * @return Zend_Filter_StringToLower Provides a fluent interface
- * @throws Zend_Filter_Exception
- */
- public function setEncoding($encoding = null)
- {
- if ($encoding !== null) {
- if (!function_exists('mb_strtolower')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('mbstring is required for this feature');
- }
-
- $encoding = (string) $encoding;
- if (!in_array(strtolower($encoding), array_map('strtolower', mb_list_encodings()))) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The given encoding '$encoding' is not supported by mbstring");
- }
- }
-
- $this->_encoding = $encoding;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns the string $value, converting characters to lowercase as necessary
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- if ($this->_encoding !== null) {
- return mb_strtolower((string) $value, $this->_encoding);
- }
-
- return strtolower((string) $value);
- }
-}
diff --git a/lib/zend/Zend/Filter/StringToUpper.php b/lib/zend/Zend/Filter/StringToUpper.php
deleted file mode 100644
index 8fe362055f2a1..0000000000000
--- a/lib/zend/Zend/Filter/StringToUpper.php
+++ /dev/null
@@ -1,121 +0,0 @@
-toArray();
- } else if (!is_array($options)) {
- $options = func_get_args();
- $temp = array();
- if (!empty($options)) {
- $temp['encoding'] = array_shift($options);
- }
- $options = $temp;
- }
-
- if (!array_key_exists('encoding', $options) && function_exists('mb_internal_encoding')) {
- $options['encoding'] = mb_internal_encoding();
- }
-
- if (array_key_exists('encoding', $options)) {
- $this->setEncoding($options['encoding']);
- }
- }
-
- /**
- * Returns the set encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Set the input encoding for the given string
- *
- * @param string $encoding
- * @return Zend_Filter_StringToUpper Provides a fluent interface
- * @throws Zend_Filter_Exception
- */
- public function setEncoding($encoding = null)
- {
- if ($encoding !== null) {
- if (!function_exists('mb_strtoupper')) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception('mbstring is required for this feature');
- }
-
- $encoding = (string) $encoding;
- if (!in_array(strtolower($encoding), array_map('strtolower', mb_list_encodings()))) {
- require_once 'Zend/Filter/Exception.php';
- throw new Zend_Filter_Exception("The given encoding '$encoding' is not supported by mbstring");
- }
- }
-
- $this->_encoding = $encoding;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns the string $value, converting characters to uppercase as necessary
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- if ($this->_encoding) {
- return mb_strtoupper((string) $value, $this->_encoding);
- }
-
- return strtoupper((string) $value);
- }
-}
diff --git a/lib/zend/Zend/Filter/StringTrim.php b/lib/zend/Zend/Filter/StringTrim.php
deleted file mode 100644
index 4f86d89e2c0cd..0000000000000
--- a/lib/zend/Zend/Filter/StringTrim.php
+++ /dev/null
@@ -1,124 +0,0 @@
-toArray();
- } else if (!is_array($options)) {
- $options = func_get_args();
- $temp['charlist'] = array_shift($options);
- $options = $temp;
- }
-
- if (array_key_exists('charlist', $options)) {
- $this->setCharList($options['charlist']);
- }
- }
-
- /**
- * Returns the charList option
- *
- * @return string|null
- */
- public function getCharList()
- {
- return $this->_charList;
- }
-
- /**
- * Sets the charList option
- *
- * @param string|null $charList
- * @return Zend_Filter_StringTrim Provides a fluent interface
- */
- public function setCharList($charList)
- {
- $this->_charList = $charList;
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * Returns the string $value with characters stripped from the beginning and end
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- if (null === $this->_charList) {
- return $this->_unicodeTrim((string) $value);
- } else {
- return $this->_unicodeTrim((string) $value, $this->_charList);
- }
- }
-
- /**
- * Unicode aware trim method
- * Fixes a PHP problem
- *
- * @param string $value
- * @param string $charlist
- * @return string
- */
- protected function _unicodeTrim($value, $charlist = '\\\\s')
- {
- $chars = preg_replace(
- array( '/[\^\-\]\\\]/S', '/\\\{4}/S', '/\//'),
- array( '\\\\\\0', '\\', '\/' ),
- $charlist
- );
-
- $pattern = '^[' . $chars . ']*|[' . $chars . ']*$';
- return preg_replace("/$pattern/sSD", '', $value);
- }
-}
diff --git a/lib/zend/Zend/Filter/StripNewlines.php b/lib/zend/Zend/Filter/StripNewlines.php
deleted file mode 100644
index 667c6aae24029..0000000000000
--- a/lib/zend/Zend/Filter/StripNewlines.php
+++ /dev/null
@@ -1,48 +0,0 @@
- Tags which are allowed
- * 'allowAttribs' => Attributes which are allowed
- * 'allowComments' => Are comments allowed ?
- *
- * @param string|array|Zend_Config $options
- * @return void
- */
- public function __construct($options = null)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } else if ((!is_array($options)) || (is_array($options) && !array_key_exists('allowTags', $options) &&
- !array_key_exists('allowAttribs', $options) && !array_key_exists('allowComments', $options))) {
- $options = func_get_args();
- $temp['allowTags'] = array_shift($options);
- if (!empty($options)) {
- $temp['allowAttribs'] = array_shift($options);
- }
-
- if (!empty($options)) {
- $temp['allowComments'] = array_shift($options);
- }
-
- $options = $temp;
- }
-
- if (array_key_exists('allowTags', $options)) {
- $this->setTagsAllowed($options['allowTags']);
- }
-
- if (array_key_exists('allowAttribs', $options)) {
- $this->setAttributesAllowed($options['allowAttribs']);
- }
-
- if (array_key_exists('allowComments', $options)) {
- $this->setCommentsAllowed($options['allowComments']);
- }
- }
-
- /**
- * Returns the commentsAllowed option
- *
- * This setting is now deprecated and ignored internally.
- *
- * @deprecated
- * @return bool
- */
- public function getCommentsAllowed()
- {
- return $this->commentsAllowed;
- }
-
- /**
- * Sets the commentsAllowed option
- *
- * This setting is now deprecated and ignored internally.
- *
- * @deprecated
- * @param boolean $commentsAllowed
- * @return Zend_Filter_StripTags Provides a fluent interface
- */
- public function setCommentsAllowed($commentsAllowed)
- {
- $this->commentsAllowed = (boolean) $commentsAllowed;
- return $this;
- }
-
- /**
- * Returns the tagsAllowed option
- *
- * @return array
- */
- public function getTagsAllowed()
- {
- return $this->_tagsAllowed;
- }
-
- /**
- * Sets the tagsAllowed option
- *
- * @param array|string $tagsAllowed
- * @return Zend_Filter_StripTags Provides a fluent interface
- */
- public function setTagsAllowed($tagsAllowed)
- {
- if (!is_array($tagsAllowed)) {
- $tagsAllowed = array($tagsAllowed);
- }
-
- foreach ($tagsAllowed as $index => $element) {
- // If the tag was provided without attributes
- if (is_int($index) && is_string($element)) {
- // Canonicalize the tag name
- $tagName = strtolower($element);
- // Store the tag as allowed with no attributes
- $this->_tagsAllowed[$tagName] = array();
- }
- // Otherwise, if a tag was provided with attributes
- else if (is_string($index) && (is_array($element) || is_string($element))) {
- // Canonicalize the tag name
- $tagName = strtolower($index);
- // Canonicalize the attributes
- if (is_string($element)) {
- $element = array($element);
- }
- // Store the tag as allowed with the provided attributes
- $this->_tagsAllowed[$tagName] = array();
- foreach ($element as $attribute) {
- if (is_string($attribute)) {
- // Canonicalize the attribute name
- $attributeName = strtolower($attribute);
- $this->_tagsAllowed[$tagName][$attributeName] = null;
- }
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Returns the attributesAllowed option
- *
- * @return array
- */
- public function getAttributesAllowed()
- {
- return $this->_attributesAllowed;
- }
-
- /**
- * Sets the attributesAllowed option
- *
- * @param array|string $attributesAllowed
- * @return Zend_Filter_StripTags Provides a fluent interface
- */
- public function setAttributesAllowed($attributesAllowed)
- {
- if (!is_array($attributesAllowed)) {
- $attributesAllowed = array($attributesAllowed);
- }
-
- // Store each attribute as allowed
- foreach ($attributesAllowed as $attribute) {
- if (is_string($attribute)) {
- // Canonicalize the attribute name
- $attributeName = strtolower($attribute);
- $this->_attributesAllowed[$attributeName] = null;
- }
- }
-
- return $this;
- }
-
- /**
- * Defined by Zend_Filter_Interface
- *
- * @todo improve docblock descriptions
- *
- * @param string $value
- * @return string
- */
- public function filter($value)
- {
- $value = (string) $value;
-
- // Strip HTML comments first
- while (strpos($value, '' . $link . '';
- }
-
- return $link;
- }
-
- /**
- * Render link elements as string
- *
- * @param string|int $indent
- * @return string
- */
- public function toString($indent = null)
- {
- $indent = (null !== $indent)
- ? $this->getWhitespace($indent)
- : $this->getIndent();
-
- $items = array();
- $this->getContainer()->ksort();
- foreach ($this as $item) {
- $items[] = $this->itemToString($item);
- }
-
- return $indent . implode($this->_escape($this->getSeparator()) . $indent, $items);
- }
-
- /**
- * Create data item for stack
- *
- * @param array $attributes
- * @return stdClass
- */
- public function createData(array $attributes)
- {
- $data = (object) $attributes;
- return $data;
- }
-
- /**
- * Create item for stylesheet link item
- *
- * @param array $args
- * @return stdClass|false Returns fals if stylesheet is a duplicate
- */
- public function createDataStylesheet(array $args)
- {
- $rel = 'stylesheet';
- $type = 'text/css';
- $media = 'screen';
- $conditionalStylesheet = false;
- $href = array_shift($args);
-
- if ($this->_isDuplicateStylesheet($href)) {
- return false;
- }
-
- if (0 < count($args)) {
- $media = array_shift($args);
- if(is_array($media)) {
- $media = implode(',', $media);
- } else {
- $media = (string) $media;
- }
- }
- if (0 < count($args)) {
- $conditionalStylesheet = array_shift($args);
- if(!empty($conditionalStylesheet) && is_string($conditionalStylesheet)) {
- $conditionalStylesheet = (string) $conditionalStylesheet;
- } else {
- $conditionalStylesheet = null;
- }
- }
-
- if(0 < count($args) && is_array($args[0])) {
- $extras = array_shift($args);
- $extras = (array) $extras;
- }
-
- $attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet', 'extras');
- return $this->createData($this->_applyExtras($attributes));
- }
-
- /**
- * Is the linked stylesheet a duplicate?
- *
- * @param string $uri
- * @return bool
- */
- protected function _isDuplicateStylesheet($uri)
- {
- foreach ($this->getContainer() as $item) {
- if (($item->rel == 'stylesheet') && ($item->href == $uri)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Create item for alternate link item
- *
- * @param array $args
- * @return stdClass
- */
- public function createDataAlternate(array $args)
- {
- if (3 > count($args)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf('Alternate tags require 3 arguments; %s provided', count($args)));
- $e->setView($this->view);
- throw $e;
- }
-
- $rel = 'alternate';
- $href = array_shift($args);
- $type = array_shift($args);
- $title = array_shift($args);
-
- if(0 < count($args) && is_array($args[0])) {
- $extras = array_shift($args);
- $extras = (array) $extras;
-
- if(isset($extras['media']) && is_array($extras['media'])) {
- $extras['media'] = implode(',', $extras['media']);
- }
- }
-
- $href = (string) $href;
- $type = (string) $type;
- $title = (string) $title;
-
- $attributes = compact('rel', 'href', 'type', 'title', 'extras');
- return $this->createData($this->_applyExtras($attributes));
- }
-
- /**
- * Apply any overrides specified in the 'extras' array
- * @param array $attributes
- * @return array
- */
- protected function _applyExtras($attributes)
- {
- if (isset($attributes['extras'])) {
- foreach ($attributes['extras'] as $eKey=>$eVal) {
- if (isset($attributes[$eKey])) {
- $attributes[$eKey] = $eVal;
- unset($attributes['extras'][$eKey]);
- }
- }
- }
- return $attributes;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HeadMeta.php b/lib/zend/Zend/View/Helper/HeadMeta.php
deleted file mode 100644
index de58edd5dcc0e..0000000000000
--- a/lib/zend/Zend/View/Helper/HeadMeta.php
+++ /dev/null
@@ -1,449 +0,0 @@
-setSeparator(PHP_EOL);
- }
-
- /**
- * Retrieve object instance; optionally add meta tag
- *
- * @param string $content
- * @param string $keyValue
- * @param string $keyType
- * @param array $modifiers
- * @param string $placement
- * @return Zend_View_Helper_HeadMeta
- */
- public function headMeta($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
- {
- if ((null !== $content) && (null !== $keyValue)) {
- $item = $this->createData($keyType, $keyValue, $content, $modifiers);
- $action = strtolower($placement);
- switch ($action) {
- case 'append':
- case 'prepend':
- case 'set':
- $this->$action($item);
- break;
- default:
- $this->append($item);
- break;
- }
- }
-
- return $this;
- }
-
- protected function _normalizeType($type)
- {
- switch ($type) {
- case 'Name':
- return 'name';
- case 'HttpEquiv':
- return 'http-equiv';
- case 'Property':
- return 'property';
- default:
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf('Invalid type "%s" passed to _normalizeType', $type));
- $e->setView($this->view);
- throw $e;
- }
- }
-
- /**
- * Overload method access
- *
- * Allows the following 'virtual' methods:
- * - appendName($keyValue, $content, $modifiers = array())
- * - offsetGetName($index, $keyValue, $content, $modifers = array())
- * - prependName($keyValue, $content, $modifiers = array())
- * - setName($keyValue, $content, $modifiers = array())
- * - appendHttpEquiv($keyValue, $content, $modifiers = array())
- * - offsetGetHttpEquiv($index, $keyValue, $content, $modifers = array())
- * - prependHttpEquiv($keyValue, $content, $modifiers = array())
- * - setHttpEquiv($keyValue, $content, $modifiers = array())
- * - appendProperty($keyValue, $content, $modifiers = array())
- * - offsetGetProperty($index, $keyValue, $content, $modifiers = array())
- * - prependProperty($keyValue, $content, $modifiers = array())
- * - setProperty($keyValue, $content, $modifiers = array())
- *
- * @param string $method
- * @param array $args
- * @return Zend_View_Helper_HeadMeta
- */
- public function __call($method, $args)
- {
- if (preg_match('/^(?Pset|(pre|ap)pend|offsetSet)(?PName|HttpEquiv|Property)$/', $method, $matches)) {
- $action = $matches['action'];
- $type = $this->_normalizeType($matches['type']);
- $argc = count($args);
- $index = null;
-
- if ('offsetSet' == $action) {
- if (0 < $argc) {
- $index = array_shift($args);
- --$argc;
- }
- }
-
- if (2 > $argc) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Too few arguments provided; requires key value, and content');
- $e->setView($this->view);
- throw $e;
- }
-
- if (3 > $argc) {
- $args[] = array();
- }
-
- $item = $this->createData($type, $args[0], $args[1], $args[2]);
-
- if ('offsetSet' == $action) {
- return $this->offsetSet($index, $item);
- }
-
- $this->$action($item);
- return $this;
- }
-
- return parent::__call($method, $args);
- }
-
- /**
- * Create an HTML5-style meta charset tag. Something like
- *
- * Not valid in a non-HTML5 doctype
- *
- * @param string $charset
- * @return Zend_View_Helper_HeadMeta Provides a fluent interface
- */
- public function setCharset($charset)
- {
- $item = new stdClass;
- $item->type = 'charset';
- $item->charset = $charset;
- $item->content = null;
- $item->modifiers = array();
- $this->set($item);
- return $this;
- }
-
- /**
- * Determine if item is valid
- *
- * @param mixed $item
- * @return boolean
- */
- protected function _isValid($item)
- {
- if ((!$item instanceof stdClass)
- || !isset($item->type)
- || !isset($item->modifiers))
- {
- return false;
- }
-
- $isHtml5 = is_null($this->view) ? false : $this->view->doctype()->isHtml5();
-
- if (!isset($item->content)
- && (! $isHtml5 || (! $isHtml5 && $item->type !== 'charset'))) {
- return false;
- }
-
- // is only supported with doctype RDFa
- if ( !is_null($this->view) && !$this->view->doctype()->isRdfa()
- && $item->type === 'property') {
- return false;
- }
-
- return true;
- }
-
- /**
- * Append
- *
- * @param string $value
- * @return void
- * @throws Zend_View_Exception
- */
- public function append($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to append; please use appendMeta()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->append($value);
- }
-
- /**
- * OffsetSet
- *
- * @param string|int $index
- * @param string $value
- * @return void
- * @throws Zend_View_Exception
- */
- public function offsetSet($index, $value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetName() or offsetSetHttpEquiv()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->offsetSet($index, $value);
- }
-
- /**
- * OffsetUnset
- *
- * @param string|int $index
- * @return void
- * @throws Zend_View_Exception
- */
- public function offsetUnset($index)
- {
- if (!in_array($index, $this->getContainer()->getKeys())) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid index passed to offsetUnset()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->offsetUnset($index);
- }
-
- /**
- * Prepend
- *
- * @param string $value
- * @return void
- * @throws Zend_View_Exception
- */
- public function prepend($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to prepend; please use prependMeta()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->prepend($value);
- }
-
- /**
- * Set
- *
- * @param string $value
- * @return void
- * @throws Zend_View_Exception
- */
- public function set($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to set; please use setMeta()');
- $e->setView($this->view);
- throw $e;
- }
-
- $container = $this->getContainer();
- foreach ($container->getArrayCopy() as $index => $item) {
- if ($item->type == $value->type && $item->{$item->type} == $value->{$value->type}) {
- $this->offsetUnset($index);
- }
- }
-
- return $this->append($value);
- }
-
- /**
- * Build meta HTML string
- *
- * @param string $type
- * @param string $typeValue
- * @param string $content
- * @param array $modifiers
- * @return string
- */
- public function itemToString(stdClass $item)
- {
- if (!in_array($item->type, $this->_typeKeys)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf('Invalid type "%s" provided for meta', $item->type));
- $e->setView($this->view);
- throw $e;
- }
- $type = $item->type;
-
- $modifiersString = '';
- foreach ($item->modifiers as $key => $value) {
- if (!is_null($this->view) && $this->view->doctype()->isHtml5()
- && $key == 'scheme') {
- require_once 'Zend/View/Exception.php';
- throw new Zend_View_Exception('Invalid modifier '
- . '"scheme" provided; not supported by HTML5');
- }
- if (!in_array($key, $this->_modifierKeys)) {
- continue;
- }
- $modifiersString .= $key . '="' . $this->_escape($value) . '" ';
- }
-
- if ($this->view instanceof Zend_View_Abstract) {
- if ($this->view->doctype()->isHtml5()
- && $type == 'charset') {
- $tpl = ($this->view->doctype()->isXhtml())
- ? ' '
- : ' ';
- } elseif ($this->view->doctype()->isXhtml()) {
- $tpl = ' ';
- } else {
- $tpl = ' ';
- }
- } else {
- $tpl = ' ';
- }
-
- $meta = sprintf(
- $tpl,
- $type,
- $this->_escape($item->$type),
- $this->_escape($item->content),
- $modifiersString
- );
-
- if (isset($item->modifiers['conditional'])
- && !empty($item->modifiers['conditional'])
- && is_string($item->modifiers['conditional']))
- {
- if (str_replace(' ', '', $item->modifiers['conditional']) === '!IE') {
- $meta = '' . $meta . '';
- }
-
- return $meta;
- }
-
- /**
- * Render placeholder as string
- *
- * @param string|int $indent
- * @return string
- */
- public function toString($indent = null)
- {
- $indent = (null !== $indent)
- ? $this->getWhitespace($indent)
- : $this->getIndent();
-
- $items = array();
- $this->getContainer()->ksort();
- try {
- foreach ($this as $item) {
- $items[] = $this->itemToString($item);
- }
- } catch (Zend_View_Exception $e) {
- trigger_error($e->getMessage(), E_USER_WARNING);
- return '';
- }
- return $indent . implode($this->_escape($this->getSeparator()) . $indent, $items);
- }
-
- /**
- * Create data item for inserting into stack
- *
- * @param string $type
- * @param string $typeValue
- * @param string $content
- * @param array $modifiers
- * @return stdClass
- */
- public function createData($type, $typeValue, $content, array $modifiers)
- {
- $data = new stdClass;
- $data->type = $type;
- $data->$type = $typeValue;
- $data->content = $content;
- $data->modifiers = $modifiers;
- return $data;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HeadScript.php b/lib/zend/Zend/View/Helper/HeadScript.php
deleted file mode 100644
index 062bed1b0cd1a..0000000000000
--- a/lib/zend/Zend/View/Helper/HeadScript.php
+++ /dev/null
@@ -1,520 +0,0 @@
-setSeparator(PHP_EOL);
- }
-
- /**
- * Return headScript object
- *
- * Returns headScript helper object; optionally, allows specifying a script
- * or script file to include.
- *
- * @param string $mode Script or file
- * @param string $spec Script/url
- * @param string $placement Append, prepend, or set
- * @param array $attrs Array of script attributes
- * @param string $type Script type and/or array of script attributes
- * @return Zend_View_Helper_HeadScript
- */
- public function headScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
- {
- if ((null !== $spec) && is_string($spec)) {
- $action = ucfirst(strtolower($mode));
- $placement = strtolower($placement);
- switch ($placement) {
- case 'set':
- case 'prepend':
- case 'append':
- $action = $placement . $action;
- break;
- default:
- $action = 'append' . $action;
- break;
- }
- $this->$action($spec, $type, $attrs);
- }
-
- return $this;
- }
-
- /**
- * Start capture action
- *
- * @param mixed $captureType
- * @param string $typeOrAttrs
- * @return void
- */
- public function captureStart($captureType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $type = 'text/javascript', $attrs = array())
- {
- if ($this->_captureLock) {
- require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
- $e = new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headScript captures');
- $e->setView($this->view);
- throw $e;
- }
-
- $this->_captureLock = true;
- $this->_captureType = $captureType;
- $this->_captureScriptType = $type;
- $this->_captureScriptAttrs = $attrs;
- ob_start();
- }
-
- /**
- * End capture action and store
- *
- * @return void
- */
- public function captureEnd()
- {
- $content = ob_get_clean();
- $type = $this->_captureScriptType;
- $attrs = $this->_captureScriptAttrs;
- $this->_captureScriptType = null;
- $this->_captureScriptAttrs = null;
- $this->_captureLock = false;
-
- switch ($this->_captureType) {
- case Zend_View_Helper_Placeholder_Container_Abstract::SET:
- case Zend_View_Helper_Placeholder_Container_Abstract::PREPEND:
- case Zend_View_Helper_Placeholder_Container_Abstract::APPEND:
- $action = strtolower($this->_captureType) . 'Script';
- break;
- default:
- $action = 'appendScript';
- break;
- }
- $this->$action($content, $type, $attrs);
- }
-
- /**
- * Overload method access
- *
- * Allows the following method calls:
- * - appendFile($src, $type = 'text/javascript', $attrs = array())
- * - offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array())
- * - prependFile($src, $type = 'text/javascript', $attrs = array())
- * - setFile($src, $type = 'text/javascript', $attrs = array())
- * - appendScript($script, $type = 'text/javascript', $attrs = array())
- * - offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array())
- * - prependScript($script, $type = 'text/javascript', $attrs = array())
- * - setScript($script, $type = 'text/javascript', $attrs = array())
- *
- * @param string $method
- * @param array $args
- * @return Zend_View_Helper_HeadScript
- * @throws Zend_View_Exception if too few arguments or invalid method
- */
- public function __call($method, $args)
- {
- if (preg_match('/^(?Pset|(ap|pre)pend|offsetSet)(?PFile|Script)$/', $method, $matches)) {
- if (1 > count($args)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf('Method "%s" requires at least one argument', $method));
- $e->setView($this->view);
- throw $e;
- }
-
- $action = $matches['action'];
- $mode = strtolower($matches['mode']);
- $type = 'text/javascript';
- $attrs = array();
-
- if ('offsetSet' == $action) {
- $index = array_shift($args);
- if (1 > count($args)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf('Method "%s" requires at least two arguments, an index and source', $method));
- $e->setView($this->view);
- throw $e;
- }
- }
-
- $content = $args[0];
-
- if (isset($args[1])) {
- $type = (string) $args[1];
- }
- if (isset($args[2])) {
- $attrs = (array) $args[2];
- }
-
- switch ($mode) {
- case 'script':
- $item = $this->createData($type, $attrs, $content);
- if ('offsetSet' == $action) {
- $this->offsetSet($index, $item);
- } else {
- $this->$action($item);
- }
- break;
- case 'file':
- default:
- if (!$this->_isDuplicate($content) || $action=='set') {
- $attrs['src'] = $content;
- $item = $this->createData($type, $attrs);
- if ('offsetSet' == $action) {
- $this->offsetSet($index, $item);
- } else {
- $this->$action($item);
- }
- }
- break;
- }
-
- return $this;
- }
-
- return parent::__call($method, $args);
- }
-
- /**
- * Is the file specified a duplicate?
- *
- * @param string $file
- * @return bool
- */
- protected function _isDuplicate($file)
- {
- foreach ($this->getContainer() as $item) {
- if (($item->source === null)
- && array_key_exists('src', $item->attributes)
- && ($file == $item->attributes['src']))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Is the script provided valid?
- *
- * @param mixed $value
- * @param string $method
- * @return bool
- */
- protected function _isValid($value)
- {
- if ((!$value instanceof stdClass)
- || !isset($value->type)
- || (!isset($value->source) && !isset($value->attributes)))
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Override append
- *
- * @param string $value
- * @return void
- */
- public function append($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid argument passed to append(); please use one of the helper methods, appendScript() or appendFile()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->append($value);
- }
-
- /**
- * Override prepend
- *
- * @param string $value
- * @return void
- */
- public function prepend($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid argument passed to prepend(); please use one of the helper methods, prependScript() or prependFile()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->prepend($value);
- }
-
- /**
- * Override set
- *
- * @param string $value
- * @return void
- */
- public function set($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid argument passed to set(); please use one of the helper methods, setScript() or setFile()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->set($value);
- }
-
- /**
- * Override offsetSet
- *
- * @param string|int $index
- * @param mixed $value
- * @return void
- */
- public function offsetSet($index, $value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->offsetSet($index, $value);
- }
-
- /**
- * Set flag indicating if arbitrary attributes are allowed
- *
- * @param bool $flag
- * @return Zend_View_Helper_HeadScript
- */
- public function setAllowArbitraryAttributes($flag)
- {
- $this->_arbitraryAttributes = (bool) $flag;
- return $this;
- }
-
- /**
- * Are arbitrary attributes allowed?
- *
- * @return bool
- */
- public function arbitraryAttributesAllowed()
- {
- return $this->_arbitraryAttributes;
- }
-
- /**
- * Create script HTML
- *
- * @param string $type
- * @param array $attributes
- * @param string $content
- * @param string|int $indent
- * @return string
- */
- public function itemToString($item, $indent, $escapeStart, $escapeEnd)
- {
- $attrString = '';
- if (!empty($item->attributes)) {
- foreach ($item->attributes as $key => $value) {
- if ((!$this->arbitraryAttributesAllowed() && !in_array($key, $this->_optionalAttributes))
- || in_array($key, array('conditional', 'noescape')))
- {
- continue;
- }
- if ('defer' == $key) {
- $value = 'defer';
- }
- $attrString .= sprintf(' %s="%s"', $key, ($this->_autoEscape) ? $this->_escape($value) : $value);
- }
- }
-
- $addScriptEscape = !(isset($item->attributes['noescape']) && filter_var($item->attributes['noescape'], FILTER_VALIDATE_BOOLEAN));
-
- $type = ($this->_autoEscape) ? $this->_escape($item->type) : $item->type;
- $html = '';
-
- if (isset($item->attributes['conditional'])
- && !empty($item->attributes['conditional'])
- && is_string($item->attributes['conditional']))
- {
- // inner wrap with comment end and start if !IE
- if (str_replace(' ', '', $item->attributes['conditional']) === '!IE') {
- $html = '' . $html . '';
- } else {
- $html = $indent . $html;
- }
-
- return $html;
- }
-
- /**
- * Retrieve string representation
- *
- * @param string|int $indent
- * @return string
- */
- public function toString($indent = null)
- {
- $indent = (null !== $indent)
- ? $this->getWhitespace($indent)
- : $this->getIndent();
-
- if ($this->view) {
- $useCdata = $this->view->doctype()->isXhtml() ? true : false;
- } else {
- $useCdata = $this->useCdata ? true : false;
- }
- $escapeStart = ($useCdata) ? '//' : '//-->';
-
- $items = array();
- $this->getContainer()->ksort();
- foreach ($this as $item) {
- if (!$this->_isValid($item)) {
- continue;
- }
-
- $items[] = $this->itemToString($item, $indent, $escapeStart, $escapeEnd);
- }
-
- $return = implode($this->getSeparator(), $items);
- return $return;
- }
-
- /**
- * Create data item containing all necessary components of script
- *
- * @param string $type
- * @param array $attributes
- * @param string $content
- * @return stdClass
- */
- public function createData($type, array $attributes, $content = null)
- {
- $data = new stdClass();
- $data->type = $type;
- $data->attributes = $attributes;
- $data->source = $content;
- return $data;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HeadStyle.php b/lib/zend/Zend/View/Helper/HeadStyle.php
deleted file mode 100644
index fc571bc9e024d..0000000000000
--- a/lib/zend/Zend/View/Helper/HeadStyle.php
+++ /dev/null
@@ -1,433 +0,0 @@
-setSeparator(PHP_EOL);
- }
-
- /**
- * Return headStyle object
- *
- * Returns headStyle helper object; optionally, allows specifying
- *
- * @param string $content Stylesheet contents
- * @param string $placement Append, prepend, or set
- * @param string|array $attributes Optional attributes to utilize
- * @return Zend_View_Helper_HeadStyle
- */
- public function headStyle($content = null, $placement = 'APPEND', $attributes = array())
- {
- if ((null !== $content) && is_string($content)) {
- switch (strtoupper($placement)) {
- case 'SET':
- $action = 'setStyle';
- break;
- case 'PREPEND':
- $action = 'prependStyle';
- break;
- case 'APPEND':
- default:
- $action = 'appendStyle';
- break;
- }
- $this->$action($content, $attributes);
- }
-
- return $this;
- }
-
- /**
- * Overload method calls
- *
- * Allows the following method calls:
- * - appendStyle($content, $attributes = array())
- * - offsetSetStyle($index, $content, $attributes = array())
- * - prependStyle($content, $attributes = array())
- * - setStyle($content, $attributes = array())
- *
- * @param string $method
- * @param array $args
- * @return void
- * @throws Zend_View_Exception When no $content provided or invalid method
- */
- public function __call($method, $args)
- {
- if (preg_match('/^(?Pset|(ap|pre)pend|offsetSet)(Style)$/', $method, $matches)) {
- $index = null;
- $argc = count($args);
- $action = $matches['action'];
-
- if ('offsetSet' == $action) {
- if (0 < $argc) {
- $index = array_shift($args);
- --$argc;
- }
- }
-
- if (1 > $argc) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf('Method "%s" requires minimally content for the stylesheet', $method));
- $e->setView($this->view);
- throw $e;
- }
-
- $content = $args[0];
- $attrs = array();
- if (isset($args[1])) {
- $attrs = (array) $args[1];
- }
-
- $item = $this->createData($content, $attrs);
-
- if ('offsetSet' == $action) {
- $this->offsetSet($index, $item);
- } else {
- $this->$action($item);
- }
-
- return $this;
- }
-
- return parent::__call($method, $args);
- }
-
- /**
- * Determine if a value is a valid style tag
- *
- * @param mixed $value
- * @param string $method
- * @return boolean
- */
- protected function _isValid($value)
- {
- if ((!$value instanceof stdClass)
- || !isset($value->content)
- || !isset($value->attributes))
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Override append to enforce style creation
- *
- * @param mixed $value
- * @return void
- */
- public function append($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to append; please use appendStyle()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->append($value);
- }
-
- /**
- * Override offsetSet to enforce style creation
- *
- * @param string|int $index
- * @param mixed $value
- * @return void
- */
- public function offsetSet($index, $value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetStyle()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->offsetSet($index, $value);
- }
-
- /**
- * Override prepend to enforce style creation
- *
- * @param mixed $value
- * @return void
- */
- public function prepend($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to prepend; please use prependStyle()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->prepend($value);
- }
-
- /**
- * Override set to enforce style creation
- *
- * @param mixed $value
- * @return void
- */
- public function set($value)
- {
- if (!$this->_isValid($value)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Invalid value passed to set; please use setStyle()');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->getContainer()->set($value);
- }
-
- /**
- * Start capture action
- *
- * @param mixed $captureType
- * @param string $typeOrAttrs
- * @return void
- */
- public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $attrs = null)
- {
- if ($this->_captureLock) {
- require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
- $e = new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headStyle captures');
- $e->setView($this->view);
- throw $e;
- }
-
- $this->_captureLock = true;
- $this->_captureAttrs = $attrs;
- $this->_captureType = $type;
- ob_start();
- }
-
- /**
- * End capture action and store
- *
- * @return void
- */
- public function captureEnd()
- {
- $content = ob_get_clean();
- $attrs = $this->_captureAttrs;
- $this->_captureAttrs = null;
- $this->_captureLock = false;
-
- switch ($this->_captureType) {
- case Zend_View_Helper_Placeholder_Container_Abstract::SET:
- $this->setStyle($content, $attrs);
- break;
- case Zend_View_Helper_Placeholder_Container_Abstract::PREPEND:
- $this->prependStyle($content, $attrs);
- break;
- case Zend_View_Helper_Placeholder_Container_Abstract::APPEND:
- default:
- $this->appendStyle($content, $attrs);
- break;
- }
- }
-
- /**
- * Convert content and attributes into valid style tag
- *
- * @param stdClass $item Item to render
- * @param string $indent Indentation to use
- * @return string
- */
- public function itemToString(stdClass $item, $indent)
- {
- $attrString = '';
- if (!empty($item->attributes)) {
- $enc = 'UTF-8';
- if ($this->view instanceof Zend_View_Interface
- && method_exists($this->view, 'getEncoding')
- ) {
- $enc = $this->view->getEncoding();
- }
- foreach ($item->attributes as $key => $value) {
- if (!in_array($key, $this->_optionalAttributes)) {
- continue;
- }
- if ('media' == $key) {
- if(false === strpos($value, ',')) {
- if (!in_array($value, $this->_mediaTypes)) {
- continue;
- }
- } else {
- $media_types = explode(',', $value);
- $value = '';
- foreach($media_types as $type) {
- $type = trim($type);
- if (!in_array($type, $this->_mediaTypes)) {
- continue;
- }
- $value .= $type .',';
- }
- $value = substr($value, 0, -1);
- }
- }
- $attrString .= sprintf(' %s="%s"', $key, htmlspecialchars($value, ENT_COMPAT, $enc));
- }
- }
-
- $escapeStart = $indent . ''. PHP_EOL;
- if (isset($item->attributes['conditional'])
- && !empty($item->attributes['conditional'])
- && is_string($item->attributes['conditional'])
- ) {
- $escapeStart = null;
- $escapeEnd = null;
- }
-
- $html = '';
-
- if (null == $escapeStart && null == $escapeEnd) {
- if (str_replace(' ', '', $item->attributes['conditional']) === '!IE') {
- $html = '' . $html . '';
- }
-
- return $html;
- }
-
- /**
- * Create string representation of placeholder
- *
- * @param string|int $indent
- * @return string
- */
- public function toString($indent = null)
- {
- $indent = (null !== $indent)
- ? $this->getWhitespace($indent)
- : $this->getIndent();
-
- $items = array();
- $this->getContainer()->ksort();
- foreach ($this as $item) {
- if (!$this->_isValid($item)) {
- continue;
- }
- $items[] = $this->itemToString($item, $indent);
- }
-
- $return = $indent . implode($this->getSeparator() . $indent, $items);
- $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return);
- return $return;
- }
-
- /**
- * Create data item for use in stack
- *
- * @param string $content
- * @param array $attributes
- * @return stdClass
- */
- public function createData($content, array $attributes)
- {
- if (!isset($attributes['media'])) {
- $attributes['media'] = 'screen';
- } else if(is_array($attributes['media'])) {
- $attributes['media'] = implode(',', $attributes['media']);
- }
-
- $data = new stdClass();
- $data->content = $content;
- $data->attributes = $attributes;
-
- return $data;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HeadTitle.php b/lib/zend/Zend/View/Helper/HeadTitle.php
deleted file mode 100644
index 8f3d9d0dbc09d..0000000000000
--- a/lib/zend/Zend/View/Helper/HeadTitle.php
+++ /dev/null
@@ -1,222 +0,0 @@
-getDefaultAttachOrder())
- ? Zend_View_Helper_Placeholder_Container_Abstract::APPEND
- : $this->getDefaultAttachOrder();
- }
- $title = (string) $title;
- if ($title !== '') {
- if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
- $this->set($title);
- } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
- $this->prepend($title);
- } else {
- $this->append($title);
- }
- }
-
- return $this;
- }
-
- /**
- * Set a default order to add titles
- *
- * @param string $setType
- */
- public function setDefaultAttachOrder($setType)
- {
- if (!in_array($setType, array(
- Zend_View_Helper_Placeholder_Container_Abstract::APPEND,
- Zend_View_Helper_Placeholder_Container_Abstract::SET,
- Zend_View_Helper_Placeholder_Container_Abstract::PREPEND
- ))) {
- require_once 'Zend/View/Exception.php';
- throw new Zend_View_Exception("You must use a valid attach order: 'PREPEND', 'APPEND' or 'SET'");
- }
-
- $this->_defaultAttachOrder = $setType;
- return $this;
- }
-
- /**
- * Get the default attach order, if any.
- *
- * @return mixed
- */
- public function getDefaultAttachOrder()
- {
- return $this->_defaultAttachOrder;
- }
-
- /**
- * Sets a translation Adapter for translation
- *
- * @param Zend_Translate|Zend_Translate_Adapter $translate
- * @return Zend_View_Helper_HeadTitle
- */
- public function setTranslator($translate)
- {
- if ($translate instanceof Zend_Translate_Adapter) {
- $this->_translator = $translate;
- } elseif ($translate instanceof Zend_Translate) {
- $this->_translator = $translate->getAdapter();
- } else {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
- $e->setView($this->view);
- throw $e;
- }
- return $this;
- }
-
- /**
- * Retrieve translation object
- *
- * If none is currently registered, attempts to pull it from the registry
- * using the key 'Zend_Translate'.
- *
- * @return Zend_Translate_Adapter|null
- */
- public function getTranslator()
- {
- if (null === $this->_translator) {
- require_once 'Zend/Registry.php';
- if (Zend_Registry::isRegistered('Zend_Translate')) {
- $this->setTranslator(Zend_Registry::get('Zend_Translate'));
- }
- }
- return $this->_translator;
- }
-
- /**
- * Enables translation
- *
- * @return Zend_View_Helper_HeadTitle
- */
- public function enableTranslation()
- {
- $this->_translate = true;
- return $this;
- }
-
- /**
- * Disables translation
- *
- * @return Zend_View_Helper_HeadTitle
- */
- public function disableTranslation()
- {
- $this->_translate = false;
- return $this;
- }
-
- /**
- * Turn helper into string
- *
- * @param string|null $indent
- * @param string|null $locale
- * @return string
- */
- public function toString($indent = null, $locale = null)
- {
- $indent = (null !== $indent)
- ? $this->getWhitespace($indent)
- : $this->getIndent();
-
- $items = array();
-
- if($this->_translate && $translator = $this->getTranslator()) {
- foreach ($this as $item) {
- $items[] = $translator->translate($item, $locale);
- }
- } else {
- foreach ($this as $item) {
- $items[] = $item;
- }
- }
-
- $separator = $this->getSeparator();
- $output = '';
- if(($prefix = $this->getPrefix())) {
- $output .= $prefix;
- }
- $output .= implode($separator, $items);
- if(($postfix = $this->getPostfix())) {
- $output .= $postfix;
- }
-
- $output = ($this->_autoEscape) ? $this->_escape($output) : $output;
-
- return $indent . '' . $output . ' ';
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HtmlElement.php b/lib/zend/Zend/View/Helper/HtmlElement.php
deleted file mode 100644
index 263fcd32d22ed..0000000000000
--- a/lib/zend/Zend/View/Helper/HtmlElement.php
+++ /dev/null
@@ -1,167 +0,0 @@
-_closingBracket) {
- if ($this->_isXhtml()) {
- $this->_closingBracket = ' />';
- } else {
- $this->_closingBracket = '>';
- }
- }
-
- return $this->_closingBracket;
- }
-
- /**
- * Is doctype XHTML?
- *
- * @return boolean
- */
- protected function _isXhtml()
- {
- $doctype = $this->view->doctype();
- return $doctype->isXhtml();
- }
-
- /**
- * Is doctype HTML5?
- *
- * @return boolean
- */
- protected function _isHtml5()
- {
- $doctype = $this->view->doctype();
- return $doctype->isHtml5();
- }
-
- /**
- * Is doctype strict?
- *
- * @return boolean
- */
- protected function _isStrictDoctype()
- {
- $doctype = $this->view->doctype();
- return $doctype->isStrict();
- }
-
- /**
- * Converts an associative array to a string of tag attributes.
- *
- * @access public
- *
- * @param array $attribs From this array, each key-value pair is
- * converted to an attribute name and value.
- *
- * @return string The XHTML for the attributes.
- */
- protected function _htmlAttribs($attribs)
- {
- $xhtml = '';
- foreach ((array) $attribs as $key => $val) {
- $key = $this->view->escape($key);
-
- if (('on' == substr($key, 0, 2)) || ('constraints' == $key)) {
- // Don't escape event attributes; _do_ substitute double quotes with singles
- if (!is_scalar($val)) {
- // non-scalar data should be cast to JSON first
- require_once 'Zend/Json.php';
- $val = Zend_Json::encode($val);
- }
- // Escape single quotes inside event attribute values.
- // This will create html, where the attribute value has
- // single quotes around it, and escaped single quotes or
- // non-escaped double quotes inside of it
- $val = str_replace('\'', ''', $val);
- } else {
- if (is_array($val)) {
- $val = implode(' ', $val);
- }
- $val = $this->view->escape($val);
- }
-
- if ('id' == $key) {
- $val = $this->_normalizeId($val);
- }
-
- if (strpos($val, '"') !== false) {
- $xhtml .= " $key='$val'";
- } else {
- $xhtml .= " $key=\"$val\"";
- }
-
- }
- return $xhtml;
- }
-
- /**
- * Normalize an ID
- *
- * @param string $value
- * @return string
- */
- protected function _normalizeId($value)
- {
- if (strstr($value, '[')) {
- if ('[]' == substr($value, -2)) {
- $value = substr($value, 0, strlen($value) - 2);
- }
- $value = trim($value, ']');
- $value = str_replace('][', '-', $value);
- $value = str_replace('[', '-', $value);
- }
- return $value;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HtmlFlash.php b/lib/zend/Zend/View/Helper/HtmlFlash.php
deleted file mode 100644
index 3edcf1afcef92..0000000000000
--- a/lib/zend/Zend/View/Helper/HtmlFlash.php
+++ /dev/null
@@ -1,60 +0,0 @@
- $data,
- 'quality' => 'high'), $params);
-
- return $this->htmlObject($data, self::TYPE, $attribs, $params, $content);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HtmlList.php b/lib/zend/Zend/View/Helper/HtmlList.php
deleted file mode 100644
index 471ade4808f97..0000000000000
--- a/lib/zend/Zend/View/Helper/HtmlList.php
+++ /dev/null
@@ -1,90 +0,0 @@
-setView($this->view);
- throw $e;
- }
-
- $list = '';
-
- foreach ($items as $item) {
- if (!is_array($item)) {
- if ($escape) {
- $item = $this->view->escape($item);
- }
- $list .= '' . $item . ' ' . self::EOL;
- } else {
- if (6 < strlen($list)) {
- $list = substr($list, 0, strlen($list) - 6)
- . $this->htmlList($item, $ordered, $attribs, $escape) . '' . self::EOL;
- } else {
- $list .= '' . $this->htmlList($item, $ordered, $attribs, $escape) . ' ' . self::EOL;
- }
- }
- }
-
- if ($attribs) {
- $attribs = $this->_htmlAttribs($attribs);
- } else {
- $attribs = '';
- }
-
- $tag = 'ul';
- if ($ordered) {
- $tag = 'ol';
- }
-
- return '<' . $tag . $attribs . '>' . self::EOL . $list . '' . $tag . '>' . self::EOL;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HtmlObject.php b/lib/zend/Zend/View/Helper/HtmlObject.php
deleted file mode 100644
index 1eddfea5eebdf..0000000000000
--- a/lib/zend/Zend/View/Helper/HtmlObject.php
+++ /dev/null
@@ -1,80 +0,0 @@
- $data,
- 'type' => $type), $attribs);
-
- // Params
- $paramHtml = array();
- $closingBracket = $this->getClosingBracket();
-
- foreach ($params as $param => $options) {
- if (is_string($options)) {
- $options = array('value' => $options);
- }
-
- $options = array_merge(array('name' => $param), $options);
-
- $paramHtml[] = ' _htmlAttribs($options) . $closingBracket;
- }
-
- // Content
- if (is_array($content)) {
- $content = implode(self::EOL, $content);
- }
-
- // Object header
- $xhtml = '_htmlAttribs($attribs) . '>' . self::EOL
- . implode(self::EOL, $paramHtml) . self::EOL
- . ($content ? $content . self::EOL : '')
- . ' ';
-
- return $xhtml;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HtmlPage.php b/lib/zend/Zend/View/Helper/HtmlPage.php
deleted file mode 100644
index e7b8b0f200c97..0000000000000
--- a/lib/zend/Zend/View/Helper/HtmlPage.php
+++ /dev/null
@@ -1,75 +0,0 @@
- self::ATTRIB_CLASSID);
-
- /**
- * Output a html object tag
- *
- * @param string $data The html url
- * @param array $attribs Attribs for the object tag
- * @param array $params Params for in the object tag
- * @param string $content Alternative content
- * @return string
- */
- public function htmlPage($data, array $attribs = array(), array $params = array(), $content = null)
- {
- // Attrs
- $attribs = array_merge($this->_attribs, $attribs);
-
- // Params
- $params = array_merge(array('data' => $data), $params);
-
- return $this->htmlObject($data, self::TYPE, $attribs, $params, $content);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/HtmlQuicktime.php b/lib/zend/Zend/View/Helper/HtmlQuicktime.php
deleted file mode 100644
index 6c200dbcecb57..0000000000000
--- a/lib/zend/Zend/View/Helper/HtmlQuicktime.php
+++ /dev/null
@@ -1,82 +0,0 @@
- self::ATTRIB_CLASSID,
- 'codebase' => self::ATTRIB_CODEBASE);
-
- /**
- * Output a quicktime movie object tag
- *
- * @param string $data The quicktime file
- * @param array $attribs Attribs for the object tag
- * @param array $params Params for in the object tag
- * @param string $content Alternative content
- * @return string
- */
- public function htmlQuicktime($data, array $attribs = array(), array $params = array(), $content = null)
- {
- // Attrs
- $attribs = array_merge($this->_attribs, $attribs);
-
- // Params
- $params = array_merge(array('src' => $data), $params);
-
- return $this->htmlObject($data, self::TYPE, $attribs, $params, $content);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/InlineScript.php b/lib/zend/Zend/View/Helper/InlineScript.php
deleted file mode 100644
index 978c6b812b559..0000000000000
--- a/lib/zend/Zend/View/Helper/InlineScript.php
+++ /dev/null
@@ -1,61 +0,0 @@
-headScript($mode, $spec, $placement, $attrs, $type);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Interface.php b/lib/zend/Zend/View/Helper/Interface.php
deleted file mode 100644
index c7e761b2a5694..0000000000000
--- a/lib/zend/Zend/View/Helper/Interface.php
+++ /dev/null
@@ -1,46 +0,0 @@
-true|false
- * this array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false
- * that will not be passed to Zend_Json::encode method but will be used here
- * @param bool $encodeData
- * @return string|void
- */
- public function json($data, $keepLayouts = false, $encodeData = true)
- {
- $options = array();
- if (is_array($keepLayouts)) {
- $options = $keepLayouts;
-
- $keepLayouts = false;
- if (array_key_exists('keepLayouts', $options)) {
- $keepLayouts = $options['keepLayouts'];
- unset($options['keepLayouts']);
- }
-
- if (array_key_exists('encodeData', $options)) {
- $encodeData = $options['encodeData'];
- unset($options['encodeData']);
- }
- }
-
- if ($encodeData) {
- $data = Zend_Json::encode($data, null, $options);
- }
- if (!$keepLayouts) {
- require_once 'Zend/Layout.php';
- $layout = Zend_Layout::getMvcInstance();
- if ($layout instanceof Zend_Layout) {
- $layout->disableLayout();
- }
- }
-
- $response = Zend_Controller_Front::getInstance()->getResponse();
- $response->setHeader('Content-Type', 'application/json', true);
- return $data;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Layout.php b/lib/zend/Zend/View/Helper/Layout.php
deleted file mode 100644
index 286a9e38e7ea2..0000000000000
--- a/lib/zend/Zend/View/Helper/Layout.php
+++ /dev/null
@@ -1,81 +0,0 @@
-_layout) {
- require_once 'Zend/Layout.php';
- $this->_layout = Zend_Layout::getMvcInstance();
- if (null === $this->_layout) {
- // Implicitly creates layout object
- $this->_layout = new Zend_Layout();
- }
- }
-
- return $this->_layout;
- }
-
- /**
- * Set layout object
- *
- * @param Zend_Layout $layout
- * @return Zend_Layout_Controller_Action_Helper_Layout
- */
- public function setLayout(Zend_Layout $layout)
- {
- $this->_layout = $layout;
- return $this;
- }
-
- /**
- * Return layout object
- *
- * Usage: $this->layout()->setLayout('alternate');
- *
- * @return Zend_Layout
- */
- public function layout()
- {
- return $this->getLayout();
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Navigation.php b/lib/zend/Zend/View/Helper/Navigation.php
deleted file mode 100644
index 2e82ef6a291c6..0000000000000
--- a/lib/zend/Zend/View/Helper/Navigation.php
+++ /dev/null
@@ -1,350 +0,0 @@
-setContainer($container);
- }
-
- return $this;
- }
-
- /**
- * Magic overload: Proxy to other navigation helpers or the container
- *
- * Examples of usage from a view script or layout:
- *
- * // proxy to Menu helper and render container:
- * echo $this->navigation()->menu();
- *
- * // proxy to Breadcrumbs helper and set indentation:
- * $this->navigation()->breadcrumbs()->setIndent(8);
- *
- * // proxy to container and find all pages with 'blog' route:
- * $blogPages = $this->navigation()->findAllByRoute('blog');
- *
- *
- * @param string $method helper name or method name in
- * container
- * @param array $arguments [optional] arguments to pass
- * @return mixed returns what the proxied call returns
- * @throws Zend_View_Exception if proxying to a helper, and the
- * helper is not an instance of the
- * interface specified in
- * {@link findHelper()}
- * @throws Zend_Navigation_Exception if method does not exist in container
- */
- public function __call($method, array $arguments = array())
- {
- // check if call should proxy to another helper
- if ($helper = $this->findHelper($method, false)) {
- return call_user_func_array(array($helper, $method), $arguments);
- }
-
- // default behaviour: proxy call to container
- return parent::__call($method, $arguments);
- }
-
- /**
- * Returns the helper matching $proxy
- *
- * The helper must implement the interface
- * {@link Zend_View_Helper_Navigation_Helper}.
- *
- * @param string $proxy helper name
- * @param bool $strict [optional] whether
- * exceptions should be
- * thrown if something goes
- * wrong. Default is true.
- * @return Zend_View_Helper_Navigation_Helper helper instance
- * @throws Zend_Loader_PluginLoader_Exception if $strict is true and
- * helper cannot be found
- * @throws Zend_View_Exception if $strict is true and
- * helper does not implement
- * the specified interface
- */
- public function findHelper($proxy, $strict = true)
- {
- if (isset($this->_helpers[$proxy])) {
- return $this->_helpers[$proxy];
- }
-
- if (!$this->view->getPluginLoader('helper')->getPaths(self::NS)) {
- // Add navigation helper path at the beginning
- $paths = $this->view->getHelperPaths();
- $this->view->setHelperPath(null);
-
- $this->view->addHelperPath(
- str_replace('_', '/', self::NS),
- self::NS);
-
- foreach ($paths as $ns => $path) {
- $this->view->addHelperPath($path, $ns);
- }
- }
-
- if ($strict) {
- $helper = $this->view->getHelper($proxy);
- } else {
- try {
- $helper = $this->view->getHelper($proxy);
- } catch (Zend_Loader_PluginLoader_Exception $e) {
- return null;
- }
- }
-
- if (!$helper instanceof Zend_View_Helper_Navigation_Helper) {
- if ($strict) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf(
- 'Proxy helper "%s" is not an instance of ' .
- 'Zend_View_Helper_Navigation_Helper',
- get_class($helper)));
- $e->setView($this->view);
- throw $e;
- }
-
- return null;
- }
-
- $this->_inject($helper);
- $this->_helpers[$proxy] = $helper;
-
- return $helper;
- }
-
- /**
- * Injects container, ACL, and translator to the given $helper if this
- * helper is configured to do so
- *
- * @param Zend_View_Helper_Navigation_Helper $helper helper instance
- * @return void
- */
- protected function _inject(Zend_View_Helper_Navigation_Helper $helper)
- {
- if ($this->getInjectContainer() && !$helper->hasContainer()) {
- $helper->setContainer($this->getContainer());
- }
-
- if ($this->getInjectAcl()) {
- if (!$helper->hasAcl()) {
- $helper->setAcl($this->getAcl());
- }
- if (!$helper->hasRole()) {
- $helper->setRole($this->getRole());
- }
- }
-
- if ($this->getInjectTranslator() && !$helper->hasTranslator()) {
- $helper->setTranslator($this->getTranslator());
- }
- }
-
- // Accessors:
-
- /**
- * Sets the default proxy to use in {@link render()}
- *
- * @param string $proxy default proxy
- * @return Zend_View_Helper_Navigation fluent interface, returns self
- */
- public function setDefaultProxy($proxy)
- {
- $this->_defaultProxy = (string) $proxy;
- return $this;
- }
-
- /**
- * Returns the default proxy to use in {@link render()}
- *
- * @return string the default proxy to use in {@link render()}
- */
- public function getDefaultProxy()
- {
- return $this->_defaultProxy;
- }
-
- /**
- * Sets whether container should be injected when proxying
- *
- * @param bool $injectContainer [optional] whether container should
- * be injected when proxying. Default
- * is true.
- * @return Zend_View_Helper_Navigation fluent interface, returns self
- */
- public function setInjectContainer($injectContainer = true)
- {
- $this->_injectContainer = (bool) $injectContainer;
- return $this;
- }
-
- /**
- * Returns whether container should be injected when proxying
- *
- * @return bool whether container should be injected when proxying
- */
- public function getInjectContainer()
- {
- return $this->_injectContainer;
- }
-
- /**
- * Sets whether ACL should be injected when proxying
- *
- * @param bool $injectAcl [optional] whether ACL should be
- * injected when proxying. Default is
- * true.
- * @return Zend_View_Helper_Navigation fluent interface, returns self
- */
- public function setInjectAcl($injectAcl = true)
- {
- $this->_injectAcl = (bool) $injectAcl;
- return $this;
- }
-
- /**
- * Returns whether ACL should be injected when proxying
- *
- * @return bool whether ACL should be injected when proxying
- */
- public function getInjectAcl()
- {
- return $this->_injectAcl;
- }
-
- /**
- * Sets whether translator should be injected when proxying
- *
- * @param bool $injectTranslator [optional] whether translator should
- * be injected when proxying. Default
- * is true.
- * @return Zend_View_Helper_Navigation fluent interface, returns self
- */
- public function setInjectTranslator($injectTranslator = true)
- {
- $this->_injectTranslator = (bool) $injectTranslator;
- return $this;
- }
-
- /**
- * Returns whether translator should be injected when proxying
- *
- * @return bool whether translator should be injected when proxying
- */
- public function getInjectTranslator()
- {
- return $this->_injectTranslator;
- }
-
- // Zend_View_Helper_Navigation_Helper:
-
- /**
- * Renders helper
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * render. Default is to
- * render the container
- * registered in the helper.
- * @return string helper output
- * @throws Zend_Loader_PluginLoader_Exception if helper cannot be found
- * @throws Zend_View_Exception if helper doesn't implement
- * the interface specified in
- * {@link findHelper()}
- */
- public function render(Zend_Navigation_Container $container = null)
- {
- $helper = $this->findHelper($this->getDefaultProxy());
- return $helper->render($container);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Navigation/Breadcrumbs.php b/lib/zend/Zend/View/Helper/Navigation/Breadcrumbs.php
deleted file mode 100644
index 10755c3df4918..0000000000000
--- a/lib/zend/Zend/View/Helper/Navigation/Breadcrumbs.php
+++ /dev/null
@@ -1,331 +0,0 @@
-setContainer($container);
- }
-
- return $this;
- }
-
- // Accessors:
-
- /**
- * Sets breadcrumb separator
- *
- * @param string $separator separator string
- * @return Zend_View_Helper_Navigation_Breadcrumbs fluent interface,
- * returns self
- */
- public function setSeparator($separator)
- {
- if (is_string($separator)) {
- $this->_separator = $separator;
- }
-
- return $this;
- }
-
- /**
- * Returns breadcrumb separator
- *
- * @return string breadcrumb separator
- */
- public function getSeparator()
- {
- return $this->_separator;
- }
-
- /**
- * Sets whether last page in breadcrumbs should be hyperlinked
- *
- * @param bool $linkLast whether last page should
- * be hyperlinked
- * @return Zend_View_Helper_Navigation_Breadcrumbs fluent interface,
- * returns self
- */
- public function setLinkLast($linkLast)
- {
- $this->_linkLast = (bool) $linkLast;
- return $this;
- }
-
- /**
- * Returns whether last page in breadcrumbs should be hyperlinked
- *
- * @return bool whether last page in breadcrumbs should be hyperlinked
- */
- public function getLinkLast()
- {
- return $this->_linkLast;
- }
-
- /**
- * Sets which partial view script to use for rendering menu
- *
- * @param string|array $partial partial view script or
- * null. If an array is
- * given, it is expected to
- * contain two values;
- * the partial view script
- * to use, and the module
- * where the script can be
- * found.
- * @return Zend_View_Helper_Navigation_Breadcrumbs fluent interface,
- * returns self
- */
- public function setPartial($partial)
- {
- if (null === $partial || is_string($partial) || is_array($partial)) {
- $this->_partial = $partial;
- }
-
- return $this;
- }
-
- /**
- * Returns partial view script to use for rendering menu
- *
- * @return string|array|null
- */
- public function getPartial()
- {
- return $this->_partial;
- }
-
- // Render methods:
-
- /**
- * Renders breadcrumbs by chaining 'a' elements with the separator
- * registered in the helper
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * render. Default is to
- * render the container
- * registered in the helper.
- * @return string helper output
- */
- public function renderStraight(Zend_Navigation_Container $container = null)
- {
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- // find deepest active
- if (!$active = $this->findActive($container)) {
- return '';
- }
-
- $active = $active['page'];
-
- // put the deepest active page last in breadcrumbs
- if ($this->getLinkLast()) {
- $html = $this->htmlify($active);
- } else {
- $html = $active->getLabel();
- if ($this->getUseTranslator() && $t = $this->getTranslator()) {
- $html = $t->translate($html);
- }
- $html = $this->view->escape($html);
- }
-
- // walk back to root
- while ($parent = $active->getParent()) {
- if ($parent instanceof Zend_Navigation_Page) {
- // prepend crumb to html
- $html = $this->htmlify($parent)
- . $this->getSeparator()
- . $html;
- }
-
- if ($parent === $container) {
- // at the root of the given container
- break;
- }
-
- $active = $parent;
- }
-
- return strlen($html) ? $this->getIndent() . $html : '';
- }
-
- /**
- * Renders the given $container by invoking the partial view helper
- *
- * The container will simply be passed on as a model to the view script,
- * so in the script it will be available in $this->container
.
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * pass to view script.
- * Default is to use the
- * container registered in the
- * helper.
- * @param string|array $partial [optional] partial view
- * script to use. Default is
- * to use the partial
- * registered in the helper.
- * If an array is given, it is
- * expected to contain two
- * values; the partial view
- * script to use, and the
- * module where the script can
- * be found.
- * @return string helper output
- */
- public function renderPartial(Zend_Navigation_Container $container = null,
- $partial = null)
- {
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- if (null === $partial) {
- $partial = $this->getPartial();
- }
-
- if (empty($partial)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(
- 'Unable to render menu: No partial view script provided'
- );
- $e->setView($this->view);
- throw $e;
- }
-
- // put breadcrumb pages in model
- $model = array('pages' => array());
- if ($active = $this->findActive($container)) {
- $active = $active['page'];
- $model['pages'][] = $active;
- while ($parent = $active->getParent()) {
- if ($parent instanceof Zend_Navigation_Page) {
- $model['pages'][] = $parent;
- } else {
- break;
- }
-
- if ($parent === $container) {
- // break if at the root of the given container
- break;
- }
-
- $active = $parent;
- }
- $model['pages'] = array_reverse($model['pages']);
- }
-
- if (is_array($partial)) {
- if (count($partial) != 2) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(
- 'Unable to render menu: A view partial supplied as '
- . 'an array must contain two values: partial view '
- . 'script and module where script can be found'
- );
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->view->partial($partial[0], $partial[1], $model);
- }
-
- return $this->view->partial($partial, null, $model);
- }
-
- // Zend_View_Helper_Navigation_Helper:
-
- /**
- * Renders helper
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::render()}.
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * render. Default is to
- * render the container
- * registered in the helper.
- * @return string helper output
- */
- public function render(Zend_Navigation_Container $container = null)
- {
- if ($partial = $this->getPartial()) {
- return $this->renderPartial($container, $partial);
- } else {
- return $this->renderStraight($container);
- }
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Navigation/Helper.php b/lib/zend/Zend/View/Helper/Navigation/Helper.php
deleted file mode 100644
index e7d5878160c43..0000000000000
--- a/lib/zend/Zend/View/Helper/Navigation/Helper.php
+++ /dev/null
@@ -1,212 +0,0 @@
-_container = $container;
- return $this;
- }
-
- /**
- * Returns the navigation container helper operates on by default
- *
- * Implements {@link Zend_View_Helper_Navigation_Interface::getContainer()}.
- *
- * If a helper is not explicitly set in this helper instance by calling
- * {@link setContainer()} or by passing it through the helper entry point,
- * this method will look in {@link Zend_Registry} for a container by using
- * the key 'Zend_Navigation'.
- *
- * If no container is set, and nothing is found in Zend_Registry, a new
- * container will be instantiated and stored in the helper.
- *
- * @return Zend_Navigation_Container navigation container
- */
- public function getContainer()
- {
- if (null === $this->_container) {
- // try to fetch from registry first
- require_once 'Zend/Registry.php';
- if (Zend_Registry::isRegistered('Zend_Navigation')) {
- $nav = Zend_Registry::get('Zend_Navigation');
- if ($nav instanceof Zend_Navigation_Container) {
- return $this->_container = $nav;
- }
- }
-
- // nothing found in registry, create new container
- require_once 'Zend/Navigation.php';
- $this->_container = new Zend_Navigation();
- }
-
- return $this->_container;
- }
-
- /**
- * Sets the minimum depth a page must have to be included when rendering
- *
- * @param int $minDepth [optional] minimum
- * depth. Default is
- * null, which sets
- * no minimum depth.
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setMinDepth($minDepth = null)
- {
- if (null === $minDepth || is_int($minDepth)) {
- $this->_minDepth = $minDepth;
- } else {
- $this->_minDepth = (int) $minDepth;
- }
- return $this;
- }
-
- /**
- * Returns minimum depth a page must have to be included when rendering
- *
- * @return int|null minimum depth or null
- */
- public function getMinDepth()
- {
- if (!is_int($this->_minDepth) || $this->_minDepth < 0) {
- return 0;
- }
- return $this->_minDepth;
- }
-
- /**
- * Sets the maximum depth a page can have to be included when rendering
- *
- * @param int $maxDepth [optional] maximum
- * depth. Default is
- * null, which sets no
- * maximum depth.
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setMaxDepth($maxDepth = null)
- {
- if (null === $maxDepth || is_int($maxDepth)) {
- $this->_maxDepth = $maxDepth;
- } else {
- $this->_maxDepth = (int) $maxDepth;
- }
- return $this;
- }
-
- /**
- * Returns maximum depth a page can have to be included when rendering
- *
- * @return int|null maximum depth or null
- */
- public function getMaxDepth()
- {
- return $this->_maxDepth;
- }
-
- /**
- * Set the indentation string for using in {@link render()}, optionally a
- * number of spaces to indent with
- *
- * @param string|int $indent indentation string or
- * number of spaces
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setIndent($indent)
- {
- $this->_indent = $this->_getWhitespace($indent);
- return $this;
- }
-
- /**
- * Returns indentation (format output is respected)
- *
- * @return string indentation string or an empty string
- */
- public function getIndent()
- {
- if (false === $this->getFormatOutput()) {
- return '';
- }
-
- return $this->_indent;
- }
-
- /**
- * Returns the EOL character (format output is respected)
- *
- * @see self::EOL
- * @see getFormatOutput()
- *
- * @return string standard EOL charater or an empty string
- */
- public function getEOL()
- {
- if (false === $this->getFormatOutput()) {
- return '';
- }
-
- return self::EOL;
- }
-
- /**
- * Sets whether HTML/XML output should be formatted
- *
- * @param bool $formatOutput [optional] whether output
- * should be formatted. Default
- * is true.
- *
- * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns
- * self
- */
- public function setFormatOutput($formatOutput = true)
- {
- $this->_formatOutput = (bool)$formatOutput;
-
- return $this;
- }
-
- /**
- * Returns whether HTML/XML output should be formatted
- *
- * @return bool whether HTML/XML output should be formatted
- */
- public function getFormatOutput()
- {
- return $this->_formatOutput;
- }
-
- /**
- * Sets prefix for IDs when they are normalized
- *
- * @param string $prefix Prefix for IDs
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface, returns self
- */
- public function setPrefixForId($prefix)
- {
- if (is_string($prefix)) {
- $this->_prefixForId = trim($prefix);
- }
-
- return $this;
- }
-
- /**
- * Returns prefix for IDs when they are normalized
- *
- * @return string Prefix for
- */
- public function getPrefixForId()
- {
- if (null === $this->_prefixForId) {
- $prefix = get_class($this);
- $this->_prefixForId = strtolower(
- trim(substr($prefix, strrpos($prefix, '_')), '_')
- ) . '-';
- }
-
- return $this->_prefixForId;
- }
-
- /**
- * Skip the current prefix for IDs when they are normalized
- *
- * @param bool $flag
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface, returns self
- */
- public function skipPrefixForId($flag = true)
- {
- $this->_skipPrefixForId = (bool) $flag;
- return $this;
- }
-
- /**
- * Sets translator to use in helper
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::setTranslator()}.
- *
- * @param mixed $translator [optional] translator.
- * Expects an object of
- * type
- * {@link Zend_Translate_Adapter}
- * or {@link Zend_Translate},
- * or null. Default is
- * null, which sets no
- * translator.
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setTranslator($translator = null)
- {
- if (null == $translator ||
- $translator instanceof Zend_Translate_Adapter) {
- $this->_translator = $translator;
- } elseif ($translator instanceof Zend_Translate) {
- $this->_translator = $translator->getAdapter();
- }
-
- return $this;
- }
-
- /**
- * Returns translator used in helper
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::getTranslator()}.
- *
- * @return Zend_Translate_Adapter|null translator or null
- */
- public function getTranslator()
- {
- if (null === $this->_translator) {
- require_once 'Zend/Registry.php';
- if (Zend_Registry::isRegistered('Zend_Translate')) {
- $this->setTranslator(Zend_Registry::get('Zend_Translate'));
- }
- }
-
- return $this->_translator;
- }
-
- /**
- * Sets ACL to use when iterating pages
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::setAcl()}.
- *
- * @param Zend_Acl $acl [optional] ACL object.
- * Default is null.
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setAcl(Zend_Acl $acl = null)
- {
- $this->_acl = $acl;
- return $this;
- }
-
- /**
- * Returns ACL or null if it isn't set using {@link setAcl()} or
- * {@link setDefaultAcl()}
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::getAcl()}.
- *
- * @return Zend_Acl|null ACL object or null
- */
- public function getAcl()
- {
- if ($this->_acl === null && self::$_defaultAcl !== null) {
- return self::$_defaultAcl;
- }
-
- return $this->_acl;
- }
-
- /**
- * Sets ACL role(s) to use when iterating pages
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::setRole()}.
- *
- * @param mixed $role [optional] role to
- * set. Expects a string,
- * an instance of type
- * {@link Zend_Acl_Role_Interface},
- * or null. Default is
- * null, which will set
- * no role.
- * @throws Zend_View_Exception if $role is invalid
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setRole($role = null)
- {
- if (null === $role || is_string($role) ||
- $role instanceof Zend_Acl_Role_Interface) {
- $this->_role = $role;
- } else {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf(
- '$role must be a string, null, or an instance of '
- . 'Zend_Acl_Role_Interface; %s given',
- gettype($role)
- ));
- $e->setView($this->view);
- throw $e;
- }
-
- return $this;
- }
-
- /**
- * Returns ACL role to use when iterating pages, or null if it isn't set
- * using {@link setRole()} or {@link setDefaultRole()}
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::getRole()}.
- *
- * @return string|Zend_Acl_Role_Interface|null role or null
- */
- public function getRole()
- {
- if ($this->_role === null && self::$_defaultRole !== null) {
- return self::$_defaultRole;
- }
-
- return $this->_role;
- }
-
- /**
- * Sets whether ACL should be used
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::setUseAcl()}.
- *
- * @param bool $useAcl [optional] whether ACL
- * should be used.
- * Default is true.
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setUseAcl($useAcl = true)
- {
- $this->_useAcl = (bool) $useAcl;
- return $this;
- }
-
- /**
- * Returns whether ACL should be used
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::getUseAcl()}.
- *
- * @return bool whether ACL should be used
- */
- public function getUseAcl()
- {
- return $this->_useAcl;
- }
-
- /**
- * Return renderInvisible flag
- *
- * @return bool
- */
- public function getRenderInvisible()
- {
- return $this->_renderInvisible;
- }
-
- /**
- * Render invisible items?
- *
- * @param bool $renderInvisible [optional] boolean flag
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface
- * returns self
- */
- public function setRenderInvisible($renderInvisible = true)
- {
- $this->_renderInvisible = (bool) $renderInvisible;
- return $this;
- }
-
- /**
- * Sets whether translator should be used
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::setUseTranslator()}.
- *
- * @param bool $useTranslator [optional] whether
- * translator should be
- * used. Default is true.
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setUseTranslator($useTranslator = true)
- {
- $this->_useTranslator = (bool) $useTranslator;
- return $this;
- }
-
- /**
- * Returns whether translator should be used
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::getUseTranslator()}.
- *
- * @return bool whether translator should be used
- */
- public function getUseTranslator()
- {
- return $this->_useTranslator;
- }
-
- // Magic overloads:
-
- /**
- * Magic overload: Proxy calls to the navigation container
- *
- * @param string $method method name in container
- * @param array $arguments [optional] arguments to pass
- * @return mixed returns what the container returns
- * @throws Zend_Navigation_Exception if method does not exist in container
- */
- public function __call($method, array $arguments = array())
- {
- return call_user_func_array(
- array($this->getContainer(), $method),
- $arguments);
- }
-
- /**
- * Magic overload: Proxy to {@link render()}.
- *
- * This method will trigger an E_USER_ERROR if rendering the helper causes
- * an exception to be thrown.
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::__toString()}.
- *
- * @return string
- */
- public function __toString()
- {
- try {
- return $this->render();
- } catch (Exception $e) {
- $msg = get_class($e) . ': ' . $e->getMessage();
- trigger_error($msg, E_USER_ERROR);
- return '';
- }
- }
-
- // Public methods:
-
- /**
- * Finds the deepest active page in the given container
- *
- * @param Zend_Navigation_Container $container container to search
- * @param int|null $minDepth [optional] minimum depth
- * required for page to be
- * valid. Default is to use
- * {@link getMinDepth()}. A
- * null value means no minimum
- * depth required.
- * @param int|null $minDepth [optional] maximum depth
- * a page can have to be
- * valid. Default is to use
- * {@link getMaxDepth()}. A
- * null value means no maximum
- * depth required.
- * @return array an associative array with
- * the values 'depth' and
- * 'page', or an empty array
- * if not found
- */
- public function findActive(Zend_Navigation_Container $container,
- $minDepth = null,
- $maxDepth = -1)
- {
- if (!is_int($minDepth)) {
- $minDepth = $this->getMinDepth();
- }
- if ((!is_int($maxDepth) || $maxDepth < 0) && null !== $maxDepth) {
- $maxDepth = $this->getMaxDepth();
- }
-
- $found = null;
- $foundDepth = -1;
- $iterator = new RecursiveIteratorIterator($container,
- RecursiveIteratorIterator::CHILD_FIRST);
-
- foreach ($iterator as $page) {
- $currDepth = $iterator->getDepth();
- if ($currDepth < $minDepth || !$this->accept($page)) {
- // page is not accepted
- continue;
- }
-
- if ($page->isActive(false) && $currDepth > $foundDepth) {
- // found an active page at a deeper level than before
- $found = $page;
- $foundDepth = $currDepth;
- }
- }
-
- if (is_int($maxDepth) && $foundDepth > $maxDepth) {
- while ($foundDepth > $maxDepth) {
- if (--$foundDepth < $minDepth) {
- $found = null;
- break;
- }
-
- $found = $found->getParent();
- if (!$found instanceof Zend_Navigation_Page) {
- $found = null;
- break;
- }
- }
- }
-
- if ($found) {
- return array('page' => $found, 'depth' => $foundDepth);
- } else {
- return array();
- }
- }
-
- /**
- * Checks if the helper has a container
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::hasContainer()}.
- *
- * @return bool whether the helper has a container or not
- */
- public function hasContainer()
- {
- return null !== $this->_container;
- }
-
- /**
- * Checks if the helper has an ACL instance
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::hasAcl()}.
- *
- * @return bool whether the helper has a an ACL instance or not
- */
- public function hasAcl()
- {
- return null !== $this->_acl;
- }
-
- /**
- * Checks if the helper has an ACL role
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::hasRole()}.
- *
- * @return bool whether the helper has a an ACL role or not
- */
- public function hasRole()
- {
- return null !== $this->_role;
- }
-
- /**
- * Checks if the helper has a translator
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::hasTranslator()}.
- *
- * @return bool whether the helper has a translator or not
- */
- public function hasTranslator()
- {
- return null !== $this->_translator;
- }
-
- /**
- * Returns an HTML string containing an 'a' element for the given page
- *
- * @param Zend_Navigation_Page $page page to generate HTML for
- * @return string HTML string for the given page
- */
- public function htmlify(Zend_Navigation_Page $page)
- {
- // get label and title for translating
- $label = $page->getLabel();
- $title = $page->getTitle();
-
- if ($this->getUseTranslator() && $t = $this->getTranslator()) {
- if (is_string($label) && !empty($label)) {
- $label = $t->translate($label);
- }
- if (is_string($title) && !empty($title)) {
- $title = $t->translate($title);
- }
- }
-
- // get attribs for anchor element
- $attribs = array_merge(
- array(
- 'id' => $page->getId(),
- 'title' => $title,
- 'class' => $page->getClass(),
- 'href' => $page->getHref(),
- 'target' => $page->getTarget()
- ),
- $page->getCustomHtmlAttribs()
- );
-
- return '_htmlAttribs($attribs) . '>'
- . $this->view->escape($label)
- . ' ';
- }
-
- // Iterator filter methods:
-
- /**
- * Determines whether a page should be accepted when iterating
- *
- * Rules:
- * - If a page is not visible it is not accepted, unless RenderInvisible has
- * been set to true.
- * - If helper has no ACL, page is accepted
- * - If helper has ACL, but no role, page is not accepted
- * - If helper has ACL and role:
- * - Page is accepted if it has no resource or privilege
- * - Page is accepted if ACL allows page's resource or privilege
- * - If page is accepted by the rules above and $recursive is true, the page
- * will not be accepted if it is the descendant of a non-accepted page.
- *
- * @param Zend_Navigation_Page $page page to check
- * @param bool $recursive [optional] if true, page will not
- * be accepted if it is the
- * descendant of a page that is not
- * accepted. Default is true.
- * @return bool whether page should be accepted
- */
- public function accept(Zend_Navigation_Page $page, $recursive = true)
- {
- // accept by default
- $accept = true;
-
- if (!$page->isVisible(false) && !$this->getRenderInvisible()) {
- // don't accept invisible pages
- $accept = false;
- } elseif ($this->getUseAcl() && !$this->_acceptAcl($page)) {
- // acl is not amused
- $accept = false;
- }
-
- if ($accept && $recursive) {
- $parent = $page->getParent();
- if ($parent instanceof Zend_Navigation_Page) {
- $accept = $this->accept($parent, true);
- }
- }
-
- return $accept;
- }
-
- /**
- * Determines whether a page should be accepted by ACL when iterating
- *
- * Rules:
- * - If helper has no ACL, page is accepted
- * - If page has a resource or privilege defined, page is accepted
- * if the ACL allows access to it using the helper's role
- * - If page has no resource or privilege, page is accepted
- *
- * @param Zend_Navigation_Page $page page to check
- * @return bool whether page is accepted by ACL
- */
- protected function _acceptAcl(Zend_Navigation_Page $page)
- {
- if (!$acl = $this->getAcl()) {
- // no acl registered means don't use acl
- return true;
- }
-
- $role = $this->getRole();
- $resource = $page->getResource();
- $privilege = $page->getPrivilege();
-
- if ($resource || $privilege) {
- // determine using helper role and page resource/privilege
- return $acl->isAllowed($role, $resource, $privilege);
- }
-
- return true;
- }
-
- // Util methods:
-
- /**
- * Retrieve whitespace representation of $indent
- *
- * @param int|string $indent
- * @return string
- */
- protected function _getWhitespace($indent)
- {
- if (is_int($indent)) {
- $indent = str_repeat(' ', $indent);
- }
-
- return (string) $indent;
- }
-
- /**
- * Converts an associative array to a string of tag attributes.
- *
- * Overloads {@link Zend_View_Helper_HtmlElement::_htmlAttribs()}.
- *
- * @param array $attribs an array where each key-value pair is converted
- * to an attribute name and value
- * @return string an attribute string
- */
- protected function _htmlAttribs($attribs)
- {
- // filter out null values and empty string values
- foreach ($attribs as $key => $value) {
- if ($value === null || (is_string($value) && !strlen($value))) {
- unset($attribs[$key]);
- }
- }
-
- return parent::_htmlAttribs($attribs);
- }
-
- /**
- * Normalize an ID
- *
- * Extends {@link Zend_View_Helper_HtmlElement::_normalizeId()}.
- *
- * @param string $value ID
- * @return string Normalized ID
- */
- protected function _normalizeId($value)
- {
- if (false === $this->_skipPrefixForId) {
- $prefix = $this->getPrefixForId();
-
- if (strlen($prefix)) {
- return $prefix . $value;
- }
- }
-
- return parent::_normalizeId($value);
- }
-
- // Static methods:
-
- /**
- * Sets default ACL to use if another ACL is not explicitly set
- *
- * @param Zend_Acl $acl [optional] ACL object. Default is null, which
- * sets no ACL object.
- * @return void
- */
- public static function setDefaultAcl(Zend_Acl $acl = null)
- {
- self::$_defaultAcl = $acl;
- }
-
- /**
- * Sets default ACL role(s) to use when iterating pages if not explicitly
- * set later with {@link setRole()}
- *
- * @param mixed $role [optional] role to set. Expects null,
- * string, or an instance of
- * {@link Zend_Acl_Role_Interface}.
- * Default is null, which sets no default
- * role.
- * @throws Zend_View_Exception if role is invalid
- * @return void
- */
- public static function setDefaultRole($role = null)
- {
- if (null === $role ||
- is_string($role) ||
- $role instanceof Zend_Acl_Role_Interface) {
- self::$_defaultRole = $role;
- } else {
- require_once 'Zend/View/Exception.php';
- throw new Zend_View_Exception(
- '$role must be null|string|Zend_Acl_Role_Interface'
- );
- }
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Navigation/Links.php b/lib/zend/Zend/View/Helper/Navigation/Links.php
deleted file mode 100644
index 5d05c1008b48d..0000000000000
--- a/lib/zend/Zend/View/Helper/Navigation/Links.php
+++ /dev/null
@@ -1,783 +0,0 @@
- elements
- *
- * @category Zend
- * @package Zend_View
- * @subpackage Helper
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_View_Helper_Navigation_Links
- extends Zend_View_Helper_Navigation_HelperAbstract
-{
- /**#@+
- * Constants used for specifying which link types to find and render
- *
- * @var int
- */
- const RENDER_ALTERNATE = 0x0001;
- const RENDER_STYLESHEET = 0x0002;
- const RENDER_START = 0x0004;
- const RENDER_NEXT = 0x0008;
- const RENDER_PREV = 0x0010;
- const RENDER_CONTENTS = 0x0020;
- const RENDER_INDEX = 0x0040;
- const RENDER_GLOSSARY = 0x0080;
- const RENDER_COPYRIGHT = 0x0100;
- const RENDER_CHAPTER = 0x0200;
- const RENDER_SECTION = 0x0400;
- const RENDER_SUBSECTION = 0x0800;
- const RENDER_APPENDIX = 0x1000;
- const RENDER_HELP = 0x2000;
- const RENDER_BOOKMARK = 0x4000;
- const RENDER_CUSTOM = 0x8000;
- const RENDER_ALL = 0xffff;
- /**#@+**/
-
- /**
- * Maps render constants to W3C link types
- *
- * @var array
- */
- protected static $_RELATIONS = array(
- self::RENDER_ALTERNATE => 'alternate',
- self::RENDER_STYLESHEET => 'stylesheet',
- self::RENDER_START => 'start',
- self::RENDER_NEXT => 'next',
- self::RENDER_PREV => 'prev',
- self::RENDER_CONTENTS => 'contents',
- self::RENDER_INDEX => 'index',
- self::RENDER_GLOSSARY => 'glossary',
- self::RENDER_COPYRIGHT => 'copyright',
- self::RENDER_CHAPTER => 'chapter',
- self::RENDER_SECTION => 'section',
- self::RENDER_SUBSECTION => 'subsection',
- self::RENDER_APPENDIX => 'appendix',
- self::RENDER_HELP => 'help',
- self::RENDER_BOOKMARK => 'bookmark'
- );
-
- /**
- * The helper's render flag
- *
- * @see render()
- * @see setRenderFlag()
- * @var int
- */
- protected $_renderFlag = self::RENDER_ALL;
-
- /**
- * Root container
- *
- * Used for preventing methods to traverse above the container given to
- * the {@link render()} method.
- *
- * @see _findRoot()
- *
- * @var Zend_Navigation_Container
- */
- protected $_root;
-
- /**
- * View helper entry point:
- * Retrieves helper and optionally sets container to operate on
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * operate on
- * @return Zend_View_Helper_Navigation_Links fluent interface, returns
- * self
- */
- public function links(Zend_Navigation_Container $container = null)
- {
- if (null !== $container) {
- $this->setContainer($container);
- }
-
- return $this;
- }
-
- /**
- * Magic overload: Proxy calls to {@link findRelation()} or container
- *
- * Examples of finder calls:
- *
- * // METHOD // SAME AS
- * $h->findRelNext($page); // $h->findRelation($page, 'rel', 'next')
- * $h->findRevSection($page); // $h->findRelation($page, 'rev', 'section');
- * $h->findRelFoo($page); // $h->findRelation($page, 'rel', 'foo');
- *
- *
- * @param string $method method name
- * @param array $arguments method arguments
- * @throws Zend_Navigation_Exception if method does not exist in container
- */
- public function __call($method, array $arguments = array())
- {
- if (@preg_match('/find(Rel|Rev)(.+)/', $method, $match)) {
- return $this->findRelation($arguments[0],
- strtolower($match[1]),
- strtolower($match[2]));
- }
-
- return parent::__call($method, $arguments);
- }
-
- // Accessors:
-
- /**
- * Sets the helper's render flag
- *
- * The helper uses the bitwise '&' operator against the hex values of the
- * render constants. This means that the flag can is "bitwised" value of
- * the render constants. Examples:
- *
- * // render all links except glossary
- * $flag = Zend_View_Helper_Navigation_Links:RENDER_ALL ^
- * Zend_View_Helper_Navigation_Links:RENDER_GLOSSARY;
- * $helper->setRenderFlag($flag);
- *
- * // render only chapters and sections
- * $flag = Zend_View_Helper_Navigation_Links:RENDER_CHAPTER |
- * Zend_View_Helper_Navigation_Links:RENDER_SECTION;
- * $helper->setRenderFlag($flag);
- *
- * // render only relations that are not native W3C relations
- * $helper->setRenderFlag(Zend_View_Helper_Navigation_Links:RENDER_CUSTOM);
- *
- * // render all relations (default)
- * $helper->setRenderFlag(Zend_View_Helper_Navigation_Links:RENDER_ALL);
- *
- *
- * Note that custom relations can also be rendered directly using the
- * {@link renderLink()} method.
- *
- * @param int $renderFlag render flag
- * @return Zend_View_Helper_Navigation_Links fluent interface, returns self
- */
- public function setRenderFlag($renderFlag)
- {
- $this->_renderFlag = (int) $renderFlag;
- return $this;
- }
-
- /**
- * Returns the helper's render flag
- *
- * @return int render flag
- */
- public function getRenderFlag()
- {
- return $this->_renderFlag;
- }
-
- // Finder methods:
-
- /**
- * Finds all relations (forward and reverse) for the given $page
- *
- * The form of the returned array:
- *
- * // $page denotes an instance of Zend_Navigation_Page
- * $returned = array(
- * 'rel' => array(
- * 'alternate' => array($page, $page, $page),
- * 'start' => array($page),
- * 'next' => array($page),
- * 'prev' => array($page),
- * 'canonical' => array($page)
- * ),
- * 'rev' => array(
- * 'section' => array($page)
- * )
- * );
- *
- *
- * @param Zend_Navigation_Page $page page to find links for
- * @return array related pages
- */
- public function findAllRelations(Zend_Navigation_Page $page,
- $flag = null)
- {
- if (!is_int($flag)) {
- $flag = self::RENDER_ALL;
- }
-
- $result = array('rel' => array(), 'rev' => array());
- $native = array_values(self::$_RELATIONS);
-
- foreach (array_keys($result) as $rel) {
- $meth = 'getDefined' . ucfirst($rel);
- $types = array_merge($native, array_diff($page->$meth(), $native));
-
- foreach ($types as $type) {
- if (!$relFlag = array_search($type, self::$_RELATIONS)) {
- $relFlag = self::RENDER_CUSTOM;
- }
- if (!($flag & $relFlag)) {
- continue;
- }
- if ($found = $this->findRelation($page, $rel, $type)) {
- if (!is_array($found)) {
- $found = array($found);
- }
- $result[$rel][$type] = $found;
- }
- }
- }
-
- return $result;
- }
-
- /**
- * Finds relations of the given $rel=$type from $page
- *
- * This method will first look for relations in the page instance, then
- * by searching the root container if nothing was found in the page.
- *
- * @param Zend_Navigation_Page $page page to find relations for
- * @param string $rel relation, "rel" or "rev"
- * @param string $type link type, e.g. 'start', 'next'
- * @return Zend_Navigaiton_Page|array|null page(s), or null if not found
- * @throws Zend_View_Exception if $rel is not "rel" or "rev"
- */
- public function findRelation(Zend_Navigation_Page $page, $rel, $type)
- {
- if (!in_array($rel, array('rel', 'rev'))) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf(
- 'Invalid argument: $rel must be "rel" or "rev"; "%s" given',
- $rel));
- $e->setView($this->view);
- throw $e;
- }
-
- if (!$result = $this->_findFromProperty($page, $rel, $type)) {
- $result = $this->_findFromSearch($page, $rel, $type);
- }
-
- return $result;
- }
-
- /**
- * Finds relations of given $type for $page by checking if the
- * relation is specified as a property of $page
- *
- * @param Zend_Navigation_Page $page page to find relations for
- * @param string $rel relation, 'rel' or 'rev'
- * @param string $type link type, e.g. 'start', 'next'
- * @return Zend_Navigation_Page|array|null page(s), or null if not found
- */
- protected function _findFromProperty(Zend_Navigation_Page $page, $rel, $type)
- {
- $method = 'get' . ucfirst($rel);
- if ($result = $page->$method($type)) {
- if ($result = $this->_convertToPages($result)) {
- if (!is_array($result)) {
- $result = array($result);
- }
-
- foreach ($result as $key => $page) {
- if (!$this->accept($page)) {
- unset($result[$key]);
- }
- }
-
- return count($result) == 1 ? $result[0] : $result;
- }
- }
-
- return null;
- }
-
- /**
- * Finds relations of given $rel=$type for $page by using the helper to
- * search for the relation in the root container
- *
- * @param Zend_Navigation_Page $page page to find relations for
- * @param string $rel relation, 'rel' or 'rev'
- * @param string $type link type, e.g. 'start', 'next', etc
- * @return array|null array of pages, or null if not found
- */
- protected function _findFromSearch(Zend_Navigation_Page $page, $rel, $type)
- {
- $found = null;
-
- $method = 'search' . ucfirst($rel) . ucfirst($type);
- if (method_exists($this, $method)) {
- $found = $this->$method($page);
- }
-
- return $found;
- }
-
- // Search methods:
-
- /**
- * Searches the root container for the forward 'start' relation of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to the first document in a collection of documents. This link type
- * tells search engines which document is considered by the author to be the
- * starting point of the collection.
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|null page or null
- */
- public function searchRelStart(Zend_Navigation_Page $page)
- {
- $found = $this->_findRoot($page);
- if (!$found instanceof Zend_Navigation_Page) {
- $found->rewind();
- $found = $found->current();
- }
-
- if ($found === $page || !$this->accept($found)) {
- $found = null;
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for the forward 'next' relation of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to the next document in a linear sequence of documents. User
- * agents may choose to preload the "next" document, to reduce the perceived
- * load time.
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|null page(s) or null
- */
- public function searchRelNext(Zend_Navigation_Page $page)
- {
- $found = null;
- $break = false;
- $iterator = new RecursiveIteratorIterator($this->_findRoot($page),
- RecursiveIteratorIterator::SELF_FIRST);
- foreach ($iterator as $intermediate) {
- if ($intermediate === $page) {
- // current page; break at next accepted page
- $break = true;
- continue;
- }
-
- if ($break && $this->accept($intermediate)) {
- $found = $intermediate;
- break;
- }
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for the forward 'prev' relation of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to the previous document in an ordered series of documents. Some
- * user agents also support the synonym "Previous".
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|null page or null
- */
- public function searchRelPrev(Zend_Navigation_Page $page)
- {
- $found = null;
- $prev = null;
- $iterator = new RecursiveIteratorIterator(
- $this->_findRoot($page),
- RecursiveIteratorIterator::SELF_FIRST);
- foreach ($iterator as $intermediate) {
- if (!$this->accept($intermediate)) {
- continue;
- }
- if ($intermediate === $page) {
- $found = $prev;
- break;
- }
-
- $prev = $intermediate;
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for forward 'chapter' relations of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a chapter in a collection of documents.
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|array|null page(s) or null
- */
- public function searchRelChapter(Zend_Navigation_Page $page)
- {
- $found = array();
-
- // find first level of pages
- $root = $this->_findRoot($page);
-
- // find start page(s)
- $start = $this->findRelation($page, 'rel', 'start');
- if (!is_array($start)) {
- $start = array($start);
- }
-
- foreach ($root as $chapter) {
- // exclude self and start page from chapters
- if ($chapter !== $page &&
- !in_array($chapter, $start) &&
- $this->accept($chapter)) {
- $found[] = $chapter;
- }
- }
-
- switch (count($found)) {
- case 0:
- return null;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Searches the root container for forward 'section' relations of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a section in a collection of documents.
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|array|null page(s) or null
- */
- public function searchRelSection(Zend_Navigation_Page $page)
- {
- $found = array();
-
- // check if given page has pages and is a chapter page
- if ($page->hasPages() && $this->_findRoot($page)->hasPage($page)) {
- foreach ($page as $section) {
- if ($this->accept($section)) {
- $found[] = $section;
- }
- }
- }
-
- switch (count($found)) {
- case 0:
- return null;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Searches the root container for forward 'subsection' relations of the
- * given $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a subsection in a collection of
- * documents.
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|array|null page(s) or null
- */
- public function searchRelSubsection(Zend_Navigation_Page $page)
- {
- $found = array();
-
- if ($page->hasPages()) {
- // given page has child pages, loop chapters
- foreach ($this->_findRoot($page) as $chapter) {
- // is page a section?
- if ($chapter->hasPage($page)) {
- foreach ($page as $subsection) {
- if ($this->accept($subsection)) {
- $found[] = $subsection;
- }
- }
- }
- }
- }
-
- switch (count($found)) {
- case 0:
- return null;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Searches the root container for the reverse 'section' relation of the
- * given $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a section in a collection of documents.
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|null page(s) or null
- */
- public function searchRevSection(Zend_Navigation_Page $page)
- {
- $found = null;
-
- if ($parent = $page->getParent()) {
- if ($parent instanceof Zend_Navigation_Page &&
- $this->_findRoot($page)->hasPage($parent)) {
- $found = $parent;
- }
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for the reverse 'section' relation of the
- * given $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a subsection in a collection of
- * documents.
- *
- * @param Zend_Navigation_Page $page page to find relation for
- * @return Zend_Navigation_Page|null page(s) or null
- */
- public function searchRevSubsection(Zend_Navigation_Page $page)
- {
- $found = null;
-
- if ($parent = $page->getParent()) {
- if ($parent instanceof Zend_Navigation_Page) {
- $root = $this->_findRoot($page);
- foreach ($root as $chapter) {
- if ($chapter->hasPage($parent)) {
- $found = $parent;
- break;
- }
- }
- }
- }
-
- return $found;
- }
-
- // Util methods:
-
- /**
- * Returns the root container of the given page
- *
- * When rendering a container, the render method still store the given
- * container as the root container, and unset it when done rendering. This
- * makes sure finder methods will not traverse above the container given
- * to the render method.
- *
- * @param Zend_Navigaiton_Page $page page to find root for
- * @return Zend_Navigation_Container the root container of the given page
- */
- protected function _findRoot(Zend_Navigation_Page $page)
- {
- if ($this->_root) {
- return $this->_root;
- }
-
- $root = $page;
-
- while ($parent = $page->getParent()) {
- $root = $parent;
- if ($parent instanceof Zend_Navigation_Page) {
- $page = $parent;
- } else {
- break;
- }
- }
-
- return $root;
- }
-
- /**
- * Converts a $mixed value to an array of pages
- *
- * @param mixed $mixed mixed value to get page(s) from
- * @param bool $recursive whether $value should be looped
- * if it is an array or a config
- * @return Zend_Navigation_Page|array|null empty if unable to convert
- */
- protected function _convertToPages($mixed, $recursive = true)
- {
- if (is_object($mixed)) {
- if ($mixed instanceof Zend_Navigation_Page) {
- // value is a page instance; return directly
- return $mixed;
- } elseif ($mixed instanceof Zend_Navigation_Container) {
- // value is a container; return pages in it
- $pages = array();
- foreach ($mixed as $page) {
- $pages[] = $page;
- }
- return $pages;
- } elseif ($mixed instanceof Zend_Config) {
- // convert config object to array and extract
- return $this->_convertToPages($mixed->toArray(), $recursive);
- }
- } elseif (is_string($mixed)) {
- // value is a string; make an URI page
- return Zend_Navigation_Page::factory(array(
- 'type' => 'uri',
- 'uri' => $mixed
- ));
- } elseif (is_array($mixed) && !empty($mixed)) {
- if ($recursive && is_numeric(key($mixed))) {
- // first key is numeric; assume several pages
- $pages = array();
- foreach ($mixed as $value) {
- if ($value = $this->_convertToPages($value, false)) {
- $pages[] = $value;
- }
- }
- return $pages;
- } else {
- // pass array to factory directly
- try {
- $page = Zend_Navigation_Page::factory($mixed);
- return $page;
- } catch (Exception $e) {
- }
- }
- }
-
- // nothing found
- return null;
- }
-
- // Render methods:
-
- /**
- * Renders the given $page as a link element, with $attrib = $relation
- *
- * @param Zend_Navigation_Page $page the page to render the link for
- * @param string $attrib the attribute to use for $type,
- * either 'rel' or 'rev'
- * @param string $relation relation type, muse be one of;
- * alternate, appendix, bookmark,
- * chapter, contents, copyright,
- * glossary, help, home, index, next,
- * prev, section, start, stylesheet,
- * subsection
- * @return string rendered link element
- * @throws Zend_View_Exception if $attrib is invalid
- */
- public function renderLink(Zend_Navigation_Page $page, $attrib, $relation)
- {
- if (!in_array($attrib, array('rel', 'rev'))) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf(
- 'Invalid relation attribute "%s", must be "rel" or "rev"',
- $attrib));
- $e->setView($this->view);
- throw $e;
- }
-
- if (!$href = $page->getHref()) {
- return '';
- }
-
- // TODO: add more attribs
- // http://www.w3.org/TR/html401/struct/links.html#h-12.2
- $attribs = array(
- $attrib => $relation,
- 'href' => $href,
- 'title' => $page->getLabel()
- );
-
- return ' _htmlAttribs($attribs) .
- $this->getClosingBracket();
- }
-
- // Zend_View_Helper_Navigation_Helper:
-
- /**
- * Renders helper
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::render()}.
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * render. Default is to
- * render the container
- * registered in the helper.
- * @return string helper output
- */
- public function render(Zend_Navigation_Container $container = null)
- {
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- if ($active = $this->findActive($container)) {
- $active = $active['page'];
- } else {
- // no active page
- return '';
- }
-
- $output = '';
- $indent = $this->getIndent();
- $this->_root = $container;
-
- $result = $this->findAllRelations($active, $this->getRenderFlag());
- foreach ($result as $attrib => $types) {
- foreach ($types as $relation => $pages) {
- foreach ($pages as $page) {
- if ($r = $this->renderLink($page, $attrib, $relation)) {
- $output .= $indent . $r . $this->getEOL();
- }
- }
- }
- }
-
- $this->_root = null;
-
- // return output (trim last newline by spec)
- return strlen($output) ? rtrim($output, self::EOL) : '';
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Navigation/Menu.php b/lib/zend/Zend/View/Helper/Navigation/Menu.php
deleted file mode 100644
index da3faee84a87e..0000000000000
--- a/lib/zend/Zend/View/Helper/Navigation/Menu.php
+++ /dev/null
@@ -1,1099 +0,0 @@
-setContainer($container);
- }
-
- return $this;
- }
-
- // Accessors:
-
- /**
- * Sets CSS class to use for the first 'ul' element when rendering
- *
- * @param string $ulClass CSS class to set
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setUlClass($ulClass)
- {
- if (is_string($ulClass)) {
- $this->_ulClass = $ulClass;
- }
-
- return $this;
- }
-
- /**
- * Returns CSS class to use for the first 'ul' element when rendering
- *
- * @return string CSS class
- */
- public function getUlClass()
- {
- return $this->_ulClass;
- }
-
- /**
- * Sets unique identifier (id) to use for the first 'ul' element when
- * rendering
- *
- * @param string|null $ulId Unique identifier (id) to set
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setUlId($ulId)
- {
- if (is_string($ulId)) {
- $this->_ulId = $ulId;
- }
-
- return $this;
- }
-
- /**
- * Returns unique identifier (id) to use for the first 'ul' element when
- * rendering
- *
- * @return string|null Unique identifier (id); Default is 'null'
- */
- public function getUlId()
- {
- return $this->_ulId;
- }
-
- /**
- * Sets CSS class to use for the active elements when rendering
- *
- * @param string $activeClass CSS class to set
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setActiveClass($activeClass)
- {
- if (is_string($activeClass)) {
- $this->_activeClass = $activeClass;
- }
-
- return $this;
- }
-
- /**
- * Returns CSS class to use for the active elements when rendering
- *
- * @return string CSS class
- */
- public function getActiveClass()
- {
- return $this->_activeClass;
- }
-
- /**
- * Sets CSS class to use for the parent li elements when rendering
- *
- * @param string $parentClass CSS class to set to parents
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setParentClass($parentClass)
- {
- if (is_string($parentClass)) {
- $this->_parentClass = $parentClass;
- }
-
- return $this;
- }
-
- /**
- * Returns CSS class to use for the parent lie elements when rendering
- *
- * @return string CSS class
- */
- public function getParentClass()
- {
- return $this->_parentClass;
- }
-
- /**
- * Enables/disables rendering of parent class to the li element
- *
- * @param bool $flag [optional] render with parent
- * class. Default is true.
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setRenderParentClass($flag = true)
- {
- $this->_renderParentClass = (bool) $flag;
- return $this;
- }
-
- /**
- * Returns flag indicating whether parent class should be rendered to the li
- * element
- *
- * @return bool whether parent class should be rendered
- */
- public function getRenderParentClass()
- {
- return $this->_renderParentClass;
- }
-
- /**
- * Sets a flag indicating whether only active branch should be rendered
- *
- * @param bool $flag [optional] render only active
- * branch. Default is true.
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setOnlyActiveBranch($flag = true)
- {
- $this->_onlyActiveBranch = (bool) $flag;
- return $this;
- }
-
- /**
- * Returns a flag indicating whether only active branch should be rendered
- *
- * By default, this value is false, meaning the entire menu will be
- * be rendered.
- *
- * @return bool whether only active branch should be rendered
- */
- public function getOnlyActiveBranch()
- {
- return $this->_onlyActiveBranch;
- }
-
- /**
- * Sets a flag indicating whether to expand all sibling nodes of the active branch
- *
- * @param bool $flag [optional] expand all siblings of
- * nodes in the active branch. Default is true.
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setExpandSiblingNodesOfActiveBranch($flag = true)
- {
- $this->_expandSiblingNodesOfActiveBranch = (bool) $flag;
- return $this;
- }
-
- /**
- * Returns a flag indicating whether to expand all sibling nodes of the active branch
- *
- * By default, this value is false, meaning the entire menu will be
- * be rendered.
- *
- * @return bool whether siblings of nodes in the active branch should be expanded
- */
- public function getExpandSiblingNodesOfActiveBranch()
- {
- return $this->_expandSiblingNodesOfActiveBranch;
- }
-
- /**
- * Enables/disables rendering of parents when only rendering active branch
- *
- * See {@link setOnlyActiveBranch()} for more information.
- *
- * @param bool $flag [optional] render parents when
- * rendering active branch.
- * Default is true.
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setRenderParents($flag = true)
- {
- $this->_renderParents = (bool) $flag;
- return $this;
- }
-
- /**
- * Returns flag indicating whether parents should be rendered when rendering
- * only the active branch
- *
- * By default, this value is true.
- *
- * @return bool whether parents should be rendered
- */
- public function getRenderParents()
- {
- return $this->_renderParents;
- }
-
- /**
- * Sets which partial view script to use for rendering menu
- *
- * @param string|array $partial partial view script or null. If
- * an array is given, it is
- * expected to contain two values;
- * the partial view script to use,
- * and the module where the script
- * can be found.
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function setPartial($partial)
- {
- if (null === $partial || is_string($partial) || is_array($partial)) {
- $this->_partial = $partial;
- }
-
- return $this;
- }
-
- /**
- * Returns partial view script to use for rendering menu
- *
- * @return string|array|null
- */
- public function getPartial()
- {
- return $this->_partial;
- }
-
- /**
- * Adds CSS class from page to li element
- *
- * Before:
- *
- *
- * Bar
- *
- *
- *
- * After:
- *
- *
- * Bar
- *
- *
- *
- * @param bool $flag [optional] adds CSS class from
- * page to li element
- *
- * @return Zend_View_Helper_Navigation_Menu fluent interface, returns self
- */
- public function addPageClassToLi($flag = true)
- {
- $this->_addPageClassToLi = (bool) $flag;
-
- return $this;
- }
-
- /**
- * Returns a flag indicating whether the CSS class from page to be added to
- * li element
- *
- * @return bool
- */
- public function getAddPageClassToLi()
- {
- return $this->_addPageClassToLi;
- }
-
- /**
- * Set the inner indentation string for using in {@link render()}, optionally
- * a number of spaces to indent with
- *
- * @param string|int $indent indentation string or
- * number of spaces
- * @return Zend_View_Helper_Navigation_HelperAbstract fluent interface,
- * returns self
- */
- public function setInnerIndent($indent)
- {
- $this->_innerIndent = $this->_getWhitespace($indent);
-
- return $this;
- }
-
- /**
- * Returns inner indentation (format output is respected)
- *
- * @see getFormatOutput()
- *
- * @return string indentation string or an empty string
- */
- public function getInnerIndent()
- {
- if (false === $this->getFormatOutput()) {
- return '';
- }
-
- return $this->_innerIndent;
- }
-
- // Public methods:
-
- /**
- * Returns an HTML string containing an 'a' element for the given page if
- * the page's href is not empty, and a 'span' element if it is empty
- *
- * Overrides {@link Zend_View_Helper_Navigation_Abstract::htmlify()}.
- *
- * @param Zend_Navigation_Page $page page to generate HTML for
- * @return string HTML string for the given page
- */
- public function htmlify(Zend_Navigation_Page $page)
- {
- // get label and title for translating
- $label = $page->getLabel();
- $title = $page->getTitle();
-
- // translate label and title?
- if ($this->getUseTranslator() && $t = $this->getTranslator()) {
- if (is_string($label) && !empty($label)) {
- $label = $t->translate($label);
- }
- if (is_string($title) && !empty($title)) {
- $title = $t->translate($title);
- }
- }
-
- // get attribs for element
- $attribs = array(
- 'id' => $page->getId(),
- 'title' => $title,
- );
-
- if (false === $this->getAddPageClassToLi()) {
- $attribs['class'] = $page->getClass();
- }
-
- // does page have a href?
- if ($href = $page->getHref()) {
- $element = 'a';
- $attribs['href'] = $href;
- $attribs['target'] = $page->getTarget();
- $attribs['accesskey'] = $page->getAccessKey();
- } else {
- $element = 'span';
- }
-
- // Add custom HTML attributes
- $attribs = array_merge($attribs, $page->getCustomHtmlAttribs());
-
- return '<' . $element . $this->_htmlAttribs($attribs) . '>'
- . $this->view->escape($label)
- . '' . $element . '>';
- }
-
- /**
- * Normalizes given render options
- *
- * @param array $options [optional] options to normalize
- * @return array normalized options
- */
- protected function _normalizeOptions(array $options = array())
- {
- // Ident
- if (isset($options['indent'])) {
- $options['indent'] = $this->_getWhitespace($options['indent']);
- } else {
- $options['indent'] = $this->getIndent();
- }
-
- // Inner ident
- if (isset($options['innerIndent'])) {
- $options['innerIndent'] =
- $this->_getWhitespace($options['innerIndent']);
- } else {
- $options['innerIndent'] = $this->getInnerIndent();
- }
-
- // UL class
- if (isset($options['ulClass']) && $options['ulClass'] !== null) {
- $options['ulClass'] = (string) $options['ulClass'];
- } else {
- $options['ulClass'] = $this->getUlClass();
- }
-
- // UL id
- if (isset($options['ulId']) && $options['ulId'] !== null) {
- $options['ulId'] = (string) $options['ulId'];
- } else {
- $options['ulId'] = $this->getUlId();
- }
-
- // Active class
- if (isset($options['activeClass']) && $options['activeClass'] !== null
- ) {
- $options['activeClass'] = (string) $options['activeClass'];
- } else {
- $options['activeClass'] = $this->getActiveClass();
- }
-
- // Parent class
- if (isset($options['parentClass']) && $options['parentClass'] !== null) {
- $options['parentClass'] = (string) $options['parentClass'];
- } else {
- $options['parentClass'] = $this->getParentClass();
- }
-
- // Minimum depth
- if (array_key_exists('minDepth', $options)) {
- if (null !== $options['minDepth']) {
- $options['minDepth'] = (int) $options['minDepth'];
- }
- } else {
- $options['minDepth'] = $this->getMinDepth();
- }
-
- if ($options['minDepth'] < 0 || $options['minDepth'] === null) {
- $options['minDepth'] = 0;
- }
-
- // Maximum depth
- if (array_key_exists('maxDepth', $options)) {
- if (null !== $options['maxDepth']) {
- $options['maxDepth'] = (int) $options['maxDepth'];
- }
- } else {
- $options['maxDepth'] = $this->getMaxDepth();
- }
-
- // Only active branch
- if (!isset($options['onlyActiveBranch'])) {
- $options['onlyActiveBranch'] = $this->getOnlyActiveBranch();
- }
-
- // Expand sibling nodes of active branch
- if (!isset($options['expandSiblingNodesOfActiveBranch'])) {
- $options['expandSiblingNodesOfActiveBranch'] = $this->getExpandSiblingNodesOfActiveBranch();
- }
-
- // Render parents?
- if (!isset($options['renderParents'])) {
- $options['renderParents'] = $this->getRenderParents();
- }
-
- // Render parent class?
- if (!isset($options['renderParentClass'])) {
- $options['renderParentClass'] = $this->getRenderParentClass();
- }
-
- // Add page CSS class to LI element
- if (!isset($options['addPageClassToLi'])) {
- $options['addPageClassToLi'] = $this->getAddPageClassToLi();
- }
-
- return $options;
- }
-
- // Render methods:
-
- /**
- * Renders the deepest active menu within [$minDepth, $maxDeth], (called
- * from {@link renderMenu()})
- *
- * @param Zend_Navigation_Container $container container to render
- * @param string $ulClass CSS class for first UL
- * @param string $indent initial indentation
- * @param string $innerIndent inner indentation
- * @param int|null $minDepth minimum depth
- * @param int|null $maxDepth maximum depth
- * @param string|null $ulId unique identifier (id)
- * for first UL
- * @param bool $addPageClassToLi adds CSS class from
- * page to li element
- * @param string|null $activeClass CSS class for active
- * element
- * @param string $parentClass CSS class for parent
- * li's
- * @param bool $renderParentClass Render parent class?
- * @return string rendered menu (HTML)
- */
- protected function _renderDeepestMenu(Zend_Navigation_Container $container,
- $ulClass,
- $indent,
- $innerIndent,
- $minDepth,
- $maxDepth,
- $ulId,
- $addPageClassToLi,
- $activeClass,
- $parentClass,
- $renderParentClass)
- {
- if (!$active = $this->findActive($container, $minDepth - 1, $maxDepth)) {
- return '';
- }
-
- // special case if active page is one below minDepth
- if ($active['depth'] < $minDepth) {
- if (!$active['page']->hasPages()) {
- return '';
- }
- } else if (!$active['page']->hasPages()) {
- // found pages has no children; render siblings
- $active['page'] = $active['page']->getParent();
- } else if (is_int($maxDepth) && $active['depth'] + 1 > $maxDepth) {
- // children are below max depth; render siblings
- $active['page'] = $active['page']->getParent();
- }
-
- $attribs = array(
- 'class' => $ulClass,
- 'id' => $ulId,
- );
-
- // We don't need a prefix for the menu ID (backup)
- $skipValue = $this->_skipPrefixForId;
- $this->skipPrefixForId();
-
- $html = $indent . '_htmlAttribs($attribs)
- . '>'
- . $this->getEOL();
-
- // Reset prefix for IDs
- $this->_skipPrefixForId = $skipValue;
-
- foreach ($active['page'] as $subPage) {
- if (!$this->accept($subPage)) {
- continue;
- }
-
- $liClass = '';
- if ($subPage->isActive(true) && $addPageClassToLi) {
- $liClass = $this->_htmlAttribs(
- array('class' => $activeClass . ' ' . $subPage->getClass())
- );
- } else if ($subPage->isActive(true)) {
- $liClass = $this->_htmlAttribs(array('class' => $activeClass));
- } else if ($addPageClassToLi) {
- $liClass = $this->_htmlAttribs(
- array('class' => $subPage->getClass())
- );
- }
- $html .= $indent . $innerIndent . '' . $this->getEOL();
- $html .= $indent . str_repeat($innerIndent, 2) . $this->htmlify($subPage)
- . $this->getEOL();
- $html .= $indent . $innerIndent . ' ' . $this->getEOL();
- }
-
- $html .= $indent . ' ';
-
- return $html;
- }
-
- /**
- * Renders a normal menu (called from {@link renderMenu()})
- *
- * @param Zend_Navigation_Container $container container to render
- * @param string $ulClass CSS class for first UL
- * @param string $indent initial indentation
- * @param string $innerIndent inner indentation
- * @param int|null $minDepth minimum depth
- * @param int|null $maxDepth maximum depth
- * @param bool $onlyActive render only active branch?
- * @param bool $expandSibs render siblings of active
- * branch nodes?
- * @param string|null $ulId unique identifier (id)
- * for first UL
- * @param bool $addPageClassToLi adds CSS class from
- * page to li element
- * @param string|null $activeClass CSS class for active
- * element
- * @param string $parentClass CSS class for parent
- * li's
- * @param bool $renderParentClass Render parent class?
- * @return string rendered menu (HTML)
- */
- protected function _renderMenu(Zend_Navigation_Container $container,
- $ulClass,
- $indent,
- $innerIndent,
- $minDepth,
- $maxDepth,
- $onlyActive,
- $expandSibs,
- $ulId,
- $addPageClassToLi,
- $activeClass,
- $parentClass,
- $renderParentClass)
- {
- $html = '';
-
- // find deepest active
- if ($found = $this->findActive($container, $minDepth, $maxDepth)) {
- $foundPage = $found['page'];
- $foundDepth = $found['depth'];
- } else {
- $foundPage = null;
- }
-
- // create iterator
- $iterator = new RecursiveIteratorIterator($container,
- RecursiveIteratorIterator::SELF_FIRST);
- if (is_int($maxDepth)) {
- $iterator->setMaxDepth($maxDepth);
- }
-
- // iterate container
- $prevDepth = -1;
- foreach ($iterator as $page) {
- $depth = $iterator->getDepth();
- $isActive = $page->isActive(true);
- if ($depth < $minDepth || !$this->accept($page)) {
- // page is below minDepth or not accepted by acl/visibilty
- continue;
- } else if ($expandSibs && $depth > $minDepth) {
- // page is not active itself, but might be in the active branch
- $accept = false;
- if ($foundPage) {
- if ($foundPage->hasPage($page)) {
- // accept if page is a direct child of the active page
- $accept = true;
- } else if ($page->getParent()->isActive(true)) {
- // page is a sibling of the active branch...
- $accept = true;
- }
- }
- if (!$isActive && !$accept) {
- continue;
- }
- } else if ($onlyActive && !$isActive) {
- // page is not active itself, but might be in the active branch
- $accept = false;
- if ($foundPage) {
- if ($foundPage->hasPage($page)) {
- // accept if page is a direct child of the active page
- $accept = true;
- } else if ($foundPage->getParent()->hasPage($page)) {
- // page is a sibling of the active page...
- if (!$foundPage->hasPages() ||
- is_int($maxDepth) && $foundDepth + 1 > $maxDepth) {
- // accept if active page has no children, or the
- // children are too deep to be rendered
- $accept = true;
- }
- }
- }
-
- if (!$accept) {
- continue;
- }
- }
-
- // make sure indentation is correct
- $depth -= $minDepth;
- $myIndent = $indent . str_repeat($innerIndent, $depth * 2);
-
- if ($depth > $prevDepth) {
- $attribs = array();
-
- // start new ul tag
- if (0 == $depth) {
- $attribs = array(
- 'class' => $ulClass,
- 'id' => $ulId,
- );
- }
-
- // We don't need a prefix for the menu ID (backup)
- $skipValue = $this->_skipPrefixForId;
- $this->skipPrefixForId();
-
- $html .= $myIndent . '_htmlAttribs($attribs)
- . '>'
- . $this->getEOL();
-
- // Reset prefix for IDs
- $this->_skipPrefixForId = $skipValue;
- } else if ($prevDepth > $depth) {
- // close li/ul tags until we're at current depth
- for ($i = $prevDepth; $i > $depth; $i--) {
- $ind = $indent . str_repeat($innerIndent, $i * 2);
- $html .= $ind . $innerIndent . '' . $this->getEOL();
- $html .= $ind . ' ' . $this->getEOL();
- }
- // close previous li tag
- $html .= $myIndent . $innerIndent . '' . $this->getEOL();
- } else {
- // close previous li tag
- $html .= $myIndent . $innerIndent . '' . $this->getEOL();
- }
-
- // render li tag and page
- $liClasses = array();
- // Is page active?
- if ($isActive) {
- $liClasses[] = $activeClass;
- }
- // Add CSS class from page to LI?
- if ($addPageClassToLi) {
- $liClasses[] = $page->getClass();
- }
- // Add CSS class for parents to LI?
- if ($renderParentClass && $page->hasChildren()) {
- // Check max depth
- if ((is_int($maxDepth) && ($depth + 1 < $maxDepth))
- || !is_int($maxDepth)
- ) {
- $liClasses[] = $parentClass;
- }
- }
-
- $html .= $myIndent . $innerIndent . '_htmlAttribs(array('class' => implode(' ', $liClasses)))
- . '>' . $this->getEOL()
- . $myIndent . str_repeat($innerIndent, 2)
- . $this->htmlify($page)
- . $this->getEOL();
-
- // store as previous depth for next iteration
- $prevDepth = $depth;
- }
-
- if ($html) {
- // done iterating container; close open ul/li tags
- for ($i = $prevDepth+1; $i > 0; $i--) {
- $myIndent = $indent . str_repeat($innerIndent . $innerIndent, $i - 1);
- $html .= $myIndent . $innerIndent . ' ' . $this->getEOL()
- . $myIndent . '' . $this->getEOL();
- }
- $html = rtrim($html, $this->getEOL());
- }
-
- return $html;
- }
-
- /**
- * Renders helper
- *
- * Renders a HTML 'ul' for the given $container. If $container is not given,
- * the container registered in the helper will be used.
- *
- * Available $options:
- *
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * create menu from. Default
- * is to use the container
- * retrieved from
- * {@link getContainer()}.
- * @param array $options [optional] options for
- * controlling rendering
- * @return string rendered menu
- */
- public function renderMenu(Zend_Navigation_Container $container = null,
- array $options = array())
- {
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- $options = $this->_normalizeOptions($options);
-
- if ($options['onlyActiveBranch'] && !$options['renderParents']) {
- $html = $this->_renderDeepestMenu(
- $container,
- $options['ulClass'],
- $options['indent'],
- $options['innerIndent'],
- $options['minDepth'],
- $options['maxDepth'],
- $options['ulId'],
- $options['addPageClassToLi'],
- $options['activeClass'],
- $options['parentClass'],
- $options['renderParentClass']
- );
- } else {
- $html = $this->_renderMenu(
- $container,
- $options['ulClass'],
- $options['indent'],
- $options['innerIndent'],
- $options['minDepth'],
- $options['maxDepth'],
- $options['onlyActiveBranch'],
- $options['expandSiblingNodesOfActiveBranch'],
- $options['ulId'],
- $options['addPageClassToLi'],
- $options['activeClass'],
- $options['parentClass'],
- $options['renderParentClass']
- );
- }
-
- return $html;
- }
-
- /**
- * Renders the inner-most sub menu for the active page in the $container
- *
- * This is a convenience method which is equivalent to the following call:
- *
- * renderMenu($container, array(
- * 'indent' => $indent,
- * 'ulClass' => $ulClass,
- * 'minDepth' => null,
- * 'maxDepth' => null,
- * 'onlyActiveBranch' => true,
- * 'renderParents' => false
- * ));
- *
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * render. Default is to render
- * the container registered in
- * the helper.
- * @param string|null $ulClass [optional] CSS class to
- * use for UL element. Default
- * is to use the value from
- * {@link getUlClass()}.
- * @param string|int $indent [optional] indentation as
- * a string or number of
- * spaces. Default is to use
- * the value retrieved from
- * {@link getIndent()}.
- * @param string|null $ulId [optional] Unique identifier
- * (id) use for UL element
- * @param bool $addPageClassToLi adds CSS class from
- * page to li element
- * @param string|int $innerIndent [optional] inner
- * indentation as a string
- * or number of spaces.
- * Default is to use the
- * {@link getInnerIndent()}.
- * @return string rendered content
- */
- public function renderSubMenu(Zend_Navigation_Container $container = null,
- $ulClass = null,
- $indent = null,
- $ulId = null,
- $addPageClassToLi = false,
- $innerIndent = null)
- {
- return $this->renderMenu($container, array(
- 'indent' => $indent,
- 'innerIndent' => $innerIndent,
- 'ulClass' => $ulClass,
- 'minDepth' => null,
- 'maxDepth' => null,
- 'onlyActiveBranch' => true,
- 'renderParents' => false,
- 'ulId' => $ulId,
- 'addPageClassToLi' => $addPageClassToLi,
- ));
- }
-
- /**
- * Renders the given $container by invoking the partial view helper
- *
- * The container will simply be passed on as a model to the view script
- * as-is, and will be available in the partial script as 'container', e.g.
- * echo 'Number of pages: ', count($this->container);
.
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * pass to view script. Default
- * is to use the container
- * registered in the helper.
- * @param string|array $partial [optional] partial view
- * script to use. Default is to
- * use the partial registered
- * in the helper. If an array
- * is given, it is expected to
- * contain two values; the
- * partial view script to use,
- * and the module where the
- * script can be found.
- * @return string helper output
- *
- * @throws Zend_View_Exception When no partial script is set
- */
- public function renderPartial(Zend_Navigation_Container $container = null,
- $partial = null)
- {
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- if (null === $partial) {
- $partial = $this->getPartial();
- }
-
- if (empty($partial)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(
- 'Unable to render menu: No partial view script provided'
- );
- $e->setView($this->view);
- throw $e;
- }
-
- $model = array(
- 'container' => $container
- );
-
- if (is_array($partial)) {
- if (count($partial) != 2) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(
- 'Unable to render menu: A view partial supplied as '
- . 'an array must contain two values: partial view '
- . 'script and module where script can be found'
- );
- $e->setView($this->view);
- throw $e;
- }
-
- return $this->view->partial($partial[0], $partial[1], $model);
- }
-
- return $this->view->partial($partial, null, $model);
- }
-
- // Zend_View_Helper_Navigation_Helper:
-
- /**
- * Renders menu
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::render()}.
- *
- * If a partial view is registered in the helper, the menu will be rendered
- * using the given partial script. If no partial is registered, the menu
- * will be rendered as an 'ul' element by the helper's internal method.
- *
- * @see renderPartial()
- * @see renderMenu()
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * render. Default is to
- * render the container
- * registered in the helper.
- * @return string helper output
- */
- public function render(Zend_Navigation_Container $container = null)
- {
- if ($partial = $this->getPartial()) {
- return $this->renderPartial($container, $partial);
- } else {
- return $this->renderMenu($container);
- }
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Navigation/Sitemap.php b/lib/zend/Zend/View/Helper/Navigation/Sitemap.php
deleted file mode 100644
index b93808a2c6b66..0000000000000
--- a/lib/zend/Zend/View/Helper/Navigation/Sitemap.php
+++ /dev/null
@@ -1,444 +0,0 @@
- tag
- *
- * @var string
- */
- const SITEMAP_NS = 'http://www.sitemaps.org/schemas/sitemap/0.9';
-
- /**
- * Schema URL
- *
- * @var string
- */
- const SITEMAP_XSD = 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd';
-
- /**
- * Whether the XML declaration should be included in XML output
- *
- * @var bool
- */
- protected $_useXmlDeclaration = true;
-
- /**
- * Whether sitemap should be validated using Zend_Validate_Sitemap_*
- *
- * @var bool
- */
- protected $_useSitemapValidators = true;
-
- /**
- * Whether sitemap should be schema validated when generated
- *
- * @var bool
- */
- protected $_useSchemaValidation = false;
-
- /**
- * Server url
- *
- * @var string
- */
- protected $_serverUrl;
-
- /**
- * View helper entry point:
- * Retrieves helper and optionally sets container to operate on
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * operate on
- * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns
- * self
- */
- public function sitemap(Zend_Navigation_Container $container = null)
- {
- if (null !== $container) {
- $this->setContainer($container);
- }
-
- return $this;
- }
-
- // Accessors:
-
- /**
- * Sets whether the XML declaration should be used in output
- *
- * @param bool $useXmlDecl whether XML delcaration
- * should be rendered
- * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns
- * self
- */
- public function setUseXmlDeclaration($useXmlDecl)
- {
- $this->_useXmlDeclaration = (bool) $useXmlDecl;
- return $this;
- }
-
- /**
- * Returns whether the XML declaration should be used in output
- *
- * @return bool whether the XML declaration should be used in output
- */
- public function getUseXmlDeclaration()
- {
- return $this->_useXmlDeclaration;
- }
-
- /**
- * Sets whether sitemap should be validated using Zend_Validate_Sitemap_*
- *
- * @param bool $useSitemapValidators whether sitemap validators
- * should be used
- * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns
- * self
- */
- public function setUseSitemapValidators($useSitemapValidators)
- {
- $this->_useSitemapValidators = (bool) $useSitemapValidators;
- return $this;
- }
-
- /**
- * Returns whether sitemap should be validated using Zend_Validate_Sitemap_*
- *
- * @return bool whether sitemap should be validated using validators
- */
- public function getUseSitemapValidators()
- {
- return $this->_useSitemapValidators;
- }
-
- /**
- * Sets whether sitemap should be schema validated when generated
- *
- * @param bool $schemaValidation whether sitemap should
- * validated using XSD Schema
- * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns
- * self
- */
- public function setUseSchemaValidation($schemaValidation)
- {
- $this->_useSchemaValidation = (bool) $schemaValidation;
- return $this;
- }
-
- /**
- * Returns true if sitemap should be schema validated when generated
- *
- * @return bool
- */
- public function getUseSchemaValidation()
- {
- return $this->_useSchemaValidation;
- }
-
- /**
- * Sets server url (scheme and host-related stuff without request URI)
- *
- * E.g. http://www.example.com
- *
- * @param string $serverUrl server URL to set (only
- * scheme and host)
- * @throws Zend_Uri_Exception if invalid server URL
- * @return Zend_View_Helper_Navigation_Sitemap fluent interface, returns
- * self
- */
- public function setServerUrl($serverUrl)
- {
- require_once 'Zend/Uri.php';
- $uri = Zend_Uri::factory($serverUrl);
- $uri->setFragment('');
- $uri->setPath('');
- $uri->setQuery('');
-
- if ($uri->valid()) {
- $this->_serverUrl = $uri->getUri();
- } else {
- require_once 'Zend/Uri/Exception.php';
- $e = new Zend_Uri_Exception(sprintf(
- 'Invalid server URL: "%s"',
- $serverUrl));
- $e->setView($this->view);
- throw $e;
- }
-
- return $this;
- }
-
- /**
- * Returns server URL
- *
- * @return string server URL
- */
- public function getServerUrl()
- {
- if (!isset($this->_serverUrl)) {
- $this->_serverUrl = $this->view->serverUrl();
- }
-
- return $this->_serverUrl;
- }
-
- // Helper methods:
-
- /**
- * Escapes string for XML usage
- *
- * @param string $string string to escape
- * @return string escaped string
- */
- protected function _xmlEscape($string)
- {
- $enc = 'UTF-8';
- if ($this->view instanceof Zend_View_Interface
- && method_exists($this->view, 'getEncoding')
- ) {
- $enc = $this->view->getEncoding();
- }
-
- // do not encode existing HTML entities
- return htmlspecialchars($string, ENT_QUOTES, $enc, false);
- }
-
- // Public methods:
-
- /**
- * Returns an escaped absolute URL for the given page
- *
- * @param Zend_Navigation_Page $page page to get URL from
- * @return string
- */
- public function url(Zend_Navigation_Page $page)
- {
- $href = $page->getHref();
-
- if (!isset($href{0})) {
- // no href
- return '';
- } elseif ($href{0} == '/') {
- // href is relative to root; use serverUrl helper
- $url = $this->getServerUrl() . $href;
- } elseif (preg_match('/^[a-z]+:/im', (string) $href)) {
- // scheme is given in href; assume absolute URL already
- $url = (string) $href;
- } else {
- // href is relative to current document; use url helpers
- $url = $this->getServerUrl()
- . rtrim($this->view->url(), '/') . '/'
- . $href;
- }
-
- return $this->_xmlEscape($url);
- }
-
- /**
- * Returns a DOMDocument containing the Sitemap XML for the given container
- *
- * @param Zend_Navigation_Container $container [optional] container to get
- * breadcrumbs from, defaults
- * to what is registered in the
- * helper
- * @return DOMDocument DOM representation of the
- * container
- * @throws Zend_View_Exception if schema validation is on
- * and the sitemap is invalid
- * according to the sitemap
- * schema, or if sitemap
- * validators are used and the
- * loc element fails validation
- */
- public function getDomSitemap(Zend_Navigation_Container $container = null)
- {
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- // check if we should validate using our own validators
- if ($this->getUseSitemapValidators()) {
- require_once 'Zend/Validate/Sitemap/Changefreq.php';
- require_once 'Zend/Validate/Sitemap/Lastmod.php';
- require_once 'Zend/Validate/Sitemap/Loc.php';
- require_once 'Zend/Validate/Sitemap/Priority.php';
-
- // create validators
- $locValidator = new Zend_Validate_Sitemap_Loc();
- $lastmodValidator = new Zend_Validate_Sitemap_Lastmod();
- $changefreqValidator = new Zend_Validate_Sitemap_Changefreq();
- $priorityValidator = new Zend_Validate_Sitemap_Priority();
- }
-
- // create document
- $dom = new DOMDocument('1.0', 'UTF-8');
- $dom->formatOutput = $this->getFormatOutput();
-
- // ...and urlset (root) element
- $urlSet = $dom->createElementNS(self::SITEMAP_NS, 'urlset');
- $dom->appendChild($urlSet);
-
- // create iterator
- $iterator = new RecursiveIteratorIterator($container,
- RecursiveIteratorIterator::SELF_FIRST);
-
- $maxDepth = $this->getMaxDepth();
- if (is_int($maxDepth)) {
- $iterator->setMaxDepth($maxDepth);
- }
- $minDepth = $this->getMinDepth();
- if (!is_int($minDepth) || $minDepth < 0) {
- $minDepth = 0;
- }
-
- // iterate container
- foreach ($iterator as $page) {
- if ($iterator->getDepth() < $minDepth || !$this->accept($page)) {
- // page should not be included
- continue;
- }
-
- // get absolute url from page
- if (!$url = $this->url($page)) {
- // skip page if it has no url (rare case)
- continue;
- }
-
- // create url node for this page
- $urlNode = $dom->createElementNS(self::SITEMAP_NS, 'url');
- $urlSet->appendChild($urlNode);
-
- if ($this->getUseSitemapValidators() &&
- !$locValidator->isValid($url)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf(
- 'Encountered an invalid URL for Sitemap XML: "%s"',
- $url));
- $e->setView($this->view);
- throw $e;
- }
-
- // put url in 'loc' element
- $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS,
- 'loc', $url));
-
- // add 'lastmod' element if a valid lastmod is set in page
- if (isset($page->lastmod)) {
- $lastmod = strtotime((string) $page->lastmod);
-
- // prevent 1970-01-01...
- if ($lastmod !== false) {
- $lastmod = date('c', $lastmod);
- }
-
- if (!$this->getUseSitemapValidators() ||
- $lastmodValidator->isValid($lastmod)) {
- $urlNode->appendChild(
- $dom->createElementNS(self::SITEMAP_NS, 'lastmod',
- $lastmod)
- );
- }
- }
-
- // add 'changefreq' element if a valid changefreq is set in page
- if (isset($page->changefreq)) {
- $changefreq = $page->changefreq;
- if (!$this->getUseSitemapValidators() ||
- $changefreqValidator->isValid($changefreq)) {
- $urlNode->appendChild(
- $dom->createElementNS(self::SITEMAP_NS, 'changefreq',
- $changefreq)
- );
- }
- }
-
- // add 'priority' element if a valid priority is set in page
- if (isset($page->priority)) {
- $priority = $page->priority;
- if (!$this->getUseSitemapValidators() ||
- $priorityValidator->isValid($priority)) {
- $urlNode->appendChild(
- $dom->createElementNS(self::SITEMAP_NS, 'priority',
- $priority)
- );
- }
- }
- }
-
- // validate using schema if specified
- if ($this->getUseSchemaValidation()) {
- if (!@$dom->schemaValidate(self::SITEMAP_XSD)) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception(sprintf(
- 'Sitemap is invalid according to XML Schema at "%s"',
- self::SITEMAP_XSD));
- $e->setView($this->view);
- throw $e;
- }
- }
-
- return $dom;
- }
-
- // Zend_View_Helper_Navigation_Helper:
-
- /**
- * Renders helper
- *
- * Implements {@link Zend_View_Helper_Navigation_Helper::render()}.
- *
- * @param Zend_Navigation_Container $container [optional] container to
- * render. Default is to
- * render the container
- * registered in the helper.
- * @return string helper output
- */
- public function render(Zend_Navigation_Container $container = null)
- {
- $dom = $this->getDomSitemap($container);
-
- $xml = $this->getUseXmlDeclaration() ?
- $dom->saveXML() :
- $dom->saveXML($dom->documentElement);
-
- return rtrim($xml, self::EOL);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/PaginationControl.php b/lib/zend/Zend/View/Helper/PaginationControl.php
deleted file mode 100644
index 6f5929a22dd26..0000000000000
--- a/lib/zend/Zend/View/Helper/PaginationControl.php
+++ /dev/null
@@ -1,145 +0,0 @@
-view = $view;
- return $this;
- }
-
- /**
- * Sets the default view partial.
- *
- * @param string|array $partial View partial
- */
- public static function setDefaultViewPartial($partial)
- {
- self::$_defaultViewPartial = $partial;
- }
-
- /**
- * Gets the default view partial
- *
- * @return string|array
- */
- public static function getDefaultViewPartial()
- {
- return self::$_defaultViewPartial;
- }
-
- /**
- * Render the provided pages. This checks if $view->paginator is set and,
- * if so, uses that. Also, if no scrolling style or partial are specified,
- * the defaults will be used (if set).
- *
- * @param Zend_Paginator (Optional) $paginator
- * @param string $scrollingStyle (Optional) Scrolling style
- * @param string $partial (Optional) View partial
- * @param array|string $params (Optional) params to pass to the partial
- * @return string
- * @throws Zend_View_Exception
- */
- public function paginationControl(Zend_Paginator $paginator = null, $scrollingStyle = null, $partial = null, $params = null)
- {
- if ($paginator === null) {
- if (isset($this->view->paginator) and $this->view->paginator !== null and $this->view->paginator instanceof Zend_Paginator) {
- $paginator = $this->view->paginator;
- } else {
- /**
- * @see Zend_View_Exception
- */
- require_once 'Zend/View/Exception.php';
-
- $e = new Zend_View_Exception('No paginator instance provided or incorrect type');
- $e->setView($this->view);
- throw $e;
- }
- }
-
- if ($partial === null) {
- if (self::$_defaultViewPartial === null) {
- /**
- * @see Zend_View_Exception
- */
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('No view partial provided and no default set');
- $e->setView($this->view);
- throw $e;
- }
-
- $partial = self::$_defaultViewPartial;
- }
-
- $pages = get_object_vars($paginator->getPages($scrollingStyle));
-
- if ($params !== null) {
- $pages = array_merge($pages, (array) $params);
- }
-
- if (is_array($partial)) {
- if (count($partial) != 2) {
- /**
- * @see Zend_View_Exception
- */
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('A view partial supplied as an array must contain two values: the filename and its module');
- $e->setView($this->view);
- throw $e;
- }
-
- if ($partial[1] !== null) {
- return $this->view->partial($partial[0], $partial[1], $pages);
- }
-
- $partial = $partial[0];
- }
-
- return $this->view->partial($partial, $pages);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Partial.php b/lib/zend/Zend/View/Helper/Partial.php
deleted file mode 100644
index 733f563b9bbc6..0000000000000
--- a/lib/zend/Zend/View/Helper/Partial.php
+++ /dev/null
@@ -1,153 +0,0 @@
-cloneView();
- if (isset($this->partialCounter)) {
- $view->partialCounter = $this->partialCounter;
- }
- if (isset($this->partialTotalCount)) {
- $view->partialTotalCount = $this->partialTotalCount;
- }
-
- if ((null !== $module) && is_string($module)) {
- require_once 'Zend/Controller/Front.php';
- $moduleDir = Zend_Controller_Front::getInstance()->getControllerDirectory($module);
- if (null === $moduleDir) {
- require_once 'Zend/View/Helper/Partial/Exception.php';
- $e = new Zend_View_Helper_Partial_Exception('Cannot render partial; module does not exist');
- $e->setView($this->view);
- throw $e;
- }
- $viewsDir = dirname($moduleDir) . '/views';
- $view->addBasePath($viewsDir);
- } elseif ((null == $model) && (null !== $module)
- && (is_array($module) || is_object($module)))
- {
- $model = $module;
- }
-
- if (!empty($model)) {
- if (is_array($model)) {
- $view->assign($model);
- } elseif (is_object($model)) {
- if (null !== ($objectKey = $this->getObjectKey())) {
- $view->assign($objectKey, $model);
- } elseif (method_exists($model, 'toArray')) {
- $view->assign($model->toArray());
- } else {
- $view->assign(get_object_vars($model));
- }
- }
- }
-
- return $view->render($name);
- }
-
- /**
- * Clone the current View
- *
- * @return Zend_View_Interface
- */
- public function cloneView()
- {
- $view = clone $this->view;
- $view->clearVars();
- return $view;
- }
-
- /**
- * Set object key
- *
- * @param string $key
- * @return Zend_View_Helper_Partial
- */
- public function setObjectKey($key)
- {
- if (null === $key) {
- $this->_objectKey = null;
- } else {
- $this->_objectKey = (string) $key;
- }
-
- return $this;
- }
-
- /**
- * Retrieve object key
- *
- * The objectKey is the variable to which an object in the iterator will be
- * assigned.
- *
- * @return null|string
- */
- public function getObjectKey()
- {
- return $this->_objectKey;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Partial/Exception.php b/lib/zend/Zend/View/Helper/Partial/Exception.php
deleted file mode 100644
index 9355fd35240d9..0000000000000
--- a/lib/zend/Zend/View/Helper/Partial/Exception.php
+++ /dev/null
@@ -1,39 +0,0 @@
-setView($this->view);
- throw $e;
- }
-
- if (is_object($model)
- && (!$model instanceof Traversable)
- && method_exists($model, 'toArray')
- ) {
- $model = $model->toArray();
- }
-
- $content = '';
- // reset the counter if it's call again
- $this->partialCounter = 0;
- $this->partialTotalCount = count($model);
-
- foreach ($model as $item) {
- // increment the counter variable
- $this->partialCounter++;
-
- $content .= $this->partial($name, $module, $item);
- }
-
- return $content;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Placeholder.php b/lib/zend/Zend/View/Helper/Placeholder.php
deleted file mode 100644
index c726b401db69e..0000000000000
--- a/lib/zend/Zend/View/Helper/Placeholder.php
+++ /dev/null
@@ -1,87 +0,0 @@
-_registry = Zend_View_Helper_Placeholder_Registry::getRegistry();
- }
-
-
- /**
- * Placeholder helper
- *
- * @param string $name
- * @return Zend_View_Helper_Placeholder_Container_Abstract
- */
- public function placeholder($name)
- {
- $name = (string) $name;
- return $this->_registry->getContainer($name);
- }
-
- /**
- * Retrieve the registry
- *
- * @return Zend_View_Helper_Placeholder_Registry
- */
- public function getRegistry()
- {
- return $this->_registry;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Placeholder/Container.php b/lib/zend/Zend/View/Helper/Placeholder/Container.php
deleted file mode 100644
index 10e706d3b6eb9..0000000000000
--- a/lib/zend/Zend/View/Helper/Placeholder/Container.php
+++ /dev/null
@@ -1,36 +0,0 @@
-exchangeArray(array($value));
- }
-
- /**
- * Prepend a value to the top of the container
- *
- * @param mixed $value
- * @return void
- */
- public function prepend($value)
- {
- $values = $this->getArrayCopy();
- array_unshift($values, $value);
- $this->exchangeArray($values);
- }
-
- /**
- * Retrieve container value
- *
- * If single element registered, returns that element; otherwise,
- * serializes to array.
- *
- * @return mixed
- */
- public function getValue()
- {
- if (1 == count($this)) {
- $keys = $this->getKeys();
- $key = array_shift($keys);
- return $this[$key];
- }
-
- return $this->getArrayCopy();
- }
-
- /**
- * Set prefix for __toString() serialization
- *
- * @param string $prefix
- * @return Zend_View_Helper_Placeholder_Container
- */
- public function setPrefix($prefix)
- {
- $this->_prefix = (string) $prefix;
- return $this;
- }
-
- /**
- * Retrieve prefix
- *
- * @return string
- */
- public function getPrefix()
- {
- return $this->_prefix;
- }
-
- /**
- * Set postfix for __toString() serialization
- *
- * @param string $postfix
- * @return Zend_View_Helper_Placeholder_Container
- */
- public function setPostfix($postfix)
- {
- $this->_postfix = (string) $postfix;
- return $this;
- }
-
- /**
- * Retrieve postfix
- *
- * @return string
- */
- public function getPostfix()
- {
- return $this->_postfix;
- }
-
- /**
- * Set separator for __toString() serialization
- *
- * Used to implode elements in container
- *
- * @param string $separator
- * @return Zend_View_Helper_Placeholder_Container
- */
- public function setSeparator($separator)
- {
- $this->_separator = (string) $separator;
- return $this;
- }
-
- /**
- * Retrieve separator
- *
- * @return string
- */
- public function getSeparator()
- {
- return $this->_separator;
- }
-
- /**
- * Set the indentation string for __toString() serialization,
- * optionally, if a number is passed, it will be the number of spaces
- *
- * @param string|int $indent
- * @return Zend_View_Helper_Placeholder_Container_Abstract
- */
- public function setIndent($indent)
- {
- $this->_indent = $this->getWhitespace($indent);
- return $this;
- }
-
- /**
- * Retrieve indentation
- *
- * @return string
- */
- public function getIndent()
- {
- return $this->_indent;
- }
-
- /**
- * Retrieve whitespace representation of $indent
- *
- * @param int|string $indent
- * @return string
- */
- public function getWhitespace($indent)
- {
- if (is_int($indent)) {
- $indent = str_repeat(' ', $indent);
- }
-
- return (string) $indent;
- }
-
- /**
- * Start capturing content to push into placeholder
- *
- * @param int|string $type How to capture content into placeholder; append, prepend, or set
- * @param null $key
- * @throws Zend_View_Helper_Placeholder_Container_Exception
- * @return void
- */
- public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $key = null)
- {
- if ($this->_captureLock) {
- require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
- $e = new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest placeholder captures for the same placeholder');
- $e->setView($this->view);
- throw $e;
- }
-
- $this->_captureLock = true;
- $this->_captureType = $type;
- if ((null !== $key) && is_scalar($key)) {
- $this->_captureKey = (string) $key;
- }
- ob_start();
- }
-
- /**
- * End content capture
- *
- * @return void
- */
- public function captureEnd()
- {
- $data = ob_get_clean();
- $key = null;
- $this->_captureLock = false;
- if (null !== $this->_captureKey) {
- $key = $this->_captureKey;
- }
- switch ($this->_captureType) {
- case self::SET:
- if (null !== $key) {
- $this[$key] = $data;
- } else {
- $this->exchangeArray(array($data));
- }
- break;
- case self::PREPEND:
- if (null !== $key) {
- $array = array($key => $data);
- $values = $this->getArrayCopy();
- $final = $array + $values;
- $this->exchangeArray($final);
- } else {
- $this->prepend($data);
- }
- break;
- case self::APPEND:
- default:
- if (null !== $key) {
- if (empty($this[$key])) {
- $this[$key] = $data;
- } else {
- $this[$key] .= $data;
- }
- } else {
- $this[$this->nextIndex()] = $data;
- }
- break;
- }
- }
-
- /**
- * Get keys
- *
- * @return array
- */
- public function getKeys()
- {
- $array = $this->getArrayCopy();
- return array_keys($array);
- }
-
- /**
- * Next Index
- *
- * as defined by the PHP manual
- * @return int
- */
- public function nextIndex()
- {
- $keys = $this->getKeys();
- if (0 == count($keys)) {
- return 0;
- }
-
- return $nextIndex = max($keys) + 1;
- }
-
- /**
- * Render the placeholder
- *
- * @param null $indent
- * @return string
- */
- public function toString($indent = null)
- {
- // Check items
- if (0 === $this->count()) {
- return '';
- }
-
- $indent = ($indent !== null)
- ? $this->getWhitespace($indent)
- : $this->getIndent();
-
- $items = $this->getArrayCopy();
- $return = $indent
- . $this->getPrefix()
- . implode($this->getSeparator(), $items)
- . $this->getPostfix();
- $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return);
- return $return;
- }
-
- /**
- * Serialize object to string
- *
- * @return string
- */
- public function __toString()
- {
- return $this->toString();
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Placeholder/Container/Exception.php b/lib/zend/Zend/View/Helper/Placeholder/Container/Exception.php
deleted file mode 100644
index da15f6e746a9f..0000000000000
--- a/lib/zend/Zend/View/Helper/Placeholder/Container/Exception.php
+++ /dev/null
@@ -1,39 +0,0 @@
-setRegistry(Zend_View_Helper_Placeholder_Registry::getRegistry());
- $this->setContainer($this->getRegistry()->getContainer($this->_regKey));
- }
-
- /**
- * Retrieve registry
- *
- * @return Zend_View_Helper_Placeholder_Registry
- */
- public function getRegistry()
- {
- return $this->_registry;
- }
-
- /**
- * Set registry object
- *
- * @param Zend_View_Helper_Placeholder_Registry $registry
- * @return Zend_View_Helper_Placeholder_Container_Standalone
- */
- public function setRegistry(Zend_View_Helper_Placeholder_Registry $registry)
- {
- $this->_registry = $registry;
- return $this;
- }
-
- /**
- * Set whether or not auto escaping should be used
- *
- * @param bool $autoEscape whether or not to auto escape output
- * @return Zend_View_Helper_Placeholder_Container_Standalone
- */
- public function setAutoEscape($autoEscape = true)
- {
- $this->_autoEscape = ($autoEscape) ? true : false;
- return $this;
- }
-
- /**
- * Return whether autoEscaping is enabled or disabled
- *
- * return bool
- */
- public function getAutoEscape()
- {
- return $this->_autoEscape;
- }
-
- /**
- * Escape a string
- *
- * @param string $string
- * @return string
- */
- protected function _escape($string)
- {
- $enc = 'UTF-8';
- if ($this->view instanceof Zend_View_Interface
- && method_exists($this->view, 'getEncoding')
- ) {
- $enc = $this->view->getEncoding();
- }
-
- return htmlspecialchars((string) $string, ENT_COMPAT, $enc);
- }
-
- /**
- * Set container on which to operate
- *
- * @param Zend_View_Helper_Placeholder_Container_Abstract $container
- * @return Zend_View_Helper_Placeholder_Container_Standalone
- */
- public function setContainer(Zend_View_Helper_Placeholder_Container_Abstract $container)
- {
- $this->_container = $container;
- return $this;
- }
-
- /**
- * Retrieve placeholder container
- *
- * @return Zend_View_Helper_Placeholder_Container_Abstract
- */
- public function getContainer()
- {
- return $this->_container;
- }
-
- /**
- * Overloading: set property value
- *
- * @param string $key
- * @param mixed $value
- * @return void
- */
- public function __set($key, $value)
- {
- $container = $this->getContainer();
- $container[$key] = $value;
- }
-
- /**
- * Overloading: retrieve property
- *
- * @param string $key
- * @return mixed
- */
- public function __get($key)
- {
- $container = $this->getContainer();
- if (isset($container[$key])) {
- return $container[$key];
- }
-
- return null;
- }
-
- /**
- * Overloading: check if property is set
- *
- * @param string $key
- * @return bool
- */
- public function __isset($key)
- {
- $container = $this->getContainer();
- return isset($container[$key]);
- }
-
- /**
- * Overloading: unset property
- *
- * @param string $key
- * @return void
- */
- public function __unset($key)
- {
- $container = $this->getContainer();
- if (isset($container[$key])) {
- unset($container[$key]);
- }
- }
-
- /**
- * Overload
- *
- * Proxy to container methods
- *
- * @param string $method
- * @param array $args
- * @return mixed
- */
- public function __call($method, $args)
- {
- $container = $this->getContainer();
- if (method_exists($container, $method)) {
- $return = call_user_func_array(array($container, $method), $args);
- if ($return === $container) {
- // If the container is returned, we really want the current object
- return $this;
- }
- return $return;
- }
-
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('Method "' . $method . '" does not exist');
- $e->setView($this->view);
- throw $e;
- }
-
- /**
- * String representation
- *
- * @return string
- */
- public function toString()
- {
- return $this->getContainer()->toString();
- }
-
- /**
- * Cast to string representation
- *
- * @return string
- */
- public function __toString()
- {
- return $this->toString();
- }
-
- /**
- * Countable
- *
- * @return int
- */
- public function count()
- {
- $container = $this->getContainer();
- return count($container);
- }
-
- /**
- * ArrayAccess: offsetExists
- *
- * @param string|int $offset
- * @return bool
- */
- public function offsetExists($offset)
- {
- return $this->getContainer()->offsetExists($offset);
- }
-
- /**
- * ArrayAccess: offsetGet
- *
- * @param string|int $offset
- * @return mixed
- */
- public function offsetGet($offset)
- {
- return $this->getContainer()->offsetGet($offset);
- }
-
- /**
- * ArrayAccess: offsetSet
- *
- * @param string|int $offset
- * @param mixed $value
- * @return void
- */
- public function offsetSet($offset, $value)
- {
- return $this->getContainer()->offsetSet($offset, $value);
- }
-
- /**
- * ArrayAccess: offsetUnset
- *
- * @param string|int $offset
- * @return void
- */
- public function offsetUnset($offset)
- {
- return $this->getContainer()->offsetUnset($offset);
- }
-
- /**
- * IteratorAggregate: get Iterator
- *
- * @return Iterator
- */
- public function getIterator()
- {
- return $this->getContainer()->getIterator();
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Placeholder/Registry.php b/lib/zend/Zend/View/Helper/Placeholder/Registry.php
deleted file mode 100644
index b4a10c8c8f16f..0000000000000
--- a/lib/zend/Zend/View/Helper/Placeholder/Registry.php
+++ /dev/null
@@ -1,188 +0,0 @@
-_items[$key] = new $this->_containerClass($value);
- return $this->_items[$key];
- }
-
- /**
- * Retrieve a placeholder container
- *
- * @param string $key
- * @return Zend_View_Helper_Placeholder_Container_Abstract
- */
- public function getContainer($key)
- {
- $key = (string) $key;
- if (isset($this->_items[$key])) {
- return $this->_items[$key];
- }
-
- $container = $this->createContainer($key);
-
- return $container;
- }
-
- /**
- * Does a particular container exist?
- *
- * @param string $key
- * @return bool
- */
- public function containerExists($key)
- {
- $key = (string) $key;
- $return = array_key_exists($key, $this->_items);
- return $return;
- }
-
- /**
- * Set the container for an item in the registry
- *
- * @param string $key
- * @param Zend_View_Placeholder_Container_Abstract $container
- * @return Zend_View_Placeholder_Registry
- */
- public function setContainer($key, Zend_View_Helper_Placeholder_Container_Abstract $container)
- {
- $key = (string) $key;
- $this->_items[$key] = $container;
- return $this;
- }
-
- /**
- * Delete a container
- *
- * @param string $key
- * @return bool
- */
- public function deleteContainer($key)
- {
- $key = (string) $key;
- if (isset($this->_items[$key])) {
- unset($this->_items[$key]);
- return true;
- }
-
- return false;
- }
-
- /**
- * Set the container class to use
- *
- * @param string $name
- * @return Zend_View_Helper_Placeholder_Registry
- */
- public function setContainerClass($name)
- {
- if (!class_exists($name)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($name);
- }
-
- $reflection = new ReflectionClass($name);
- if (!$reflection->isSubclassOf(new ReflectionClass('Zend_View_Helper_Placeholder_Container_Abstract'))) {
- require_once 'Zend/View/Helper/Placeholder/Registry/Exception.php';
- $e = new Zend_View_Helper_Placeholder_Registry_Exception('Invalid Container class specified');
- $e->setView($this->view);
- throw $e;
- }
-
- $this->_containerClass = $name;
- return $this;
- }
-
- /**
- * Retrieve the container class
- *
- * @return string
- */
- public function getContainerClass()
- {
- return $this->_containerClass;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Placeholder/Registry/Exception.php b/lib/zend/Zend/View/Helper/Placeholder/Registry/Exception.php
deleted file mode 100644
index 6bffa198a8939..0000000000000
--- a/lib/zend/Zend/View/Helper/Placeholder/Registry/Exception.php
+++ /dev/null
@@ -1,39 +0,0 @@
-view->placeholder($placeholder)->captureStart();
- echo $this->view->render($script);
- $this->view->placeholder($placeholder)->captureEnd();
- }
-}
diff --git a/lib/zend/Zend/View/Helper/ServerUrl.php b/lib/zend/Zend/View/Helper/ServerUrl.php
deleted file mode 100644
index c38ec8bc86aa2..0000000000000
--- a/lib/zend/Zend/View/Helper/ServerUrl.php
+++ /dev/null
@@ -1,148 +0,0 @@
-setScheme($scheme);
-
- if (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) {
- $this->setHost($_SERVER['HTTP_HOST']);
- } else if (isset($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'])) {
- $name = $_SERVER['SERVER_NAME'];
- $port = $_SERVER['SERVER_PORT'];
-
- if (($scheme == 'http' && $port == 80) ||
- ($scheme == 'https' && $port == 443)) {
- $this->setHost($name);
- } else {
- $this->setHost($name . ':' . $port);
- }
- }
- }
-
- /**
- * View helper entry point:
- * Returns the current host's URL like http://site.com
- *
- * @param string|boolean $requestUri [optional] if true, the request URI
- * found in $_SERVER will be appended
- * as a path. If a string is given, it
- * will be appended as a path. Default
- * is to not append any path.
- * @return string server url
- */
- public function serverUrl($requestUri = null)
- {
- if ($requestUri === true) {
- $path = $_SERVER['REQUEST_URI'];
- } else if (is_string($requestUri)) {
- $path = $requestUri;
- } else {
- $path = '';
- }
-
- return $this->getScheme() . '://' . $this->getHost() . $path;
- }
-
- /**
- * Returns host
- *
- * @return string host
- */
- public function getHost()
- {
- return $this->_host;
- }
-
- /**
- * Sets host
- *
- * @param string $host new host
- * @return Zend_View_Helper_ServerUrl fluent interface, returns self
- */
- public function setHost($host)
- {
- $this->_host = $host;
- return $this;
- }
-
- /**
- * Returns scheme (typically http or https)
- *
- * @return string scheme (typically http or https)
- */
- public function getScheme()
- {
- return $this->_scheme;
- }
-
- /**
- * Sets scheme (typically http or https)
- *
- * @param string $scheme new scheme (typically http or https)
- * @return Zend_View_Helper_ServerUrl fluent interface, returns self
- */
- public function setScheme($scheme)
- {
- $this->_scheme = $scheme;
- return $this;
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Translate.php b/lib/zend/Zend/View/Helper/Translate.php
deleted file mode 100644
index f66a560b0d9d5..0000000000000
--- a/lib/zend/Zend/View/Helper/Translate.php
+++ /dev/null
@@ -1,180 +0,0 @@
-setTranslator($translate);
- }
- }
-
- /**
- * Translate a message
- * You can give multiple params or an array of params.
- * If you want to output another locale just set it as last single parameter
- * Example 1: translate('%1\$s + %2\$s', $value1, $value2, $locale);
- * Example 2: translate('%1\$s + %2\$s', array($value1, $value2), $locale);
- *
- * @param string $messageid Id of the message to be translated
- * @return string|Zend_View_Helper_Translate Translated message
- */
- public function translate($messageid = null)
- {
- if ($messageid === null) {
- return $this;
- }
-
- $translate = $this->getTranslator();
- $options = func_get_args();
-
- array_shift($options);
- $count = count($options);
- $locale = null;
- if ($count > 0) {
- if (Zend_Locale::isLocale($options[($count - 1)], null, false) !== false) {
- $locale = array_pop($options);
- }
- }
-
- if ((count($options) === 1) and (is_array($options[0]) === true)) {
- $options = $options[0];
- }
-
- if ($translate !== null) {
- $messageid = $translate->translate($messageid, $locale);
- }
-
- if (count($options) === 0) {
- return $messageid;
- }
-
- return vsprintf($messageid, $options);
- }
-
- /**
- * Sets a translation Adapter for translation
- *
- * @param Zend_Translate|Zend_Translate_Adapter $translate Instance of Zend_Translate
- * @throws Zend_View_Exception When no or a false instance was set
- * @return Zend_View_Helper_Translate
- */
- public function setTranslator($translate)
- {
- if ($translate instanceof Zend_Translate_Adapter) {
- $this->_translator = $translate;
- } else if ($translate instanceof Zend_Translate) {
- $this->_translator = $translate->getAdapter();
- } else {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
- $e->setView($this->view);
- throw $e;
- }
-
- return $this;
- }
-
- /**
- * Retrieve translation object
- *
- * @return Zend_Translate_Adapter|null
- */
- public function getTranslator()
- {
- if ($this->_translator === null) {
- require_once 'Zend/Registry.php';
- if (Zend_Registry::isRegistered('Zend_Translate')) {
- $this->setTranslator(Zend_Registry::get('Zend_Translate'));
- }
- }
-
- return $this->_translator;
- }
-
- /**
- * Set's an new locale for all further translations
- *
- * @param string|Zend_Locale $locale New locale to set
- * @throws Zend_View_Exception When no Zend_Translate instance was set
- * @return Zend_View_Helper_Translate
- */
- public function setLocale($locale = null)
- {
- $translate = $this->getTranslator();
- if ($translate === null) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
- $e->setView($this->view);
- throw $e;
- }
-
- $translate->setLocale($locale);
- return $this;
- }
-
- /**
- * Returns the set locale for translations
- *
- * @throws Zend_View_Exception When no Zend_Translate instance was set
- * @return string|Zend_Locale
- */
- public function getLocale()
- {
- $translate = $this->getTranslator();
- if ($translate === null) {
- require_once 'Zend/View/Exception.php';
- $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
- $e->setView($this->view);
- throw $e;
- }
-
- return $translate->getLocale();
- }
-}
diff --git a/lib/zend/Zend/View/Helper/Url.php b/lib/zend/Zend/View/Helper/Url.php
deleted file mode 100644
index fbf7b690e6353..0000000000000
--- a/lib/zend/Zend/View/Helper/Url.php
+++ /dev/null
@@ -1,51 +0,0 @@
-getRouter();
- return $router->assemble($urlOptions, $name, $reset, $encode);
- }
-}
diff --git a/lib/zend/Zend/View/Helper/UserAgent.php b/lib/zend/Zend/View/Helper/UserAgent.php
deleted file mode 100644
index 708ccda651347..0000000000000
--- a/lib/zend/Zend/View/Helper/UserAgent.php
+++ /dev/null
@@ -1,83 +0,0 @@
-setUserAgent($userAgent);
- }
- return $this->getUserAgent();
- }
-
- /**
- * Set UserAgent instance
- *
- * @param Zend_Http_UserAgent $userAgent
- * @return Zend_View_Helper_UserAgent
- */
- public function setUserAgent(Zend_Http_UserAgent $userAgent)
- {
- $this->_userAgent = $userAgent;
- return $this;
- }
-
- /**
- * Retrieve UserAgent instance
- *
- * If none set, instantiates one using no configuration
- *
- * @return Zend_Http_UserAgent
- */
- public function getUserAgent()
- {
- if (null === $this->_userAgent) {
- require_once 'Zend/Http/UserAgent.php';
- $this->setUserAgent(new Zend_Http_UserAgent());
- }
- return $this->_userAgent;
- }
-}
diff --git a/lib/zend/Zend/View/Interface.php b/lib/zend/Zend/View/Interface.php
deleted file mode 100644
index 496ec7108ec6d..0000000000000
--- a/lib/zend/Zend/View/Interface.php
+++ /dev/null
@@ -1,137 +0,0 @@
- value pairs to set en
- * masse.
- *
- * @see __set()
- * @param string|array $spec The assignment strategy to use (key or array of key
- * => value pairs)
- * @param mixed $value (Optional) If assigning a named variable, use this
- * as the value.
- * @return void
- */
- public function assign($spec, $value = null);
-
- /**
- * Clear all assigned variables
- *
- * Clears all variables assigned to Zend_View either via {@link assign()} or
- * property overloading ({@link __get()}/{@link __set()}).
- *
- * @return void
- */
- public function clearVars();
-
- /**
- * Processes a view script and returns the output.
- *
- * @param string $name The script name to process.
- * @return string The script output.
- */
- public function render($name);
-}
diff --git a/lib/zend/Zend/View/Stream.php b/lib/zend/Zend/View/Stream.php
deleted file mode 100644
index ae8d52419e483..0000000000000
--- a/lib/zend/Zend/View/Stream.php
+++ /dev/null
@@ -1,183 +0,0 @@
-_data = file_get_contents($path);
-
- /**
- * If reading the file failed, update our local stat store
- * to reflect the real stat of the file, then return on failure
- */
- if ($this->_data === false) {
- $this->_stat = stat($path);
- return false;
- }
-
- /**
- * Convert = ?> to long-form and ?> to
- *
- */
- $this->_data = preg_replace('/\<\?\=/', "_data);
- $this->_data = preg_replace('/<\?(?!xml|php)/s', '_data);
-
- /**
- * file_get_contents() won't update PHP's stat cache, so we grab a stat
- * of the file to prevent additional reads should the script be
- * requested again, which will make include() happy.
- */
- $this->_stat = stat($path);
-
- return true;
- }
-
- /**
- * Included so that __FILE__ returns the appropriate info
- *
- * @return array
- */
- public function url_stat()
- {
- return $this->_stat;
- }
-
- /**
- * Reads from the stream.
- */
- public function stream_read($count)
- {
- $ret = substr($this->_data, $this->_pos, $count);
- $this->_pos += strlen($ret);
- return $ret;
- }
-
-
- /**
- * Tells the current position in the stream.
- */
- public function stream_tell()
- {
- return $this->_pos;
- }
-
-
- /**
- * Tells if we are at the end of the stream.
- */
- public function stream_eof()
- {
- return $this->_pos >= strlen($this->_data);
- }
-
-
- /**
- * Stream statistics.
- */
- public function stream_stat()
- {
- return $this->_stat;
- }
-
-
- /**
- * Seek to a specific point in the stream.
- */
- public function stream_seek($offset, $whence)
- {
- switch ($whence) {
- case SEEK_SET:
- if ($offset < strlen($this->_data) && $offset >= 0) {
- $this->_pos = $offset;
- return true;
- } else {
- return false;
- }
- break;
-
- case SEEK_CUR:
- if ($offset >= 0) {
- $this->_pos += $offset;
- return true;
- } else {
- return false;
- }
- break;
-
- case SEEK_END:
- if (strlen($this->_data) + $offset >= 0) {
- $this->_pos = strlen($this->_data) + $offset;
- return true;
- } else {
- return false;
- }
- break;
-
- default:
- return false;
- }
- }
-}
diff --git a/lib/zend/Zend/Xml/Exception.php b/lib/zend/Zend/Xml/Exception.php
deleted file mode 100644
index b58c249512fe4..0000000000000
--- a/lib/zend/Zend/Xml/Exception.php
+++ /dev/null
@@ -1,36 +0,0 @@
- 0) {
- return true;
- }
- return false;
- }
-
- /**
- * Scan XML string for potential XXE and XEE attacks
- *
- * @param string $xml
- * @param DomDocument $dom
- * @throws Zend_Xml_Exception
- * @return SimpleXMLElement|DomDocument|boolean
- */
- public static function scan($xml, DOMDocument $dom = null)
- {
- // If running with PHP-FPM we perform an heuristic scan
- // We cannot use libxml_disable_entity_loader because of this bug
- // @see https://bugs.php.net/bug.php?id=64938
- if (self::isPhpFpm()) {
- self::heuristicScan($xml);
- }
-
- if (null === $dom) {
- $simpleXml = true;
- $dom = new DOMDocument();
- }
-
- if (!self::isPhpFpm()) {
- $loadEntities = libxml_disable_entity_loader(true);
- $useInternalXmlErrors = libxml_use_internal_errors(true);
- }
-
- // Load XML with network access disabled (LIBXML_NONET)
- // error disabled with @ for PHP-FPM scenario
- set_error_handler(array('Zend_Xml_Security', 'loadXmlErrorHandler'), E_WARNING);
-
- $result = $dom->loadXml($xml, LIBXML_NONET);
- restore_error_handler();
-
- if (!$result) {
- // Entity load to previous setting
- if (!self::isPhpFpm()) {
- libxml_disable_entity_loader($loadEntities);
- libxml_use_internal_errors($useInternalXmlErrors);
- }
- return false;
- }
-
- // Scan for potential XEE attacks using ENTITY, if not PHP-FPM
- if (!self::isPhpFpm()) {
- foreach ($dom->childNodes as $child) {
- if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
- if ($child->entities->length > 0) {
- require_once 'Exception.php';
- throw new Zend_Xml_Exception(self::ENTITY_DETECT);
- }
- }
- }
- }
-
- // Entity load to previous setting
- if (!self::isPhpFpm()) {
- libxml_disable_entity_loader($loadEntities);
- libxml_use_internal_errors($useInternalXmlErrors);
- }
-
- if (isset($simpleXml)) {
- $result = simplexml_import_dom($dom);
- if (!$result instanceof SimpleXMLElement) {
- return false;
- }
- return $result;
- }
- return $dom;
- }
-
- /**
- * Scan XML file for potential XXE/XEE attacks
- *
- * @param string $file
- * @param DOMDocument $dom
- * @throws Zend_Xml_Exception
- * @return SimpleXMLElement|DomDocument
- */
- public static function scanFile($file, DOMDocument $dom = null)
- {
- if (!file_exists($file)) {
- require_once 'Exception.php';
- throw new Zend_Xml_Exception(
- "The file $file specified doesn't exist"
- );
- }
- return self::scan(file_get_contents($file), $dom);
- }
-
- /**
- * Return true if PHP is running with PHP-FPM
- *
- * This method is mainly used to determine whether or not heuristic checks
- * (vs libxml checks) should be made, due to threading issues in libxml;
- * under php-fpm, threading becomes a concern.
- *
- * However, PHP versions 5.5.22+ and 5.6.6+ contain a patch to the
- * libxml support in PHP that makes the libxml checks viable; in such
- * versions, this method will return false to enforce those checks, which
- * are more strict and accurate than the heuristic checks.
- *
- * @return boolean
- */
- public static function isPhpFpm()
- {
- $isVulnerableVersion = (
- version_compare(PHP_VERSION, '5.5.22', 'lt')
- || (
- version_compare(PHP_VERSION, '5.6', 'gte')
- && version_compare(PHP_VERSION, '5.6.6', 'lt')
- )
- );
-
- if (substr(php_sapi_name(), 0, 3) === 'fpm' && $isVulnerableVersion) {
- return true;
- }
- return false;
- }
-
- /**
- * Determine and return the string(s) to use for the $generator) {
- $prefix = call_user_func($generator, '<' . '?xml');
- if (0 === strncmp($xml, $prefix, strlen($prefix))) {
- return $encoding;
- }
- }
-
- // Fallback
- return 'UTF-8';
- }
-
- /**
- * Attempt to detect the specified XML encoding.
- *
- * Using the file's encoding, determines if an "encoding" attribute is
- * present and well-formed in the XML declaration; if so, it returns a
- * list with both the ASCII representation of that declaration and the
- * original file encoding.
- *
- * If not, a list containing only the provided file encoding is returned.
- *
- * @param string $xml
- * @param string $fileEncoding
- * @return string[] Potential XML encodings
- */
- protected static function detectXmlEncoding($xml, $fileEncoding)
- {
- $encodingMap = self::getAsciiEncodingMap();
- $generator = $encodingMap[$fileEncoding];
- $encAttr = call_user_func($generator, 'encoding="');
- $quote = call_user_func($generator, '"');
- $close = call_user_func($generator, '>');
-
- $closePos = strpos($xml, $close);
- if (false === $closePos) {
- return array($fileEncoding);
- }
-
- $encPos = strpos($xml, $encAttr);
- if (false === $encPos
- || $encPos > $closePos
- ) {
- return array($fileEncoding);
- }
-
- $encPos += strlen($encAttr);
- $quotePos = strpos($xml, $quote, $encPos);
- if (false === $quotePos) {
- return array($fileEncoding);
- }
-
- $encoding = self::substr($xml, $encPos, $quotePos);
- return array(
- // Following line works because we're only supporting 8-bit safe encodings at this time.
- str_replace('\0', '', $encoding), // detected encoding
- $fileEncoding, // file encoding
- );
- }
-
- /**
- * Return a list of BOM maps.
- *
- * Returns a list of common encoding -> BOM maps, along with the character
- * length to compare against.
- *
- * @link https://en.wikipedia.org/wiki/Byte_order_mark
- * @return array
- */
- protected static function getBomMap()
- {
- return array(
- array(
- 'encoding' => 'UTF-32BE',
- 'bom' => pack('CCCC', 0x00, 0x00, 0xfe, 0xff),
- 'length' => 4,
- ),
- array(
- 'encoding' => 'UTF-32LE',
- 'bom' => pack('CCCC', 0xff, 0xfe, 0x00, 0x00),
- 'length' => 4,
- ),
- array(
- 'encoding' => 'GB-18030',
- 'bom' => pack('CCCC', 0x84, 0x31, 0x95, 0x33),
- 'length' => 4,
- ),
- array(
- 'encoding' => 'UTF-16BE',
- 'bom' => pack('CC', 0xfe, 0xff),
- 'length' => 2,
- ),
- array(
- 'encoding' => 'UTF-16LE',
- 'bom' => pack('CC', 0xff, 0xfe),
- 'length' => 2,
- ),
- array(
- 'encoding' => 'UTF-8',
- 'bom' => pack('CCC', 0xef, 0xbb, 0xbf),
- 'length' => 3,
- ),
- );
- }
-
- /**
- * Return a map of encoding => generator pairs.
- *
- * Returns a map of encoding => generator pairs, where the generator is a
- * callable that accepts a string and returns the appropriate byte order
- * sequence of that string for the encoding.
- *
- * @return array
- */
- protected static function getAsciiEncodingMap()
- {
- return array(
- 'UTF-32BE' => array(__CLASS__, 'encodeToUTF32BE'),
- 'UTF-32LE' => array(__CLASS__, 'encodeToUTF32LE'),
- 'UTF-32odd1' => array(__CLASS__, 'encodeToUTF32odd1'),
- 'UTF-32odd2' => array(__CLASS__, 'encodeToUTF32odd2'),
- 'UTF-16BE' => array(__CLASS__, 'encodeToUTF16BE'),
- 'UTF-16LE' => array(__CLASS__, 'encodeToUTF16LE'),
- 'UTF-8' => array(__CLASS__, 'encodeToUTF8'),
- 'GB-18030' => array(__CLASS__, 'encodeToUTF8'),
- );
- }
-
- /**
- * Binary-safe substr.
- *
- * substr() is not binary-safe; this method loops by character to ensure
- * multi-byte characters are aggregated correctly.
- *
- * @param string $string
- * @param int $start
- * @param int $end
- * @return string
- */
- protected static function substr($string, $start, $end)
- {
- $substr = '';
- for ($i = $start; $i < $end; $i += 1) {
- $substr .= $string[$i];
- }
- return $substr;
- }
-
- /**
- * Generate an entity comparison based on the given encoding.
- *
- * This patch is internal only, and public only so it can be used as a
- * callable to pass to array_map.
- *
- * @internal
- * @param string $encoding
- * @return string
- */
- public static function generateEntityComparison($encoding)
- {
- $encodingMap = self::getAsciiEncodingMap();
- $generator = isset($encodingMap[$encoding]) ? $encodingMap[$encoding] : $encodingMap['UTF-8'];
- return call_user_func($generator, '_httpClient = new Zend_Http_Client();
- } else {
- $this->_httpClient = $httpClient;
- }
-
- $this->_introspector = new Zend_XmlRpc_Client_ServerIntrospection($this);
- $this->_serverAddress = $server;
- }
-
-
- /**
- * Sets the HTTP client object to use for connecting the XML-RPC server.
- *
- * @param Zend_Http_Client $httpClient
- * @return Zend_Http_Client
- */
- public function setHttpClient(Zend_Http_Client $httpClient)
- {
- return $this->_httpClient = $httpClient;
- }
-
-
- /**
- * Gets the HTTP client object.
- *
- * @return Zend_Http_Client
- */
- public function getHttpClient()
- {
- return $this->_httpClient;
- }
-
-
- /**
- * Sets the object used to introspect remote servers
- *
- * @param Zend_XmlRpc_Client_ServerIntrospection
- * @return Zend_XmlRpc_Client_ServerIntrospection
- */
- public function setIntrospector(Zend_XmlRpc_Client_ServerIntrospection $introspector)
- {
- return $this->_introspector = $introspector;
- }
-
-
- /**
- * Gets the introspection object.
- *
- * @return Zend_XmlRpc_Client_ServerIntrospection
- */
- public function getIntrospector()
- {
- return $this->_introspector;
- }
-
-
- /**
- * The request of the last method call
- *
- * @return Zend_XmlRpc_Request
- */
- public function getLastRequest()
- {
- return $this->_lastRequest;
- }
-
-
- /**
- * The response received from the last method call
- *
- * @return Zend_XmlRpc_Response
- */
- public function getLastResponse()
- {
- return $this->_lastResponse;
- }
-
-
- /**
- * Returns a proxy object for more convenient method calls
- *
- * @param string $namespace Namespace to proxy or empty string for none
- * @return Zend_XmlRpc_Client_ServerProxy
- */
- public function getProxy($namespace = '')
- {
- if (empty($this->_proxyCache[$namespace])) {
- $proxy = new Zend_XmlRpc_Client_ServerProxy($this, $namespace);
- $this->_proxyCache[$namespace] = $proxy;
- }
- return $this->_proxyCache[$namespace];
- }
-
- /**
- * Set skip system lookup flag
- *
- * @param bool $flag
- * @return Zend_XmlRpc_Client
- */
- public function setSkipSystemLookup($flag = true)
- {
- $this->_skipSystemLookup = (bool) $flag;
- return $this;
- }
-
- /**
- * Skip system lookup when determining if parameter should be array or struct?
- *
- * @return bool
- */
- public function skipSystemLookup()
- {
- return $this->_skipSystemLookup;
- }
-
- /**
- * Perform an XML-RPC request and return a response.
- *
- * @param Zend_XmlRpc_Request $request
- * @param null|Zend_XmlRpc_Response $response
- * @return void
- * @throws Zend_XmlRpc_Client_HttpException
- */
- public function doRequest($request, $response = null)
- {
- $this->_lastRequest = $request;
-
- if (PHP_VERSION_ID < 50600) {
- iconv_set_encoding('input_encoding', 'UTF-8');
- iconv_set_encoding('output_encoding', 'UTF-8');
- iconv_set_encoding('internal_encoding', 'UTF-8');
- } else {
- ini_set('input_encoding', 'UTF-8');
- ini_set('output_encoding', 'UTF-8');
- ini_set('default_charset', 'UTF-8');
- }
-
- $http = $this->getHttpClient();
- if($http->getUri() === null) {
- $http->setUri($this->_serverAddress);
- }
-
- $http->setHeaders(array(
- 'Content-Type: text/xml; charset=utf-8',
- 'Accept: text/xml',
- ));
-
- if ($http->getHeader('user-agent') === null) {
- $http->setHeaders(array('User-Agent: Zend_XmlRpc_Client'));
- }
-
- $xml = $this->_lastRequest->__toString();
- $http->setRawData($xml);
- $httpResponse = $http->request(Zend_Http_Client::POST);
-
- if (! $httpResponse->isSuccessful()) {
- /**
- * Exception thrown when an HTTP error occurs
- * @see Zend_XmlRpc_Client_HttpException
- */
- require_once 'Zend/XmlRpc/Client/HttpException.php';
- throw new Zend_XmlRpc_Client_HttpException(
- $httpResponse->getMessage(),
- $httpResponse->getStatus());
- }
-
- if ($response === null) {
- $response = new Zend_XmlRpc_Response();
- }
- $this->_lastResponse = $response;
- $this->_lastResponse->loadXml(trim($httpResponse->getBody()));
- }
-
- /**
- * Send an XML-RPC request to the service (for a specific method)
- *
- * @param string $method Name of the method we want to call
- * @param array $params Array of parameters for the method
- * @return mixed
- * @throws Zend_XmlRpc_Client_FaultException
- */
- public function call($method, $params=array())
- {
- if (!$this->skipSystemLookup() && ('system.' != substr($method, 0, 7))) {
- // Ensure empty array/struct params are cast correctly
- // If system.* methods are not available, bypass. (ZF-2978)
- $success = true;
- try {
- $signatures = $this->getIntrospector()->getMethodSignature($method);
- } catch (Zend_XmlRpc_Exception $e) {
- $success = false;
- }
- if ($success) {
- $validTypes = array(
- Zend_XmlRpc_Value::XMLRPC_TYPE_ARRAY,
- Zend_XmlRpc_Value::XMLRPC_TYPE_BASE64,
- Zend_XmlRpc_Value::XMLRPC_TYPE_BOOLEAN,
- Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME,
- Zend_XmlRpc_Value::XMLRPC_TYPE_DOUBLE,
- Zend_XmlRpc_Value::XMLRPC_TYPE_I4,
- Zend_XmlRpc_Value::XMLRPC_TYPE_INTEGER,
- Zend_XmlRpc_Value::XMLRPC_TYPE_NIL,
- Zend_XmlRpc_Value::XMLRPC_TYPE_STRING,
- Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT,
- );
-
- if (!is_array($params)) {
- $params = array($params);
- }
-
- foreach ($params as $key => $param)
- {
- if ($param instanceof Zend_XmlRpc_Value) {
- continue;
- }
-
- if (count($signatures) > 1) {
- $type = Zend_XmlRpc_Value::getXmlRpcTypeByValue($param);
- foreach ($signatures as $signature) {
- if (!is_array($signature)) {
- continue;
- }
- if (isset($signature['parameters'][$key])) {
- if ($signature['parameters'][$key] == $type) {
- break;
- }
- }
- }
- } elseif (isset($signatures[0]['parameters'][$key])) {
- $type = $signatures[0]['parameters'][$key];
- } else {
- $type = null;
- }
-
- if (empty($type) || !in_array($type, $validTypes)) {
- $type = Zend_XmlRpc_Value::AUTO_DETECT_TYPE;
- }
-
- $params[$key] = Zend_XmlRpc_Value::getXmlRpcValue($param, $type);
- }
- }
- }
-
- $request = $this->_createRequest($method, $params);
-
- $this->doRequest($request);
-
- if ($this->_lastResponse->isFault()) {
- $fault = $this->_lastResponse->getFault();
- /**
- * Exception thrown when an XML-RPC fault is returned
- * @see Zend_XmlRpc_Client_FaultException
- */
- require_once 'Zend/XmlRpc/Client/FaultException.php';
- throw new Zend_XmlRpc_Client_FaultException($fault->getMessage(),
- $fault->getCode());
- }
-
- return $this->_lastResponse->getReturnValue();
- }
-
- /**
- * Create request object
- *
- * @return Zend_XmlRpc_Request
- */
- protected function _createRequest($method, $params)
- {
- return new Zend_XmlRpc_Request($method, $params);
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Client/Exception.php b/lib/zend/Zend/XmlRpc/Client/Exception.php
deleted file mode 100644
index d82601da6f04d..0000000000000
--- a/lib/zend/Zend/XmlRpc/Client/Exception.php
+++ /dev/null
@@ -1,40 +0,0 @@
-_system = $client->getProxy('system');
- }
-
- /**
- * Returns the signature for each method on the server,
- * autodetecting whether system.multicall() is supported and
- * using it if so.
- *
- * @return array
- */
- public function getSignatureForEachMethod()
- {
- $methods = $this->listMethods();
-
- require_once 'Zend/XmlRpc/Client/FaultException.php';
- try {
- $signatures = $this->getSignatureForEachMethodByMulticall($methods);
- } catch (Zend_XmlRpc_Client_FaultException $e) {
- // degrade to looping
- }
-
- if (empty($signatures)) {
- $signatures = $this->getSignatureForEachMethodByLooping($methods);
- }
-
- return $signatures;
- }
-
- /**
- * Attempt to get the method signatures in one request via system.multicall().
- * This is a boxcar feature of XML-RPC and is found on fewer servers. However,
- * can significantly improve performance if present.
- *
- * @param array $methods
- * @return array array(array(return, param, param, param...))
- */
- public function getSignatureForEachMethodByMulticall($methods = null)
- {
- if ($methods === null) {
- $methods = $this->listMethods();
- }
-
- $multicallParams = array();
- foreach ($methods as $method) {
- $multicallParams[] = array('methodName' => 'system.methodSignature',
- 'params' => array($method));
- }
-
- $serverSignatures = $this->_system->multicall($multicallParams);
-
- if (! is_array($serverSignatures)) {
- $type = gettype($serverSignatures);
- $error = "Multicall return is malformed. Expected array, got $type";
- require_once 'Zend/XmlRpc/Client/IntrospectException.php';
- throw new Zend_XmlRpc_Client_IntrospectException($error);
- }
-
- if (count($serverSignatures) != count($methods)) {
- $error = 'Bad number of signatures received from multicall';
- require_once 'Zend/XmlRpc/Client/IntrospectException.php';
- throw new Zend_XmlRpc_Client_IntrospectException($error);
- }
-
- // Create a new signatures array with the methods name as keys and the signature as value
- $signatures = array();
- foreach ($serverSignatures as $i => $signature) {
- $signatures[$methods[$i]] = $signature;
- }
-
- return $signatures;
- }
-
- /**
- * Get the method signatures for every method by
- * successively calling system.methodSignature
- *
- * @param array $methods
- * @return array
- */
- public function getSignatureForEachMethodByLooping($methods = null)
- {
- if ($methods === null) {
- $methods = $this->listMethods();
- }
-
- $signatures = array();
- foreach ($methods as $method) {
- $signatures[$method] = $this->getMethodSignature($method);
- }
-
- return $signatures;
- }
-
- /**
- * Call system.methodSignature() for the given method
- *
- * @param array $method
- * @return array array(array(return, param, param, param...))
- */
- public function getMethodSignature($method)
- {
- $signature = $this->_system->methodSignature($method);
- if (!is_array($signature)) {
- $error = 'Invalid signature for method "' . $method . '"';
- require_once 'Zend/XmlRpc/Client/IntrospectException.php';
- throw new Zend_XmlRpc_Client_IntrospectException($error);
- }
- return $signature;
- }
-
- /**
- * Call system.listMethods()
- *
- * @param array $method
- * @return array array(method, method, method...)
- */
- public function listMethods()
- {
- return $this->_system->listMethods();
- }
-
-}
diff --git a/lib/zend/Zend/XmlRpc/Client/ServerProxy.php b/lib/zend/Zend/XmlRpc/Client/ServerProxy.php
deleted file mode 100644
index 516619773b907..0000000000000
--- a/lib/zend/Zend/XmlRpc/Client/ServerProxy.php
+++ /dev/null
@@ -1,95 +0,0 @@
-foo->bar->baz()".
- *
- * @category Zend
- * @package Zend_XmlRpc
- * @subpackage Client
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_XmlRpc_Client_ServerProxy
-{
- /**
- * @var Zend_XmlRpc_Client
- */
- private $_client = null;
-
- /**
- * @var string
- */
- private $_namespace = '';
-
-
- /**
- * @var array of Zend_XmlRpc_Client_ServerProxy
- */
- private $_cache = array();
-
-
- /**
- * Class constructor
- *
- * @param string $namespace
- * @param Zend_XmlRpc_Client $client
- */
- public function __construct($client, $namespace = '')
- {
- $this->_namespace = $namespace;
- $this->_client = $client;
- }
-
-
- /**
- * Get the next successive namespace
- *
- * @param string $name
- * @return Zend_XmlRpc_Client_ServerProxy
- */
- public function __get($namespace)
- {
- $namespace = ltrim("$this->_namespace.$namespace", '.');
- if (!isset($this->_cache[$namespace])) {
- $this->_cache[$namespace] = new $this($this->_client, $namespace);
- }
- return $this->_cache[$namespace];
- }
-
-
- /**
- * Call a method in this namespace.
- *
- * @param string $methodN
- * @param array $args
- * @return mixed
- */
- public function __call($method, $args)
- {
- $method = ltrim("$this->_namespace.$method", '.');
- return $this->_client->call($method, $args);
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Exception.php b/lib/zend/Zend/XmlRpc/Exception.php
deleted file mode 100644
index d3350515a73ae..0000000000000
--- a/lib/zend/Zend/XmlRpc/Exception.php
+++ /dev/null
@@ -1,37 +0,0 @@
- messages
- * @var array
- */
- protected $_internal = array(
- 404 => 'Unknown Error',
-
- // 610 - 619 reflection errors
- 610 => 'Invalid method class',
- 611 => 'Unable to attach function or callback; not callable',
- 612 => 'Unable to load array; not an array',
- 613 => 'One or more method records are corrupt or otherwise unusable',
-
- // 620 - 629 dispatch errors
- 620 => 'Method does not exist',
- 621 => 'Error instantiating class to invoke method',
- 622 => 'Method missing implementation',
- 623 => 'Calling parameters do not match signature',
-
- // 630 - 639 request errors
- 630 => 'Unable to read request',
- 631 => 'Failed to parse request',
- 632 => 'Invalid request, no method passed; request must contain a \'methodName\' tag',
- 633 => 'Param must contain a value',
- 634 => 'Invalid method name',
- 635 => 'Invalid XML provided to request',
- 636 => 'Error creating xmlrpc value',
-
- // 640 - 649 system.* errors
- 640 => 'Method does not exist',
-
- // 650 - 659 response errors
- 650 => 'Invalid XML provided for response',
- 651 => 'Failed to parse response',
- 652 => 'Invalid response',
- 653 => 'Invalid XMLRPC value in response',
- );
-
- /**
- * Constructor
- *
- * @return Zend_XmlRpc_Fault
- */
- public function __construct($code = 404, $message = '')
- {
- $this->setCode($code);
- $code = $this->getCode();
-
- if (empty($message) && isset($this->_internal[$code])) {
- $message = $this->_internal[$code];
- } elseif (empty($message)) {
- $message = 'Unknown error';
- }
- $this->setMessage($message);
- }
-
- /**
- * Set the fault code
- *
- * @param int $code
- * @return Zend_XmlRpc_Fault
- */
- public function setCode($code)
- {
- $this->_code = (int) $code;
- return $this;
- }
-
- /**
- * Return fault code
- *
- * @return int
- */
- public function getCode()
- {
- return $this->_code;
- }
-
- /**
- * Retrieve fault message
- *
- * @param string
- * @return Zend_XmlRpc_Fault
- */
- public function setMessage($message)
- {
- $this->_message = (string) $message;
- return $this;
- }
-
- /**
- * Retrieve fault message
- *
- * @return string
- */
- public function getMessage()
- {
- return $this->_message;
- }
-
- /**
- * Set encoding to use in fault response
- *
- * @param string $encoding
- * @return Zend_XmlRpc_Fault
- */
- public function setEncoding($encoding)
- {
- $this->_encoding = $encoding;
- Zend_XmlRpc_Value::setEncoding($encoding);
- return $this;
- }
-
- /**
- * Retrieve current fault encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Load an XMLRPC fault from XML
- *
- * @param string $fault
- * @return boolean Returns true if successfully loaded fault response, false
- * if response was not a fault response
- * @throws Zend_XmlRpc_Exception if no or faulty XML provided, or if fault
- * response does not contain either code or message
- */
- public function loadXml($fault)
- {
- if (!is_string($fault)) {
- require_once 'Zend/XmlRpc/Exception.php';
- throw new Zend_XmlRpc_Exception('Invalid XML provided to fault');
- }
-
- try {
- $xml = @new SimpleXMLElement($fault);
- } catch (Exception $e) {
- // Not valid XML
- require_once 'Zend/XmlRpc/Exception.php';
- throw new Zend_XmlRpc_Exception('Failed to parse XML fault: ' . $e->getMessage(), 500, $e);
- }
-
- // Check for fault
- if (!$xml->fault) {
- // Not a fault
- return false;
- }
-
- if (!$xml->fault->value->struct) {
- // not a proper fault
- require_once 'Zend/XmlRpc/Exception.php';
- throw new Zend_XmlRpc_Exception('Invalid fault structure', 500);
- }
-
- $structXml = $xml->fault->value->asXML();
- $struct = Zend_XmlRpc_Value::getXmlRpcValue($structXml, Zend_XmlRpc_Value::XML_STRING);
- $struct = $struct->getValue();
-
- if (isset($struct['faultCode'])) {
- $code = $struct['faultCode'];
- }
- if (isset($struct['faultString'])) {
- $message = $struct['faultString'];
- }
-
- if (empty($code) && empty($message)) {
- require_once 'Zend/XmlRpc/Exception.php';
- throw new Zend_XmlRpc_Exception('Fault code and string required');
- }
-
- if (empty($code)) {
- $code = '404';
- }
-
- if (empty($message)) {
- if (isset($this->_internal[$code])) {
- $message = $this->_internal[$code];
- } else {
- $message = 'Unknown Error';
- }
- }
-
- $this->setCode($code);
- $this->setMessage($message);
-
- return true;
- }
-
- /**
- * Determine if an XML response is an XMLRPC fault
- *
- * @param string $xml
- * @return boolean
- */
- public static function isFault($xml)
- {
- $fault = new self();
- require_once 'Zend/XmlRpc/Exception.php';
- try {
- $isFault = $fault->loadXml($xml);
- } catch (Zend_XmlRpc_Exception $e) {
- $isFault = false;
- }
-
- return $isFault;
- }
-
- /**
- * Serialize fault to XML
- *
- * @return string
- */
- public function saveXml()
- {
- // Create fault value
- $faultStruct = array(
- 'faultCode' => $this->getCode(),
- 'faultString' => $this->getMessage()
- );
- $value = Zend_XmlRpc_Value::getXmlRpcValue($faultStruct);
-
- $generator = Zend_XmlRpc_Value::getGenerator();
- $generator->openElement('methodResponse')
- ->openElement('fault');
- $value->generateXml();
- $generator->closeElement('fault')
- ->closeElement('methodResponse');
-
- return $generator->flush();
- }
-
- /**
- * Return XML fault response
- *
- * @return string
- */
- public function __toString()
- {
- return $this->saveXML();
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Generator/DomDocument.php b/lib/zend/Zend/XmlRpc/Generator/DomDocument.php
deleted file mode 100644
index 88bc05fa0cd69..0000000000000
--- a/lib/zend/Zend/XmlRpc/Generator/DomDocument.php
+++ /dev/null
@@ -1,101 +0,0 @@
-_dom->createElement($name);
-
- $this->_currentElement = $this->_currentElement->appendChild($newElement);
- }
-
- /**
- * Write XML text data into the currently opened XML element
- *
- * @param string $text
- */
- protected function _writeTextData($text)
- {
- $this->_currentElement->appendChild($this->_dom->createTextNode($text));
- }
-
- /**
- * Close an previously opened XML element
- *
- * Resets $_currentElement to the next parent node in the hierarchy
- *
- * @param string $name
- * @return void
- */
- protected function _closeElement($name)
- {
- if (isset($this->_currentElement->parentNode)) {
- $this->_currentElement = $this->_currentElement->parentNode;
- }
- }
-
- /**
- * Save XML as a string
- *
- * @return string
- */
- public function saveXml()
- {
- return $this->_dom->saveXml();
- }
-
- /**
- * Initializes internal objects
- *
- * @return void
- */
- protected function _init()
- {
- $this->_dom = new DOMDocument('1.0', $this->_encoding);
- $this->_currentElement = $this->_dom;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Generator/GeneratorAbstract.php b/lib/zend/Zend/XmlRpc/Generator/GeneratorAbstract.php
deleted file mode 100644
index 03afcd696f4c6..0000000000000
--- a/lib/zend/Zend/XmlRpc/Generator/GeneratorAbstract.php
+++ /dev/null
@@ -1,150 +0,0 @@
-_encoding = $encoding;
- $this->_init();
- }
-
- /**
- * Start XML element
- *
- * Method opens a new XML element with an element name and an optional value
- *
- * @param string $name XML tag name
- * @param string $value Optional value of the XML tag
- * @return Zend_XmlRpc_Generator_Abstract Fluent interface
- */
- public function openElement($name, $value = null)
- {
- $this->_openElement($name);
- if ($value !== null) {
- $this->_writeTextData($value);
- }
-
- return $this;
- }
-
- /**
- * End of an XML element
- *
- * Method marks the end of an XML element
- *
- * @param string $name XML tag name
- * @return Zend_XmlRpc_Generator_Abstract Fluent interface
- */
- public function closeElement($name)
- {
- $this->_closeElement($name);
-
- return $this;
- }
-
- /**
- * Return XML as a string
- *
- * @return string
- */
- abstract public function saveXml();
-
- /**
- * Return encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Returns the XML as a string and flushes all internal buffers
- *
- * @return string
- */
- public function flush()
- {
- $xml = $this->saveXml();
- $this->_init();
- return $xml;
- }
-
- /**
- * Returns XML without document declaration
- *
- * @return string
- */
- public function __toString()
- {
- return $this->stripDeclaration($this->saveXml());
- }
-
- /**
- * Removes XML declaration from a string
- *
- * @param string $xml
- * @return string
- */
- public function stripDeclaration($xml)
- {
- return preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $xml);
- }
-
- /**
- * Start XML element
- *
- * @param string $name XML element name
- */
- abstract protected function _openElement($name);
-
- /**
- * Write XML text data into the currently opened XML element
- *
- * @param string $text
- */
- abstract protected function _writeTextData($text);
-
- /**
- * End XML element
- *
- * @param string $name
- */
- abstract protected function _closeElement($name);
-}
diff --git a/lib/zend/Zend/XmlRpc/Generator/XmlWriter.php b/lib/zend/Zend/XmlRpc/Generator/XmlWriter.php
deleted file mode 100644
index a84e11d3bf424..0000000000000
--- a/lib/zend/Zend/XmlRpc/Generator/XmlWriter.php
+++ /dev/null
@@ -1,93 +0,0 @@
-_xmlWriter = new XMLWriter();
- $this->_xmlWriter->openMemory();
- $this->_xmlWriter->startDocument('1.0', $this->_encoding);
- }
-
-
- /**
- * Open a new XML element
- *
- * @param string $name XML element name
- * @return void
- */
- protected function _openElement($name)
- {
- $this->_xmlWriter->startElement($name);
- }
-
- /**
- * Write XML text data into the currently opened XML element
- *
- * @param string $text XML text data
- * @return void
- */
- protected function _writeTextData($text)
- {
- $this->_xmlWriter->text($text);
- }
-
- /**
- * Close an previously opened XML element
- *
- * @param string $name
- * @return void
- */
- protected function _closeElement($name)
- {
- $this->_xmlWriter->endElement();
-
- return $this;
- }
-
- public function saveXml()
- {
- $xml = $this->_xmlWriter->flush(false);
- return $xml;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Request.php b/lib/zend/Zend/XmlRpc/Request.php
deleted file mode 100644
index 73bb9670a3306..0000000000000
--- a/lib/zend/Zend/XmlRpc/Request.php
+++ /dev/null
@@ -1,445 +0,0 @@
-setMethod($method);
- }
-
- if ($params !== null) {
- $this->setParams($params);
- }
- }
-
-
- /**
- * Set encoding to use in request
- *
- * @param string $encoding
- * @return Zend_XmlRpc_Request
- */
- public function setEncoding($encoding)
- {
- $this->_encoding = $encoding;
- Zend_XmlRpc_Value::setEncoding($encoding);
- return $this;
- }
-
- /**
- * Retrieve current request encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Set method to call
- *
- * @param string $method
- * @return boolean Returns true on success, false if method name is invalid
- */
- public function setMethod($method)
- {
- if (!is_string($method) || !preg_match('/^[a-z0-9_.:\/]+$/i', $method)) {
- $this->_fault = new Zend_XmlRpc_Fault(634, 'Invalid method name ("' . $method . '")');
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- $this->_method = $method;
- return true;
- }
-
- /**
- * Retrieve call method
- *
- * @return string
- */
- public function getMethod()
- {
- return $this->_method;
- }
-
- /**
- * Add a parameter to the parameter stack
- *
- * Adds a parameter to the parameter stack, associating it with the type
- * $type if provided
- *
- * @param mixed $value
- * @param string $type Optional; type hinting
- * @return void
- */
- public function addParam($value, $type = null)
- {
- $this->_params[] = $value;
- if (null === $type) {
- // Detect type if not provided explicitly
- if ($value instanceof Zend_XmlRpc_Value) {
- $type = $value->getType();
- } else {
- $xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($value);
- $type = $xmlRpcValue->getType();
- }
- }
- $this->_types[] = $type;
- $this->_xmlRpcParams[] = array('value' => $value, 'type' => $type);
- }
-
- /**
- * Set the parameters array
- *
- * If called with a single, array value, that array is used to set the
- * parameters stack. If called with multiple values or a single non-array
- * value, the arguments are used to set the parameters stack.
- *
- * Best is to call with array of the format, in order to allow type hinting
- * when creating the XMLRPC values for each parameter:
- *
- * $array = array(
- * array(
- * 'value' => $value,
- * 'type' => $type
- * )[, ... ]
- * );
- *
- *
- * @access public
- * @return void
- */
- public function setParams()
- {
- $argc = func_num_args();
- $argv = func_get_args();
- if (0 == $argc) {
- return;
- }
-
- if ((1 == $argc) && is_array($argv[0])) {
- $params = array();
- $types = array();
- $wellFormed = true;
- foreach ($argv[0] as $arg) {
- if (!is_array($arg) || !isset($arg['value'])) {
- $wellFormed = false;
- break;
- }
- $params[] = $arg['value'];
-
- if (!isset($arg['type'])) {
- $xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($arg['value']);
- $arg['type'] = $xmlRpcValue->getType();
- }
- $types[] = $arg['type'];
- }
- if ($wellFormed) {
- $this->_xmlRpcParams = $argv[0];
- $this->_params = $params;
- $this->_types = $types;
- } else {
- $this->_params = $argv[0];
- $this->_types = array();
- $xmlRpcParams = array();
- foreach ($argv[0] as $arg) {
- if ($arg instanceof Zend_XmlRpc_Value) {
- $type = $arg->getType();
- } else {
- $xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($arg);
- $type = $xmlRpcValue->getType();
- }
- $xmlRpcParams[] = array('value' => $arg, 'type' => $type);
- $this->_types[] = $type;
- }
- $this->_xmlRpcParams = $xmlRpcParams;
- }
- return;
- }
-
- $this->_params = $argv;
- $this->_types = array();
- $xmlRpcParams = array();
- foreach ($argv as $arg) {
- if ($arg instanceof Zend_XmlRpc_Value) {
- $type = $arg->getType();
- } else {
- $xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($arg);
- $type = $xmlRpcValue->getType();
- }
- $xmlRpcParams[] = array('value' => $arg, 'type' => $type);
- $this->_types[] = $type;
- }
- $this->_xmlRpcParams = $xmlRpcParams;
- }
-
- /**
- * Retrieve the array of parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_params;
- }
-
- /**
- * Return parameter types
- *
- * @return array
- */
- public function getTypes()
- {
- return $this->_types;
- }
-
- /**
- * Load XML and parse into request components
- *
- * @param string $request
- * @return boolean True on success, false if an error occurred.
- */
- public function loadXml($request)
- {
- if (!is_string($request)) {
- $this->_fault = new Zend_XmlRpc_Fault(635);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- try {
- $xml = Zend_Xml_Security::scan($request);
- } catch (Zend_Xml_Exception $e) {
- // Not valid XML
- $this->_fault = new Zend_XmlRpc_Fault(631);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- // Check for method name
- if (empty($xml->methodName)) {
- // Missing method name
- $this->_fault = new Zend_XmlRpc_Fault(632);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- $this->_method = (string) $xml->methodName;
-
- // Check for parameters
- if (!empty($xml->params)) {
- $types = array();
- $argv = array();
- foreach ($xml->params->children() as $param) {
- if (!isset($param->value)) {
- $this->_fault = new Zend_XmlRpc_Fault(633);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- try {
- $param = Zend_XmlRpc_Value::getXmlRpcValue($param->value, Zend_XmlRpc_Value::XML_STRING);
- $types[] = $param->getType();
- $argv[] = $param->getValue();
- } catch (Exception $e) {
- $this->_fault = new Zend_XmlRpc_Fault(636);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
- }
-
- $this->_types = $types;
- $this->_params = $argv;
- }
-
- $this->_xml = $request;
-
- return true;
- }
-
- /**
- * Does the current request contain errors and should it return a fault
- * response?
- *
- * @return boolean
- */
- public function isFault()
- {
- return $this->_fault instanceof Zend_XmlRpc_Fault;
- }
-
- /**
- * Retrieve the fault response, if any
- *
- * @return null|Zend_XmlRpc_Fault
- */
- public function getFault()
- {
- return $this->_fault;
- }
-
- /**
- * Retrieve method parameters as XMLRPC values
- *
- * @return array
- */
- protected function _getXmlRpcParams()
- {
- $params = array();
- if (is_array($this->_xmlRpcParams)) {
- foreach ($this->_xmlRpcParams as $param) {
- $value = $param['value'];
- $type = isset($param['type']) ? $param['type'] : Zend_XmlRpc_Value::AUTO_DETECT_TYPE;
-
- if (!$value instanceof Zend_XmlRpc_Value) {
- $value = Zend_XmlRpc_Value::getXmlRpcValue($value, $type);
- }
- $params[] = $value;
- }
- }
-
- return $params;
- }
-
- /**
- * Create XML request
- *
- * @return string
- */
- public function saveXml()
- {
- $args = $this->_getXmlRpcParams();
- $method = $this->getMethod();
-
- $generator = Zend_XmlRpc_Value::getGenerator();
- $generator->openElement('methodCall')
- ->openElement('methodName', $method)
- ->closeElement('methodName');
-
- if (is_array($args) && count($args)) {
- $generator->openElement('params');
-
- foreach ($args as $arg) {
- $generator->openElement('param');
- $arg->generateXml();
- $generator->closeElement('param');
- }
- $generator->closeElement('params');
- }
- $generator->closeElement('methodCall');
-
- return $generator->flush();
- }
-
- /**
- * Return XML request
- *
- * @return string
- */
- public function __toString()
- {
- return $this->saveXML();
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Request/Http.php b/lib/zend/Zend/XmlRpc/Request/Http.php
deleted file mode 100644
index df058a1a84a49..0000000000000
--- a/lib/zend/Zend/XmlRpc/Request/Http.php
+++ /dev/null
@@ -1,124 +0,0 @@
-_fault = new Zend_XmlRpc_Fault(630);
- return;
- }
-
- $this->_xml = $xml;
-
- $this->loadXml($xml);
- }
-
- /**
- * Retrieve the raw XML request
- *
- * @return string
- */
- public function getRawRequest()
- {
- return $this->_xml;
- }
-
- /**
- * Get headers
- *
- * Gets all headers as key => value pairs and returns them.
- *
- * @return array
- */
- public function getHeaders()
- {
- if (null === $this->_headers) {
- $this->_headers = array();
- foreach ($_SERVER as $key => $value) {
- if ('HTTP_' == substr($key, 0, 5)) {
- $header = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
- $this->_headers[$header] = $value;
- }
- }
- }
-
- return $this->_headers;
- }
-
- /**
- * Retrieve the full HTTP request, including headers and XML
- *
- * @return string
- */
- public function getFullRequest()
- {
- $request = '';
- foreach ($this->getHeaders() as $key => $value) {
- $request .= $key . ': ' . $value . "\n";
- }
-
- $request .= $this->_xml;
-
- return $request;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Request/Stdin.php b/lib/zend/Zend/XmlRpc/Request/Stdin.php
deleted file mode 100644
index d6bb539e1994f..0000000000000
--- a/lib/zend/Zend/XmlRpc/Request/Stdin.php
+++ /dev/null
@@ -1,84 +0,0 @@
-_fault = new Zend_XmlRpc_Server_Exception(630);
- return;
- }
-
- $xml = '';
- while (!feof($fh)) {
- $xml .= fgets($fh);
- }
- fclose($fh);
-
- $this->_xml = $xml;
-
- $this->loadXml($xml);
- }
-
- /**
- * Retrieve the raw XML request
- *
- * @return string
- */
- public function getRawRequest()
- {
- return $this->_xml;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Response.php b/lib/zend/Zend/XmlRpc/Response.php
deleted file mode 100644
index be5a6cbb4e568..0000000000000
--- a/lib/zend/Zend/XmlRpc/Response.php
+++ /dev/null
@@ -1,255 +0,0 @@
-setReturnValue($return, $type);
- }
-
- /**
- * Set encoding to use in response
- *
- * @param string $encoding
- * @return Zend_XmlRpc_Response
- */
- public function setEncoding($encoding)
- {
- $this->_encoding = $encoding;
- Zend_XmlRpc_Value::setEncoding($encoding);
- return $this;
- }
-
- /**
- * Retrieve current response encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Set the return value
- *
- * Sets the return value, with optional type hinting if provided.
- *
- * @param mixed $value
- * @param string $type
- * @return void
- */
- public function setReturnValue($value, $type = null)
- {
- $this->_return = $value;
- $this->_type = (string) $type;
- }
-
- /**
- * Retrieve the return value
- *
- * @return mixed
- */
- public function getReturnValue()
- {
- return $this->_return;
- }
-
- /**
- * Retrieve the XMLRPC value for the return value
- *
- * @return Zend_XmlRpc_Value
- */
- protected function _getXmlRpcReturn()
- {
- return Zend_XmlRpc_Value::getXmlRpcValue($this->_return);
- }
-
- /**
- * Is the response a fault response?
- *
- * @return boolean
- */
- public function isFault()
- {
- return $this->_fault instanceof Zend_XmlRpc_Fault;
- }
-
- /**
- * Returns the fault, if any.
- *
- * @return null|Zend_XmlRpc_Fault
- */
- public function getFault()
- {
- return $this->_fault;
- }
-
- /**
- * Load a response from an XML response
- *
- * Attempts to load a response from an XMLRPC response, autodetecting if it
- * is a fault response.
- *
- * @param string $response
- * @return boolean True if a valid XMLRPC response, false if a fault
- * response or invalid input
- */
- public function loadXml($response)
- {
- if (!is_string($response)) {
- $this->_fault = new Zend_XmlRpc_Fault(650);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- try {
- $xml = Zend_Xml_Security::scan($response);
- } catch (Zend_Xml_Exception $e) {
- // Not valid XML
- $this->_fault = new Zend_XmlRpc_Fault(651);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- if (!empty($xml->fault)) {
- // fault response
- $this->_fault = new Zend_XmlRpc_Fault();
- $this->_fault->setEncoding($this->getEncoding());
- $this->_fault->loadXml($response);
- return false;
- }
-
- if (empty($xml->params)) {
- // Invalid response
- $this->_fault = new Zend_XmlRpc_Fault(652);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- try {
- if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
- }
- $valueXml = $xml->params->param->value->asXML();
- $value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
- } catch (Zend_XmlRpc_Value_Exception $e) {
- $this->_fault = new Zend_XmlRpc_Fault(653);
- $this->_fault->setEncoding($this->getEncoding());
- return false;
- }
-
- $this->setReturnValue($value->getValue());
- return true;
- }
-
- /**
- * Return response as XML
- *
- * @return string
- */
- public function saveXml()
- {
- $value = $this->_getXmlRpcReturn();
- $generator = Zend_XmlRpc_Value::getGenerator();
- $generator->openElement('methodResponse')
- ->openElement('params')
- ->openElement('param');
- $value->generateXml();
- $generator->closeElement('param')
- ->closeElement('params')
- ->closeElement('methodResponse');
-
- return $generator->flush();
- }
-
- /**
- * Return XML response
- *
- * @return string
- */
- public function __toString()
- {
- return $this->saveXML();
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Response/Http.php b/lib/zend/Zend/XmlRpc/Response/Http.php
deleted file mode 100644
index 5bc246ba678d0..0000000000000
--- a/lib/zend/Zend/XmlRpc/Response/Http.php
+++ /dev/null
@@ -1,51 +0,0 @@
-getEncoding()));
- }
-
- return parent::__toString();
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Server.php b/lib/zend/Zend/XmlRpc/Server.php
deleted file mode 100644
index 1c747084b0c6f..0000000000000
--- a/lib/zend/Zend/XmlRpc/Server.php
+++ /dev/null
@@ -1,615 +0,0 @@
-
- * require_once 'Zend/XmlRpc/Server.php';
- * require_once 'Zend/XmlRpc/Server/Cache.php';
- * require_once 'Zend/XmlRpc/Server/Fault.php';
- * require_once 'My/Exception.php';
- * require_once 'My/Fault/Observer.php';
- *
- * // Instantiate server
- * $server = new Zend_XmlRpc_Server();
- *
- * // Allow some exceptions to report as fault responses:
- * Zend_XmlRpc_Server_Fault::attachFaultException('My_Exception');
- * Zend_XmlRpc_Server_Fault::attachObserver('My_Fault_Observer');
- *
- * // Get or build dispatch table:
- * if (!Zend_XmlRpc_Server_Cache::get($filename, $server)) {
- * require_once 'Some/Service/Class.php';
- * require_once 'Another/Service/Class.php';
- *
- * // Attach Some_Service_Class in 'some' namespace
- * $server->setClass('Some_Service_Class', 'some');
- *
- * // Attach Another_Service_Class in 'another' namespace
- * $server->setClass('Another_Service_Class', 'another');
- *
- * // Create dispatch table cache file
- * Zend_XmlRpc_Server_Cache::save($filename, $server);
- * }
- *
- * $response = $server->handle();
- * echo $response;
- *
- *
- * @category Zend
- * @package Zend_XmlRpc
- * @subpackage Server
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_XmlRpc_Server extends Zend_Server_Abstract
-{
- /**
- * Character encoding
- * @var string
- */
- protected $_encoding = 'UTF-8';
-
- /**
- * Request processed
- * @var null|Zend_XmlRpc_Request
- */
- protected $_request = null;
-
- /**
- * Class to use for responses; defaults to {@link Zend_XmlRpc_Response_Http}
- * @var string
- */
- protected $_responseClass = 'Zend_XmlRpc_Response_Http';
-
- /**
- * Dispatch table of name => method pairs
- * @var Zend_Server_Definition
- */
- protected $_table;
-
- /**
- * PHP types => XML-RPC types
- * @var array
- */
- protected $_typeMap = array(
- 'i4' => 'i4',
- 'int' => 'int',
- 'integer' => 'int',
- 'Zend_Crypt_Math_BigInteger' => 'i8',
- 'i8' => 'i8',
- 'ex:i8' => 'i8',
- 'double' => 'double',
- 'float' => 'double',
- 'real' => 'double',
- 'boolean' => 'boolean',
- 'bool' => 'boolean',
- 'true' => 'boolean',
- 'false' => 'boolean',
- 'string' => 'string',
- 'str' => 'string',
- 'base64' => 'base64',
- 'dateTime.iso8601' => 'dateTime.iso8601',
- 'date' => 'dateTime.iso8601',
- 'time' => 'dateTime.iso8601',
- 'time' => 'dateTime.iso8601',
- 'Zend_Date' => 'dateTime.iso8601',
- 'DateTime' => 'dateTime.iso8601',
- 'array' => 'array',
- 'struct' => 'struct',
- 'null' => 'nil',
- 'nil' => 'nil',
- 'ex:nil' => 'nil',
- 'void' => 'void',
- 'mixed' => 'struct',
- );
-
- /**
- * Send arguments to all methods or just constructor?
- *
- * @var bool
- */
- protected $_sendArgumentsToAllMethods = true;
-
- /**
- * Constructor
- *
- * Creates system.* methods.
- *
- * @return void
- */
- public function __construct()
- {
- $this->_table = new Zend_Server_Definition();
- $this->_registerSystemMethods();
- }
-
- /**
- * Proxy calls to system object
- *
- * @param string $method
- * @param array $params
- * @return mixed
- * @throws Zend_XmlRpc_Server_Exception
- */
- public function __call($method, $params)
- {
- $system = $this->getSystem();
- if (!method_exists($system, $method)) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Unknown instance method called on server: ' . $method);
- }
- return call_user_func_array(array($system, $method), $params);
- }
-
- /**
- * Attach a callback as an XMLRPC method
- *
- * Attaches a callback as an XMLRPC method, prefixing the XMLRPC method name
- * with $namespace, if provided. Reflection is done on the callback's
- * docblock to create the methodHelp for the XMLRPC method.
- *
- * Additional arguments to pass to the function at dispatch may be passed;
- * any arguments following the namespace will be aggregated and passed at
- * dispatch time.
- *
- * @param string|array $function Valid callback
- * @param string $namespace Optional namespace prefix
- * @return void
- * @throws Zend_XmlRpc_Server_Exception
- */
- public function addFunction($function, $namespace = '')
- {
- if (!is_string($function) && !is_array($function)) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
- }
-
- $argv = null;
- if (2 < func_num_args()) {
- $argv = func_get_args();
- $argv = array_slice($argv, 2);
- }
-
- $function = (array) $function;
- foreach ($function as $func) {
- if (!is_string($func) || !function_exists($func)) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
- }
- $reflection = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
- $this->_buildSignature($reflection);
- }
- }
-
- /**
- * Attach class methods as XMLRPC method handlers
- *
- * $class may be either a class name or an object. Reflection is done on the
- * class or object to determine the available public methods, and each is
- * attached to the server as an available method; if a $namespace has been
- * provided, that namespace is used to prefix the XMLRPC method names.
- *
- * Any additional arguments beyond $namespace will be passed to a method at
- * invocation.
- *
- * @param string|object $class
- * @param string $namespace Optional
- * @param mixed $argv Optional arguments to pass to methods
- * @return void
- * @throws Zend_XmlRpc_Server_Exception on invalid input
- */
- public function setClass($class, $namespace = '', $argv = null)
- {
- if (is_string($class) && !class_exists($class)) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Invalid method class', 610);
- }
-
- $args = null;
- if (2 < func_num_args()) {
- $args = func_get_args();
- $args = array_slice($args, 2);
- }
-
- $dispatchable = Zend_Server_Reflection::reflectClass($class, $args, $namespace);
- foreach ($dispatchable->getMethods() as $reflection) {
- $this->_buildSignature($reflection, $class);
- }
- }
-
- /**
- * Raise an xmlrpc server fault
- *
- * @param string|Exception $fault
- * @param int $code
- * @return Zend_XmlRpc_Server_Fault
- */
- public function fault($fault = null, $code = 404)
- {
- if (!$fault instanceof Exception) {
- $fault = (string) $fault;
- if (empty($fault)) {
- $fault = 'Unknown Error';
- }
- require_once 'Zend/XmlRpc/Server/Exception.php';
- $fault = new Zend_XmlRpc_Server_Exception($fault, $code);
- }
-
- return Zend_XmlRpc_Server_Fault::getInstance($fault);
- }
-
- /**
- * Handle an xmlrpc call
- *
- * @param Zend_XmlRpc_Request $request Optional
- * @return Zend_XmlRpc_Response|Zend_XmlRpc_Fault
- */
- public function handle($request = false)
- {
- // Get request
- if ((!$request || !$request instanceof Zend_XmlRpc_Request)
- && (null === ($request = $this->getRequest()))
- ) {
- require_once 'Zend/XmlRpc/Request/Http.php';
- $request = new Zend_XmlRpc_Request_Http();
- $request->setEncoding($this->getEncoding());
- }
-
- $this->setRequest($request);
-
- if ($request->isFault()) {
- $response = $request->getFault();
- } else {
- try {
- $response = $this->_handle($request);
- } catch (Exception $e) {
- $response = $this->fault($e);
- }
- }
-
- // Set output encoding
- $response->setEncoding($this->getEncoding());
-
- return $response;
- }
-
- /**
- * Load methods as returned from {@link getFunctions}
- *
- * Typically, you will not use this method; it will be called using the
- * results pulled from {@link Zend_XmlRpc_Server_Cache::get()}.
- *
- * @param array|Zend_Server_Definition $definition
- * @return void
- * @throws Zend_XmlRpc_Server_Exception on invalid input
- */
- public function loadFunctions($definition)
- {
- if (!is_array($definition) && (!$definition instanceof Zend_Server_Definition)) {
- if (is_object($definition)) {
- $type = get_class($definition);
- } else {
- $type = gettype($definition);
- }
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Unable to load server definition; must be an array or Zend_Server_Definition, received ' . $type, 612);
- }
-
- $this->_table->clearMethods();
- $this->_registerSystemMethods();
-
- if ($definition instanceof Zend_Server_Definition) {
- $definition = $definition->getMethods();
- }
-
- foreach ($definition as $key => $method) {
- if ('system.' == substr($key, 0, 7)) {
- continue;
- }
- $this->_table->addMethod($method, $key);
- }
- }
-
- /**
- * Set encoding
- *
- * @param string $encoding
- * @return Zend_XmlRpc_Server
- */
- public function setEncoding($encoding)
- {
- $this->_encoding = $encoding;
- Zend_XmlRpc_Value::setEncoding($encoding);
- return $this;
- }
-
- /**
- * Retrieve current encoding
- *
- * @return string
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Do nothing; persistence is handled via {@link Zend_XmlRpc_Server_Cache}
- *
- * @param mixed $mode
- * @return void
- */
- public function setPersistence($mode)
- {
- }
-
- /**
- * Set the request object
- *
- * @param string|Zend_XmlRpc_Request $request
- * @return Zend_XmlRpc_Server
- * @throws Zend_XmlRpc_Server_Exception on invalid request class or object
- */
- public function setRequest($request)
- {
- if (is_string($request) && class_exists($request)) {
- $request = new $request();
- if (!$request instanceof Zend_XmlRpc_Request) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Invalid request class');
- }
- $request->setEncoding($this->getEncoding());
- } elseif (!$request instanceof Zend_XmlRpc_Request) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Invalid request object');
- }
-
- $this->_request = $request;
- return $this;
- }
-
- /**
- * Return currently registered request object
- *
- * @return null|Zend_XmlRpc_Request
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set the class to use for the response
- *
- * @param string $class
- * @return boolean True if class was set, false if not
- */
- public function setResponseClass($class)
- {
- if (!class_exists($class) or
- ($c = new ReflectionClass($class) and !$c->isSubclassOf('Zend_XmlRpc_Response'))) {
-
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Invalid response class');
- }
- $this->_responseClass = $class;
- return true;
- }
-
- /**
- * Retrieve current response class
- *
- * @return string
- */
- public function getResponseClass()
- {
- return $this->_responseClass;
- }
-
- /**
- * Retrieve dispatch table
- *
- * @return array
- */
- public function getDispatchTable()
- {
- return $this->_table;
- }
-
- /**
- * Returns a list of registered methods
- *
- * Returns an array of dispatchables (Zend_Server_Reflection_Function,
- * _Method, and _Class items).
- *
- * @return array
- */
- public function getFunctions()
- {
- return $this->_table->toArray();
- }
-
- /**
- * Retrieve system object
- *
- * @return Zend_XmlRpc_Server_System
- */
- public function getSystem()
- {
- return $this->_system;
- }
-
- /**
- * Send arguments to all methods?
- *
- * If setClass() is used to add classes to the server, this flag defined
- * how to handle arguments. If set to true, all methods including constructor
- * will receive the arguments. If set to false, only constructor will receive the
- * arguments
- */
- public function sendArgumentsToAllMethods($flag = null)
- {
- if ($flag === null) {
- return $this->_sendArgumentsToAllMethods;
- }
-
- $this->_sendArgumentsToAllMethods = (bool)$flag;
- return $this;
- }
-
- /**
- * Map PHP type to XML-RPC type
- *
- * @param string $type
- * @return string
- */
- protected function _fixType($type)
- {
- if (isset($this->_typeMap[$type])) {
- return $this->_typeMap[$type];
- }
- return 'void';
- }
-
- /**
- * Handle an xmlrpc call (actual work)
- *
- * @param Zend_XmlRpc_Request $request
- * @return Zend_XmlRpc_Response
- * @throws Zend_XmlRpcServer_Exception|Exception
- * Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise,
- * any other exception may be thrown by the callback
- */
- protected function _handle(Zend_XmlRpc_Request $request)
- {
- $method = $request->getMethod();
-
- // Check for valid method
- if (!$this->_table->hasMethod($method)) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 620);
- }
-
- $info = $this->_table->getMethod($method);
- $params = $request->getParams();
- $argv = $info->getInvokeArguments();
- if (0 < count($argv) and $this->sendArgumentsToAllMethods()) {
- $params = array_merge($params, $argv);
- }
-
- // Check calling parameters against signatures
- $matched = false;
- $sigCalled = $request->getTypes();
-
- $sigLength = count($sigCalled);
- $paramsLen = count($params);
- if ($sigLength < $paramsLen) {
- for ($i = $sigLength; $i < $paramsLen; ++$i) {
- $xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($params[$i]);
- $sigCalled[] = $xmlRpcValue->getType();
- }
- }
-
- $signatures = $info->getPrototypes();
- foreach ($signatures as $signature) {
- $sigParams = $signature->getParameters();
- if ($sigCalled === $sigParams) {
- $matched = true;
- break;
- }
- }
- if (!$matched) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Calling parameters do not match signature', 623);
- }
-
- $return = $this->_dispatch($info, $params);
- $responseClass = $this->getResponseClass();
- return new $responseClass($return);
- }
-
- /**
- * Register system methods with the server
- *
- * @return void
- */
- protected function _registerSystemMethods()
- {
- $system = new Zend_XmlRpc_Server_System($this);
- $this->_system = $system;
- $this->setClass($system, 'system');
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Server/Cache.php b/lib/zend/Zend/XmlRpc/Server/Cache.php
deleted file mode 100644
index 7c52902b62f68..0000000000000
--- a/lib/zend/Zend/XmlRpc/Server/Cache.php
+++ /dev/null
@@ -1,46 +0,0 @@
- true);
-
- /**
- * @var array Array of fault observers
- */
- protected static $_observers = array();
-
- /**
- * Constructor
- *
- * @param Exception $e
- * @return Zend_XmlRpc_Server_Fault
- */
- public function __construct(Exception $e)
- {
- $this->_exception = $e;
- $code = 404;
- $message = 'Unknown error';
- $exceptionClass = get_class($e);
-
- foreach (array_keys(self::$_faultExceptionClasses) as $class) {
- if ($e instanceof $class) {
- $code = $e->getCode();
- $message = $e->getMessage();
- break;
- }
- }
-
- parent::__construct($code, $message);
-
- // Notify exception observers, if present
- if (!empty(self::$_observers)) {
- foreach (array_keys(self::$_observers) as $observer) {
- call_user_func(array($observer, 'observe'), $this);
- }
- }
- }
-
- /**
- * Return Zend_XmlRpc_Server_Fault instance
- *
- * @param Exception $e
- * @return Zend_XmlRpc_Server_Fault
- */
- public static function getInstance(Exception $e)
- {
- return new self($e);
- }
-
- /**
- * Attach valid exceptions that can be used to define xmlrpc faults
- *
- * @param string|array $classes Class name or array of class names
- * @return void
- */
- public static function attachFaultException($classes)
- {
- if (!is_array($classes)) {
- $classes = (array) $classes;
- }
-
- foreach ($classes as $class) {
- if (is_string($class) && class_exists($class)) {
- self::$_faultExceptionClasses[$class] = true;
- }
- }
- }
-
- /**
- * Detach fault exception classes
- *
- * @param string|array $classes Class name or array of class names
- * @return void
- */
- public static function detachFaultException($classes)
- {
- if (!is_array($classes)) {
- $classes = (array) $classes;
- }
-
- foreach ($classes as $class) {
- if (is_string($class) && isset(self::$_faultExceptionClasses[$class])) {
- unset(self::$_faultExceptionClasses[$class]);
- }
- }
- }
-
- /**
- * Attach an observer class
- *
- * Allows observation of xmlrpc server faults, thus allowing logging or mail
- * notification of fault responses on the xmlrpc server.
- *
- * Expects a valid class name; that class must have a public static method
- * 'observe' that accepts an exception as its sole argument.
- *
- * @param string $class
- * @return boolean
- */
- public static function attachObserver($class)
- {
- if (!is_string($class)
- || !class_exists($class)
- || !is_callable(array($class, 'observe')))
- {
- return false;
- }
-
- if (!isset(self::$_observers[$class])) {
- self::$_observers[$class] = true;
- }
-
- return true;
- }
-
- /**
- * Detach an observer
- *
- * @param string $class
- * @return boolean
- */
- public static function detachObserver($class)
- {
- if (!isset(self::$_observers[$class])) {
- return false;
- }
-
- unset(self::$_observers[$class]);
- return true;
- }
-
- /**
- * Retrieve the exception
- *
- * @access public
- * @return Exception
- */
- public function getException()
- {
- return $this->_exception;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Server/System.php b/lib/zend/Zend/XmlRpc/Server/System.php
deleted file mode 100644
index 340eb1cd739d9..0000000000000
--- a/lib/zend/Zend/XmlRpc/Server/System.php
+++ /dev/null
@@ -1,162 +0,0 @@
-_server = $server;
- }
-
- /**
- * List all available XMLRPC methods
- *
- * Returns an array of methods.
- *
- * @return array
- */
- public function listMethods()
- {
- $table = $this->_server->getDispatchTable()->getMethods();
- return array_keys($table);
- }
-
- /**
- * Display help message for an XMLRPC method
- *
- * @param string $method
- * @return string
- */
- public function methodHelp($method)
- {
- $table = $this->_server->getDispatchTable();
- if (!$table->hasMethod($method)) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 640);
- }
-
- return $table->getMethod($method)->getMethodHelp();
- }
-
- /**
- * Return a method signature
- *
- * @param string $method
- * @return array
- */
- public function methodSignature($method)
- {
- $table = $this->_server->getDispatchTable();
- if (!$table->hasMethod($method)) {
- require_once 'Zend/XmlRpc/Server/Exception.php';
- throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 640);
- }
- $method = $table->getMethod($method)->toArray();
- return $method['prototypes'];
- }
-
- /**
- * Multicall - boxcar feature of XML-RPC for calling multiple methods
- * in a single request.
- *
- * Expects a an array of structs representing method calls, each element
- * having the keys:
- * - methodName
- * - params
- *
- * Returns an array of responses, one for each method called, with the value
- * returned by the method. If an error occurs for a given method, returns a
- * struct with a fault response.
- *
- * @see http://www.xmlrpc.com/discuss/msgReader$1208
- * @param array $methods
- * @return array
- */
- public function multicall($methods)
- {
- $responses = array();
- foreach ($methods as $method) {
- $fault = false;
- if (!is_array($method)) {
- $fault = $this->_server->fault('system.multicall expects each method to be a struct', 601);
- } elseif (!isset($method['methodName'])) {
- $fault = $this->_server->fault('Missing methodName: ' . var_export($methods, 1), 602);
- } elseif (!isset($method['params'])) {
- $fault = $this->_server->fault('Missing params', 603);
- } elseif (!is_array($method['params'])) {
- $fault = $this->_server->fault('Params must be an array', 604);
- } else {
- if ('system.multicall' == $method['methodName']) {
- // don't allow recursive calls to multicall
- $fault = $this->_server->fault('Recursive system.multicall forbidden', 605);
- }
- }
-
- if (!$fault) {
- try {
- $request = new Zend_XmlRpc_Request();
- $request->setMethod($method['methodName']);
- $request->setParams($method['params']);
- $response = $this->_server->handle($request);
- if ($response instanceof Zend_XmlRpc_Fault
- || $response->isFault()
- ) {
- $fault = $response;
- } else {
- $responses[] = $response->getReturnValue();
- }
- } catch (Exception $e) {
- $fault = $this->_server->fault($e);
- }
- }
-
- if ($fault) {
- $responses[] = array(
- 'faultCode' => $fault->getCode(),
- 'faultString' => $fault->getMessage()
- );
- }
- }
-
- return $responses;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value.php b/lib/zend/Zend/XmlRpc/Value.php
deleted file mode 100644
index 6b22449964961..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value.php
+++ /dev/null
@@ -1,525 +0,0 @@
-_type;
- }
-
- /**
- * Get XML generator instance
- *
- * @return Zend_XmlRpc_Generator_GeneratorAbstract
- */
- public static function getGenerator()
- {
- if (!self::$_generator) {
- if (extension_loaded('xmlwriter')) {
- require_once 'Zend/XmlRpc/Generator/XmlWriter.php';
- self::$_generator = new Zend_XmlRpc_Generator_XmlWriter();
- } else {
- require_once 'Zend/XmlRpc/Generator/DomDocument.php';
- self::$_generator = new Zend_XmlRpc_Generator_DomDocument();
- }
- }
-
- return self::$_generator;
- }
-
- /**
- * Sets XML generator instance
- *
- * @param Zend_XmlRpc_Generator_GeneratorAbstract $generator
- * @return void
- */
- public static function setGenerator(Zend_XmlRpc_Generator_GeneratorAbstract $generator)
- {
- self::$_generator = $generator;
- }
-
- /**
- * Changes the encoding of the generator
- *
- * @param string $encoding
- * @return void
- */
- public static function setEncoding($encoding)
- {
- $generator = self::getGenerator();
- $newGenerator = new $generator($encoding);
- self::setGenerator($newGenerator);
- }
-
- /**
- * Return the value of this object, convert the XML-RPC native value into a PHP variable
- *
- * @return mixed
- */
- abstract public function getValue();
-
-
- /**
- * Return the XML code that represent a native MXL-RPC value
- *
- * @return string
- */
- public function saveXml()
- {
- if (!$this->_xml) {
- $this->generateXml();
- $this->_xml = (string) $this->getGenerator();
- }
- return $this->_xml;
- }
-
- /**
- * Generate XML code that represent a native XML/RPC value
- *
- * @return void
- */
- public function generateXml()
- {
- $this->_generateXml();
- }
-
- /**
- * Creates a Zend_XmlRpc_Value* object, representing a native XML-RPC value
- * A XmlRpcValue object can be created in 3 ways:
- * 1. Autodetecting the native type out of a PHP variable
- * (if $type is not set or equal to Zend_XmlRpc_Value::AUTO_DETECT_TYPE)
- * 2. By specifing the native type ($type is one of the Zend_XmlRpc_Value::XMLRPC_TYPE_* constants)
- * 3. From a XML string ($type is set to Zend_XmlRpc_Value::XML_STRING)
- *
- * By default the value type is autodetected according to it's PHP type
- *
- * @param mixed $value
- * @param Zend_XmlRpc_Value::constant $type
- *
- * @return Zend_XmlRpc_Value
- * @static
- */
- public static function getXmlRpcValue($value, $type = self::AUTO_DETECT_TYPE)
- {
- switch ($type) {
- case self::AUTO_DETECT_TYPE:
- // Auto detect the XML-RPC native type from the PHP type of $value
- return self::_phpVarToNativeXmlRpc($value);
-
- case self::XML_STRING:
- // Parse the XML string given in $value and get the XML-RPC value in it
- return self::_xmlStringToNativeXmlRpc($value);
-
- case self::XMLRPC_TYPE_I4:
- // fall through to the next case
- case self::XMLRPC_TYPE_INTEGER:
- require_once 'Zend/XmlRpc/Value/Integer.php';
- return new Zend_XmlRpc_Value_Integer($value);
-
- case self::XMLRPC_TYPE_I8:
- // fall through to the next case
- case self::XMLRPC_TYPE_APACHEI8:
- require_once 'Zend/XmlRpc/Value/BigInteger.php';
- return new Zend_XmlRpc_Value_BigInteger($value);
-
- case self::XMLRPC_TYPE_DOUBLE:
- require_once 'Zend/XmlRpc/Value/Double.php';
- return new Zend_XmlRpc_Value_Double($value);
-
- case self::XMLRPC_TYPE_BOOLEAN:
- require_once 'Zend/XmlRpc/Value/Boolean.php';
- return new Zend_XmlRpc_Value_Boolean($value);
-
- case self::XMLRPC_TYPE_STRING:
- require_once 'Zend/XmlRpc/Value/String.php';
- return new Zend_XmlRpc_Value_String($value);
-
- case self::XMLRPC_TYPE_BASE64:
- require_once 'Zend/XmlRpc/Value/Base64.php';
- return new Zend_XmlRpc_Value_Base64($value);
-
- case self::XMLRPC_TYPE_NIL:
- // fall through to the next case
- case self::XMLRPC_TYPE_APACHENIL:
- require_once 'Zend/XmlRpc/Value/Nil.php';
- return new Zend_XmlRpc_Value_Nil();
-
- case self::XMLRPC_TYPE_DATETIME:
- require_once 'Zend/XmlRpc/Value/DateTime.php';
- return new Zend_XmlRpc_Value_DateTime($value);
-
- case self::XMLRPC_TYPE_ARRAY:
- require_once 'Zend/XmlRpc/Value/Array.php';
- return new Zend_XmlRpc_Value_Array($value);
-
- case self::XMLRPC_TYPE_STRUCT:
- require_once 'Zend/XmlRpc/Value/Struct.php';
- return new Zend_XmlRpc_Value_Struct($value);
-
- default:
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception('Given type is not a '. __CLASS__ .' constant');
- }
- }
-
- /**
- * Get XML-RPC type for a PHP native variable
- *
- * @static
- * @param mixed $value
- * @return string
- */
- public static function getXmlRpcTypeByValue($value)
- {
- if (is_object($value)) {
- if ($value instanceof Zend_XmlRpc_Value) {
- return $value->getType();
- } elseif (($value instanceof Zend_Date) || ($value instanceof DateTime)) {
- return self::XMLRPC_TYPE_DATETIME;
- }
- return self::getXmlRpcTypeByValue(get_object_vars($value));
- } elseif (is_array($value)) {
- if (!empty($value) && is_array($value) && (array_keys($value) !== range(0, count($value) - 1))) {
- return self::XMLRPC_TYPE_STRUCT;
- }
- return self::XMLRPC_TYPE_ARRAY;
- } elseif (is_int($value)) {
- return ($value > PHP_INT_MAX) ? self::XMLRPC_TYPE_I8 : self::XMLRPC_TYPE_INTEGER;
- } elseif (is_double($value)) {
- return self::XMLRPC_TYPE_DOUBLE;
- } elseif (is_bool($value)) {
- return self::XMLRPC_TYPE_BOOLEAN;
- } elseif (is_null($value)) {
- return self::XMLRPC_TYPE_NIL;
- } elseif (is_string($value)) {
- return self::XMLRPC_TYPE_STRING;
- }
- throw new Zend_XmlRpc_Value_Exception(sprintf(
- 'No matching XMLRPC type found for php type %s.',
- gettype($value)
- ));
- }
-
- /**
- * Transform a PHP native variable into a XML-RPC native value
- *
- * @param mixed $value The PHP variable for convertion
- *
- * @return Zend_XmlRpc_Value
- * @static
- */
- protected static function _phpVarToNativeXmlRpc($value)
- {
- // @see http://framework.zend.com/issues/browse/ZF-8623
- if (is_object($value)) {
- if ($value instanceof Zend_XmlRpc_Value) {
- return $value;
- }
- if ($value instanceof Zend_Crypt_Math_BigInteger) {
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception(
- 'Using Zend_Crypt_Math_BigInteger to get an ' .
- 'instance of Zend_XmlRpc_Value_BigInteger is not ' .
- 'available anymore.'
- );
- }
- }
-
- switch (self::getXmlRpcTypeByValue($value))
- {
- case self::XMLRPC_TYPE_DATETIME:
- require_once 'Zend/XmlRpc/Value/DateTime.php';
- return new Zend_XmlRpc_Value_DateTime($value);
-
- case self::XMLRPC_TYPE_ARRAY:
- require_once 'Zend/XmlRpc/Value/Array.php';
- return new Zend_XmlRpc_Value_Array($value);
-
- case self::XMLRPC_TYPE_STRUCT:
- require_once 'Zend/XmlRpc/Value/Struct.php';
- return new Zend_XmlRpc_Value_Struct($value);
-
- case self::XMLRPC_TYPE_INTEGER:
- require_once 'Zend/XmlRpc/Value/Integer.php';
- return new Zend_XmlRpc_Value_Integer($value);
-
- case self::XMLRPC_TYPE_DOUBLE:
- require_once 'Zend/XmlRpc/Value/Double.php';
- return new Zend_XmlRpc_Value_Double($value);
-
- case self::XMLRPC_TYPE_BOOLEAN:
- require_once 'Zend/XmlRpc/Value/Boolean.php';
- return new Zend_XmlRpc_Value_Boolean($value);
-
- case self::XMLRPC_TYPE_NIL:
- require_once 'Zend/XmlRpc/Value/Nil.php';
- return new Zend_XmlRpc_Value_Nil;
-
- case self::XMLRPC_TYPE_STRING:
- // Fall through to the next case
- default:
- // If type isn't identified (or identified as string), it treated as string
- require_once 'Zend/XmlRpc/Value/String.php';
- return new Zend_XmlRpc_Value_String($value);
- }
- }
-
-
- /**
- * Transform an XML string into a XML-RPC native value
- *
- * @param string|SimpleXMLElement $xml A SimpleXMLElement object represent the XML string
- * It can be also a valid XML string for convertion
- *
- * @return Zend_XmlRpc_Value
- * @static
- */
- protected static function _xmlStringToNativeXmlRpc($xml)
- {
- self::_createSimpleXMLElement($xml);
-
- self::_extractTypeAndValue($xml, $type, $value);
-
- switch ($type) {
- // All valid and known XML-RPC native values
- case self::XMLRPC_TYPE_I4:
- // Fall through to the next case
- case self::XMLRPC_TYPE_INTEGER:
- require_once 'Zend/XmlRpc/Value/Integer.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_Integer($value);
- break;
- case self::XMLRPC_TYPE_APACHEI8:
- // Fall through to the next case
- case self::XMLRPC_TYPE_I8:
- require_once 'Zend/XmlRpc/Value/BigInteger.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_BigInteger($value);
- break;
- case self::XMLRPC_TYPE_DOUBLE:
- require_once 'Zend/XmlRpc/Value/Double.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_Double($value);
- break;
- case self::XMLRPC_TYPE_BOOLEAN:
- require_once 'Zend/XmlRpc/Value/Boolean.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_Boolean($value);
- break;
- case self::XMLRPC_TYPE_STRING:
- require_once 'Zend/XmlRpc/Value/String.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_String($value);
- break;
- case self::XMLRPC_TYPE_DATETIME: // The value should already be in a iso8601 format
- require_once 'Zend/XmlRpc/Value/DateTime.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_DateTime($value);
- break;
- case self::XMLRPC_TYPE_BASE64: // The value should already be base64 encoded
- require_once 'Zend/XmlRpc/Value/Base64.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_Base64($value, true);
- break;
- case self::XMLRPC_TYPE_NIL:
- // Fall through to the next case
- case self::XMLRPC_TYPE_APACHENIL:
- // The value should always be NULL
- require_once 'Zend/XmlRpc/Value/Nil.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_Nil();
- break;
- case self::XMLRPC_TYPE_ARRAY:
- // PHP 5.2.4 introduced a regression in how empty($xml->value)
- // returns; need to look for the item specifically
- $data = null;
- foreach ($value->children() as $key => $value) {
- if ('data' == $key) {
- $data = $value;
- break;
- }
- }
-
- if (null === $data) {
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception('Invalid XML for XML-RPC native '. self::XMLRPC_TYPE_ARRAY .' type: ARRAY tag must contain DATA tag');
- }
- $values = array();
- // Parse all the elements of the array from the XML string
- // (simple xml element) to Zend_XmlRpc_Value objects
- foreach ($data->value as $element) {
- $values[] = self::_xmlStringToNativeXmlRpc($element);
- }
- require_once 'Zend/XmlRpc/Value/Array.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_Array($values);
- break;
- case self::XMLRPC_TYPE_STRUCT:
- $values = array();
- // Parse all the memebers of the struct from the XML string
- // (simple xml element) to Zend_XmlRpc_Value objects
- foreach ($value->member as $member) {
- // @todo? If a member doesn't have a tag, we don't add it to the struct
- // Maybe we want to throw an exception here ?
- if (!isset($member->value) or !isset($member->name)) {
- continue;
- //throw new Zend_XmlRpc_Value_Exception('Member of the '. self::XMLRPC_TYPE_STRUCT .' XML-RPC native type must contain a VALUE tag');
- }
- $values[(string)$member->name] = self::_xmlStringToNativeXmlRpc($member->value);
- }
- require_once 'Zend/XmlRpc/Value/Struct.php';
- $xmlrpcValue = new Zend_XmlRpc_Value_Struct($values);
- break;
- default:
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception('Value type \''. $type .'\' parsed from the XML string is not a known XML-RPC native type');
- break;
- }
- $xmlrpcValue->_setXML($xml->asXML());
-
- return $xmlrpcValue;
- }
-
- protected static function _createSimpleXMLElement(&$xml)
- {
- if ($xml instanceof SimpleXMLElement) {
- return;
- }
-
- try {
- $xml = new SimpleXMLElement($xml);
- } catch (Exception $e) {
- // The given string is not a valid XML
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception('Failed to create XML-RPC value from XML string: ' . $e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Extract XML/RPC type and value from SimpleXMLElement object
- *
- * @param SimpleXMLElement $xml
- * @param string &$type Type bind variable
- * @param string &$value Value bind variable
- * @return void
- */
- protected static function _extractTypeAndValue(SimpleXMLElement $xml, &$type, &$value)
- {
- list($type, $value) = each($xml);
-
- if (!$type and $value === null) {
- $namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions');
- foreach ($namespaces as $namespaceName => $namespaceUri) {
- $namespaceXml = $xml->children($namespaceUri);
- list($type, $value) = each($namespaceXml);
- if ($type !== null) {
- $type = $namespaceName . ':' . $type;
- break;
- }
- }
- }
-
- //if there is a child element, try to parse type for it
- if (!$type && $value instanceof SimpleXMLElement) {
- self::_extractTypeAndValue($value->children(), $type, $value);
- }
-
- // If no type was specified, the default is string
- if (!$type) {
- $type = self::XMLRPC_TYPE_STRING;
- if (preg_match('#^.* $#', $xml->asXML())) {
- $value = str_replace(array('', ' '), '', $xml->asXML());
- }
- }
- }
-
- /**
- * @param string $xml
- * @return void
- */
- protected function _setXML($xml)
- {
- $this->_xml = $this->getGenerator()->stripDeclaration($xml);
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/Array.php b/lib/zend/Zend/XmlRpc/Value/Array.php
deleted file mode 100644
index 60f68b29628e3..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Array.php
+++ /dev/null
@@ -1,73 +0,0 @@
-_type = self::XMLRPC_TYPE_ARRAY;
- parent::__construct($value);
- }
-
-
- /**
- * Generate the XML code that represent an array native MXL-RPC value
- *
- * @return void
- */
- protected function _generateXml()
- {
- $generator = $this->getGenerator();
- $generator->openElement('value')
- ->openElement('array')
- ->openElement('data');
-
- if (is_array($this->_value)) {
- foreach ($this->_value as $val) {
- $val->generateXml();
- }
- }
- $generator->closeElement('data')
- ->closeElement('array')
- ->closeElement('value');
- }
-}
-
diff --git a/lib/zend/Zend/XmlRpc/Value/Base64.php b/lib/zend/Zend/XmlRpc/Value/Base64.php
deleted file mode 100644
index eee61bae5ca69..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Base64.php
+++ /dev/null
@@ -1,68 +0,0 @@
-_type = self::XMLRPC_TYPE_BASE64;
-
- $value = (string)$value; // Make sure this value is string
- if (!$alreadyEncoded) {
- $value = base64_encode($value); // We encode it in base64
- }
- $this->_value = $value;
- }
-
- /**
- * Return the value of this object, convert the XML-RPC native base64 value into a PHP string
- * We return this value decoded (a normal string)
- *
- * @return string
- */
- public function getValue()
- {
- return base64_decode($this->_value);
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/BigInteger.php b/lib/zend/Zend/XmlRpc/Value/BigInteger.php
deleted file mode 100644
index b636a5814f982..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/BigInteger.php
+++ /dev/null
@@ -1,58 +0,0 @@
-_value = $integer->init($value);
- $this->_type = self::XMLRPC_TYPE_I8;
- }
-
- /**
- * Return bigint value
- *
- * @return string
- */
- public function getValue()
- {
- return $this->_value;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/Boolean.php b/lib/zend/Zend/XmlRpc/Value/Boolean.php
deleted file mode 100644
index 1a91872ca0272..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Boolean.php
+++ /dev/null
@@ -1,63 +0,0 @@
-_type = self::XMLRPC_TYPE_BOOLEAN;
- // Make sure the value is boolean and then convert it into a integer
- // The double convertion is because a bug in the ZendOptimizer in PHP version 5.0.4
- $this->_value = (int)(bool)$value;
- }
-
- /**
- * Return the value of this object, convert the XML-RPC native boolean value into a PHP boolean
- *
- * @return bool
- */
- public function getValue()
- {
- return (bool)$this->_value;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/Collection.php b/lib/zend/Zend/XmlRpc/Value/Collection.php
deleted file mode 100644
index 2ef9a9a3d50d1..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Collection.php
+++ /dev/null
@@ -1,73 +0,0 @@
- $value) {
- // If the elements of the given array are not Zend_XmlRpc_Value objects,
- // we need to convert them as such (using auto-detection from PHP value)
- if (!$value instanceof parent) {
- $value = self::getXmlRpcValue($value, self::AUTO_DETECT_TYPE);
- }
- $this->_value[$key] = $value;
- }
- }
-
-
- /**
- * Return the value of this object, convert the XML-RPC native collection values into a PHP array
- *
- * @return arary
- */
- public function getValue()
- {
- $values = (array)$this->_value;
- foreach ($values as $key => $value) {
- /* @var $value Zend_XmlRpc_Value */
- $values[$key] = $value->getValue();
- }
- return $values;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/DateTime.php b/lib/zend/Zend/XmlRpc/Value/DateTime.php
deleted file mode 100644
index 18d9991dc111f..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/DateTime.php
+++ /dev/null
@@ -1,91 +0,0 @@
-_type = self::XMLRPC_TYPE_DATETIME;
-
- if ($value instanceof Zend_Date) {
- $this->_value = $value->toString($this->_isoFormatString);
- } elseif ($value instanceof DateTime) {
- $this->_value = $value->format($this->_phpFormatString);
- } elseif (is_numeric($value)) { // The value is numeric, we make sure it is an integer
- $this->_value = date($this->_phpFormatString, (int)$value);
- } else {
- $timestamp = new DateTime($value);
- if ($timestamp === false) { // cannot convert the value to a timestamp
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception('Cannot convert given value \''. $value .'\' to a timestamp');
- }
-
- $this->_value = $timestamp->format($this->_phpFormatString); // Convert the timestamp to iso8601 format
- }
- }
-
- /**
- * Return the value of this object as iso8601 dateTime value
- *
- * @return int As a Unix timestamp
- */
- public function getValue()
- {
- return $this->_value;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/Double.php b/lib/zend/Zend/XmlRpc/Value/Double.php
deleted file mode 100644
index 6251879f069ff..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Double.php
+++ /dev/null
@@ -1,62 +0,0 @@
-_type = self::XMLRPC_TYPE_DOUBLE;
- $precision = (int)ini_get('precision');
- $formatString = '%1.' . $precision . 'F';
- $this->_value = rtrim(sprintf($formatString, (float)$value), '0');
- }
-
- /**
- * Return the value of this object, convert the XML-RPC native double value into a PHP float
- *
- * @return float
- */
- public function getValue()
- {
- return (float)$this->_value;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/Exception.php b/lib/zend/Zend/XmlRpc/Value/Exception.php
deleted file mode 100644
index 3a18f28e73662..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Exception.php
+++ /dev/null
@@ -1,39 +0,0 @@
- PHP_INT_MAX) {
- require_once 'Zend/XmlRpc/Value/Exception.php';
- throw new Zend_XmlRpc_Value_Exception('Overlong integer given');
- }
-
- $this->_type = self::XMLRPC_TYPE_INTEGER;
- $this->_value = (int)$value; // Make sure this value is integer
- }
-
- /**
- * Return the value of this object, convert the XML-RPC native integer value into a PHP integer
- *
- * @return int
- */
- public function getValue()
- {
- return $this->_value;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/Nil.php b/lib/zend/Zend/XmlRpc/Value/Nil.php
deleted file mode 100644
index 67305d0d8d98e..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Nil.php
+++ /dev/null
@@ -1,60 +0,0 @@
-_type = self::XMLRPC_TYPE_NIL;
- $this->_value = null;
- }
-
- /**
- * Return the value of this object, convert the XML-RPC native nill value into a PHP NULL
- *
- * @return null
- */
- public function getValue()
- {
- return null;
- }
-}
-
diff --git a/lib/zend/Zend/XmlRpc/Value/Scalar.php b/lib/zend/Zend/XmlRpc/Value/Scalar.php
deleted file mode 100644
index 86397d209122d..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Scalar.php
+++ /dev/null
@@ -1,53 +0,0 @@
-getGenerator();
-
- $generator->openElement('value')
- ->openElement($this->_type, $this->_value)
- ->closeElement($this->_type)
- ->closeElement('value');
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/String.php b/lib/zend/Zend/XmlRpc/Value/String.php
deleted file mode 100644
index 37ac5b8321640..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/String.php
+++ /dev/null
@@ -1,60 +0,0 @@
-_type = self::XMLRPC_TYPE_STRING;
-
- // Make sure this value is string and all XML characters are encoded
- $this->_value = (string)$value;
- }
-
- /**
- * Return the value of this object, convert the XML-RPC native string value into a PHP string
- *
- * @return string
- */
- public function getValue()
- {
- return (string)$this->_value;
- }
-}
diff --git a/lib/zend/Zend/XmlRpc/Value/Struct.php b/lib/zend/Zend/XmlRpc/Value/Struct.php
deleted file mode 100644
index 5272eb508db3d..0000000000000
--- a/lib/zend/Zend/XmlRpc/Value/Struct.php
+++ /dev/null
@@ -1,75 +0,0 @@
-_type = self::XMLRPC_TYPE_STRUCT;
- parent::__construct($value);
- }
-
-
- /**
- * Generate the XML code that represent struct native MXL-RPC value
- *
- * @return void
- */
- protected function _generateXML()
- {
- $generator = $this->getGenerator();
- $generator->openElement('value')
- ->openElement('struct');
-
- if (is_array($this->_value)) {
- foreach ($this->_value as $name => $val) {
- /* @var $val Zend_XmlRpc_Value */
- $generator->openElement('member')
- ->openElement('name', $name)
- ->closeElement('name');
- $val->generateXml();
- $generator->closeElement('member');
- }
- }
- $generator->closeElement('struct')
- ->closeElement('value');
- }
-}
diff --git a/lib/zend/readme_moodle.txt b/lib/zend/readme_moodle.txt
deleted file mode 100644
index 2c1d1c8973e2e..0000000000000
--- a/lib/zend/readme_moodle.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-Description of Zend framework 1.10.6 import into Moodle
-Please note the zend framework is modified - some packages are removed.
-
-Delete all the files from the Moodle lib/zend/Zend folder.
-Copy all the files from the zend/library/Zend folder into the Moodle lib/zend/Zend folder.
-
-Audit the Classes we actually use - and delete libraries that are not used directly or indirectly by any of them.
-
-Libraries I think are safe to remove:
-
-Application/ Tool/ Application.php Barcode/ Barcode.php Captcha/ Form/ Form.php Dojo/ Dojo.php Cloud/
-CodeGenerator/ Console/ Test/ Db.php Db/ Paginator.php Paginator/ Session.php Session/ Feed.php Feed/
-Auth/Adapter/DbTable.php Queue/Adapter/Db/ Queue/Adapter/Db.php Debug.php Dom/ EventManager/ File/ Ldap.php
-Ldap/ Auth/Adapter/Ldap.php Locale/Data Mail.php Mail/ Markup.php Markup/ Measure/ Memory.php Memory/ Pdf.php Pdf/
-Mime.php Mime/ Mobile/ OpenId.php OpenId/ Auth/Adapter/OpenId.php ProgressBar.php ProgressBar Queue.php Queue/
-Search/ Serializer.php Serializer/ Stdlib/ Tag/ Text/ TimeSync.php TimeSync/ Translate.php Translate/
-Log/Writer/Firebug.php Wildfire/ Service/ShortUrl/ Service/WindowsAzure/
-
-
-
-
-Do not use outside of our /webservice/* or mnet !!
-
-Changes:
-* Update to 1.12.16 - this is more or less vanilla now except for the above folders removed.
diff --git a/webservice/lib.php b/webservice/lib.php
index 1ddd70db3eb02..2fa826deca1cd 100644
--- a/webservice/lib.php
+++ b/webservice/lib.php
@@ -1099,464 +1099,6 @@ protected function set_web_service_call_settings() {
}
}
-/**
- * Special abstraction of our services that allows interaction with stock Zend ws servers.
- *
- * @package core_webservice
- * @copyright 2009 Jerome Mouneyrac
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-abstract class webservice_zend_server extends webservice_server {
-
- /** @var string Name of the zend server class : moodle_zend_soap_server, Zend_Soap_AutoDiscover, ...*/
- protected $zend_class;
-
- /** @var stdClass Zend server instance */
- protected $zend_server;
-
- /** @var string Virtual web service class with all functions user name execute, created on the fly */
- protected $service_class;
-
- /**
- * Constructor
- *
- * @param int $authmethod authentication method - one of WEBSERVICE_AUTHMETHOD_*
- * @param string $zend_class Name of the zend server class
- */
- public function __construct($authmethod, $zend_class) {
- parent::__construct($authmethod);
- $this->zend_class = $zend_class;
- }
-
- /**
- * Process request from client.
- *
- * @uses die
- */
- public function run() {
- // we will probably need a lot of memory in some functions
- raise_memory_limit(MEMORY_EXTRA);
-
- // set some longer timeout, this script is not sending any output,
- // this means we need to manually extend the timeout operations
- // that need longer time to finish
- external_api::set_timeout();
-
- // now create the instance of zend server
- $this->init_zend_server();
-
- // set up exception handler first, we want to sent them back in correct format that
- // the other system understands
- // we do not need to call the original default handler because this ws handler does everything
- set_exception_handler(array($this, 'exception_handler'));
-
- // init all properties from the request data
- $this->parse_request();
-
- // this sets up $USER and $SESSION and context restrictions
- $this->authenticate_user();
-
- // make a list of all functions user is allowed to excecute
- $this->init_service_class();
-
- // tell server what functions are available
- $this->zend_server->setClass($this->service_class);
-
- // Log the web service request.
- $params = array(
- 'other' => array(
- 'function' => 'unknown'
- )
- );
- $event = \core\event\webservice_function_called::create($params);
- $event->set_legacy_logdata(array(SITEID, 'webservice', '', '', $this->zend_class.' '.getremoteaddr(), 0, $this->userid));
- $event->trigger();
-
- //send headers
- $this->send_headers();
-
- // execute and return response, this sends some headers too
- $response = $this->zend_server->handle();
-
- // session cleanup
- $this->session_cleanup();
-
- //finally send the result
- echo $response;
- die;
- }
-
- /**
- * Load virtual class needed for Zend api
- */
- protected function init_service_class() {
- global $USER, $DB;
-
- // first ofall get a complete list of services user is allowed to access
-
- if ($this->restricted_serviceid) {
- $params = array('sid1'=>$this->restricted_serviceid, 'sid2'=>$this->restricted_serviceid);
- $wscond1 = 'AND s.id = :sid1';
- $wscond2 = 'AND s.id = :sid2';
- } else {
- $params = array();
- $wscond1 = '';
- $wscond2 = '';
- }
-
- // now make sure the function is listed in at least one service user is allowed to use
- // allow access only if:
- // 1/ entry in the external_services_users table if required
- // 2/ validuntil not reached
- // 3/ has capability if specified in service desc
- // 4/ iprestriction
-
- $sql = "SELECT s.*, NULL AS iprestriction
- FROM {external_services} s
- JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 0)
- WHERE s.enabled = 1 $wscond1
-
- UNION
-
- SELECT s.*, su.iprestriction
- FROM {external_services} s
- JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 1)
- JOIN {external_services_users} su ON (su.externalserviceid = s.id AND su.userid = :userid)
- WHERE s.enabled = 1 AND (su.validuntil IS NULL OR su.validuntil < :now) $wscond2";
-
- $params = array_merge($params, array('userid'=>$USER->id, 'now'=>time()));
-
- $serviceids = array();
- $rs = $DB->get_recordset_sql($sql, $params);
-
- // now make sure user may access at least one service
- $remoteaddr = getremoteaddr();
- $allowed = false;
- foreach ($rs as $service) {
- if (isset($serviceids[$service->id])) {
- continue;
- }
- if ($service->requiredcapability and !has_capability($service->requiredcapability, $this->restricted_context)) {
- continue; // cap required, sorry
- }
- if ($service->iprestriction and !address_in_subnet($remoteaddr, $service->iprestriction)) {
- continue; // wrong request source ip, sorry
- }
- $serviceids[$service->id] = $service->id;
- }
- $rs->close();
-
- // now get the list of all functions
- $wsmanager = new webservice();
- $functions = $wsmanager->get_external_functions($serviceids);
-
- // now make the virtual WS class with all the fuctions for this particular user
- $methods = '';
- foreach ($functions as $function) {
- $methods .= $this->get_virtual_method_code($function);
- }
-
- // let's use unique class name, there might be problem in unit tests
- $classname = 'webservices_virtual_class_000000';
- while(class_exists($classname)) {
- $classname++;
- }
-
- $code = '
-/**
- * Virtual class web services for user id '.$USER->id.' in context '.$this->restricted_context->id.'.
- */
-class '.$classname.' {
-'.$methods.'
-}
-';
-
- // load the virtual class definition into memory
- eval($code);
- $this->service_class = $classname;
- }
-
- /**
- * returns virtual method code
- *
- * @param stdClass $function a record from external_function
- * @return string PHP code
- */
- protected function get_virtual_method_code($function) {
- global $CFG;
-
- $function = external_function_info($function);
-
- //arguments in function declaration line with defaults.
- $paramanddefaults = array();
- //arguments used as parameters for external lib call.
- $params = array();
- $params_desc = array();
- foreach ($function->parameters_desc->keys as $name=>$keydesc) {
- $param = '$'.$name;
- $paramanddefault = $param;
- //need to generate the default if there is any
- if ($keydesc instanceof external_value) {
- if ($keydesc->required == VALUE_DEFAULT) {
- if ($keydesc->default===null) {
- $paramanddefault .= '=null';
- } else {
- switch($keydesc->type) {
- case PARAM_BOOL:
- $paramanddefault .= '='. (int) $keydesc->default; break;
- case PARAM_INT:
- $paramanddefault .= '='.$keydesc->default; break;
- case PARAM_FLOAT;
- $paramanddefault .= '='.$keydesc->default; break;
- default:
- $paramanddefault .= '=\''.$keydesc->default.'\'';
- }
- }
- } else if ($keydesc->required == VALUE_OPTIONAL) {
- // It does not make sense to declare a parameter VALUE_OPTIONAL.
- // VALUE_OPTIONAL is used only for array/object key.
- throw new moodle_exception('erroroptionalparamarray', 'webservice', '', $name);
- }
- } else { //for the moment we do not support default for other structure types
- if ($keydesc->required == VALUE_DEFAULT) {
- //accept empty array as default
- if (isset($keydesc->default) and is_array($keydesc->default)
- and empty($keydesc->default)) {
- $paramanddefault .= '=array()';
- } else {
- throw new moodle_exception('errornotemptydefaultparamarray', 'webservice', '', $name);
- }
- }
- if ($keydesc->required == VALUE_OPTIONAL) {
- throw new moodle_exception('erroroptionalparamarray', 'webservice', '', $name);
- }
- }
- $params[] = $param;
- $paramanddefaults[] = $paramanddefault;
- $type = $this->get_phpdoc_type($keydesc);
- $params_desc[] = ' * @param '.$type.' $'.$name.' '.$keydesc->desc;
- }
- $params = implode(', ', $params);
- $paramanddefaults = implode(', ', $paramanddefaults);
- $params_desc = implode("\n", $params_desc);
-
- $serviceclassmethodbody = $this->service_class_method_body($function, $params);
-
- if (is_null($function->returns_desc)) {
- $return = ' * @return void';
- } else {
- $type = $this->get_phpdoc_type($function->returns_desc);
- $return = ' * @return '.$type.' '.$function->returns_desc->desc;
- }
-
- // now crate the virtual method that calls the ext implementation
-
- $code = '
- /**
- * '.$function->description.'
- *
-'.$params_desc.'
-'.$return.'
- */
- public function '.$function->name.'('.$paramanddefaults.') {
-'.$serviceclassmethodbody.'
- }
-';
- return $code;
- }
-
- /**
- * Get the phpdoc type for an external_description
- * external_value => int, double or string
- * external_single_structure => object|struct, on-fly generated stdClass name, ...
- * external_multiple_structure => array
- *
- * @param string $keydesc any of PARAM_*
- * @return string phpdoc type (string, double, int, array...)
- */
- protected function get_phpdoc_type($keydesc) {
- if ($keydesc instanceof external_value) {
- switch($keydesc->type) {
- case PARAM_BOOL: // 0 or 1 only for now
- case PARAM_INT:
- $type = 'int'; break;
- case PARAM_FLOAT;
- $type = 'double'; break;
- default:
- $type = 'string';
- }
-
- } else if ($keydesc instanceof external_single_structure) {
- $classname = $this->generate_simple_struct_class($keydesc);
- $type = $classname;
-
- } else if ($keydesc instanceof external_multiple_structure) {
- $type = 'array';
- }
-
- return $type;
- }
-
- /**
- * Generate 'struct'/'object' type name
- * Some servers (our Zend ones) parse the phpdoc to know the parameter types.
- * The purpose to this function is to be overwritten when the common object|struct type are not understood by the server.
- * See webservice/soap/locallib.php - the SOAP server requires detailed structure)
- *
- * @param external_single_structure $structdesc the structure for which we generate the phpdoc type
- * @return string the phpdoc type
- */
- protected function generate_simple_struct_class(external_single_structure $structdesc) {
- return 'object|struct'; //only 'object' is supported by SOAP, 'struct' by XML-RPC MDL-23083
- }
-
- /**
- * You can override this function in your child class to add extra code into the dynamically
- * created service class.
- *
- * @param stdClass $function a record from external_function
- * @param array $params web service function parameters
- * @return string body of the method for $function ie. everything within the {} of the method declaration.
- */
- protected function service_class_method_body($function, $params){
- //cast the param from object to array (validate_parameters except array only)
- $castingcode = '';
- if ($params){
- $paramstocast = explode(',', $params);
- foreach ($paramstocast as $paramtocast) {
- //clean the parameter from any white space
- $paramtocast = trim($paramtocast);
- $castingcode .= $paramtocast .
- '=webservice_zend_server::cast_objects_to_array('.$paramtocast.');';
- }
-
- }
-
- $descriptionmethod = $function->methodname.'_returns()';
- $callforreturnvaluedesc = $function->classname.'::'.$descriptionmethod;
- return $castingcode . ' if ('.$callforreturnvaluedesc.' == null) {'.
- $function->classname.'::'.$function->methodname.'('.$params.');
- return null;
- }
- return external_api::clean_returnvalue('.$callforreturnvaluedesc.', '.$function->classname.'::'.$function->methodname.'('.$params.'));';
- }
-
- /**
- * Recursive function to recurse down into a complex variable and convert all
- * objects to arrays.
- *
- * @param mixed $param value to cast
- * @return mixed Cast value
- */
- public static function cast_objects_to_array($param){
- if (is_object($param)){
- $param = (array)$param;
- }
- if (is_array($param)){
- $toreturn = array();
- foreach ($param as $key=> $param){
- $toreturn[$key] = self::cast_objects_to_array($param);
- }
- return $toreturn;
- } else {
- return $param;
- }
- }
-
- /**
- * Set up zend service class
- */
- protected function init_zend_server() {
- $this->zend_server = new $this->zend_class();
- }
-
- /**
- * This method parses the $_POST and $_GET superglobals and looks for
- * the following information:
- * 1/ user authentication - username+password or token (wsusername, wspassword and wstoken parameters)
- *
- * @return void
- */
- protected function parse_request() {
-
- // We are going to clean the POST/GET parameters from the parameters specific to the server.
- parent::set_web_service_call_settings();
-
- // Get GET and POST paramters.
- $methodvariables = array_merge($_GET,$_POST);
-
- if ($this->authmethod == WEBSERVICE_AUTHMETHOD_USERNAME) {
- //note: some clients have problems with entity encoding :-(
- if (isset($methodvariables['wsusername'])) {
- $this->username = $methodvariables['wsusername'];
- }
- if (isset($methodvariables['wspassword'])) {
- $this->password = $methodvariables['wspassword'];
- }
- } else {
- if (isset($methodvariables['wstoken'])) {
- $this->token = $methodvariables['wstoken'];
- }
- }
- }
-
- /**
- * Internal implementation - sending of page headers.
- */
- protected function send_headers() {
- header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
- header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
- header('Pragma: no-cache');
- header('Accept-Ranges: none');
- }
-
- /**
- * Specialised exception handler, we can not use the standard one because
- * it can not just print html to output.
- *
- * @param exception $ex
- * @uses exit
- */
- public function exception_handler($ex) {
- // detect active db transactions, rollback and log as error
- abort_all_db_transactions();
-
- // some hacks might need a cleanup hook
- $this->session_cleanup($ex);
-
- // now let the plugin send the exception to client
- $this->send_error($ex);
-
- // not much else we can do now, add some logging later
- exit(1);
- }
-
- /**
- * Send the error information to the WS client
- * formatted as XML document.
- *
- * @param exception $ex
- */
- protected function send_error($ex=null) {
- $this->send_headers();
- echo $this->zend_server->fault($ex);
- }
-
- /**
- * Future hook needed for emulated sessions.
- *
- * @param exception $exception null means normal termination, $exception received when WS call failed
- */
- protected function session_cleanup($exception=null) {
- if ($this->authmethod == WEBSERVICE_AUTHMETHOD_USERNAME) {
- // nothing needs to be done, there is no persistent session
- } else {
- // close emulated session if used
- }
- }
-
-}
-
/**
* Web Service server base class.
*
@@ -1794,7 +1336,6 @@ protected function execute() {
* - has the required capability.
* - meets the IP restriction requirement.
* This virtual class can be used by web service protocols such as SOAP, especially when generating WSDL.
- * NOTE: The implementation of this method has been mostly copied from webservice_zend_server::init_server_class().
*/
protected function init_service_class() {
global $USER, $DB;
@@ -1879,7 +1420,6 @@ class $classname {
/**
* Generates a struct class.
*
- * NOTE: The implementation of this method has been mostly copied from webservice_zend_server::generate_simple_struct_class().
* @param external_single_structure $structdesc The basis of the struct class to be generated.
* @return string The class name of the generated struct class.
*/
@@ -1929,7 +1469,6 @@ class $classname {
/**
* Returns a virtual method code for a web service function.
*
- * NOTE: The implementation of this method has been mostly copied from webservice_zend_server::get_virtual_method_code().
* @param stdClass $function a record from external_function
* @return string The PHP code of the virtual method.
* @throws coding_exception
@@ -2066,7 +1605,6 @@ protected function get_phpdoc_type($keydesc) {
/**
* Generates the method body of the virtual external function.
*
- * NOTE: The implementation of this method has been mostly copied from webservice_zend_server::service_class_method_body().
* @param stdClass $function a record from external_function.
* @param array $params web service function parameters.
* @return string body of the method for $function ie. everything within the {} of the method declaration.
diff --git a/webservice/soap/locallib.php b/webservice/soap/locallib.php
index 96d715b71ac9c..02c644056b3c5 100644
--- a/webservice/soap/locallib.php
+++ b/webservice/soap/locallib.php
@@ -312,82 +312,6 @@ public function fault($fault = null, $code = 'Receiver') {
}
}
-/**
- * The Zend SOAP server but with a fault that returns debuginfo.
- *
- * @package webservice_soap
- * @copyright 2011 Jerome Mouneyrac
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 2.2
- * @deprecated since 3.1, see {@link webservice_soap_server()}.
- */
-class moodle_zend_soap_server extends webservice_soap_server {
-
- /**
- * moodle_zend_soap_server constructor.
- *
- * @param string $authmethod
- */
- public function __construct($authmethod) {
- debugging('moodle_zend_soap_server is deprecated, please use webservice_soap_server instead.', DEBUG_DEVELOPER);
- parent::__construct($authmethod);
- }
-
- /**
- * Generate a server fault.
- *
- * Note that the arguments are the reverse of those used by SoapFault.
- *
- * Moodle note: basically we return the faultactor (errorcode) and faultdetails (debuginfo).
- *
- * If an exception is passed as the first argument, its message and code
- * will be used to create the fault object if it has been registered via
- * {@Link registerFaultException()}.
- *
- * @link http://www.w3.org/TR/soap12-part1/#faultcodes
- * @param string|Exception $fault
- * @param string $code SOAP Fault Codes
- * @return SoapFault
- * @deprecated since 3.1, see {@link webservice_soap_server::fault()}.
- */
- public function fault($fault = null, $code = "Receiver") {
- debugging('moodle_zend_soap_server::fault() is deprecated, please use webservice_soap_server::fault() instead.',
- DEBUG_DEVELOPER);
- parent::fault($fault, $code);
- }
-
- /**
- * Handle a request.
- *
- * NOTE: this is basically a copy of the Zend handle()
- * but with $soap->fault returning faultactor + faultdetail
- * So we don't require coding style checks within this method
- * to keep it as similar as the original one.
- *
- * Instantiates SoapServer object with options set in object, and
- * dispatches its handle() method.
- *
- * $request may be any of:
- * - DOMDocument; if so, then cast to XML
- * - DOMNode; if so, then grab owner document and cast to XML
- * - SimpleXMLElement; if so, then cast to XML
- * - stdClass; if so, calls __toString() and verifies XML
- * - string; if so, verifies XML
- *
- * If no request is passed, pulls request using php:://input (for
- * cross-platform compatability purposes).
- *
- * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request Optional request
- * @return void|string
- * @deprecated since 3.1, see {@link webservice_soap_server::handle()}.
- */
- public function handle($request = null) {
- debugging('moodle_zend_soap_server::handle() is deprecated, please use webservice_soap_server::handle() instead.',
- DEBUG_DEVELOPER);
- parent::handle();
- }
-}
-
/**
* SOAP test client class
*
diff --git a/webservice/soap/server.php b/webservice/soap/server.php
index 70097e08f37e6..2d49302cdc86e 100644
--- a/webservice/soap/server.php
+++ b/webservice/soap/server.php
@@ -30,15 +30,6 @@
define('WS_SERVER', true);
-// Make sure OPcache does not strip comments, we need them for Zend!
-if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
- if (!ini_get('opcache.save_comments') or strtolower(ini_get('opcache.save_comments')) === 'off') {
- ini_set('opcache.enable', 0);
- } else {
- ini_set('opcache.load_comments', 1);
- }
-}
-
require('../../config.php');
require_once("$CFG->dirroot/webservice/soap/locallib.php");
diff --git a/webservice/soap/simpleserver.php b/webservice/soap/simpleserver.php
index 45f1029e9f2b1..fa5d54849d98a 100644
--- a/webservice/soap/simpleserver.php
+++ b/webservice/soap/simpleserver.php
@@ -30,15 +30,6 @@
define('WS_SERVER', true);
-// Make sure OPcache does not strip comments, we need them for Zend!
-if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
- if (!ini_get('opcache.save_comments') or strtolower(ini_get('opcache.save_comments')) === 'off') {
- ini_set('opcache.enable', 0);
- } else {
- ini_set('opcache.load_comments', 1);
- }
-}
-
require('../../config.php');
require_once("$CFG->dirroot/webservice/soap/locallib.php");
diff --git a/webservice/upgrade.txt b/webservice/upgrade.txt
index a0e6cc319b115..a7aa0f7ad1b9c 100644
--- a/webservice/upgrade.txt
+++ b/webservice/upgrade.txt
@@ -11,10 +11,7 @@ This information is intended for authors of webservices, not people writing webs
on the string returned by the getMessage() method of the thrown exception.
* The xmlrpc server is no longer enabled when the Mobile service is activated.
* Support for the AMF protocol has been dropped completely.
-* Zend_SOAP has been dropped. The native PHP SoapClient and SoapServer classes are now being used instead. WSDL is now
- generated by the new class webservice_soap_wsdl. For fault strings, a different error message might be shown depending
- on the string returned by the getMessage() method of the thrown exception.
-* With Zend_SOAP dropped, moodle_zend_soap_server is now also deprecated.
+* As Zend Framework has been removed, the webservice_zend_* classes have also been removed.
=== 3.0 ===
diff --git a/webservice/xmlrpc/locallib.php b/webservice/xmlrpc/locallib.php
index 9803b9d530566..e8eddf3765f4d 100644
--- a/webservice/xmlrpc/locallib.php
+++ b/webservice/xmlrpc/locallib.php
@@ -195,39 +195,6 @@ protected function generate_error(Exception $ex, $faultcode = 404) {
}
}
-/**
- * The Zend XMLRPC server but with a fault that return debuginfo.
- *
- * MDL-52209: Since Zend is being removed from Moodle, this class will be deprecated and eventually removed.
- * Please use webservice_xmlrpc_server instead.
- *
- * @package webservice_xmlrpc
- * @copyright 2011 Jerome Mouneyrac
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 2.2
- * @deprecated since 3.1, see {@link webservice_xmlrpc_server}.
- */
-class moodle_zend_xmlrpc_server extends webservice_xmlrpc_server {
-
- /**
- * Raise an xmlrpc server fault.
- *
- * Moodle note: the difference with the Zend server is that we throw a plain PHP Exception
- * with the debuginfo integrated to the exception message when DEBUG >= NORMAL.
- *
- * @param string|Exception $fault
- * @param int $code
- * @return Zend_XmlRpc_Server_Fault
- * @deprecated since 3.1, see {@link webservice_xmlrpc_server::generate_error()}.
- */
- public function fault($fault = null, $code = 404) {
- debugging('moodle_zend_xmlrpc_server::fault() is deprecated, please use ' .
- 'webservice_xmlrpc_server::generate_error() instead.', DEBUG_DEVELOPER);
-
- return $this->generate_error($fault, $code);
- }
-}
-
/**
* XML-RPC test client class
*
diff --git a/webservice/xmlrpc/server.php b/webservice/xmlrpc/server.php
index d4ea1b670217b..e83f7d47aed19 100644
--- a/webservice/xmlrpc/server.php
+++ b/webservice/xmlrpc/server.php
@@ -30,15 +30,6 @@
define('WS_SERVER', true);
-// Make sure OPcache does not strip comments, we need them for Zend!
-if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
- if (!ini_get('opcache.save_comments') or strtolower(ini_get('opcache.save_comments')) === 'off') {
- ini_set('opcache.enable', 0);
- } else {
- ini_set('opcache.load_comments', 1);
- }
-}
-
require('../../config.php');
require_once("$CFG->dirroot/webservice/xmlrpc/locallib.php");
diff --git a/webservice/xmlrpc/simpleserver.php b/webservice/xmlrpc/simpleserver.php
index 93f4957027da0..b1f08557a35d3 100644
--- a/webservice/xmlrpc/simpleserver.php
+++ b/webservice/xmlrpc/simpleserver.php
@@ -30,15 +30,6 @@
define('WS_SERVER', true);
-// Make sure OPcache does not strip comments, we need them for Zend!
-if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
- if (!ini_get('opcache.save_comments') or strtolower(ini_get('opcache.save_comments')) === 'off') {
- ini_set('opcache.enable', 0);
- } else {
- ini_set('opcache.load_comments', 1);
- }
-}
-
require('../../config.php');
require_once("$CFG->dirroot/webservice/xmlrpc/locallib.php");