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 00e75010566..00000000000 --- 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 4182f6aa8ad..00000000000 --- 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 0f87286031d..00000000000 --- 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 d9532ac1123..00000000000 --- 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 32ebf268b81..00000000000 --- 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 59cacba52be..00000000000 --- 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 bdbbba2a7db..00000000000 --- 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 acb5a0c6c8e..00000000000 --- 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 a759f58e53e..00000000000 --- 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 a6eaf166fb4..00000000000 --- 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 64d3c990ea0..00000000000 --- 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 0b4b00ffb44..00000000000 --- 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 f52b651e7a6..00000000000 --- 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 03216493065..00000000000 --- a/lib/zend/Zend/Auth/Adapter/Exception.php +++ /dev/null @@ -1,38 +0,0 @@ - 'basic'|'digest'|'basic digest' - * 'realm' =>
- *
- * @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 58b9bd3936a..00000000000
--- 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 74e4b0c4a10..00000000000
--- 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 9fcc22693e5..00000000000
--- 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 ed141659fa8..00000000000
--- 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 9829fb66bc4..00000000000
--- 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 71ed9473de5..00000000000
--- 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 2d036333060..00000000000
--- 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 927b97b3d34..00000000000
--- 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 2f6dc84807f..00000000000
--- 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 a474931ac51..00000000000
--- 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 2d33c61811a..00000000000
--- 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 6e82990f557..00000000000
--- 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 e012357d7b3..00000000000
--- 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 4acd9f572ed..00000000000
--- 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 0ceeac71e33..00000000000
--- 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 9afa43d6713..00000000000
--- 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 36acda37e76..00000000000
--- 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 e066f608513..00000000000
--- 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 40154b6fbb0..00000000000
--- 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 d5ee2e6ddf0..00000000000
--- 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 9fa92815e30..00000000000
--- 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 f1cf65e86ac..00000000000
--- 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 98b2e026c24..00000000000
--- 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 9694342d17b..00000000000
--- 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 9abc8b19989..00000000000
--- 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 8e828864b8c..00000000000
--- 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 6934d690e05..00000000000
--- 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 0ec9fce9fc2..00000000000
--- 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 f4573b38ce5..00000000000
--- 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 d97acb0f92c..00000000000
--- 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 1256ff9bd6b..00000000000
--- 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 7455dafe45c..00000000000
--- 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 7374da1665e..00000000000
--- 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 8d6a6da5607..00000000000
--- 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 f7961ea5110..00000000000
--- 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 e9361f7a437..00000000000
--- 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 6bd4451f7bd..00000000000
--- 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 2b20ac6f071..00000000000
--- 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 75f0a4063bc..00000000000
--- 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 33115105a00..00000000000
--- 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 d2ce0d89a9b..00000000000
--- 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 9921fe9648a..00000000000
--- 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 02e9a8e5d4f..00000000000
--- 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 844d95b86f7..00000000000
--- 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 01c3ed5a733..00000000000
--- 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 1510e7ff90f..00000000000
--- 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 7d1f70bd0ae..00000000000
--- 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 5763b2456ec..00000000000
--- 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 23c71b4b0aa..00000000000
--- 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 dd34321dea7..00000000000
--- 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 b70acbe301f..00000000000
--- 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 e65453e0fdb..00000000000
--- 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 0c1dfecb956..00000000000
--- 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 00eea7d64b2..00000000000
--- 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 c3229fa6fb4..00000000000
--- 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 ee20702559e..00000000000
--- 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 60dbb9e0657..00000000000
--- 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 c7988004160..00000000000
--- 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 7100c3717d8..00000000000
--- 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 00881de5f52..00000000000
--- 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 b208cfe77a1..00000000000
--- 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 8fe362055f2..00000000000
--- 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 4f86d89e2c0..00000000000
--- 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 667c6aae240..00000000000
--- 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 de58edd5dcc..00000000000
--- 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('/^(?P
- * // 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 10755c3df49..00000000000
--- 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 e7d5878160c..00000000000
--- 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 5d05c1008b4..00000000000
--- 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 da3faee84a8..00000000000
--- 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 . '
- * 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 b93808a2c6b..00000000000
--- 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 6f5929a22dd..00000000000
--- 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 733f563b9bb..00000000000
--- 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 9355fd35240..00000000000
--- 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 c726b401db6..00000000000
--- 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 10e706d3b6e..00000000000
--- 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 da15f6e746a..00000000000
--- 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 b4a10c8c8f1..00000000000
--- 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 6bffa198a89..00000000000
--- 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 c38ec8bc86a..00000000000
--- 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 f66a560b0d9..00000000000
--- 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 fbf7b690e63..00000000000
--- 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 708ccda6513..00000000000
--- 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 496ec7108ec..00000000000
--- 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 ae8d52419e4..00000000000
--- 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 b58c249512f..00000000000
--- 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 d82601da6f0..00000000000
--- 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 516619773b9..00000000000
--- 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 d3350515a73..00000000000
--- 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 88bc05fa0cd..00000000000
--- 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 03afcd696f4..00000000000
--- 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 a84e11d3bf4..00000000000
--- 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 73bb9670a33..00000000000
--- 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 df058a1a84a..00000000000
--- 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 d6bb539e199..00000000000
--- 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 be5a6cbb4e5..00000000000
--- 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 5bc246ba678..00000000000
--- 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 1c747084b0c..00000000000
--- 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 7c52902b62f..00000000000
--- 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 340eb1cd739..00000000000
--- 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 6b224499649..00000000000
--- 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