diff options
Diffstat (limited to 'libs/Zend')
377 files changed, 4609 insertions, 22878 deletions
diff --git a/libs/Zend/Auth.php b/libs/Zend/Auth.php index 47d474458a..d53602269e 100644 --- a/libs/Zend/Auth.php +++ b/libs/Zend/Auth.php @@ -14,16 +14,16 @@ * * @category Zend * @package Zend_Auth - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Auth.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Auth.php 18039 2009-09-09 03:35:19Z ralph $ */ /** * @category Zend * @package Zend_Auth - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth @@ -87,7 +87,7 @@ class Zend_Auth /** * @see Zend_Auth_Storage_Session */ - // require_once 'Zend/Auth/Storage/Session.php'; + require_once 'Zend/Auth/Storage/Session.php'; $this->setStorage(new Zend_Auth_Storage_Session()); } @@ -119,11 +119,11 @@ class Zend_Auth /** * 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()); } diff --git a/libs/Zend/Auth/Adapter/DbTable.php b/libs/Zend/Auth/Adapter/DbTable.php index 30bbd2478d..db64bcba9e 100644 --- a/libs/Zend/Auth/Adapter/DbTable.php +++ b/libs/Zend/Auth/Adapter/DbTable.php @@ -14,34 +14,34 @@ * * @category Zend * @package Zend_Auth - * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Adapter + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DbTable.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: DbTable.php 18066 2009-09-10 18:47:53Z ralph $ */ /** * @see Zend_Auth_Adapter_Interface */ -// require_once 'Zend/Auth/Adapter/Interface.php'; +require_once 'Zend/Auth/Adapter/Interface.php'; /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Auth_Result */ -// require_once 'Zend/Auth/Result.php'; +require_once 'Zend/Auth/Result.php'; /** * @category Zend * @package Zend_Auth - * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Adapter + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface @@ -58,7 +58,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface * @var Zend_Db_Select */ protected $_dbSelect = null; - + /** * $_tableName - the table name to check * @@ -185,7 +185,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface /** * setCredentialTreatment() - allows the developer to pass a parameterized string that is - * used to transform or treat the input credential data. + * used to transform or treat the input credential data * * In many cases, passwords and other sensitive data are encrypted, hashed, encoded, * obscured, or otherwise treated through some function or algorithm. By specifying a @@ -241,10 +241,10 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface if ($this->_dbSelect == null) { $this->_dbSelect = $this->_zendDb->select(); } - + return $this->_dbSelect; } - + /** * getResultRowObject() - Returns the result row as a stdClass object * @@ -292,8 +292,8 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface /** * authenticate() - defined by Zend_Auth_Adapter_Interface. This method is called to - * attempt an authentication. Previous to this call, this adapter would have already - * been configured with all necessary information to successfully connect to a database + * attempt an authenication. Previous to this call, this adapter would have already + * been configured with all nessissary information to successfully connect to a database * table and attempt to find a record matching the provided identity. * * @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible @@ -314,9 +314,8 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface } /** - * _authenticateSetup() - This method abstracts the steps involved with - * making sure that this adapter was indeed setup properly with all - * required pieces of information. + * _authenticateSetup() - This method abstracts the steps involved with making sure + * that this adapter was indeed setup properly with all required peices of information. * * @throws Zend_Auth_Adapter_Exception - in the event that setup was not done properly * @return true @@ -341,7 +340,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception($exception); } @@ -392,8 +391,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface * performs a query against the database with that object. * * @param Zend_Db_Select $dbSelect - * @throws Zend_Auth_Adapter_Exception - when an invalid select - * object is encountered + * @throws Zend_Auth_Adapter_Exception - when a invalid select object is encoutered * @return array */ protected function _authenticateQuerySelect(Zend_Db_Select $dbSelect) @@ -412,17 +410,17 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('The supplied parameters to Zend_Auth_Adapter_DbTable failed to ' . 'produce a valid sql statement, please check table and column names ' - . 'for validity.', 0, $e); + . 'for validity.'); } return $resultIdentities; } /** - * _authenticateValidateResultSet() - This method attempts to make - * certain that only one record was returned in the resultset + * _authenticateValidateResultSet() - This method attempts to make certian that only one + * record was returned in the result set * * @param array $resultIdentities * @return true|Zend_Auth_Result @@ -444,9 +442,8 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface } /** - * _authenticateValidateResult() - This method attempts to validate that - * the record in the resultset is indeed a record that matched the - * identity provided to this adapter. + * _authenticateValidateResult() - This method attempts to validate that the record in the + * result set is indeed a record that matched the identity provided to this adapter. * * @param array $resultIdentity * @return Zend_Auth_Result @@ -454,7 +451,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface protected function _authenticateValidateResult($resultIdentity) { $zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match'); - + if ($resultIdentity[$zendAuthCredentialMatchColumn] != '1') { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.'; @@ -470,8 +467,8 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface } /** - * _authenticateCreateAuthResult() - Creates a Zend_Auth_Result object from - * the information that has been collected during the authenticate() attempt. + * _authenticateCreateAuthResult() - This method creates a Zend_Auth_Result object + * from the information that has been collected during the authenticate() attempt. * * @return Zend_Auth_Result */ diff --git a/libs/Zend/Auth/Adapter/Digest.php b/libs/Zend/Auth/Adapter/Digest.php index a099bef358..259ae3f3cd 100644 --- a/libs/Zend/Auth/Adapter/Digest.php +++ b/libs/Zend/Auth/Adapter/Digest.php @@ -14,24 +14,24 @@ * * @category Zend * @package Zend_Auth - * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Adapter + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Digest.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Digest.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Adapter_Interface */ -// require_once 'Zend/Auth/Adapter/Interface.php'; +require_once 'Zend/Auth/Adapter/Interface.php'; /** * @category Zend * @package Zend_Auth - * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Adapter + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_Digest implements Zend_Auth_Adapter_Interface @@ -186,7 +186,7 @@ class Zend_Auth_Adapter_Digest implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception("Option '$optionRequired' must be set before authentication"); } } @@ -195,7 +195,7 @@ class Zend_Auth_Adapter_Digest implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception("Cannot open '$this->_filename' for reading"); } diff --git a/libs/Zend/Auth/Adapter/Exception.php b/libs/Zend/Auth/Adapter/Exception.php index 23282dddf2..0b5a4d43cf 100644 --- a/libs/Zend/Auth/Adapter/Exception.php +++ b/libs/Zend/Auth/Adapter/Exception.php @@ -14,24 +14,24 @@ * * @category Zend * @package Zend_Auth - * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Adapter + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * Zend_Auth_Exception */ -// require_once 'Zend/Auth/Exception.php'; +require_once 'Zend/Auth/Exception.php'; /** * @category Zend * @package Zend_Auth - * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Adapter + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_Exception extends Zend_Auth_Exception diff --git a/libs/Zend/Auth/Adapter/Http.php b/libs/Zend/Auth/Adapter/Http.php index d645d8db93..466ce42597 100644 --- a/libs/Zend/Auth/Adapter/Http.php +++ b/libs/Zend/Auth/Adapter/Http.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Http.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Http.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Adapter_Interface */ -// require_once 'Zend/Auth/Adapter/Interface.php'; +require_once 'Zend/Auth/Adapter/Interface.php'; /** @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @todo Support auth-int * @todo Track nonces, nonce-count, opaque for replay protection and stale support @@ -171,7 +171,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception(__CLASS__ . ' requires the \'hash\' extension'); } @@ -184,7 +184,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Config key \'accept_schemes\' is required'); } @@ -194,7 +194,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('No supported schemes given in \'accept_schemes\'. Valid values: ' . implode(', ', $this->_supportedSchemes)); } @@ -208,7 +208,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Config key \'realm\' is required, and must contain only printable ' . 'characters, excluding quotation marks and colons'); } else { @@ -222,7 +222,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Config key \'digest_domains\' is required, and must contain ' . 'only printable characters, excluding quotation marks'); } else { @@ -234,7 +234,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Config key \'nonce_timeout\' is required, and must be an ' . 'integer'); } else { @@ -368,7 +368,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling ' . 'authenticate()'); } @@ -403,7 +403,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface // challenge again the client return $this->_challengeClient(); } - + switch ($clientScheme) { case 'basic': $result = $this->_basicAuth($authHeader); @@ -415,7 +415,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Unsupported authentication scheme'); } @@ -502,14 +502,14 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('The value of the client Authorization header is required'); } if (empty($this->_basicResolver)) { /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('A basicResolver object must be set before doing Basic ' . 'authentication'); } @@ -521,7 +521,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Unable to base64_decode Authorization header value'); } @@ -559,14 +559,14 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('The value of the client Authorization header is required'); } if (empty($this->_digestResolver)) { /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('A digestResolver object must be set before doing Digest authentication'); } @@ -625,7 +625,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; + require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Client requested an unsupported qop option'); } // Using hash() should make parameterizing the hash algorithm diff --git a/libs/Zend/Auth/Adapter/Http/Resolver/Exception.php b/libs/Zend/Auth/Adapter/Http/Resolver/Exception.php index 5a4c9bf358..cb7b18be0d 100644 --- a/libs/Zend/Auth/Adapter/Http/Resolver/Exception.php +++ b/libs/Zend/Auth/Adapter/Http/Resolver/Exception.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Exception */ -// require_once 'Zend/Auth/Exception.php'; +require_once 'Zend/Auth/Exception.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_Http_Resolver_Exception extends Zend_Auth_Exception diff --git a/libs/Zend/Auth/Adapter/Http/Resolver/File.php b/libs/Zend/Auth/Adapter/Http/Resolver/File.php index d17c2ecb37..39b548ca66 100644 --- a/libs/Zend/Auth/Adapter/Http/Resolver/File.php +++ b/libs/Zend/Auth/Adapter/Http/Resolver/File.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: File.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: File.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Adapter_Http_Resolver_Interface */ -// require_once 'Zend/Auth/Adapter/Http/Resolver/Interface.php'; +require_once 'Zend/Auth/Adapter/Http/Resolver/Interface.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_Http_Resolver_File implements Zend_Auth_Adapter_Http_Resolver_Interface @@ -71,7 +71,7 @@ class Zend_Auth_Adapter_Http_Resolver_File implements Zend_Auth_Adapter_Http_Res /** * @see Zend_Auth_Adapter_Http_Resolver_Exception */ - // require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; + require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; throw new Zend_Auth_Adapter_Http_Resolver_Exception('Path not readable: ' . $path); } $this->_file = $path; @@ -116,13 +116,13 @@ class Zend_Auth_Adapter_Http_Resolver_File implements Zend_Auth_Adapter_Http_Res /** * @see Zend_Auth_Adapter_Http_Resolver_Exception */ - // require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; + require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username is required'); } else if (!ctype_print($username) || strpos($username, ':') !== false) { /** * @see Zend_Auth_Adapter_Http_Resolver_Exception */ - // require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; + require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username must consist only of printable characters, ' . 'excluding the colon'); } @@ -130,13 +130,13 @@ class Zend_Auth_Adapter_Http_Resolver_File implements Zend_Auth_Adapter_Http_Res /** * @see Zend_Auth_Adapter_Http_Resolver_Exception */ - // require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; + require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm is required'); } else if (!ctype_print($realm) || strpos($realm, ':') !== false) { /** * @see Zend_Auth_Adapter_Http_Resolver_Exception */ - // require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; + require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm must consist only of printable characters, ' . 'excluding the colon.'); } @@ -147,7 +147,7 @@ class Zend_Auth_Adapter_Http_Resolver_File implements Zend_Auth_Adapter_Http_Res /** * @see Zend_Auth_Adapter_Http_Resolver_Exception */ - // require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; + require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php'; throw new Zend_Auth_Adapter_Http_Resolver_Exception('Unable to open password file: ' . $this->_file); } diff --git a/libs/Zend/Auth/Adapter/Http/Resolver/Interface.php b/libs/Zend/Auth/Adapter/Http/Resolver/Interface.php index 78c0343147..d36a0125a2 100644 --- a/libs/Zend/Auth/Adapter/Http/Resolver/Interface.php +++ b/libs/Zend/Auth/Adapter/Http/Resolver/Interface.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16200 2009-06-21 18:50:06Z thomas $ */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Auth_Adapter_Http_Resolver_Interface diff --git a/libs/Zend/Auth/Adapter/InfoCard.php b/libs/Zend/Auth/Adapter/InfoCard.php index 8f2572a571..1af3a08616 100644 --- a/libs/Zend/Auth/Adapter/InfoCard.php +++ b/libs/Zend/Auth/Adapter/InfoCard.php @@ -15,25 +15,25 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: InfoCard.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: InfoCard.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Adapter_Interface */ -// require_once 'Zend/Auth/Adapter/Interface.php'; +require_once 'Zend/Auth/Adapter/Interface.php'; /** * @see Zend_Auth_Result */ -// require_once 'Zend/Auth/Result.php'; +require_once 'Zend/Auth/Result.php'; /** * @see Zend_InfoCard */ -// require_once 'Zend/InfoCard.php'; +require_once 'Zend/InfoCard.php'; /** * A Zend_Auth Authentication Adapter allowing the use of Information Cards as an @@ -42,7 +42,7 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_InfoCard implements Zend_Auth_Adapter_Interface diff --git a/libs/Zend/Auth/Adapter/Interface.php b/libs/Zend/Auth/Adapter/Interface.php index 3f8204842b..67cb6b8b02 100644 --- a/libs/Zend/Auth/Adapter/Interface.php +++ b/libs/Zend/Auth/Adapter/Interface.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Result */ -// require_once 'Zend/Auth/Result.php'; +require_once 'Zend/Auth/Result.php'; /** * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Auth_Adapter_Interface diff --git a/libs/Zend/Auth/Adapter/Ldap.php b/libs/Zend/Auth/Adapter/Ldap.php index 20f31c1fe0..9c0fc7f785 100644 --- a/libs/Zend/Auth/Adapter/Ldap.php +++ b/libs/Zend/Auth/Adapter/Ldap.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ldap.php 21320 2010-03-04 16:05:09Z sgehrig $ + * @version $Id: Ldap.php 17976 2009-09-04 14:50:25Z sgehrig $ */ /** * @see Zend_Auth_Adapter_Interface */ -// require_once 'Zend/Auth/Adapter/Interface.php'; +require_once 'Zend/Auth/Adapter/Interface.php'; /** * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface @@ -161,7 +161,7 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface /** * setIdentity() - set the identity (username) to be used * - * Proxies to {@see setUsername()} + * Proxies to {@see setPassword()} * * Closes ZF-6813 * @@ -199,7 +199,7 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface /** * @see Zend_Ldap */ - // require_once 'Zend/Ldap.php'; + require_once 'Zend/Ldap.php'; $this->_ldap = new Zend_Ldap(); } @@ -247,7 +247,7 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface /** * @see Zend_Ldap_Exception */ - // require_once 'Zend/Ldap/Exception.php'; + require_once 'Zend/Ldap/Exception.php'; $messages = array(); $messages[0] = ''; // reserved @@ -285,8 +285,8 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface /** * @see Zend_Auth_Adapter_Exception */ - // require_once 'Zend/Auth/Adapter/Exception.php'; - throw new Zend_Auth_Adapter_Exception('Adapter options array not an array'); + require_once 'Zend/Auth/Adapter/Exception.php'; + throw new Zend_Auth_Adapter_Exception('Adapter options array not in array'); } $adapterOptions = $this->_prepareOptions($ldap, $options); $dname = ''; @@ -314,18 +314,6 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface $canonicalName = $ldap->getCanonicalAccountName($username); $ldap->bind($canonicalName, $password); - /* - * Fixes problem when authenticated user is not allowed to retrieve - * group-membership information or own account. - * This requires that the user specified with "username" and optionally - * "password" in the Zend_Ldap options is able to retrieve the required - * information. - */ - $requireRebind = false; - if (isset($options['username'])) { - $ldap->bind(); - $requireRebind = true; - } $dn = $ldap->getCanonicalAccountName($canonicalName, Zend_Ldap::ACCTNAME_FORM_DN); $groupResult = $this->_checkGroupMembership($ldap, $canonicalName, $dn, $adapterOptions); @@ -334,10 +322,6 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface $messages[0] = ''; $messages[1] = ''; $messages[] = "$canonicalName authentication successful"; - if ($requireRebind === true) { - // rebinding with authenticated user - $ldap->bind($dn, $password); - } return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $canonicalName, $messages); } else { $messages[0] = 'Account is not a member of the specified group'; @@ -424,6 +408,7 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface } } } + $ldap->setOptions($options); return $adapterOptions; } @@ -452,7 +437,7 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface /** * @see Zend_Ldap_Filter */ - // require_once 'Zend/Ldap/Filter.php'; + require_once 'Zend/Ldap/Filter.php'; $groupName = Zend_Ldap_Filter::equals($adapterOptions['groupAttr'], $adapterOptions['group']); $membership = Zend_Ldap_Filter::equals($adapterOptions['memberAttr'], $user); $group = Zend_Ldap_Filter::andFilter($groupName, $membership); @@ -461,6 +446,14 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface $group = $group->addAnd($groupFilter); } + /* + * Fixes problem when authenticated user is not allowed to retrieve + * group-membership information. + * This requires that the user specified with "username" and "password" + * in the Zend_Ldap options is able to retrieve the required information. + */ + $ldap->bind(); + $result = $ldap->count($group, $adapterOptions['groupDn'], $adapterOptions['groupScope']); if ($result === 1) { @@ -473,14 +466,13 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface /** * getAccountObject() - Returns the result entry as a stdClass object * - * This resembles the feature {@see Zend_Auth_Adapter_DbTable::getResultRowObject()}. + * This ressembles the feature {@see Zend_Auth_Adapter_DbTable::getResultRowObject()}. * Closes ZF-6813 * * @param array $returnAttribs - * @param array $omitAttribs * @return stdClass|boolean */ - public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array()) + public function getAccountObject(array $returnAttribs = array()) { if (!$this->_authenticatedDn) { return false; @@ -488,14 +480,8 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface $returnObject = new stdClass(); - $omitAttribs = array_map('strtolower', $omitAttribs); - $entry = $this->getLdap()->getEntry($this->_authenticatedDn, $returnAttribs, true); foreach ($entry as $attr => $value) { - if (in_array($attr, $omitAttribs)) { - // skip attributes marked to be omitted - continue; - } if (is_array($value)) { $returnObject->$attr = (count($value) > 1) ? $value : $value[0]; } else { diff --git a/libs/Zend/Auth/Adapter/OpenId.php b/libs/Zend/Auth/Adapter/OpenId.php index 08f21d949b..44e4684456 100644 --- a/libs/Zend/Auth/Adapter/OpenId.php +++ b/libs/Zend/Auth/Adapter/OpenId.php @@ -15,22 +15,22 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OpenId.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: OpenId.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Adapter_Interface */ -// require_once 'Zend/Auth/Adapter/Interface.php'; +require_once 'Zend/Auth/Adapter/Interface.php'; /** * @see Zend_OpenId_Consumer */ -// require_once 'Zend/OpenId/Consumer.php'; +require_once 'Zend/OpenId/Consumer.php'; /** @@ -40,7 +40,7 @@ * @category Zend * @package Zend_Auth * @subpackage Zend_Auth_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Adapter_OpenId implements Zend_Auth_Adapter_Interface diff --git a/libs/Zend/Auth/Exception.php b/libs/Zend/Auth/Exception.php index 80334c1911..c71f41c505 100644 --- a/libs/Zend/Auth/Exception.php +++ b/libs/Zend/Auth/Exception.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Auth - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Auth - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Exception extends Zend_Exception diff --git a/libs/Zend/Auth/Result.php b/libs/Zend/Auth/Result.php index 964d44d80d..18ba1023f9 100644 --- a/libs/Zend/Auth/Result.php +++ b/libs/Zend/Auth/Result.php @@ -14,16 +14,16 @@ * * @category Zend * @package Zend_Auth - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Result.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Result.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @category Zend * @package Zend_Auth - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Result diff --git a/libs/Zend/Auth/Storage/Exception.php b/libs/Zend/Auth/Storage/Exception.php index 218c909c50..6f3af444c0 100644 --- a/libs/Zend/Auth/Storage/Exception.php +++ b/libs/Zend/Auth/Storage/Exception.php @@ -14,24 +14,24 @@ * * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Exception */ -// require_once 'Zend/Auth/Exception.php'; +require_once 'Zend/Auth/Exception.php'; /** * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Storage_Exception extends Zend_Auth_Exception diff --git a/libs/Zend/Auth/Storage/Interface.php b/libs/Zend/Auth/Storage/Interface.php index 9fedf01322..a604a0d8c6 100644 --- a/libs/Zend/Auth/Storage/Interface.php +++ b/libs/Zend/Auth/Storage/Interface.php @@ -14,17 +14,18 @@ * * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16200 2009-06-21 18:50:06Z thomas $ */ + /** * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Auth_Storage_Interface diff --git a/libs/Zend/Auth/Storage/NonPersistent.php b/libs/Zend/Auth/Storage/NonPersistent.php index 1dd034b7ef..6c544fff4b 100644 --- a/libs/Zend/Auth/Storage/NonPersistent.php +++ b/libs/Zend/Auth/Storage/NonPersistent.php @@ -14,17 +14,17 @@ * * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NonPersistent.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: NonPersistent.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Storage_Interface */ -// require_once 'Zend/Auth/Storage/Interface.php'; +require_once 'Zend/Auth/Storage/Interface.php'; /** @@ -36,8 +36,8 @@ * * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Storage_NonPersistent implements Zend_Auth_Storage_Interface @@ -47,6 +47,7 @@ class Zend_Auth_Storage_NonPersistent implements Zend_Auth_Storage_Interface */ protected $_data; + /** * Returns true if and only if storage is empty * diff --git a/libs/Zend/Auth/Storage/Session.php b/libs/Zend/Auth/Storage/Session.php index a3775ce3d3..14027968b0 100644 --- a/libs/Zend/Auth/Storage/Session.php +++ b/libs/Zend/Auth/Storage/Session.php @@ -14,30 +14,30 @@ * * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Session.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Session.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @see Zend_Auth_Storage_Interface */ -// require_once 'Zend/Auth/Storage/Interface.php'; +require_once 'Zend/Auth/Storage/Interface.php'; /** * @see Zend_Session */ -// require_once 'Zend/Session.php'; +require_once 'Zend/Session.php'; /** * @category Zend * @package Zend_Auth - * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @subpackage Zend_Auth_Storage + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Auth_Storage_Session implements Zend_Auth_Storage_Interface diff --git a/libs/Zend/Cache.php b/libs/Zend/Cache.php index 761be75e17..1ea81411d8 100644 --- a/libs/Zend/Cache.php +++ b/libs/Zend/Cache.php @@ -14,15 +14,15 @@ * * @category Zend * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Cache.php 21974 2010-04-23 17:10:17Z alexander $ + * @version $Id: Cache.php 16200 2009-06-21 18:50:06Z thomas $ */ /** * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Cache @@ -40,16 +40,15 @@ abstract class Zend_Cache * * @var array */ - public static $standardBackends = array('File', 'Sqlite', 'Memcached', 'Apc', 'ZendPlatform', - 'Xcache', 'TwoLevels', 'ZendServer_Disk', 'ZendServer_ShMem'); + public static $standardBackends = array('File', 'Sqlite', 'Memcached', 'Apc', 'ZendPlatform', 'Xcache', 'TwoLevels'); /** * Standard backends which implement the ExtendedInterface - * + * * @var array */ public static $standardExtendedBackends = array('File', 'Apc', 'TwoLevels', 'Memcached', 'Sqlite'); - + /** * Only for backward compatibily (may be removed in next major release) * @@ -74,7 +73,7 @@ abstract class Zend_Cache const CLEANING_MODE_MATCHING_TAG = 'matchingTag'; const CLEANING_MODE_NOT_MATCHING_TAG = 'notMatchingTag'; const CLEANING_MODE_MATCHING_ANY_TAG = 'matchingAnyTag'; - + /** * Factory * @@ -84,7 +83,7 @@ abstract class Zend_Cache * @param array $backendOptions associative array of options for the corresponding backend constructor * @param boolean $customFrontendNaming if true, the frontend argument is used as a complete class name ; if false, the frontend argument is used as the end of "Zend_Cache_Frontend_[...]" class name * @param boolean $customBackendNaming if true, the backend argument is used as a complete class name ; if false, the backend argument is used as the end of "Zend_Cache_Backend_[...]" class name - * @param boolean $autoload if true, there will no // require_once for backend and frontend (usefull only for custom backends/frontends) + * @param boolean $autoload if true, there will no require_once for backend and frontend (usefull only for custom backends/frontends) * @throws Zend_Cache_Exception * @return Zend_Cache_Core|Zend_Cache_Frontend */ @@ -111,7 +110,7 @@ abstract class Zend_Cache $frontendObject->setBackend($backendObject); return $frontendObject; } - + /** * Frontend Constructor * @@ -130,7 +129,7 @@ abstract class Zend_Cache // we use a standard backend $backendClass = 'Zend_Cache_Backend_' . $backend; // security controls are explicit - // require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php'; + require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php'; } else { // we use a custom backend if (!preg_match('~^[\w]+$~D', $backend)) { @@ -147,12 +146,12 @@ abstract class Zend_Cache if (!(self::_isReadable($file))) { self::throwException("file $file not found in include_path"); } - // require_once $file; + require_once $file; } } return new $backendClass($backendOptions); } - + /** * Backend Constructor * @@ -172,7 +171,7 @@ abstract class Zend_Cache // For perfs reasons, with frontend == 'Core', we can interact with the Core itself $frontendClass = 'Zend_Cache_' . ($frontend != 'Core' ? 'Frontend_' : '') . $frontend; // security controls are explicit - // require_once str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php'; + require_once str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php'; } else { // we use a custom frontend if (!preg_match('~^[\w]+$~D', $frontend)) { @@ -189,7 +188,7 @@ abstract class Zend_Cache if (!(self::_isReadable($file))) { self::throwException("file $file not found in include_path"); } - // require_once $file; + require_once $file; } } return new $frontendClass($frontendOptions); @@ -202,11 +201,11 @@ abstract class Zend_Cache * @param string $msg Message for the exception * @throws Zend_Cache_Exception */ - public static function throwException($msg, Exception $e = null) + public static function throwException($msg) { // For perfs reasons, we use this dynamic inclusion - // require_once 'Zend/Cache/Exception.php'; - throw new Zend_Cache_Exception($msg, 0, $e); + require_once 'Zend/Cache/Exception.php'; + throw new Zend_Cache_Exception($msg); } /** @@ -221,10 +220,6 @@ abstract class Zend_Cache $name = str_replace(array('-', '_', '.'), ' ', $name); $name = ucwords($name); $name = str_replace(' ', '', $name); - if (stripos($name, 'ZendServer') === 0) { - $name = 'ZendServer_' . substr($name, strlen('ZendServer')); - } - return $name; } diff --git a/libs/Zend/Cache/Backend.php b/libs/Zend/Cache/Backend.php index f71dae135a..052181972f 100644 --- a/libs/Zend/Cache/Backend.php +++ b/libs/Zend/Cache/Backend.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Backend.php 20882 2010-02-03 18:19:44Z matthew $ + * @version $Id: Backend.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend @@ -140,77 +140,77 @@ class Zend_Cache_Backend { return true; } - + /** * Determine system TMP directory and detect if we have read access * - * inspired from Zend_File_Transfer_Adapter_Abstract + * inspired from Zend_File_Transfer_Adapter_Abstract * * @return string * @throws Zend_Cache_Exception if unable to determine directory */ public function getTmpDir() { - $tmpdir = array(); + $tmpdir = array(); foreach (array($_ENV, $_SERVER) as $tab) { - foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) { - if (isset($tab[$key])) { - if (($key == 'windir') or ($key == 'SystemRoot')) { + foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) { + if (isset($tab[$key])) { + if (($key == 'windir') or ($key == 'SystemRoot')) { $dir = realpath($tab[$key] . '\\temp'); } else { - $dir = realpath($tab[$key]); - } - if ($this->_isGoodTmpDir($dir)) { - return $dir; + $dir = realpath($tab[$key]); } - } - } + if ($this->_isGoodTmpDir($dir)) { + return $dir; + } + } + } } $upload = ini_get('upload_tmp_dir'); if ($upload) { $dir = realpath($upload); - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } + if ($this->_isGoodTmpDir($dir)) { + return $dir; + } } if (function_exists('sys_get_temp_dir')) { $dir = sys_get_temp_dir(); - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } + if ($this->_isGoodTmpDir($dir)) { + return $dir; + } } // Attemp to detect by creating a temporary file $tempFile = tempnam(md5(uniqid(rand(), TRUE)), ''); if ($tempFile) { - $dir = realpath(dirname($tempFile)); + $dir = realpath(dirname($tempFile)); unlink($tempFile); if ($this->_isGoodTmpDir($dir)) { return $dir; } } if ($this->_isGoodTmpDir('/tmp')) { - return '/tmp'; + return '/tmp'; } if ($this->_isGoodTmpDir('\\temp')) { - return '\\temp'; + return '\\temp'; } Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually'); } - + /** * Verify if the given temporary directory is readable and writable - * + * * @param $dir temporary directory * @return boolean true if the directory is ok */ protected function _isGoodTmpDir($dir) { - if (is_readable($dir)) { - if (is_writable($dir)) { - return true; - } - } - return false; + if (is_readable($dir)) { + if (is_writable($dir)) { + return true; + } + } + return false; } /** @@ -226,17 +226,23 @@ class Zend_Cache_Backend if (!isset($this->_directives['logging']) || !$this->_directives['logging']) { return; } - + try { + /** + * @see Zend_Log + */ + require_once 'Zend/Log.php'; + } catch (Zend_Exception $e) { + Zend_Cache::throwException('Logging feature is enabled but the Zend_Log class is not available'); + } if (isset($this->_directives['logger'])) { if ($this->_directives['logger'] instanceof Zend_Log) { return; + } else { + Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.'); } - Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.'); } - // Create a default logger to the standard output stream - // require_once 'Zend/Log.php'; - // require_once 'Zend/Log/Writer/Stream.php'; + require_once 'Zend/Log/Writer/Stream.php'; $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output')); $this->_directives['logger'] = $logger; } @@ -255,7 +261,7 @@ class Zend_Cache_Backend } if (!isset($this->_directives['logger'])) { - Zend_Cache::throwException('Logging is enabled but logger is not set.'); + Zend_Cache::throwException('Logging is enabled but logger is not set.'); } $logger = $this->_directives['logger']; if (!$logger instanceof Zend_Log) { diff --git a/libs/Zend/Cache/Backend/Apc.php b/libs/Zend/Cache/Backend/Apc.php index e25bd397bb..fd99ae45ef 100644 --- a/libs/Zend/Cache/Backend/Apc.php +++ b/libs/Zend/Cache/Backend/Apc.php @@ -15,27 +15,27 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Apc.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Apc.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/ExtendedInterface.php'; +require_once 'Zend/Cache/Backend/ExtendedInterface.php'; /** * @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface @@ -166,18 +166,18 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba * Return true if the automatic cleaning is available for the backend * * DEPRECATED : use getCapabilities() instead - * - * @deprecated + * + * @deprecated * @return boolean */ public function isAutomaticCleaningAvailable() { return false; } - + /** * Return the filling percentage of the backend storage - * + * * @throws Zend_Cache_Exception * @return int integer between 0 and 100 */ @@ -195,21 +195,21 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba } return ((int) (100. * ($memUsed / $memSize))); } - + /** * Return an array of stored tags * * @return array array of stored tags (string) */ public function getTags() - { + { $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); return array(); } - + /** * Return an array of stored cache ids which match given tags - * + * * In case of multiple tags, a logical AND is made between tags * * @param array $tags array of tags @@ -218,26 +218,26 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba public function getIdsMatchingTags($tags = array()) { $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - return array(); + return array(); } /** * Return an array of stored cache ids which don't match given tags - * + * * In case of multiple tags, a logical OR is made between tags * * @param array $tags array of tags * @return array array of not matching cache ids (string) - */ + */ public function getIdsNotMatchingTags($tags = array()) { $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - return array(); + return array(); } - + /** * Return an array of stored cache ids which match any given tags - * + * * In case of multiple tags, a logical AND is made between tags * * @param array $tags array of tags @@ -246,12 +246,12 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba public function getIdsMatchingAnyTags($tags = array()) { $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - return array(); + return array(); } - + /** * Return an array of stored cache ids - * + * * @return array array of stored cache ids (string) */ public function getIds() @@ -264,7 +264,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba } return $res; } - + /** * Return an array of metadatas for the given cache id * @@ -272,7 +272,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba * - expire : the expire timestamp * - tags : a string array of tags * - mtime : timestamp of last modification time - * + * * @param string $id cache id * @return array array of metadatas (false if the cache id is not found) */ @@ -294,9 +294,9 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba 'mtime' => $mtime ); } - return false; + return false; } - + /** * Give (if possible) an extra lifetime to the given cache id * @@ -318,17 +318,17 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba $lifetime = $tmp[2]; $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime; if ($newLifetime <=0) { - return false; + return false; } apc_store($id, array($data, time(), $newLifetime), $newLifetime); return true; } return false; } - + /** * Return an associative array of capabilities (booleans) of the backend - * + * * The array must include these keys : * - automatic_cleaning (is automating cleaning necessary) * - tags (are tags supported) @@ -337,7 +337,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba * - priority does the backend deal with priority when saving * - infinite_lifetime (is infinite lifetime can work with this backend) * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * + * * @return array associative of with capabilities */ public function getCapabilities() diff --git a/libs/Zend/Cache/Backend/BlackHole.php b/libs/Zend/Cache/Backend/BlackHole.php deleted file mode 100644 index 3eb382eca2..0000000000 --- a/libs/Zend/Cache/Backend/BlackHole.php +++ /dev/null @@ -1,250 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Cache - * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BlackHole.php 17867 2009-08-28 09:42:11Z yoshida@zend.co.jp $ - */ - -/** - * @see Zend_Cache_Backend_Interface - */ -// require_once 'Zend/Cache/Backend/ExtendedInterface.php'; - -/** - * @see Zend_Cache_Backend - */ -// require_once 'Zend/Cache/Backend.php'; - -/** - * @package Zend_Cache - * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Cache_Backend_BlackHole - extends Zend_Cache_Backend - implements Zend_Cache_Backend_ExtendedInterface -{ - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id cache id - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - return true; - } - - /** - * Remove a cache record - * - * @param string $id cache id - * @return boolean true if no problem - */ - public function remove($id) - { - return true; - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => remove too old cache entries ($tags is not used) - * 'matchingTag' => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * 'notMatchingTag' => remove cache entries not matching one of the given tags - * ($tags can be an array of strings or a single string) - * 'matchingAnyTag' => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode clean mode - * @param tags array $tags array of tags - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - return true; - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - return array(); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - return array(); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - return array(); - } - - /** - * Return the filling percentage of the backend storage - * - * @return int integer between 0 and 100 - * @throws Zend_Cache_Exception - */ - public function getFillingPercentage() - { - return 0; - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - return false; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => true, - 'tags' => true, - 'expired_read' => true, - 'priority' => true, - 'infinite_lifetime' => true, - 'get_list' => true, - ); - } - - /** - * PUBLIC METHOD FOR UNIT TESTING ONLY ! - * - * Force a cache record to expire - * - * @param string $id cache id - */ - public function ___expire($id) - { - } -} diff --git a/libs/Zend/Cache/Backend/ExtendedInterface.php b/libs/Zend/Cache/Backend/ExtendedInterface.php index f24ecc1091..22e559b25b 100644 --- a/libs/Zend/Cache/Backend/ExtendedInterface.php +++ b/libs/Zend/Cache/Backend/ExtendedInterface.php @@ -15,20 +15,20 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExtendedInterface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: ExtendedInterface.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/Interface.php'; +require_once 'Zend/Cache/Backend/Interface.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interface @@ -36,21 +36,21 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf /** * Return an array of stored cache ids - * + * * @return array array of stored cache ids (string) */ public function getIds(); - + /** * Return an array of stored tags * * @return array array of stored tags (string) */ public function getTags(); - + /** * Return an array of stored cache ids which match given tags - * + * * In case of multiple tags, a logical AND is made between tags * * @param array $tags array of tags @@ -60,24 +60,24 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf /** * Return an array of stored cache ids which don't match given tags - * + * * In case of multiple tags, a logical OR is made between tags * * @param array $tags array of tags * @return array array of not matching cache ids (string) - */ + */ public function getIdsNotMatchingTags($tags = array()); /** * Return an array of stored cache ids which match any given tags - * + * * In case of multiple tags, a logical AND is made between tags * * @param array $tags array of tags * @return array array of any matching cache ids (string) */ public function getIdsMatchingAnyTags($tags = array()); - + /** * Return the filling percentage of the backend storage * @@ -92,12 +92,12 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf * - expire : the expire timestamp * - tags : a string array of tags * - mtime : timestamp of last modification time - * + * * @param string $id cache id * @return array array of metadatas (false if the cache id is not found) */ public function getMetadatas($id); - + /** * Give (if possible) an extra lifetime to the given cache id * @@ -106,10 +106,10 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf * @return boolean true if ok */ public function touch($id, $extraLifetime); - + /** * Return an associative array of capabilities (booleans) of the backend - * + * * The array must include these keys : * - automatic_cleaning (is automating cleaning necessary) * - tags (are tags supported) @@ -118,9 +118,9 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf * - priority does the backend deal with priority when saving * - infinite_lifetime (is infinite lifetime can work with this backend) * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * + * * @return array associative of with capabilities */ public function getCapabilities(); - + } diff --git a/libs/Zend/Cache/Backend/File.php b/libs/Zend/Cache/Backend/File.php index eeddfa5b80..51e2697ad9 100644 --- a/libs/Zend/Cache/Backend/File.php +++ b/libs/Zend/Cache/Backend/File.php @@ -15,26 +15,26 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: File.php 21642 2010-03-25 17:07:02Z mabe $ + * @version $Id: File.php 17868 2009-08-28 09:46:30Z yoshida@zend.co.jp $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/ExtendedInterface.php'; +require_once 'Zend/Cache/Backend/ExtendedInterface.php'; /** * @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface @@ -123,8 +123,8 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B $this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false); } if (isset($this->_options['file_name_prefix'])) { // particular case for this option - if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) { - Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]'); + if (!preg_match('~^[\w]+$~', $this->_options['file_name_prefix'])) { + Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-A0-9_]'); } } if ($this->_options['metadatas_array_max_size'] < 10) { @@ -647,7 +647,6 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B $prefix = $this->_options['file_name_prefix']; $glob = @glob($dir . $prefix . '--*'); if ($glob === false) { - // On some systems it is impossible to distinguish between empty match and an error. return true; } foreach ($glob as $file) { @@ -740,8 +739,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B $prefix = $this->_options['file_name_prefix']; $glob = @glob($dir . $prefix . '--*'); if ($glob === false) { - // On some systems it is impossible to distinguish between empty match and an error. - return array(); + return true; } foreach ($glob as $file) { if (is_file($file)) { @@ -804,12 +802,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B } if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) { // Recursive call - $recursiveRs = $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags); - if ($recursiveRs === false) { - $this->_log('Zend_Cache_Backend_File::_get() / recursive call : can\'t list entries of "'.$file.'"'); - } else { - $result = array_unique(array_merge($result, $recursiveRs)); - } + $result = array_unique(array_merge($result, $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags))); } } return array_unique($result); diff --git a/libs/Zend/Cache/Backend/Interface.php b/libs/Zend/Cache/Backend/Interface.php index 3e8c7d1211..f2878f95ae 100644 --- a/libs/Zend/Cache/Backend/Interface.php +++ b/libs/Zend/Cache/Backend/Interface.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Cache_Backend_Interface diff --git a/libs/Zend/Cache/Backend/Memcached.php b/libs/Zend/Cache/Backend/Memcached.php index 3c29bcce67..86bbca3a1c 100644 --- a/libs/Zend/Cache/Backend/Memcached.php +++ b/libs/Zend/Cache/Backend/Memcached.php @@ -15,27 +15,27 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Memcached.php 22208 2010-05-20 16:59:02Z mabe $ + * @version $Id: Memcached.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/ExtendedInterface.php'; +require_once 'Zend/Cache/Backend/ExtendedInterface.php'; /** * @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface @@ -155,16 +155,16 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca $server['failure_callback'] = self::DEFAULT_FAILURE_CALLBACK; } if ($this->_options['compatibility']) { - // No status for compatibility mode (#ZF-5887) - $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], + // No status for compatibility mode (#ZF-5887) + $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], $server['weight'], $server['timeout'], $server['retry_interval']); - } else { - $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], + } else { + $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], $server['weight'], $server['timeout'], $server['retry_interval'], $server['status'], $server['failure_callback']); - } + } } } @@ -178,7 +178,7 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca public function load($id, $doNotTestCacheValidity = false) { $tmp = $this->_memcache->get($id); - if (is_array($tmp) && isset($tmp[0])) { + if (is_array($tmp)) { return $tmp[0]; } return false; @@ -219,14 +219,13 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca } else { $flag = 0; } - - // ZF-8856: using set because add needs a second request if item already exists - $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime); - + // #ZF-5702 : we try add() first becase set() seems to be slower + if (!($result = $this->_memcache->add($id, array($data, time(), $lifetime), $flag, $lifetime))) { + $result = $this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime); + } if (count($tags) > 0) { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND); + $this->_log("Zend_Cache_Backend_Memcached::save() : tags are unsupported by the Memcached backend"); } - return $result; } @@ -238,7 +237,7 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca */ public function remove($id) { - return $this->_memcache->delete($id, 0); + return $this->_memcache->delete($id); } /** @@ -381,26 +380,25 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca { $mems = $this->_memcache->getExtendedStats(); - $memSize = null; - $memUsed = null; + $memSize = 0; + $memUsed = 0; foreach ($mems as $key => $mem) { - if ($mem === false) { - $this->_log('can\'t get stat from ' . $key); - continue; - } - - $eachSize = $mem['limit_maxbytes']; - $eachUsed = $mem['bytes']; - if ($eachUsed > $eachSize) { - $eachUsed = $eachSize; - } - - $memSize += $eachSize; - $memUsed += $eachUsed; - } - - if ($memSize === null || $memUsed === null) { - Zend_Cache::throwException('Can\'t get filling percentage'); + if ($mem === false) { + Zend_Cache::throwException('can\'t get stat from ' . $key); + } else { + $eachSize = $mem['limit_maxbytes']; + if ($eachSize == 0) { + Zend_Cache::throwException('can\'t get memory size from ' . $key); + } + + $eachUsed = $mem['bytes']; + if ($eachUsed > $eachSize) { + $eachUsed = $eachSize; + } + + $memSize += $eachSize; + $memUsed += $eachUsed; + } } return ((int) (100. * ($memUsed / $memSize))); @@ -468,7 +466,7 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca } // #ZF-5702 : we try replace() first becase set() seems to be slower if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $flag, $newLifetime))) { - $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime); + $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime); } return $result; } diff --git a/libs/Zend/Cache/Backend/Sqlite.php b/libs/Zend/Cache/Backend/Sqlite.php index 3bb5ba91e3..7430d7303b 100644 --- a/libs/Zend/Cache/Backend/Sqlite.php +++ b/libs/Zend/Cache/Backend/Sqlite.php @@ -15,26 +15,26 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sqlite.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Sqlite.php 17868 2009-08-28 09:46:30Z yoshida@zend.co.jp $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/ExtendedInterface.php'; +require_once 'Zend/Cache/Backend/ExtendedInterface.php'; /** * @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_Sqlite extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface diff --git a/libs/Zend/Cache/Backend/Static.php b/libs/Zend/Cache/Backend/Static.php deleted file mode 100644 index 19d83d5fd4..0000000000 --- a/libs/Zend/Cache/Backend/Static.php +++ /dev/null @@ -1,558 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Cache - * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BlackHole.php 17867 2009-08-28 09:42:11Z yoshida@zend.co.jp $ - */ - -/** - * @see Zend_Cache_Backend_Interface - */ -// require_once 'Zend/Cache/Backend/Interface.php'; - -/** - * @see Zend_Cache_Backend - */ -// require_once 'Zend/Cache/Backend.php'; - -/** - * @package Zend_Cache - * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Cache_Backend_Static - extends Zend_Cache_Backend - implements Zend_Cache_Backend_Interface -{ - const INNER_CACHE_NAME = 'zend_cache_backend_static_tagcache'; - - /** - * Static backend options - * @var array - */ - protected $_options = array( - 'public_dir' => null, - 'sub_dir' => 'html', - 'file_extension' => '.html', - 'index_filename' => 'index', - 'file_locking' => true, - 'cache_file_umask' => 0600, - 'cache_directory_umask' => 0700, - 'debug_header' => false, - 'tag_cache' => null, - 'disable_caching' => false - ); - - /** - * Cache for handling tags - * @var Zend_Cache_Core - */ - protected $_tagCache = null; - - /** - * Tagged items - * @var array - */ - protected $_tagged = null; - - /** - * Interceptor child method to handle the case where an Inner - * Cache object is being set since it's not supported by the - * standard backend interface - * - * @param string $name - * @param mixed $value - * @return Zend_Cache_Backend_Static - */ - public function setOption($name, $value) - { - if ($name == 'tag_cache') { - $this->setInnerCache($value); - } else { - parent::setOption($name, $value); - } - return $this; - } - - /** - * Retrieve any option via interception of the parent's statically held - * options including the local option for a tag cache. - * - * @param string $name - * @return mixed - */ - public function getOption($name) - { - if ($name == 'tag_cache') { - return $this->getInnerCache(); - } else { - if (in_array($name, $this->_options)) { - return $this->_options[$name]; - } - if ($name == 'lifetime') { - return parent::getLifetime(); - } - return null; - } - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * Note : return value is always "string" (unserialization is done by the core not by the backend) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - if (empty($id)) { - $id = $this->_detectId(); - } else { - $id = $this->_decodeId($id); - } - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - if ($doNotTestCacheValidity) { - $this->_log("Zend_Cache_Backend_Static::load() : \$doNotTestCacheValidity=true is unsupported by the Static backend"); - } - - $fileName = basename($id); - if (empty($fileName)) { - $fileName = $this->_options['index_filename']; - } - $pathName = $this->_options['public_dir'] . dirname($id); - $file = rtrim($pathName, '/') . '/' . $fileName . $this->_options['file_extension']; - if (file_exists($file)) { - $content = file_get_contents($file); - return $content; - } - - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return bool - */ - public function test($id) - { - $id = $this->_decodeId($id); - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - - $fileName = basename($id); - if (empty($fileName)) { - $fileName = $this->_options['index_filename']; - } - if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif (!$this->_tagged) { - return false; - } - $pathName = $this->_options['public_dir'] . dirname($id); - - // Switch extension if needed - if (isset($this->_tagged[$id])) { - $extension = $this->_tagged[$id]['extension']; - } else { - $extension = $this->_options['file_extension']; - } - $file = $pathName . '/' . $fileName . $extension; - if (file_exists($file)) { - return true; - } - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - if ($this->_options['disable_caching']) { - return true; - } - $extension = null; - if ($this->_isSerialized($data)) { - $data = unserialize($data); - $extension = '.' . ltrim($data[1], '.'); - $data = $data[0]; - } - - clearstatcache(); - if (is_null($id) || strlen($id) == 0) { - $id = $this->_detectId(); - } else { - $id = $this->_decodeId($id); - } - - $fileName = basename($id); - if (empty($fileName)) { - $fileName = $this->_options['index_filename']; - } - - $pathName = realpath($this->_options['public_dir']) . dirname($id); - $this->_createDirectoriesFor($pathName); - - if (is_null($id) || strlen($id) == 0) { - $dataUnserialized = unserialize($data); - $data = $dataUnserialized['data']; - } - $ext = $this->_options['file_extension']; - if ($extension) $ext = $extension; - $file = rtrim($pathName, '/') . '/' . $fileName . $ext; - if ($this->_options['file_locking']) { - $result = file_put_contents($file, $data, LOCK_EX); - } else { - $result = file_put_contents($file, $data); - } - @chmod($file, $this->_octdec($this->_options['cache_file_umask'])); - - if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif (is_null($this->_tagged)) { - $this->_tagged = array(); - } - if (!isset($this->_tagged[$id])) { - $this->_tagged[$id] = array(); - } - if (!isset($this->_tagged[$id]['tags'])) { - $this->_tagged[$id]['tags'] = array(); - } - $this->_tagged[$id]['tags'] = array_unique(array_merge($this->_tagged[$id]['tags'], $tags)); - $this->_tagged[$id]['extension'] = $ext; - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - return (bool) $result; - } - - /** - * Recursively create the directories needed to write the static file - */ - protected function _createDirectoriesFor($path) - { - $parts = explode('/', $path); - $directory = ''; - foreach ($parts as $part) { - $directory = rtrim($directory, '/') . '/' . $part; - if (!is_dir($directory)) { - mkdir($directory, $this->_octdec($this->_options['cache_directory_umask'])); - } - } - } - - /** - * Detect serialization of data (cannot predict since this is the only way - * to obey the interface yet pass in another parameter). - * - * In future, ZF 2.0, check if we can just avoid the interface restraints. - * - * This format is the only valid one possible for the class, so it's simple - * to just run a regular expression for the starting serialized format. - */ - protected function _isSerialized($data) - { - return preg_match("/a:2:\{i:0;s:\d+:\"/", $data); - } - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - $fileName = basename($id); - if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif (!$this->_tagged) { - return false; - } - if (isset($this->_tagged[$id])) { - $extension = $this->_tagged[$id]['extension']; - } else { - $extension = $this->_options['file_extension']; - } - if (empty($fileName)) { - $fileName = $this->_options['index_filename']; - } - $pathName = $this->_options['public_dir'] . dirname($id); - $file = realpath($pathName) . '/' . $fileName . $extension; - if (!file_exists($file)) { - return false; - } - return unlink($file); - } - - /** - * Remove a cache record recursively for the given directory matching a - * REQUEST_URI based relative path (deletes the actual file matching this - * in addition to the matching directory) - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function removeRecursively($id) - { - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - $fileName = basename($id); - if (empty($fileName)) { - $fileName = $this->_options['index_filename']; - } - $pathName = $this->_options['public_dir'] . dirname($id); - $file = $pathName . '/' . $fileName . $this->_options['file_extension']; - $directory = $pathName . '/' . $fileName; - if (file_exists($directory)) { - if (!is_writable($directory)) { - return false; - } - foreach (new DirectoryIterator($directory) as $file) { - if (true === $file->isFile()) { - if (false === unlink($file->getPathName())) { - return false; - } - } - } - rmdir(dirname($path)); - } - if (file_exists($file)) { - if (!is_writable($file)) { - return false; - } - return unlink($file); - } - return true; - } - - /** - * Clean some cache records - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - $result = false; - switch ($mode) { - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - if (empty($tags)) { - throw new Zend_Exception('Cannot use tag matching modes as no tags were defined'); - } - if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif (!$this->_tagged) { - return true; - } - foreach ($tags as $tag) { - $urls = array_keys($this->_tagged); - foreach ($urls as $url) { - if (isset($this->_tagged[$url]['tags']) && in_array($tag, $this->_tagged[$url]['tags'])) { - $this->remove($url); - unset($this->_tagged[$url]); - } - } - } - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - $result = true; - break; - case Zend_Cache::CLEANING_MODE_ALL: - if (is_null($this->_tagged)) { - $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME); - $this->_tagged = $tagged; - } - if (is_null($this->_tagged) || empty($this->_tagged)) { - return true; - } - $urls = array_keys($this->_tagged); - foreach ($urls as $url) { - $this->remove($url); - unset($this->_tagged[$url]); - } - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - $result = true; - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_Static : Selected Cleaning Mode Currently Unsupported By This Backend"); - break; - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - if (empty($tags)) { - throw new Zend_Exception('Cannot use tag matching modes as no tags were defined'); - } - if (is_null($this->_tagged)) { - $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME); - $this->_tagged = $tagged; - } - if (is_null($this->_tagged) || empty($this->_tagged)) { - return true; - } - $urls = array_keys($this->_tagged); - foreach ($urls as $url) { - $difference = array_diff($tags, $this->_tagged[$url]['tags']); - if (count($tags) == count($difference)) { - $this->remove($url); - unset($this->_tagged[$url]); - } - } - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - $result = true; - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - return $result; - } - - /** - * Set an Inner Cache, used here primarily to store Tags associated - * with caches created by this backend. Note: If Tags are lost, the cache - * should be completely cleaned as the mapping of tags to caches will - * have been irrevocably lost. - * - * @param Zend_Cache_Core - * @return void - */ - public function setInnerCache(Zend_Cache_Core $cache) - { - $this->_tagCache = $cache; - $this->_options['tag_cache'] = $cache; - } - - /** - * Get the Inner Cache if set - * - * @return Zend_Cache_Core - */ - public function getInnerCache() - { - if (is_null($this->_tagCache)) { - Zend_Cache::throwException('An Inner Cache has not been set; use setInnerCache()'); - } - return $this->_tagCache; - } - - /** - * Verify path exists and is non-empty - * - * @param string $path - * @return bool - */ - protected function _verifyPath($path) - { - $path = realpath($path); - $base = realpath($this->_options['public_dir']); - return strncmp($path, $base, strlen($base)) !== 0; - } - - /** - * Determine the page to save from the request - * - * @return string - */ - protected function _detectId() - { - return $_SERVER['REQUEST_URI']; - } - - /** - * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...) - * - * Throw an exception if a problem is found - * - * @param string $string Cache id or tag - * @throws Zend_Cache_Exception - * @return void - * @deprecated Not usable until perhaps ZF 2.0 - */ - protected static function _validateIdOrTag($string) - { - if (!is_string($string)) { - Zend_Cache::throwException('Invalid id or tag : must be a string'); - } - - // Internal only checked in Frontend - not here! - if (substr($string, 0, 9) == 'internal-') { - return; - } - - // Validation assumes no query string, fragments or scheme included - only the path - if (!preg_match( - '/^(?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*\'()\[\]:@&=+$,;])*)?)+$/', - $string - ) - ) { - Zend_Cache::throwException("Invalid id or tag '$string' : must be a valid URL path"); - } - } - - /** - * Detect an octal string and return its octal value for file permission ops - * otherwise return the non-string (assumed octal or decimal int already) - * - * @param $val The potential octal in need of conversion - * @return int - */ - protected function _octdec($val) - { - if (decoct(octdec($val)) == $val && is_string($val)) { - return octdec($val); - } - return $val; - } - - /** - * Decode a request URI from the provided ID - */ - protected function _decodeId($id) - { - return pack('H*', $id);; - } -} diff --git a/libs/Zend/Cache/Backend/Test.php b/libs/Zend/Cache/Backend/Test.php index f143ab4609..713b48954a 100644 --- a/libs/Zend/Cache/Backend/Test.php +++ b/libs/Zend/Cache/Backend/Test.php @@ -15,29 +15,29 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Test.php 21292 2010-03-02 10:25:22Z mabe $ + * @version $Id: Test.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/ExtendedInterface.php'; +require_once 'Zend/Cache/Backend/Interface.php'; /** * @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface +class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_Backend_Interface { /** * Available options @@ -103,11 +103,7 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B public function load($id, $doNotTestCacheValidity = false) { $this->_addLog('get', array($id, $doNotTestCacheValidity)); - if ( $id == 'false' - || $id == 'd8523b3ee441006261eeffa5c3d3a0a7' - || $id == 'e83249ea22178277d5befc2c5e2e9ace' - || $id == '40f649b94977c0a6e76902e2a0b43587') - { + if ($id=='false') { return false; } if ($id=='serialized') { @@ -140,7 +136,10 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B if ($id=='false') { return false; } - if (($id=='3c439c922209e2cb0b54d6deffccd75a')) { + if (($id=='d8523b3ee441006261eeffa5c3d3a0a7') or ($id=='3c439c922209e2cb0b54d6deffccd75a')) { + return false; + } + if (($id=='40f649b94977c0a6e76902e2a0b43587') or ($id=='e83249ea22178277d5befc2c5e2e9ace')) { return false; } return 123456; @@ -253,145 +252,6 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B } /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - return array( - 'prefix_id1', 'prefix_id2' - ); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - return array( - 'tag1', 'tag2' - ); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - if ($tags == array('tag1', 'tag2')) { - return array('prefix_id1', 'prefix_id2'); - } - - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - if ($tags == array('tag3', 'tag4')) { - return array('prefix_id3', 'prefix_id4'); - } - - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - if ($tags == array('tag5', 'tag6')) { - return array('prefix_id5', 'prefix_id6'); - } - - return array(); - } - - /** - * Return the filling percentage of the backend storage - * - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - return 50; - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - return true; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => true, - 'tags' => true, - 'expired_read' => false, - 'priority' => true, - 'infinite_lifetime' => true, - 'get_list' => true - ); - } - - /** * Add an event to the log array * * @param string $methodName MethodName diff --git a/libs/Zend/Cache/Backend/TwoLevels.php b/libs/Zend/Cache/Backend/TwoLevels.php index a537b739ca..b340645f6c 100644 --- a/libs/Zend/Cache/Backend/TwoLevels.php +++ b/libs/Zend/Cache/Backend/TwoLevels.php @@ -15,27 +15,27 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TwoLevels.php 21954 2010-04-19 19:19:24Z mabe $ + * @version $Id: TwoLevels.php 17741 2009-08-22 02:58:33Z yoshida@zend.co.jp $ */ /** * @see Zend_Cache_Backend_ExtendedInterface */ -// require_once 'Zend/Cache/Backend/ExtendedInterface.php'; +require_once 'Zend/Cache/Backend/ExtendedInterface.php'; /** * @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -95,21 +95,21 @@ class Zend_Cache_Backend_TwoLevels extends Zend_Cache_Backend implements Zend_Ca * * @var Zend_Cache_Backend */ - protected $_slowBackend; + private $_slowBackend; /** * Fast Backend * * @var Zend_Cache_Backend */ - protected $_fastBackend; + private $_fastBackend; /** * Cache for the fast backend filling percentage * * @var int */ - protected $_fastBackendFillingPercentage = null; + private $_fastBackendFillingPercentage = null; /** * Constructor @@ -121,39 +121,20 @@ class Zend_Cache_Backend_TwoLevels extends Zend_Cache_Backend implements Zend_Ca public function __construct(array $options = array()) { parent::__construct($options); - if ($this->_options['slow_backend'] === null) { Zend_Cache::throwException('slow_backend option has to set'); - } elseif ($this->_options['slow_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) { - $this->_slowBackend = $this->_options['slow_backend']; - } else { - $this->_slowBackend = Zend_Cache::_makeBackend( - $this->_options['slow_backend'], - $this->_options['slow_backend_options'], - $this->_options['slow_backend_custom_naming'], - $this->_options['slow_backend_autoload'] - ); - if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) { - Zend_Cache::throwException('slow_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); - } } - if ($this->_options['fast_backend'] === null) { Zend_Cache::throwException('fast_backend option has to set'); - } elseif ($this->_options['fast_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) { - $this->_fastBackend = $this->_options['fast_backend']; - } else { - $this->_fastBackend = Zend_Cache::_makeBackend( - $this->_options['fast_backend'], - $this->_options['fast_backend_options'], - $this->_options['fast_backend_custom_naming'], - $this->_options['fast_backend_autoload'] - ); - if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) { - Zend_Cache::throwException('fast_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); - } } - + $this->_slowBackend = Zend_Cache::_makeBackend($this->_options['slow_backend'], $this->_options['slow_backend_options'], $this->_options['slow_backend_custom_naming'], $this->_options['slow_backend_autoload']); + $this->_fastBackend = Zend_Cache::_makeBackend($this->_options['fast_backend'], $this->_options['fast_backend_options'], $this->_options['fast_backend_custom_naming'], $this->_options['fast_backend_autoload']); + if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) { + Zend_Cache::throwException('slow_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); + } + if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) { + Zend_Cache::throwException('fast_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); + } $this->_slowBackend->setDirectives($this->_directives); $this->_fastBackend->setDirectives($this->_directives); } @@ -196,14 +177,8 @@ class Zend_Cache_Backend_TwoLevels extends Zend_Cache_Backend implements Zend_Ca if (($priority > 0) && (10 * $priority >= $usage)) { $fastLifetime = $this->_getFastLifetime($lifetime, $priority); $boolFast = $this->_fastBackend->save($preparedData, $id, array(), $fastLifetime); - $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime); - } else { - $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime); - if ($boolSlow === true) { - $boolFast = $this->_fastBackend->remove($id); - } } - + $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime); return ($boolFast && $boolSlow); } diff --git a/libs/Zend/Cache/Backend/Xcache.php b/libs/Zend/Cache/Backend/Xcache.php index ccd9672ca6..8f7af5963f 100644 --- a/libs/Zend/Cache/Backend/Xcache.php +++ b/libs/Zend/Cache/Backend/Xcache.php @@ -15,27 +15,27 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Xcache.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Xcache.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/Interface.php'; +require_once 'Zend/Cache/Backend/Interface.php'; /** * @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_Xcache extends Zend_Cache_Backend implements Zend_Cache_Backend_Interface @@ -46,7 +46,7 @@ class Zend_Cache_Backend_Xcache extends Zend_Cache_Backend implements Zend_Cache */ const TAGS_UNSUPPORTED_BY_CLEAN_OF_XCACHE_BACKEND = 'Zend_Cache_Backend_Xcache::clean() : tags are unsupported by the Xcache backend'; const TAGS_UNSUPPORTED_BY_SAVE_OF_XCACHE_BACKEND = 'Zend_Cache_Backend_Xcache::save() : tags are unsupported by the Xcache backend'; - + /** * Available options * diff --git a/libs/Zend/Cache/Backend/ZendPlatform.php b/libs/Zend/Cache/Backend/ZendPlatform.php index 90b7c608c4..71bbdab3e0 100644 --- a/libs/Zend/Cache/Backend/ZendPlatform.php +++ b/libs/Zend/Cache/Backend/ZendPlatform.php @@ -15,20 +15,20 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ZendPlatform.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: ZendPlatform.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/Interface.php'; +require_once 'Zend/Cache/Backend/Interface.php'; /** @@ -36,7 +36,7 @@ * * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_ZendPlatform extends Zend_Cache_Backend implements Zend_Cache_Backend_Interface diff --git a/libs/Zend/Cache/Backend/ZendServer.php b/libs/Zend/Cache/Backend/ZendServer.php index f7a62f6276..55840efa43 100644 --- a/libs/Zend/Cache/Backend/ZendServer.php +++ b/libs/Zend/Cache/Backend/ZendServer.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ZendServer.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: ZendServer.php 17672 2009-08-19 13:05:18Z yoshida@zend.co.jp $ */ /** @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/Interface.php'; +require_once 'Zend/Cache/Backend/Interface.php'; /** @see Zend_Cache_Backend */ -// require_once 'Zend/Cache/Backend.php'; +require_once 'Zend/Cache/Backend.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Cache_Backend_ZendServer extends Zend_Cache_Backend implements Zend_Cache_Backend_Interface diff --git a/libs/Zend/Cache/Backend/ZendServer/Disk.php b/libs/Zend/Cache/Backend/ZendServer/Disk.php index 49c604d005..ba0dd4b366 100644 --- a/libs/Zend/Cache/Backend/ZendServer/Disk.php +++ b/libs/Zend/Cache/Backend/ZendServer/Disk.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Disk.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Disk.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/Interface.php'; +require_once 'Zend/Cache/Backend/Interface.php'; /** @see Zend_Cache_Backend_ZendServer */ -// require_once 'Zend/Cache/Backend/ZendServer.php'; +require_once 'Zend/Cache/Backend/ZendServer.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer implements Zend_Cache_Backend_Interface @@ -50,7 +50,7 @@ class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer i parent::__construct($options); } - /** + /** * Store data * * @param mixed $data Object to store @@ -60,13 +60,13 @@ class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer i */ protected function _store($data, $id, $timeToLive) { - if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id, - $data, - $timeToLive) === false) { + if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id, + $data, + $timeToLive) === false) { $this->_log('Store operation failed.'); return false; - } - return true; + } + return true; } /** @@ -76,7 +76,7 @@ class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer i */ protected function _fetch($id) { - return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id); + return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id); } /** @@ -87,7 +87,7 @@ class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer i */ protected function _unset($id) { - return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id); + return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id); } /** @@ -95,6 +95,6 @@ class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer i */ protected function _clear() { - zend_disk_cache_clear($this->_options['namespace']); + zend_disk_cache_clear($this->_options['namespace']); } } diff --git a/libs/Zend/Cache/Backend/ZendServer/ShMem.php b/libs/Zend/Cache/Backend/ZendServer/ShMem.php index fd08df68bb..8e42eb60f1 100644 --- a/libs/Zend/Cache/Backend/ZendServer/ShMem.php +++ b/libs/Zend/Cache/Backend/ZendServer/ShMem.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ShMem.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: ShMem.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @see Zend_Cache_Backend_Interface */ -// require_once 'Zend/Cache/Backend/Interface.php'; +require_once 'Zend/Cache/Backend/Interface.php'; /** @see Zend_Cache_Backend_ZendServer */ -// require_once 'Zend/Cache/Backend/ZendServer.php'; +require_once 'Zend/Cache/Backend/ZendServer.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Backend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Backend_ZendServer_ShMem extends Zend_Cache_Backend_ZendServer implements Zend_Cache_Backend_Interface diff --git a/libs/Zend/Cache/Core.php b/libs/Zend/Cache/Core.php index 680d4d8028..361fc3e75c 100644 --- a/libs/Zend/Cache/Core.php +++ b/libs/Zend/Cache/Core.php @@ -14,26 +14,20 @@ * * @category Zend * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Core.php 21293 2010-03-02 10:26:32Z mabe $ + * @version $Id: Core.php 18255 2009-09-18 17:26:32Z padraic $ */ /** * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Core { /** - * Messages - */ - const BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend'; - const BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'; - - /** * Backend Object * * @var object $_backend @@ -262,9 +256,6 @@ class Zend_Cache_Core if (!is_string($name) || !array_key_exists($name, $this->_options)) { Zend_Cache::throwException("Incorrect option name : $name"); } - if ($name == 'lifetime' && empty($value)) { - $value = null; - } $this->_options[$name] = $value; } @@ -316,7 +307,7 @@ class Zend_Cache_Core * Test if a cache is available for the given id * * @param string $id Cache id - * @return int|false Last modified time of cache entry if it is available, false otherwise + * @return boolean True is a cache is available, false else */ public function test($id) { @@ -472,26 +463,12 @@ class Zend_Cache_Core public function getIdsMatchingTags($tags = array()) { if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); + Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'); } if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG); + Zend_Cache::throwException('tags are not supported by the current backend'); } - - $ids = $this->_backend->getIdsMatchingTags($tags); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } - } - - return $ids; + return $this->_backend->getIdsMatchingTags($tags); } /** @@ -505,59 +482,12 @@ class Zend_Cache_Core public function getIdsNotMatchingTags($tags = array()) { if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG); - } - - $ids = $this->_backend->getIdsNotMatchingTags($tags); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } - } - - return $ids; - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of matching any cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); + Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'); } if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG); - } - - $ids = $this->_backend->getIdsMatchingAnyTags($tags); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } + Zend_Cache::throwException('tags are not supported by the current backend'); } - - return $ids; + return $this->_backend->getIdsNotMatchingTags($tags); } /** @@ -568,23 +498,20 @@ class Zend_Cache_Core public function getIds() { if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - - $ids = $this->_backend->getIds(); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } - } - - return $ids; + Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'); + } + $array = $this->_backend->getIds(); + if ((!isset($this->_options['cache_id_prefix'])) || ($this->_options['cache_id_prefix'] == '')) return $array; + // we need to remove cache_id_prefix from ids (see #ZF-6178) + $res = array(); + while (list(,$id) = each($array)) { + if (strpos($id, $this->_options['cache_id_prefix']) === 0) { + $res[] = preg_replace("~^{$this->_options['cache_id_prefix']}~", '', $id); + } else { + $res[] = $id; + } + } + return $res; } /** @@ -595,10 +522,10 @@ class Zend_Cache_Core public function getTags() { if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); + Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'); } if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG); + Zend_Cache::throwException('tags are not supported by the current backend'); } return $this->_backend->getTags(); } @@ -611,11 +538,11 @@ class Zend_Cache_Core public function getFillingPercentage() { if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); + Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'); } return $this->_backend->getFillingPercentage(); } - + /** * Return an array of metadatas for the given cache id * @@ -629,8 +556,8 @@ class Zend_Cache_Core */ public function getMetadatas($id) { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); + if (!$this->_extendedBackend) { + Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'); } $id = $this->_id($id); // cache id may need prefix return $this->_backend->getMetadatas($id); @@ -646,7 +573,7 @@ class Zend_Cache_Core public function touch($id, $extraLifetime) { if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); + Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'); } $id = $this->_id($id); // cache id may need prefix return $this->_backend->touch($id, $extraLifetime); @@ -669,7 +596,7 @@ class Zend_Cache_Core if (substr($string, 0, 9) == 'internal-') { Zend_Cache::throwException('"internal-*" ids or tags are reserved'); } - if (!preg_match('~^[a-zA-Z0-9_]+$~D', $string)) { + if (!preg_match('~^[\w]+$~D', $string)) { Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_]"); } } @@ -713,7 +640,7 @@ class Zend_Cache_Core } // Create a default logger to the standard output stream - // require_once 'Zend/Log/Writer/Stream.php'; + require_once 'Zend/Log/Writer/Stream.php'; $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output')); $this->_options['logger'] = $logger; } diff --git a/libs/Zend/Cache/Exception.php b/libs/Zend/Cache/Exception.php index 63a4a28838..1e1e62c4d8 100644 --- a/libs/Zend/Cache/Exception.php +++ b/libs/Zend/Cache/Exception.php @@ -14,19 +14,19 @@ * * @category Zend * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Exception extends Zend_Exception {} diff --git a/libs/Zend/Cache/Frontend/Capture.php b/libs/Zend/Cache/Frontend/Capture.php deleted file mode 100644 index 8536c5ffb5..0000000000 --- a/libs/Zend/Cache/Frontend/Capture.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Cache - * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - -/** - * @see Zend_Cache_Core - */ -// require_once 'Zend/Cache/Core.php'; - - -/** - * @package Zend_Cache - * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Cache_Frontend_Capture extends Zend_Cache_Core -{ - /** - * Page identifiers - * @var array - */ - protected $_idStack = array(); - - /** - * Tags - * @var array - */ - protected $_tags = array(); - - protected $_extension = null; - - /** - * Start the cache - * - * @param string $id Cache id - * @return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas) - */ - public function start($id, array $tags, $extension = null) - { - $this->_tags = $tags; - $this->_extension = $extension; - ob_start(array($this, '_flush')); - ob_implicit_flush(false); - $this->_idStack[] = $id; - return false; - } - - /** - * callback for output buffering - * (shouldn't really be called manually) - * - * @param string $data Buffered output - * @return string Data to send to browser - */ - public function _flush($data) - { - $id = array_pop($this->_idStack); - if (is_null($id)) { - Zend_Cache::throwException('use of _flush() without a start()'); - } - if ($this->_extension) { - $this->save(serialize(array($data, $this->_extension)), $id, $this->_tags); - } else { - $this->save($data, $id, $this->_tags); - } - return $data; - } -} diff --git a/libs/Zend/Cache/Frontend/Class.php b/libs/Zend/Cache/Frontend/Class.php index 3dbdcf666b..6c4ef471b8 100644 --- a/libs/Zend/Cache/Frontend/Class.php +++ b/libs/Zend/Cache/Frontend/Class.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Class.php 20379 2010-01-18 14:40:57Z mabe $ + * @version $Id: Class.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Cache_Core */ -// require_once 'Zend/Cache/Core.php'; +require_once 'Zend/Cache/Core.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Frontend_Class extends Zend_Cache_Core @@ -208,14 +208,14 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core // We do not have not cache return call_user_func_array(array($this->_cachedEntity, $name), $parameters); } - $id = $this->_makeId($name, $parameters); - if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1]) ) { + if ($this->test($id)) { // A cache is available - $output = $rs[0]; - $return = $rs[1]; + $result = $this->load($id); + $output = $result[0]; + $return = $result[1]; } else { - // A cache is not available (or not valid for this frontend) + // A cache is not available ob_start(); ob_implicit_flush(false); $return = call_user_func_array(array($this->_cachedEntity, $name), $parameters); @@ -224,7 +224,6 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core $data = array($output, $return); $this->save($data, $id, $this->_tags, $this->_specificLifetime, $this->_priority); } - echo $output; return $return; } diff --git a/libs/Zend/Cache/Frontend/File.php b/libs/Zend/Cache/Frontend/File.php index 2cbfe74d0c..5e28e015d5 100644 --- a/libs/Zend/Cache/Frontend/File.php +++ b/libs/Zend/Cache/Frontend/File.php @@ -15,66 +15,66 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: File.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: File.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Cache_Core */ -// require_once 'Zend/Cache/Core.php'; +require_once 'Zend/Cache/Core.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Frontend_File extends Zend_Cache_Core { - - /** - * Consts for master_files_mode - */ - const MODE_AND = 'AND'; - const MODE_OR = 'OR'; - + + /** + * Consts for master_files_mode + */ + const MODE_AND = 'AND'; + const MODE_OR = 'OR'; + /** * Available options * * ====> (string) master_file : * - a complete path of the master file * - deprecated (see master_files) - * + * * ====> (array) master_files : * - an array of complete path of master files * - this option has to be set ! - * + * * ====> (string) master_files_mode : * - Zend_Cache_Frontend_File::MODE_AND or Zend_Cache_Frontend_File::MODE_OR * - if MODE_AND, then all master files have to be touched to get a cache invalidation * - if MODE_OR (default), then a single touched master file is enough to get a cache invalidation * * ====> (boolean) ignore_missing_master_files - * - if set to true, missing master files are ignored silently + * - if set to true, missing master files are ignored silently * - if set to false (default), an exception is thrown if there is a missing master file * @var array available options */ protected $_specificOptions = array( - 'master_file' => null, + 'master_file' => null, 'master_files' => null, - 'master_files_mode' => 'OR', - 'ignore_missing_master_files' => false + 'master_files_mode' => 'OR', + 'ignore_missing_master_files' => false ); /** * Master file mtimes * * Array of int - * + * * @var array */ private $_masterFile_mtimes = null; @@ -95,10 +95,10 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core Zend_Cache::throwException('master_files option must be set'); } } - + /** * Change the master_file option - * + * * @param string $masterFile the complete path and name of the master file */ public function setMasterFiles($masterFiles) @@ -109,27 +109,27 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core $this->_masterFile_mtimes = array(); $i = 0; foreach ($masterFiles as $masterFile) { - $this->_masterFile_mtimes[$i] = @filemtime($masterFile); - if ((!($this->_specificOptions['ignore_missing_master_files'])) && (!($this->_masterFile_mtimes[$i]))) { - Zend_Cache::throwException('Unable to read master_file : '.$masterFile); - } - $i++; + $this->_masterFile_mtimes[$i] = @filemtime($masterFile); + if ((!($this->_specificOptions['ignore_missing_master_files'])) && (!($this->_masterFile_mtimes[$i]))) { + Zend_Cache::throwException('Unable to read master_file : '.$masterFile); + } + $i++; } } - + /** * Change the master_file option - * - * To keep the compatibility - * + * + * To keep the compatibility + * * @deprecated * @param string $masterFile the complete path and name of the master file - */ + */ public function setMasterFile($masterFile) { - $this->setMasterFiles(array(0 => $masterFile)); + $this->setMasterFiles(array(0 => $masterFile)); } - + /** * Public frontend to set an option * @@ -145,7 +145,7 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core if ($name == 'master_file') { $this->setMasterFile($value); } else if ($name == 'master_files') { - $this->setMasterFiles($value); + $this->setMasterFiles($value); } else { parent::setOption($name, $value); } @@ -174,33 +174,33 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core * Test if a cache is available for the given id * * @param string $id Cache id - * @return int|false Last modified time of cache entry if it is available, false otherwise + * @return boolean True is a cache is available, false else */ public function test($id) { $lastModified = parent::test($id); if ($lastModified) { - if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) { - // MODE_AND - foreach($this->_masterFile_mtimes as $masterFileMTime) { - if ($masterFileMTime) { - if ($lastModified > $masterFileMTime) { - return $lastModified; - } - } - } - } else { - // MODE_OR - $res = true; - foreach($this->_masterFile_mtimes as $masterFileMTime) { - if ($masterFileMTime) { - if ($lastModified <= $masterFileMTime) { - return false; - } - } - } - return $lastModified; - } + if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) { + // MODE_AND + foreach($this->_masterFile_mtimes as $masterFileMTime) { + if ($masterFileMTime) { + if ($lastModified > $masterFileMTime) { + return $lastModified; + } + } + } + } else { + // MODE_OR + $res = true; + foreach($this->_masterFile_mtimes as $masterFileMTime) { + if ($masterFileMTime) { + if ($lastModified <= $masterFileMTime) { + return false; + } + } + } + return $lastModified; + } } return false; } diff --git a/libs/Zend/Cache/Frontend/Function.php b/libs/Zend/Cache/Frontend/Function.php index 7d7f827fee..03e28931ce 100644 --- a/libs/Zend/Cache/Frontend/Function.php +++ b/libs/Zend/Cache/Frontend/Function.php @@ -15,22 +15,22 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Function.php 20379 2010-01-18 14:40:57Z mabe $ + * @version $Id: Function.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Cache_Core */ -// require_once 'Zend/Cache/Core.php'; +require_once 'Zend/Cache/Core.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Frontend_Function extends Zend_Cache_Core @@ -76,7 +76,7 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core * @param array $parameters Function parameters * @param array $tags Cache tags * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends + * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends * @return mixed Result */ public function call($name, $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8) @@ -89,14 +89,14 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core // We do not have not cache return call_user_func_array($name, $parameters); } - $id = $this->_makeId($name, $parameters); - if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1])) { + if ($this->test($id)) { // A cache is available - $output = $rs[0]; - $return = $rs[1]; + $result = $this->load($id); + $output = $result[0]; + $return = $result[1]; } else { - // A cache is not available (or not valid for this frontend) + // A cache is not available ob_start(); ob_implicit_flush(false); $return = call_user_func_array($name, $parameters); @@ -105,7 +105,6 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core $data = array($output, $return); $this->save($data, $id, $tags, $specificLifetime, $priority); } - echo $output; return $return; } diff --git a/libs/Zend/Cache/Frontend/Output.php b/libs/Zend/Cache/Frontend/Output.php index 1757381ce4..00f200d722 100644 --- a/libs/Zend/Cache/Frontend/Output.php +++ b/libs/Zend/Cache/Frontend/Output.php @@ -15,22 +15,22 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Output.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Output.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Cache_Core */ -// require_once 'Zend/Cache/Core.php'; +require_once 'Zend/Cache/Core.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Frontend_Output extends Zend_Cache_Core diff --git a/libs/Zend/Cache/Frontend/Page.php b/libs/Zend/Cache/Frontend/Page.php index 21ce6537a7..8a6a6f64f4 100644 --- a/libs/Zend/Cache/Frontend/Page.php +++ b/libs/Zend/Cache/Frontend/Page.php @@ -15,22 +15,22 @@ * @category Zend * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Page.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Page.php 16974 2009-07-22 19:23:08Z matthew $ */ /** * @see Zend_Cache_Core */ -// require_once 'Zend/Cache/Core.php'; +require_once 'Zend/Cache/Core.php'; /** * @package Zend_Cache * @subpackage Zend_Cache_Frontend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Cache_Frontend_Page extends Zend_Cache_Core @@ -275,7 +275,7 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core header("$name: $value"); } } - if ($this->_specificOptions['debug_header']) { + if ($this->_specificOptions['debug_header']) { echo 'DEBUG HEADER : This is a cached page !'; } echo $data; @@ -339,9 +339,9 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core { $tmp = $_SERVER['REQUEST_URI']; $array = explode('?', $tmp, 2); - $tmp = $array[0]; + $tmp = $array[0]; foreach (array('Get', 'Post', 'Session', 'Files', 'Cookie') as $arrayName) { - $tmp2 = $this->_makePartialId($arrayName, $this->_activeOptions['cache_with_' . strtolower($arrayName) . '_variables'], $this->_activeOptions['make_id_with_' . strtolower($arrayName) . '_variables']); + $tmp2 = $this->_makePartialId($arrayName, $this->_activeOptions['cache_with_' . strtolower($arrayName) . '_variables'], $this->_activeOptions['make_id_with_' . strtolower($arrayName) . '_variables']); if ($tmp2===false) { return false; } @@ -360,7 +360,7 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core */ protected function _makePartialId($arrayName, $bool1, $bool2) { - switch ($arrayName) { + switch ($arrayName) { case 'Get': $var = $_GET; break; diff --git a/libs/Zend/Cache/Manager.php b/libs/Zend/Cache/Manager.php deleted file mode 100644 index d7f157038c..0000000000 --- a/libs/Zend/Cache/Manager.php +++ /dev/null @@ -1,286 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** @see Zend_Cache_Exception */ -// require_once 'Zend/Cache/Exception.php'; - -/** @see Zend_Cache */ -// require_once 'Zend/Cache.php'; - -/** - * @category Zend - * @package Zend_Cache - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Cache_Manager -{ - /** - * Constant holding reserved name for default Page Cache - */ - const PAGECACHE = 'page'; - - /** - * Constant holding reserved name for default Page Tag Cache - */ - const PAGETAGCACHE = 'pagetag'; - - /** - * Array of caches stored by the Cache Manager instance - * - * @var array - */ - protected $_caches = array(); - - /** - * Array of ready made configuration templates for lazy - * loading caches. - * - * @var array - */ - protected $_optionTemplates = array( - // Null Cache (Enforce Null/Empty Values) - 'skeleton' => array( - 'frontend' => array( - 'name' => null, - 'options' => array(), - ), - 'backend' => array( - 'name' => null, - 'options' => array(), - ), - ), - // Simple Common Default - 'default' => array( - 'frontend' => array( - 'name' => 'Core', - 'options' => array( - 'automatic_serialization' => true, - ), - ), - 'backend' => array( - 'name' => 'File', - 'options' => array( - 'cache_dir' => '../cache', - ), - ), - ), - // Static Page HTML Cache - 'page' => array( - 'frontend' => array( - 'name' => 'Capture', - 'options' => array( - 'ignore_user_abort' => true, - ), - ), - 'backend' => array( - 'name' => 'Static', - 'options' => array( - 'public_dir' => '../public', - ), - ), - ), - // Tag Cache - 'pagetag' => array( - 'frontend' => array( - 'name' => 'Core', - 'options' => array( - 'automatic_serialization' => true, - 'lifetime' => null - ), - ), - 'backend' => array( - 'name' => 'File', - 'options' => array( - 'cache_dir' => '../cache', - 'cache_file_umask' => 0644 - ), - ), - ), - ); - - /** - * Set a new cache for the Cache Manager to contain - * - * @param string $name - * @param Zend_Cache_Core $cache - * @return Zend_Cache_Manager - */ - public function setCache($name, Zend_Cache_Core $cache) - { - $this->_caches[$name] = $cache; - return $this; - } - - /** - * Check if the Cache Manager contains the named cache object, or a named - * configuration template to lazy load the cache object - * - * @param string $name - * @return bool - */ - public function hasCache($name) - { - if (isset($this->_caches[$name]) - || $this->hasCacheTemplate($name) - ) { - return true; - } - return false; - } - - /** - * Fetch the named cache object, or instantiate and return a cache object - * using a named configuration template - * - * @param string $name - * @return Zend_Cache_Core - */ - public function getCache($name) - { - if (isset($this->_caches[$name])) { - return $this->_caches[$name]; - } - if (isset($this->_optionTemplates[$name])) { - if ($name == self::PAGECACHE - && (!isset($this->_optionTemplates[$name]['backend']['options']['tag_cache']) - || !$this->_optionTemplates[$name]['backend']['options']['tag_cache'] instanceof Zend_Cache_Core) - ) { - $this->_optionTemplates[$name]['backend']['options']['tag_cache'] - = $this->getCache(self::PAGETAGCACHE); - } - $this->_caches[$name] = Zend_Cache::factory( - $this->_optionTemplates[$name]['frontend']['name'], - $this->_optionTemplates[$name]['backend']['name'], - isset($this->_optionTemplates[$name]['frontend']['options']) ? $this->_optionTemplates[$name]['frontend']['options'] : array(), - isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array(), - isset($this->_optionTemplates[$name]['frontend']['customFrontendNaming']) ? $this->_optionTemplates[$name]['frontend']['customFrontendNaming'] : false, - isset($this->_optionTemplates[$name]['backend']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['customBackendNaming'] : false, - isset($this->_optionTemplates[$name]['frontendBackendAutoload']) ? $this->_optionTemplates[$name]['frontendBackendAutoload'] : false - ); - return $this->_caches[$name]; - } - } - - /** - * Set a named configuration template from which a cache object can later - * be lazy loaded - * - * @param string $name - * @param array $options - * @return Zend_Cache_Manager - */ - public function setCacheTemplate($name, $options) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (!is_array($options)) { - // require_once 'Zend/Cache/Exception.php'; - throw new Zend_Cache_Exception('Options passed must be in' - . ' an associative array or instance of Zend_Config'); - } - $this->_optionTemplates[$name] = $options; - return $this; - } - - /** - * Check if the named configuration template - * - * @param string $name - * @return bool - */ - public function hasCacheTemplate($name) - { - if (isset($this->_optionTemplates[$name])) { - return true; - } - return false; - } - - /** - * Get the named configuration template - * - * @param string $name - * @return array - */ - public function getCacheTemplate($name) - { - if (isset($this->_optionTemplates[$name])) { - return $this->_optionTemplates[$name]; - } - } - - /** - * Pass an array containing changes to be applied to a named - * configuration - * template - * - * @param string $name - * @param array $options - * @return Zend_Cache_Manager - * @throws Zend_Cache_Exception for invalid options format or if option templates do not have $name - */ - public function setTemplateOptions($name, $options) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (!is_array($options)) { - // require_once 'Zend/Cache/Exception.php'; - throw new Zend_Cache_Exception('Options passed must be in' - . ' an associative array or instance of Zend_Config'); - } - if (!isset($this->_optionTemplates[$name])) { - throw new Zend_Cache_Exception('A cache configuration template' - . 'does not exist with the name "' . $name . '"'); - } - $this->_optionTemplates[$name] - = $this->_mergeOptions($this->_optionTemplates[$name], $options); - return $this; - } - - /** - * Simple method to merge two configuration arrays - * - * @param array $current - * @param array $options - * @return array - */ - protected function _mergeOptions(array $current, array $options) - { - if (isset($options['frontend']['name'])) { - $current['frontend']['name'] = $options['frontend']['name']; - } - if (isset($options['backend']['name'])) { - $current['backend']['name'] = $options['backend']['name']; - } - if (isset($options['frontend']['options'])) { - foreach ($options['frontend']['options'] as $key=>$value) { - $current['frontend']['options'][$key] = $value; - } - } - if (isset($options['backend']['options'])) { - foreach ($options['backend']['options'] as $key=>$value) { - $current['backend']['options'][$key] = $value; - } - } - return $current; - } -} diff --git a/libs/Zend/Config.php b/libs/Zend/Config.php index 0ba76392f4..0652e9901f 100644 --- a/libs/Zend/Config.php +++ b/libs/Zend/Config.php @@ -14,16 +14,16 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Config.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Config.php 16201 2009-06-21 18:51:15Z thomas $ */ /** * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Config implements Countable, Iterator @@ -83,7 +83,7 @@ class Zend_Config implements Countable, Iterator /** * Load file error string. - * + * * Is null if there was no error while file loading * * @var string @@ -165,15 +165,15 @@ class Zend_Config implements Countable, Iterator $this->_count = count($this->_data); } else { /** @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('Zend_Config is read only'); } } - + /** * Deep clone of this instance to ensure that nested Zend_Configs * are also cloned. - * + * * @return void */ public function __clone() @@ -234,7 +234,7 @@ class Zend_Config implements Countable, Iterator $this->_skipNextIteration = true; } else { /** @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('Zend_Config is read only'); } @@ -374,7 +374,7 @@ class Zend_Config implements Countable, Iterator } } } - + /** * Returns if this Zend_Config object is read only or not. * @@ -384,7 +384,7 @@ class Zend_Config implements Countable, Iterator { return !$this->_allowModifications; } - + /** * Get the current extends * @@ -394,7 +394,7 @@ class Zend_Config implements Countable, Iterator { return $this->_extends; } - + /** * Set an extend for Zend_Config_Writer * @@ -410,7 +410,7 @@ class Zend_Config implements Countable, Iterator $this->_extends[$extendingSection] = $extendedSection; } } - + /** * Throws an exception if $extendingSection may not extend $extendedSection, * and tracks the section extension if it is valid. @@ -427,7 +427,7 @@ class Zend_Config implements Countable, Iterator while (array_key_exists($extendedSectionCurrent, $this->_extends)) { if ($this->_extends[$extendedSectionCurrent] == $extendingSection) { /** @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('Illegal circular inheritance detected'); } $extendedSectionCurrent = $this->_extends[$extendedSectionCurrent]; @@ -445,7 +445,7 @@ class Zend_Config implements Countable, Iterator * @param integer $errline */ protected function _loadFileErrorHandler($errno, $errstr, $errfile, $errline) - { + { if ($this->_loadFileErrorStr === null) { $this->_loadFileErrorStr = $errstr; } else { @@ -453,32 +453,4 @@ class Zend_Config implements Countable, Iterator } } - /** - * Merge two arrays recursively, overwriting keys of the same name - * in $firstArray with the value in $secondArray. - * - * @param mixed $firstArray First array - * @param mixed $secondArray Second array to merge into first array - * @return array - */ - protected function _arrayMergeRecursive($firstArray, $secondArray) - { - if (is_array($firstArray) && is_array($secondArray)) { - foreach ($secondArray as $key => $value) { - if (isset($firstArray[$key])) { - $firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key], $value); - } else { - if($key === 0) { - $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray, $value)); - } else { - $firstArray[$key] = $value; - } - } - } - } else { - $firstArray = $secondArray; - } - - return $firstArray; - } -}
\ No newline at end of file +} diff --git a/libs/Zend/Config/Exception.php b/libs/Zend/Config/Exception.php index 8ef700783c..859d3bf71c 100644 --- a/libs/Zend/Config/Exception.php +++ b/libs/Zend/Config/Exception.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Config_Exception extends Zend_Exception {} diff --git a/libs/Zend/Config/Ini.php b/libs/Zend/Config/Ini.php index 63cab0f9a4..efb6862713 100644 --- a/libs/Zend/Config/Ini.php +++ b/libs/Zend/Config/Ini.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ini.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Ini.php 16201 2009-06-21 18:51:15Z thomas $ */ /** * @see Zend_Config */ -// require_once 'Zend/Config.php'; +require_once 'Zend/Config.php'; /** * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Config_Ini extends Zend_Config @@ -49,12 +49,12 @@ class Zend_Config_Ini extends Zend_Config protected $_sectionSeparator = ':'; /** - * Whether to skip extends or not + * Wether to skip extends or not * * @var boolean */ protected $_skipExtends = false; - + /** * Loads the section $section from the config file $filename for * access facilitated by nested object properties. @@ -103,7 +103,7 @@ class Zend_Config_Ini extends Zend_Config /** * @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('Filename is not set'); } @@ -129,7 +129,7 @@ class Zend_Config_Ini extends Zend_Config $dataArray = array(); foreach ($iniArray as $sectionName => $sectionData) { if(!is_array($sectionData)) { - $dataArray = $this->_arrayMergeRecursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData)); + $dataArray = array_merge_recursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData)); } else { $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName); } @@ -146,59 +146,44 @@ class Zend_Config_Ini extends Zend_Config /** * @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $filename"); } - $dataArray = $this->_arrayMergeRecursive($this->_processSection($iniArray, $sectionName), $dataArray); + $dataArray = array_merge($this->_processSection($iniArray, $sectionName), $dataArray); } parent::__construct($dataArray, $allowModifications); - } + } $this->_loadedSection = $section; } - + /** - * Load the INI file from disk using parse_ini_file(). Use a private error - * handler to convert any loading errors into a Zend_Config_Exception - * + * Load the ini file and preprocess the section separator (':' in the + * section name (that is used for section extension) so that the resultant + * array has the correct section names and the extension information is + * stored in a sub-key called ';extends'. We use ';extends' as this can + * never be a valid key name in an INI file that has been loaded using + * parse_ini_file(). + * * @param string $filename * @throws Zend_Config_Exception * @return array */ - protected function _parseIniFile($filename) + protected function _loadIniFile($filename) { set_error_handler(array($this, '_loadFileErrorHandler')); - $iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed + $loaded = parse_ini_file($filename, true); // Warnings and errors are suppressed restore_error_handler(); - // Check if there was a error while loading file if ($this->_loadFileErrorStr !== null) { /** * @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception($this->_loadFileErrorStr); } - - return $iniArray; - } - /** - * Load the ini file and preprocess the section separator (':' in the - * section name (that is used for section extension) so that the resultant - * array has the correct section names and the extension information is - * stored in a sub-key called ';extends'. We use ';extends' as this can - * never be a valid key name in an INI file that has been loaded using - * parse_ini_file(). - * - * @param string $filename - * @throws Zend_Config_Exception - * @return array - */ - protected function _loadIniFile($filename) - { - $loaded = $this->_parseIniFile($filename); $iniArray = array(); foreach ($loaded as $key => $data) { @@ -218,14 +203,14 @@ class Zend_Config_Ini extends Zend_Config /** * @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections in $filename"); } } return $iniArray; } - + /** * Process each element in the section and handle the ";extends" inheritance * key. Passes control to _processKey() to handle the nest separator @@ -245,7 +230,7 @@ class Zend_Config_Ini extends Zend_Config if (strtolower($key) == ';extends') { if (isset($iniArray[$value])) { $this->_assertValidExtend($section, $value); - + if (!$this->_skipExtends) { $config = $this->_processSection($iniArray, $value, $config); } @@ -253,7 +238,7 @@ class Zend_Config_Ini extends Zend_Config /** * @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Parent section '$section' cannot be found"); } } else { @@ -289,7 +274,7 @@ class Zend_Config_Ini extends Zend_Config /** * @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists"); } $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value); @@ -297,7 +282,7 @@ class Zend_Config_Ini extends Zend_Config /** * @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Invalid key '$key'"); } } else { diff --git a/libs/Zend/Config/Writer.php b/libs/Zend/Config/Writer.php index 9bfedca748..56bb66bfd1 100644 --- a/libs/Zend/Config/Writer.php +++ b/libs/Zend/Config/Writer.php @@ -14,28 +14,28 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Writer.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Writer.php 16201 2009-06-21 18:51:15Z thomas $ */ /** * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Config_Writer { /** * Option keys to skip when calling setOptions() - * + * * @var array */ protected $_skipOptions = array( 'options' ); - + /** * Config object to write * @@ -45,8 +45,8 @@ abstract class Zend_Config_Writer /** * Create a new adapter - * - * $options can only be passed as array or be omitted + * + * $options can only be passed as array or be omitted * * @param null|array $options */ @@ -56,7 +56,7 @@ abstract class Zend_Config_Writer $this->setOptions($options); } } - + /** * Set options via a Zend_Config instance * @@ -66,10 +66,10 @@ abstract class Zend_Config_Writer public function setConfig(Zend_Config $config) { $this->_config = $config; - + return $this; } - + /** * Set options via an array * @@ -88,10 +88,10 @@ abstract class Zend_Config_Writer $this->$method($value); } } - + return $this; } - + /** * Write a Zend_Config object to it's target * diff --git a/libs/Zend/Config/Writer/Array.php b/libs/Zend/Config/Writer/Array.php index 6e9b158997..dd880b010b 100644 --- a/libs/Zend/Config/Writer/Array.php +++ b/libs/Zend/Config/Writer/Array.php @@ -14,42 +14,119 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Array.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Array.php 16201 2009-06-21 18:51:15Z thomas $ */ /** * @see Zend_Config_Writer */ -// require_once 'Zend/Config/Writer/FileAbstract.php'; +require_once 'Zend/Config/Writer.php'; /** * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Config_Writer_Array extends Zend_Config_Writer_FileAbstract +class Zend_Config_Writer_Array extends Zend_Config_Writer { /** - * Render a Zend_Config into a PHP Array config string. + * Filename to write to * - * @since 1.10 - * @return string + * @var string */ - public function render() + protected $_filename = null; + + /** + * Wether to exclusively lock the file or not + * + * @var boolean + */ + protected $_exclusiveLock = false; + + /** + * Set the target filename + * + * @param string $filename + * @return Zend_Config_Writer_Array + */ + public function setFilename($filename) + { + $this->_filename = $filename; + + return $this; + } + + /** + * Set wether to exclusively lock the file or not + * + * @param boolean $exclusiveLock + * @return Zend_Config_Writer_Array + */ + public function setExclusiveLock($exclusiveLock) + { + $this->_exclusiveLock = $exclusiveLock; + + return $this; + } + + /** + * Defined by Zend_Config_Writer + * + * @param string $filename + * @param Zend_Config $config + * @param boolean $exclusiveLock + * @throws Zend_Config_Exception When filename was not set + * @throws Zend_Config_Exception When filename is not writable + * @return void + */ + public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null) { + if ($filename !== null) { + $this->setFilename($filename); + } + + if ($config !== null) { + $this->setConfig($config); + } + + if ($exclusiveLock !== null) { + $this->setExclusiveLock($exclusiveLock); + } + + if ($this->_filename === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No filename was set'); + } + + if ($this->_config === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No config was set'); + } + $data = $this->_config->toArray(); $sectionName = $this->_config->getSectionName(); - + if (is_string($sectionName)) { $data = array($sectionName => $data); } - + $arrayString = "<?php\n" . "return " . var_export($data, true) . ";\n"; - - return $arrayString; + + $flags = 0; + + if ($this->_exclusiveLock) { + $flags |= LOCK_EX; + } + + $result = @file_put_contents($this->_filename, $arrayString, $flags); + + if ($result === false) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"'); + } } } diff --git a/libs/Zend/Config/Writer/FileAbstract.php b/libs/Zend/Config/Writer/FileAbstract.php deleted file mode 100644 index ee14b772fa..0000000000 --- a/libs/Zend/Config/Writer/FileAbstract.php +++ /dev/null @@ -1,134 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Config - * @package Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// require_once "Zend/Config/Writer.php"; - -/** - * Abstract File Writer - * - * @category Zend - * @package Zend_package - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FileAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ -class Zend_Config_Writer_FileAbstract extends Zend_Config_Writer -{ - /** - * Filename to write to - * - * @var string - */ - protected $_filename = null; - - /** - * Wether to exclusively lock the file or not - * - * @var boolean - */ - protected $_exclusiveLock = false; - - /** - * Set the target filename - * - * @param string $filename - * @return Zend_Config_Writer_Array - */ - public function setFilename($filename) - { - $this->_filename = $filename; - - return $this; - } - - /** - * Set wether to exclusively lock the file or not - * - * @param boolean $exclusiveLock - * @return Zend_Config_Writer_Array - */ - public function setExclusiveLock($exclusiveLock) - { - $this->_exclusiveLock = $exclusiveLock; - - return $this; - } - - /** - * Write configuration to file. - * - * @param string $filename - * @param Zend_Config $config - * @param bool $exclusiveLock - * @return void - */ - public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null) - { - if ($filename !== null) { - $this->setFilename($filename); - } - - if ($config !== null) { - $this->setConfig($config); - } - - if ($exclusiveLock !== null) { - $this->setExclusiveLock($exclusiveLock); - } - - if ($this->_filename === null) { - // require_once 'Zend/Config/Exception.php'; - throw new Zend_Config_Exception('No filename was set'); - } - - if ($this->_config === null) { - // require_once 'Zend/Config/Exception.php'; - throw new Zend_Config_Exception('No config was set'); - } - - $configString = $this->render(); - - $flags = 0; - - if ($this->_exclusiveLock) { - $flags |= LOCK_EX; - } - - $result = @file_put_contents($this->_filename, $configString, $flags); - - if ($result === false) { - // require_once 'Zend/Config/Exception.php'; - throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"'); - } - } - - /** - * Render a Zend_Config into a config file string. - * - * @since 1.10 - * @todo For 2.0 this should be redone into an abstract method. - * @return string - */ - public function render() - { - return ""; - } -}
\ No newline at end of file diff --git a/libs/Zend/Config/Writer/Ini.php b/libs/Zend/Config/Writer/Ini.php index 163c95e216..ea65ca87c3 100644 --- a/libs/Zend/Config/Writer/Ini.php +++ b/libs/Zend/Config/Writer/Ini.php @@ -14,81 +14,123 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ini.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Ini.php 16201 2009-06-21 18:51:15Z thomas $ */ /** * @see Zend_Config_Writer */ -// require_once 'Zend/Config/Writer/FileAbstract.php'; +require_once 'Zend/Config/Writer.php'; /** * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract +class Zend_Config_Writer_Ini extends Zend_Config_Writer { /** - * String that separates nesting levels of configuration data identifiers + * Filename to write to * * @var string */ - protected $_nestSeparator = '.'; - + protected $_filename = null; + /** - * If true the ini string is rendered in the global namespace without sections. + * Wether to exclusively lock the file or not * - * @var bool + * @var boolean */ - protected $_renderWithoutSections = false; - + protected $_exclusiveLock = false; + /** - * Set the nest separator + * String that separates nesting levels of configuration data identifiers + * + * @var string + */ + protected $_nestSeparator = '.'; + + /** + * Set the target filename * * @param string $filename - * @return Zend_Config_Writer_Ini + * @return Zend_Config_Writer_Xml */ - public function setNestSeparator($separator) + public function setFilename($filename) { - $this->_nestSeparator = $separator; - + $this->_filename = $filename; + return $this; } - + /** - * Set if rendering should occour without sections or not. + * Set wether to exclusively lock the file or not * - * If set to true, the INI file is rendered without sections completely - * into the global namespace of the INI file. + * @param boolean $exclusiveLock + * @return Zend_Config_Writer_Array + */ + public function setExclusiveLock($exclusiveLock) + { + $this->_exclusiveLock = $exclusiveLock; + + return $this; + } + + /** + * Set the nest separator * - * @param bool $withoutSections + * @param string $filename * @return Zend_Config_Writer_Ini */ - public function setRenderWithoutSections($withoutSections=true) + public function setNestSeparator($separator) { - $this->_renderWithoutSections = (bool)$withoutSections; + $this->_nestSeparator = $separator; + return $this; } - + /** - * Render a Zend_Config into a INI config string. + * Defined by Zend_Config_Writer * - * @since 1.10 - * @return string + * @param string $filename + * @param Zend_Config $config + * @param boolean $exclusiveLock + * @throws Zend_Config_Exception When filename was not set + * @throws Zend_Config_Exception When filename is not writable + * @return void */ - public function render() + public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null) { + if ($filename !== null) { + $this->setFilename($filename); + } + + if ($config !== null) { + $this->setConfig($config); + } + + if ($exclusiveLock !== null) { + $this->setExclusiveLock($exclusiveLock); + } + + if ($this->_filename === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No filename was set'); + } + + if ($this->_config === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No config was set'); + } + $iniString = ''; $extends = $this->_config->getExtends(); $sectionName = $this->_config->getSectionName(); - - if($this->_renderWithoutSections == true) { - $iniString .= $this->_addBranch($this->_config); - } else if (is_string($sectionName)) { + + if (is_string($sectionName)) { $iniString .= '[' . $sectionName . ']' . "\n" . $this->_addBranch($this->_config) . "\n"; @@ -103,17 +145,28 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract if (isset($extends[$sectionName])) { $sectionName .= ' : ' . $extends[$sectionName]; } - + $iniString .= '[' . $sectionName . ']' . "\n" . $this->_addBranch($data) . "\n"; } } } + + $flags = 0; + + if ($this->_exclusiveLock) { + $flags |= LOCK_EX; + } + + $result = @file_put_contents($this->_filename, $iniString, $flags); - return $iniString; + if ($result === false) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"'); + } } - + /** * Add a branch to an INI string recursively * @@ -126,7 +179,7 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract foreach ($config as $key => $value) { $group = array_merge($parents, array($key)); - + if ($value instanceof Zend_Config) { $iniString .= $this->_addBranch($value, $group); } else { @@ -136,10 +189,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract . "\n"; } } - + return $iniString; } - + /** * Prepare a value for INI * @@ -152,12 +205,8 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract return $value; } elseif (is_bool($value)) { return ($value ? 'true' : 'false'); - } elseif (strpos($value, '"') === false) { - return '"' . $value . '"'; } else { - /** @see Zend_Config_Exception */ - // require_once 'Zend/Config/Exception.php'; - throw new Zend_Config_Exception('Value can not contain double quotes "'); + return '"' . addslashes($value) . '"'; } } } diff --git a/libs/Zend/Config/Writer/Xml.php b/libs/Zend/Config/Writer/Xml.php index 7b779d63af..764b461ded 100644 --- a/libs/Zend/Config/Writer/Xml.php +++ b/libs/Zend/Config/Writer/Xml.php @@ -14,41 +14,107 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Xml.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Xml.php 16924 2009-07-21 16:34:04Z dasprid $ */ /** * @see Zend_Config_Writer */ -// require_once 'Zend/Config/Writer/FileAbstract.php'; +require_once 'Zend/Config/Writer.php'; /** * @see Zend_Config_Xml */ -// require_once 'Zend/Config/Xml.php'; +require_once 'Zend/Config/Xml.php'; /** * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Config_Writer_Xml extends Zend_Config_Writer_FileAbstract +class Zend_Config_Writer_Xml extends Zend_Config_Writer { /** - * Render a Zend_Config into a XML config string. + * Filename to write to * - * @since 1.10 - * @return string + * @var string */ - public function render() + protected $_filename = null; + + /** + * Wether to exclusively lock the file or not + * + * @var boolean + */ + protected $_exclusiveLock = false; + + /** + * Set the target filename + * + * @param string $filename + * @return Zend_Config_Writer_Xml + */ + public function setFilename($filename) + { + $this->_filename = $filename; + + return $this; + } + + /** + * Set wether to exclusively lock the file or not + * + * @param boolean $exclusiveLock + * @return Zend_Config_Writer_Array + */ + public function setExclusiveLock($exclusiveLock) { + $this->_exclusiveLock = $exclusiveLock; + + return $this; + } + + /** + * Defined by Zend_Config_Writer + * + * @param string $filename + * @param Zend_Config $config + * @param boolean $exclusiveLock + * @throws Zend_Config_Exception When filename was not set + * @throws Zend_Config_Exception When filename is not writable + * @return void + */ + public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null) + { + if ($filename !== null) { + $this->setFilename($filename); + } + + if ($config !== null) { + $this->setConfig($config); + } + + if ($exclusiveLock !== null) { + $this->setExclusiveLock($exclusiveLock); + } + + if ($this->_filename === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No filename was set'); + } + + if ($this->_config === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No config was set'); + } + $xml = new SimpleXMLElement('<zend-config xmlns:zf="' . Zend_Config_Xml::XML_NAMESPACE . '"/>'); $extends = $this->_config->getExtends(); $sectionName = $this->_config->getSectionName(); - + if (is_string($sectionName)) { $child = $xml->addChild($sectionName); @@ -59,24 +125,35 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer_FileAbstract $xml->addChild($sectionName, (string) $data); } else { $child = $xml->addChild($sectionName); - + if (isset($extends[$sectionName])) { $child->addAttribute('zf:extends', $extends[$sectionName], Zend_Config_Xml::XML_NAMESPACE); } - + $this->_addBranch($data, $child, $xml); } } } - + $dom = dom_import_simplexml($xml)->ownerDocument; $dom->formatOutput = true; - + $xmlString = $dom->saveXML(); - - return $xmlString; + + $flags = 0; + + if ($this->_exclusiveLock) { + $flags |= LOCK_EX; + } + + $result = @file_put_contents($this->_filename, $xmlString, $flags); + + if ($result === false) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"'); + } } - + /** * Add a branch to an XML object recursively * @@ -88,35 +165,35 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer_FileAbstract protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent) { $branchType = null; - + foreach ($config as $key => $value) { if ($branchType === null) { if (is_numeric($key)) { $branchType = 'numeric'; $branchName = $xml->getName(); $xml = $parent; - + unset($parent->{$branchName}); } else { $branchType = 'string'; } } else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) { - // require_once 'Zend/Config/Exception.php'; - throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed'); + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed'); } - + if ($branchType === 'numeric') { if ($value instanceof Zend_Config) { - $child = $parent->addChild($branchName); - + $child = $parent->addChild($branchName, (string) $value); + $this->_addBranch($value, $child, $parent); } else { $parent->addChild($branchName, (string) $value); } - } else { + } else { if ($value instanceof Zend_Config) { $child = $xml->addChild($key); - + $this->_addBranch($value, $child, $xml); } else { $xml->addChild($key, (string) $value); diff --git a/libs/Zend/Config/Xml.php b/libs/Zend/Config/Xml.php index 698247cec8..e68bfd3b32 100644 --- a/libs/Zend/Config/Xml.php +++ b/libs/Zend/Config/Xml.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Xml.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Xml.php 17267 2009-07-29 02:13:18Z yoshida@zend.co.jp $ */ /** * @see Zend_Config */ -// require_once 'Zend/Config.php'; +require_once 'Zend/Config.php'; /** * XML Adapter for Zend_Config * * @category Zend * @package Zend_Config - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Config_Xml extends Zend_Config @@ -40,7 +40,7 @@ class Zend_Config_Xml extends Zend_Config const XML_NAMESPACE = 'http://framework.zend.com/xml/zend-config-xml/1.0/'; /** - * Whether to skip extends or not + * Wether to skip extends or not * * @var boolean */ @@ -61,14 +61,14 @@ class Zend_Config_Xml extends Zend_Config * * @param string $xml XML file or string to process * @param mixed $section Section to process - * @param boolean $options Whether modifications are allowed at runtime + * @param boolean $options Whether modifiacations are allowed at runtime * @throws Zend_Config_Exception When xml is not set or cannot be loaded * @throws Zend_Config_Exception When section $sectionName cannot be found in $xml */ public function __construct($xml, $section = null, $options = false) { if (empty($xml)) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('Filename is not set'); } @@ -94,7 +94,7 @@ class Zend_Config_Xml extends Zend_Config restore_error_handler(); // Check if there was a error while loading file if ($this->_loadFileErrorStr !== null) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception($this->_loadFileErrorStr); } @@ -109,7 +109,7 @@ class Zend_Config_Xml extends Zend_Config $dataArray = array(); foreach ($section as $sectionName) { if (!isset($config->$sectionName)) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $xml"); } @@ -119,7 +119,7 @@ class Zend_Config_Xml extends Zend_Config parent::__construct($dataArray, $allowModifications); } else { if (!isset($config->$section)) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Section '$section' cannot be found in $xml"); } @@ -148,7 +148,7 @@ class Zend_Config_Xml extends Zend_Config protected function _processExtends(SimpleXMLElement $element, $section, array $config = array()) { if (!isset($element->$section)) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Section '$section' cannot be found"); } @@ -205,7 +205,7 @@ class Zend_Config_Xml extends Zend_Config // Search for local 'const' nodes and replace them if (count($xmlObject->children(self::XML_NAMESPACE)) > 0) { if (count($xmlObject->children()) > 0) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("A node with a 'const' childnode may not have any other children"); } @@ -224,14 +224,14 @@ class Zend_Config_Xml extends Zend_Config switch ($node->localName) { case 'const': if (!$node->hasAttributeNS(self::XML_NAMESPACE, 'name')) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Misssing 'name' attribute in 'const' node"); } $constantName = $node->getAttributeNS(self::XML_NAMESPACE, 'name'); if (!defined($constantName)) { - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Constant with name '$constantName' was not defined"); } @@ -241,7 +241,7 @@ class Zend_Config_Xml extends Zend_Config break; default: - // require_once 'Zend/Config/Exception.php'; + require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Unknown node with name '$node->localName' found"); } } @@ -283,4 +283,33 @@ class Zend_Config_Xml extends Zend_Config return $config; } + + /** + * Merge two arrays recursively, overwriting keys of the same name + * in $firstArray with the value in $secondArray. + * + * @param mixed $firstArray First array + * @param mixed $secondArray Second array to merge into first array + * @return array + */ + protected function _arrayMergeRecursive($firstArray, $secondArray) + { + if (is_array($firstArray) && is_array($secondArray)) { + foreach ($secondArray as $key => $value) { + if (isset($firstArray[$key])) { + $firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key], $value); + } else { + if($key === 0) { + $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray, $value)); + } else { + $firstArray[$key] = $value; + } + } + } + } else { + $firstArray = $secondArray; + } + + return $firstArray; + } } diff --git a/libs/Zend/Db.php b/libs/Zend/Db.php index 9bbf1e793f..b62bcdbbee 100644 --- a/libs/Zend/Db.php +++ b/libs/Zend/Db.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Db - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Db.php 18373 2009-09-22 19:16:25Z ralph $ */ @@ -26,7 +26,7 @@ * * @category Zend * @package Zend_Db - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db @@ -219,7 +219,7 @@ class Zend_Db /** * @see Zend_Db_Exception */ - // require_once 'Zend/Db/Exception.php'; + require_once 'Zend/Db/Exception.php'; throw new Zend_Db_Exception('Adapter parameters must be in an array or a Zend_Config object'); } @@ -230,7 +230,7 @@ class Zend_Db /** * @see Zend_Db_Exception */ - // require_once 'Zend/Db/Exception.php'; + require_once 'Zend/Db/Exception.php'; throw new Zend_Db_Exception('Adapter name must be specified in a string'); } @@ -253,10 +253,10 @@ class Zend_Db * Load the adapter class. This throws an exception * if the specified class cannot be loaded. */ - // if (!class_exists($adapterName)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($adapterName); - // } + if (!class_exists($adapterName)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($adapterName); + } /* * Create an instance of the adapter class. @@ -271,7 +271,7 @@ class Zend_Db /** * @see Zend_Db_Exception */ - // require_once 'Zend/Db/Exception.php'; + require_once 'Zend/Db/Exception.php'; throw new Zend_Db_Exception("Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract"); } diff --git a/libs/Zend/Db/Adapter/Abstract.php b/libs/Zend/Db/Adapter/Abstract.php index 09ab9e692d..bd00da96f4 100644 --- a/libs/Zend/Db/Adapter/Abstract.php +++ b/libs/Zend/Db/Adapter/Abstract.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 18633 2009-10-17 05:36:58Z ralph $ */ /** * @see Zend_Db */ -// require_once 'Zend/Db.php'; +require_once 'Zend/Db.php'; /** * @see Zend_Db_Select */ -// require_once 'Zend/Db/Select.php'; +require_once 'Zend/Db/Select.php'; /** * Class for connecting to SQL databases and performing common operations. @@ -37,7 +37,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Db_Adapter_Abstract @@ -175,7 +175,7 @@ abstract class Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception('Adapter parameters must be in an array or a Zend_Config object'); } } @@ -230,7 +230,7 @@ abstract class Zend_Db_Adapter_Abstract break; default: /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception('Case must be one of the following constants: ' . 'Zend_Db::CASE_NATURAL, Zend_Db::CASE_LOWER, Zend_Db::CASE_UPPER'); } @@ -272,7 +272,7 @@ abstract class Zend_Db_Adapter_Abstract // we need at least a dbname if (! array_key_exists('dbname', $config)) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance"); } @@ -280,7 +280,7 @@ abstract class Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials"); } @@ -288,7 +288,7 @@ abstract class Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials"); } } @@ -358,7 +358,7 @@ abstract class Zend_Db_Adapter_Abstract /** * @see Zend_Db_Profiler_Exception */ - // require_once 'Zend/Db/Profiler/Exception.php'; + require_once 'Zend/Db/Profiler/Exception.php'; throw new Zend_Db_Profiler_Exception('Profiler argument must be an instance of either Zend_Db_Profiler' . ' or Zend_Config when provided as an object'); } @@ -379,16 +379,16 @@ abstract class Zend_Db_Adapter_Abstract } if ($profilerInstance === null) { - // if (!class_exists($profilerClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($profilerClass); - // } + if (!class_exists($profilerClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($profilerClass); + } $profilerInstance = new $profilerClass(); } if (!$profilerInstance instanceof Zend_Db_Profiler) { /** @see Zend_Db_Profiler_Exception */ - // require_once 'Zend/Db/Profiler/Exception.php'; + require_once 'Zend/Db/Profiler/Exception.php'; throw new Zend_Db_Profiler_Exception('Class ' . get_class($profilerInstance) . ' does not extend ' . 'Zend_Db_Profiler'); } @@ -579,7 +579,7 @@ abstract class Zend_Db_Adapter_Abstract $i++; } else { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding"); } } @@ -902,7 +902,7 @@ abstract class Zend_Db_Adapter_Abstract return str_replace('?', $this->quote($value, $type), $text); } else { while ($count > 0) { - if (strpos($text, '?') !== false) { + if (strpos($text, '?') != false) { $text = substr_replace($text, $this->quote($value, $type), strpos($text, '?'), 1); } --$count; @@ -1097,7 +1097,7 @@ abstract class Zend_Db_Adapter_Abstract { if ($this->_allowSerialization == false) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception(get_class($this) ." is not allowed to be serialized"); } $this->_connection = false; diff --git a/libs/Zend/Db/Adapter/Db2.php b/libs/Zend/Db/Adapter/Db2.php index bde2100793..9d9e9849f3 100644 --- a/libs/Zend/Db/Adapter/Db2.php +++ b/libs/Zend/Db/Adapter/Db2.php @@ -15,31 +15,31 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db2.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Db2.php 16541 2009-07-07 06:59:03Z bkarwin $ * */ /** * @see Zend_Db */ -// require_once 'Zend/Db.php'; +require_once 'Zend/Db.php'; /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Statement_Db2 */ -// require_once 'Zend/Db/Statement/Db2.php'; +require_once 'Zend/Db/Statement/Db2.php'; /** * @package Zend_Db - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -127,7 +127,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but the extension is not loaded'); } @@ -184,7 +184,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error()); } } @@ -223,10 +223,10 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract { $this->_connect(); $stmtClass = $this->_defaultStmtClass; - // if (!class_exists($stmtClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($stmtClass); - // } + if (!class_exists($stmtClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($stmtClass); + } $stmt = new $stmtClass($this, $sql); $stmt->setFetchMode($this->_fetchMode); return $stmt; @@ -258,7 +258,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("execution mode not supported"); break; } @@ -373,7 +373,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract if ($schemaName === null && $this->_config['schema'] != null) { $schemaName = $this->_config['schema']; } - + if (!$this->_isI5) { $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno, @@ -402,14 +402,14 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract $sql = "SELECT DISTINCT C.TABLE_SCHEMA, C.TABLE_NAME, C.COLUMN_NAME, C.ORDINAL_POSITION, C.DATA_TYPE, C.COLUMN_DEFAULT, C.NULLS ,C.LENGTH, C.SCALE, LEFT(C.IDENTITY,1), LEFT(tc.TYPE, 1) AS tabconsttype, k.COLSEQ - FROM QSYS2.SYSCOLUMNS C + FROM QSYS2.SYSCOLUMNS C LEFT JOIN (QSYS2.syskeycst k JOIN QSYS2.SYSCST tc ON (k.TABLE_SCHEMA = tc.TABLE_SCHEMA AND k.TABLE_NAME = tc.TABLE_NAME - AND LEFT(tc.type,1) = 'P')) + AND LEFT(tc.type,1) = 'P')) ON (C.TABLE_SCHEMA = k.TABLE_SCHEMA AND C.TABLE_NAME = k.TABLE_NAME - AND C.COLUMN_NAME = k.COLUMN_NAME) + AND C.COLUMN_NAME = k.COLUMN_NAME) WHERE " . $this->quoteInto('UPPER(C.TABLE_NAME) = UPPER(?)', $tableName); @@ -583,7 +583,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception( db2_conn_errormsg($this->_connection), db2_conn_error($this->_connection)); @@ -603,7 +603,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception( db2_conn_errormsg($this->_connection), db2_conn_error($this->_connection)); @@ -631,14 +631,14 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception('FETCH_BOUND is not supported yet'); break; default: /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("Invalid fetch mode '$mode' specified"); break; } @@ -659,7 +659,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument count=$count is not valid"); } @@ -668,7 +668,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Db2_Exception */ - // require_once 'Zend/Db/Adapter/Db2/Exception.php'; + require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument offset=$offset is not valid"); } diff --git a/libs/Zend/Db/Adapter/Db2/Exception.php b/libs/Zend/Db/Adapter/Db2/Exception.php index 8104606d59..621274745d 100644 --- a/libs/Zend/Db/Adapter/Db2/Exception.php +++ b/libs/Zend/Db/Adapter/Db2/Exception.php @@ -15,22 +15,22 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Adapter_Exception */ -// require_once 'Zend/Db/Adapter/Exception.php'; +require_once 'Zend/Db/Adapter/Exception.php'; /** * Zend_Db_Adapter_Db2_Exception * * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Db2_Exception extends Zend_Db_Adapter_Exception @@ -38,8 +38,8 @@ class Zend_Db_Adapter_Db2_Exception extends Zend_Db_Adapter_Exception protected $code = '00000'; protected $message = 'unknown exception'; - function __construct($message = 'unknown exception', $code = '00000', Exception $e = null) - { - parent::__construct($message, $code, $e); + function __construct($msg = 'unknown exception', $state = '00000') { + $this->message = $msg; + $this->code = $state; } } diff --git a/libs/Zend/Db/Adapter/Exception.php b/libs/Zend/Db/Adapter/Exception.php index 2510ef6526..51c06874a6 100644 --- a/libs/Zend/Db/Adapter/Exception.php +++ b/libs/Zend/Db/Adapter/Exception.php @@ -15,43 +15,44 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 17860 2009-08-27 22:48:48Z beberlei $ */ /** * Zend_Db_Exception */ -// require_once 'Zend/Db/Exception.php'; +require_once 'Zend/Db/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Exception extends Zend_Db_Exception { protected $_chainedException = null; - public function __construct($message = '', $code = 0, Exception $e = null) + public function __construct($message = null, Exception $e = null) { - if ($e && (0 === $code)) { - $code = $e->getCode(); + if ($e) { + $this->_chainedException = $e; + $this->code = $e->getCode(); } - parent::__construct($message, $code, $e); + parent::__construct($message); } public function hasChainedException() { - return ($this->_previous !== null); + return ($this->_chainedException!==null); } public function getChainedException() { - return $this->getPrevious(); + return $this->_chainedException; } } diff --git a/libs/Zend/Db/Adapter/Mysqli.php b/libs/Zend/Db/Adapter/Mysqli.php index eb9437d059..3b686948c8 100644 --- a/libs/Zend/Db/Adapter/Mysqli.php +++ b/libs/Zend/Db/Adapter/Mysqli.php @@ -15,38 +15,38 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mysqli.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mysqli.php 16203 2009-06-21 18:56:17Z thomas $ */ /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Profiler */ -// require_once 'Zend/Db/Profiler.php'; +require_once 'Zend/Db/Profiler.php'; /** * @see Zend_Db_Select */ -// require_once 'Zend/Db/Select.php'; +require_once 'Zend/Db/Select.php'; /** * @see Zend_Db_Statement_Mysqli */ -// require_once 'Zend/Db/Statement/Mysqli.php'; +require_once 'Zend/Db/Statement/Mysqli.php'; /** * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract @@ -140,7 +140,7 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception($this->getConnection()->error); } return $result; @@ -200,7 +200,7 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception($this->getConnection()->error); } @@ -287,7 +287,7 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded'); } @@ -329,7 +329,7 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error()); } @@ -374,10 +374,10 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract $this->_stmt->close(); } $stmtClass = $this->_defaultStmtClass; - // if (!class_exists($stmtClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($stmtClass); - // } + if (!class_exists($stmtClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($stmtClass); + } $stmt = new $stmtClass($this, $sql); if ($stmt === false) { return false; @@ -467,14 +467,14 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception('FETCH_BOUND is not supported yet'); break; default: /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception("Invalid fetch mode '$mode' specified"); } } @@ -494,7 +494,7 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception("LIMIT argument count=$count is not valid"); } @@ -503,7 +503,7 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Mysqli_Exception */ - // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; + require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception("LIMIT argument offset=$offset is not valid"); } diff --git a/libs/Zend/Db/Adapter/Mysqli/Exception.php b/libs/Zend/Db/Adapter/Mysqli/Exception.php index f7f9f4a8fa..f2fbd8f958 100644 --- a/libs/Zend/Db/Adapter/Mysqli/Exception.php +++ b/libs/Zend/Db/Adapter/Mysqli/Exception.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ * */ /** * Zend */ -// require_once 'Zend/Db/Adapter/Exception.php'; +require_once 'Zend/Db/Adapter/Exception.php'; /** * Zend_Db_Adapter_Mysqli_Exception @@ -32,7 +32,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Mysqli_Exception extends Zend_Db_Adapter_Exception diff --git a/libs/Zend/Db/Adapter/Oracle.php b/libs/Zend/Db/Adapter/Oracle.php index 17fb8488f4..233335825d 100644 --- a/libs/Zend/Db/Adapter/Oracle.php +++ b/libs/Zend/Db/Adapter/Oracle.php @@ -15,26 +15,26 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Oracle.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Oracle.php 18415 2009-09-25 17:46:24Z mikaelkael $ */ /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Statement_Oracle */ -// require_once 'Zend/Db/Statement/Oracle.php'; +require_once 'Zend/Db/Statement/Oracle.php'; /** * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract @@ -115,14 +115,14 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but the extension is not loaded'); } $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); $connectionFuncName = ($this->_config['persistent'] == true) ? 'oci_pconnect' : 'oci_connect'; - + $this->_connection = @$connectionFuncName( $this->_config['username'], $this->_config['password'], @@ -134,7 +134,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception(oci_error()); } } @@ -204,10 +204,10 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract { $this->_connect(); $stmtClass = $this->_defaultStmtClass; - // if (!class_exists($stmtClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($stmtClass); - // } + if (!class_exists($stmtClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($stmtClass); + } $stmt = new $stmtClass($this, $sql); if ($stmt instanceof Zend_Db_Statement_Oracle) { $stmt->setLobAsString($this->getLobAsString()); @@ -360,7 +360,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION FROM ALL_TAB_COLUMNS TC LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C - ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P')) + ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND C.CONSTRAINT_TYPE = 'P')) ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)"; $bind[':TBNAME'] = $tableName; @@ -467,7 +467,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection)); } $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); @@ -485,7 +485,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection)); } $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); @@ -513,14 +513,14 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception('FETCH_BOUND is not supported yet'); break; default: /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception("Invalid fetch mode '$mode' specified"); break; } @@ -542,7 +542,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument count=$count is not valid"); } @@ -551,7 +551,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument offset=$offset is not valid"); } @@ -588,7 +588,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Adapter/Oracle/Exception.php'; + require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception("Invalid execution mode '$mode' specified"); break; } diff --git a/libs/Zend/Db/Adapter/Oracle/Exception.php b/libs/Zend/Db/Adapter/Oracle/Exception.php index a2f43ae893..39809b10df 100644 --- a/libs/Zend/Db/Adapter/Oracle/Exception.php +++ b/libs/Zend/Db/Adapter/Oracle/Exception.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Adapter_Exception */ -// require_once 'Zend/Db/Adapter/Exception.php'; +require_once 'Zend/Db/Adapter/Exception.php'; /** * Zend_Db_Adapter_Oracle_Exception @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Oracle_Exception extends Zend_Db_Adapter_Exception diff --git a/libs/Zend/Db/Adapter/Pdo/Abstract.php b/libs/Zend/Db/Adapter/Pdo/Abstract.php index 0ffc1f428f..9d05f417b4 100644 --- a/libs/Zend/Db/Adapter/Pdo/Abstract.php +++ b/libs/Zend/Db/Adapter/Pdo/Abstract.php @@ -15,22 +15,22 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 17860 2009-08-27 22:48:48Z beberlei $ */ /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Statement_Pdo */ -// require_once 'Zend/Db/Statement/Pdo.php'; +require_once 'Zend/Db/Statement/Pdo.php'; /** @@ -39,7 +39,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract @@ -99,7 +99,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded'); } @@ -108,7 +108,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception('The ' . $this->_pdoType . ' driver is not currently installed'); } @@ -119,7 +119,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract if (isset($this->_config['persistent']) && ($this->_config['persistent'] == true)) { $this->_config['driver_options'][PDO::ATTR_PERSISTENT] = true; } - + try { $this->_connection = new PDO( $dsn, @@ -140,8 +140,8 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; - throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e); + require_once 'Zend/Db/Adapter/Exception.php'; + throw new Zend_Db_Adapter_Exception($e->getMessage(), $e); } } @@ -177,10 +177,10 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract { $this->_connect(); $stmtClass = $this->_defaultStmtClass; - // if (!class_exists($stmtClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($stmtClass); - // } + if (!class_exists($stmtClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($stmtClass); + } $stmt = new $stmtClass($this, $sql); $stmt->setFetchMode($this->_fetchMode); return $stmt; @@ -240,7 +240,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Statement_Exception */ - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -258,26 +258,26 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract if ($sql instanceof Zend_Db_Select) { $sql = $sql->assemble(); } - + try { $affected = $this->getConnection()->exec($sql); - + if ($affected === false) { $errorInfo = $this->getConnection()->errorInfo(); /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception($errorInfo[2]); } - + return $affected; } catch (PDOException $e) { /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; - throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e); + require_once 'Zend/Db/Adapter/Exception.php'; + throw new Zend_Db_Adapter_Exception($e->getMessage(), $e); } } @@ -338,7 +338,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded'); } switch ($mode) { @@ -354,7 +354,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Invalid fetch mode '$mode' specified"); break; } diff --git a/libs/Zend/Db/Adapter/Pdo/Ibm.php b/libs/Zend/Db/Adapter/Pdo/Ibm.php index 22738248a9..47d91da0dc 100644 --- a/libs/Zend/Db/Adapter/Pdo/Ibm.php +++ b/libs/Zend/Db/Adapter/Pdo/Ibm.php @@ -15,30 +15,30 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ibm.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Ibm.php 16203 2009-06-21 18:56:17Z thomas $ */ /** @see Zend_Db_Adapter_Pdo_Abstract */ -// require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; +require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; /** @see Zend_Db_Abstract_Pdo_Ibm_Db2 */ -// require_once 'Zend/Db/Adapter/Pdo/Ibm/Db2.php'; +require_once 'Zend/Db/Adapter/Pdo/Ibm/Db2.php'; /** @see Zend_Db_Abstract_Pdo_Ibm_Ids */ -// require_once 'Zend/Db/Adapter/Pdo/Ibm/Ids.php'; +require_once 'Zend/Db/Adapter/Pdo/Ibm/Ids.php'; /** @see Zend_Db_Statement_Pdo_Ibm */ -// require_once 'Zend/Db/Statement/Pdo/Ibm.php'; +require_once 'Zend/Db/Statement/Pdo/Ibm.php'; /** * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Ibm extends Zend_Db_Adapter_Pdo_Abstract @@ -131,12 +131,12 @@ class Zend_Db_Adapter_Pdo_Ibm extends Zend_Db_Adapter_Pdo_Abstract } } catch (PDOException $e) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; $error = strpos($e->getMessage(), 'driver does not support that attribute'); if ($error) { - throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later", 0, $e); + throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later"); } else { - throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e); + throw new Zend_Db_Adapter_Exception($e->getMessage()); } } } @@ -178,7 +178,7 @@ class Zend_Db_Adapter_Pdo_Ibm extends Zend_Db_Adapter_Pdo_Abstract if (array_key_exists('host', $this->_config) && !array_key_exists('port', $config)) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified"); } } diff --git a/libs/Zend/Db/Adapter/Pdo/Ibm/Db2.php b/libs/Zend/Db/Adapter/Pdo/Ibm/Db2.php index 94899d4462..99182c0576 100644 --- a/libs/Zend/Db/Adapter/Pdo/Ibm/Db2.php +++ b/libs/Zend/Db/Adapter/Pdo/Ibm/Db2.php @@ -15,24 +15,24 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db2.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Db2.php 16203 2009-06-21 18:56:17Z thomas $ */ /** @see Zend_Db_Adapter_Pdo_Ibm */ -// require_once 'Zend/Db/Adapter/Pdo/Ibm.php'; +require_once 'Zend/Db/Adapter/Pdo/Ibm.php'; /** @see Zend_Db_Statement_Pdo_Ibm */ -// require_once 'Zend/Db/Statement/Pdo/Ibm.php'; +require_once 'Zend/Db/Statement/Pdo/Ibm.php'; /** * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Ibm_Db2 @@ -168,13 +168,13 @@ class Zend_Db_Adapter_Pdo_Ibm_Db2 $count = intval($count); if ($count < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } else { $offset = intval($offset); if ($offset < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } diff --git a/libs/Zend/Db/Adapter/Pdo/Ibm/Ids.php b/libs/Zend/Db/Adapter/Pdo/Ibm/Ids.php index 5777e5621c..766106332b 100644 --- a/libs/Zend/Db/Adapter/Pdo/Ibm/Ids.php +++ b/libs/Zend/Db/Adapter/Pdo/Ibm/Ids.php @@ -15,24 +15,24 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ids.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Ids.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @see Zend_Db_Adapter_Pdo_Ibm */ -// require_once 'Zend/Db/Adapter/Pdo/Ibm.php'; +require_once 'Zend/Db/Adapter/Pdo/Ibm.php'; /** @see Zend_Db_Statement_Pdo_Ibm */ -// require_once 'Zend/Db/Statement/Pdo/Ibm.php'; +require_once 'Zend/Db/Statement/Pdo/Ibm.php'; /** * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Ibm_Ids @@ -250,7 +250,7 @@ class Zend_Db_Adapter_Pdo_Ibm_Ids $count = intval($count); if ($count < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } else if ($count == 0) { $limit_sql = str_ireplace("SELECT", "SELECT * FROM (SELECT", $sql); @@ -259,7 +259,7 @@ class Zend_Db_Adapter_Pdo_Ibm_Ids $offset = intval($offset); if ($offset < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } if ($offset == 0) { diff --git a/libs/Zend/Db/Adapter/Pdo/Mssql.php b/libs/Zend/Db/Adapter/Pdo/Mssql.php index 0bd7a1bfbd..b61a4d61cc 100644 --- a/libs/Zend/Db/Adapter/Pdo/Mssql.php +++ b/libs/Zend/Db/Adapter/Pdo/Mssql.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mssql.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mssql.php 17792 2009-08-24 16:18:02Z ralph $ */ /** * @see Zend_Db_Adapter_Pdo_Abstract */ -// require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; +require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract @@ -254,7 +254,7 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract if ($schemaName != null) { $sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true); } - + $stmt = $this->query($sql); $primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM); $primaryKeyColumn = array(); @@ -319,14 +319,14 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract $count = intval($count); if ($count <= 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } $offset = intval($offset); if ($offset < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } @@ -335,46 +335,46 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract 'SELECT $1TOP ' . ($count+$offset) . ' ', $sql ); - + if ($offset > 0) { - $orderby = stristr($sql, 'ORDER BY'); - - if ($orderby !== false) { - $orderParts = explode(',', substr($orderby, 8)); - $pregReplaceCount = null; - $orderbyInverseParts = array(); - foreach ($orderParts as $orderPart) { - $orderPart = rtrim($orderPart); - $inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount); - if ($pregReplaceCount) { - $orderbyInverseParts[] = $inv; - continue; - } - $inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount); - if ($pregReplaceCount) { - $orderbyInverseParts[] = $inv; - continue; - } else { - $orderbyInverseParts[] = $orderPart . ' DESC'; - } - } - - $orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts); - } - - - - - $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl'; - if ($orderby !== false) { - $sql .= ' ' . $orderbyInverse . ' '; - } - $sql .= ') AS outer_tbl'; - if ($orderby !== false) { - $sql .= ' ' . $orderby; - } + $orderby = stristr($sql, 'ORDER BY'); + + if ($orderby !== false) { + $orderParts = explode(',', substr($orderby, 8)); + $pregReplaceCount = null; + $orderbyInverseParts = array(); + foreach ($orderParts as $orderPart) { + $orderPart = rtrim($orderPart); + $inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount); + if ($pregReplaceCount) { + $orderbyInverseParts[] = $inv; + continue; + } + $inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount); + if ($pregReplaceCount) { + $orderbyInverseParts[] = $inv; + continue; + } else { + $orderbyInverseParts[] = $orderPart . ' DESC'; + } + } + + $orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts); + } + + + + + $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl'; + if ($orderby !== false) { + $sql .= ' ' . $orderbyInverse . ' '; + } + $sql .= ') AS outer_tbl'; + if ($orderby !== false) { + $sql .= ' ' . $orderby; + } } - + return $sql; } diff --git a/libs/Zend/Db/Adapter/Pdo/Mysql.php b/libs/Zend/Db/Adapter/Pdo/Mysql.php index 0e4d794922..98551812cc 100644 --- a/libs/Zend/Db/Adapter/Pdo/Mysql.php +++ b/libs/Zend/Db/Adapter/Pdo/Mysql.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mysql.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mysql.php 16942 2009-07-22 04:03:09Z ralph $ */ /** * @see Zend_Db_Adapter_Pdo_Abstract */ -// require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; +require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Abstract @@ -235,14 +235,14 @@ class Zend_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Abstract $count = intval($count); if ($count <= 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } $offset = intval($offset); if ($offset < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } diff --git a/libs/Zend/Db/Adapter/Pdo/Oci.php b/libs/Zend/Db/Adapter/Pdo/Oci.php index fb47ad1c0b..91ce3ac370 100644 --- a/libs/Zend/Db/Adapter/Pdo/Oci.php +++ b/libs/Zend/Db/Adapter/Pdo/Oci.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Oci.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Oci.php 16203 2009-06-21 18:56:17Z thomas $ */ /** * @see Zend_Db_Adapter_Pdo_Abstract */ -// require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; +require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Oci extends Zend_Db_Adapter_Pdo_Abstract @@ -186,7 +186,7 @@ class Zend_Db_Adapter_Pdo_Oci extends Zend_Db_Adapter_Pdo_Abstract TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION FROM ALL_TAB_COLUMNS TC LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C - ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P')) + ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND C.CONSTRAINT_TYPE = 'P')) ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)"; $bind[':TBNAME'] = $tableName; @@ -347,14 +347,14 @@ class Zend_Db_Adapter_Pdo_Oci extends Zend_Db_Adapter_Pdo_Abstract $count = intval($count); if ($count <= 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } $offset = intval($offset); if ($offset < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } diff --git a/libs/Zend/Db/Adapter/Pdo/Pgsql.php b/libs/Zend/Db/Adapter/Pdo/Pgsql.php index bec14b569b..0c1d0ca2e8 100644 --- a/libs/Zend/Db/Adapter/Pdo/Pgsql.php +++ b/libs/Zend/Db/Adapter/Pdo/Pgsql.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Pgsql.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Pgsql.php 18646 2009-10-18 13:16:21Z mikaelkael $ */ /** * @see Zend_Db_Adapter_Pdo_Abstract */ -// require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; +require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract @@ -195,15 +195,15 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract $desc = array(); foreach ($result as $key => $row) { $defaultValue = $row[$default_value]; - if ($row[$type] == 'varchar' || $row[$type] == 'bpchar' ) { - if (preg_match('/character(?: varying)?(?:\((\d+)\))?/', $row[$complete_type], $matches)) { + if ($row[$type] == 'varchar') { + if (preg_match('/character varying(?:\((\d+)\))?/', $row[$complete_type], $matches)) { if (isset($matches[1])) { $row[$length] = $matches[1]; } else { $row[$length] = null; // unlimited } } - if (preg_match("/^'(.*?)'::(?:character varying|bpchar)$/", $defaultValue, $matches)) { + if (preg_match("/^'(.*?)'::character varying$/", $defaultValue, $matches)) { $defaultValue = $matches[1]; } } @@ -249,7 +249,7 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } @@ -258,7 +258,7 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } diff --git a/libs/Zend/Db/Adapter/Pdo/Sqlite.php b/libs/Zend/Db/Adapter/Pdo/Sqlite.php index f1e6562ef7..82687d5a9d 100644 --- a/libs/Zend/Db/Adapter/Pdo/Sqlite.php +++ b/libs/Zend/Db/Adapter/Pdo/Sqlite.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sqlite.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Sqlite.php 18214 2009-09-18 05:30:19Z ralph $ */ /** * @see Zend_Db_Adapter_Pdo_Abstract */ -// require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; +require_once 'Zend/Db/Adapter/Pdo/Abstract.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract @@ -106,7 +106,7 @@ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract // we need at least a dbname if (! array_key_exists('dbname', $config)) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance"); } } @@ -140,7 +140,7 @@ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract if ($retval === false) { $error = $this->_connection->errorInfo(); /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception($error[2]); } @@ -148,7 +148,7 @@ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract if ($retval === false) { $error = $this->_connection->errorInfo(); /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception($error[2]); } } @@ -198,11 +198,11 @@ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract public function describeTable($tableName, $schemaName = null) { $sql = 'PRAGMA '; - + if ($schemaName) { $sql .= $this->quoteIdentifier($schemaName) . '.'; } - + $sql .= 'table_info('.$this->quoteIdentifier($tableName).')'; $stmt = $this->query($sql); @@ -275,14 +275,14 @@ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract $count = intval($count); if ($count <= 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } $offset = intval($offset); if ($offset < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } diff --git a/libs/Zend/Db/Adapter/Sqlsrv.php b/libs/Zend/Db/Adapter/Sqlsrv.php index 533523759e..3de2500ea1 100644 --- a/libs/Zend/Db/Adapter/Sqlsrv.php +++ b/libs/Zend/Db/Adapter/Sqlsrv.php @@ -15,26 +15,25 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sqlsrv.php 21197 2010-02-24 16:12:53Z rob $ */ /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Statement_Sqlsrv */ -// require_once 'Zend/Db/Statement/Sqlsrv.php'; +require_once 'Zend/Db/Statement/Sqlsrv.php'; /** * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract @@ -121,7 +120,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Sqlsrv_Exception */ - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception('The Sqlsrv extension is required for this adapter but the extension is not loaded'); } @@ -148,11 +147,11 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract foreach ($this->_config['driver_options'] as $option => $value) { // A value may be a constant. if (is_string($value)) { - $constantName = strtoupper($value); - if (defined($constantName)) { - $connectionInfo[$option] = constant($constantName); - } else { + $constantValue = @constant(strtoupper($value)); + if ($constantValue === null) { $connectionInfo[$option] = $value; + } else { + $connectionInfo[$option] = $constantValue; } } } @@ -164,7 +163,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Sqlsrv_Exception */ - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors()); } } @@ -181,7 +180,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract // we need at least a dbname if (! array_key_exists('dbname', $config)) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance"); } @@ -189,7 +188,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials. If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config."); } @@ -198,7 +197,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract /** * @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials. If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config."); } @@ -239,12 +238,12 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract $sql = "SERIALIZABLE"; break; default: - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified"); } if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) { - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'"); } @@ -287,13 +286,13 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract $this->_connect(); $stmtClass = $this->_defaultStmtClass; - // if (!class_exists($stmtClass)) { + if (!class_exists($stmtClass)) { /** * @see Zend_Loader */ - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($stmtClass); - // } + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($stmtClass); + } $stmt = new $stmtClass($this, $sql); $stmt->setFetchMode($this->_fetchMode); @@ -519,7 +518,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract protected function _beginTransaction() { if (!sqlsrv_begin_transaction($this->_connection)) { - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors()); } } @@ -533,7 +532,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract protected function _commit() { if (!sqlsrv_commit($this->_connection)) { - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors()); } } @@ -547,7 +546,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract protected function _rollBack() { if (!sqlsrv_rollback($this->_connection)) { - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors()); } } @@ -571,11 +570,11 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract $this->_fetchMode = $mode; break; case Zend_Db::FETCH_BOUND: // bound to PHP variable - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception('FETCH_BOUND is not supported yet'); break; default: - // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid fetch mode '$mode' specified"); break; } @@ -594,40 +593,34 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract { $count = intval($count); if ($count <= 0) { - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid"); } $offset = intval($offset); if ($offset < 0) { /** @see Zend_Db_Adapter_Exception */ - // require_once 'Zend/Db/Adapter/Exception.php'; + require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid"); } - if ($offset == 0) { - $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $sql); - } else { - $orderby = stristr($sql, 'ORDER BY'); - if ($orderby !== false) { - $sort = (stripos($orderby, ' desc') !== false) ? 'desc' : 'asc'; - $order = str_ireplace('ORDER BY', '', $orderby); - $order = trim(preg_replace('/\bASC\b|\bDESC\b/i', '', $order)); - } - - $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $sql); - - $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl'; - if ($orderby !== false) { - $innerOrder = preg_replace('/\".*\".\"(.*)\"/i', '"inner_tbl"."$1"', $order); - $sql .= ' ORDER BY ' . $innerOrder . ' '; - $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC'; - } - $sql .= ') AS outer_tbl'; - if ($orderby !== false) { - $outerOrder = preg_replace('/\".*\".\"(.*)\"/i', '"outer_tbl"."$1"', $order); - $sql .= ' ORDER BY ' . $outerOrder . ' ' . $sort; - } + $orderby = stristr($sql, 'ORDER BY'); + if ($orderby !== false) { + $sort = (stripos($orderby, ' desc') !== false) ? 'desc' : 'asc'; + $order = str_ireplace('ORDER BY', '', $orderby); + $order = trim(preg_replace('/\bASC\b|\bDESC\b/i', '', $order)); + } + + $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $sql); + + $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl'; + if ($orderby !== false) { + $sql .= ' ORDER BY ' . $order . ' '; + $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC'; + } + $sql .= ') AS outer_tbl'; + if ($orderby !== false) { + $sql .= ' ORDER BY ' . $order . ' ' . $sort; } return $sql; diff --git a/libs/Zend/Db/Adapter/Sqlsrv/Exception.php b/libs/Zend/Db/Adapter/Sqlsrv/Exception.php index 1f68aa9c56..a07b3eb9a3 100644 --- a/libs/Zend/Db/Adapter/Sqlsrv/Exception.php +++ b/libs/Zend/Db/Adapter/Sqlsrv/Exception.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20629 2010-01-25 21:17:23Z ralph $ + * */ /** * @see Zend_Db_Adapter_Exception */ -// require_once 'Zend/Db/Adapter/Exception.php'; +require_once 'Zend/Db/Adapter/Exception.php'; /** * Zend_Db_Adapter_Sqlsrv_Exception @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Db * @subpackage Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Sqlsrv_Exception extends Zend_Db_Adapter_Exception @@ -58,6 +58,6 @@ class Zend_Db_Adapter_Sqlsrv_Exception extends Zend_Db_Adapter_Exception $code = (int) $message['code']; $message = (string) $message['message']; } - parent::__construct($message, $code, new Exception($message, $code)); + parent::__construct($message, new Exception($message, $code)); } } diff --git a/libs/Zend/Db/Exception.php b/libs/Zend/Db/Exception.php index 43e374b1b0..3d30302674 100644 --- a/libs/Zend/Db/Exception.php +++ b/libs/Zend/Db/Exception.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Db - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Db - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Exception extends Zend_Exception diff --git a/libs/Zend/Db/Expr.php b/libs/Zend/Db/Expr.php index df366b3b2a..2f2b7d51db 100644 --- a/libs/Zend/Db/Expr.php +++ b/libs/Zend/Db/Expr.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Db * @subpackage Expr - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Expr.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Expr.php 16203 2009-06-21 18:56:17Z thomas $ */ @@ -43,7 +43,7 @@ * @category Zend * @package Zend_Db * @subpackage Expr - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Expr diff --git a/libs/Zend/Db/Profiler.php b/libs/Zend/Db/Profiler.php index 9d695b877d..d0b2af5f1a 100644 --- a/libs/Zend/Db/Profiler.php +++ b/libs/Zend/Db/Profiler.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Profiler.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Profiler.php 16203 2009-06-21 18:56:17Z thomas $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Profiler @@ -68,15 +68,6 @@ class Zend_Db_Profiler */ const TRANSACTION = 64; - /** - * Inform that a query is stored (in case of filtering) - */ - const STORED = 'stored'; - - /** - * Inform that a query is ignored (in case of filtering) - */ - const IGNORED = 'ignored'; /** * Array of Zend_Db_Profiler_Query objects. @@ -278,7 +269,7 @@ class Zend_Db_Profiler /** * @see Zend_Db_Profiler_Query */ - // require_once 'Zend/Db/Profiler/Query.php'; + require_once 'Zend/Db/Profiler/Query.php'; $this->_queryProfiles[] = new Zend_Db_Profiler_Query($queryText, $queryType); end($this->_queryProfiles); @@ -298,7 +289,7 @@ class Zend_Db_Profiler { // Don't do anything if the Zend_Db_Profiler is not enabled. if (!$this->_enabled) { - return self::IGNORED; + return; } // Check for a valid query handle. @@ -306,7 +297,7 @@ class Zend_Db_Profiler /** * @see Zend_Db_Profiler_Exception */ - // require_once 'Zend/Db/Profiler/Exception.php'; + require_once 'Zend/Db/Profiler/Exception.php'; throw new Zend_Db_Profiler_Exception("Profiler has no query with handle '$queryId'."); } @@ -317,7 +308,7 @@ class Zend_Db_Profiler /** * @see Zend_Db_Profiler_Exception */ - // require_once 'Zend/Db/Profiler/Exception.php'; + require_once 'Zend/Db/Profiler/Exception.php'; throw new Zend_Db_Profiler_Exception("Query with profiler handle '$queryId' has already ended."); } @@ -330,7 +321,7 @@ class Zend_Db_Profiler */ if (null !== $this->_filterElapsedSecs && $qp->getElapsedSecs() < $this->_filterElapsedSecs) { unset($this->_queryProfiles[$queryId]); - return self::IGNORED; + return; } /** @@ -339,10 +330,8 @@ class Zend_Db_Profiler */ if (null !== $this->_filterTypes && !($qp->getQueryType() & $this->_filterTypes)) { unset($this->_queryProfiles[$queryId]); - return self::IGNORED; + return; } - - return self::STORED; } /** @@ -359,7 +348,7 @@ class Zend_Db_Profiler /** * @see Zend_Db_Profiler_Exception */ - // require_once 'Zend/Db/Profiler/Exception.php'; + require_once 'Zend/Db/Profiler/Exception.php'; throw new Zend_Db_Profiler_Exception("Query handle '$queryId' not found in profiler log."); } diff --git a/libs/Zend/Db/Profiler/Exception.php b/libs/Zend/Db/Profiler/Exception.php index 6caab626f7..3494622c2d 100644 --- a/libs/Zend/Db/Profiler/Exception.php +++ b/libs/Zend/Db/Profiler/Exception.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16203 2009-06-21 18:56:17Z thomas $ */ /** * @see Zend_Db_Exception */ -// require_once 'Zend/Db/Exception.php'; +require_once 'Zend/Db/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Profiler_Exception extends Zend_Db_Exception diff --git a/libs/Zend/Db/Profiler/Firebug.php b/libs/Zend/Db/Profiler/Firebug.php index 0ffaf142be..35a4ebd7b9 100644 --- a/libs/Zend/Db/Profiler/Firebug.php +++ b/libs/Zend/Db/Profiler/Firebug.php @@ -15,27 +15,27 @@ * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Firebug.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Firebug.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** Zend_Db_Profiler */ -// require_once 'Zend/Db/Profiler.php'; +require_once 'Zend/Db/Profiler.php'; /** Zend_Wildfire_Plugin_FirePhp */ -// require_once 'Zend/Wildfire/Plugin/FirePhp.php'; +require_once 'Zend/Wildfire/Plugin/FirePhp.php'; /** Zend_Wildfire_Plugin_FirePhp_TableMessage */ -// require_once 'Zend/Wildfire/Plugin/FirePhp/TableMessage.php'; +require_once 'Zend/Wildfire/Plugin/FirePhp/TableMessage.php'; /** * Writes DB events as log messages to the Firebug Console via FirePHP. - * + * * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler @@ -45,25 +45,25 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler * @var string */ protected $_label = null; - + /** * The label template for this profiler * @var string */ protected $_label_template = '%label% (%totalCount% @ %totalDuration% sec)'; - + /** * The message envelope holding the profiling summary * @var Zend_Wildfire_Plugin_FirePhp_TableMessage */ protected $_message = null; - + /** * The total time taken for all profiled queries. * @var float */ protected $_totalElapsedTime = 0; - + /** * Constructor * @@ -90,7 +90,7 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler parent::setEnabled($enable); if ($this->getEnabled()) { - + if (!$this->_message) { $this->_message = new Zend_Wildfire_Plugin_FirePhp_TableMessage($this->_label); $this->_message->setBuffered(true); @@ -106,7 +106,7 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler $this->_message->setDestroy(true); $this->_message = null; } - + } return $this; @@ -121,28 +121,28 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler */ public function queryEnd($queryId) { - $state = parent::queryEnd($queryId); - - if (!$this->getEnabled() || $state == self::IGNORED) { + parent::queryEnd($queryId); + + if (!$this->getEnabled()) { return; } $this->_message->setDestroy(false); $profile = $this->getQueryProfile($queryId); - + $this->_totalElapsedTime += $profile->getElapsedSecs(); - + $this->_message->addRow(array((string)round($profile->getElapsedSecs(),5), $profile->getQuery(), ($params=$profile->getQueryParams())?$params:null)); - + $this->updateMessageLabel(); } - + /** * Update the label of the message holding the profile info. - * + * * @return void */ protected function updateMessageLabel() diff --git a/libs/Zend/Db/Profiler/Query.php b/libs/Zend/Db/Profiler/Query.php index aacc16fbb9..74f3fe1aec 100644 --- a/libs/Zend/Db/Profiler/Query.php +++ b/libs/Zend/Db/Profiler/Query.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Query.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Query.php 16203 2009-06-21 18:56:17Z thomas $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Db * @subpackage Profiler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Profiler_Query diff --git a/libs/Zend/Db/Select.php b/libs/Zend/Db/Select.php index 721f3ec859..c8f1c77607 100644 --- a/libs/Zend/Db/Select.php +++ b/libs/Zend/Db/Select.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Select - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Select.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Select.php 18511 2009-10-12 14:33:35Z ralph $ */ /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Expr */ -// require_once 'Zend/Db/Expr.php'; +require_once 'Zend/Db/Expr.php'; /** @@ -38,7 +38,7 @@ * @category Zend * @package Zend_Db * @subpackage Select - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Select @@ -173,7 +173,7 @@ class Zend_Db_Select */ public function getBind() { - return $this->_bind; + return $this->_bind; } /** @@ -184,9 +184,9 @@ class Zend_Db_Select */ public function bind($bind) { - $this->_bind = $bind; + $this->_bind = $bind; - return $this; + return $this; } /** @@ -243,15 +243,14 @@ class Zend_Db_Select public function columns($cols = '*', $correlationName = null) { if ($correlationName === null && count($this->_parts[self::FROM])) { - $correlationNameKeys = array_keys($this->_parts[self::FROM]); - $correlationName = current($correlationNameKeys); + $correlationName = current(array_keys($this->_parts[self::FROM])); } if (!array_key_exists($correlationName, $this->_parts[self::FROM])) { /** * @see Zend_Db_Select_Exception */ - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("No table has been specified for the FROM clause"); } @@ -263,31 +262,20 @@ class Zend_Db_Select /** * Adds a UNION clause to the query. * - * The first parameter has to be an array of Zend_Db_Select or - * sql query strings. + * The first parameter $select can be a string, an existing Zend_Db_Select + * object or an array of either of these types. * - * <code> - * $sql1 = $db->select(); - * $sql2 = "SELECT ..."; - * $select = $db->select() - * ->union(array($sql1, $sql2)) - * ->order("id"); - * </code> - * - * @param array $select Array of select clauses for the union. + * @param array|string|Zend_Db_Select $select One or more select clauses for the UNION. * @return Zend_Db_Select This Zend_Db_Select object. */ public function union($select = array(), $type = self::SQL_UNION) { if (!is_array($select)) { - // require_once 'Zend/Db/Select/Exception.php'; - throw new Zend_Db_Select_Exception( - "union() only accepts an array of Zend_Db_Select instances of sql query strings." - ); + $select = array(); } if (!in_array($type, self::$_unionTypes)) { - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid union type '{$type}'"); } @@ -466,7 +454,7 @@ class Zend_Db_Select * </code> * * @param string $cond The WHERE condition. - * @param mixed $value OPTIONAL The value to quote into the condition. + * @param string $value OPTIONAL A single value to quote into the condition. * @param constant $type OPTIONAL The type of the given value * @return Zend_Db_Select This Zend_Db_Select object. */ @@ -483,7 +471,7 @@ class Zend_Db_Select * Otherwise identical to where(). * * @param string $cond The WHERE condition. - * @param mixed $value OPTIONAL The value to quote into the condition. + * @param string $value OPTIONAL A single value to quote into the condition. * @param constant $type OPTIONAL The type of the given value * @return Zend_Db_Select This Zend_Db_Select object. * @@ -526,7 +514,7 @@ class Zend_Db_Select * appears. See {@link where()} for an example * * @param string $cond The HAVING condition. - * @param string|Zend_Db_Expr $val The value to quote into the condition. + * @param string|Zend_Db_Expr $val A single value to quote into the condition. * @return Zend_Db_Select This Zend_Db_Select object. */ public function having($cond) @@ -551,7 +539,7 @@ class Zend_Db_Select * Otherwise identical to orHaving(). * * @param string $cond The HAVING condition. - * @param mixed $val The value to quote into the condition. + * @param string $val A single value to quote into the condition. * @return Zend_Db_Select This Zend_Db_Select object. * * @see having() @@ -664,7 +652,7 @@ class Zend_Db_Select { $part = strtolower($part); if (!array_key_exists($part, $this->_parts)) { - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid Select part '$part'"); } return $this->_parts[$part]; @@ -757,12 +745,12 @@ class Zend_Db_Select /** * @see Zend_Db_Select_Exception */ - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid join type '$type'"); } if (count($this->_parts[self::UNION])) { - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid use of table with " . self::SQL_UNION); } @@ -798,16 +786,16 @@ class Zend_Db_Select list($schema, $tableName) = explode('.', $tableName); } - $lastFromCorrelationName = null; if (!empty($correlationName)) { if (array_key_exists($correlationName, $this->_parts[self::FROM])) { /** * @see Zend_Db_Select_Exception */ - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("You cannot define a correlation name '$correlationName' more than once"); } - + + $lastFromCorrelationName = null; if ($type == self::FROM) { // append this from after the last from joinType $tmpFromParts = $this->_parts[self::FROM]; @@ -839,7 +827,7 @@ class Zend_Db_Select // add to the columns from this joined table if ($type == self::FROM && $lastFromCorrelationName == null) { $lastFromCorrelationName = true; - } + } $this->_tableCols($correlationName, $cols, $lastFromCorrelationName); return $this; @@ -873,7 +861,7 @@ class Zend_Db_Select public function _joinUsing($type, $name, $cond, $cols = '*', $schema = null) { if (empty($this->_parts[self::FROM])) { - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("You can only perform a joinUsing after specifying a FROM table"); } @@ -957,7 +945,7 @@ class Zend_Db_Select } else { $tmpColumns = array(); } - + // find the correlation name to insert after if (is_string($afterCorrelationName)) { while ($tmpColumns) { @@ -972,7 +960,7 @@ class Zend_Db_Select foreach ($columnValues as $columnValue) { array_push($this->_parts[self::COLUMNS], $columnValue); } - + // finish ensuring that all previous values are applied (if they exist) while ($tmpColumns) { array_push($this->_parts[self::COLUMNS], array_shift($tmpColumns)); @@ -984,7 +972,7 @@ class Zend_Db_Select * Internal function for creating the where clause * * @param string $condition - * @param mixed $value optional + * @param string $value optional * @param string $type optional * @param boolean $bool true = AND, false = OR * @return string clause @@ -992,7 +980,7 @@ class Zend_Db_Select protected function _where($condition, $value = null, $type = null, $bool = true) { if (count($this->_parts[self::UNION])) { - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid use of where clause with " . self::SQL_UNION); } @@ -1116,7 +1104,7 @@ class Zend_Db_Select $tmp = ''; $joinType = ($table['joinType'] == self::FROM) ? self::INNER_JOIN : $table['joinType']; - + // Add join clause (if applicable) if (! empty($from)) { $tmp .= ' ' . strtoupper($joinType) . ' '; @@ -1258,7 +1246,8 @@ class Zend_Db_Select if (!empty($this->_parts[self::LIMIT_OFFSET])) { $offset = (int) $this->_parts[self::LIMIT_OFFSET]; - $count = PHP_INT_MAX; + // This should reduce to the max integer PHP can support + $count = intval(9223372036854775807); } if (!empty($this->_parts[self::LIMIT_COUNT])) { @@ -1314,11 +1303,11 @@ class Zend_Db_Select if ($type) { $type .= ' join'; if (!in_array($type, self::$_joinTypes)) { - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Unrecognized method '$method()'"); } if (in_array($type, array(self::CROSS_JOIN, self::NATURAL_JOIN))) { - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Cannot perform a joinUsing with method '$method()'"); } } else { @@ -1328,7 +1317,7 @@ class Zend_Db_Select return call_user_func_array(array($this, '_joinUsing'), $args); } - // require_once 'Zend/Db/Select/Exception.php'; + require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Unrecognized method '$method()'"); } diff --git a/libs/Zend/Db/Select/Exception.php b/libs/Zend/Db/Select/Exception.php index dc02cb40ab..23fdf2dfec 100644 --- a/libs/Zend/Db/Select/Exception.php +++ b/libs/Zend/Db/Select/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Select - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Exception */ -// require_once 'Zend/Db/Exception.php'; +require_once 'Zend/Db/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Select - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/libs/Zend/Db/Statement.php b/libs/Zend/Db/Statement.php index df99fa0133..7dada0964a 100644 --- a/libs/Zend/Db/Statement.php +++ b/libs/Zend/Db/Statement.php @@ -15,20 +15,20 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Statement.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Statement.php 17858 2009-08-27 22:04:38Z ralph $ */ /** * @see Zend_Db */ -// require_once 'Zend/Db.php'; +require_once 'Zend/Db.php'; /** * @see Zend_Db_Statement_Interface */ -// require_once 'Zend/Db/Statement/Interface.php'; +require_once 'Zend/Db/Statement/Interface.php'; /** * Abstract class to emulate a PDOStatement for native database adapters. @@ -36,7 +36,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface @@ -46,7 +46,7 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface * @var resource|object The driver level statement object/resource */ protected $_stmt = null; - + /** * @var Zend_Db_Adapter_Abstract */ @@ -120,14 +120,14 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface /** * Internal method called by abstract statment constructor to setup * the driver level statement - * + * * @return void */ protected function _prepare($sql) { return; } - + /** * @param string $sql * @return void @@ -148,7 +148,7 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface /** * @see Zend_Db_Statement_Exception */ - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$val'"); } } else if ($val[0] == ':') { @@ -156,7 +156,7 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface /** * @see Zend_Db_Statement_Exception */ - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception("Invalid bind-variable name '$val'"); } } @@ -241,7 +241,7 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface /** * @see Zend_Db_Statement_Exception */ - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception('Invalid bind-variable position'); } @@ -263,7 +263,7 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface /** * @see Zend_Db_Statement_Exception */ - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$parameter'"); } @@ -433,7 +433,7 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface /** * @see Zend_Db_Statement_Exception */ - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception('invalid fetch mode'); break; } @@ -472,9 +472,9 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface { return $this->_adapter; } - + /** - * Gets the resource or object setup by the + * Gets the resource or object setup by the * _parse * @return unknown_type */ diff --git a/libs/Zend/Db/Statement/Db2.php b/libs/Zend/Db/Statement/Db2.php index 729d65c61a..c2dac3a646 100644 --- a/libs/Zend/Db/Statement/Db2.php +++ b/libs/Zend/Db/Statement/Db2.php @@ -15,22 +15,22 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db2.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Db2.php 17857 2009-08-27 22:01:47Z ralph $ */ /** * @see Zend_Db_Statement */ -// require_once 'Zend/Db/Statement.php'; +require_once 'Zend/Db/Statement.php'; /** * Extends for DB2 native adapter. * * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Db2 extends Zend_Db_Statement @@ -65,7 +65,7 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement /** * @see Zend_Db_Statement_Db2_Exception */ - // require_once 'Zend/Db/Statement/Db2/Exception.php'; + require_once 'Zend/Db/Statement/Db2/Exception.php'; throw new Zend_Db_Statement_Db2_Exception( db2_stmt_errormsg(), db2_stmt_error() @@ -100,7 +100,7 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement /** * @see Zend_Db_Statement_Db2_Exception */ - // require_once 'Zend/Db/Statement/Db2/Exception.php'; + require_once 'Zend/Db/Statement/Db2/Exception.php'; throw new Zend_Db_Statement_Db2_Exception( db2_stmt_errormsg(), db2_stmt_error() @@ -154,7 +154,7 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement $error = db2_stmt_error(); if ($error === '') { - return false; + return false; } return $error; @@ -168,10 +168,10 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement */ public function errorInfo() { - $error = $this->errorCode(); - if ($error === false){ - return false; - } + $error = $this->errorCode(); + if ($error === false){ + return false; + } /* * Return three-valued array like PDO. But DB2 does not distinguish @@ -208,7 +208,7 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement /** * @see Zend_Db_Statement_Db2_Exception */ - // require_once 'Zend/Db/Statement/Db2/Exception.php'; + require_once 'Zend/Db/Statement/Db2/Exception.php'; throw new Zend_Db_Statement_Db2_Exception( db2_stmt_errormsg(), db2_stmt_error()); @@ -272,7 +272,7 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement /** * @see Zend_Db_Statement_Db2_Exception */ - // require_once 'Zend/Db/Statement/Db2/Exception.php'; + require_once 'Zend/Db/Statement/Db2/Exception.php'; throw new Zend_Db_Statement_Db2_Exception("Invalid fetch mode '$style' specified"); break; } @@ -306,7 +306,7 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement /** * @see Zend_Db_Statement_Db2_Exception */ - // require_once 'Zend/Db/Statement/Db2/Exception.php'; + require_once 'Zend/Db/Statement/Db2/Exception.php'; throw new Zend_Db_Statement_Db2_Exception(__FUNCTION__ . '() is not implemented'); } diff --git a/libs/Zend/Db/Statement/Db2/Exception.php b/libs/Zend/Db/Statement/Db2/Exception.php index d77b5d830c..0b04bf4af2 100644 --- a/libs/Zend/Db/Statement/Db2/Exception.php +++ b/libs/Zend/Db/Statement/Db2/Exception.php @@ -15,20 +15,20 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Statement_Exception */ -// require_once 'Zend/Db/Statement/Exception.php'; +require_once 'Zend/Db/Statement/Exception.php'; /** * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/libs/Zend/Db/Statement/Exception.php b/libs/Zend/Db/Statement/Exception.php index 511888a5e3..7c9d58992a 100644 --- a/libs/Zend/Db/Statement/Exception.php +++ b/libs/Zend/Db/Statement/Exception.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20514 2010-01-22 07:57:10Z ralph $ + * @version $Id: Exception.php 17860 2009-08-27 22:48:48Z beberlei $ */ /** * @see Zend_Db_Exception */ -// require_once 'Zend/Db/Exception.php'; +require_once 'Zend/Db/Exception.php'; /** * Zend_Db_Statement_Exception @@ -31,19 +31,36 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Exception extends Zend_Db_Exception { /** + * @var Exception + */ + protected $_chainedException = null; + + /** + * @param string $message + * @param string|int $code + * @param Exception $chainedException + */ + public function __construct($message = null, $code = null, Exception $chainedException=null) + { + $this->message = $message; + $this->code = $code; + $this->_chainedException = $chainedException; + } + + /** * Check if this general exception has a specific database driver specific exception nested inside. - * + * * @return bool */ public function hasChainedException() { - return ($this->getPrevious() !== null); + return ($this->_chainedException!==null); } /** @@ -51,6 +68,6 @@ class Zend_Db_Statement_Exception extends Zend_Db_Exception */ public function getChainedException() { - return $this->getPrevious(); + return $this->_chainedException; } } diff --git a/libs/Zend/Db/Statement/Interface.php b/libs/Zend/Db/Statement/Interface.php index 701c64010e..2cf951b057 100644 --- a/libs/Zend/Db/Statement/Interface.php +++ b/libs/Zend/Db/Statement/Interface.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** @@ -26,7 +26,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Db_Statement_Interface diff --git a/libs/Zend/Db/Statement/Mysqli.php b/libs/Zend/Db/Statement/Mysqli.php index 51dba7160f..a1870f13fa 100644 --- a/libs/Zend/Db/Statement/Mysqli.php +++ b/libs/Zend/Db/Statement/Mysqli.php @@ -15,25 +15,25 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mysqli.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mysqli.php 18195 2009-09-17 20:58:05Z bittarman $ */ /** * @see Zend_Db_Statement */ -// require_once 'Zend/Db/Statement.php'; - +require_once 'Zend/Db/Statement.php'; + /** * Extends for Mysqli * * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement @@ -73,7 +73,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement /** * @see Zend_Db_Statement_Mysqli_Exception */ - // require_once 'Zend/Db/Statement/Mysqli/Exception.php'; + require_once 'Zend/Db/Statement/Mysqli/Exception.php'; throw new Zend_Db_Statement_Mysqli_Exception("Mysqli prepare error: " . $mysqli->error, $mysqli->errno); } } @@ -210,7 +210,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement /** * @see Zend_Db_Statement_Mysqli_Exception */ - // require_once 'Zend/Db/Statement/Mysqli/Exception.php'; + require_once 'Zend/Db/Statement/Mysqli/Exception.php'; throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement execute error : " . $this->_stmt->error, $this->_stmt->errno); } @@ -222,7 +222,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement /** * @see Zend_Db_Statement_Mysqli_Exception */ - // require_once 'Zend/Db/Statement/Mysqli/Exception.php'; + require_once 'Zend/Db/Statement/Mysqli/Exception.php'; throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement metadata error: " . $this->_stmt->error, $this->_stmt->errno); } } @@ -275,12 +275,12 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement // fetch the next result $retval = $this->_stmt->fetch(); switch ($retval) { - case null: // end of data - case false: // error occurred - $this->_stmt->reset(); - return false; - default: - // fallthrough + case null: // end of data + case false: // error occurred + $this->_stmt->reset(); + return false; + default: + // fallthrough } // make sure we have a fetch mode @@ -319,7 +319,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement /** * @see Zend_Db_Statement_Mysqli_Exception */ - // require_once 'Zend/Db/Statement/Mysqli/Exception.php'; + require_once 'Zend/Db/Statement/Mysqli/Exception.php'; throw new Zend_Db_Statement_Mysqli_Exception("Invalid fetch mode '$style' specified"); break; } @@ -339,7 +339,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement /** * @see Zend_Db_Statement_Mysqli_Exception */ - // require_once 'Zend/Db/Statement/Mysqli/Exception.php'; + require_once 'Zend/Db/Statement/Mysqli/Exception.php'; throw new Zend_Db_Statement_Mysqli_Exception(__FUNCTION__.'() is not implemented'); } diff --git a/libs/Zend/Db/Statement/Mysqli/Exception.php b/libs/Zend/Db/Statement/Mysqli/Exception.php index 4847231476..a90162db02 100644 --- a/libs/Zend/Db/Statement/Mysqli/Exception.php +++ b/libs/Zend/Db/Statement/Mysqli/Exception.php @@ -15,20 +15,20 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Statement_Exception */ -// require_once 'Zend/Db/Statement/Exception.php'; +require_once 'Zend/Db/Statement/Exception.php'; /** * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/libs/Zend/Db/Statement/Oracle.php b/libs/Zend/Db/Statement/Oracle.php index d84d2bab7f..0c8c18a6bd 100644 --- a/libs/Zend/Db/Statement/Oracle.php +++ b/libs/Zend/Db/Statement/Oracle.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Oracle.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Oracle.php 18636 2009-10-17 05:44:41Z ralph $ */ /** * @see Zend_Db_Statement */ -// require_once 'Zend/Db/Statement.php'; +require_once 'Zend/Db/Statement.php'; /** * Extends for Oracle. @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Oracle extends Zend_Db_Statement @@ -92,7 +92,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Statement_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection)); } } @@ -125,7 +125,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } @@ -249,7 +249,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } } @@ -259,7 +259,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } @@ -323,7 +323,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception( array( 'code' => 'HYC00', @@ -337,7 +337,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception($error); } @@ -374,7 +374,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception( array( 'code' => 'HYC00', @@ -402,7 +402,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception( array( 'code' => 'HYC00', @@ -419,7 +419,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception($error); } if (!$rows) { @@ -442,7 +442,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception($error); } } @@ -472,7 +472,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception($error); } @@ -481,7 +481,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } @@ -516,7 +516,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception($error); } @@ -538,7 +538,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Statement_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception( array( 'code' => 'HYC00', @@ -567,7 +567,7 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement /** * @see Zend_Db_Adapter_Oracle_Exception */ - // require_once 'Zend/Db/Statement/Oracle/Exception.php'; + require_once 'Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } diff --git a/libs/Zend/Db/Statement/Oracle/Exception.php b/libs/Zend/Db/Statement/Oracle/Exception.php index d5e21bad3f..26f5412eef 100644 --- a/libs/Zend/Db/Statement/Oracle/Exception.php +++ b/libs/Zend/Db/Statement/Oracle/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Statement_Exception */ -// require_once 'Zend/Db/Statement/Exception.php'; +require_once 'Zend/Db/Statement/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/libs/Zend/Db/Statement/Pdo.php b/libs/Zend/Db/Statement/Pdo.php index b9e9400d28..c0f6bc5248 100644 --- a/libs/Zend/Db/Statement/Pdo.php +++ b/libs/Zend/Db/Statement/Pdo.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Pdo.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Pdo.php 18079 2009-09-11 17:46:45Z ralph $ */ /** * @see Zend_Db_Statement */ -// require_once 'Zend/Db/Statement.php'; +require_once 'Zend/Db/Statement.php'; /** * Proxy class to wrap a PDOStatement object. @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggregate @@ -57,7 +57,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { $this->_stmt = $this->_adapter->getConnection()->prepare($sql); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -81,7 +81,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega return $this->_stmt->bindColumn($column, $param, $type); } } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -113,7 +113,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega } return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -132,9 +132,9 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega if (is_string($parameter) && $parameter[0] != ':') { $parameter = ":$parameter"; } - + $this->_bindParam[$parameter] = $value; - + try { if ($type === null) { return $this->_stmt->bindValue($parameter, $value); @@ -142,7 +142,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega return $this->_stmt->bindValue($parameter, $value, $type); } } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -158,7 +158,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->closeCursor(); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -175,7 +175,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->columnCount(); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -192,7 +192,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->errorCode(); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -209,7 +209,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->errorInfo(); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -230,8 +230,8 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega return $this->_stmt->execute(); } } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; - throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e); + require_once 'Zend/Db/Statement/Exception.php'; + throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -252,7 +252,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->fetch($style, $cursor, $offset); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -290,7 +290,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega return $this->_stmt->fetchAll($style); } } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -307,7 +307,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->fetchColumn($col); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -325,7 +325,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->fetchObject($class, $config); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -342,7 +342,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->getAttribute($key); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -359,7 +359,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->getColumnMeta($column); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -377,7 +377,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->nextRowset(); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -395,7 +395,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->rowCount(); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -413,7 +413,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->setAttribute($key, $val); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } @@ -431,7 +431,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega try { return $this->_stmt->setFetchMode($mode); } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } diff --git a/libs/Zend/Db/Statement/Pdo/Ibm.php b/libs/Zend/Db/Statement/Pdo/Ibm.php index 20b6aea7a9..29ae3db62e 100644 --- a/libs/Zend/Db/Statement/Pdo/Ibm.php +++ b/libs/Zend/Db/Statement/Pdo/Ibm.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ibm.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Ibm.php 17860 2009-08-27 22:48:48Z beberlei $ */ /** * @see Zend_Db_Statement_Pdo */ -// require_once 'Zend/Db/Statement/Pdo.php'; +require_once 'Zend/Db/Statement/Pdo.php'; /** * Proxy class to wrap a PDOStatement object for IBM Databases. @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Pdo_Ibm extends Zend_Db_Statement_Pdo @@ -86,7 +86,7 @@ class Zend_Db_Statement_Pdo_Ibm extends Zend_Db_Statement_Pdo return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options); } } catch (PDOException $e) { - // require_once 'Zend/Db/Statement/Exception.php'; + require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } } diff --git a/libs/Zend/Db/Statement/Pdo/Oci.php b/libs/Zend/Db/Statement/Pdo/Oci.php index 2306228187..e4b1edc638 100644 --- a/libs/Zend/Db/Statement/Pdo/Oci.php +++ b/libs/Zend/Db/Statement/Pdo/Oci.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Oci.php 21105 2010-02-19 21:27:09Z mikaelkael $ + * @version $Id: Oci.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Db_Statement_Pdo */ -// require_once 'Zend/Db/Statement/Pdo.php'; +require_once 'Zend/Db/Statement/Pdo.php'; /** * Proxy class to wrap a PDOStatement object for IBM Databases. @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Pdo_Oci extends Zend_Db_Statement_Pdo @@ -66,26 +66,4 @@ class Zend_Db_Statement_Pdo_Oci extends Zend_Db_Statement_Pdo } return $results; } - - - /** - * Fetches a row from the result set. - * - * @param int $style OPTIONAL Fetch mode for this fetch operation. - * @param int $cursor OPTIONAL Absolute, relative, or other. - * @param int $offset OPTIONAL Number for absolute or relative cursors. - * @return mixed Array, object, or scalar depending on fetch mode. - * @throws Zend_Db_Statement_Exception - */ - public function fetch($style = null, $cursor = null, $offset = null) - { - $row = parent::fetch($style, $cursor, $offset); - - $remove = $this->_adapter->foldCase('zend_db_rownum'); - if (is_array($row) && array_key_exists($remove, $row)) { - unset($row[$remove]); - } - - return $row; - } }
\ No newline at end of file diff --git a/libs/Zend/Db/Statement/Sqlsrv.php b/libs/Zend/Db/Statement/Sqlsrv.php index 9663c83ccf..45c243edf1 100644 --- a/libs/Zend/Db/Statement/Sqlsrv.php +++ b/libs/Zend/Db/Statement/Sqlsrv.php @@ -15,15 +15,14 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sqlsrv.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** * @see Zend_Db_Statement */ -// require_once 'Zend/Db/Statement.php'; +require_once 'Zend/Db/Statement.php'; /** * Extends for Microsoft SQL Server Driver for PHP @@ -31,7 +30,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement @@ -66,7 +65,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement $this->_stmt = sqlsrv_prepare($connection, $sql); if (!$this->_stmt) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors()); } @@ -202,7 +201,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement $this->_stmt = sqlsrv_query($connection, $this->_originalSQL, $params); if (!$this->_stmt) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors()); } @@ -233,7 +232,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement $values = sqlsrv_fetch_array($this->_stmt, SQLSRV_FETCH_ASSOC); if (!$values && (null !== $error = sqlsrv_errors())) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception($error); } @@ -270,7 +269,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement $row = $this->_fetchBound($row); break; default: - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception("Invalid fetch mode '$style' specified"); break; } @@ -293,7 +292,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement if (!sqlsrv_fetch($this->_stmt)) { if (null !== $error = sqlsrv_errors()) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception($error); } @@ -303,7 +302,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement $data = sqlsrv_get_field($this->_stmt, $col); //0-based if ($data === false) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors()); } @@ -327,7 +326,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement $obj = sqlsrv_fetch_object($this->_stmt); if ($error = sqlsrv_errors()) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception($error); } @@ -373,7 +372,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement public function nextRowset() { if (sqlsrv_next_result($this->_stmt) === false) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors()); } @@ -402,7 +401,7 @@ class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement // Strict check is necessary; 0 is a valid return value if ($num_rows === false) { - // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; + require_once 'Zend/Db/Statement/Sqlsrv/Exception.php'; throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors()); } diff --git a/libs/Zend/Db/Statement/Sqlsrv/Exception.php b/libs/Zend/Db/Statement/Sqlsrv/Exception.php index cbd4cf4d45..02378627f9 100644 --- a/libs/Zend/Db/Statement/Sqlsrv/Exception.php +++ b/libs/Zend/Db/Statement/Sqlsrv/Exception.php @@ -12,23 +12,21 @@ * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * - * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** * @see Zend_Db_Statement_Exception */ -// require_once 'Zend/Db/Statement/Exception.php'; +require_once 'Zend/Db/Statement/Exception.php'; /** * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Statement_Sqlsrv_Exception extends Zend_Db_Statement_Exception diff --git a/libs/Zend/Db/Table.php b/libs/Zend/Db/Table.php index ba22f7f262..20319fd1ec 100644 --- a/libs/Zend/Db/Table.php +++ b/libs/Zend/Db/Table.php @@ -15,20 +15,20 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Table.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Table.php 16733 2009-07-15 13:16:50Z ralph $ */ /** - * @see Zend_Db_Table_Abstract + * Zend_Db_Table_Abstract */ -// require_once 'Zend/Db/Table/Abstract.php'; +require_once 'Zend/Db/Table/Abstract.php'; /** * @see Zend_Db_Table_Definition */ -// require_once 'Zend/Db/Table/Definition.php'; +require_once 'Zend/Db/Table/Definition.php'; /** * Class for SQL table interface. @@ -36,25 +36,25 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table extends Zend_Db_Table_Abstract { - + /** * __construct() - For concrete implementation of Zend_Db_Table * * @param string|array $config string can reference a Zend_Registry key for a db adapter - * OR it can reference the name of a table - * @param array|Zend_Db_Table_Definition $definition + * OR it can refernece the name of a table + * @param unknown_type $definition */ public function __construct($config = array(), $definition = null) { if ($definition !== null && is_array($definition)) { $definition = new Zend_Db_Table_Definition($definition); } - + if (is_string($config)) { if (Zend_Registry::isRegistered($config)) { trigger_error(__CLASS__ . '::' . __METHOD__ . '(\'registryName\') is not valid usage of Zend_Db_Table, ' @@ -73,7 +73,12 @@ class Zend_Db_Table extends Zend_Db_Table_Abstract } } } - + parent::__construct($config); } + + + + + } diff --git a/libs/Zend/Db/Table/Abstract.php b/libs/Zend/Db/Table/Abstract.php index e07ed22517..f0a6ea18d7 100644 --- a/libs/Zend/Db/Table/Abstract.php +++ b/libs/Zend/Db/Table/Abstract.php @@ -15,25 +15,25 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 21079 2010-02-18 18:15:49Z tech13 $ + * @version $Id: Abstract.php 17822 2009-08-26 00:03:56Z ralph $ */ /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Select.php'; +require_once 'Zend/Db/Select.php'; /** * @see Zend_Db */ -// require_once 'Zend/Db.php'; +require_once 'Zend/Db.php'; /** * Class for SQL table interface. @@ -41,7 +41,7 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Db_Table_Abstract @@ -93,14 +93,14 @@ abstract class Zend_Db_Table_Abstract * @var unknown_type */ protected $_definition = null; - + /** * Optional definition config name used in concrete implementation * * @var string */ protected $_definitionConfigName = null; - + /** * Default cache for information provided by the adapter's describeTable() method. * @@ -326,7 +326,7 @@ abstract class Zend_Db_Table_Abstract return $this; } - + /** * setDefinition() * @@ -338,7 +338,7 @@ abstract class Zend_Db_Table_Abstract $this->_definition = $definition; return $this; } - + /** * getDefinition() * @@ -348,7 +348,7 @@ abstract class Zend_Db_Table_Abstract { return $this->_definition; } - + /** * setDefinitionConfigName() * @@ -360,7 +360,7 @@ abstract class Zend_Db_Table_Abstract $this->_definitionConfigName = $definitionConfigName; return $this; } - + /** * getDefinitionConfigName() * @@ -466,11 +466,11 @@ abstract class Zend_Db_Table_Abstract $refMap = $this->_getReferenceMapNormalized(); if ($ruleKey !== null) { if (!isset($refMap[$ruleKey])) { - // require_once "Zend/Db/Table/Exception.php"; + require_once "Zend/Db/Table/Exception.php"; throw new Zend_Db_Table_Exception("No reference rule \"$ruleKey\" from table $thisClass to table $tableClassname"); } if ($refMap[$ruleKey][self::REF_TABLE_CLASS] != $tableClassname) { - // require_once "Zend/Db/Table/Exception.php"; + require_once "Zend/Db/Table/Exception.php"; throw new Zend_Db_Table_Exception("Reference rule \"$ruleKey\" does not reference table $tableClassname"); } return $refMap[$ruleKey]; @@ -480,7 +480,7 @@ abstract class Zend_Db_Table_Abstract return $reference; } } - // require_once "Zend/Db/Table/Exception.php"; + require_once "Zend/Db/Table/Exception.php"; throw new Zend_Db_Table_Exception("No reference from table $thisClass to table $tableClassname"); } @@ -603,11 +603,11 @@ abstract class Zend_Db_Table_Abstract return null; } if (is_string($db)) { - // require_once 'Zend/Registry.php'; + require_once 'Zend/Registry.php'; $db = Zend_Registry::get($db); } if (!$db instanceof Zend_Db_Adapter_Abstract) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored'); } return $db; @@ -698,11 +698,11 @@ abstract class Zend_Db_Table_Abstract return null; } if (is_string($metadataCache)) { - // require_once 'Zend/Registry.php'; + require_once 'Zend/Registry.php'; $metadataCache = Zend_Registry::get($metadataCache); } if (!$metadataCache instanceof Zend_Cache_Core) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('Argument must be of type Zend_Cache_Core, or a Registry key where a Zend_Cache_Core object is stored'); } return $metadataCache; @@ -750,7 +750,7 @@ abstract class Zend_Db_Table_Abstract if (! $this->_db) { $this->_db = self::getDefaultAdapter(); if (!$this->_db instanceof Zend_Db_Adapter_Abstract) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this)); } } @@ -803,10 +803,10 @@ abstract class Zend_Db_Table_Abstract // If $this has a metadata cache if (null !== $this->_metadataCache) { // Define the cache identifier where the metadata are saved - + //get db configuration $dbConfig = $this->_db->getConfig(); - + // Define the cache identifier where the metadata are saved $cacheId = md5( // port:host/dbname:schema.table (based on availabilty) (isset($dbConfig['options']['port']) ? ':'.$dbConfig['options']['port'] : null) @@ -823,7 +823,11 @@ abstract class Zend_Db_Table_Abstract $metadata = $this->_db->describeTable($this->_name, $this->_schema); // If $this has a metadata cache, then cache the metadata if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) { - trigger_error('Failed saving metadata to metadataCache', E_USER_NOTICE); + /** + * @see Zend_Db_Table_Exception + */ + require_once 'Zend/Db/Table/Exception.php'; + throw new Zend_Db_Table_Exception('Failed saving metadata to metadataCache'); } } @@ -872,7 +876,7 @@ abstract class Zend_Db_Table_Abstract // if no primary key was specified and none was found in the metadata // then throw an exception. if (empty($this->_primary)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('A table must have a primary key, but none was found'); } } else if (!is_array($this->_primary)) { @@ -884,7 +888,7 @@ abstract class Zend_Db_Table_Abstract $cols = $this->_getCols(); if (! array_intersect((array) $this->_primary, $cols) == (array) $this->_primary) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Primary key column(s) (" . implode(',', (array) $this->_primary) . ") are not columns in this table (" @@ -986,7 +990,7 @@ abstract class Zend_Db_Table_Abstract } if (!array_key_exists($key, $info)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('There is no table information for the key "' . $key . '"'); } @@ -1001,7 +1005,7 @@ abstract class Zend_Db_Table_Abstract */ public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART) { - // require_once 'Zend/Db/Table/Select.php'; + require_once 'Zend/Db/Table/Select.php'; $select = new Zend_Db_Table_Select($this); if ($withFromPart == self::SELECT_WITH_FROM_PART) { $select->from($this->info(self::NAME), Zend_Db_Table_Select::SQL_WILDCARD, $this->info(self::SCHEMA)); @@ -1088,7 +1092,7 @@ abstract class Zend_Db_Table_Abstract /** * @see Zend_Db_Table_Exception */ - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('Column "' . $column . '" not found in table.'); } @@ -1221,12 +1225,12 @@ abstract class Zend_Db_Table_Abstract $keyNames = array_values((array) $this->_primary); if (count($args) < count($keyNames)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Too few columns for the primary key"); } if (count($args) > count($keyNames)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Too many columns for the primary key"); } @@ -1243,7 +1247,7 @@ abstract class Zend_Db_Table_Abstract if ($numberTerms == 0) { $numberTerms = $keyValuesCount; } else if ($keyValuesCount != $numberTerms) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Missing value(s) for the primary key"); } $keyValues = array_values($keyValues); @@ -1276,13 +1280,13 @@ abstract class Zend_Db_Table_Abstract // issue ZF-5775 (empty where clause should return empty rowset) if ($whereClause == null) { $rowsetClass = $this->getRowsetClass(); - // if (!class_exists($rowsetClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowsetClass); - // } + if (!class_exists($rowsetClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowsetClass); + } return new $rowsetClass(array('table' => $this, 'rowClass' => $this->getRowClass(), 'stored' => true)); } - + return $this->fetchAll($whereClause); } @@ -1329,10 +1333,10 @@ abstract class Zend_Db_Table_Abstract ); $rowsetClass = $this->getRowsetClass(); - // if (!class_exists($rowsetClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowsetClass); - // } + if (!class_exists($rowsetClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowsetClass); + } return new $rowsetClass($data); } @@ -1378,10 +1382,10 @@ abstract class Zend_Db_Table_Abstract ); $rowClass = $this->getRowClass(); - // if (!class_exists($rowClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowClass); - // } + if (!class_exists($rowClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowClass); + } return new $rowClass($data); } @@ -1441,10 +1445,10 @@ abstract class Zend_Db_Table_Abstract ); $rowClass = $this->getRowClass(); - // if (!class_exists($rowClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowClass); - // } + if (!class_exists($rowClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowClass); + } $row = new $rowClass($config); $row->setFromArray($data); return $row; diff --git a/libs/Zend/Db/Table/Definition.php b/libs/Zend/Db/Table/Definition.php index 30e601a5b1..edea0ee640 100644 --- a/libs/Zend/Db/Table/Definition.php +++ b/libs/Zend/Db/Table/Definition.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Definition.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Definition.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @@ -26,17 +26,17 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table_Definition { - + /** * @var array */ protected $_tableConfigs = array(); - + /** * __construct() * @@ -50,7 +50,7 @@ class Zend_Db_Table_Definition $this->setOptions($options); } } - + /** * setConfig() * @@ -62,7 +62,7 @@ class Zend_Db_Table_Definition $this->setOptions($config->toArray()); return $this; } - + /** * setOptions() * @@ -76,7 +76,7 @@ class Zend_Db_Table_Definition } return $this; } - + /** * @param string $tableName * @param array $tableConfig @@ -87,15 +87,15 @@ class Zend_Db_Table_Definition // @todo logic here $tableConfig[Zend_Db_Table::DEFINITION_CONFIG_NAME] = $tableName; $tableConfig[Zend_Db_Table::DEFINITION] = $this; - + if (!isset($tableConfig[Zend_Db_Table::NAME])) { $tableConfig[Zend_Db_Table::NAME] = $tableName; } - + $this->_tableConfigs[$tableName] = $tableConfig; return $this; } - + /** * getTableConfig() * @@ -106,7 +106,7 @@ class Zend_Db_Table_Definition { return $this->_tableConfigs[$tableName]; } - + /** * removeTableConfig() * @@ -116,7 +116,7 @@ class Zend_Db_Table_Definition { unset($this->_tableConfigs[$tableName]); } - + /** * hasTableConfig() * diff --git a/libs/Zend/Db/Table/Exception.php b/libs/Zend/Db/Table/Exception.php index 3757324052..2d85136109 100644 --- a/libs/Zend/Db/Table/Exception.php +++ b/libs/Zend/Db/Table/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Exception */ -// require_once 'Zend/Db/Exception.php'; +require_once 'Zend/Db/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table_Exception extends Zend_Db_Exception diff --git a/libs/Zend/Db/Table/Row.php b/libs/Zend/Db/Table/Row.php index 5e80a644c0..970c493419 100644 --- a/libs/Zend/Db/Table/Row.php +++ b/libs/Zend/Db/Table/Row.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Row.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Row.php 16203 2009-06-21 18:56:17Z thomas $ */ /** * @see Zend_Db_Table_Row_Abstract */ -// require_once 'Zend/Db/Table/Row/Abstract.php'; +require_once 'Zend/Db/Table/Row/Abstract.php'; /** @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table_Row extends Zend_Db_Table_Row_Abstract diff --git a/libs/Zend/Db/Table/Row/Abstract.php b/libs/Zend/Db/Table/Row/Abstract.php index c7243eb003..501bae171a 100644 --- a/libs/Zend/Db/Table/Row/Abstract.php +++ b/libs/Zend/Db/Table/Row/Abstract.php @@ -15,24 +15,24 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 22230 2010-05-21 20:59:18Z ralph $ + * @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Db */ -// require_once 'Zend/Db.php'; +require_once 'Zend/Db.php'; /** * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggregate +abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess { /** @@ -122,7 +122,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg if (isset($config['data'])) { if (!is_array($config['data'])) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('Data must be an array'); } $this->_data = $config['data']; @@ -157,7 +157,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg protected function _transformColumn($columnName) { if (!is_string($columnName)) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('Specified column is not a string'); } // Perform no transformation by default @@ -175,7 +175,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg { $columnName = $this->_transformColumn($columnName); if (!array_key_exists($columnName, $this->_data)) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row"); } return $this->_data[$columnName]; @@ -193,7 +193,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg { $columnName = $this->_transformColumn($columnName); if (!array_key_exists($columnName, $this->_data)) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row"); } $this->_data[$columnName] = $value; @@ -211,11 +211,11 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg { $columnName = $this->_transformColumn($columnName); if (!array_key_exists($columnName, $this->_data)) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row"); } if ($this->isConnected() && in_array($columnName, $this->_table->info('primary'))) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is a primary key and should not be unset"); } unset($this->_data[$columnName]); @@ -293,14 +293,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg } /** - * Proxy to __unset + * Does nothing * Required by the ArrayAccess implementation * * @param string $offset */ public function offsetUnset($offset) { - return $this->__unset($offset); } /** @@ -342,7 +341,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg $tableClass = get_class($table); if (! $table instanceof $this->_tableClass) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("The specified Table is of class $tableClass, expecting class to be instance of $this->_tableClass"); } @@ -352,13 +351,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg $info = $this->_table->info(); if ($info['cols'] != array_keys($this->_data)) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('The specified Table does not have the same columns as the Row'); } if (! array_intersect((array) $this->_primary, $info['primary']) == (array) $this->_primary) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("The specified Table '$tableClass' does not have the same primary key as the Row"); } @@ -451,7 +450,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg * A read-only row cannot be saved. */ if ($this->_readOnly === true) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('This row has been marked read-only'); } @@ -473,9 +472,9 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg if (is_array($primaryKey)) { $newPrimaryKey = $primaryKey; } else { - //ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails. + //ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails. $tempPrimaryKey = (array) $this->_primary; - $newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey); + $newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey); } /** @@ -509,7 +508,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg * A read-only row cannot be saved. */ if ($this->_readOnly === true) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('This row has been marked read-only'); } @@ -598,7 +597,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg * A read-only row cannot be deleted. */ if ($this->_readOnly === true) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('This row has been marked read-only'); } @@ -642,11 +641,6 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg return $result; } - public function getIterator() - { - return new ArrayIterator((array) $this->_data); - } - /** * Returns the column/value data as an array. * @@ -692,7 +686,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg protected function _getTable() { if (!$this->_connected) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('Cannot save a Row unless it is connected'); } return $this->_table; @@ -707,7 +701,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg protected function _getPrimaryKey($useDirty = true) { if (!is_array($this->_primary)) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("The primary key must be set as an array"); } @@ -718,7 +712,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg $array = array_intersect_key($this->_cleanData, $primary); } if (count($primary) != count($array)) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("The specified Table '$this->_tableClass' does not have the same primary key as the Row"); } return $array; @@ -760,7 +754,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg $row = $this->_getTable()->fetchRow($where); if (null === $row) { - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception('Cannot refresh row as parent is missing'); } @@ -871,13 +865,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg if (is_string($dependentTable)) { $dependentTable = $this->_getTableFromString($dependentTable); } - + if (!$dependentTable instanceof Zend_Db_Table_Abstract) { $type = gettype($dependentTable); if ($type == 'object') { $type = get_class($dependentTable); } - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Dependent table must be a Zend_Db_Table_Abstract, but it is $type"); } @@ -927,13 +921,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg if (is_string($parentTable)) { $parentTable = $this->_getTableFromString($parentTable); } - + if (!$parentTable instanceof Zend_Db_Table_Abstract) { $type = gettype($parentTable); if ($type == 'object') { $type = get_class($parentTable); } - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Parent table must be a Zend_Db_Table_Abstract, but it is $type"); } @@ -943,7 +937,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg && ($parentTable->getDefinition() == null)) { $parentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition)); } - + if ($select === null) { $select = $parentTable->select(); } else { @@ -961,7 +955,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg $parentColumnName = $parentDb->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]); $parentColumn = $parentDb->quoteIdentifier($parentColumnName, true); $parentInfo = $parentTable->info(); - + // determine where part $type = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['DATA_TYPE']; $nullable = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['NULLABLE']; @@ -972,7 +966,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg } else { $select->where("$parentColumn = ?", $value, $type); } - + } return $parentTable->fetchRow($select); @@ -995,13 +989,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg if (is_string($intersectionTable)) { $intersectionTable = $this->_getTableFromString($intersectionTable); } - + if (!$intersectionTable instanceof Zend_Db_Table_Abstract) { $type = gettype($intersectionTable); if ($type == 'object') { $type = get_class($intersectionTable); } - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Intersection table must be a Zend_Db_Table_Abstract, but it is $type"); } @@ -1011,17 +1005,17 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg && ($intersectionTable->getDefinition() == null)) { $intersectionTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition)); } - + if (is_string($matchTable)) { $matchTable = $this->_getTableFromString($matchTable); } - + if (! $matchTable instanceof Zend_Db_Table_Abstract) { $type = gettype($matchTable); if ($type == 'object') { $type = get_class($matchTable); } - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Match table must be a Zend_Db_Table_Abstract, but it is $type"); } @@ -1031,7 +1025,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg && ($matchTable->getDefinition() == null)) { $matchTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition)); } - + if ($select === null) { $select = $matchTable->select(); } else { @@ -1056,7 +1050,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg } $joinCond = implode(' AND ', $joinCond); - $select->from(array('i' => $interName), array(), $interSchema) + $select->from(array('i' => $interName), Zend_Db_Select::SQL_WILDCARD, $interSchema) ->joinInner(array('m' => $matchName), $joinCond, Zend_Db_Select::SQL_WILDCARD, $matchSchema) ->setIntegrityCheck(false); @@ -1083,15 +1077,15 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg ); $rowsetClass = $matchTable->getRowsetClass(); - // if (!class_exists($rowsetClass)) { - // try { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowsetClass); - // } catch (Zend_Exception $e) { - // require_once 'Zend/Db/Table/Row/Exception.php'; - // throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e); - // } - // } + if (!class_exists($rowsetClass)) { + try { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowsetClass); + } catch (Zend_Exception $e) { + require_once 'Zend/Db/Table/Row/Exception.php'; + throw new Zend_Db_Table_Row_Exception($e->getMessage()); + } + } $rowset = new $rowsetClass($config); return $rowset; } @@ -1154,7 +1148,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg return $this->findDependentRowset($class, $ruleKey1, $select); } - // require_once 'Zend/Db/Table/Row/Exception.php'; + require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception("Unrecognized method '$method()'"); } @@ -1170,29 +1164,29 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg if ($this->_table instanceof Zend_Db_Table_Abstract) { $tableDefinition = $this->_table->getDefinition(); - + if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) { return new Zend_Db_Table($tableName, $tableDefinition); - } + } } - + // assume the tableName is the class name - // if (!class_exists($tableName)) { - // try { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($tableName); - // } catch (Zend_Exception $e) { - // require_once 'Zend/Db/Table/Row/Exception.php'; - // throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e); - // } - // } + if (!class_exists($tableName)) { + try { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($tableName); + } catch (Zend_Exception $e) { + require_once 'Zend/Db/Table/Row/Exception.php'; + throw new Zend_Db_Table_Row_Exception($e->getMessage()); + } + } $options = array(); - + if (($table = $this->_getTable())) { $options['db'] = $table->getAdapter(); } - + if (isset($tableDefinition) && $tableDefinition !== null) { $options[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition; } diff --git a/libs/Zend/Db/Table/Row/Exception.php b/libs/Zend/Db/Table/Row/Exception.php index 236c4bec42..12d17febcd 100644 --- a/libs/Zend/Db/Table/Row/Exception.php +++ b/libs/Zend/Db/Table/Row/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Db_Table_Exception */ -// require_once 'Zend/Db/Table/Exception.php'; +require_once 'Zend/Db/Table/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table_Row_Exception extends Zend_Db_Table_Exception diff --git a/libs/Zend/Db/Table/Rowset.php b/libs/Zend/Db/Table/Rowset.php index 186abe14fd..b7e495d6d0 100644 --- a/libs/Zend/Db/Table/Rowset.php +++ b/libs/Zend/Db/Table/Rowset.php @@ -16,16 +16,16 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rowset.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Rowset.php 16203 2009-06-21 18:56:17Z thomas $ */ /** * @see Zend_Db_Table_Rowset_Abstract */ -// require_once 'Zend/Db/Table/Rowset/Abstract.php'; +require_once 'Zend/Db/Table/Rowset/Abstract.php'; /** @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table_Rowset extends Zend_Db_Table_Rowset_Abstract diff --git a/libs/Zend/Db/Table/Rowset/Abstract.php b/libs/Zend/Db/Table/Rowset/Abstract.php index 8cafadc91e..d9e324baf1 100644 --- a/libs/Zend/Db/Table/Rowset/Abstract.php +++ b/libs/Zend/Db/Table/Rowset/Abstract.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Countable, ArrayAccess @@ -111,10 +111,10 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta if (isset($config['rowClass'])) { $this->_rowClass = $config['rowClass']; } - // if (!class_exists($this->_rowClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($this->_rowClass); - // } + if (!class_exists($this->_rowClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($this->_rowClass); + } if (isset($config['data'])) { $this->_data = $config['data']; } @@ -321,7 +321,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta { $position = (int) $position; if ($position < 0 || $position >= $this->_count) { - // require_once 'Zend/Db/Table/Rowset/Exception.php'; + require_once 'Zend/Db/Table/Rowset/Exception.php'; throw new Zend_Db_Table_Rowset_Exception("Illegal index $position"); } $this->_pointer = $position; @@ -390,8 +390,8 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta $this->seek($position); $row = $this->current(); } catch (Zend_Db_Table_Rowset_Exception $e) { - // require_once 'Zend/Db/Table/Rowset/Exception.php'; - throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position, 0, $e); + require_once 'Zend/Db/Table/Rowset/Exception.php'; + throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position); } if ($seek == false) { $this->seek($key); diff --git a/libs/Zend/Db/Table/Rowset/Exception.php b/libs/Zend/Db/Table/Rowset/Exception.php index 8696c74e06..99b4dc54a4 100644 --- a/libs/Zend/Db/Table/Rowset/Exception.php +++ b/libs/Zend/Db/Table/Rowset/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * Zend_Db_Table_Exception */ -// require_once 'Zend/Db/Table/Exception.php'; +require_once 'Zend/Db/Table/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table_Rowset_Exception extends Zend_Db_Table_Exception diff --git a/libs/Zend/Db/Table/Select.php b/libs/Zend/Db/Table/Select.php index 699c071884..c99a5ad8de 100644 --- a/libs/Zend/Db/Table/Select.php +++ b/libs/Zend/Db/Table/Select.php @@ -16,22 +16,22 @@ * @category Zend * @package Zend_Db * @subpackage Select - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Select.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Select.php 18200 2009-09-17 21:25:37Z beberlei $ */ /** * @see Zend_Db_Select */ -// require_once 'Zend/Db/Select.php'; +require_once 'Zend/Db/Select.php'; /** * @see Zend_Db_Table_Abstract */ -// require_once 'Zend/Db/Table/Abstract.php'; +require_once 'Zend/Db/Table/Abstract.php'; /** @@ -40,7 +40,7 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Table_Select extends Zend_Db_Select @@ -195,7 +195,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select if (count($this->_parts[self::UNION]) == 0) { - + // If no fields are specified we assume all fields from primary table if (!count($fields)) { $this->from($primary, self::SQL_WILDCARD, $schema); @@ -211,7 +211,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select // Check each column to ensure it only references the primary table if ($column) { if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) { - // require_once 'Zend/Db/Table/Select/Exception.php'; + require_once 'Zend/Db/Table/Select/Exception.php'; throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table'); } } diff --git a/libs/Zend/Db/Table/Select/Exception.php b/libs/Zend/Db/Table/Select/Exception.php index ac03702c2d..886f11876e 100644 --- a/libs/Zend/Db/Table/Select/Exception.php +++ b/libs/Zend/Db/Table/Select/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Db * @subpackage Select - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * Zend_Db_Exception */ -// require_once 'Zend/Db/Select/Exception.php'; +require_once 'Zend/Db/Select/Exception.php'; /** * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/libs/Zend/Exception.php b/libs/Zend/Exception.php index bbfb792e93..3cb5704b3f 100644 --- a/libs/Zend/Exception.php +++ b/libs/Zend/Exception.php @@ -14,82 +14,18 @@ * * @category Zend * @package Zend - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ + /** -* @category Zend -* @package Zend -* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) -* @license http://framework.zend.com/license/new-bsd New BSD License -*/ + * @category Zend + * @package Zend + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ class Zend_Exception extends Exception -{ - /** - * @var null|Exception - */ - private $_previous = null; - - /** - * Construct the exception - * - * @param string $msg - * @param int $code - * @param Exception $previous - * @return void - */ - public function __construct($msg = '', $code = 0, Exception $previous = null) - { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - parent::__construct($msg, (int) $code); - $this->_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/libs/Zend/Feed.php b/libs/Zend/Feed.php index 5e4d7b0894..b8555c7ce8 100644 --- a/libs/Zend/Feed.php +++ b/libs/Zend/Feed.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Feed.php 18291 2009-09-18 21:00:51Z padraic $ */ @@ -29,7 +29,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed @@ -84,7 +84,7 @@ class Zend_Feed /** * @see Zend_Http_Client */ - // require_once 'Zend/Http/Client.php'; + require_once 'Zend/Http/Client.php'; self::$_httpClient = new Zend_Http_Client(); } @@ -173,7 +173,7 @@ class Zend_Feed /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus()); } $feed = $response->getBody(); @@ -194,7 +194,7 @@ class Zend_Feed $libxml_errflag = libxml_use_internal_errors(true); $doc = new DOMDocument; if (trim($string) == '') { - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Document/string being imported' . ' is an Empty string or comes from an empty HTTP response'); } @@ -216,7 +216,7 @@ class Zend_Feed /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception($errormsg); } @@ -226,7 +226,7 @@ class Zend_Feed /** * @see Zend_Feed_Atom */ - // require_once 'Zend/Feed/Atom.php'; + require_once 'Zend/Feed/Atom.php'; // return a newly created Zend_Feed_Atom object return new Zend_Feed_Atom(null, $string); } @@ -236,7 +236,7 @@ class Zend_Feed /** * @see Zend_Feed_Rss */ - // require_once 'Zend/Feed/Rss.php'; + require_once 'Zend/Feed/Rss.php'; // return a newly created Zend_Feed_Rss object return new Zend_Feed_Rss(null, $string); } @@ -245,7 +245,7 @@ class Zend_Feed /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Invalid or unsupported feed format'); } @@ -266,7 +266,7 @@ class Zend_Feed /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("File could not be loaded: $php_errormsg"); } return self::importString($feed); @@ -293,7 +293,7 @@ class Zend_Feed /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("Failed to access $uri, got response code " . $response->getStatus()); } $contents = $response->getBody(); @@ -307,7 +307,7 @@ class Zend_Feed /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("Internal error: $php_errormsg"); } @@ -380,15 +380,15 @@ class Zend_Feed public static function importArray(array $data, $format = 'atom') { $obj = 'Zend_Feed_' . ucfirst(strtolower($format)); - // if (!class_exists($obj)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($obj); - // } + if (!class_exists($obj)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($obj); + } /** * @see Zend_Feed_Builder */ - // require_once 'Zend/Feed/Builder.php'; + require_once 'Zend/Feed/Builder.php'; return new $obj(null, null, new Zend_Feed_Builder($data)); } @@ -402,10 +402,10 @@ class Zend_Feed public static function importBuilder(Zend_Feed_Builder_Interface $builder, $format = 'atom') { $obj = 'Zend_Feed_' . ucfirst(strtolower($format)); - // if (!class_exists($obj)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($obj); - // } + if (!class_exists($obj)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($obj); + } return new $obj(null, null, $builder); } } diff --git a/libs/Zend/Feed/Abstract.php b/libs/Zend/Feed/Abstract.php index 8cd77dee7c..ce59dc0793 100644 --- a/libs/Zend/Feed/Abstract.php +++ b/libs/Zend/Feed/Abstract.php @@ -15,16 +15,16 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 18293 2009-09-18 22:16:07Z padraic $ */ /** * @see Zend_Feed_Element */ -// require_once 'Zend/Feed/Element.php'; +require_once 'Zend/Feed/Element.php'; /** @@ -37,7 +37,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator, Countable @@ -77,10 +77,10 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator, $client->setUri($uri); $response = $client->request('GET'); if ($response->getStatus() !== 200) { - /** + /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus()); } $this->_element = $response->getBody(); @@ -123,11 +123,11 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator, $php_errormsg = '(error message not available)'; } } - - /** + + /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("DOMDocument cannot parse XML: $php_errormsg"); } diff --git a/libs/Zend/Feed/Atom.php b/libs/Zend/Feed/Atom.php index 8a723f862d..db0055c5c2 100644 --- a/libs/Zend/Feed/Atom.php +++ b/libs/Zend/Feed/Atom.php @@ -15,21 +15,21 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Atom.php 16205 2009-06-21 19:08:45Z thomas $ */ /** * @see Zend_Feed_Abstract */ -// require_once 'Zend/Feed/Abstract.php'; +require_once 'Zend/Feed/Abstract.php'; /** * @see Zend_Feed_Entry_Atom */ -// require_once 'Zend/Feed/Entry/Atom.php'; +require_once 'Zend/Feed/Entry/Atom.php'; /** @@ -44,7 +44,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Atom extends Zend_Feed_Abstract @@ -89,10 +89,10 @@ class Zend_Feed_Atom extends Zend_Feed_Abstract // Try to find a single <entry> instead. $element = $this->_element->getElementsByTagName($this->_entryElementName)->item(0); if (!$element) { - /** + /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('No root <feed> or <' . $this->_entryElementName . '> element found, cannot parse feed.'); } @@ -376,10 +376,10 @@ class Zend_Feed_Atom extends Zend_Feed_Abstract public function send() { if (headers_sent()) { - /** + /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Cannot send ATOM because headers have already been sent.'); } diff --git a/libs/Zend/Feed/Builder.php b/libs/Zend/Feed/Builder.php index a9517ce5be..a0adbb1643 100644 --- a/libs/Zend/Feed/Builder.php +++ b/libs/Zend/Feed/Builder.php @@ -15,26 +15,26 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Builder.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Builder.php 16205 2009-06-21 19:08:45Z thomas $ */ /** * @see Zend_Feed_Builder_Interface */ -// require_once 'Zend/Feed/Builder/Interface.php'; +require_once 'Zend/Feed/Builder/Interface.php'; /** * @see Zend_Feed_Builder_Header */ -// require_once 'Zend/Feed/Builder/Header.php'; +require_once 'Zend/Feed/Builder/Header.php'; /** * @see Zend_Feed_Builder_Entry */ -// require_once 'Zend/Feed/Builder/Entry.php'; +require_once 'Zend/Feed/Builder/Entry.php'; /** @@ -44,7 +44,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface @@ -212,7 +212,7 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface * @throws Zend_Feed_Builder_Exception * @return void */ - protected function _createHeader(array $data) + private function _createHeader(array $data) { $mandatories = array('title', 'link', 'charset'); foreach ($mandatories as $mandatory) { @@ -220,7 +220,7 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$mandatory key is missing"); } } @@ -268,7 +268,7 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to define $mandatory property of your cloud"); } } @@ -282,7 +282,7 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to define $mandatory property of your textInput"); } } @@ -340,7 +340,7 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface * @throws Zend_Feed_Builder_Exception * @return void */ - protected function _createEntries(array $data) + private function _createEntries(array $data) { foreach ($data as $row) { $mandatories = array('title', 'link', 'description'); @@ -349,7 +349,7 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$mandatory key is missing"); } } @@ -379,7 +379,7 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$mandatory key of source property is missing"); } } @@ -395,4 +395,4 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface $this->_entries[] = $entry; } } -} +}
\ No newline at end of file diff --git a/libs/Zend/Feed/Builder/Entry.php b/libs/Zend/Feed/Builder/Entry.php index 6e7edc67b0..e428928717 100644 --- a/libs/Zend/Feed/Builder/Entry.php +++ b/libs/Zend/Feed/Builder/Entry.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 16205 2009-06-21 19:08:45Z thomas $ */ @@ -29,7 +29,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Builder_Entry extends ArrayObject @@ -224,7 +224,7 @@ class Zend_Feed_Builder_Entry extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to define the name of the category"); } @@ -263,7 +263,7 @@ class Zend_Feed_Builder_Entry extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to supply an url for your enclosure"); } $type = isset($enclosure['type']) ? $enclosure['type'] : ''; diff --git a/libs/Zend/Feed/Builder/Exception.php b/libs/Zend/Feed/Builder/Exception.php index 9037cc891a..b213ceb42b 100644 --- a/libs/Zend/Feed/Builder/Exception.php +++ b/libs/Zend/Feed/Builder/Exception.php @@ -15,16 +15,16 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16205 2009-06-21 19:08:45Z thomas $ */ /** * @see Zend_Feed_Exception */ -// require_once 'Zend/Feed/Exception.php'; +require_once 'Zend/Feed/Exception.php'; /** @@ -32,7 +32,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Builder_Exception extends Zend_Feed_Exception diff --git a/libs/Zend/Feed/Builder/Header.php b/libs/Zend/Feed/Builder/Header.php index 51a57953f2..a234377a15 100644 --- a/libs/Zend/Feed/Builder/Header.php +++ b/libs/Zend/Feed/Builder/Header.php @@ -15,20 +15,20 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Header.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Header.php 16205 2009-06-21 19:08:45Z thomas $ */ /** * @see Zend_Feed_Builder_Header_Itunes */ -// require_once 'Zend/Feed/Builder/Header/Itunes.php'; +require_once 'Zend/Feed/Builder/Header/Itunes.php'; /** * @see Zend_Uri */ -// require_once 'Zend/Uri.php'; +require_once 'Zend/Uri.php'; /** @@ -39,7 +39,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Builder_Header extends ArrayObject @@ -172,13 +172,13 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Validate_EmailAddress */ - // require_once 'Zend/Validate/EmailAddress.php'; + require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($email)) { /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the email property"); } $this->offsetSet('email', $email); @@ -246,13 +246,13 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Validate_EmailAddress */ - // require_once 'Zend/Validate/EmailAddress.php'; + require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($webmaster)) { /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the webmaster property"); } $this->offsetSet('webmaster', $webmaster); @@ -272,13 +272,13 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Validate_Int */ - // require_once 'Zend/Validate/Int.php'; + require_once 'Zend/Validate/Int.php'; $validate = new Zend_Validate_Int(); if (!$validate->isValid($ttl)) { /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set an integer value to the ttl property"); } $this->offsetSet('ttl', $ttl); @@ -317,7 +317,7 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception('Passed parameter is not a valid HTTP URI'); } if (!$uri->getPort()) { @@ -362,7 +362,7 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you can not have more than 24 rows in the skipHours property"); } foreach ($hours as $hour) { @@ -370,7 +370,7 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$hour has te be between 0 and 23"); } } @@ -392,7 +392,7 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you can not have more than 7 days in the skipDays property"); } $valid = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); @@ -401,7 +401,7 @@ class Zend_Feed_Builder_Header extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$day is not a valid day"); } } diff --git a/libs/Zend/Feed/Builder/Header/Itunes.php b/libs/Zend/Feed/Builder/Header/Itunes.php index 9445460c07..cbb443bbae 100644 --- a/libs/Zend/Feed/Builder/Header/Itunes.php +++ b/libs/Zend/Feed/Builder/Header/Itunes.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Itunes.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Itunes.php 16205 2009-06-21 19:08:45Z thomas $ */ @@ -28,7 +28,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Builder_Header_Itunes extends ArrayObject @@ -66,14 +66,14 @@ class Zend_Feed_Builder_Header_Itunes extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set at least one itunes category"); } if ($nb > 3) { /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set at most three itunes categories"); } foreach ($categories as $i => $category) { @@ -81,7 +81,7 @@ class Zend_Feed_Builder_Header_Itunes extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set the main category (category #$i)"); } } @@ -112,16 +112,16 @@ class Zend_Feed_Builder_Header_Itunes extends ArrayObject public function setOwner($name = '', $email = '') { if (!empty($email)) { - /** - * @see Zend_Validate_EmailAddress - */ - // require_once 'Zend/Validate/EmailAddress.php'; + /** + * @see Zend_Validate_EmailAddress + */ + require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($email)) { /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the itunes owner's email property"); } } @@ -182,7 +182,7 @@ class Zend_Feed_Builder_Header_Itunes extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set yes or no to the itunes block property"); } $this->offsetSet('block', $block); @@ -203,7 +203,7 @@ class Zend_Feed_Builder_Header_Itunes extends ArrayObject /** * @see Zend_Feed_Builder_Exception */ - // require_once 'Zend/Feed/Builder/Exception.php'; + require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set yes, no or clean to the itunes explicit property"); } $this->offsetSet('explicit', $explicit); diff --git a/libs/Zend/Feed/Builder/Interface.php b/libs/Zend/Feed/Builder/Interface.php index 9dce55f815..a3cce7e018 100644 --- a/libs/Zend/Feed/Builder/Interface.php +++ b/libs/Zend/Feed/Builder/Interface.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16205 2009-06-21 19:08:45Z thomas $ */ @@ -29,7 +29,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Feed_Builder_Interface diff --git a/libs/Zend/Feed/Element.php b/libs/Zend/Feed/Element.php index b7a8e632f2..2f0337d54f 100644 --- a/libs/Zend/Feed/Element.php +++ b/libs/Zend/Feed/Element.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Element.php 20104 2010-01-06 21:26:01Z matthew $ + * @version $Id: Element.php 18568 2009-10-16 11:59:55Z sgehrig $ */ @@ -26,7 +26,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Element implements ArrayAccess @@ -38,11 +38,6 @@ class Zend_Feed_Element implements ArrayAccess protected $_element; /** - * @var string Character encoding to utilize - */ - protected $_encoding = 'UTF-8'; - - /** * @var Zend_Feed_Element */ protected $_parentElement; @@ -153,27 +148,6 @@ class Zend_Feed_Element implements ArrayAccess return $this->_element->ownerDocument->saveXML($this->_element); } - /** - * Get encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set encoding - * - * @param string $value Encoding to use - * @return Zend_Feed_Element - */ - public function setEncoding($value) - { - $this->_encoding = (string) $value; - return $this; - } /** * Map variable access onto the underlying entry representation. @@ -231,18 +205,18 @@ class Zend_Feed_Element implements ArrayAccess if (strpos($var, ':') !== false) { list($ns, $elt) = explode(':', $var, 2); $node = $this->_element->ownerDocument->createElementNS(Zend_Feed::lookupNamespace($ns), - $var, htmlspecialchars($val, ENT_NOQUOTES, $this->getEncoding())); + $var, htmlspecialchars($val, ENT_NOQUOTES, 'UTF-8')); $this->_element->appendChild($node); } else { $node = $this->_element->ownerDocument->createElement($var, - htmlspecialchars($val, ENT_NOQUOTES, $this->getEncoding())); + htmlspecialchars($val, ENT_NOQUOTES, 'UTF-8')); $this->_element->appendChild($node); } } elseif (count($nodes) > 1) { - /** + /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Cannot set the value of multiple tags simultaneously.'); } else { $nodes[0]->nodeValue = $val; diff --git a/libs/Zend/Feed/Entry/Abstract.php b/libs/Zend/Feed/Entry/Abstract.php index 60c10cc89a..ba82f1fca1 100644 --- a/libs/Zend/Feed/Entry/Abstract.php +++ b/libs/Zend/Feed/Entry/Abstract.php @@ -15,21 +15,21 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 16205 2009-06-21 19:08:45Z thomas $ */ /** * @see Zend_Feed */ -// require_once 'Zend/Feed.php'; +require_once 'Zend/Feed.php'; /** * @see Zend_Feed_Element */ -// require_once 'Zend/Feed/Element.php'; +require_once 'Zend/Feed/Element.php'; /** @@ -38,7 +38,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Feed_Entry_Abstract extends Zend_Feed_Element @@ -93,19 +93,19 @@ abstract class Zend_Feed_Entry_Abstract extends Zend_Feed_Element } } - /** + /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("DOMDocument cannot parse XML: $php_errormsg"); } $element = $doc->getElementsByTagName($this->_rootElement)->item(0); if (!$element) { - /** + /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.'); } } else { diff --git a/libs/Zend/Feed/Entry/Atom.php b/libs/Zend/Feed/Entry/Atom.php index 01a17232eb..7cbfce2c0e 100644 --- a/libs/Zend/Feed/Entry/Atom.php +++ b/libs/Zend/Feed/Entry/Atom.php @@ -15,16 +15,16 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Atom.php 18184 2009-09-17 18:26:40Z padraic $ */ /** * @see Zend_Feed_Entry_Abstract */ -// require_once 'Zend/Feed/Entry/Abstract.php'; +require_once 'Zend/Feed/Entry/Abstract.php'; /** @@ -32,15 +32,15 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract { - /** - * Content-Type - */ - const CONTENT_TYPE = 'application/atom+xml'; + /** + * Content-Type + */ + const CONTENT_TYPE = 'application/atom+xml'; /** * Root XML element for Atom entries. @@ -79,7 +79,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Cannot delete entry; no link rel="edit" is present.'); } @@ -107,7 +107,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("Expected response code 2xx, got $httpStatus"); } } while (true); @@ -144,7 +144,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Cannot edit entry; no link rel="edit" is present.'); } @@ -164,7 +164,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Expected response code 200, got ' . $response->getStatus()); } } else { @@ -172,7 +172,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('PostURI must be specified to save new entries.'); } $client = Zend_Feed::getHttpClient(); @@ -185,7 +185,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Expected response code 201, got ' . $response->getStatus()); } @@ -210,7 +210,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('XML cannot be parsed: ' . $php_errormsg); } @@ -219,7 +219,7 @@ class Zend_Feed_Entry_Atom extends Zend_Feed_Entry_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('No root <feed> element found in server response:' . "\n\n" . $client->responseBody); } diff --git a/libs/Zend/Feed/Entry/Rss.php b/libs/Zend/Feed/Entry/Rss.php index a03fe8052e..464601b5e7 100644 --- a/libs/Zend/Feed/Entry/Rss.php +++ b/libs/Zend/Feed/Entry/Rss.php @@ -15,16 +15,16 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Rss.php 16205 2009-06-21 19:08:45Z thomas $ */ /** * @see Zend_Feed_Entry_Abstract */ -// require_once 'Zend/Feed/Entry/Abstract.php'; +require_once 'Zend/Feed/Entry/Abstract.php'; /** @@ -32,7 +32,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Entry_Rss extends Zend_Feed_Entry_Abstract @@ -98,7 +98,7 @@ class Zend_Feed_Entry_Rss extends Zend_Feed_Entry_Abstract return parent::__isset($var); } } - + /** * Overwrites parent::_call method to enable read access * to content:encoded element. diff --git a/libs/Zend/Feed/Exception.php b/libs/Zend/Feed/Exception.php index 1142c88a00..c77bb35495 100644 --- a/libs/Zend/Feed/Exception.php +++ b/libs/Zend/Feed/Exception.php @@ -15,16 +15,16 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16205 2009-06-21 19:08:45Z thomas $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** @@ -34,7 +34,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Exception extends Zend_Exception diff --git a/libs/Zend/Feed/Pubsubhubbub.php b/libs/Zend/Feed/Pubsubhubbub.php deleted file mode 100644 index eeffd74218..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Http_Client - */ -// require_once 'Zend/Http/Client.php'; - -/** - * @see Zend_Uri - */ -// require_once 'Zend/Uri.php'; - -/** - * @see Zend_Version - */ -// require_once 'Zend/Version.php'; - -/** - * @see Zend_Feed_Reader - */ -// require_once 'Zend/Feed/Reader.php'; - -/** - * @see Zend_Feed_Abstract - */ -// require_once 'Zend/Feed/Abstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub -{ - /** - * Verification Modes - */ - const VERIFICATION_MODE_SYNC = 'sync'; - const VERIFICATION_MODE_ASYNC = 'async'; - - /** - * Subscription States - */ - const SUBSCRIPTION_VERIFIED = 'verified'; - const SUBSCRIPTION_NOTVERIFIED = 'not_verified'; - const SUBSCRIPTION_TODELETE = 'to_delete'; - - /** - * Singleton instance if required of the HTTP client - * - * @var Zend_Http_Client - */ - protected static $httpClient = null; - - /** - * Simple utility function which imports any feed URL and - * determines the existence of Hub Server endpoints. This works - * best if directly given an instance of Zend_Feed_Reader_Atom|Rss - * to leverage off. - * - * @param Zend_Feed_Reader_FeedAbstract|Zend_Feed_Abstract|string $source - * @return array - */ - public static function detectHubs($source) - { - if (is_string($source)) { - $feed = Zend_Feed_Reader::import($source); - } elseif (is_object($source) && $source instanceof Zend_Feed_Reader_FeedAbstract) { - $feed = $source; - } elseif (is_object($source) && $source instanceof Zend_Feed_Abstract) { - $feed = Zend_Feed_Reader::importFeed($source); - } else { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('The source parameter was' - . ' invalid, i.e. not a URL string or an instance of type' - . ' Zend_Feed_Reader_FeedAbstract or Zend_Feed_Abstract'); - } - return $feed->getHubs(); - } - - /** - * Allows the external environment to make Zend_Oauth use a specific - * Client instance. - * - * @param Zend_Http_Client $httpClient - * @return void - */ - public static function setHttpClient(Zend_Http_Client $httpClient) - { - self::$httpClient = $httpClient; - } - - /** - * Return the singleton instance of the HTTP Client. Note that - * the instance is reset and cleared of previous parameters GET/POST. - * Headers are NOT reset but handled by this component if applicable. - * - * @return Zend_Http_Client - */ - public static function getHttpClient() - { - if (!isset(self::$httpClient)): - self::$httpClient = new Zend_Http_Client; - else: - self::$httpClient->resetParameters(); - endif; - return self::$httpClient; - } - - /** - * Simple mechanism to delete the entire singleton HTTP Client instance - * which forces an new instantiation for subsequent requests. - * - * @return void - */ - public static function clearHttpClient() - { - self::$httpClient = null; - } - - /** - * RFC 3986 safe url encoding method - * - * @param string $string - * @return string - */ - public static function urlencode($string) - { - $rawencoded = rawurlencode($string); - $rfcencoded = str_replace('%7E', '~', $rawencoded); - return $rfcencoded; - } -} diff --git a/libs/Zend/Feed/Pubsubhubbub/CallbackAbstract.php b/libs/Zend/Feed/Pubsubhubbub/CallbackAbstract.php deleted file mode 100644 index 2fae31b831..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/CallbackAbstract.php +++ /dev/null @@ -1,307 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Callback - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Feed_Pubsubhubbub_CallbackInterface - */ -// require_once 'Zend/Feed/Pubsubhubbub/CallbackInterface.php'; - -/** - * @see Zend_Feed_Pubsubhubbub_HttpResponse - */ -// require_once 'Zend/Feed/Pubsubhubbub/HttpResponse.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Callback - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Feed_Pubsubhubbub_CallbackAbstract - implements Zend_Feed_Pubsubhubbub_CallbackInterface -{ - /** - * An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used - * to background save any verification tokens associated with a subscription - * or other. - * - * @var Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface - */ - protected $_storage = null; - - /** - * An instance of a class handling Http Responses. This is implemented in - * Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with - * (i.e. not inherited from) Zend_Controller_Response_Http. - * - * @var Zend_Feed_Pubsubhubbub_HttpResponse|Zend_Controller_Response_Http - */ - protected $_httpResponse = null; - - /** - * The number of Subscribers for which any updates are on behalf of. - * - * @var int - */ - protected $_subscriberCount = 1; - - /** - * Constructor; accepts an array or Zend_Config instance to preset - * options for the Subscriber without calling all supported setter - * methods in turn. - * - * @param array|Zend_Config $options Options array or Zend_Config instance - */ - public function __construct($config = null) - { - if (!is_null($config)) { - $this->setConfig($config); - } - } - - /** - * Process any injected configuration options - * - * @param array|Zend_Config $options Options array or Zend_Config instance - * @return Zend_Feed_Pubsubhubbub_CallbackAbstract - */ - public function setConfig($config) - { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } elseif (!is_array($config)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Array or Zend_Config object' - . 'expected, got ' . gettype($config)); - } - if (array_key_exists('storage', $config)) { - $this->setStorage($config['storage']); - } - return $this; - } - - /** - * Send the response, including all headers. - * If you wish to handle this via Zend_Controller, use the getter methods - * to retrieve any data needed to be set on your HTTP Response object, or - * simply give this object the HTTP Response instance to work with for you! - * - * @return void - */ - public function sendResponse() - { - $this->getHttpResponse()->sendResponse(); - } - - /** - * Sets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used - * to background save any verification tokens associated with a subscription - * or other. - * - * @param Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage - * @return Zend_Feed_Pubsubhubbub_CallbackAbstract - */ - public function setStorage(Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage) - { - $this->_storage = $storage; - return $this; - } - - /** - * Gets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used - * to background save any verification tokens associated with a subscription - * or other. - * - * @return Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface - */ - public function getStorage() - { - if ($this->_storage === null) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('No storage object has been' - . ' set that subclasses Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface'); - } - return $this->_storage; - } - - /** - * An instance of a class handling Http Responses. This is implemented in - * Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with - * (i.e. not inherited from) Zend_Controller_Response_Http. - * - * @param Zend_Feed_Pubsubhubbub_HttpResponse|Zend_Controller_Response_Http $httpResponse - * @return Zend_Feed_Pubsubhubbub_CallbackAbstract - */ - public function setHttpResponse($httpResponse) - { - if (!is_object($httpResponse) - || (!$httpResponse instanceof Zend_Feed_Pubsubhubbub_HttpResponse - && !$httpResponse instanceof Zend_Controller_Response_Http) - ) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('HTTP Response object must' - . ' implement one of Zend_Feed_Pubsubhubbub_HttpResponse or' - . ' Zend_Controller_Response_Http'); - } - $this->_httpResponse = $httpResponse; - return $this; - } - - /** - * An instance of a class handling Http Responses. This is implemented in - * Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with - * (i.e. not inherited from) Zend_Controller_Response_Http. - * - * @return Zend_Feed_Pubsubhubbub_HttpResponse|Zend_Controller_Response_Http - */ - public function getHttpResponse() - { - if ($this->_httpResponse === null) { - $this->_httpResponse = new Zend_Feed_Pubsubhubbub_HttpResponse; - } - return $this->_httpResponse; - } - - /** - * Sets the number of Subscribers for which any updates are on behalf of. - * In other words, is this class serving one or more subscribers? How many? - * Defaults to 1 if left unchanged. - * - * @param string|int $count - * @return Zend_Feed_Pubsubhubbub_CallbackAbstract - */ - public function setSubscriberCount($count) - { - $count = intval($count); - if ($count <= 0) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Subscriber count must be' - . ' greater than zero'); - } - $this->_subscriberCount = $count; - return $this; - } - - /** - * Gets the number of Subscribers for which any updates are on behalf of. - * In other words, is this class serving one or more subscribers? How many? - * - * @return int - */ - public function getSubscriberCount() - { - return $this->_subscriberCount; - } - - /** - * Attempt to detect the callback URL (specifically the path forward) - */ - protected function _detectCallbackUrl() - { - $callbackUrl = ''; - if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { - $callbackUrl = $_SERVER['HTTP_X_REWRITE_URL']; - } elseif (isset($_SERVER['REQUEST_URI'])) { - $callbackUrl = $_SERVER['REQUEST_URI']; - $scheme = 'http'; - if ($_SERVER['HTTPS'] == 'on') { - $scheme = 'https'; - } - $schemeAndHttpHost = $scheme . '://' . $this->_getHttpHost(); - if (strpos($callbackUrl, $schemeAndHttpHost) === 0) { - $callbackUrl = substr($callbackUrl, strlen($schemeAndHttpHost)); - } - } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { - $callbackUrl= $_SERVER['ORIG_PATH_INFO']; - if (!empty($_SERVER['QUERY_STRING'])) { - $callbackUrl .= '?' . $_SERVER['QUERY_STRING']; - } - } - return $callbackUrl; - } - - /** - * Get the HTTP host - * - * @return string - */ - protected function _getHttpHost() - { - if (!empty($_SERVER['HTTP_HOST'])) { - return $_SERVER['HTTP_HOST']; - } - $scheme = 'http'; - if ($_SERVER['HTTPS'] == 'on') { - $scheme = 'https'; - } - $name = $_SERVER['SERVER_NAME']; - $port = $_SERVER['SERVER_PORT']; - if (($scheme == 'http' && $port == 80) - || ($scheme == 'https' && $port == 443) - ) { - return $name; - } else { - return $name . ':' . $port; - } - } - - /** - * Retrieve a Header value from either $_SERVER or Apache - * - * @param string $header - */ - protected function _getHeader($header) - { - $temp = strtoupper(str_replace('-', '_', $header)); - if (!empty($_SERVER[$temp])) { - return $_SERVER[$temp]; - } - $temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header)); - if (!empty($_SERVER[$temp])) { - return $_SERVER[$temp]; - } - if (function_exists('apache_request_headers')) { - $headers = apache_request_headers(); - if (!empty($headers[$header])) { - return $headers[$header]; - } - } - return false; - } - - /** - * Return the raw body of the request - * - * @return string|false Raw body, or false if not present - */ - protected function _getRawBody() - { - $body = file_get_contents('php://input'); - if (strlen(trim($body)) == 0 && isset($GLOBALS['HTTP_RAW_POST_DATA'])) { - $body = $GLOBALS['HTTP_RAW_POST_DATA']; - } - if (strlen(trim($body)) > 0) { - return $body; - } - return false; - } -} diff --git a/libs/Zend/Feed/Pubsubhubbub/CallbackInterface.php b/libs/Zend/Feed/Pubsubhubbub/CallbackInterface.php deleted file mode 100644 index ce30a6bb23..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/CallbackInterface.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Callback - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Callback - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Feed_Pubsubhubbub_CallbackInterface -{ - /** - * Handle any callback from a Hub Server responding to a subscription or - * unsubscription request. This should be the Hub Server confirming the - * the request prior to taking action on it. - * - * @param array $httpData GET/POST data if available and not in $_GET/POST - * @param bool $sendResponseNow Whether to send response now or when asked - */ - public function handle(array $httpData = null, $sendResponseNow = false); - - /** - * Send the response, including all headers. - * If you wish to handle this via Zend_Controller, use the getter methods - * to retrieve any data needed to be set on your HTTP Response object, or - * simply give this object the HTTP Response instance to work with for you! - * - * @return void - */ - public function sendResponse(); - - /** - * An instance of a class handling Http Responses. This is implemented in - * Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with - * (i.e. not inherited from) Zend_Controller_Response_Http. - * - * @param Zend_Feed_Pubsubhubbub_HttpResponse|Zend_Controller_Response_Http $httpResponse - */ - public function setHttpResponse($httpResponse); - - /** - * An instance of a class handling Http Responses. This is implemented in - * Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with - * (i.e. not inherited from) Zend_Controller_Response_Http. - * - * @return Zend_Feed_Pubsubhubbub_HttpResponse|Zend_Controller_Response_Http - */ - public function getHttpResponse(); -} diff --git a/libs/Zend/Feed/Pubsubhubbub/Exception.php b/libs/Zend/Feed/Pubsubhubbub/Exception.php deleted file mode 100644 index 5bc562c94e..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/Exception.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Exception - */ -// require_once 'Zend/Exception.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub_Exception extends Zend_Exception -{} diff --git a/libs/Zend/Feed/Pubsubhubbub/HttpResponse.php b/libs/Zend/Feed/Pubsubhubbub/HttpResponse.php deleted file mode 100644 index e44f0eb86a..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/HttpResponse.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Feed_Pubsubhubbub - */ -// require_once 'Zend/Feed/Pubsubhubbub.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub_HttpResponse -{ - /** - * The body of any response to the current callback request - * - * @var string - */ - protected $_body = ''; - - /** - * Array of headers. Each header is an array with keys 'name' and 'value' - * - * @var array - */ - protected $_headers = array(); - - /** - * HTTP response code to use in headers - * - * @var int - */ - protected $_httpResponseCode = 200; - - /** - * Send the response, including all headers - * - * @return void - */ - public function sendResponse() - { - $this->sendHeaders(); - echo $this->getBody(); - } - - /** - * 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 void - */ - public function sendHeaders() - { - if (count($this->_headers) || (200 != $this->_httpResponseCode)) { - $this->canSendHeaders(true); - } elseif (200 == $this->_httpResponseCode) { - return; - } - $httpCodeSent = false; - 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; - } - } - - /** - * Set a header - * - * If $replace is true, replaces any headers already defined with that - * $name. - * - * @param string $name - * @param string $value - * @param boolean $replace - * @return Zend_Feed_Pubsubhubbub_HttpResponse - */ - public function setHeader($name, $value, $replace = false) - { - $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; - } - - /** - * Check if a specific Header is set and return its value - * - * @param string $name - * @return string|null - */ - public function getHeader($name) - { - $name = $this->_normalizeHeader($name); - foreach ($this->_headers as $header) { - if ($header['name'] == $name) { - return $header['value']; - } - } - } - - /** - * Return array of headers; see {@link $_headers} for format - * - * @return array - */ - public function getHeaders() - { - return $this->_headers; - } - - /** - * 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_Feed_Pubsubhubbub_Exception - */ - public function canSendHeaders($throw = false) - { - $ok = headers_sent($file, $line); - if ($ok && $throw) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Cannot send headers; headers already sent in ' . $file . ', line ' . $line); - } - return !$ok; - } - - /** - * Set HTTP response code to use with headers - * - * @param int $code - * @return Zend_Feed_Pubsubhubbub_HttpResponse - */ - public function setHttpResponseCode($code) - { - if (!is_int($code) || (100 > $code) || (599 < $code)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid HTTP response' - . ' code:' . $code); - } - $this->_httpResponseCode = $code; - return $this; - } - - /** - * Retrieve HTTP response code - * - * @return int - */ - public function getHttpResponseCode() - { - return $this->_httpResponseCode; - } - - /** - * Set body content - * - * @param string $content - * @return Zend_Feed_Pubsubhubbub_HttpResponse - */ - public function setBody($content) - { - $this->_body = (string) $content; - $this->setHeader('content-length', strlen($content)); - return $this; - } - - /** - * Return the body content - * - * @return string - */ - public function getBody() - { - return $this->_body; - } - - /** - * Normalizes a header name to X-Capitalized-Names - * - * @param string $name - * @return string - */ - protected function _normalizeHeader($name) - { - $filtered = str_replace(array('-', '_'), ' ', (string) $name); - $filtered = ucwords(strtolower($filtered)); - $filtered = str_replace(' ', '-', $filtered); - return $filtered; - } -} diff --git a/libs/Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php b/libs/Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php deleted file mode 100644 index eab4b56322..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - -/** @see Zend_Db_Table */ -// require_once 'Zend/Db/Table.php'; - -/** - * @see Zend_Registry - * Seems to fix the file not being included by Zend_Db_Table... - */ -// require_once 'Zend/Registry.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub_Model_ModelAbstract -{ - /** - * Zend_Db_Table instance to host database methods - * - * @var Zend_Db_Table - */ - protected $_db = null; - - /** - * Constructor - * - * @param array $data - * @param Zend_Db_Table_Abstract $tableGateway - * @return void - */ - public function __construct(Zend_Db_Table_Abstract $tableGateway = null) - { - if (is_null($tableGateway)) { - $parts = explode('_', get_class($this)); - $table = strtolower(array_pop($parts)); - $this->_db = new Zend_Db_Table($table); - } else { - $this->_db = $tableGateway; - } - } - -} diff --git a/libs/Zend/Feed/Pubsubhubbub/Model/Subscription.php b/libs/Zend/Feed/Pubsubhubbub/Model/Subscription.php deleted file mode 100644 index ea971b4f77..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/Model/Subscription.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Entity - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** @see Zend_Feed_Pubsubhubbub_Model_ModelAbstract */ -// require_once 'Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php'; - -/** @see Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface */ -// require_once 'Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Entity - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub_Model_Subscription - extends Zend_Feed_Pubsubhubbub_Model_ModelAbstract - implements Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface -{ - - /** - * Save subscription to RDMBS - * - * @param array $data - * @return bool - */ - public function setSubscription(array $data) - { - if (!isset($data['id'])) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception( - 'ID must be set before attempting a save' - ); - } - $result = $this->_db->find($data['id']); - if ($result) { - $data['created_time'] = $result->current()->created_time; - $now = new Zend_Date; - if ($data['lease_seconds']) { - $data['expiration_time'] = $now->add($data['lease_seconds'], Zend_Date::SECOND) - ->get('yyyy-MM-dd HH:mm:ss'); - } - $this->_db->update( - $data, - $this->_db->getAdapter()->quoteInto('id = ?', $data['id']) - ); - return false; - } - - $this->_db->insert($data); - return true; - } - - /** - * Get subscription by ID/key - * - * @param string $key - * @return array - */ - public function getSubscription($key) - { - if (empty($key) || !is_string($key)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "key"' - .' of "' . $key . '" must be a non-empty string'); - } - $result = $this->_db->find($key); - if ($result) { - return (array) $result->current(); - } - return false; - } - - /** - * Determine if a subscription matching the key exists - * - * @param string $key - * @return bool - */ - public function hasSubscription($key) - { - if (empty($key) || !is_string($key)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "key"' - .' of "' . $key . '" must be a non-empty string'); - } - $result = $this->_db->find($key); - if ($result) { - return true; - } - return false; - } - - /** - * Delete a subscription - * - * @param string $key - * @return bool - */ - public function deleteSubscription($key) - { - $result = $this->_db->find($key); - if ($result) { - $this->_db->delete( - $this->_db->getAdapter()->quoteInto('id = ?', $key) - ); - return true; - } - return false; - } - -} diff --git a/libs/Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php b/libs/Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php deleted file mode 100644 index f8a6e6a3e3..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Entity - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @subpackage Entity - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface -{ - - /** - * Save subscription to RDMBS - * - * @param array $data The key must be stored here as a $data['id'] entry - * @return bool - */ - public function setSubscription(array $data); - - /** - * Get subscription by ID/key - * - * @param string $key - * @return array - */ - public function getSubscription($key); - - /** - * Determine if a subscription matching the key exists - * - * @param string $key - * @return bool - */ - public function hasSubscription($key); - - /** - * Delete a subscription - * - * @param string $key - * @return bool - */ - public function deleteSubscription($key); - -} diff --git a/libs/Zend/Feed/Pubsubhubbub/Publisher.php b/libs/Zend/Feed/Pubsubhubbub/Publisher.php deleted file mode 100644 index dfc388beca..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/Publisher.php +++ /dev/null @@ -1,417 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Feed_Pubsubhubbub - */ -// require_once 'Zend/Feed/Pubsubhubbub.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub_Publisher -{ - /** - * An array of URLs for all Hub Servers used by the Publisher, and to - * which all topic update notifications will be sent. - * - * @var array - */ - protected $_hubUrls = array(); - - /** - * An array of topic (Atom or RSS feed) URLs which have been updated and - * whose updated status will be notified to all Hub Servers. - * - * @var array - */ - protected $_updatedTopicUrls = array(); - - /** - * An array of any errors including keys for 'response', 'hubUrl'. - * The response is the actual Zend_Http_Response object. - * - * @var array - */ - protected $_errors = array(); - - /** - * An array of topic (Atom or RSS feed) URLs which have been updated and - * whose updated status will be notified to all Hub Servers. - * - * @var array - */ - protected $_parameters = array(); - - /** - * Constructor; accepts an array or Zend_Config instance to preset - * options for the Publisher without calling all supported setter - * methods in turn. - * - * @param array|Zend_Config $options Options array or Zend_Config instance - * @return void - */ - public function __construct($config = null) - { - if (!is_null($config)) { - $this->setConfig($config); - } - } - - /** - * Process any injected configuration options - * - * @param array|Zend_Config $options Options array or Zend_Config instance - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function setConfig($config) - { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } elseif (!is_array($config)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Array or Zend_Config object' - . 'expected, got ' . gettype($config)); - } - if (array_key_exists('hubUrls', $config)) { - $this->addHubUrls($config['hubUrls']); - } - if (array_key_exists('updatedTopicUrls', $config)) { - $this->addUpdatedTopicUrls($config['updatedTopicUrls']); - } - if (array_key_exists('parameters', $config)) { - $this->setParameters($config['parameters']); - } - return $this; - } - - /** - * Add a Hub Server URL supported by Publisher - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function addHubUrl($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' - .' of "' . $url . '" must be a non-empty string and a valid' - .'URL'); - } - $this->_hubUrls[] = $url; - return $this; - } - - /** - * Add an array of Hub Server URLs supported by Publisher - * - * @param array $urls - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function addHubUrls(array $urls) - { - foreach ($urls as $url) { - $this->addHubUrl($url); - } - return $this; - } - - /** - * Remove a Hub Server URL - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function removeHubUrl($url) - { - if (!in_array($url, $this->getHubUrls())) { - return $this; - } - $key = array_search($url, $this->_hubUrls); - unset($this->_hubUrls[$key]); - return $this; - } - - /** - * Return an array of unique Hub Server URLs currently available - * - * @return array - */ - public function getHubUrls() - { - $this->_hubUrls = array_unique($this->_hubUrls); - return $this->_hubUrls; - } - - /** - * Add a URL to a topic (Atom or RSS feed) which has been updated - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function addUpdatedTopicUrl($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' - .' of "' . $url . '" must be a non-empty string and a valid' - .'URL'); - } - $this->_updatedTopicUrls[] = $url; - return $this; - } - - /** - * Add an array of Topic URLs which have been updated - * - * @param array $urls - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function addUpdatedTopicUrls(array $urls) - { - foreach ($urls as $url) { - $this->addUpdatedTopicUrl($url); - } - return $this; - } - - /** - * Remove an updated topic URL - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function removeUpdatedTopicUrl($url) - { - if (!in_array($url, $this->getUpdatedTopicUrls())) { - return $this; - } - $key = array_search($url, $this->_updatedTopicUrls); - unset($this->_updatedTopicUrls[$key]); - return $this; - } - - /** - * Return an array of unique updated topic URLs currently available - * - * @return array - */ - public function getUpdatedTopicUrls() - { - $this->_updatedTopicUrls = array_unique($this->_updatedTopicUrls); - return $this->_updatedTopicUrls; - } - - /** - * Notifies a single Hub Server URL of changes - * - * @param string $url The Hub Server's URL - * @return void - * @throws Zend_Feed_Pubsubhubbub_Exception Thrown on failure - */ - public function notifyHub($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' - .' of "' . $url . '" must be a non-empty string and a valid' - .'URL'); - } - $client = $this->_getHttpClient(); - $client->setUri($url); - $response = $client->request(); - if ($response->getStatus() !== 204) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Notification to Hub Server ' - . 'at "' . $url . '" appears to have failed with a status code of "' - . $response->getStatus() . '" and message "' - . $response->getMessage() . '"'); - } - } - - /** - * Notifies all Hub Server URLs of changes - * - * If a Hub notification fails, certain data will be retained in an - * an array retrieved using getErrors(), if a failure occurs for any Hubs - * the isSuccess() check will return FALSE. This method is designed not - * to needlessly fail with an Exception/Error unless from Zend_Http_Client. - * - * @return void - * @throws Zend_Feed_Pubsubhubbub_Exception Thrown if no hubs attached - */ - public function notifyAll() - { - $client = $this->_getHttpClient(); - $hubs = $this->getHubUrls(); - if (empty($hubs)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('No Hub Server URLs' - . ' have been set so no notifcations can be sent'); - } - $this->_errors = array(); - foreach ($hubs as $url) { - $client->setUri($url); - $response = $client->request(); - if ($response->getStatus() !== 204) { - $this->_errors[] = array( - 'response' => $response, - 'hubUrl' => $url - ); - } - } - } - - /** - * Add an optional parameter to the update notification requests - * - * @param string $name - * @param string|null $value - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function setParameter($name, $value = null) - { - if (is_array($name)) { - $this->setParameters($name); - return $this; - } - if (empty($name) || !is_string($name)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "name"' - .' of "' . $name . '" must be a non-empty string'); - } - if ($value === null) { - $this->removeParameter($name); - return $this; - } - if (empty($value) || (!is_string($value) && !is_null($value))) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "value"' - .' of "' . $value . '" must be a non-empty string'); - } - $this->_parameters[$name] = $value; - return $this; - } - - /** - * Add an optional parameter to the update notification requests - * - * @param array $parameters - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function setParameters(array $parameters) - { - foreach ($parameters as $name => $value) { - $this->setParameter($name, $value); - } - return $this; - } - - /** - * Remove an optional parameter for the notification requests - * - * @param string $name - * @return Zend_Feed_Pubsubhubbub_Publisher - */ - public function removeParameter($name) - { - if (empty($name) || !is_string($name)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "name"' - .' of "' . $name . '" must be a non-empty string'); - } - if (array_key_exists($name, $this->_parameters)) { - unset($this->_parameters[$name]); - } - return $this; - } - - /** - * Return an array of optional parameters for notification requests - * - * @return array - */ - public function getParameters() - { - return $this->_parameters; - } - - /** - * Returns a boolean indicator of whether the notifications to Hub - * Servers were ALL successful. If even one failed, FALSE is returned. - * - * @return bool - */ - public function isSuccess() - { - if (count($this->_errors) > 0) { - return false; - } - return true; - } - - /** - * Return an array of errors met from any failures, including keys: - * 'response' => the Zend_Http_Response object from the failure - * 'hubUrl' => the URL of the Hub Server whose notification failed - * - * @return array - */ - public function getErrors() - { - return $this->_errors; - } - - /** - * Get a basic prepared HTTP client for use - * - * @return Zend_Http_Client - */ - protected function _getHttpClient() - { - $client = Zend_Feed_Pubsubhubbub::getHttpClient(); - $client->setMethod(Zend_Http_Client::POST); - $client->setConfig(array( - 'useragent' => 'Zend_Feed_Pubsubhubbub_Publisher/' . Zend_Version::VERSION, - )); - $params = array(); - $params[] = 'hub.mode=publish'; - $topics = $this->getUpdatedTopicUrls(); - if (empty($topics)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('No updated topic URLs' - . ' have been set'); - } - foreach ($topics as $topicUrl) { - $params[] = 'hub.url=' . urlencode($topicUrl); - } - $optParams = $this->getParameters(); - foreach ($optParams as $name => $value) { - $params[] = urlencode($name) . '=' . urlencode($value); - } - $paramString = implode('&', $params); - $client->setRawData($paramString); - return $client; - } -} diff --git a/libs/Zend/Feed/Pubsubhubbub/Subscriber.php b/libs/Zend/Feed/Pubsubhubbub/Subscriber.php deleted file mode 100644 index 9921bce594..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/Subscriber.php +++ /dev/null @@ -1,856 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Feed_Pubsubhubbub - */ -// require_once 'Zend/Feed/Pubsubhubbub.php'; - -/** - * @see Zend_Date - */ -// require_once 'Zend/Date.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub_Subscriber -{ - /** - * An array of URLs for all Hub Servers to subscribe/unsubscribe. - * - * @var array - */ - protected $_hubUrls = array(); - - /** - * An array of optional parameters to be included in any - * (un)subscribe requests. - * - * @var array - */ - protected $_parameters = array(); - - /** - * The URL of the topic (Rss or Atom feed) which is the subject of - * our current intent to subscribe to/unsubscribe from updates from - * the currently configured Hub Servers. - * - * @var string - */ - protected $_topicUrl = ''; - - /** - * The URL Hub Servers must use when communicating with this Subscriber - * - * @var string - */ - protected $_callbackUrl = ''; - - /** - * The number of seconds for which the subscriber would like to have the - * subscription active. Defaults to null, i.e. not sent, to setup a - * permanent subscription if possible. - * - * @var int - */ - protected $_leaseSeconds = null; - - /** - * The preferred verification mode (sync or async). By default, this - * Subscriber prefers synchronous verification, but is considered - * desireable to support asynchronous verification if possible. - * - * Zend_Feed_Pubsubhubbub_Subscriber will always send both modes, whose - * order of occurance in the parameter list determines this preference. - * - * @var string - */ - protected $_preferredVerificationMode - = Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC; - - /** - * An array of any errors including keys for 'response', 'hubUrl'. - * The response is the actual Zend_Http_Response object. - * - * @var array - */ - protected $_errors = array(); - - /** - * An array of Hub Server URLs for Hubs operating at this time in - * asynchronous verification mode. - * - * @var array - */ - protected $_asyncHubs = array(); - - /** - * An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background - * save any verification tokens associated with a subscription or other. - * - * @var Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface - */ - protected $_storage = null; - - /** - * An array of authentication credentials for HTTP Basic Authentication - * if required by specific Hubs. The array is indexed by Hub Endpoint URI - * and the value is a simple array of the username and password to apply. - * - * @var array - */ - protected $_authentications = array(); - - /** - * Tells the Subscriber to append any subscription identifier to the path - * of the base Callback URL. E.g. an identifier "subkey1" would be added - * to the callback URL "http://www.example.com/callback" to create a subscription - * specific Callback URL of "http://www.example.com/callback/subkey1". - * - * This is required for all Hubs using the Pubsubhubbub 0.1 Specification. - * It should be manually intercepted and passed to the Callback class using - * Zend_Feed_Pubsubhubbub_Subscriber_Callback::setSubscriptionKey(). Will - * require a route in the form "callback/:subkey" to allow the parameter be - * retrieved from an action using the Zend_Controller_Action::_getParam() - * method. - * - * @var string - */ - protected $_usePathParameter = false; - - /** - * Constructor; accepts an array or Zend_Config instance to preset - * options for the Subscriber without calling all supported setter - * methods in turn. - * - * @param array|Zend_Config $options Options array or Zend_Config instance - * @return void - */ - public function __construct($config = null) - { - if (!is_null($config)) { - $this->setConfig($config); - } - } - - /** - * Process any injected configuration options - * - * @param array|Zend_Config $options Options array or Zend_Config instance - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setConfig($config) - { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } elseif (!is_array($config)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Array or Zend_Config object' - . ' expected, got ' . gettype($config)); - } - if (array_key_exists('hubUrls', $config)) { - $this->addHubUrls($config['hubUrls']); - } - if (array_key_exists('callbackUrl', $config)) { - $this->setCallbackUrl($config['callbackUrl']); - } - if (array_key_exists('topicUrl', $config)) { - $this->setTopicUrl($config['topicUrl']); - } - if (array_key_exists('storage', $config)) { - $this->setStorage($config['storage']); - } - if (array_key_exists('leaseSeconds', $config)) { - $this->setLeaseSeconds($config['leaseSeconds']); - } - if (array_key_exists('parameters', $config)) { - $this->setParameters($config['parameters']); - } - if (array_key_exists('authentications', $config)) { - $this->addAuthentications($config['authentications']); - } - if (array_key_exists('usePathParameter', $config)) { - $this->usePathParameter($config['usePathParameter']); - } - if (array_key_exists('preferredVerificationMode', $config)) { - $this->setPreferredVerificationMode( - $config['preferredVerificationMode'] - ); - } - return $this; - } - - /** - * Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe - * event will relate - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setTopicUrl($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' - .' of "' . $url . '" must be a non-empty string and a valid' - .' URL'); - } - $this->_topicUrl = $url; - return $this; - } - - /** - * Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe - * event will relate - * - * @return string - */ - public function getTopicUrl() - { - if (empty($this->_topicUrl)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('A valid Topic (RSS or Atom' - . ' feed) URL MUST be set before attempting any operation'); - } - return $this->_topicUrl; - } - - /** - * Set the number of seconds for which any subscription will remain valid - * - * @param int $seconds - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setLeaseSeconds($seconds) - { - $seconds = intval($seconds); - if ($seconds <= 0) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Expected lease seconds' - . ' must be an integer greater than zero'); - } - $this->_leaseSeconds = $seconds; - return $this; - } - - /** - * Get the number of lease seconds on subscriptions - * - * @return int - */ - public function getLeaseSeconds() - { - return $this->_leaseSeconds; - } - - /** - * Set the callback URL to be used by Hub Servers when communicating with - * this Subscriber - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setCallbackUrl($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' - . ' of "' . $url . '" must be a non-empty string and a valid' - . ' URL'); - } - $this->_callbackUrl = $url; - return $this; - } - - /** - * Get the callback URL to be used by Hub Servers when communicating with - * this Subscriber - * - * @return string - */ - public function getCallbackUrl() - { - if (empty($this->_callbackUrl)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('A valid Callback URL MUST be' - . ' set before attempting any operation'); - } - return $this->_callbackUrl; - } - - /** - * Set preferred verification mode (sync or async). By default, this - * Subscriber prefers synchronous verification, but does support - * asynchronous if that's the Hub Server's utilised mode. - * - * Zend_Feed_Pubsubhubbub_Subscriber will always send both modes, whose - * order of occurance in the parameter list determines this preference. - * - * @param string $mode Should be 'sync' or 'async' - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setPreferredVerificationMode($mode) - { - if ($mode !== Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC - && $mode !== Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_ASYNC) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid preferred' - . ' mode specified: "' . $mode . '" but should be one of' - . ' Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC or' - . ' Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_ASYNC'); - } - $this->_preferredVerificationMode = $mode; - return $this; - } - - /** - * Get preferred verification mode (sync or async). - * - * @return string - */ - public function getPreferredVerificationMode() - { - return $this->_preferredVerificationMode; - } - - /** - * Add a Hub Server URL supported by Publisher - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function addHubUrl($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' - . ' of "' . $url . '" must be a non-empty string and a valid' - . ' URL'); - } - $this->_hubUrls[] = $url; - return $this; - } - - /** - * Add an array of Hub Server URLs supported by Publisher - * - * @param array $urls - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function addHubUrls(array $urls) - { - foreach ($urls as $url) { - $this->addHubUrl($url); - } - return $this; - } - - /** - * Remove a Hub Server URL - * - * @param string $url - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function removeHubUrl($url) - { - if (!in_array($url, $this->getHubUrls())) { - return $this; - } - $key = array_search($url, $this->_hubUrls); - unset($this->_hubUrls[$key]); - return $this; - } - - /** - * Return an array of unique Hub Server URLs currently available - * - * @return array - */ - public function getHubUrls() - { - $this->_hubUrls = array_unique($this->_hubUrls); - return $this->_hubUrls; - } - - /** - * Add authentication credentials for a given URL - * - * @param string $url - * @param array $authentication - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function addAuthentication($url, array $authentication) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' - . ' of "' . $url . '" must be a non-empty string and a valid' - . ' URL'); - } - $this->_authentications[$url] = $authentication; - return $this; - } - - /** - * Add authentication credentials for hub URLs - * - * @param array $authentications - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function addAuthentications(array $authentications) - { - foreach ($authentications as $url => $authentication) { - $this->addAuthentication($url, $authentication); - } - return $this; - } - - /** - * Get all hub URL authentication credentials - * - * @return array - */ - public function getAuthentications() - { - return $this->_authentications; - } - - /** - * Set flag indicating whether or not to use a path parameter - * - * @param bool $bool - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function usePathParameter($bool = true) - { - $this->_usePathParameter = $bool; - return $this; - } - - /** - * Add an optional parameter to the (un)subscribe requests - * - * @param string $name - * @param string|null $value - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setParameter($name, $value = null) - { - if (is_array($name)) { - $this->setParameters($name); - return $this; - } - if (empty($name) || !is_string($name)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "name"' - . ' of "' . $name . '" must be a non-empty string'); - } - if ($value === null) { - $this->removeParameter($name); - return $this; - } - if (empty($value) || (!is_string($value) && !is_null($value))) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "value"' - . ' of "' . $value . '" must be a non-empty string'); - } - $this->_parameters[$name] = $value; - return $this; - } - - /** - * Add an optional parameter to the (un)subscribe requests - * - * @param string $name - * @param string|null $value - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setParameters(array $parameters) - { - foreach ($parameters as $name => $value) { - $this->setParameter($name, $value); - } - return $this; - } - - /** - * Remove an optional parameter for the (un)subscribe requests - * - * @param string $name - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function removeParameter($name) - { - if (empty($name) || !is_string($name)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "name"' - . ' of "' . $name . '" must be a non-empty string'); - } - if (array_key_exists($name, $this->_parameters)) { - unset($this->_parameters[$name]); - } - return $this; - } - - /** - * Return an array of optional parameters for (un)subscribe requests - * - * @return array - */ - public function getParameters() - { - return $this->_parameters; - } - - /** - * Sets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background - * save any verification tokens associated with a subscription or other. - * - * @param Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage - * @return Zend_Feed_Pubsubhubbub_Subscriber - */ - public function setStorage(Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage) - { - $this->_storage = $storage; - return $this; - } - - /** - * Gets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used - * to background save any verification tokens associated with a subscription - * or other. - * - * @return Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface - */ - public function getStorage() - { - if ($this->_storage === null) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('No storage vehicle ' - . 'has been set.'); - } - return $this->_storage; - } - - /** - * Subscribe to one or more Hub Servers using the stored Hub URLs - * for the given Topic URL (RSS or Atom feed) - * - * @return void - */ - public function subscribeAll() - { - return $this->_doRequest('subscribe'); - } - - /** - * Unsubscribe from one or more Hub Servers using the stored Hub URLs - * for the given Topic URL (RSS or Atom feed) - * - * @return void - */ - public function unsubscribeAll() - { - return $this->_doRequest('unsubscribe'); - } - - /** - * Returns a boolean indicator of whether the notifications to Hub - * Servers were ALL successful. If even one failed, FALSE is returned. - * - * @return bool - */ - public function isSuccess() - { - if (count($this->_errors) > 0) { - return false; - } - return true; - } - - /** - * Return an array of errors met from any failures, including keys: - * 'response' => the Zend_Http_Response object from the failure - * 'hubUrl' => the URL of the Hub Server whose notification failed - * - * @return array - */ - public function getErrors() - { - return $this->_errors; - } - - /** - * Return an array of Hub Server URLs who returned a response indicating - * operation in Asynchronous Verification Mode, i.e. they will not confirm - * any (un)subscription immediately but at a later time (Hubs may be - * doing this as a batch process when load balancing) - * - * @return array - */ - public function getAsyncHubs() - { - return $this->_asyncHubs; - } - - /** - * Executes an (un)subscribe request - * - * @param string $mode - * @return void - */ - protected function _doRequest($mode) - { - $client = $this->_getHttpClient(); - $hubs = $this->getHubUrls(); - if (empty($hubs)) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('No Hub Server URLs' - . ' have been set so no subscriptions can be attempted'); - } - $this->_errors = array(); - $this->_asyncHubs = array(); - foreach ($hubs as $url) { - if (array_key_exists($url, $this->_authentications)) { - $auth = $this->_authentications[$url]; - $client->setAuth($auth[0], $auth[1]); - } - $client->setUri($url); - $client->setRawData($this->_getRequestParameters($url, $mode)); - $response = $client->request(); - if ($response->getStatus() !== 204 - && $response->getStatus() !== 202 - ) { - $this->_errors[] = array( - 'response' => $response, - 'hubUrl' => $url, - ); - /** - * At first I thought it was needed, but the backend storage will - * allow tracking async without any user interference. It's left - * here in case the user is interested in knowing what Hubs - * are using async verification modes so they may update Models and - * move these to asynchronous processes. - */ - } elseif ($response->getStatus() == 202) { - $this->_asyncHubs[] = array( - 'response' => $response, - 'hubUrl' => $url, - ); - } - } - } - - /** - * Get a basic prepared HTTP client for use - * - * @param string $mode Must be "subscribe" or "unsubscribe" - * @return Zend_Http_Client - */ - protected function _getHttpClient() - { - $client = Zend_Feed_Pubsubhubbub::getHttpClient(); - $client->setMethod(Zend_Http_Client::POST); - $client->setConfig(array('useragent' => 'Zend_Feed_Pubsubhubbub_Subscriber/' - . Zend_Version::VERSION)); - return $client; - } - - /** - * Return a list of standard protocol/optional parameters for addition to - * client's POST body that are specific to the current Hub Server URL - * - * @param string $hubUrl - * @param mode $hubUrl - * @return string - */ - protected function _getRequestParameters($hubUrl, $mode) - { - if (!in_array($mode, array('subscribe', 'unsubscribe'))) { - // require_once 'Zend/Feed/Pubsubhubbub/Exception.php'; - throw new Zend_Feed_Pubsubhubbub_Exception('Invalid mode specified: "' - . $mode . '" which should have been "subscribe" or "unsubscribe"'); - } - - $params = array( - 'hub.mode' => $mode, - 'hub.topic' => $this->getTopicUrl(), - ); - - if ($this->getPreferredVerificationMode() - == Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC - ) { - $vmodes = array( - Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC, - Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_ASYNC, - ); - } else { - $vmodes = array( - Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_ASYNC, - Zend_Feed_Pubsubhubbub::VERIFICATION_MODE_SYNC, - ); - } - $params['hub.verify'] = array(); - foreach($vmodes as $vmode) { - $params['hub.verify'][] = $vmode; - } - - /** - * Establish a persistent verify_token and attach key to callback - * URL's path/querystring - */ - $key = $this->_generateSubscriptionKey($params, $hubUrl); - $token = $this->_generateVerifyToken(); - $params['hub.verify_token'] = $token; - - // Note: query string only usable with PuSH 0.2 Hubs - if (!$this->_usePathParameter) { - $params['hub.callback'] = $this->getCallbackUrl() - . '?xhub.subscription=' . Zend_Feed_Pubsubhubbub::urlencode($key); - } else { - $params['hub.callback'] = rtrim($this->getCallbackUrl(), '/') - . '/' . Zend_Feed_Pubsubhubbub::urlencode($key); - } - if ($mode == 'subscribe' && !is_null($this->getLeaseSeconds())) { - $params['hub.lease_seconds'] = $this->getLeaseSeconds(); - } - - // hub.secret not currently supported - $optParams = $this->getParameters(); - foreach ($optParams as $name => $value) { - $params[$name] = $value; - } - - // store subscription to storage - $now = new Zend_Date; - $expires = null; - if (isset($params['hub.lease_seconds'])) { - $expires = $now->add($params['hub.lease_seconds'], Zend_Date::SECOND) - ->get('yyyy-MM-dd HH:mm:ss'); - } - $data = array( - 'id' => $key, - 'topic_url' => $params['hub.topic'], - 'hub_url' => $hubUrl, - 'created_time' => $now->get('yyyy-MM-dd HH:mm:ss'), - 'lease_seconds' => $expires, - 'verify_token' => hash('sha256', $params['hub.verify_token']), - 'secret' => null, - 'expiration_time' => $expires, - 'subscription_state' => Zend_Feed_Pubsubhubbub::SUBSCRIPTION_NOTVERIFIED, - ); - $this->getStorage()->setSubscription($data); - - return $this->_toByteValueOrderedString( - $this->_urlEncode($params) - ); - } - - /** - * Simple helper to generate a verification token used in (un)subscribe - * requests to a Hub Server. Follows no particular method, which means - * it might be improved/changed in future. - * - * @param string $hubUrl The Hub Server URL for which this token will apply - * @return string - */ - protected function _generateVerifyToken() - { - if (!empty($this->_testStaticToken)) { - return $this->_testStaticToken; - } - return uniqid(rand(), true) . time(); - } - - /** - * Simple helper to generate a verification token used in (un)subscribe - * requests to a Hub Server. - * - * @param string $hubUrl The Hub Server URL for which this token will apply - * @return string - */ - protected function _generateSubscriptionKey(array $params, $hubUrl) - { - $keyBase = $params['hub.topic'] . $hubUrl; - $key = md5($keyBase); - return $key; - } - - /** - * URL Encode an array of parameters - * - * @param array $params - * @return array - */ - protected function _urlEncode(array $params) - { - $encoded = array(); - foreach ($params as $key => $value) { - if (is_array($value)) { - $ekey = Zend_Feed_Pubsubhubbub::urlencode($key); - $encoded[$ekey] = array(); - foreach ($value as $duplicateKey) { - $encoded[$ekey][] - = Zend_Feed_Pubsubhubbub::urlencode($duplicateKey); - } - } else { - $encoded[Zend_Feed_Pubsubhubbub::urlencode($key)] - = Zend_Feed_Pubsubhubbub::urlencode($value); - } - } - return $encoded; - } - - /** - * Order outgoing parameters - * - * @param array $params - * @return array - */ - protected function _toByteValueOrderedString(array $params) - { - $return = array(); - uksort($params, 'strnatcmp'); - foreach ($params as $key => $value) { - if (is_array($value)) { - foreach ($value as $keyduplicate) { - $return[] = $key . '=' . $keyduplicate; - } - } else { - $return[] = $key . '=' . $value; - } - } - return implode('&', $return); - } - - /** - * This is STRICTLY for testing purposes only... - */ - protected $_testStaticToken = null; - - final public function setTestStaticToken($token) - { - $this->_testStaticToken = (string) $token; - } -} diff --git a/libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php b/libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php deleted file mode 100644 index 1f42375839..0000000000 --- a/libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php +++ /dev/null @@ -1,328 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Feed_Pubsubhubbub - */ -// require_once 'Zend/Feed/Pubsubhubbub.php'; - -/** - * @see Zend_Feed_Pubsubhubbub - */ -// require_once 'Zend/Feed/Pubsubhubbub/CallbackAbstract.php'; - -/** - * @see Zend_Feed_Reader - */ -// require_once 'Zend/Feed/Reader.php'; - -/** - * @category Zend - * @package Zend_Feed_Pubsubhubbub - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Pubsubhubbub_Subscriber_Callback - extends Zend_Feed_Pubsubhubbub_CallbackAbstract -{ - /** - * Contains the content of any feeds sent as updates to the Callback URL - * - * @var string - */ - protected $_feedUpdate = null; - - /** - * Holds a manually set subscription key (i.e. identifies a unique - * subscription) which is typical when it is not passed in the query string - * but is part of the Callback URL path, requiring manual retrieval e.g. - * using a route and the Zend_Controller_Action::_getParam() method. - * - * @var string - */ - protected $_subscriptionKey = null; - - /** - * After verification, this is set to the verified subscription's data. - * - * @var array - */ - protected $_currentSubscriptionData = null; - - /** - * Set a subscription key to use for the current callback request manually. - * Required if usePathParameter is enabled for the Subscriber. - * - * @param string $key - * @return Zend_Feed_Pubsubhubbub_Subscriber_Callback - */ - public function setSubscriptionKey($key) - { - $this->_subscriptionKey = $key; - return $this; - } - - /** - * Handle any callback from a Hub Server responding to a subscription or - * unsubscription request. This should be the Hub Server confirming the - * the request prior to taking action on it. - * - * @param array $httpGetData GET data if available and not in $_GET - * @param bool $sendResponseNow Whether to send response now or when asked - * @return void - */ - public function handle(array $httpGetData = null, $sendResponseNow = false) - { - if ($httpGetData === null) { - $httpGetData = $_GET; - } - - /** - * Handle any feed updates (sorry for the mess :P) - * - * This DOES NOT attempt to process a feed update. Feed updates - * SHOULD be validated/processed by an asynchronous process so as - * to avoid holding up responses to the Hub. - */ - if (strtolower($_SERVER['REQUEST_METHOD']) == 'post' - && $this->_hasValidVerifyToken(null, false) - && ($this->_getHeader('Content-Type') == 'application/atom+xml' - || $this->_getHeader('Content-Type') == 'application/rss+xml' - || $this->_getHeader('Content-Type') == 'application/xml' - || $this->_getHeader('Content-Type') == 'text/xml' - || $this->_getHeader('Content-Type') == 'application/rdf+xml') - ) { - $this->setFeedUpdate($this->_getRawBody()); - $this->getHttpResponse() - ->setHeader('X-Hub-On-Behalf-Of', $this->getSubscriberCount()); - /** - * Handle any (un)subscribe confirmation requests - */ - } elseif ($this->isValidHubVerification($httpGetData)) { - $data = $this->_currentSubscriptionData; - $this->getHttpResponse()->setBody($httpGetData['hub_challenge']); - $data['subscription_state'] = Zend_Feed_Pubsubhubbub::SUBSCRIPTION_VERIFIED; - if (isset($httpGetData['hub_lease_seconds'])) { - $data['lease_seconds'] = $httpGetData['hub_lease_seconds']; - } - $this->getStorage()->setSubscription($data); - /** - * Hey, C'mon! We tried everything else! - */ - } else { - $this->getHttpResponse()->setHttpResponseCode(404); - } - if ($sendResponseNow) { - $this->sendResponse(); - } - } - - /** - * Checks validity of the request simply by making a quick pass and - * confirming the presence of all REQUIRED parameters. - * - * @param array $httpGetData - * @return bool - */ - public function isValidHubVerification(array $httpGetData) - { - /** - * As per the specification, the hub.verify_token is OPTIONAL. This - * implementation of Pubsubhubbub considers it REQUIRED and will - * always send a hub.verify_token parameter to be echoed back - * by the Hub Server. Therefore, its absence is considered invalid. - */ - if (strtolower($_SERVER['REQUEST_METHOD']) !== 'get') { - return false; - } - $required = array( - 'hub_mode', - 'hub_topic', - 'hub_challenge', - 'hub_verify_token', - ); - foreach ($required as $key) { - if (!array_key_exists($key, $httpGetData)) { - return false; - } - } - if ($httpGetData['hub_mode'] !== 'subscribe' - && $httpGetData['hub_mode'] !== 'unsubscribe' - ) { - return false; - } - if ($httpGetData['hub_mode'] == 'subscribe' - && !array_key_exists('hub_lease_seconds', $httpGetData) - ) { - return false; - } - if (!Zend_Uri::check($httpGetData['hub_topic'])) { - return false; - } - - /** - * Attempt to retrieve any Verification Token Key attached to Callback - * URL's path by our Subscriber implementation - */ - if (!$this->_hasValidVerifyToken($httpGetData)) { - return false; - } - return true; - } - - /** - * Sets a newly received feed (Atom/RSS) sent by a Hub as an update to a - * Topic we've subscribed to. - * - * @param string $feed - * @return Zend_Feed_Pubsubhubbub_Subscriber_Callback - */ - public function setFeedUpdate($feed) - { - $this->_feedUpdate = $feed; - return $this; - } - - /** - * Check if any newly received feed (Atom/RSS) update was received - * - * @return bool - */ - public function hasFeedUpdate() - { - if (is_null($this->_feedUpdate)) { - return false; - } - return true; - } - - /** - * Gets a newly received feed (Atom/RSS) sent by a Hub as an update to a - * Topic we've subscribed to. - * - * @return string - */ - public function getFeedUpdate() - { - return $this->_feedUpdate; - } - - /** - * Check for a valid verify_token. By default attempts to compare values - * with that sent from Hub, otherwise merely ascertains its existence. - * - * @param array $httpGetData - * @param bool $checkValue - * @return bool - */ - protected function _hasValidVerifyToken(array $httpGetData = null, $checkValue = true) - { - $verifyTokenKey = $this->_detectVerifyTokenKey($httpGetData); - if (empty($verifyTokenKey)) { - return false; - } - $verifyTokenExists = $this->getStorage()->hasSubscription($verifyTokenKey); - if (!$verifyTokenExists) { - return false; - } - if ($checkValue) { - $data = $this->getStorage()->getSubscription($verifyTokenKey); - $verifyToken = $data['verify_token']; - if ($verifyToken !== hash('sha256', $httpGetData['hub_verify_token'])) { - return false; - } - $this->_currentSubscriptionData = $data; - return true; - } - return true; - } - - /** - * Attempt to detect the verification token key. This would be passed in - * the Callback URL (which we are handling with this class!) as a URI - * path part (the last part by convention). - * - * @param null|array $httpGetData - * @return false|string - */ - protected function _detectVerifyTokenKey(array $httpGetData = null) - { - /** - * Available when sub keys encoding in Callback URL path - */ - if (isset($this->_subscriptionKey)) { - return $this->_subscriptionKey; - } - - /** - * Available only if allowed by PuSH 0.2 Hubs - */ - if (is_array($httpGetData) - && isset($httpGetData['xhub_subscription']) - ) { - return $httpGetData['xhub_subscription']; - } - - /** - * Available (possibly) if corrupted in transit and not part of $_GET - */ - $params = $this->_parseQueryString(); - if (isset($params['xhub.subscription'])) { - return rawurldecode($params['xhub.subscription']); - } - - return false; - } - - /** - * Build an array of Query String parameters. - * This bypasses $_GET which munges parameter names and cannot accept - * multiple parameters with the same key. - * - * @return array|void - */ - protected function _parseQueryString() - { - $params = array(); - $queryString = ''; - if (isset($_SERVER['QUERY_STRING'])) { - $queryString = $_SERVER['QUERY_STRING']; - } - if (empty($queryString)) { - return array(); - } - $parts = explode('&', $queryString); - foreach ($parts as $kvpair) { - $pair = explode('=', $kvpair); - $key = rawurldecode($pair[0]); - $value = rawurldecode($pair[1]); - if (isset($params[$key])) { - if (is_array($params[$key])) { - $params[$key][] = $value; - } else { - $params[$key] = array($params[$key], $value); - } - } else { - $params[$key] = $value; - } - } - return $params; - } -} diff --git a/libs/Zend/Feed/Reader.php b/libs/Zend/Feed/Reader.php index 26bf661cdf..ced12cf7c7 100644 --- a/libs/Zend/Feed/Reader.php +++ b/libs/Zend/Feed/Reader.php @@ -14,55 +14,49 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Reader.php 22093 2010-05-04 12:55:06Z padraic $ + * @version $Id: Reader.php 17391 2009-08-05 11:27:52Z padraic $ */ /** * @see Zend_Feed */ -// require_once 'Zend/Feed.php'; +require_once 'Zend/Feed.php'; /** * @see Zend_Feed_Reader_Feed_Rss */ -// require_once 'Zend/Feed/Reader/Feed/Rss.php'; +require_once 'Zend/Feed/Reader/Feed/Rss.php'; /** * @see Zend_Feed_Reader_Feed_Atom */ -// require_once 'Zend/Feed/Reader/Feed/Atom.php'; - -/** - * @see Zend_Feed_Reader_FeedSet - */ -// require_once 'Zend/Feed/Reader/FeedSet.php'; +require_once 'Zend/Feed/Reader/Feed/Atom.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader { - /** - * Namespace constants - */ - const NAMESPACE_ATOM_03 = 'http://purl.org/atom/ns#'; + /** + * Namespace constants + */ + const NAMESPACE_ATOM_03 = 'http://purl.org/atom/ns#'; const NAMESPACE_ATOM_10 = 'http://www.w3.org/2005/Atom'; const NAMESPACE_RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; const NAMESPACE_RSS_090 = 'http://my.netscape.com/rdf/simple/0.9/'; const NAMESPACE_RSS_10 = 'http://purl.org/rss/1.0/'; /** - * Feed type constants - */ - const TYPE_ANY = 'any'; - const TYPE_ATOM_03 = 'atom-03'; + * Feed type constants + */ + const TYPE_ANY = 'any'; + const TYPE_ATOM_03 = 'atom-03'; const TYPE_ATOM_10 = 'atom-10'; - const TYPE_ATOM_10_ENTRY = 'atom-10-entry'; const TYPE_ATOM_ANY = 'atom'; const TYPE_RSS_090 = 'rss-090'; const TYPE_RSS_091 = 'rss-091'; @@ -167,7 +161,7 @@ class Zend_Feed_Reader /** * @see Zend_Http_Client */ - // require_once 'Zend/Http/Client.php'; + require_once 'Zend/Http/Client.php'; self::$_httpClient = new Zend_Http_Client(); } @@ -214,13 +208,13 @@ class Zend_Feed_Reader } /** - * Import a feed by providing a URL - * - * @param string $url The URL to the feed + * Import a feed by providing a URL + * + * @param string $url The URL to the feed * @param string $etag OPTIONAL Last received ETag for this resource * @param string $lastModified OPTIONAL Last-Modified value for this resource - * @return Zend_Feed_Reader_FeedInterface - */ + * @return Zend_Feed_Reader_Feed_Interface + */ public static function import($uri, $etag = null, $lastModified = null) { $cache = self::getCache(); @@ -251,7 +245,7 @@ class Zend_Feed_Reader } $response = $client->request('GET'); if ($response->getStatus() !== 200 && $response->getStatus() !== 304) { - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus()); } if ($response->getStatus() == 304) { @@ -274,7 +268,7 @@ class Zend_Feed_Reader } $response = $client->request('GET'); if ($response->getStatus() !== 200) { - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus()); } $responseXml = $response->getBody(); @@ -283,12 +277,10 @@ class Zend_Feed_Reader } else { $response = $client->request('GET'); if ($response->getStatus() !== 200) { - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus()); } - $reader = self::importString($response->getBody()); - $reader->setOriginalSourceUri($uri); - return $reader; + return self::importString($response->getBody()); } } @@ -296,8 +288,8 @@ class Zend_Feed_Reader * Import a feed by providing a Zend_Feed_Abstract object * * @param Zend_Feed_Abstract $feed A fully instantiated Zend_Feed object - * @return Zend_Feed_Reader_FeedInterface - */ + * @return Zend_Feed_Reader_Feed_Interface + */ public static function importFeed(Zend_Feed_Abstract $feed) { $dom = $feed->getDOM()->ownerDocument; @@ -306,7 +298,7 @@ class Zend_Feed_Reader if (substr($type, 0, 3) == 'rss') { $reader = new Zend_Feed_Reader_Feed_Rss($dom, $type); } else { - $reader = new Zend_Feed_Reader_Feed_Atom($dom, $type); + $reader = new Zend_Feed_Reader_Feed_Atom($dom, $type); } return $reader; @@ -316,7 +308,7 @@ class Zend_Feed_Reader * Import a feed froma string * * @param string $string - * @return Zend_Feed_Reader_FeedInterface + * @return Zend_Feed_Reader_Feed_Interface */ public static function importString($string) { @@ -329,12 +321,12 @@ class Zend_Feed_Reader // Build error message $error = libxml_get_last_error(); if ($error && $error->message) { - $errormsg = "DOMDocument cannot parse XML: {$error->message}"; + $errormsg = "DOMDocument cannot parse XML: {$error->message}"; } else { - $errormsg = "DOMDocument cannot parse XML: Please check the XML document's validity"; + $errormsg = "DOMDocument cannot parse XML: Please check the XML document's validity"; } - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception($errormsg); } @@ -344,14 +336,8 @@ class Zend_Feed_Reader if (substr($type, 0, 3) == 'rss') { $reader = new Zend_Feed_Reader_Feed_Rss($dom, $type); - } elseif (substr($type, 8, 5) == 'entry') { - $reader = new Zend_Feed_Reader_Entry_Atom($dom->documentElement, 0, Zend_Feed_Reader::TYPE_ATOM_10); - } elseif (substr($type, 0, 4) == 'atom') { - $reader = new Zend_Feed_Reader_Feed_Atom($dom, $type); } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('The URI used does not point to a ' - . 'valid Atom, RSS or RDF feed that Zend_Feed_Reader can parse.'); + $reader = new Zend_Feed_Reader_Feed_Atom($dom, $type); } return $reader; } @@ -372,7 +358,7 @@ class Zend_Feed_Reader /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("File could not be loaded: $php_errormsg"); } return self::importString($feed); @@ -388,48 +374,62 @@ class Zend_Feed_Reader /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("Failed to access $uri, got response code " . $response->getStatus()); } $responseHtml = $response->getBody(); - $libxml_errflag = libxml_use_internal_errors(true); + @ini_set('track_errors', 1); $dom = new DOMDocument; - $status = $dom->loadHTML($responseHtml); - libxml_use_internal_errors($libxml_errflag); + $status = @$dom->loadHTML($responseHtml); + @ini_restore('track_errors'); if (!$status) { - // Build error message - $error = libxml_get_last_error(); - if ($error && $error->message) { - $errormsg = "DOMDocument cannot parse HTML: {$error->message}"; - } else { - $errormsg = "DOMDocument cannot parse HTML: Please check the XML document's validity"; + if (!isset($php_errormsg)) { + if (function_exists('xdebug_is_enabled')) { + $php_errormsg = '(error message not available, when XDebug is running)'; + } else { + $php_errormsg = '(error message not available)'; + } } - - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception($errormsg); + require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception("DOMDocument cannot parse XML: $php_errormsg"); } - $feedSet = new Zend_Feed_Reader_FeedSet; + $feedLinks = new stdClass; $links = $dom->getElementsByTagName('link'); - $feedSet->addLinks($links, $uri); - return $feedSet; + foreach ($links as $link) { + if (strtolower($link->getAttribute('rel')) !== 'alternate' + || !$link->getAttribute('type') || !$link->getAttribute('href')) { + continue; + } + if (!isset($feedLinks->rss) && $link->getAttribute('type') == 'application/rss+xml') { + $feedLinks->rss = $link->getAttribute('href'); + } elseif(!isset($feedLinks->atom) && $link->getAttribute('type') == 'application/atom+xml') { + $feedLinks->atom = $link->getAttribute('href'); + } elseif(!isset($feedLinks->rdf) && $link->getAttribute('type') == 'application/rdf+xml') { + $feedLinks->rdf = $link->getAttribute('href'); + } + if (isset($feedLinks->rss) && isset($feedLinks->atom) && isset($feedLinks->rdf)) { + break; + } + } + return $feedLinks; } /** * Detect the feed type of the provided feed * - * @param Zend_Feed_Abstract|DOMDocument|string $feed + * @param Zend_Feed_Abstract $feed A fully instantiated Zend_Feed object * @return string */ - public static function detectType($feed, $specOnly = false) + public static function detectType($feed) { if ($feed instanceof Zend_Feed_Reader_FeedInterface) { $dom = $feed->getDomDocument(); - } elseif($feed instanceof DOMDocument) { + } elseif($feed instanceof DomDocument) { $dom = $feed; } elseif(is_string($feed) && !empty($feed)) { @ini_set('track_errors', 1); $dom = new DOMDocument; - $status = @$dom->loadXML($feed); + $status = @$doc->loadXML($string); @ini_restore('track_errors'); if (!$status) { if (!isset($php_errormsg)) { @@ -439,13 +439,12 @@ class Zend_Feed_Reader $php_errormsg = '(error message not available)'; } } - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("DOMDocument cannot parse XML: $php_errormsg"); } } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid object/scalar provided: must' - . ' be of type Zend_Feed_Reader_FeedInterface, DomDocument or string'); + require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception('Invalid object/scalar provided: must be of type Zend_Feed_Reader_FeedInterface, DomDocument or string'); } $xpath = new DOMXPath($dom); @@ -510,14 +509,6 @@ class Zend_Feed_Reader if ($xpath->query('//atom:feed')->length) { return self::TYPE_ATOM_10; } - - if ($xpath->query('//atom:entry')->length) { - if ($specOnly == true) { - return self::TYPE_ATOM_10; - } else { - return self::TYPE_ATOM_10_ENTRY; - } - } $xpath->registerNamespace('atom', self::NAMESPACE_ATOM_03); @@ -546,7 +537,7 @@ class Zend_Feed_Reader public static function getPluginLoader() { if (!isset(self::$_pluginLoader)) { - // require_once 'Zend/Loader/PluginLoader.php'; + require_once 'Zend/Loader/PluginLoader.php'; self::$_pluginLoader = new Zend_Loader_PluginLoader(array( 'Zend_Feed_Reader_Extension_' => 'Zend/Feed/Reader/Extension/', )); @@ -616,7 +607,7 @@ class Zend_Feed_Reader if (!self::getPluginLoader()->isLoaded($feedName) && !self::getPluginLoader()->isLoaded($entryName) ) { - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Could not load extension: ' . $name . 'using Plugin Loader. Check prefix paths are configured and extension exists.'); } @@ -698,24 +689,4 @@ class Zend_Feed_Reader self::registerExtension('Thread'); self::registerExtension('Podcast'); } - - /** - * Utility method to apply array_unique operation to a multidimensional - * array. - * - * @param array - * @return array - */ - public static function arrayUnique(array $array) - { - foreach ($array as &$value) { - $value = serialize($value); - } - $array = array_unique($array); - foreach ($array as &$value) { - $value = unserialize($value); - } - return $array; - } - } diff --git a/libs/Zend/Feed/Reader/Collection.php b/libs/Zend/Feed/Reader/Collection.php deleted file mode 100644 index fba2b52b52..0000000000 --- a/libs/Zend/Feed/Reader/Collection.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Reader_Collection extends ArrayObject -{ - - - -} diff --git a/libs/Zend/Feed/Reader/Collection/Author.php b/libs/Zend/Feed/Reader/Collection/Author.php deleted file mode 100644 index 6a039974b6..0000000000 --- a/libs/Zend/Feed/Reader/Collection/Author.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Author.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Feed_Reader_Collection_CollectionAbstract - */ -// require_once 'Zend/Feed/Reader/Collection/CollectionAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Reader_Collection_Author -extends Zend_Feed_Reader_Collection_CollectionAbstract -{ - - /** - * Return a simple array of the most relevant slice of - * the author values, i.e. all author names. - * - * @return array - */ - public function getValues() { - $authors = array(); - foreach ($this->getIterator() as $element) { - $authors[] = $element['name']; - } - return array_unique($authors); - } - -} diff --git a/libs/Zend/Feed/Reader/Collection/Category.php b/libs/Zend/Feed/Reader/Collection/Category.php deleted file mode 100644 index 2587c13268..0000000000 --- a/libs/Zend/Feed/Reader/Collection/Category.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Category.php 20954 2010-02-06 17:56:27Z padraic $ - */ - -/** - * @see Zend_Feed_Reader_Collection_CollectionAbstract - */ -// require_once 'Zend/Feed/Reader/Collection/CollectionAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Reader_Collection_Category -extends Zend_Feed_Reader_Collection_CollectionAbstract -{ - - /** - * Return a simple array of the most relevant slice of - * the collection values. For example, feed categories contain - * the category name, domain/URI, and other data. This method would - * merely return the most useful data - i.e. the category names. - * - * @return array - */ - public function getValues() { - $categories = array(); - foreach ($this->getIterator() as $element) { - if (isset($element['label']) && !empty($element['label'])) { - $categories[] = $element['label']; - } else { - $categories[] = $element['term']; - } - } - return array_unique($categories); - } - -} diff --git a/libs/Zend/Feed/Reader/Collection/CollectionAbstract.php b/libs/Zend/Feed/Reader/Collection/CollectionAbstract.php deleted file mode 100644 index 7b6dbd0317..0000000000 --- a/libs/Zend/Feed/Reader/Collection/CollectionAbstract.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CollectionAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Feed_Reader_Collection_CollectionAbstract extends ArrayObject -{ - - /** - * Return a simple array of the most relevant slice of - * the collection values. For example, feed categories contain - * the category name, domain/URI, and other data. This method would - * merely return the most useful data - i.e. the category names. - * - * @return array - */ - public abstract function getValues(); - -} diff --git a/libs/Zend/Feed/Reader/Entry/Atom.php b/libs/Zend/Feed/Reader/Entry/Atom.php index 77289b411b..b788cd2533 100644 --- a/libs/Zend/Feed/Reader/Entry/Atom.php +++ b/libs/Zend/Feed/Reader/Entry/Atom.php @@ -14,35 +14,35 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Atom.php 16966 2009-07-22 15:22:18Z padraic $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_EntryInterface */ -// require_once 'Zend/Feed/Reader/EntryInterface.php'; +require_once 'Zend/Feed/Reader/EntryInterface.php'; /** * @see Zend_Feed_Reader_EntryAbstract */ -// require_once 'Zend/Feed/Reader/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/EntryAbstract.php'; /** * @see Zend_Feed_Reader_Extension_Atom_Entry */ -// require_once 'Zend/Feed/Reader/Extension/Atom/Entry.php'; +require_once 'Zend/Feed/Reader/Extension/Atom/Entry.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract implements Zend_Feed_Reader_EntryInterface @@ -74,12 +74,9 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme $threadClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Thread_Entry'); $this->_extensions['Thread_Entry'] = new $threadClass($entry, $entryKey, $type); - - $threadClass = Zend_Feed_Reader::getPluginLoader()->getClassName('DublinCore_Entry'); - $this->_extensions['DublinCore_Entry'] = new $threadClass($entry, $entryKey, $type); } - /** + /** * Get the specified author * * @param int $index @@ -298,7 +295,7 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme return $this->_data['commentcount']; } - $commentcount = $this->getExtension('Thread')->getCommentCount(); + $commentcount = $this->getExtension('Thread')>getCommentCount(); if (!$commentcount) { $commentcount = $this->getExtension('Atom')->getCommentCount(); @@ -344,46 +341,6 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme return $this->_data['commentfeedlink']; } - - /** - * Get category data as a Zend_Feed_Reader_Collection_Category object - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - $categoryCollection = $this->getExtension('Atom')->getCategories(); - - if (count($categoryCollection) == 0) { - $categoryCollection = $this->getExtension('DublinCore')->getCategories(); - } - - $this->_data['categories'] = $categoryCollection; - - return $this->_data['categories']; - } - - /** - * Get source feed metadata from the entry - * - * @return Zend_Feed_Reader_Feed_Atom_Source|null - */ - public function getSource() - { - if (array_key_exists('source', $this->_data)) { - return $this->_data['source']; - } - - $source = $this->getExtension('Atom')->getSource(); - - $this->_data['source'] = $source; - - return $this->_data['source']; - } /** * Set the XPath query (incl. on all Extensions) diff --git a/libs/Zend/Feed/Reader/Entry/Rss.php b/libs/Zend/Feed/Reader/Entry/Rss.php index 21a30a98fc..b91990a665 100644 --- a/libs/Zend/Feed/Reader/Entry/Rss.php +++ b/libs/Zend/Feed/Reader/Entry/Rss.php @@ -14,70 +14,65 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 22301 2010-05-26 10:15:13Z padraic $ + * @version $Id: Rss.php 18367 2009-09-22 14:55:59Z padraic $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_EntryInterface */ -// require_once 'Zend/Feed/Reader/EntryInterface.php'; +require_once 'Zend/Feed/Reader/EntryInterface.php'; /** * @see Zend_Feed_Reader_EntryAbstract */ -// require_once 'Zend/Feed/Reader/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/EntryAbstract.php'; /** * @see Zend_Feed_Reader_Extension_DublinCore_Entry */ -// require_once 'Zend/Feed/Reader/Extension/DublinCore/Entry.php'; +require_once 'Zend/Feed/Reader/Extension/DublinCore/Entry.php'; /** * @see Zend_Feed_Reader_Extension_Content_Entry */ -// require_once 'Zend/Feed/Reader/Extension/Content/Entry.php'; +require_once 'Zend/Feed/Reader/Extension/Content/Entry.php'; /** * @see Zend_Feed_Reader_Extension_Atom_Entry */ -// require_once 'Zend/Feed/Reader/Extension/Atom/Entry.php'; +require_once 'Zend/Feed/Reader/Extension/Atom/Entry.php'; /** * @see Zend_Feed_Reader_Extension_WellformedWeb_Entry */ -// require_once 'Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php'; +require_once 'Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php'; /** * @see Zend_Feed_Reader_Extension_Slash_Entry */ -// require_once 'Zend/Feed/Reader/Extension/Slash/Entry.php'; +require_once 'Zend/Feed/Reader/Extension/Slash/Entry.php'; /** * @see Zend_Feed_Reader_Extension_Thread_Entry */ -// require_once 'Zend/Feed/Reader/Extension/Thread/Entry.php'; +require_once 'Zend/Feed/Reader/Extension/Thread/Entry.php'; /** * @see Zend_Date */ -// require_once 'Zend/Date.php'; - -/** - * @see Zend_Feed_Reader_Collection_Category - */ -// require_once 'Zend/Feed/Reader/Collection/Category.php'; +require_once 'Zend/Date.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implements Zend_Feed_Reader_EntryInterface @@ -159,50 +154,45 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen if (array_key_exists('authors', $this->_data)) { return $this->_data['authors']; } - + $authors = array(); - $authors_dc = $this->getExtension('DublinCore')->getAuthors(); - if (!empty($authors_dc)) { - foreach ($authors_dc as $author) { - $authors[] = array( - 'name' => $author['name'] - ); - } - } - - if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 - && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { - $list = $this->_xpath->query($this->_xpathQueryRss . '//author'); + // @todo: create a list from all potential sources rather than from alternatives + if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && + $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { + $list = $this->_xpath->evaluate($this->_xpathQueryRss.'//author'); } else { - $list = $this->_xpath->query($this->_xpathQueryRdf . '//rss:author'); + $list = $this->_xpath->evaluate($this->_xpathQueryRdf.'//rss:author'); } + if (!$list->length) { + if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { + $list = $this->_xpath->query('//author'); + } else { + $list = $this->_xpath->query('//rss:author'); + } + } + if ($list->length) { foreach ($list as $author) { - $string = trim($author->nodeValue); - $email = null; - $name = null; - $data = array(); - // Pretty rough parsing - but it's a catchall - if (preg_match("/^.*@[^ ]*/", $string, $matches)) { - $data['email'] = trim($matches[0]); - if (preg_match("/\((.*)\)$/", $string, $matches)) { - $data['name'] = $matches[1]; - } - $authors[] = $data; - } + if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_20 + && preg_match("/\(([^\)]+)\)/", $author->nodeValue, $matches, PREG_OFFSET_CAPTURE) + ) { + // source name from RSS 2.0 <author> + // format "joe@example.com (Joe Bloggs)" + $authors[] = $matches[1][0]; + } else { + $authors[] = $author->nodeValue; + } } + + $authors = array_unique($authors); } - if (count($authors) == 0) { - $authors = $this->getExtension('Atom')->getAuthors(); - } else { - $authors = new Zend_Feed_Reader_Collection_Author( - Zend_Feed_Reader::arrayUnique($authors) - ); + if (empty($authors)) { + $authors = $this->getExtension('DublinCore')->getAuthors(); } - if (count($authors) == 0) { - $authors = null; + if (empty($authors)) { + $authors = $this->getExtension('Atom')->getAuthors(); } $this->_data['authors'] = $authors; @@ -265,27 +255,21 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen ) { $dateModified = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/pubDate)'); if ($dateModified) { - $dateModifiedParsed = strtotime($dateModified); - if ($dateModifiedParsed) { - $date = new Zend_Date($dateModifiedParsed); - } else { - $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, - Zend_Date::RFC_2822, Zend_Date::DATES); - $date = new Zend_Date; - foreach ($dateStandards as $standard) { - try { - $date->set($dateModified, $standard); - break; - } catch (Zend_Date_Exception $e) { - if ($standard == Zend_Date::DATES) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception( - 'Could not load date due to unrecognised' - .' format (should follow RFC 822 or 2822):' - . $e->getMessage(), - 0, $e - ); - } + $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, + Zend_Date::RFC_2822, Zend_Date::DATES); + $date = new Zend_Date; + foreach ($dateStandards as $standard) { + try { + $date->set($dateModified, $standard); + break; + } catch (Zend_Date_Exception $e) { + if ($standard == Zend_Date::DATES) { + require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception( + 'Could not load date due to unrecognised' + .' format (should follow RFC 822 or 2822):' + . $e->getMessage() + ); } } } @@ -340,6 +324,8 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen if (!$description) { $description = null; + } else { + $description = html_entity_decode($description, ENT_QUOTES, $this->getEncoding()); } $this->_data['description'] = $description; @@ -472,46 +458,6 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen return $this->_data['links']; } - - /** - * Get all categories - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && - $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { - $list = $this->_xpath->query($this->_xpathQueryRss.'//category'); - } else { - $list = $this->_xpath->query($this->_xpathQueryRdf.'//rss:category'); - } - - if ($list->length) { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - foreach ($list as $category) { - $categoryCollection[] = array( - 'term' => $category->nodeValue, - 'scheme' => $category->getAttribute('domain'), - 'label' => $category->nodeValue, - ); - } - } else { - $categoryCollection = $this->getExtension('DublinCore')->getCategories(); - } - - if (count($categoryCollection) == 0) { - $categoryCollection = $this->getExtension('Atom')->getCategories(); - } - - $this->_data['categories'] = $categoryCollection; - - return $this->_data['categories']; - } /** * Get a permalink to the entry diff --git a/libs/Zend/Feed/Reader/EntryAbstract.php b/libs/Zend/Feed/Reader/EntryAbstract.php index f73e1d1e8e..153149ebcc 100644 --- a/libs/Zend/Feed/Reader/EntryAbstract.php +++ b/libs/Zend/Feed/Reader/EntryAbstract.php @@ -14,15 +14,15 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EntryAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: EntryAbstract.php 16966 2009-07-22 15:22:18Z padraic $ */ /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Feed_Reader_EntryAbstract @@ -118,9 +118,6 @@ abstract class Zend_Feed_Reader_EntryAbstract public function getEncoding() { $assumed = $this->getDomDocument()->encoding; - if (empty($assumed)) { - $assumed = 'UTF-8'; - } return $assumed; } @@ -137,7 +134,7 @@ abstract class Zend_Feed_Reader_EntryAbstract return $dom->saveXml(); } - /** + /** * Get the entry type * * @return string @@ -154,13 +151,10 @@ abstract class Zend_Feed_Reader_EntryAbstract */ public function getXpath() { - if (!$this->_xpath) { - $this->setXpath(new DOMXPath($this->getDomDocument())); - } return $this->_xpath; } - /** + /** * Set the XPath query * * @param DOMXPath $xpath @@ -173,6 +167,16 @@ abstract class Zend_Feed_Reader_EntryAbstract } /** + * Serialize the entry to an array + * + * @return array + */ + public function toArray() + { + return $this->_data; + } + + /** * Get registered extensions * * @return array @@ -211,7 +215,7 @@ abstract class Zend_Feed_Reader_EntryAbstract return call_user_func_array(array($extension, $method), $args); } } - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Method: ' . $method . 'does not exist and could not be located on a registered Extension'); } diff --git a/libs/Zend/Feed/Reader/EntryInterface.php b/libs/Zend/Feed/Reader/EntryInterface.php index 392a533a30..dafbe293dd 100644 --- a/libs/Zend/Feed/Reader/EntryInterface.php +++ b/libs/Zend/Feed/Reader/EntryInterface.php @@ -14,15 +14,15 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EntryInterface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: EntryInterface.php 16953 2009-07-22 11:57:25Z padraic $ */ /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Feed_Reader_EntryInterface @@ -133,11 +133,4 @@ interface Zend_Feed_Reader_EntryInterface * @return string */ public function getCommentFeedLink(); - - /** - * Get all categories - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories(); } diff --git a/libs/Zend/Feed/Reader/Extension/Atom/Entry.php b/libs/Zend/Feed/Reader/Extension/Atom/Entry.php index 1efa197787..f442115801 100644 --- a/libs/Zend/Feed/Reader/Extension/Atom/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/Atom/Entry.php @@ -14,51 +14,41 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 22301 2010-05-26 10:15:13Z padraic $ + * @version $Id: Entry.php 18655 2009-10-20 14:17:39Z padraic $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_Extension_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @see Zend_Date */ -// require_once 'Zend/Date.php'; +require_once 'Zend/Date.php'; /** * @see Zend_Uri */ -// require_once 'Zend/Uri.php'; - -/** - * @see Zend_Feed_Reader_Collection_Category - */ -// require_once 'Zend/Feed/Reader/Collection/Category.php'; - -/** - * @see Zend_Feed_Reader_Feed_Atom_Source - */ -// require_once 'Zend/Feed/Reader/Feed/Atom/Source.php'; +require_once 'Zend/Uri.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Extension_Atom_Entry extends Zend_Feed_Reader_Extension_EntryAbstract { - /** + /** * Get the specified author * * @param int $index @@ -86,34 +76,33 @@ class Zend_Feed_Reader_Extension_Atom_Entry return $this->_data['authors']; } - $authors = array(); - $list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:author'); + $authors = $this->_xpath->query( + $this->getXpathPrefix() . '//atom:author' . '|' + . $this->getXpathPrefix(). '//atom:contributor' + ); - if (!$list->length) { - /** - * TODO: Limit query to feed level els only! - */ - $list = $this->getXpath()->query('//atom:author'); + if (!$authors->length) { + $authors = $this->_xpath->query( + '//atom:author' . '|' . '//atom:contributor' + ); } - if ($list->length) { - foreach ($list as $author) { + $people = array(); + + if ($authors->length) { + foreach ($authors as $author) { $author = $this->_getAuthor($author); + if (!empty($author)) { - $authors[] = $author; + $people[] = $author; } } } - if (count($authors) == 0) { - $authors = null; - } else { - $authors = new Zend_Feed_Reader_Collection_Author( - Zend_Feed_Reader::arrayUnique($authors) - ); - } + $people = array_unique($people); + + $this->_data['authors'] = $people; - $this->_data['authors'] = $authors; return $this->_data['authors']; } @@ -127,65 +116,21 @@ class Zend_Feed_Reader_Extension_Atom_Entry if (array_key_exists('content', $this->_data)) { return $this->_data['content']; } - - $content = null; - - $el = $this->getXpath()->query($this->getXpathPrefix() . '/atom:content'); - if($el->length > 0) { - $el = $el->item(0); - $type = $el->getAttribute('type'); - switch ($type) { - case '': - case 'text': - case 'text/plain': - case 'html': - case 'text/html': - $content = $el->nodeValue; - break; - case 'xhtml': - $this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml'); - $xhtml = $this->getXpath()->query( - $this->getXpathPrefix() . '/atom:content/xhtml:div' - )->item(0); - //$xhtml->setAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); - $d = new DOMDocument('1.0', $this->getEncoding()); - $xhtmls = $d->importNode($xhtml, true); - $d->appendChild($xhtmls); - $content = $this->_collectXhtml( - $d->saveXML(), - $d->lookupPrefix('http://www.w3.org/1999/xhtml') - ); - break; - } + + $content = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:content)'); + + if ($content) { + $content = html_entity_decode($content, ENT_QUOTES, $this->getEncoding()); } - - //var_dump($content); exit; if (!$content) { $content = $this->getDescription(); } - $this->_data['content'] = trim($content); + $this->_data['content'] = $content; return $this->_data['content']; } - - /** - * Parse out XHTML to remove the namespacing - */ - protected function _collectXhtml($xhtml, $prefix) - { - if (!empty($prefix)) $prefix = $prefix . ':'; - $matches = array( - "/<\?xml[^<]*>[^<]*<" . $prefix . "div[^<]*/", - "/<\/" . $prefix . "div>\s*$/" - ); - $xhtml = preg_replace($matches, '', $xhtml); - if (!empty($prefix)) { - $xhtml = preg_replace("/(<[\/]?)" . $prefix . "([a-zA-Z]+)/", '$1$2', $xhtml); - } - return $xhtml; - } /** * Get the entry creation date @@ -200,10 +145,10 @@ class Zend_Feed_Reader_Extension_Atom_Entry $date = null; - if ($this->_getAtomType() === Zend_Feed_Reader::TYPE_ATOM_03) { - $dateCreated = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:created)'); + if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) { + $dateCreated = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:created)'); } else { - $dateCreated = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:published)'); + $dateCreated = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:published)'); } if ($dateCreated) { @@ -229,10 +174,10 @@ class Zend_Feed_Reader_Extension_Atom_Entry $date = null; - if ($this->_getAtomType() === Zend_Feed_Reader::TYPE_ATOM_03) { - $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)'); + if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) { + $dateModified = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)'); } else { - $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:updated)'); + $dateModified = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:updated)'); } if ($dateModified) { @@ -256,10 +201,12 @@ class Zend_Feed_Reader_Extension_Atom_Entry return $this->_data['description']; } - $description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:summary)'); + $description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:summary)'); if (!$description) { $description = null; + } else { + $description = html_entity_decode($description, ENT_QUOTES, $this->getEncoding()); } $this->_data['description'] = $description; @@ -280,7 +227,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry $enclosure = null; - $nodeList = $this->getXpath()->query($this->getXpathPrefix() . '/atom:link[@rel="enclosure"]'); + $nodeList = $this->_xpath->query($this->getXpathPrefix() . '/atom:link[@rel="enclosure"]'); if ($nodeList->length > 0) { $enclosure = new stdClass(); @@ -305,7 +252,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry return $this->_data['id']; } - $id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)'); + $id = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)'); if (!$id) { if ($this->getPermalink()) { @@ -321,7 +268,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry return $this->_data['id']; } - + /** * Get the base URI of the feed (if set). * @@ -332,19 +279,19 @@ class Zend_Feed_Reader_Extension_Atom_Entry if (array_key_exists('baseUrl', $this->_data)) { return $this->_data['baseUrl']; } - - $baseUrl = $this->getXpath()->evaluate('string(' + + $baseUrl = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/@xml:base[1]' . ')'); - + if (!$baseUrl) { - $baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])'); + $baseUrl = $this->_xpath->evaluate('string(//@xml:base[1])'); } if (!$baseUrl) { $baseUrl = null; } - + $this->_data['baseUrl'] = $baseUrl; return $this->_data['baseUrl']; @@ -382,7 +329,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry $links = array(); - $list = $this->getXpath()->query( + $list = $this->_xpath->query( $this->getXpathPrefix() . '//atom:link[@rel="alternate"]/@href' . '|' . $this->getXpathPrefix() . '//atom:link[not(@rel)]/@href' ); @@ -419,10 +366,12 @@ class Zend_Feed_Reader_Extension_Atom_Entry return $this->_data['title']; } - $title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)'); + $title = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)'); if (!$title) { $title = null; + } else { + $title = html_entity_decode($title, ENT_QUOTES, $this->getEncoding()); } $this->_data['title'] = $title; @@ -443,8 +392,8 @@ class Zend_Feed_Reader_Extension_Atom_Entry $count = null; - $this->getXpath()->registerNamespace('thread10', 'http://purl.org/syndication/thread/1.0'); - $list = $this->getXpath()->query( + $this->_xpath->registerNamespace('thread10', 'http://purl.org/syndication/thread/1.0'); + $list = $this->_xpath->query( $this->getXpathPrefix() . '//atom:link[@rel="replies"]/@thread10:count' ); @@ -470,7 +419,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry $link = null; - $list = $this->getXpath()->query( + $list = $this->_xpath->query( $this->getXpathPrefix() . '//atom:link[@rel="replies" and @type="text/html"]/@href' ); @@ -497,7 +446,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry $link = null; - $list = $this->getXpath()->query( + $list = $this->_xpath->query( $this->getXpathPrefix() . '//atom:link[@rel="replies" and @type="application/'.$type.'+xml"]/@href' ); @@ -512,72 +461,6 @@ class Zend_Feed_Reader_Extension_Atom_Entry } /** - * Get all categories - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - if ($this->_getAtomType() == Zend_Feed_Reader::TYPE_ATOM_10) { - $list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:category'); - } else { - /** - * Since Atom 0.3 did not support categories, it would have used the - * Dublin Core extension. However there is a small possibility Atom 0.3 - * may have been retrofittied to use Atom 1.0 instead. - */ - $this->getXpath()->registerNamespace('atom10', Zend_Feed_Reader::NAMESPACE_ATOM_10); - $list = $this->getXpath()->query($this->getXpathPrefix() . '//atom10:category'); - } - - if ($list->length) { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - foreach ($list as $category) { - $categoryCollection[] = array( - 'term' => $category->getAttribute('term'), - 'scheme' => $category->getAttribute('scheme'), - 'label' => $category->getAttribute('label') - ); - } - } else { - return new Zend_Feed_Reader_Collection_Category; - } - - $this->_data['categories'] = $categoryCollection; - - return $this->_data['categories']; - } - - /** - * Get source feed metadata from the entry - * - * @return Zend_Feed_Reader_Feed_Atom_Source|null - */ - public function getSource() - { - if (array_key_exists('source', $this->_data)) { - return $this->_data['source']; - } - - $source = null; - // TODO: Investigate why _getAtomType() fails here. Is it even needed? - if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10) { - $list = $this->getXpath()->query($this->getXpathPrefix() . '/atom:source[1]'); - if ($list->length) { - $element = $list->item(0); - $source = new Zend_Feed_Reader_Feed_Atom_Source($element, $this->getXpathPrefix()); - } - } - - $this->_data['source'] = $source; - return $this->_data['source']; - } - - /** * Attempt to absolutise the URI, i.e. if a relative URI apply the * xml:base value as a prefix to turn into an absolute URI. */ @@ -602,28 +485,35 @@ class Zend_Feed_Reader_Extension_Atom_Entry */ protected function _getAuthor(DOMElement $element) { - $author = array(); + $email = null; + $name = null; + $uri = null; $emailNode = $element->getElementsByTagName('email'); $nameNode = $element->getElementsByTagName('name'); $uriNode = $element->getElementsByTagName('uri'); - - if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) { - $author['email'] = $emailNode->item(0)->nodeValue; + + if ($emailNode->length) { + $email = $emailNode->item(0)->nodeValue; } - if ($nameNode->length && strlen($nameNode->item(0)->nodeValue) > 0) { - $author['name'] = $nameNode->item(0)->nodeValue; + if ($nameNode->length) { + $name = $nameNode->item(0)->nodeValue; } - if ($uriNode->length && strlen($uriNode->item(0)->nodeValue) > 0) { - $author['uri'] = $uriNode->item(0)->nodeValue; + if ($uriNode->length) { + $uri = $uriNode->item(0)->nodeValue; } - if (empty($author)) { - return null; + if (!empty($email)) { + return $email . (empty($name) ? '' : ' (' . $name . ')'); + } else if (!empty($name)) { + return $name; + } else if (!empty($uri)) { + return $uri; } - return $author; + + return null; } /** @@ -631,12 +521,18 @@ class Zend_Feed_Reader_Extension_Atom_Entry */ protected function _registerNamespaces() { - switch ($this->_getAtomType()) { + if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10 + || $this->getType() == Zend_Feed_Reader::TYPE_ATOM_03 + ) { + return; // pre-registered at Feed level + } + $atomDetected = $this->_getAtomType(); + switch ($atomDetected) { case Zend_Feed_Reader::TYPE_ATOM_03: - $this->getXpath()->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_03); + $this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_03); break; default: - $this->getXpath()->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_10); + $this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_10); break; } } @@ -646,16 +542,17 @@ class Zend_Feed_Reader_Extension_Atom_Entry */ protected function _getAtomType() { - $dom = $this->getDomDocument(); - $prefixAtom03 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_03); - $prefixAtom10 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_10); - if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_03) - || !empty($prefixAtom03)) { - return Zend_Feed_Reader::TYPE_ATOM_03; - } - if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_10) - || !empty($prefixAtom10)) { - return Zend_Feed_Reader::TYPE_ATOM_10; + $nslist = $this->getDomDocument()->documentElement->attributes; + if (!$nslist->length) { + return null; + } + foreach ($nslist as $ns) { + if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_10) { + return Zend_Feed_Reader::TYPE_ATOM_10; + } + if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_03) { + return Zend_Feed_Reader::TYPE_ATOM_03; + } } } } diff --git a/libs/Zend/Feed/Reader/Extension/Atom/Feed.php b/libs/Zend/Feed/Reader/Extension/Atom/Feed.php index 3e0e2079c5..4b1de87ed8 100644 --- a/libs/Zend/Feed/Reader/Extension/Atom/Feed.php +++ b/libs/Zend/Feed/Reader/Extension/Atom/Feed.php @@ -14,38 +14,33 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 22301 2010-05-26 10:15:13Z padraic $ + * @version $Id: Feed.php 18655 2009-10-20 14:17:39Z padraic $ */ /** * @see Zend_Feed_Reader_Extension_FeedAbstract */ -// require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; /** * @see Zend_Date */ -// require_once 'Zend/Date.php'; +require_once 'Zend/Date.php'; /** * @see Zend_Uri */ -// require_once 'Zend/Uri.php'; - -/** - * @see Zend_Feed_Reader_Collection_Author - */ -// require_once 'Zend/Feed/Reader/Collection/Author.php'; +require_once 'Zend/Uri.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_Atom_Feed +class Zend_Feed_Reader_Extension_Atom_Feed extends Zend_Feed_Reader_Extension_FeedAbstract { /** @@ -76,28 +71,38 @@ class Zend_Feed_Reader_Extension_Atom_Feed return $this->_data['authors']; } - $list = $this->_xpath->query('//atom:author'); + $authors = $this->_xpath->query('//atom:author'); + $contributors = $this->_xpath->query('//atom:contributor'); - $authors = array(); + $people = array(); - if ($list->length) { - foreach ($list as $author) { + if ($authors->length) { + foreach ($authors as $author) { $author = $this->_getAuthor($author); + if (!empty($author)) { - $authors[] = $author; + $people[] = $author; + } + } + } + + if ($contributors->length) { + foreach ($contributors as $contributor) { + $contributor = $this->_getAuthor($contributor); + + if (!empty($contributor)) { + $people[] = $contributor; } } } - if (count($authors) == 0) { - $authors = null; + if (empty($people)) { + $people = null; } else { - $authors = new Zend_Feed_Reader_Collection_Author( - Zend_Feed_Reader::arrayUnique($authors) - ); + $people = array_unique($people); } - $this->_data['authors'] = $authors; + $this->_data['authors'] = $people; return $this->_data['authors']; } @@ -231,6 +236,8 @@ class Zend_Feed_Reader_Extension_Atom_Feed if (!$generator) { $generator = null; + } else { + $generator = html_entity_decode($generator, ENT_QUOTES, $this->getEncoding()); } $this->_data['generator'] = $generator; @@ -238,7 +245,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed return $this->_data['generator']; } - /** + /** * Get the feed ID * * @return string|null @@ -291,31 +298,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed return $this->_data['language']; } - - /** - * Get the feed image - * - * @return array|null - */ - public function getImage() - { - if (array_key_exists('image', $this->_data)) { - return $this->_data['image']; - } - - $imageUrl = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:logo)'); - - if (!$imageUrl) { - $image = null; - } else { - $image = array('uri'=>$imageUrl); - } - - $this->_data['image'] = $image; - - return $this->_data['image']; - } - + /** * Get the base URI of the feed (if set). * @@ -349,12 +332,12 @@ class Zend_Feed_Reader_Extension_Atom_Feed } $link = null; - + $list = $this->_xpath->query( $this->getXpathPrefix() . '/atom:link[@rel="alternate"]/@href' . '|' . $this->getXpathPrefix() . '/atom:link[not(@rel)]/@href' ); - + if ($list->length) { $link = $list->item(0)->nodeValue; $link = $this->_absolutiseUri($link); @@ -386,34 +369,6 @@ class Zend_Feed_Reader_Extension_Atom_Feed } /** - * Get an array of any supported Pusubhubbub endpoints - * - * @return array|null - */ - public function getHubs() - { - if (array_key_exists('hubs', $this->_data)) { - return $this->_data['hubs']; - } - $hubs = array(); - - $list = $this->_xpath->query($this->getXpathPrefix() - . '//atom:link[@rel="hub"]/@href'); - - if ($list->length) { - foreach ($list as $uri) { - $hubs[] = $this->_absolutiseUri($uri->nodeValue); - } - } else { - $hubs = null; - } - - $this->_data['hubs'] = $hubs; - - return $this->_data['hubs']; - } - - /** * Get the feed title * * @return string|null @@ -434,49 +389,8 @@ class Zend_Feed_Reader_Extension_Atom_Feed return $this->_data['title']; } - - /** - * Get all categories - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10) { - $list = $this->_xpath->query($this->getXpathPrefix() . '/atom:category'); - } else { - /** - * Since Atom 0.3 did not support categories, it would have used the - * Dublin Core extension. However there is a small possibility Atom 0.3 - * may have been retrofittied to use Atom 1.0 instead. - */ - $this->_xpath->registerNamespace('atom10', Zend_Feed_Reader::NAMESPACE_ATOM_10); - $list = $this->_xpath->query($this->getXpathPrefix() . '/atom10:category'); - } - - if ($list->length) { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - foreach ($list as $category) { - $categoryCollection[] = array( - 'term' => $category->getAttribute('term'), - 'scheme' => $category->getAttribute('scheme'), - 'label' => $category->getAttribute('label') - ); - } - } else { - return new Zend_Feed_Reader_Collection_Category; - } - - $this->_data['categories'] = $categoryCollection; - - return $this->_data['categories']; - } - - /** + /** * Get an author entry in RSS format * * @param DOMElement $element @@ -484,30 +398,37 @@ class Zend_Feed_Reader_Extension_Atom_Feed */ protected function _getAuthor(DOMElement $element) { - $author = array(); + $email = null; + $name = null; + $uri = null; $emailNode = $element->getElementsByTagName('email'); $nameNode = $element->getElementsByTagName('name'); $uriNode = $element->getElementsByTagName('uri'); - - if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) { - $author['email'] = $emailNode->item(0)->nodeValue; + + if ($emailNode->length) { + $email = $emailNode->item(0)->nodeValue; } - if ($nameNode->length && strlen($nameNode->item(0)->nodeValue) > 0) { - $author['name'] = $nameNode->item(0)->nodeValue; + if ($nameNode->length) { + $name = $nameNode->item(0)->nodeValue; } - if ($uriNode->length && strlen($uriNode->item(0)->nodeValue) > 0) { - $author['uri'] = $uriNode->item(0)->nodeValue; + if ($uriNode->length) { + $uri = $uriNode->item(0)->nodeValue; } - if (empty($author)) { - return null; + if (!empty($email)) { + return $email . (empty($name) ? '' : ' (' . $name . ')'); + } else if (!empty($name)) { + return $name; + } else if (!empty($uri)) { + return $uri; } - return $author; - } + return null; + } + /** * Attempt to absolutise the URI, i.e. if a relative URI apply the * xml:base value as a prefix to turn into an absolute URI. @@ -530,7 +451,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed */ protected function _registerNamespaces() { - if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10 + if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10 || $this->getType() == Zend_Feed_Reader::TYPE_ATOM_03 ) { return; // pre-registered at Feed level @@ -551,16 +472,17 @@ class Zend_Feed_Reader_Extension_Atom_Feed */ protected function _getAtomType() { - $dom = $this->getDomDocument(); - $prefixAtom03 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_03); - $prefixAtom10 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_10); - if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_10) - || !empty($prefixAtom10)) { - return Zend_Feed_Reader::TYPE_ATOM_10; - } - if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_03) - || !empty($prefixAtom03)) { - return Zend_Feed_Reader::TYPE_ATOM_03; + $nslist = $this->getDomDocument()->documentElement->attributes; + if (!$nslist->length) { + return null; + } + foreach ($nslist as $ns) { + if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_10) { + return Zend_Feed_Reader::TYPE_ATOM_10; + } + if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_03) { + return Zend_Feed_Reader::TYPE_ATOM_03; + } } } } diff --git a/libs/Zend/Feed/Reader/Extension/Content/Entry.php b/libs/Zend/Feed/Reader/Extension/Content/Entry.php index ca10f24a3b..7145281ecb 100644 --- a/libs/Zend/Feed/Reader/Extension/Content/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/Content/Entry.php @@ -14,40 +14,43 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 22301 2010-05-26 10:15:13Z padraic $ + * @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_Entry_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_Content_Entry +class Zend_Feed_Reader_Extension_Content_Entry extends Zend_Feed_Reader_Extension_EntryAbstract { public function getContent() { - if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 + if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090 ) { $content = $this->_xpath->evaluate('string('.$this->getXpathPrefix().'/content:encoded)'); } else { $content = $this->_xpath->evaluate('string('.$this->getXpathPrefix().'/content:encoded)'); } + if ($content) { + $content = html_entity_decode($content, ENT_QUOTES, $this->getEncoding()); + } return $content; } diff --git a/libs/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php b/libs/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php index 5e78db10ab..b9830089d3 100644 --- a/libs/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php @@ -14,25 +14,25 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Feed_Reader_Extension_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @see Zend_Feed_Reader_Extension_CreativeCommons_Feed */ -// require_once 'Zend/Feed/Reader/Extension/CreativeCommons/Feed.php'; +require_once 'Zend/Feed/Reader/Extension/CreativeCommons/Feed.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Extension_CreativeCommons_Entry extends Zend_Feed_Reader_Extension_EntryAbstract diff --git a/libs/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php b/libs/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php index 3d29c6911f..c3d0cd2d42 100644 --- a/libs/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php +++ b/libs/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php @@ -14,23 +14,23 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Feed.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Feed_Reader_Extension_FeedAbstract */ -// require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_CreativeCommons_Feed +class Zend_Feed_Reader_Extension_CreativeCommons_Feed extends Zend_Feed_Reader_Extension_FeedAbstract { /** diff --git a/libs/Zend/Feed/Reader/Extension/DublinCore/Entry.php b/libs/Zend/Feed/Reader/Extension/DublinCore/Entry.php index 4ad104b6ff..522e2c1498 100644 --- a/libs/Zend/Feed/Reader/Extension/DublinCore/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/DublinCore/Entry.php @@ -14,33 +14,33 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 16711 2009-07-14 16:10:54Z matthew $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_Extension_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @see Zend_Date */ -// require_once 'Zend/Date.php'; +require_once 'Zend/Date.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_DublinCore_Entry +class Zend_Feed_Reader_Extension_DublinCore_Entry extends Zend_Feed_Reader_Extension_EntryAbstract { /** @@ -87,56 +87,22 @@ class Zend_Feed_Reader_Extension_DublinCore_Entry if ($list->length) { foreach ($list as $author) { - $authors[] = array( - 'name' => $author->nodeValue - ); + if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_20 + && preg_match("/\(([^\)]+)\)/", $author->nodeValue, $matches, PREG_OFFSET_CAPTURE) + ) { + $authors[] = $matches[1][0]; + } else { + $authors[] = $author->nodeValue; + } } - $authors = new Zend_Feed_Reader_Collection_Author( - Zend_Feed_Reader::arrayUnique($authors) - ); - } else { - $authors = null; + + $authors = array_unique($authors); } $this->_data['authors'] = $authors; return $this->_data['authors']; } - - /** - * Get categories (subjects under DC) - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:subject'); - - if (!$list->length) { - $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:subject'); - } - - if ($list->length) { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - foreach ($list as $category) { - $categoryCollection[] = array( - 'term' => $category->nodeValue, - 'scheme' => null, - 'label' => $category->nodeValue, - ); - } - } else { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - } - - $this->_data['categories'] = $categoryCollection; - return $this->_data['categories']; - } - /** * Get the entry content diff --git a/libs/Zend/Feed/Reader/Extension/DublinCore/Feed.php b/libs/Zend/Feed/Reader/Extension/DublinCore/Feed.php index 4e4bcf4888..68078578b2 100644 --- a/libs/Zend/Feed/Reader/Extension/DublinCore/Feed.php +++ b/libs/Zend/Feed/Reader/Extension/DublinCore/Feed.php @@ -14,36 +14,31 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Feed.php 16711 2009-07-14 16:10:54Z matthew $ */ /** * @see Zend_Feed_Reader_Extension_FeedAbstract */ -// require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; /** * @see Zend_Date */ -// require_once 'Zend/Date.php'; - -/** - * @see Zend_Feed_Reader_Collection_Author - */ -// require_once 'Zend/Feed/Reader/Collection/Author.php'; +require_once 'Zend/Date.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_DublinCore_Feed +class Zend_Feed_Reader_Extension_DublinCore_Feed extends Zend_Feed_Reader_Extension_FeedAbstract { - /** + /** * Get a single author * * @param int $index @@ -84,18 +79,13 @@ class Zend_Feed_Reader_Extension_DublinCore_Feed $list = $this->_xpath->query('//dc10:publisher'); } } - - if ($list->length) { - foreach ($list as $author) { - $authors[] = array( - 'name' => $author->nodeValue - ); - } - $authors = new Zend_Feed_Reader_Collection_Author( - Zend_Feed_Reader::arrayUnique($authors) - ); - } else { - $authors = null; + + foreach ($list as $authorObj) { + $authors[] = $authorObj->nodeValue; + } + + if (!empty($authors)) { + $authors = array_unique($authors); } $this->_data['authors'] = $authors; @@ -261,40 +251,6 @@ class Zend_Feed_Reader_Extension_DublinCore_Feed return $this->_data['date']; } - - /** - * Get categories (subjects under DC) - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:subject'); - - if (!$list->length) { - $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:subject'); - } - - if ($list->length) { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - foreach ($list as $category) { - $categoryCollection[] = array( - 'term' => $category->nodeValue, - 'scheme' => null, - 'label' => $category->nodeValue, - ); - } - } else { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - } - - $this->_data['categories'] = $categoryCollection; - return $this->_data['categories']; - } /** * Register the default namespaces for the current feed format diff --git a/libs/Zend/Feed/Reader/Extension/EntryAbstract.php b/libs/Zend/Feed/Reader/Extension/EntryAbstract.php index 299c1bfbaf..68ae193cf7 100644 --- a/libs/Zend/Feed/Reader/Extension/EntryAbstract.php +++ b/libs/Zend/Feed/Reader/Extension/EntryAbstract.php @@ -14,15 +14,15 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EntryAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: EntryAbstract.php 16711 2009-07-14 16:10:54Z matthew $ */ /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Feed_Reader_Extension_EntryAbstract @@ -86,14 +86,14 @@ abstract class Zend_Feed_Reader_Extension_EntryAbstract if (!is_null($type)) { $this->_data['type'] = $type; } else { - $this->_data['type'] = Zend_Feed_Reader::detectType($entry->ownerDocument, true); + $this->_data['type'] = Zend_Feed_Reader::detectType($feed); } // set the XPath query prefix for the entry being queried - if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_10 + if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_10 || $this->getType() == Zend_Feed_Reader::TYPE_RSS_090 ) { $this->setXpathPrefix('//rss:item[' . ($this->_entryKey+1) . ']'); - } elseif ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10 + } elseif ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10 || $this->getType() == Zend_Feed_Reader::TYPE_ATOM_03 ) { $this->setXpathPrefix('//atom:entry[' . ($this->_entryKey+1) . ']'); @@ -123,7 +123,7 @@ abstract class Zend_Feed_Reader_Extension_EntryAbstract return $assumed; } - /** + /** * Get the entry type * * @return string @@ -153,9 +153,6 @@ abstract class Zend_Feed_Reader_Extension_EntryAbstract */ public function getXpath() { - if (!$this->_xpath) { - $this->setXpath(new DOMXPath($this->getDomDocument())); - } return $this->_xpath; } @@ -181,8 +178,8 @@ abstract class Zend_Feed_Reader_Extension_EntryAbstract /** * Set the XPath prefix - * - * @param string $prefix + * + * @param string $prefix * @return Zend_Feed_Reader_Extension_EntryAbstract */ public function setXpathPrefix($prefix) @@ -193,7 +190,7 @@ abstract class Zend_Feed_Reader_Extension_EntryAbstract /** * Register XML namespaces - * + * * @return void */ protected abstract function _registerNamespaces(); diff --git a/libs/Zend/Feed/Reader/Extension/FeedAbstract.php b/libs/Zend/Feed/Reader/Extension/FeedAbstract.php index 23d97d3f7a..973dd81197 100644 --- a/libs/Zend/Feed/Reader/Extension/FeedAbstract.php +++ b/libs/Zend/Feed/Reader/Extension/FeedAbstract.php @@ -14,36 +14,36 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FeedAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: FeedAbstract.php 16711 2009-07-14 16:10:54Z matthew $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_Entry_Atom */ -// require_once 'Zend/Feed/Reader/Entry/Atom.php'; +require_once 'Zend/Feed/Reader/Entry/Atom.php'; /** * @see Zend_Feed_Reader_Entry_Rss */ -// require_once 'Zend/Feed/Reader/Entry/Rss.php'; +require_once 'Zend/Feed/Reader/Entry/Rss.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Feed_Reader_Extension_FeedAbstract { - /** + /** * Parsed feed data * * @var array @@ -139,33 +139,10 @@ abstract class Zend_Feed_Reader_Extension_FeedAbstract return $this->_data; } - /** - * Set the XPath query - * - * @param DOMXPath $xpath - * @return Zend_Feed_Reader_Extension_EntryAbstract - */ - public function setXpath(DOMXPath $xpath) - { - $this->_xpath = $xpath; - $this->_registerNamespaces(); - return $this; - } - - /** - * Get the DOMXPath object - * - * @return string - */ - public function getXpath() - { - return $this->_xpath; - } - - /** + /** * Get the XPath prefix - * - * @return string + * + * @return string */ public function getXpathPrefix() { diff --git a/libs/Zend/Feed/Reader/Extension/Podcast/Entry.php b/libs/Zend/Feed/Reader/Extension/Podcast/Entry.php index bbe340ce63..7af2285421 100644 --- a/libs/Zend/Feed/Reader/Extension/Podcast/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/Podcast/Entry.php @@ -14,25 +14,25 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 16792 2009-07-17 02:52:37Z norm2782 $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_Extension_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Extension_Podcast_Entry extends Zend_Feed_Reader_Extension_EntryAbstract diff --git a/libs/Zend/Feed/Reader/Extension/Podcast/Feed.php b/libs/Zend/Feed/Reader/Extension/Podcast/Feed.php index c4ea180f7c..b213d34590 100644 --- a/libs/Zend/Feed/Reader/Extension/Podcast/Feed.php +++ b/libs/Zend/Feed/Reader/Extension/Podcast/Feed.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Feed.php 16792 2009-07-17 02:52:37Z norm2782 $ */ /** * @see Zend_Feed_Reader_Extension_FeedAbstract */ -// require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Extension_Podcast_Feed extends Zend_Feed_Reader_Extension_FeedAbstract diff --git a/libs/Zend/Feed/Reader/Extension/Slash/Entry.php b/libs/Zend/Feed/Reader/Extension/Slash/Entry.php index 222c0e1062..b2aa12457b 100644 --- a/libs/Zend/Feed/Reader/Extension/Slash/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/Slash/Entry.php @@ -14,28 +14,28 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_Extension_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_Slash_Entry +class Zend_Feed_Reader_Extension_Slash_Entry extends Zend_Feed_Reader_Extension_EntryAbstract { /** diff --git a/libs/Zend/Feed/Reader/Extension/Syndication/Feed.php b/libs/Zend/Feed/Reader/Extension/Syndication/Feed.php index 5b383cfedb..bd205bcf61 100644 --- a/libs/Zend/Feed/Reader/Extension/Syndication/Feed.php +++ b/libs/Zend/Feed/Reader/Extension/Syndication/Feed.php @@ -14,25 +14,25 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Feed.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Feed_Reader_Extension_FeedAbstract */ -// require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php'; -// require_once 'Zend/Date.php'; +require_once 'Zend/Date.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_Syndication_Feed +class Zend_Feed_Reader_Extension_Syndication_Feed extends Zend_Feed_Reader_Extension_FeedAbstract { /** @@ -57,7 +57,7 @@ class Zend_Feed_Reader_Extension_Syndication_Feed case 'yearly': return $period; default: - throw new Zend_Feed_Exception("Feed specified invalid update period: '$period'." + throw new Zend_Feed_Exception("Feed specified invalid update period: '$period'." . " Must be one of hourly, daily, weekly or yearly" ); } @@ -100,13 +100,13 @@ class Zend_Feed_Reader_Extension_Syndication_Feed switch ($period) { //intentional fall through - case 'yearly': + case 'yearly': $ticks *= 52; //TODO: fix generalisation, how? - case 'weekly': + case 'weekly': $ticks *= 7; - case 'daily': + case 'daily': $ticks *= 24; - case 'hourly': + case 'hourly': $ticks *= 3600; break; default: //Never arrive here, exception thrown in getPeriod() diff --git a/libs/Zend/Feed/Reader/Extension/Thread/Entry.php b/libs/Zend/Feed/Reader/Extension/Thread/Entry.php index e8a4bde92f..c8b632726c 100644 --- a/libs/Zend/Feed/Reader/Extension/Thread/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/Thread/Entry.php @@ -14,28 +14,28 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Feed_Reader_Extension_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_Thread_Entry +class Zend_Feed_Reader_Extension_Thread_Entry extends Zend_Feed_Reader_Extension_EntryAbstract { /** * Get the "in-reply-to" value - * + * * @return string */ public function getInReplyTo() diff --git a/libs/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php b/libs/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php index fe47448338..8c96f6e316 100644 --- a/libs/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php @@ -14,28 +14,28 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; /** * @see Zend_Feed_Reader_Extension_EntryAbstract */ -// require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; +require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Feed_Reader_Extension_WellFormedWeb_Entry +class Zend_Feed_Reader_Extension_WellFormedWeb_Entry extends Zend_Feed_Reader_Extension_EntryAbstract { /** diff --git a/libs/Zend/Feed/Reader/Feed/Atom.php b/libs/Zend/Feed/Reader/Feed/Atom.php index 8199355995..0256e36122 100644 --- a/libs/Zend/Feed/Reader/Feed/Atom.php +++ b/libs/Zend/Feed/Reader/Feed/Atom.php @@ -14,25 +14,25 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 22108 2010-05-05 13:44:11Z padraic $ + * @version $Id: Atom.php 18655 2009-10-20 14:17:39Z padraic $ */ /** * @see Zend_Feed_Reader_FeedAbstract */ -// require_once 'Zend/Feed/Reader/FeedAbstract.php'; +require_once 'Zend/Feed/Reader/FeedAbstract.php'; /** * @see Zend_Feed_Reader_Extension_Atom_Feed */ -// require_once 'Zend/Feed/Reader/Extension/Atom/Feed.php'; +require_once 'Zend/Feed/Reader/Extension/Atom/Feed.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract @@ -41,16 +41,15 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract /** * Constructor * - * @param DOMDocument $dom + * @param Zend_Feed_Abstract $feed * @param string $type + * @param string $xpath */ - public function __construct(DOMDocument $dom, $type = null) + public function __construct(DomDocument $dom, $type = null) { parent::__construct($dom, $type); $atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Atom_Feed'); $this->_extensions['Atom_Feed'] = new $atomClass($dom, $this->_data['type'], $this->_xpath); - $atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('DublinCore_Feed'); - $this->_extensions['DublinCore_Feed'] = new $atomClass($dom, $this->_data['type'], $this->_xpath); foreach ($this->_extensions as $extension) { $extension->setXpathPrefix('/atom:feed'); } @@ -84,9 +83,9 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract return $this->_data['authors']; } - $authors = $this->getExtension('Atom')->getAuthors(); + $people = $this->getExtension('Atom')->getAuthors(); - $this->_data['authors'] = $authors; + $this->_data['authors'] = $people; return $this->_data['authors']; } @@ -158,16 +157,6 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract } /** - * Get the feed lastBuild date. This is not implemented in Atom. - * - * @return string|null - */ - public function getLastBuildDate() - { - return null; - } - - /** * Get the feed description * * @return string|null @@ -207,7 +196,7 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract return $this->_data['generator']; } - /** + /** * Get the feed ID * * @return string|null @@ -250,7 +239,7 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract return $this->_data['language']; } - + /** * Get a link to the source website * @@ -288,24 +277,6 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract } /** - * Get feed image data - * - * @return array|null - */ - public function getImage() - { - if (array_key_exists('image', $this->_data)) { - return $this->_data['image']; - } - - $link = $this->getExtension('Atom')->getImage(); - - $this->_data['image'] = $link; - - return $this->_data['image']; - } - - /** * Get a link to the feed's XML Url * * @return string|null @@ -318,10 +289,6 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract $link = $this->getExtension('Atom')->getFeedLink(); - if (is_null($link) || empty($link)) { - $link = $this->getOriginalSourceUri(); - } - $this->_data['feedlink'] = $link; return $this->_data['feedlink']; @@ -345,50 +312,9 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract return $this->_data['title']; } - /** - * Get an array of any supported Pusubhubbub endpoints - * - * @return array|null - */ - public function getHubs() - { - if (array_key_exists('hubs', $this->_data)) { - return $this->_data['hubs']; - } - - $hubs = $this->getExtension('Atom')->getHubs(); - - $this->_data['hubs'] = $hubs; - - return $this->_data['hubs']; - } - - /** - * Get all categories - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - $categoryCollection = $this->getExtension('Atom')->getCategories(); - - if (count($categoryCollection) == 0) { - $categoryCollection = $this->getExtension('DublinCore')->getCategories(); - } - - $this->_data['categories'] = $categoryCollection; - - return $this->_data['categories']; - } - - /** + /** * Read all entries to the internal entries array * - * @return void */ protected function _indexEntries() { diff --git a/libs/Zend/Feed/Reader/Feed/Atom/Source.php b/libs/Zend/Feed/Reader/Feed/Atom/Source.php deleted file mode 100644 index bdd972f93e..0000000000 --- a/libs/Zend/Feed/Reader/Feed/Atom/Source.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 19165 2009-11-21 16:46:40Z padraic $ - */ - -/** - * @see Zend_Feed_Reader_Feed_Atom - */ -// require_once 'Zend/Feed/Reader/Feed/Atom.php'; - -/** - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Reader_Feed_Atom_Source extends Zend_Feed_Reader_Feed_Atom -{ - - /** - * Constructor: Create a Source object which is largely just a normal - * Zend_Feed_Reader_FeedAbstract object only designed to retrieve feed level - * metadata from an Atom entry's source element. - * - * @param DOMElement $source - * @param string $xpathPrefix Passed from parent Entry object - * @param string $type Nearly always Atom 1.0 - */ - public function __construct(DOMElement $source, $xpathPrefix, $type = Zend_Feed_Reader::TYPE_ATOM_10) - { - $this->_domDocument = $source->ownerDocument; - $this->_xpath = new DOMXPath($this->_domDocument); - $this->_data['type'] = $type; - $this->_registerNamespaces(); - $this->_loadExtensions(); - - $atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Atom_Feed'); - $this->_extensions['Atom_Feed'] = new $atomClass($this->_domDocument, $this->_data['type'], $this->_xpath); - $atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('DublinCore_Feed'); - $this->_extensions['DublinCore_Feed'] = new $atomClass($this->_domDocument, $this->_data['type'], $this->_xpath); - foreach ($this->_extensions as $extension) { - $extension->setXpathPrefix(rtrim($xpathPrefix, '/') . '/atom:source'); - } - } - - /** - * Since this is not an Entry carrier but a vehicle for Feed metadata, any - * applicable Entry methods are stubbed out and do nothing. - */ - - /** - * @return void - */ - public function count() {} - - /** - * @return void - */ - public function current() {} - - /** - * @return void - */ - public function key() {} - - /** - * @return void - */ - public function next() {} - - /** - * @return void - */ - public function rewind() {} - - /** - * @return void - */ - public function valid() {} - - /** - * @return void - */ - protected function _indexEntries() {} - -} diff --git a/libs/Zend/Feed/Reader/Feed/Rss.php b/libs/Zend/Feed/Reader/Feed/Rss.php index bff78c3455..2dc2ec86f4 100644 --- a/libs/Zend/Feed/Reader/Feed/Rss.php +++ b/libs/Zend/Feed/Reader/Feed/Rss.php @@ -14,40 +14,35 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 22301 2010-05-26 10:15:13Z padraic $ + * @version $Id: Rss.php 18367 2009-09-22 14:55:59Z padraic $ */ /** * @see Zend_Feed_Reader_FeedAbstract */ -// require_once 'Zend/Feed/Reader/FeedAbstract.php'; +require_once 'Zend/Feed/Reader/FeedAbstract.php'; /** * @see Zend_feed_Reader_Extension_Atom_Feed */ -// require_once 'Zend/Feed/Reader/Extension/Atom/Feed.php'; +require_once 'Zend/Feed/Reader/Extension/Atom/Feed.php'; /** * @see Zend_Feed_Reader_Extension_DublinCore_Feed */ -// require_once 'Zend/Feed/Reader/Extension/DublinCore/Feed.php'; +require_once 'Zend/Feed/Reader/Extension/DublinCore/Feed.php'; /** * @see Zend_Date */ -// require_once 'Zend/Date.php'; - -/** - * @see Zend_Feed_Reader_Collection_Author - */ -// require_once 'Zend/Feed/Reader/Collection/Author.php'; +require_once 'Zend/Date.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract @@ -56,8 +51,9 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract /** * Constructor * - * @param DOMDocument $dom + * @param Zend_Feed_Abstract $feed * @param string $type + * @param string $xpath */ public function __construct(DomDocument $dom, $type = null) { @@ -78,7 +74,7 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract } } - /** + /** * Get a single author * * @param int $index @@ -105,54 +101,33 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract if (array_key_exists('authors', $this->_data)) { return $this->_data['authors']; } - + $authors = array(); - $authors_dc = $this->getExtension('DublinCore')->getAuthors(); - if (!empty($authors_dc)) { - foreach ($authors_dc as $author) { - $authors[] = array( - 'name' => $author['name'] - ); - } + + if (empty($authors)) { + $authors = $this->getExtension('DublinCore')->getAuthors(); } - /** - * Technically RSS doesn't specific author element use at the feed level - * but it's supported on a "just in case" basis. - */ - if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 - && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { - $list = $this->_xpath->query('//author'); - } else { - $list = $this->_xpath->query('//rss:author'); - } - if ($list->length) { - foreach ($list as $author) { - $string = trim($author->nodeValue); - $email = null; - $name = null; - $data = array(); - // Pretty rough parsing - but it's a catchall - if (preg_match("/^.*@[^ ]*/", $string, $matches)) { - $data['email'] = trim($matches[0]); - if (preg_match("/\((.*)\)$/", $string, $matches)) { - $data['name'] = $matches[1]; - } - $authors[] = $data; - } + if (empty($authors)) { + if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { + $list = $this->_xpath->query('//author'); + } else { + $list = $this->_xpath->query('//rss:author'); + } + + foreach ($list as $authorObj) { + $authors[] = $authorObj->nodeValue; } } - if (count($authors) == 0) { + if (empty($authors)) { $authors = $this->getExtension('Atom')->getAuthors(); - } else { - $authors = new Zend_Feed_Reader_Collection_Author( - Zend_Feed_Reader::arrayUnique($authors) - ); } - if (count($authors) == 0) { + if (empty($authors)) { $authors = null; + } else { + $authors = array_unique($authors); } $this->_data['authors'] = $authors; @@ -195,7 +170,7 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract return $this->_data['copyright']; } - /** + /** * Get the feed creation date * * @return string|null @@ -226,27 +201,21 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract $dateModified = $this->_xpath->evaluate('string(/rss/channel/lastBuildDate)'); } if ($dateModified) { - $dateModifiedParsed = strtotime($dateModified); - if ($dateModifiedParsed) { - $date = new Zend_Date($dateModifiedParsed); - } else { - $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, - Zend_Date::RFC_2822, Zend_Date::DATES); - $date = new Zend_Date; - foreach ($dateStandards as $standard) { - try { - $date->set($dateModified, $standard); - break; - } catch (Zend_Date_Exception $e) { - if ($standard == Zend_Date::DATES) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception( - 'Could not load date due to unrecognised' - .' format (should follow RFC 822 or 2822):' - . $e->getMessage(), - 0, $e - ); - } + $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, + Zend_Date::RFC_2822, Zend_Date::DATES); + $date = new Zend_Date; + foreach ($dateStandards as $standard) { + try { + $date->set($dateModified, $standard); + break; + } catch (Zend_Date_Exception $e) { + if ($standard == Zend_Date::DATES) { + require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception( + 'Could not load date due to unrecognised' + .' format (should follow RFC 822 or 2822):' + . $e->getMessage() + ); } } } @@ -271,60 +240,6 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract } /** - * Get the feed lastBuild date - * - * @return Zend_Date - */ - public function getLastBuildDate() - { - if (array_key_exists('lastBuildDate', $this->_data)) { - return $this->_data['lastBuildDate']; - } - - $lastBuildDate = null; - $date = null; - - if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && - $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { - $lastBuildDate = $this->_xpath->evaluate('string(/rss/channel/lastBuildDate)'); - if ($lastBuildDate) { - $lastBuildDateParsed = strtotime($lastBuildDate); - if ($lastBuildDateParsed) { - $date = new Zend_Date($lastBuildDateParsed); - } else { - $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, - Zend_Date::RFC_2822, Zend_Date::DATES); - $date = new Zend_Date; - foreach ($dateStandards as $standard) { - try { - $date->set($lastBuildDate, $standard); - break; - } catch (Zend_Date_Exception $e) { - if ($standard == Zend_Date::DATES) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception( - 'Could not load date due to unrecognised' - .' format (should follow RFC 822 or 2822):' - . $e->getMessage(), - 0, $e - ); - } - } - } - } - } - } - - if (!$date) { - $date = null; - } - - $this->_data['lastBuildDate'] = $date; - - return $this->_data['lastBuildDate']; - } - - /** * Get the feed description * * @return string|null @@ -403,60 +318,6 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract } /** - * Get the feed image data - * - * @return array|null - */ - public function getImage() - { - if (array_key_exists('image', $this->_data)) { - return $this->_data['image']; - } - - if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && - $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { - $list = $this->_xpath->query('/rss/channel/image'); - $prefix = '/rss/channel/image[1]'; - } else { - $list = $this->_xpath->query('/rdf:RDF/rss:channel/rss:image'); - $prefix = '/rdf:RDF/rss:channel/rss:image[1]'; - } - if ($list->length > 0) { - $image = array(); - $value = $this->_xpath->evaluate('string(' . $prefix . '/url)'); - if ($value) { - $image['uri'] = $value; - } - $value = $this->_xpath->evaluate('string(' . $prefix . '/link)'); - if ($value) { - $image['link'] = $value; - } - $value = $this->_xpath->evaluate('string(' . $prefix . '/title)'); - if ($value) { - $image['title'] = $value; - } - $value = $this->_xpath->evaluate('string(' . $prefix . '/height)'); - if ($value) { - $image['height'] = $value; - } - $value = $this->_xpath->evaluate('string(' . $prefix . '/width)'); - if ($value) { - $image['width'] = $value; - } - $value = $this->_xpath->evaluate('string(' . $prefix . '/description)'); - if ($value) { - $image['description'] = $value; - } - } else { - $image = null; - } - - $this->_data['image'] = $image; - - return $this->_data['image']; - } - - /** * Get the feed language * * @return string|null @@ -543,8 +404,8 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract $link = $this->getExtension('Atom')->getFeedLink(); - if (is_null($link) || empty($link)) { - $link = $this->getOriginalSourceUri(); + if (!$link) { + $link = null; } $this->_data['feedlink'] = $link; @@ -577,6 +438,9 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract } else { $generator = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/atom:generator)'); } + if ($generator) { + $generator = html_entity_decode($generator, ENT_QUOTES, $this->getEncoding()); + } } if (empty($generator)) { @@ -629,71 +493,7 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract return $this->_data['title']; } - /** - * Get an array of any supported Pusubhubbub endpoints - * - * @return array|null - */ - public function getHubs() - { - if (array_key_exists('hubs', $this->_data)) { - return $this->_data['hubs']; - } - - $hubs = $this->getExtension('Atom')->getHubs(); - - if (empty($hubs)) { - $hubs = null; - } else { - $hubs = array_unique($hubs); - } - - $this->_data['hubs'] = $hubs; - - return $this->_data['hubs']; - } - - /** - * Get all categories - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && - $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { - $list = $this->_xpath->query('/rss/channel//category'); - } else { - $list = $this->_xpath->query('/rdf:RDF/rss:channel//rss:category'); - } - - if ($list->length) { - $categoryCollection = new Zend_Feed_Reader_Collection_Category; - foreach ($list as $category) { - $categoryCollection[] = array( - 'term' => $category->nodeValue, - 'scheme' => $category->getAttribute('domain'), - 'label' => $category->nodeValue, - ); - } - } else { - $categoryCollection = $this->getExtension('DublinCore')->getCategories(); - } - - if (count($categoryCollection) == 0) { - $categoryCollection = $this->getExtension('Atom')->getCategories(); - } - - $this->_data['categories'] = $categoryCollection; - - return $this->_data['categories']; - } - - /** + /** * Read all entries to the internal entries array * */ diff --git a/libs/Zend/Feed/Reader/FeedAbstract.php b/libs/Zend/Feed/Reader/FeedAbstract.php index bda9f23b46..1e8da71726 100644 --- a/libs/Zend/Feed/Reader/FeedAbstract.php +++ b/libs/Zend/Feed/Reader/FeedAbstract.php @@ -14,30 +14,41 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FeedAbstract.php 22093 2010-05-04 12:55:06Z padraic $ + * @version $Id: FeedAbstract.php 16966 2009-07-22 15:22:18Z padraic $ */ /** * @see Zend_Feed_Reader */ -// require_once 'Zend/Feed/Reader.php'; +require_once 'Zend/Feed/Reader.php'; + +/** + * @see Zend_Feed_Reader_Entry_Atom + */ +require_once 'Zend/Feed/Reader/Entry/Atom.php'; + + +/** + * @see Zend_Feed_Reader_Entry_Rss + */ +require_once 'Zend/Feed/Reader/Entry/Rss.php'; /** * @see Zend_feed_Reader_FeedInterface */ -// require_once 'Zend/Feed/Reader/FeedInterface.php'; +require_once 'Zend/Feed/Reader/FeedInterface.php'; /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInterface { - /** + /** * Parsed feed data * * @var array @@ -72,21 +83,9 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt */ protected $_xpath = null; - /** - * Array of loaded extensions - * - * @var array - */ protected $_extensions = array(); /** - * Original Source URI (set if imported from a URI) - * - * @var string - */ - protected $_originalSourceUri = null; - - /** * Constructor * * @param DomDocument The DOM object for the feed's XML @@ -107,30 +106,7 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt $this->_loadExtensions(); } - /** - * Set an original source URI for the feed being parsed. This value - * is returned from getFeedLink() method if the feed does not carry - * a self-referencing URI. - * - * @param string $uri - */ - public function setOriginalSourceUri($uri) - { - $this->_originalSourceUri = $uri; - } - - /** - * Get an original source URI for the feed being parsed. Returns null if - * unset or the feed was not imported from a URI. - * - * @return string|null - */ - public function getOriginalSourceUri() - { - return $this->_originalSourceUri; - } - - /** + /** * Get the number of feed entries. * Required by the Iterator interface. * @@ -141,10 +117,10 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt return count($this->_entries); } - /** + /** * Return the current entry * - * @return Zend_Feed_Reader_EntryInterface + * @return Zend_Feed_Reader_Entry_Interface */ public function current() { @@ -177,9 +153,6 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt public function getEncoding() { $assumed = $this->getDomDocument()->encoding; - if (empty($assumed)) { - $assumed = 'UTF-8'; - } return $assumed; } @@ -223,7 +196,7 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt return $this->_data['type']; } - /** + /** * Return the current feed key * * @return unknown @@ -233,7 +206,7 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt return $this->_entriesKey; } - /** + /** * Move the feed pointer forward * */ @@ -252,6 +225,16 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt } /** + * Return the feed as an array + * + * @return array + */ + public function toArray() // untested + { + return $this->_data; + } + + /** * Check to see if the iterator is still valid * * @return boolean @@ -273,7 +256,7 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt return call_user_func_array(array($extension, $method), $args); } } - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Method: ' . $method . 'does not exist and could not be located on a registered Extension'); } diff --git a/libs/Zend/Feed/Reader/FeedInterface.php b/libs/Zend/Feed/Reader/FeedInterface.php index 35060bafce..3278f3ea75 100644 --- a/libs/Zend/Feed/Reader/FeedInterface.php +++ b/libs/Zend/Feed/Reader/FeedInterface.php @@ -14,15 +14,15 @@ * * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FeedInterface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: FeedInterface.php 16953 2009-07-22 11:57:25Z padraic $ */ /** * @category Zend * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Feed_Reader_FeedInterface extends Iterator, Countable @@ -111,12 +111,5 @@ interface Zend_Feed_Reader_FeedInterface extends Iterator, Countable * @return string|null */ public function getTitle(); - - /** - * Get all categories - * - * @return Zend_Feed_Reader_Collection_Category - */ - public function getCategories(); } diff --git a/libs/Zend/Feed/Reader/FeedSet.php b/libs/Zend/Feed/Reader/FeedSet.php deleted file mode 100644 index 57ccbf6056..0000000000 --- a/libs/Zend/Feed/Reader/FeedSet.php +++ /dev/null @@ -1,148 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FeedSet.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Feed_Reader - */ -// require_once 'Zend/Feed/Reader.php'; - -/** - * @see Zend_Uri - */ -// require_once 'Zend/Uri.php'; - -/** - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Reader_FeedSet extends ArrayObject -{ - - public $rss = null; - - public $rdf = null; - - public $atom = null; - - /** - * Import a DOMNodeList from any document containing a set of links - * for alternate versions of a document, which will normally refer to - * RSS/RDF/Atom feeds for the current document. - * - * All such links are stored internally, however the first instance of - * each RSS, RDF or Atom type has its URI stored as a public property - * as a shortcut where the use case is simply to get a quick feed ref. - * - * Note that feeds are not loaded at this point, but will be lazy - * loaded automatically when each links 'feed' array key is accessed. - * - * @param DOMNodeList $links - * @param string $uri - * @return void - */ - public function addLinks(DOMNodeList $links, $uri) - { - foreach ($links as $link) { - if (strtolower($link->getAttribute('rel')) !== 'alternate' - || !$link->getAttribute('type') || !$link->getAttribute('href')) { - continue; - } - if (!isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') { - $this->rss = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); - } elseif(!isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') { - $this->atom = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); - } elseif(!isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') { - $this->rdf = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); - } - $this[] = new self(array( - 'rel' => 'alternate', - 'type' => $link->getAttribute('type'), - 'href' => $this->_absolutiseUri(trim($link->getAttribute('href')), $uri), - )); - } - } - - /** - * Attempt to turn a relative URI into an absolute URI - */ - protected function _absolutiseUri($link, $uri = null) - { - if (!Zend_Uri::check($link)) { - if (!is_null($uri)) { - $uri = Zend_Uri::factory($uri); - - if ($link[0] !== '/') { - $link = $uri->getPath() . '/' . $link; - } - - $link = $uri->getScheme() . '://' . $uri->getHost() . '/' . $this->_canonicalizePath($link); - if (!Zend_Uri::check($link)) { - $link = null; - } - } - } - return $link; - } - - /** - * Canonicalize relative path - */ - protected function _canonicalizePath($path) - { - $parts = array_filter(explode('/', $path)); - $absolutes = array(); - foreach ($parts as $part) { - if ('.' == $part) { - continue; - } - if ('..' == $part) { - array_pop($absolutes); - } else { - $absolutes[] = $part; - } - } - return implode('/', $absolutes); - } - - /** - * Supports lazy loading of feeds using Zend_Feed_Reader::import() but - * delegates any other operations to the parent class. - * - * @param string $offset - * @return mixed - * @uses Zend_Feed_Reader - */ - public function offsetGet($offset) - { - if ($offset == 'feed' && !$this->offsetExists('feed')) { - if (!$this->offsetExists('href')) { - return null; - } - $feed = Zend_Feed_Reader::import($this->offsetGet('href')); - $this->offsetSet('feed', $feed); - return $feed; - } - return parent::offsetGet($offset); - } - -} diff --git a/libs/Zend/Feed/Rss.php b/libs/Zend/Feed/Rss.php index 19eaa8ec19..351dcdf2e5 100644 --- a/libs/Zend/Feed/Rss.php +++ b/libs/Zend/Feed/Rss.php @@ -15,21 +15,21 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Rss.php 18266 2009-09-18 18:32:30Z padraic $ */ /** * @see Zend_Feed_Abstract */ -// require_once 'Zend/Feed/Abstract.php'; +require_once 'Zend/Feed/Abstract.php'; /** * @see Zend_Feed_Entry_Rss */ -// require_once 'Zend/Feed/Entry/Rss.php'; +require_once 'Zend/Feed/Entry/Rss.php'; /** @@ -43,7 +43,7 @@ * * @category Zend * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Feed_Rss extends Zend_Feed_Abstract @@ -82,7 +82,7 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract // Find the base channel element and create an alias to it. $rdfTags = $this->_element->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'RDF'); if ($rdfTags->length != 0) { - $this->_element = $rdfTags->item(0); + $this->_element = $rdfTags->item(0); } else { $this->_element = $this->_element->getElementsByTagName('channel')->item(0); } @@ -90,7 +90,7 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('No root <channel> element found, cannot parse channel.'); } @@ -282,12 +282,11 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract $author = ''; $email = ''; if (isset($array->itunes->owner)) { - $itunesOwner = $array->itunes->owner; - if (isset($itunesOwner['name'])) { - $author = $itunesOwner['name']; + if (isset($array->itunes->owner['name'])) { + $author = $array->itunes->owner['name']; } - if (isset($itunesOwner['email'])) { - $email = $itunesOwner['email']; + if (isset($array->itunes->owner['email'])) { + $email = $array->itunes->owner['email']; } } if (empty($author) && isset($array->author)) { @@ -412,9 +411,6 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract if (isset($dataentry->guid)) { $guid = $this->_element->createElement('guid', $dataentry->guid); - if (!Zend_Uri::check($dataentry->guid)) { - $guid->setAttribute('isPermaLink', 'false'); - } $item->appendChild($guid); } @@ -518,7 +514,7 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract /** * @see Zend_Feed_Exception */ - // require_once 'Zend/Feed/Exception.php'; + require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Cannot send RSS because headers have already been sent.'); } diff --git a/libs/Zend/Feed/Writer.php b/libs/Zend/Feed/Writer.php deleted file mode 100644 index 1a40f63cd9..0000000000 --- a/libs/Zend/Feed/Writer.php +++ /dev/null @@ -1,267 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Writer.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer -{ - /** - * Namespace constants - */ - const NAMESPACE_ATOM_03 = 'http://purl.org/atom/ns#'; - const NAMESPACE_ATOM_10 = 'http://www.w3.org/2005/Atom'; - const NAMESPACE_RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; - const NAMESPACE_RSS_090 = 'http://my.netscape.com/rdf/simple/0.9/'; - const NAMESPACE_RSS_10 = 'http://purl.org/rss/1.0/'; - - /** - * Feed type constants - */ - const TYPE_ANY = 'any'; - const TYPE_ATOM_03 = 'atom-03'; - const TYPE_ATOM_10 = 'atom-10'; - const TYPE_ATOM_ANY = 'atom'; - const TYPE_RSS_090 = 'rss-090'; - const TYPE_RSS_091 = 'rss-091'; - const TYPE_RSS_091_NETSCAPE = 'rss-091n'; - const TYPE_RSS_091_USERLAND = 'rss-091u'; - const TYPE_RSS_092 = 'rss-092'; - const TYPE_RSS_093 = 'rss-093'; - const TYPE_RSS_094 = 'rss-094'; - const TYPE_RSS_10 = 'rss-10'; - const TYPE_RSS_20 = 'rss-20'; - const TYPE_RSS_ANY = 'rss'; - - /** - * PluginLoader instance used by component - * - * @var Zend_Loader_PluginLoader_Interface - */ - protected static $_pluginLoader = null; - - /** - * Path on which to search for Extension classes - * - * @var array - */ - protected static $_prefixPaths = array(); - - /** - * Array of registered extensions by class postfix (after the base class - * name) across four categories - data containers and renderers for entry - * and feed levels. - * - * @var array - */ - protected static $_extensions = array( - 'entry' => array(), - 'feed' => array(), - 'entryRenderer' => array(), - 'feedRenderer' => array(), - ); - - /** - * Set plugin loader for use with Extensions - * - * @param Zend_Loader_PluginLoader_Interface - */ - public static function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader) - { - self::$_pluginLoader = $loader; - } - - /** - * Get plugin loader for use with Extensions - * - * @return Zend_Loader_PluginLoader_Interface - */ - public static function getPluginLoader() - { - if (!isset(self::$_pluginLoader)) { - // require_once 'Zend/Loader/PluginLoader.php'; - self::$_pluginLoader = new Zend_Loader_PluginLoader(array( - 'Zend_Feed_Writer_Extension_' => 'Zend/Feed/Writer/Extension/', - )); - } - return self::$_pluginLoader; - } - - /** - * Add prefix path for loading Extensions - * - * @param string $prefix - * @param string $path - * @return void - */ - public static function addPrefixPath($prefix, $path) - { - $prefix = rtrim($prefix, '_'); - $path = rtrim($path, DIRECTORY_SEPARATOR); - self::getPluginLoader()->addPrefixPath($prefix, $path); - } - - /** - * Add multiple Extension prefix paths at once - * - * @param array $spec - * @return void - */ - public static function addPrefixPaths(array $spec) - { - if (isset($spec['prefix']) && isset($spec['path'])) { - self::addPrefixPath($spec['prefix'], $spec['path']); - } - foreach ($spec as $prefixPath) { - if (isset($prefixPath['prefix']) && isset($prefixPath['path'])) { - self::addPrefixPath($prefixPath['prefix'], $prefixPath['path']); - } - } - } - - /** - * Register an Extension by name - * - * @param string $name - * @return void - * @throws Zend_Feed_Exception if unable to resolve Extension class - */ - public static function registerExtension($name) - { - $feedName = $name . '_Feed'; - $entryName = $name . '_Entry'; - $feedRendererName = $name . '_Renderer_Feed'; - $entryRendererName = $name . '_Renderer_Entry'; - if (self::isRegistered($name)) { - if (self::getPluginLoader()->isLoaded($feedName) - || self::getPluginLoader()->isLoaded($entryName) - || self::getPluginLoader()->isLoaded($feedRendererName) - || self::getPluginLoader()->isLoaded($entryRendererName) - ) { - return; - } - } - try { - self::getPluginLoader()->load($feedName); - self::$_extensions['feed'][] = $feedName; - } catch (Zend_Loader_PluginLoader_Exception $e) { - } - try { - self::getPluginLoader()->load($entryName); - self::$_extensions['entry'][] = $entryName; - } catch (Zend_Loader_PluginLoader_Exception $e) { - } - try { - self::getPluginLoader()->load($feedRendererName); - self::$_extensions['feedRenderer'][] = $feedRendererName; - } catch (Zend_Loader_PluginLoader_Exception $e) { - } - try { - self::getPluginLoader()->load($entryRendererName); - self::$_extensions['entryRenderer'][] = $entryRendererName; - } catch (Zend_Loader_PluginLoader_Exception $e) { - } - if (!self::getPluginLoader()->isLoaded($feedName) - && !self::getPluginLoader()->isLoaded($entryName) - && !self::getPluginLoader()->isLoaded($feedRendererName) - && !self::getPluginLoader()->isLoaded($entryRendererName) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Could not load extension: ' . $name - . 'using Plugin Loader. Check prefix paths are configured and extension exists.'); - } - } - - /** - * Is a given named Extension registered? - * - * @param string $extensionName - * @return boolean - */ - public static function isRegistered($extensionName) - { - $feedName = $extensionName . '_Feed'; - $entryName = $extensionName . '_Entry'; - $feedRendererName = $extensionName . '_Renderer_Feed'; - $entryRendererName = $extensionName . '_Renderer_Entry'; - if (in_array($feedName, self::$_extensions['feed']) - || in_array($entryName, self::$_extensions['entry']) - || in_array($feedRendererName, self::$_extensions['feedRenderer']) - || in_array($entryRendererName, self::$_extensions['entryRenderer']) - ) { - return true; - } - return false; - } - - /** - * Get a list of extensions - * - * @return array - */ - public static function getExtensions() - { - return self::$_extensions; - } - - /** - * Reset class state to defaults - * - * @return void - */ - public static function reset() - { - self::$_pluginLoader = null; - self::$_prefixPaths = array(); - self::$_extensions = array( - 'entry' => array(), - 'feed' => array(), - 'entryRenderer' => array(), - 'feedRenderer' => array(), - ); - } - - /** - * Register core (default) extensions - * - * @return void - */ - public static function registerCoreExtensions() - { - self::registerExtension('DublinCore'); - self::registerExtension('Content'); - self::registerExtension('Atom'); - self::registerExtension('Slash'); - self::registerExtension('WellFormedWeb'); - self::registerExtension('Threading'); - self::registerExtension('ITunes'); - } - - public static function lcfirst($str) - { - $str[0] = strtolower($str[0]); - return $str; - } - -} diff --git a/libs/Zend/Feed/Writer/Deleted.php b/libs/Zend/Feed/Writer/Deleted.php deleted file mode 100644 index 19bb56b49e..0000000000 --- a/libs/Zend/Feed/Writer/Deleted.php +++ /dev/null @@ -1,202 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -// require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php'; - - /** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Deleted -{ - - /** - * Internal array containing all data associated with this entry or item. - * - * @var array - */ - protected $_data = array(); - - /** - * Holds the value "atom" or "rss" depending on the feed type set when - * when last exported. - * - * @var string - */ - protected $_type = null; - - /** - * Set the feed character encoding - * - * @return string|null - */ - public function setEncoding($encoding) - { - if (empty($encoding) || !is_string($encoding)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['encoding'] = $encoding; - } - - /** - * Get the feed character encoding - * - * @return string|null - */ - public function getEncoding() - { - if (!array_key_exists('encoding', $this->_data)) { - return 'UTF-8'; - } - return $this->_data['encoding']; - } - - /** - * Unset a specific data point - * - * @param string $name - */ - public function remove($name) - { - if (isset($this->_data[$name])) { - unset($this->_data[$name]); - } - } - - /** - * Set the current feed type being exported to "rss" or "atom". This allows - * other objects to gracefully choose whether to execute or not, depending - * on their appropriateness for the current type, e.g. renderers. - * - * @param string $type - */ - public function setType($type) - { - $this->_type = $type; - } - - /** - * Retrieve the current or last feed type exported. - * - * @return string Value will be "rss" or "atom" - */ - public function getType() - { - return $this->_type; - } - - public function setReference($reference) - { - if (empty($reference) || !is_string($reference)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: reference must be a non-empty string'); - } - $this->_data['reference'] = $reference; - } - - public function getReference() - { - if (!array_key_exists('reference', $this->_data)) { - return null; - } - return $this->_data['reference']; - } - - public function setWhen($date = null) - { - $zdate = null; - if (is_null($date)) { - $zdate = new Zend_Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { - $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); - } elseif ($date instanceof Zend_Date) { - $zdate = $date; - } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['when'] = $zdate; - } - - public function getWhen() - { - if (!array_key_exists('when', $this->_data)) { - return null; - } - return $this->_data['when']; - } - - public function setBy(array $by) - { - $author = array(); - if (!array_key_exists('name', $by) - || empty($by['name']) - || !is_string($by['name']) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value'); - } - $author['name'] = $by['name']; - if (isset($by['email'])) { - if (empty($by['email']) || !is_string($by['email'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string'); - } - $author['email'] = $by['email']; - } - if (isset($by['uri'])) { - if (empty($by['uri']) - || !is_string($by['uri']) - || !Zend_Uri::check($by['uri']) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'); - } - $author['uri'] = $by['uri']; - } - $this->_data['by'] = $author; - } - - public function getBy() - { - if (!array_key_exists('by', $this->_data)) { - return null; - } - return $this->_data['by']; - } - - public function setComment($comment) - { - $this->_data['comment'] = $comment; - } - - public function getComment() - { - if (!array_key_exists('comment', $this->_data)) { - return null; - } - return $this->_data['comment']; - } - -} diff --git a/libs/Zend/Feed/Writer/Entry.php b/libs/Zend/Feed/Writer/Entry.php deleted file mode 100644 index 01d290e6fb..0000000000 --- a/libs/Zend/Feed/Writer/Entry.php +++ /dev/null @@ -1,761 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 22065 2010-04-30 14:04:57Z padraic $ - */ - -/** - * @see Zend_Date - */ -// require_once 'Zend/Date.php'; - -/** - * @see Zend_Date - */ -// require_once 'Zend/Uri.php'; - -// require_once 'Zend/Feed/Writer/Source.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Entry -{ - - /** - * Internal array containing all data associated with this entry or item. - * - * @var array - */ - protected $_data = array(); - - /** - * Registered extensions - * - * @var array - */ - protected $_extensions = array(); - - /** - * Holds the value "atom" or "rss" depending on the feed type set when - * when last exported. - * - * @var string - */ - protected $_type = null; - - /** - * Constructor: Primarily triggers the registration of core extensions and - * loads those appropriate to this data container. - * - * @return void - */ - public function __construct() - { - Zend_Feed_Writer::registerCoreExtensions(); - $this->_loadExtensions(); - } - - /** - * Set a single author - * - * @param int $index - * @return string|null - */ - public function addAuthor($name, $email = null, $uri = null) - { - $author = array(); - if (is_array($name)) { - if (!array_key_exists('name', $name) - || empty($name['name']) - || !is_string($name['name']) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value'); - } - $author['name'] = $name['name']; - if (isset($name['email'])) { - if (empty($name['email']) || !is_string($name['email'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string'); - } - $author['email'] = $name['email']; - } - if (isset($name['uri'])) { - if (empty($name['uri']) - || !is_string($name['uri']) - || !Zend_Uri::check($name['uri']) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'); - } - $author['uri'] = $name['uri']; - } - /** - * @deprecated - * Array notation (above) is preferred and will be the sole supported input from ZF 2.0 - */ - } else { - if (empty($name['name']) || !is_string($name['name'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string value'); - } - $author['name'] = $name; - if (isset($email)) { - if (empty($email) || !is_string($email)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "email" value must be a non-empty string'); - } - $author['email'] = $email; - } - if (isset($uri)) { - if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" value must be a non-empty string and valid URI/IRI'); - } - $author['uri'] = $uri; - } - } - $this->_data['authors'][] = $author; - } - - /** - * Set an array with feed authors - * - * @return array - */ - public function addAuthors(array $authors) - { - foreach($authors as $author) { - $this->addAuthor($author); - } - } - - /** - * Set the feed character encoding - * - * @return string|null - */ - public function setEncoding($encoding) - { - if (empty($encoding) || !is_string($encoding)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['encoding'] = $encoding; - } - - /** - * Get the feed character encoding - * - * @return string|null - */ - public function getEncoding() - { - if (!array_key_exists('encoding', $this->_data)) { - return 'UTF-8'; - } - return $this->_data['encoding']; - } - - /** - * Set the copyright entry - * - * @return string|null - */ - public function setCopyright($copyright) - { - if (empty($copyright) || !is_string($copyright)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['copyright'] = $copyright; - } - - /** - * Set the entry's content - * - * @return string|null - */ - public function setContent($content) - { - if (empty($content) || !is_string($content)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['content'] = $content; - } - - /** - * Set the feed creation date - * - * @return string|null - */ - public function setDateCreated($date = null) - { - $zdate = null; - if (is_null($date)) { - $zdate = new Zend_Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { - $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); - } elseif ($date instanceof Zend_Date) { - $zdate = $date; - } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['dateCreated'] = $zdate; - } - - /** - * Set the feed modification date - * - * @return string|null - */ - public function setDateModified($date = null) - { - $zdate = null; - if (is_null($date)) { - $zdate = new Zend_Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { - $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); - } elseif ($date instanceof Zend_Date) { - $zdate = $date; - } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['dateModified'] = $zdate; - } - - /** - * Set the feed description - * - * @return string|null - */ - public function setDescription($description) - { - if (empty($description) || !is_string($description)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['description'] = $description; - } - - /** - * Set the feed ID - * - * @return string|null - */ - public function setId($id) - { - if (empty($id) || !is_string($id)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['id'] = $id; - } - - /** - * Set a link to the HTML source of this entry - * - * @return string|null - */ - public function setLink($link) - { - if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI'); - } - $this->_data['link'] = $link; - } - - /** - * Set the number of comments associated with this entry - * - * @return string|null - */ - public function setCommentCount($count) - { - if (empty($count) || !is_numeric($count) || (int) $count < 0) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "count" must be a non-empty integer number'); - } - $this->_data['commentCount'] = (int) $count; - } - - /** - * Set a link to a HTML page containing comments associated with this entry - * - * @return string|null - */ - public function setCommentLink($link) - { - if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "link" must be a non-empty string and valid URI/IRI'); - } - $this->_data['commentLink'] = $link; - } - - /** - * Set a link to an XML feed for any comments associated with this entry - * - * @return string|null - */ - public function setCommentFeedLink(array $link) - { - if (!isset($link['uri']) || !is_string($link['uri']) || !Zend_Uri::check($link['uri'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "link" must be a non-empty string and valid URI/IRI'); - } - if (!isset($link['type']) || !in_array($link['type'], array('atom', 'rss', 'rdf'))) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "type" must be one' - . ' of "atom", "rss" or "rdf"'); - } - if (!isset($this->_data['commentFeedLinks'])) { - $this->_data['commentFeedLinks'] = array(); - } - $this->_data['commentFeedLinks'][] = $link; - } - - /** - * Set a links to an XML feed for any comments associated with this entry. - * Each link is an array with keys "uri" and "type", where type is one of: - * "atom", "rss" or "rdf". - * - * @return string|null - */ - public function setCommentFeedLinks(array $links) - { - foreach ($links as $link) { - $this->setCommentFeedLink($link); - } - } - - /** - * Set the feed title - * - * @return string|null - */ - public function setTitle($title) - { - if (empty($title) || !is_string($title)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['title'] = $title; - } - - /** - * Get an array with feed authors - * - * @return array - */ - public function getAuthors() - { - if (!array_key_exists('authors', $this->_data)) { - return null; - } - return $this->_data['authors']; - } - - /** - * Get the entry content - * - * @return string - */ - public function getContent() - { - if (!array_key_exists('content', $this->_data)) { - return null; - } - return $this->_data['content']; - } - - /** - * Get the entry copyright information - * - * @return string - */ - public function getCopyright() - { - if (!array_key_exists('copyright', $this->_data)) { - return null; - } - return $this->_data['copyright']; - } - - /** - * Get the entry creation date - * - * @return string - */ - public function getDateCreated() - { - if (!array_key_exists('dateCreated', $this->_data)) { - return null; - } - return $this->_data['dateCreated']; - } - - /** - * Get the entry modification date - * - * @return string - */ - public function getDateModified() - { - if (!array_key_exists('dateModified', $this->_data)) { - return null; - } - return $this->_data['dateModified']; - } - - /** - * Get the entry description - * - * @return string - */ - public function getDescription() - { - if (!array_key_exists('description', $this->_data)) { - return null; - } - return $this->_data['description']; - } - - /** - * Get the entry ID - * - * @return string - */ - public function getId() - { - if (!array_key_exists('id', $this->_data)) { - return null; - } - return $this->_data['id']; - } - - /** - * Get a link to the HTML source - * - * @return string|null - */ - public function getLink() - { - if (!array_key_exists('link', $this->_data)) { - return null; - } - return $this->_data['link']; - } - - - /** - * Get all links - * - * @return array - */ - public function getLinks() - { - if (!array_key_exists('links', $this->_data)) { - return null; - } - return $this->_data['links']; - } - - /** - * Get the entry title - * - * @return string - */ - public function getTitle() - { - if (!array_key_exists('title', $this->_data)) { - return null; - } - return $this->_data['title']; - } - - /** - * Get the number of comments/replies for current entry - * - * @return integer - */ - public function getCommentCount() - { - if (!array_key_exists('commentCount', $this->_data)) { - return null; - } - return $this->_data['commentCount']; - } - - /** - * Returns a URI pointing to the HTML page where comments can be made on this entry - * - * @return string - */ - public function getCommentLink() - { - if (!array_key_exists('commentLink', $this->_data)) { - return null; - } - return $this->_data['commentLink']; - } - - /** - * Returns an array of URIs pointing to a feed of all comments for this entry - * where the array keys indicate the feed type (atom, rss or rdf). - * - * @return string - */ - public function getCommentFeedLinks() - { - if (!array_key_exists('commentFeedLinks', $this->_data)) { - return null; - } - return $this->_data['commentFeedLinks']; - } - - /** - * Add a entry category - * - * @param string $category - */ - public function addCategory(array $category) - { - if (!isset($category['term'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Each category must be an array and ' - . 'contain at least a "term" element containing the machine ' - . ' readable category name'); - } - if (isset($category['scheme'])) { - if (empty($category['scheme']) - || !is_string($category['scheme']) - || !Zend_Uri::check($category['scheme']) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('The Atom scheme or RSS domain of' - . ' a category must be a valid URI'); - } - } - if (!isset($this->_data['categories'])) { - $this->_data['categories'] = array(); - } - $this->_data['categories'][] = $category; - } - - /** - * Set an array of entry categories - * - * @param array $categories - */ - public function addCategories(array $categories) - { - foreach ($categories as $category) { - $this->addCategory($category); - } - } - - /** - * Get the entry categories - * - * @return string|null - */ - public function getCategories() - { - if (!array_key_exists('categories', $this->_data)) { - return null; - } - return $this->_data['categories']; - } - - /** - * Adds an enclosure to the entry. The array parameter may contain the - * keys 'uri', 'type' and 'length'. Only 'uri' is required for Atom, though the - * others must also be provided or RSS rendering (where they are required) - * will throw an Exception. - * - * @param array $enclosures - */ - public function setEnclosure(array $enclosure) - { - if (!isset($enclosure['uri'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Enclosure "uri" is not set'); - } - if (!Zend_Uri::check($enclosure['uri'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Enclosure "uri" is not a valid URI/IRI'); - } - $this->_data['enclosure'] = $enclosure; - } - - /** - * Retrieve an array of all enclosures to be added to entry. - * - * @return array - */ - public function getEnclosure() - { - if (!array_key_exists('enclosure', $this->_data)) { - return null; - } - return $this->_data['enclosure']; - } - - /** - * Unset a specific data point - * - * @param string $name - */ - public function remove($name) - { - if (isset($this->_data[$name])) { - unset($this->_data[$name]); - } - } - - /** - * Get registered extensions - * - * @return array - */ - public function getExtensions() - { - return $this->_extensions; - } - - /** - * Return an Extension object with the matching name (postfixed with _Entry) - * - * @param string $name - * @return object - */ - public function getExtension($name) - { - if (array_key_exists($name . '_Entry', $this->_extensions)) { - return $this->_extensions[$name . '_Entry']; - } - return null; - } - - /** - * Set the current feed type being exported to "rss" or "atom". This allows - * other objects to gracefully choose whether to execute or not, depending - * on their appropriateness for the current type, e.g. renderers. - * - * @param string $type - */ - public function setType($type) - { - $this->_type = $type; - } - - /** - * Retrieve the current or last feed type exported. - * - * @return string Value will be "rss" or "atom" - */ - public function getType() - { - return $this->_type; - } - - /** - * Method overloading: call given method on first extension implementing it - * - * @param string $method - * @param array $args - * @return mixed - * @throws Zend_Feed_Exception if no extensions implements the method - */ - public function __call($method, $args) - { - foreach ($this->_extensions as $extension) { - try { - return call_user_func_array(array($extension, $method), $args); - } catch (Zend_Feed_Writer_Exception_InvalidMethodException $e) { - } - } - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Method: ' . $method - . ' does not exist and could not be located on a registered Extension'); - } - - /** - * Creates a new Zend_Feed_Writer_Source data container for use. This is NOT - * added to the current feed automatically, but is necessary to create a - * container with some initial values preset based on the current feed data. - * - * @return Zend_Feed_Writer_Source - */ - public function createSource() - { - $source = new Zend_Feed_Writer_Source; - if ($this->getEncoding()) { - $source->setEncoding($this->getEncoding()); - } - $source->setType($this->getType()); - return $source; - } - - /** - * Appends a Zend_Feed_Writer_Entry object representing a new entry/item - * the feed data container's internal group of entries. - * - * @param Zend_Feed_Writer_Source $source - */ - public function setSource(Zend_Feed_Writer_Source $source) - { - $this->_data['source'] = $source; - } - - /** - * @return Zend_Feed_Writer_Source - */ - public function getSource() - { - if (isset($this->_data['source'])) { - return $this->_data['source']; - } - return null; - } - - /** - * Load extensions from Zend_Feed_Writer - * - * @return void - */ - protected function _loadExtensions() - { - $all = Zend_Feed_Writer::getExtensions(); - $exts = $all['entry']; - foreach ($exts as $ext) { - $className = Zend_Feed_Writer::getPluginLoader()->getClassName($ext); - $this->_extensions[$ext] = new $className(); - $this->_extensions[$ext]->setEncoding($this->getEncoding()); - } - } -} diff --git a/libs/Zend/Feed/Writer/Exception/InvalidMethodException.php b/libs/Zend/Feed/Writer/Exception/InvalidMethodException.php deleted file mode 100644 index 4510f12b68..0000000000 --- a/libs/Zend/Feed/Writer/Exception/InvalidMethodException.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: InvalidMethodException.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - - -/** - * @see Zend_Feed_Exception - */ -// require_once 'Zend/Feed/Exception.php'; - - -/** - * Feed exceptions - * - * Class to represent exceptions that occur during Feed operations. - * - * @category Zend - * @package Zend_Feed - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Exception_InvalidMethodException extends Zend_Exception -{} diff --git a/libs/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php b/libs/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php deleted file mode 100644 index 588a57af66..0000000000 --- a/libs/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_Atom_Renderer_Feed - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render feed - * - * @return void - */ - public function render() - { - /** - * RSS 2.0 only. Used mainly to include Atom links and - * Pubsubhubbub Hub endpoint URIs under the Atom namespace - */ - if (strtolower($this->getType()) == 'atom') { - return; - } - $this->_setFeedLinks($this->_dom, $this->_base); - $this->_setHubs($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append namespaces to root element of feed - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:atom', - 'http://www.w3.org/2005/Atom'); - } - - /** - * Set feed link elements - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setFeedLinks(DOMDocument $dom, DOMElement $root) - { - $flinks = $this->getDataContainer()->getFeedLinks(); - if(!$flinks || empty($flinks)) { - return; - } - foreach ($flinks as $type => $href) { - $mime = 'application/' . strtolower($type) . '+xml'; - $flink = $dom->createElement('atom:link'); - $root->appendChild($flink); - $flink->setAttribute('rel', 'self'); - $flink->setAttribute('type', $mime); - $flink->setAttribute('href', $href); - } - $this->_called = true; - } - - /** - * Set PuSH hubs - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setHubs(DOMDocument $dom, DOMElement $root) - { - $hubs = $this->getDataContainer()->getHubs(); - if (!$hubs || empty($hubs)) { - return; - } - foreach ($hubs as $hubUrl) { - $hub = $dom->createElement('atom:link'); - $hub->setAttribute('rel', 'hub'); - $hub->setAttribute('href', $hubUrl); - $root->appendChild($hub); - } - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php deleted file mode 100644 index 0036c6325e..0000000000 --- a/libs/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_Content_Renderer_Entry - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render entry - * - * @return void - */ - public function render() - { - if (strtolower($this->getType()) == 'atom') { - return; - } - $this->_setContent($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append namespaces to root element - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:content', - 'http://purl.org/rss/1.0/modules/content/'); - } - - /** - * Set entry content - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setContent(DOMDocument $dom, DOMElement $root) - { - $content = $this->getDataContainer()->getContent(); - if (!$content) { - return; - } - $element = $dom->createElement('content:encoded'); - $root->appendChild($element); - $cdata = $dom->createCDATASection($content); - $element->appendChild($cdata); - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php deleted file mode 100644 index c433ea3a6c..0000000000 --- a/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_DublinCore_Renderer_Entry - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render entry - * - * @return void - */ - public function render() - { - if (strtolower($this->getType()) == 'atom') { - return; - } - $this->_setAuthors($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append namespaces to entry - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:dc', - 'http://purl.org/dc/elements/1.1/'); - } - - /** - * Set entry author elements - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->getDataContainer()->getAuthors(); - if (!$authors || empty($authors)) { - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('dc:creator'); - if (array_key_exists('name', $data)) { - $text = $dom->createTextNode($data['name']); - $author->appendChild($text); - $root->appendChild($author); - } - } - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php b/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php deleted file mode 100644 index e1a0105019..0000000000 --- a/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_DublinCore_Renderer_Feed - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render feed - * - * @return void - */ - public function render() - { - if (strtolower($this->getType()) == 'atom') { - return; - } - $this->_setAuthors($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append namespaces to feed element - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:dc', - 'http://purl.org/dc/elements/1.1/'); - } - - /** - * Set feed authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->getDataContainer()->getAuthors(); - if (!$authors || empty($authors)) { - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('dc:creator'); - if (array_key_exists('name', $data)) { - $text = $dom->createTextNode($data['name']); - $author->appendChild($text); - $root->appendChild($author); - } - } - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Entry.php b/libs/Zend/Feed/Writer/Extension/ITunes/Entry.php deleted file mode 100644 index 1d7fbc5070..0000000000 --- a/libs/Zend/Feed/Writer/Extension/ITunes/Entry.php +++ /dev/null @@ -1,242 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_ITunes_Entry -{ - /** - * Array of Feed data for rendering by Extension's renderers - * - * @var array - */ - protected $_data = array(); - - /** - * Encoding of all text values - * - * @var string - */ - protected $_encoding = 'UTF-8'; - - /** - * Set feed encoding - * - * @param string $enc - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function setEncoding($enc) - { - $this->_encoding = $enc; - return $this; - } - - /** - * Get feed encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set a block value of "yes" or "no". You may also set an empty string. - * - * @param string - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function setItunesBlock($value) - { - if (!ctype_alpha($value) && strlen($value) > 0) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "block" may only' - . ' contain alphabetic characters'); - } - if (iconv_strlen($value, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "block" may only' - . ' contain a maximum of 255 characters'); - } - $this->_data['block'] = $value; - } - - /** - * Add authors to itunes entry - * - * @param array $values - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function addItunesAuthors(array $values) - { - foreach ($values as $value) { - $this->addItunesAuthor($value); - } - return $this; - } - - /** - * Add author to itunes entry - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function addItunesAuthor($value) - { - if (iconv_strlen($value, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: any "author" may only' - . ' contain a maximum of 255 characters each'); - } - if (!isset($this->_data['authors'])) { - $this->_data['authors'] = array(); - } - $this->_data['authors'][] = $value; - return $this; - } - - /** - * Set duration - * - * @param int $value - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function setItunesDuration($value) - { - $value = (string) $value; - if (!ctype_digit($value) - && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value) - && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "duration" may only' - . ' be of a specified [[HH:]MM:]SS format'); - } - $this->_data['duration'] = $value; - return $this; - } - - /** - * Set "explicit" flag - * - * @param bool $value - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function setItunesExplicit($value) - { - if (!in_array($value, array('yes','no','clean'))) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "explicit" may only' - . ' be one of "yes", "no" or "clean"'); - } - $this->_data['explicit'] = $value; - return $this; - } - - /** - * Set keywords - * - * @param array $value - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function setItunesKeywords(array $value) - { - if (count($value) > 12) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "keywords" may only' - . ' contain a maximum of 12 terms'); - } - $concat = implode(',', $value); - if (iconv_strlen($concat, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "keywords" may only' - . ' have a concatenated length of 255 chars where terms are delimited' - . ' by a comma'); - } - $this->_data['keywords'] = $value; - return $this; - } - - /** - * Set subtitle - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function setItunesSubtitle($value) - { - if (iconv_strlen($value, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "subtitle" may only' - . ' contain a maximum of 255 characters'); - } - $this->_data['subtitle'] = $value; - return $this; - } - - /** - * Set summary - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Entry - */ - public function setItunesSummary($value) - { - if (iconv_strlen($value, $this->getEncoding()) > 4000) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "summary" may only' - . ' contain a maximum of 4000 characters'); - } - $this->_data['summary'] = $value; - return $this; - } - - /** - * Overloading to itunes specific setters - * - * @param string $method - * @param array $params - * @return mixed - */ - public function __call($method, array $params) - { - $point = Zend_Feed_Writer::lcfirst(substr($method, 9)); - if (!method_exists($this, 'setItunes' . ucfirst($point)) - && !method_exists($this, 'addItunes' . ucfirst($point)) - ) { - // require_once 'Zend/Feed/Writer/Exception/InvalidMethodException.php'; - throw new Zend_Feed_Writer_Exception_InvalidMethodException( - 'invalid method: ' . $method - ); - } - if (!array_key_exists($point, $this->_data) - || empty($this->_data[$point]) - ) { - return null; - } - return $this->_data[$point]; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Feed.php b/libs/Zend/Feed/Writer/Extension/ITunes/Feed.php deleted file mode 100644 index caf0440a03..0000000000 --- a/libs/Zend/Feed/Writer/Extension/ITunes/Feed.php +++ /dev/null @@ -1,361 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_ITunes_Feed -{ - /** - * Array of Feed data for rendering by Extension's renderers - * - * @var array - */ - protected $_data = array(); - - /** - * Encoding of all text values - * - * @var string - */ - protected $_encoding = 'UTF-8'; - - /** - * Set feed encoding - * - * @param string $enc - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setEncoding($enc) - { - $this->_encoding = $enc; - return $this; - } - - /** - * Get feed encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set a block value of "yes" or "no". You may also set an empty string. - * - * @param string - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesBlock($value) - { - if (!ctype_alpha($value) && strlen($value) > 0) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "block" may only' - . ' contain alphabetic characters'); - } - if (iconv_strlen($value, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "block" may only' - . ' contain a maximum of 255 characters'); - } - $this->_data['block'] = $value; - return $this; - } - - /** - * Add feed authors - * - * @param array $values - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function addItunesAuthors(array $values) - { - foreach ($values as $value) { - $this->addItunesAuthor($value); - } - return $this; - } - - /** - * Add feed author - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function addItunesAuthor($value) - { - if (iconv_strlen($value, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: any "author" may only' - . ' contain a maximum of 255 characters each'); - } - if (!isset($this->_data['authors'])) { - $this->_data['authors'] = array(); - } - $this->_data['authors'][] = $value; - return $this; - } - - /** - * Set feed categories - * - * @param array $values - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesCategories(array $values) - { - if (!isset($this->_data['categories'])) { - $this->_data['categories'] = array(); - } - foreach ($values as $key=>$value) { - if (!is_array($value)) { - if (iconv_strlen($value, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: any "category" may only' - . ' contain a maximum of 255 characters each'); - } - $this->_data['categories'][] = $value; - } else { - if (iconv_strlen($key, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: any "category" may only' - . ' contain a maximum of 255 characters each'); - } - $this->_data['categories'][$key] = array(); - foreach ($value as $val) { - if (iconv_strlen($val, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: any "category" may only' - . ' contain a maximum of 255 characters each'); - } - $this->_data['categories'][$key][] = $val; - } - } - } - return $this; - } - - /** - * Set feed image (icon) - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesImage($value) - { - if (!Zend_Uri::check($value)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "image" may only' - . ' be a valid URI/IRI'); - } - if (!in_array(substr($value, -3), array('jpg','png'))) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "image" may only' - . ' use file extension "jpg" or "png" which must be the last three' - . ' characters of the URI (i.e. no query string or fragment)'); - } - $this->_data['image'] = $value; - return $this; - } - - /** - * Set feed cumulative duration - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesDuration($value) - { - $value = (string) $value; - if (!ctype_digit($value) - && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value) - && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "duration" may only' - . ' be of a specified [[HH:]MM:]SS format'); - } - $this->_data['duration'] = $value; - return $this; - } - - /** - * Set "explicit" flag - * - * @param bool $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesExplicit($value) - { - if (!in_array($value, array('yes','no','clean'))) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "explicit" may only' - . ' be one of "yes", "no" or "clean"'); - } - $this->_data['explicit'] = $value; - return $this; - } - - /** - * Set feed keywords - * - * @param array $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesKeywords(array $value) - { - if (count($value) > 12) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "keywords" may only' - . ' contain a maximum of 12 terms'); - } - $concat = implode(',', $value); - if (iconv_strlen($concat, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "keywords" may only' - . ' have a concatenated length of 255 chars where terms are delimited' - . ' by a comma'); - } - $this->_data['keywords'] = $value; - return $this; - } - - /** - * Set new feed URL - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesNewFeedUrl($value) - { - if (!Zend_Uri::check($value)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "newFeedUrl" may only' - . ' be a valid URI/IRI'); - } - $this->_data['newFeedUrl'] = $value; - return $this; - } - - /** - * Add feed owners - * - * @param array $values - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function addItunesOwners(array $values) - { - foreach ($values as $value) { - $this->addItunesOwner($value); - } - return $this; - } - - /** - * Add feed owner - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function addItunesOwner(array $value) - { - if (!isset($value['name']) || !isset($value['email'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: any "owner" must' - . ' be an array containing keys "name" and "email"'); - } - if (iconv_strlen($value['name'], $this->getEncoding()) > 255 - || iconv_strlen($value['email'], $this->getEncoding()) > 255 - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: any "owner" may only' - . ' contain a maximum of 255 characters each for "name" and "email"'); - } - if (!isset($this->_data['owners'])) { - $this->_data['owners'] = array(); - } - $this->_data['owners'][] = $value; - return $this; - } - - /** - * Set feed subtitle - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesSubtitle($value) - { - if (iconv_strlen($value, $this->getEncoding()) > 255) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "subtitle" may only' - . ' contain a maximum of 255 characters'); - } - $this->_data['subtitle'] = $value; - return $this; - } - - /** - * Set feed summary - * - * @param string $value - * @return Zend_Feed_Writer_Extension_ITunes_Feed - */ - public function setItunesSummary($value) - { - if (iconv_strlen($value, $this->getEncoding()) > 4000) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('invalid parameter: "summary" may only' - . ' contain a maximum of 4000 characters'); - } - $this->_data['summary'] = $value; - return $this; - } - - /** - * Overloading: proxy to internal setters - * - * @param string $method - * @param array $params - * @return mixed - */ - public function __call($method, array $params) - { - $point = Zend_Feed_Writer::lcfirst(substr($method, 9)); - if (!method_exists($this, 'setItunes' . ucfirst($point)) - && !method_exists($this, 'addItunes' . ucfirst($point)) - ) { - // require_once 'Zend/Feed/Writer/Exception/InvalidMethodException.php'; - throw new Zend_Feed_Writer_Exception_InvalidMethodException( - 'invalid method: ' . $method - ); - } - if (!array_key_exists($point, $this->_data) || empty($this->_data[$point])) { - return null; - } - return $this->_data[$point]; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php deleted file mode 100644 index 046cb546fb..0000000000 --- a/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render entry - * - * @return void - */ - public function render() - { - $this->_setAuthors($this->_dom, $this->_base); - $this->_setBlock($this->_dom, $this->_base); - $this->_setDuration($this->_dom, $this->_base); - $this->_setExplicit($this->_dom, $this->_base); - $this->_setKeywords($this->_dom, $this->_base); - $this->_setSubtitle($this->_dom, $this->_base); - $this->_setSummary($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append namespaces to entry root - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:itunes', - 'http://www.itunes.com/dtds/podcast-1.0.dtd'); - } - - /** - * Set entry authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->getDataContainer()->getItunesAuthors(); - if (!$authors || empty($authors)) { - return; - } - foreach ($authors as $author) { - $el = $dom->createElement('itunes:author'); - $text = $dom->createTextNode($author); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - } - - /** - * Set itunes block - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setBlock(DOMDocument $dom, DOMElement $root) - { - $block = $this->getDataContainer()->getItunesBlock(); - if (is_null($block)) { - return; - } - $el = $dom->createElement('itunes:block'); - $text = $dom->createTextNode($block); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set entry duration - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDuration(DOMDocument $dom, DOMElement $root) - { - $duration = $this->getDataContainer()->getItunesDuration(); - if (!$duration) { - return; - } - $el = $dom->createElement('itunes:duration'); - $text = $dom->createTextNode($duration); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set explicit flag - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setExplicit(DOMDocument $dom, DOMElement $root) - { - $explicit = $this->getDataContainer()->getItunesExplicit(); - if (is_null($explicit)) { - return; - } - $el = $dom->createElement('itunes:explicit'); - $text = $dom->createTextNode($explicit); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set entry keywords - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setKeywords(DOMDocument $dom, DOMElement $root) - { - $keywords = $this->getDataContainer()->getItunesKeywords(); - if (!$keywords || empty($keywords)) { - return; - } - $el = $dom->createElement('itunes:keywords'); - $text = $dom->createTextNode(implode(',', $keywords)); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set entry subtitle - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setSubtitle(DOMDocument $dom, DOMElement $root) - { - $subtitle = $this->getDataContainer()->getItunesSubtitle(); - if (!$subtitle) { - return; - } - $el = $dom->createElement('itunes:subtitle'); - $text = $dom->createTextNode($subtitle); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set entry summary - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setSummary(DOMDocument $dom, DOMElement $root) - { - $summary = $this->getDataContainer()->getItunesSummary(); - if (!$summary) { - return; - } - $el = $dom->createElement('itunes:summary'); - $text = $dom->createTextNode($summary); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php b/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php deleted file mode 100644 index 192d19ec42..0000000000 --- a/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php +++ /dev/null @@ -1,320 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render feed - * - * @return void - */ - public function render() - { - $this->_setAuthors($this->_dom, $this->_base); - $this->_setBlock($this->_dom, $this->_base); - $this->_setCategories($this->_dom, $this->_base); - $this->_setImage($this->_dom, $this->_base); - $this->_setDuration($this->_dom, $this->_base); - $this->_setExplicit($this->_dom, $this->_base); - $this->_setKeywords($this->_dom, $this->_base); - $this->_setNewFeedUrl($this->_dom, $this->_base); - $this->_setOwners($this->_dom, $this->_base); - $this->_setSubtitle($this->_dom, $this->_base); - $this->_setSummary($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append feed namespaces - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:itunes', - 'http://www.itunes.com/dtds/podcast-1.0.dtd'); - } - - /** - * Set feed authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->getDataContainer()->getItunesAuthors(); - if (!$authors || empty($authors)) { - return; - } - foreach ($authors as $author) { - $el = $dom->createElement('itunes:author'); - $text = $dom->createTextNode($author); - $el->appendChild($text); - $root->appendChild($el); - } - $this->_called = true; - } - - /** - * Set feed itunes block - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setBlock(DOMDocument $dom, DOMElement $root) - { - $block = $this->getDataContainer()->getItunesBlock(); - if (is_null($block)) { - return; - } - $el = $dom->createElement('itunes:block'); - $text = $dom->createTextNode($block); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set feed categories - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCategories(DOMDocument $dom, DOMElement $root) - { - $cats = $this->getDataContainer()->getItunesCategories(); - if (!$cats || empty($cats)) { - return; - } - foreach ($cats as $key=>$cat) { - if (!is_array($cat)) { - $el = $dom->createElement('itunes:category'); - $el->setAttribute('text', $cat); - $root->appendChild($el); - } else { - $el = $dom->createElement('itunes:category'); - $el->setAttribute('text', $key); - $root->appendChild($el); - foreach ($cat as $subcat) { - $el2 = $dom->createElement('itunes:category'); - $el2->setAttribute('text', $subcat); - $el->appendChild($el2); - } - } - } - $this->_called = true; - } - - /** - * Set feed image (icon) - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setImage(DOMDocument $dom, DOMElement $root) - { - $image = $this->getDataContainer()->getItunesImage(); - if (!$image) { - return; - } - $el = $dom->createElement('itunes:image'); - $el->setAttribute('href', $image); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set feed cumulative duration - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDuration(DOMDocument $dom, DOMElement $root) - { - $duration = $this->getDataContainer()->getItunesDuration(); - if (!$duration) { - return; - } - $el = $dom->createElement('itunes:duration'); - $text = $dom->createTextNode($duration); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set explicit flag - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setExplicit(DOMDocument $dom, DOMElement $root) - { - $explicit = $this->getDataContainer()->getItunesExplicit(); - if (is_null($explicit)) { - return; - } - $el = $dom->createElement('itunes:explicit'); - $text = $dom->createTextNode($explicit); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set feed keywords - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setKeywords(DOMDocument $dom, DOMElement $root) - { - $keywords = $this->getDataContainer()->getItunesKeywords(); - if (!$keywords || empty($keywords)) { - return; - } - $el = $dom->createElement('itunes:keywords'); - $text = $dom->createTextNode(implode(',', $keywords)); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set feed's new URL - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setNewFeedUrl(DOMDocument $dom, DOMElement $root) - { - $url = $this->getDataContainer()->getItunesNewFeedUrl(); - if (!$url) { - return; - } - $el = $dom->createElement('itunes:new-feed-url'); - $text = $dom->createTextNode($url); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set feed owners - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setOwners(DOMDocument $dom, DOMElement $root) - { - $owners = $this->getDataContainer()->getItunesOwners(); - if (!$owners || empty($owners)) { - return; - } - foreach ($owners as $owner) { - $el = $dom->createElement('itunes:owner'); - $name = $dom->createElement('itunes:name'); - $text = $dom->createTextNode($owner['name']); - $name->appendChild($text); - $email = $dom->createElement('itunes:email'); - $text = $dom->createTextNode($owner['email']); - $email->appendChild($text); - $root->appendChild($el); - $el->appendChild($name); - $el->appendChild($email); - } - $this->_called = true; - } - - /** - * Set feed subtitle - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setSubtitle(DOMDocument $dom, DOMElement $root) - { - $subtitle = $this->getDataContainer()->getItunesSubtitle(); - if (!$subtitle) { - return; - } - $el = $dom->createElement('itunes:subtitle'); - $text = $dom->createTextNode($subtitle); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } - - /** - * Set feed summary - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setSummary(DOMDocument $dom, DOMElement $root) - { - $summary = $this->getDataContainer()->getItunesSummary(); - if (!$summary) { - return; - } - $el = $dom->createElement('itunes:summary'); - $text = $dom->createTextNode($summary); - $el->appendChild($text); - $root->appendChild($el); - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/RendererAbstract.php b/libs/Zend/Feed/Writer/Extension/RendererAbstract.php deleted file mode 100644 index b381be3657..0000000000 --- a/libs/Zend/Feed/Writer/Extension/RendererAbstract.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to padraic dot brady at yahoo dot com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer_Entry_Rss - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererInterface - */ -// require_once 'Zend/Feed/Writer/Extension/RendererInterface.php'; - - /** - * @category Zend - * @package Zend_Feed_Writer_Entry_Rss - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Feed_Writer_Extension_RendererAbstract - implements Zend_Feed_Writer_Extension_RendererInterface -{ - /** - * @var DOMDocument - */ - protected $_dom = null; - - /** - * @var mixed - */ - protected $_entry = null; - - /** - * @var DOMElement - */ - protected $_base = null; - - /** - * @var mixed - */ - protected $_container = null; - - /** - * @var string - */ - protected $_type = null; - - /** - * @var DOMElement - */ - protected $_rootElement = null; - - /** - * Encoding of all text values - * - * @var string - */ - protected $_encoding = 'UTF-8'; - - /** - * Constructor - * - * @param mixed $container - * @return void - */ - public function __construct($container) - { - $this->_container = $container; - } - - /** - * Set feed encoding - * - * @param string $enc - * @return Zend_Feed_Writer_Extension_RendererAbstract - */ - public function setEncoding($enc) - { - $this->_encoding = $enc; - return $this; - } - - /** - * Get feed encoding - * - * @return void - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set DOMDocument and DOMElement on which to operate - * - * @param DOMDocument $dom - * @param DOMElement $base - * @return Zend_Feed_Writer_Extension_RendererAbstract - */ - public function setDomDocument(DOMDocument $dom, DOMElement $base) - { - $this->_dom = $dom; - $this->_base = $base; - return $this; - } - - /** - * Get data container being rendered - * - * @return mixed - */ - public function getDataContainer() - { - return $this->_container; - } - - /** - * Set feed type - * - * @param string $type - * @return Zend_Feed_Writer_Extension_RendererAbstract - */ - public function setType($type) - { - $this->_type = $type; - return $this; - } - - /** - * Get feedtype - * - * @return string - */ - public function getType() - { - return $this->_type; - } - - /** - * Set root element of document - * - * @param DOMElement $root - * @return Zend_Feed_Writer_Extension_RendererAbstract - */ - public function setRootElement(DOMElement $root) - { - $this->_rootElement = $root; - return $this; - } - - /** - * Get root element - * - * @return DOMElement - */ - public function getRootElement() - { - return $this->_rootElement; - } - - /** - * Append namespaces to feed - * - * @return void - */ - abstract protected function _appendNamespaces(); -} diff --git a/libs/Zend/Feed/Writer/Extension/RendererInterface.php b/libs/Zend/Feed/Writer/Extension/RendererInterface.php deleted file mode 100644 index e9c9014176..0000000000 --- a/libs/Zend/Feed/Writer/Extension/RendererInterface.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to padraic dot brady at yahoo dot com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Feed_Writer_Extension_RendererInterface -{ - /** - * Constructor - * - * @param mixed $container - * @return void - */ - public function __construct($container); - - /** - * Set DOMDocument and DOMElement on which to operate - * - * @param DOMDocument $dom - * @param DOMElement $base - * @return void - */ - public function setDomDocument(DOMDocument $dom, DOMElement $base); - - /** - * Render - * - * @return void - */ - public function render(); - - /** - * Retrieve container - * - * @return mixed - */ - public function getDataContainer(); -} diff --git a/libs/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php deleted file mode 100644 index 2814775551..0000000000 --- a/libs/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_Slash_Renderer_Entry - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render entry - * - * @return void - */ - public function render() - { - if (strtolower($this->getType()) == 'atom') { - return; // RSS 2.0 only - } - $this->_setCommentCount($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append entry namespaces - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:slash', - 'http://purl.org/rss/1.0/modules/slash/'); - } - - /** - * Set entry comment count - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCommentCount(DOMDocument $dom, DOMElement $root) - { - $count = $this->getDataContainer()->getCommentCount(); - if (!$count) { - $count = 0; - } - $tcount = $this->_dom->createElement('slash:comments'); - $tcount->nodeValue = $count; - $root->appendChild($tcount); - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php deleted file mode 100644 index 69e731d4ba..0000000000 --- a/libs/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php +++ /dev/null @@ -1,145 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_Threading_Renderer_Entry - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render entry - * - * @return void - */ - public function render() - { - if (strtolower($this->getType()) == 'rss') { - return; // Atom 1.0 only - } - $this->_setCommentLink($this->_dom, $this->_base); - $this->_setCommentFeedLinks($this->_dom, $this->_base); - $this->_setCommentCount($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append entry namespaces - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:thr', - 'http://purl.org/syndication/thread/1.0'); - } - - /** - * Set comment link - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCommentLink(DOMDocument $dom, DOMElement $root) - { - $link = $this->getDataContainer()->getCommentLink(); - if (!$link) { - return; - } - $clink = $this->_dom->createElement('link'); - $clink->setAttribute('rel', 'replies'); - $clink->setAttribute('type', 'text/html'); - $clink->setAttribute('href', $link); - $count = $this->getDataContainer()->getCommentCount(); - if (!is_null($count)) { - $clink->setAttribute('thr:count', $count); - } - $root->appendChild($clink); - $this->_called = true; - } - - /** - * Set comment feed links - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root) - { - $links = $this->getDataContainer()->getCommentFeedLinks(); - if (!$links || empty($links)) { - return; - } - foreach ($links as $link) { - $flink = $this->_dom->createElement('link'); - $flink->setAttribute('rel', 'replies'); - $flink->setAttribute('type', 'application/'. $link['type'] .'+xml'); - $flink->setAttribute('href', $link['uri']); - $count = $this->getDataContainer()->getCommentCount(); - if (!is_null($count)) { - $flink->setAttribute('thr:count', $count); - } - $root->appendChild($flink); - $this->_called = true; - } - } - - /** - * Set entry comment count - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCommentCount(DOMDocument $dom, DOMElement $root) - { - $count = $this->getDataContainer()->getCommentCount(); - if (is_null($count)) { - return; - } - $tcount = $this->_dom->createElement('thr:total'); - $tcount->nodeValue = $count; - $root->appendChild($tcount); - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php deleted file mode 100644 index c57244ae4b..0000000000 --- a/libs/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20326 2010-01-16 00:20:43Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Extension_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Extension_WellFormedWeb_Renderer_Entry - extends Zend_Feed_Writer_Extension_RendererAbstract -{ - - /** - * Set to TRUE if a rendering method actually renders something. This - * is used to prevent premature appending of a XML namespace declaration - * until an element which requires it is actually appended. - * - * @var bool - */ - protected $_called = false; - - /** - * Render entry - * - * @return void - */ - public function render() - { - if (strtolower($this->getType()) == 'atom') { - return; // RSS 2.0 only - } - $this->_setCommentFeedLinks($this->_dom, $this->_base); - if ($this->_called) { - $this->_appendNamespaces(); - } - } - - /** - * Append entry namespaces - * - * @return void - */ - protected function _appendNamespaces() - { - $this->getRootElement()->setAttribute('xmlns:wfw', - 'http://wellformedweb.org/CommentAPI/'); - } - - /** - * Set entry comment feed links - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root) - { - $links = $this->getDataContainer()->getCommentFeedLinks(); - if (!$links || empty($links)) { - return; - } - foreach ($links as $link) { - if ($link['type'] == 'rss') { - $flink = $this->_dom->createElement('wfw:commentRss'); - $text = $dom->createTextNode($link['uri']); - $flink->appendChild($text); - $root->appendChild($flink); - } - } - $this->_called = true; - } -} diff --git a/libs/Zend/Feed/Writer/Feed.php b/libs/Zend/Feed/Writer/Feed.php deleted file mode 100644 index 724caed1a2..0000000000 --- a/libs/Zend/Feed/Writer/Feed.php +++ /dev/null @@ -1,281 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20519 2010-01-22 14:06:24Z padraic $ - */ - -/** - * @see Zend_Date - */ -// require_once 'Zend/Date.php'; - -/** - * @see Zend_Date - */ -// require_once 'Zend/Uri.php'; - -/** - * @see Zend_Feed_Writer - */ -// require_once 'Zend/Feed/Writer.php'; - -/** - * @see Zend_Feed_Writer_Entry - */ -// require_once 'Zend/Feed/Writer/Entry.php'; - -/** - * @see Zend_Feed_Writer_Deleted - */ -// require_once 'Zend/Feed/Writer/Deleted.php'; - -/** - * @see Zend_Feed_Writer_Renderer_Feed_Atom - */ -// require_once 'Zend/Feed/Writer/Renderer/Feed/Atom.php'; - -/** - * @see Zend_Feed_Writer_Renderer_Feed_Rss - */ -// require_once 'Zend/Feed/Writer/Renderer/Feed/Rss.php'; - -// require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Feed extends Zend_Feed_Writer_Feed_FeedAbstract -implements Iterator, Countable -{ - - /** - * Contains all entry objects - * - * @var array - */ - protected $_entries = array(); - - /** - * A pointer for the iterator to keep track of the entries array - * - * @var int - */ - protected $_entriesKey = 0; - - /** - * Creates a new Zend_Feed_Writer_Entry data container for use. This is NOT - * added to the current feed automatically, but is necessary to create a - * container with some initial values preset based on the current feed data. - * - * @return Zend_Feed_Writer_Entry - */ - public function createEntry() - { - $entry = new Zend_Feed_Writer_Entry; - if ($this->getEncoding()) { - $entry->setEncoding($this->getEncoding()); - } - $entry->setType($this->getType()); - return $entry; - } - - /** - * Appends a Zend_Feed_Writer_Deleted object representing a new entry tombstone - * to the feed data container's internal group of entries. - * - * @param Zend_Feed_Writer_Deleted $entry - */ - public function addTombstone(Zend_Feed_Writer_Deleted $deleted) - { - $this->_entries[] = $deleted; - } - - /** - * Creates a new Zend_Feed_Writer_Deleted data container for use. This is NOT - * added to the current feed automatically, but is necessary to create a - * container with some initial values preset based on the current feed data. - * - * @return Zend_Feed_Writer_Deleted - */ - public function createTombstone() - { - $deleted = new Zend_Feed_Writer_Deleted; - if ($this->getEncoding()) { - $deleted->setEncoding($this->getEncoding()); - } - $deleted->setType($this->getType()); - return $deleted; - } - - /** - * Appends a Zend_Feed_Writer_Entry object representing a new entry/item - * the feed data container's internal group of entries. - * - * @param Zend_Feed_Writer_Entry $entry - */ - public function addEntry(Zend_Feed_Writer_Entry $entry) - { - $this->_entries[] = $entry; - } - - /** - * Removes a specific indexed entry from the internal queue. Entries must be - * added to a feed container in order to be indexed. - * - * @param int $index - */ - public function removeEntry($index) - { - if (isset($this->_entries[$index])) { - unset($this->_entries[$index]); - } - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Undefined index: ' . $index . '. Entry does not exist.'); - } - - /** - * Retrieve a specific indexed entry from the internal queue. Entries must be - * added to a feed container in order to be indexed. - * - * @param int $index - */ - public function getEntry($index = 0) - { - if (isset($this->_entries[$index])) { - return $this->_entries[$index]; - } - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Undefined index: ' . $index . '. Entry does not exist.'); - } - - /** - * Orders all indexed entries by date, thus offering date ordered readable - * content where a parser (or Homo Sapien) ignores the generic rule that - * XML element order is irrelevant and has no intrinsic meaning. - * - * Using this method will alter the original indexation. - * - * @return void - */ - public function orderByDate() - { - /** - * Could do with some improvement for performance perhaps - */ - $timestamp = time(); - $entries = array(); - foreach ($this->_entries as $entry) { - if ($entry->getDateModified()) { - $timestamp = (int) $entry->getDateModified()->get(Zend_Date::TIMESTAMP); - } elseif ($entry->getDateCreated()) { - $timestamp = (int) $entry->getDateCreated()->get(Zend_Date::TIMESTAMP); - } - $entries[$timestamp] = $entry; - } - krsort($entries, SORT_NUMERIC); - $this->_entries = array_values($entries); - } - - /** - * Get the number of feed entries. - * Required by the Iterator interface. - * - * @return int - */ - public function count() - { - return count($this->_entries); - } - - /** - * Return the current entry - * - * @return Zend_Feed_Reader_Entry_Interface - */ - public function current() - { - return $this->_entries[$this->key()]; - } - - /** - * Return the current feed key - * - * @return unknown - */ - public function key() - { - return $this->_entriesKey; - } - - /** - * Move the feed pointer forward - * - * @return void - */ - public function next() - { - ++$this->_entriesKey; - } - - /** - * Reset the pointer in the feed object - * - * @return void - */ - public function rewind() - { - $this->_entriesKey = 0; - } - - /** - * Check to see if the iterator is still valid - * - * @return boolean - */ - public function valid() - { - return 0 <= $this->_entriesKey && $this->_entriesKey < $this->count(); - } - - /** - * Attempt to build and return the feed resulting from the data set - * - * @param $type The feed type "rss" or "atom" to export as - * @return string - */ - public function export($type, $ignoreExceptions = false) - { - $this->setType(strtolower($type)); - $type = ucfirst($this->getType()); - if ($type !== 'Rss' && $type !== 'Atom') { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid feed type specified: ' . $type . '.' - . ' Should be one of "rss" or "atom".'); - } - $renderClass = 'Zend_Feed_Writer_Renderer_Feed_' . $type; - $renderer = new $renderClass($this); - if ($ignoreExceptions) { - $renderer->ignoreExceptions(); - } - return $renderer->render()->saveXml(); - } - -} diff --git a/libs/Zend/Feed/Writer/Feed/FeedAbstract.php b/libs/Zend/Feed/Writer/Feed/FeedAbstract.php deleted file mode 100644 index bc2a0fa06f..0000000000 --- a/libs/Zend/Feed/Writer/Feed/FeedAbstract.php +++ /dev/null @@ -1,805 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Date - */ -// require_once 'Zend/Date.php'; - -/** - * @see Zend_Date - */ -// require_once 'Zend/Uri.php'; - -/** - * @see Zend_Feed_Writer - */ -// require_once 'Zend/Feed/Writer.php'; - -/** - * @see Zend_Feed_Writer_Entry - */ -// require_once 'Zend/Feed/Writer/Entry.php'; - -/** - * @see Zend_Feed_Writer_Renderer_Feed_Atom - */ -// require_once 'Zend/Feed/Writer/Renderer/Feed/Atom.php'; - -/** - * @see Zend_Feed_Writer_Renderer_Feed_Rss - */ -// require_once 'Zend/Feed/Writer/Renderer/Feed/Rss.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Feed_FeedAbstract -{ - /** - * Contains all Feed level date to append in feed output - * - * @var array - */ - protected $_data = array(); - - /** - * Holds the value "atom" or "rss" depending on the feed type set when - * when last exported. - * - * @var string - */ - protected $_type = null; - - /** - * Constructor: Primarily triggers the registration of core extensions and - * loads those appropriate to this data container. - * - * @return void - */ - public function __construct() - { - Zend_Feed_Writer::registerCoreExtensions(); - $this->_loadExtensions(); - } - - /** - * Set a single author - * - * @param int $index - * @return string|null - */ - public function addAuthor($name, $email = null, $uri = null) - { - $author = array(); - if (is_array($name)) { - if (!array_key_exists('name', $name) || empty($name['name']) || !is_string($name['name'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value'); - } - $author['name'] = $name['name']; - if (isset($name['email'])) { - if (empty($name['email']) || !is_string($name['email'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string'); - } - $author['email'] = $name['email']; - } - if (isset($name['uri'])) { - if (empty($name['uri']) || !is_string($name['uri']) || !Zend_Uri::check($name['uri'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'); - } - $author['uri'] = $name['uri']; - } - } else { - if (empty($name['name']) || !is_string($name['name'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string value'); - } - $author['name'] = $name; - if (isset($email)) { - if (empty($email) || !is_string($email)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "email" value must be a non-empty string'); - } - $author['email'] = $email; - } - if (isset($uri)) { - if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" value must be a non-empty string and valid URI/IRI'); - } - $author['uri'] = $uri; - } - } - $this->_data['authors'][] = $author; - } - - /** - * Set an array with feed authors - * - * @return array - */ - public function addAuthors(array $authors) - { - foreach($authors as $author) { - $this->addAuthor($author); - } - } - - /** - * Set the copyright entry - * - * @return string|null - */ - public function setCopyright($copyright) - { - if (empty($copyright) || !is_string($copyright)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['copyright'] = $copyright; - } - - /** - * Set the feed creation date - * - * @param null|integer|Zend_Date - */ - public function setDateCreated($date = null) - { - $zdate = null; - if (is_null($date)) { - $zdate = new Zend_Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { - $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); - } elseif ($date instanceof Zend_Date) { - $zdate = $date; - } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['dateCreated'] = $zdate; - } - - /** - * Set the feed modification date - * - * @param null|integer|Zend_Date - */ - public function setDateModified($date = null) - { - $zdate = null; - if (is_null($date)) { - $zdate = new Zend_Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { - $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); - } elseif ($date instanceof Zend_Date) { - $zdate = $date; - } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['dateModified'] = $zdate; - } - - /** - * Set the feed last-build date. Ignored for Atom 1.0. - * - * @param null|integer|Zend_Date - */ - public function setLastBuildDate($date = null) - { - $zdate = null; - if (is_null($date)) { - $zdate = new Zend_Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { - $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); - } elseif ($date instanceof Zend_Date) { - $zdate = $date; - } else { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['lastBuildDate'] = $zdate; - } - - /** - * Set the feed description - * - * @return string|null - */ - public function setDescription($description) - { - if (empty($description) || !is_string($description)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['description'] = $description; - } - - /** - * Set the feed generator entry - * - * @return string|null - */ - public function setGenerator($name, $version = null, $uri = null) - { - if (is_array($name)) { - $data = $name; - if (empty($data['name']) || !is_string($data['name'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string'); - } - $generator = array('name' => $data['name']); - if (isset($data['version'])) { - if (empty($data['version']) || !is_string($data['version'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "version" must be a non-empty string'); - } - $generator['version'] = $data['version']; - } - if (isset($data['uri'])) { - if (empty($data['uri']) || !is_string($data['uri']) || !Zend_Uri::check($data['uri'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'); - } - $generator['uri'] = $data['uri']; - } - } else { - if (empty($name) || !is_string($name)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string'); - } - $generator = array('name' => $name); - if (isset($version)) { - if (empty($version) || !is_string($version)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "version" must be a non-empty string'); - } - $generator['version'] = $version; - } - if (isset($uri)) { - if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'); - } - $generator['uri'] = $uri; - } - } - $this->_data['generator'] = $generator; - } - - /** - * Set the feed ID - URI or URN (via PCRE pattern) supported - * - * @param string $id - */ - public function setId($id) - { - if ((empty($id) || !is_string($id) || !Zend_Uri::check($id)) && - !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI'); - } - $this->_data['id'] = $id; - } - - /** - * Set a feed image (URI at minimum). Parameter is a single array with the - * required key 'uri'. When rendering as RSS, the required keys are 'uri', - * 'title' and 'link'. RSS also specifies three optional parameters 'width', - * 'height' and 'description'. Only 'uri' is required and used for Atom rendering. - * - * @param array $data - */ - public function setImage(array $data) - { - if (empty($data['uri']) || !is_string($data['uri']) - || !Zend_Uri::check($data['uri'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter \'uri\'' - . ' must be a non-empty string and valid URI/IRI'); - } - $this->_data['image'] = $data; - } - - /** - * Set the feed language - * - * @return string|null - */ - public function setLanguage($language) - { - if (empty($language) || !is_string($language)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['language'] = $language; - } - - /** - * Set a link to the HTML source - * - * @param string $link - */ - public function setLink($link) - { - if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI'); - } - $this->_data['link'] = $link; - } - - /** - * Set a link to an XML feed for any feed type/version - * - * @return string|null - */ - public function setFeedLink($link, $type) - { - if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "link"" must be a non-empty string and valid URI/IRI'); - } - if (!in_array(strtolower($type), array('rss', 'rdf', 'atom'))) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "type"; You must declare the type of feed the link points to, i.e. RSS, RDF or Atom'); - } - $this->_data['feedLinks'][strtolower($type)] = $link; - } - - /** - * Set the feed title - * - * @return string|null - */ - public function setTitle($title) - { - if (empty($title) || !is_string($title)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['title'] = $title; - } - - /** - * Set the feed character encoding - * - * @param string $encoding - */ - public function setEncoding($encoding) - { - if (empty($encoding) || !is_string($encoding)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); - } - $this->_data['encoding'] = $encoding; - } - - /** - * Set the feed's base URL - * - * @param string $url - */ - public function setBaseUrl($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "url" array value' - . ' must be a non-empty string and valid URI/IRI'); - } - $this->_data['baseUrl'] = $url; - } - - /** - * Add a Pubsubhubbub hub endpoint URL - * - * @param string $url - */ - public function addHub($url) - { - if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "url" array value' - . ' must be a non-empty string and valid URI/IRI'); - } - if (!isset($this->_data['hubs'])) { - $this->_data['hubs'] = array(); - } - $this->_data['hubs'][] = $url; - } - - /** - * Add Pubsubhubbub hub endpoint URLs - * - * @param array $urls - */ - public function addHubs(array $urls) - { - foreach ($urls as $url) { - $this->addHub($url); - } - } - - /** - * Add a feed category - * - * @param string $category - */ - public function addCategory(array $category) - { - if (!isset($category['term'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Each category must be an array and ' - . 'contain at least a "term" element containing the machine ' - . ' readable category name'); - } - if (isset($category['scheme'])) { - if (empty($category['scheme']) - || !is_string($category['scheme']) - || !Zend_Uri::check($category['scheme']) - ) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('The Atom scheme or RSS domain of' - . ' a category must be a valid URI'); - } - } - if (!isset($this->_data['categories'])) { - $this->_data['categories'] = array(); - } - $this->_data['categories'][] = $category; - } - - /** - * Set an array of feed categories - * - * @param array $categories - */ - public function addCategories(array $categories) - { - foreach ($categories as $category) { - $this->addCategory($category); - } - } - - /** - * Get a single author - * - * @param int $index - * @return string|null - */ - public function getAuthor($index = 0) - { - if (isset($this->_data['authors'][$index])) { - return $this->_data['authors'][$index]; - } else { - return null; - } - } - - /** - * Get an array with feed authors - * - * @return array - */ - public function getAuthors() - { - if (!array_key_exists('authors', $this->_data)) { - return null; - } - return $this->_data['authors']; - } - - /** - * Get the copyright entry - * - * @return string|null - */ - public function getCopyright() - { - if (!array_key_exists('copyright', $this->_data)) { - return null; - } - return $this->_data['copyright']; - } - - /** - * Get the feed creation date - * - * @return string|null - */ - public function getDateCreated() - { - if (!array_key_exists('dateCreated', $this->_data)) { - return null; - } - return $this->_data['dateCreated']; - } - - /** - * Get the feed modification date - * - * @return string|null - */ - public function getDateModified() - { - if (!array_key_exists('dateModified', $this->_data)) { - return null; - } - return $this->_data['dateModified']; - } - - /** - * Get the feed last-build date - * - * @return string|null - */ - public function getLastBuildDate() - { - if (!array_key_exists('lastBuildDate', $this->_data)) { - return null; - } - return $this->_data['lastBuildDate']; - } - - /** - * Get the feed description - * - * @return string|null - */ - public function getDescription() - { - if (!array_key_exists('description', $this->_data)) { - return null; - } - return $this->_data['description']; - } - - /** - * Get the feed generator entry - * - * @return string|null - */ - public function getGenerator() - { - if (!array_key_exists('generator', $this->_data)) { - return null; - } - return $this->_data['generator']; - } - - /** - * Get the feed ID - * - * @return string|null - */ - public function getId() - { - if (!array_key_exists('id', $this->_data)) { - return null; - } - return $this->_data['id']; - } - - /** - * Get the feed image URI - * - * @return array - */ - public function getImage() - { - if (!array_key_exists('image', $this->_data)) { - return null; - } - return $this->_data['image']; - } - - /** - * Get the feed language - * - * @return string|null - */ - public function getLanguage() - { - if (!array_key_exists('language', $this->_data)) { - return null; - } - return $this->_data['language']; - } - - /** - * Get a link to the HTML source - * - * @return string|null - */ - public function getLink() - { - if (!array_key_exists('link', $this->_data)) { - return null; - } - return $this->_data['link']; - } - - /** - * Get a link to the XML feed - * - * @return string|null - */ - public function getFeedLinks() - { - if (!array_key_exists('feedLinks', $this->_data)) { - return null; - } - return $this->_data['feedLinks']; - } - - /** - * Get the feed title - * - * @return string|null - */ - public function getTitle() - { - if (!array_key_exists('title', $this->_data)) { - return null; - } - return $this->_data['title']; - } - - /** - * Get the feed character encoding - * - * @return string|null - */ - public function getEncoding() - { - if (!array_key_exists('encoding', $this->_data)) { - return 'UTF-8'; - } - return $this->_data['encoding']; - } - - /** - * Get the feed's base url - * - * @return string|null - */ - public function getBaseUrl() - { - if (!array_key_exists('baseUrl', $this->_data)) { - return null; - } - return $this->_data['baseUrl']; - } - - /** - * Get the URLs used as Pubsubhubbub hubs endpoints - * - * @return string|null - */ - public function getHubs() - { - if (!array_key_exists('hubs', $this->_data)) { - return null; - } - return $this->_data['hubs']; - } - - /** - * Get the feed categories - * - * @return string|null - */ - public function getCategories() - { - if (!array_key_exists('categories', $this->_data)) { - return null; - } - return $this->_data['categories']; - } - - /** - * Resets the instance and deletes all data - * - * @return void - */ - public function reset() - { - $this->_data = array(); - } - - /** - * Set the current feed type being exported to "rss" or "atom". This allows - * other objects to gracefully choose whether to execute or not, depending - * on their appropriateness for the current type, e.g. renderers. - * - * @param string $type - */ - public function setType($type) - { - $this->_type = $type; - } - - /** - * Retrieve the current or last feed type exported. - * - * @return string Value will be "rss" or "atom" - */ - public function getType() - { - return $this->_type; - } - - /** - * Unset a specific data point - * - * @param string $name - */ - public function remove($name) - { - if (isset($this->_data[$name])) { - unset($this->_data[$name]); - } - } - - /** - * Method overloading: call given method on first extension implementing it - * - * @param string $method - * @param array $args - * @return mixed - * @throws Zend_Feed_Exception if no extensions implements the method - */ - public function __call($method, $args) - { - foreach ($this->_extensions as $extension) { - try { - return call_user_func_array(array($extension, $method), $args); - } catch (Zend_Feed_Writer_Exception_InvalidMethodException $e) { - } - } - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Method: ' . $method - . ' does not exist and could not be located on a registered Extension'); - } - - /** - * Load extensions from Zend_Feed_Writer - * - * @return void - */ - protected function _loadExtensions() - { - $all = Zend_Feed_Writer::getExtensions(); - $exts = $all['feed']; - foreach ($exts as $ext) { - $className = Zend_Feed_Writer::getPluginLoader()->getClassName($ext); - $this->_extensions[$ext] = new $className(); - $this->_extensions[$ext]->setEncoding($this->getEncoding()); - } - } -} diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php b/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php deleted file mode 100644 index 76095e89f0..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php +++ /dev/null @@ -1,410 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 22065 2010-04-30 14:04:57Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Renderer_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php'; - -// require_once 'Zend/Feed/Writer/Renderer/Feed/Atom/Source.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_Entry_Atom - extends Zend_Feed_Writer_Renderer_RendererAbstract - implements Zend_Feed_Writer_Renderer_RendererInterface -{ - /** - * Constructor - * - * @param Zend_Feed_Writer_Entry $container - * @return void - */ - public function __construct (Zend_Feed_Writer_Entry $container) - { - parent::__construct($container); - } - - /** - * Render atom entry - * - * @return Zend_Feed_Writer_Renderer_Entry_Atom - */ - public function render() - { - $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $entry = $this->_dom->createElementNS(Zend_Feed_Writer::NAMESPACE_ATOM_10, 'entry'); - $this->_dom->appendChild($entry); - - $this->_setSource($this->_dom, $entry); - $this->_setTitle($this->_dom, $entry); - $this->_setDescription($this->_dom, $entry); - $this->_setDateCreated($this->_dom, $entry); - $this->_setDateModified($this->_dom, $entry); - $this->_setLink($this->_dom, $entry); - $this->_setId($this->_dom, $entry); - $this->_setAuthors($this->_dom, $entry); - $this->_setEnclosure($this->_dom, $entry); - $this->_setContent($this->_dom, $entry); - $this->_setCategories($this->_dom, $entry); - - foreach ($this->_extensions as $ext) { - $ext->setType($this->getType()); - $ext->setRootElement($this->getRootElement()); - $ext->setDomDocument($this->getDomDocument(), $entry); - $ext->render(); - } - - return $this; - } - - /** - * Set entry title - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setTitle(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getTitle()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 entry elements MUST contain exactly one' - . ' atom:title element but a title has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $title = $dom->createElement('title'); - $root->appendChild($title); - $title->setAttribute('type', 'html'); - $cdata = $dom->createCDATASection($this->getDataContainer()->getTitle()); - $title->appendChild($cdata); - } - - /** - * Set entry description - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDescription(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDescription()) { - return; // unless src content or base64 - } - $subtitle = $dom->createElement('summary'); - $root->appendChild($subtitle); - $subtitle->setAttribute('type', 'html'); - $cdata = $dom->createCDATASection( - $this->getDataContainer()->getDescription() - ); - $subtitle->appendChild($cdata); - } - - /** - * Set date entry was modified - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateModified(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDateModified()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 entry elements MUST contain exactly one' - . ' atom:updated element but a modification date has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - $updated = $dom->createElement('updated'); - $root->appendChild($updated); - $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Zend_Date::ISO_8601) - ); - $updated->appendChild($text); - } - - /** - * Set date entry was created - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateCreated(DOMDocument $dom, DOMElement $root) - { - if (!$this->getDataContainer()->getDateCreated()) { - return; - } - $el = $dom->createElement('published'); - $root->appendChild($el); - $text = $dom->createTextNode( - $this->getDataContainer()->getDateCreated()->get(Zend_Date::ISO_8601) - ); - $el->appendChild($text); - } - - /** - * Set entry authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->_container->getAuthors(); - if ((!$authors || empty($authors))) { - /** - * This will actually trigger an Exception at the feed level if - * a feed level author is not set. - */ - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('author'); - $name = $this->_dom->createElement('name'); - $author->appendChild($name); - $root->appendChild($author); - $text = $dom->createTextNode($data['name']); - $name->appendChild($text); - if (array_key_exists('email', $data)) { - $email = $this->_dom->createElement('email'); - $author->appendChild($email); - $text = $dom->createTextNode($data['email']); - $email->appendChild($text); - } - if (array_key_exists('uri', $data)) { - $uri = $this->_dom->createElement('uri'); - $author->appendChild($uri); - $text = $dom->createTextNode($data['uri']); - $uri->appendChild($text); - } - } - } - - /** - * Set entry enclosure - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setEnclosure(DOMDocument $dom, DOMElement $root) - { - $data = $this->_container->getEnclosure(); - if ((!$data || empty($data))) { - return; - } - $enclosure = $this->_dom->createElement('link'); - $enclosure->setAttribute('rel', 'enclosure'); - if (isset($data['type'])) { - $enclosure->setAttribute('type', $data['type']); - } - if (isset($data['length'])) { - $enclosure->setAttribute('length', $data['length']); - } - $enclosure->setAttribute('href', $data['uri']); - $root->appendChild($enclosure); - } - - protected function _setLink(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getLink()) { - return; - } - $link = $dom->createElement('link'); - $root->appendChild($link); - $link->setAttribute('rel', 'alternate'); - $link->setAttribute('type', 'text/html'); - $link->setAttribute('href', $this->getDataContainer()->getLink()); - } - - /** - * Set entry identifier - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setId(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getId() - && !$this->getDataContainer()->getLink()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 entry elements MUST contain exactly one ' - . 'atom:id element, or as an alternative, we can use the same ' - . 'value as atom:link however neither a suitable link nor an ' - . 'id have been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - if (!$this->getDataContainer()->getId()) { - $this->getDataContainer()->setId( - $this->getDataContainer()->getLink()); - } - if (!Zend_Uri::check($this->getDataContainer()->getId()) && - !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $this->getDataContainer()->getId())) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Atom 1.0 IDs must be a valid URI/IRI'); - } - $id = $dom->createElement('id'); - $root->appendChild($id); - $text = $dom->createTextNode($this->getDataContainer()->getId()); - $id->appendChild($text); - } - - /** - * Set entry content - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setContent(DOMDocument $dom, DOMElement $root) - { - $content = $this->getDataContainer()->getContent(); - if (!$content && !$this->getDataContainer()->getLink()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 entry elements MUST contain exactly one ' - . 'atom:content element, or as an alternative, at least one link ' - . 'with a rel attribute of "alternate" to indicate an alternate ' - . 'method to consume the content.'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (!$content) { - return; - } - $element = $dom->createElement('content'); - $element->setAttribute('type', 'xhtml'); - $xhtmlElement = $this->_loadXhtml($content); - $xhtml = $dom->importNode($xhtmlElement, true); - $element->appendChild($xhtml); - $root->appendChild($element); - } - - /** - * Load a HTML string and attempt to normalise to XML - */ - protected function _loadXhtml($content) - { - $xhtml = ''; - if (class_exists('tidy', false)) { - $tidy = new tidy; - $config = array( - 'output-xhtml' => true, - 'show-body-only' => true, - 'quote-nbsp' => false - ); - $encoding = str_replace('-', '', $this->getEncoding()); - $tidy->parseString($content, $config, $encoding); - $tidy->cleanRepair(); - $xhtml = (string) $tidy; - } else { - $xhtml = $content; - } - $xhtml = preg_replace(array( - "/(<[\/]?)([a-zA-Z]+)/" - ), '$1xhtml:$2', $xhtml); - $dom = new DOMDocument('1.0', $this->getEncoding()); - $dom->loadXML('<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">' - . $xhtml . '</xhtml:div>'); - return $dom->documentElement; - } - - /** - * Set entry cateories - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCategories(DOMDocument $dom, DOMElement $root) - { - $categories = $this->getDataContainer()->getCategories(); - if (!$categories) { - return; - } - foreach ($categories as $cat) { - $category = $dom->createElement('category'); - $category->setAttribute('term', $cat['term']); - if (isset($cat['label'])) { - $category->setAttribute('label', $cat['label']); - } else { - $category->setAttribute('label', $cat['term']); - } - if (isset($cat['scheme'])) { - $category->setAttribute('scheme', $cat['scheme']); - } - $root->appendChild($category); - } - } - - /** - * Append Source element (Atom 1.0 Feed Metadata) - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setSource(DOMDocument $dom, DOMElement $root) - { - $source = $this->getDataContainer()->getSource(); - if (!$source) { - return; - } - $renderer = new Zend_Feed_Writer_Renderer_Feed_Atom_Source($source); - $renderer->setType($this->getType()); - $element = $renderer->render()->getElement(); - $imported = $dom->importNode($element, true); - $root->appendChild($imported); - } -} diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php b/libs/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php deleted file mode 100644 index fb75262935..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20506 2010-01-21 22:19:05Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Renderer_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_Entry_Atom_Deleted - extends Zend_Feed_Writer_Renderer_RendererAbstract - implements Zend_Feed_Writer_Renderer_RendererInterface -{ - /** - * Constructor - * - * @param Zend_Feed_Writer_Deleted $container - * @return void - */ - public function __construct (Zend_Feed_Writer_Deleted $container) - { - parent::__construct($container); - } - - /** - * Render atom entry - * - * @return Zend_Feed_Writer_Renderer_Entry_Atom - */ - public function render() - { - $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $entry = $this->_dom->createElement('at:deleted-entry'); - $this->_dom->appendChild($entry); - - $entry->setAttribute('ref', $this->_container->getReference()); - $entry->setAttribute('when', $this->_container->getWhen()->get(Zend_Date::ISO_8601)); - - $this->_setBy($this->_dom, $entry); - $this->_setComment($this->_dom, $entry); - - return $this; - } - - /** - * Set tombstone comment - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setComment(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getComment()) { - return; - } - $c = $dom->createElement('at:comment'); - $root->appendChild($c); - $c->setAttribute('type', 'html'); - $cdata = $dom->createCDATASection($this->getDataContainer()->getComment()); - $c->appendChild($cdata); - } - - /** - * Set entry authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setBy(DOMDocument $dom, DOMElement $root) - { - $data = $this->_container->getBy(); - if ((!$data || empty($data))) { - return; - } - $author = $this->_dom->createElement('at:by'); - $name = $this->_dom->createElement('name'); - $author->appendChild($name); - $root->appendChild($author); - $text = $dom->createTextNode($data['name']); - $name->appendChild($text); - if (array_key_exists('email', $data)) { - $email = $this->_dom->createElement('email'); - $author->appendChild($email); - $text = $dom->createTextNode($data['email']); - $email->appendChild($text); - } - if (array_key_exists('uri', $data)) { - $uri = $this->_dom->createElement('uri'); - $author->appendChild($uri); - $text = $dom->createTextNode($data['uri']); - $uri->appendChild($text); - } - } - -} diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php b/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php deleted file mode 100644 index 74e80f5707..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php +++ /dev/null @@ -1,346 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 22065 2010-04-30 14:04:57Z padraic $ - */ - -/** - * @see Zend_Feed_Writer_Renderer_RendererAbstract - */ -// require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_Entry_Rss - extends Zend_Feed_Writer_Renderer_RendererAbstract - implements Zend_Feed_Writer_Renderer_RendererInterface -{ - /** - * Constructor - * - * @param Zend_Feed_Writer_Entry $container - * @return void - */ - public function __construct (Zend_Feed_Writer_Entry $container) - { - parent::__construct($container); - } - - /** - * Render RSS entry - * - * @return Zend_Feed_Writer_Renderer_Entry_Rss - */ - public function render() - { - $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $this->_dom->substituteEntities = false; - $entry = $this->_dom->createElement('item'); - $this->_dom->appendChild($entry); - - $this->_setTitle($this->_dom, $entry); - $this->_setDescription($this->_dom, $entry); - $this->_setDateCreated($this->_dom, $entry); - $this->_setDateModified($this->_dom, $entry); - $this->_setLink($this->_dom, $entry); - $this->_setId($this->_dom, $entry); - $this->_setAuthors($this->_dom, $entry); - $this->_setEnclosure($this->_dom, $entry); - $this->_setCommentLink($this->_dom, $entry); - $this->_setCategories($this->_dom, $entry); - foreach ($this->_extensions as $ext) { - $ext->setType($this->getType()); - $ext->setRootElement($this->getRootElement()); - $ext->setDomDocument($this->getDomDocument(), $entry); - $ext->render(); - } - - return $this; - } - - /** - * Set entry title - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setTitle(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDescription() - && !$this->getDataContainer()->getTitle()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'RSS 2.0 entry elements SHOULD contain exactly one' - . ' title element but a title has not been set. In addition, there' - . ' is no description as required in the absence of a title.'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $title = $dom->createElement('title'); - $root->appendChild($title); - $text = $dom->createTextNode($this->getDataContainer()->getTitle()); - $title->appendChild($text); - } - - /** - * Set entry description - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDescription(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDescription() - && !$this->getDataContainer()->getTitle()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'RSS 2.0 entry elements SHOULD contain exactly one' - . ' description element but a description has not been set. In' - . ' addition, there is no title element as required in the absence' - . ' of a description.'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (!$this->getDataContainer()->getDescription()) { - return; - } - $subtitle = $dom->createElement('description'); - $root->appendChild($subtitle); - $text = $dom->createCDATASection($this->getDataContainer()->getDescription()); - $subtitle->appendChild($text); - } - - /** - * Set date entry was last modified - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateModified(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDateModified()) { - return; - } - - $updated = $dom->createElement('pubDate'); - $root->appendChild($updated); - $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Zend_Date::RSS) - ); - $updated->appendChild($text); - } - - /** - * Set date entry was created - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateCreated(DOMDocument $dom, DOMElement $root) - { - if (!$this->getDataContainer()->getDateCreated()) { - return; - } - if (!$this->getDataContainer()->getDateModified()) { - $this->getDataContainer()->setDateModified( - $this->getDataContainer()->getDateCreated() - ); - } - } - - /** - * Set entry authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->_container->getAuthors(); - if ((!$authors || empty($authors))) { - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('author'); - $name = $data['name']; - if (array_key_exists('email', $data)) { - $name = $data['email'] . ' (' . $data['name'] . ')'; - } - $text = $dom->createTextNode($name); - $author->appendChild($text); - $root->appendChild($author); - } - } - - /** - * Set entry enclosure - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setEnclosure(DOMDocument $dom, DOMElement $root) - { - $data = $this->_container->getEnclosure(); - if ((!$data || empty($data))) { - return; - } - if (!isset($data['type'])) { - // require_once 'Zend/Feed/Exception.php'; - $exception = new Zend_Feed_Exception('Enclosure "type" is not set'); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (!isset($data['length'])) { - // require_once 'Zend/Feed/Exception.php'; - $exception = new Zend_Feed_Exception('Enclosure "length" is not set'); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (isset($data['length']) && (int) $data['length'] <= 0) { - // require_once 'Zend/Feed/Exception.php'; - $exception = new Zend_Feed_Exception('Enclosure "length" must be an integer' - . ' indicating the content\'s length in bytes'); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $enclosure = $this->_dom->createElement('enclosure'); - $enclosure->setAttribute('type', $data['type']); - $enclosure->setAttribute('length', $data['length']); - $enclosure->setAttribute('url', $data['uri']); - $root->appendChild($enclosure); - } - - /** - * Set link to entry - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLink(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getLink()) { - return; - } - $link = $dom->createElement('link'); - $root->appendChild($link); - $text = $dom->createTextNode($this->getDataContainer()->getLink()); - $link->appendChild($text); - } - - /** - * Set entry identifier - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setId(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getId() - && !$this->getDataContainer()->getLink()) { - return; - } - - $id = $dom->createElement('guid'); - $root->appendChild($id); - if (!$this->getDataContainer()->getId()) { - $this->getDataContainer()->setId( - $this->getDataContainer()->getLink()); - } - $text = $dom->createTextNode($this->getDataContainer()->getId()); - $id->appendChild($text); - if (!Zend_Uri::check($this->getDataContainer()->getId())) { - $id->setAttribute('isPermaLink', 'false'); - } - } - - /** - * Set link to entry comments - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCommentLink(DOMDocument $dom, DOMElement $root) - { - $link = $this->getDataContainer()->getCommentLink(); - if (!$link) { - return; - } - $clink = $this->_dom->createElement('comments'); - $text = $dom->createTextNode($link); - $clink->appendChild($text); - $root->appendChild($clink); - } - - /** - * Set entry categories - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCategories(DOMDocument $dom, DOMElement $root) - { - $categories = $this->getDataContainer()->getCategories(); - if (!$categories) { - return; - } - foreach ($categories as $cat) { - $category = $dom->createElement('category'); - if (isset($cat['scheme'])) { - $category->setAttribute('domain', $cat['scheme']); - } - $text = $dom->createCDATASection($cat['term']); - $category->appendChild($text); - $root->appendChild($category); - } - } -} diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php deleted file mode 100644 index 2c88dd4298..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 22098 2010-05-04 18:03:29Z padraic $ - */ - -/** @see Zend_Feed_Writer_Feed */ -// require_once 'Zend/Feed/Writer/Feed.php'; - -/** @see Zend_Version */ -// require_once 'Zend/Version.php'; - -/** @see Zend_Feed_Writer_Renderer_RendererInterface */ -// require_once 'Zend/Feed/Writer/Renderer/RendererInterface.php'; - -/** @see Zend_Feed_Writer_Renderer_Entry_Atom */ -// require_once 'Zend/Feed/Writer/Renderer/Entry/Atom.php'; - -/** @see Zend_Feed_Writer_Renderer_Entry_Atom_Deleted */ -// require_once 'Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php'; - -/** @see Zend_Feed_Writer_Renderer_RendererAbstract */ -// require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php'; - -// require_once 'Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_Feed_Atom - extends Zend_Feed_Writer_Renderer_Feed_Atom_AtomAbstract - implements Zend_Feed_Writer_Renderer_RendererInterface -{ - /** - * Constructor - * - * @param Zend_Feed_Writer_Feed $container - * @return void - */ - public function __construct (Zend_Feed_Writer_Feed $container) - { - parent::__construct($container); - } - - /** - * Render Atom feed - * - * @return Zend_Feed_Writer_Renderer_Feed_Atom - */ - public function render() - { - if (!$this->_container->getEncoding()) { - $this->_container->setEncoding('UTF-8'); - } - $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $root = $this->_dom->createElementNS( - Zend_Feed_Writer::NAMESPACE_ATOM_10, 'feed' - ); - $this->setRootElement($root); - $this->_dom->appendChild($root); - $this->_setLanguage($this->_dom, $root); - $this->_setBaseUrl($this->_dom, $root); - $this->_setTitle($this->_dom, $root); - $this->_setDescription($this->_dom, $root); - $this->_setImage($this->_dom, $root); - $this->_setDateCreated($this->_dom, $root); - $this->_setDateModified($this->_dom, $root); - $this->_setGenerator($this->_dom, $root); - $this->_setLink($this->_dom, $root); - $this->_setFeedLinks($this->_dom, $root); - $this->_setId($this->_dom, $root); - $this->_setAuthors($this->_dom, $root); - $this->_setCopyright($this->_dom, $root); - $this->_setCategories($this->_dom, $root); - $this->_setHubs($this->_dom, $root); - - foreach ($this->_extensions as $ext) { - $ext->setType($this->getType()); - $ext->setRootElement($this->getRootElement()); - $ext->setDomDocument($this->getDomDocument(), $root); - $ext->render(); - } - - foreach ($this->_container as $entry) { - if ($this->getDataContainer()->getEncoding()) { - $entry->setEncoding($this->getDataContainer()->getEncoding()); - } - if ($entry instanceof Zend_Feed_Writer_Entry) { - $renderer = new Zend_Feed_Writer_Renderer_Entry_Atom($entry); - } else { - if (!$this->_dom->documentElement->hasAttribute('xmlns:at')) { - $this->_dom->documentElement->setAttribute( - 'xmlns:at', 'http://purl.org/atompub/tombstones/1.0' - ); - } - $renderer = new Zend_Feed_Writer_Renderer_Entry_Atom_Deleted($entry); - } - if ($this->_ignoreExceptions === true) { - $renderer->ignoreExceptions(); - } - $renderer->setType($this->getType()); - $renderer->setRootElement($this->_dom->documentElement); - $renderer->render(); - $element = $renderer->getElement(); - $imported = $this->_dom->importNode($element, true); - $root->appendChild($imported); - } - return $this; - } - -} diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php deleted file mode 100644 index 254516e5b5..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php +++ /dev/null @@ -1,427 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** @see Zend_Feed_Writer_Feed */ -// require_once 'Zend/Feed/Writer/Feed.php'; - -/** @see Zend_Version */ -// require_once 'Zend/Version.php'; - -/** @see Zend_Feed_Writer_Renderer_RendererInterface */ -// require_once 'Zend/Feed/Writer/Renderer/RendererInterface.php'; - -/** @see Zend_Feed_Writer_Renderer_Entry_Atom */ -// require_once 'Zend/Feed/Writer/Renderer/Entry/Atom.php'; - -/** @see Zend_Feed_Writer_Renderer_RendererAbstract */ -// require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_Feed_Atom_AtomAbstract - extends Zend_Feed_Writer_Renderer_RendererAbstract -{ - /** - * Constructor - * - * @param Zend_Feed_Writer_Feed $container - * @return void - */ - public function __construct ($container) - { - parent::__construct($container); - } - - /** - * Set feed language - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLanguage(DOMDocument $dom, DOMElement $root) - { - if ($this->getDataContainer()->getLanguage()) { - $root->setAttribute('xml:lang', $this->getDataContainer() - ->getLanguage()); - } - } - - /** - * Set feed title - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setTitle(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getTitle()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 feed elements MUST contain exactly one' - . ' atom:title element but a title has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - $title = $dom->createElement('title'); - $root->appendChild($title); - $title->setAttribute('type', 'text'); - $text = $dom->createTextNode($this->getDataContainer()->getTitle()); - $title->appendChild($text); - } - - /** - * Set feed description - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDescription(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDescription()) { - return; - } - $subtitle = $dom->createElement('subtitle'); - $root->appendChild($subtitle); - $subtitle->setAttribute('type', 'text'); - $text = $dom->createTextNode($this->getDataContainer()->getDescription()); - $subtitle->appendChild($text); - } - - /** - * Set date feed was last modified - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateModified(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDateModified()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 feed elements MUST contain exactly one' - . ' atom:updated element but a modification date has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - $updated = $dom->createElement('updated'); - $root->appendChild($updated); - $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Zend_Date::ISO_8601) - ); - $updated->appendChild($text); - } - - /** - * Set feed generator string - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setGenerator(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getGenerator()) { - $this->getDataContainer()->setGenerator('Zend_Feed_Writer', - Zend_Version::VERSION, 'http://framework.zend.com'); - } - - $gdata = $this->getDataContainer()->getGenerator(); - $generator = $dom->createElement('generator'); - $root->appendChild($generator); - $text = $dom->createTextNode($gdata['name']); - $generator->appendChild($text); - if (array_key_exists('uri', $gdata)) { - $generator->setAttribute('uri', $gdata['uri']); - } - if (array_key_exists('version', $gdata)) { - $generator->setAttribute('version', $gdata['version']); - } - } - - /** - * Set link to feed - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLink(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getLink()) { - return; - } - $link = $dom->createElement('link'); - $root->appendChild($link); - $link->setAttribute('rel', 'alternate'); - $link->setAttribute('type', 'text/html'); - $link->setAttribute('href', $this->getDataContainer()->getLink()); - } - - /** - * Set feed links - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setFeedLinks(DOMDocument $dom, DOMElement $root) - { - $flinks = $this->getDataContainer()->getFeedLinks(); - if(!$flinks || !array_key_exists('atom', $flinks)) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 feed elements SHOULD contain one atom:link ' - . 'element with a rel attribute value of "self". This is the ' - . 'preferred URI for retrieving Atom Feed Documents representing ' - . 'this Atom feed but a feed link has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - foreach ($flinks as $type => $href) { - $mime = 'application/' . strtolower($type) . '+xml'; - $flink = $dom->createElement('link'); - $root->appendChild($flink); - $flink->setAttribute('rel', 'self'); - $flink->setAttribute('type', $mime); - $flink->setAttribute('href', $href); - } - } - - /** - * Set feed authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->_container->getAuthors(); - if (!$authors || empty($authors)) { - /** - * Technically we should defer an exception until we can check - * that all entries contain an author. If any entry is missing - * an author, then a missing feed author element is invalid - */ - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('author'); - $name = $this->_dom->createElement('name'); - $author->appendChild($name); - $root->appendChild($author); - $text = $dom->createTextNode($data['name']); - $name->appendChild($text); - if (array_key_exists('email', $data)) { - $email = $this->_dom->createElement('email'); - $author->appendChild($email); - $text = $dom->createTextNode($data['email']); - $email->appendChild($text); - } - if (array_key_exists('uri', $data)) { - $uri = $this->_dom->createElement('uri'); - $author->appendChild($uri); - $text = $dom->createTextNode($data['uri']); - $uri->appendChild($text); - } - } - } - - /** - * Set feed identifier - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setId(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getId() - && !$this->getDataContainer()->getLink()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Atom 1.0 feed elements MUST contain exactly one ' - . 'atom:id element, or as an alternative, we can use the same ' - . 'value as atom:link however neither a suitable link nor an ' - . 'id have been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - if (!$this->getDataContainer()->getId()) { - $this->getDataContainer()->setId( - $this->getDataContainer()->getLink()); - } - $id = $dom->createElement('id'); - $root->appendChild($id); - $text = $dom->createTextNode($this->getDataContainer()->getId()); - $id->appendChild($text); - } - - /** - * Set feed copyright - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCopyright(DOMDocument $dom, DOMElement $root) - { - $copyright = $this->getDataContainer()->getCopyright(); - if (!$copyright) { - return; - } - $copy = $dom->createElement('rights'); - $root->appendChild($copy); - $text = $dom->createTextNode($copyright); - $copy->appendChild($text); - } - - /** - * Set feed level logo (image) - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setImage(DOMDocument $dom, DOMElement $root) - { - $image = $this->getDataContainer()->getImage(); - if (!$image) { - return; - } - $img = $dom->createElement('logo'); - $root->appendChild($img); - $text = $dom->createTextNode($image['uri']); - $img->appendChild($text); - } - - /** - * Set date feed was created - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateCreated(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDateCreated()) { - return; - } - if(!$this->getDataContainer()->getDateModified()) { - $this->getDataContainer()->setDateModified( - $this->getDataContainer()->getDateCreated() - ); - } - } - - /** - * Set base URL to feed links - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setBaseUrl(DOMDocument $dom, DOMElement $root) - { - $baseUrl = $this->getDataContainer()->getBaseUrl(); - if (!$baseUrl) { - return; - } - $root->setAttribute('xml:base', $baseUrl); - } - - /** - * Set hubs to which this feed pushes - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setHubs(DOMDocument $dom, DOMElement $root) - { - $hubs = $this->getDataContainer()->getHubs(); - if (!$hubs) { - return; - } - foreach ($hubs as $hubUrl) { - $hub = $dom->createElement('link'); - $hub->setAttribute('rel', 'hub'); - $hub->setAttribute('href', $hubUrl); - $root->appendChild($hub); - } - } - - /** - * Set feed cateories - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCategories(DOMDocument $dom, DOMElement $root) - { - $categories = $this->getDataContainer()->getCategories(); - if (!$categories) { - return; - } - foreach ($categories as $cat) { - $category = $dom->createElement('category'); - $category->setAttribute('term', $cat['term']); - if (isset($cat['label'])) { - $category->setAttribute('label', $cat['label']); - } else { - $category->setAttribute('label', $cat['term']); - } - if (isset($cat['scheme'])) { - $category->setAttribute('scheme', $cat['scheme']); - } - $root->appendChild($category); - } - } -} diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php deleted file mode 100644 index 125fed1eaf..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -// require_once 'Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_Feed_Atom_Source - extends Zend_Feed_Writer_Renderer_Feed_Atom_AtomAbstract - implements Zend_Feed_Writer_Renderer_RendererInterface -{ - - /** - * Constructor - * - * @param Zend_Feed_Writer_Feed_Source $container - * @return void - */ - public function __construct (Zend_Feed_Writer_Source $container) - { - parent::__construct($container); - } - - /** - * Render Atom Feed Metadata (Source element) - * - * @return Zend_Feed_Writer_Renderer_Feed_Atom - */ - public function render() - { - if (!$this->_container->getEncoding()) { - $this->_container->setEncoding('UTF-8'); - } - $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $root = $this->_dom->createElement('source'); - $this->setRootElement($root); - $this->_dom->appendChild($root); - $this->_setLanguage($this->_dom, $root); - $this->_setBaseUrl($this->_dom, $root); - $this->_setTitle($this->_dom, $root); - $this->_setDescription($this->_dom, $root); - $this->_setDateCreated($this->_dom, $root); - $this->_setDateModified($this->_dom, $root); - $this->_setGenerator($this->_dom, $root); - $this->_setLink($this->_dom, $root); - $this->_setFeedLinks($this->_dom, $root); - $this->_setId($this->_dom, $root); - $this->_setAuthors($this->_dom, $root); - $this->_setCopyright($this->_dom, $root); - $this->_setCategories($this->_dom, $root); - - foreach ($this->_extensions as $ext) { - $ext->setType($this->getType()); - $ext->setRootElement($this->getRootElement()); - $ext->setDomDocument($this->getDomDocument(), $root); - $ext->render(); - } - return $this; - } - - /** - * Set feed generator string - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setGenerator(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getGenerator()) { - return; - } - - $gdata = $this->getDataContainer()->getGenerator(); - $generator = $dom->createElement('generator'); - $root->appendChild($generator); - $text = $dom->createTextNode($gdata['name']); - $generator->appendChild($text); - if (array_key_exists('uri', $gdata)) { - $generator->setAttribute('uri', $gdata['uri']); - } - if (array_key_exists('version', $gdata)) { - $generator->setAttribute('version', $gdata['version']); - } - } - -} diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php b/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php deleted file mode 100644 index 07b94e7b86..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php +++ /dev/null @@ -1,505 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 22108 2010-05-05 13:44:11Z padraic $ - */ - -/** @see Zend_Feed_Writer_Feed */ -// require_once 'Zend/Feed/Writer/Feed.php'; - -/** @see Zend_Version */ -// require_once 'Zend/Version.php'; - -/** @see Zend_Feed_Writer_Renderer_RendererInterface */ -// require_once 'Zend/Feed/Writer/Renderer/RendererInterface.php'; - -/** @see Zend_Feed_Writer_Renderer_Entry_Rss */ -// require_once 'Zend/Feed/Writer/Renderer/Entry/Rss.php'; - -/** @see Zend_Feed_Writer_Renderer_RendererAbstract */ -// require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_Feed_Rss - extends Zend_Feed_Writer_Renderer_RendererAbstract - implements Zend_Feed_Writer_Renderer_RendererInterface -{ - /** - * Constructor - * - * @param Zend_Feed_Writer_Feed $container - * @return void - */ - public function __construct (Zend_Feed_Writer_Feed $container) - { - parent::__construct($container); - } - - /** - * Render RSS feed - * - * @return Zend_Feed_Writer_Renderer_Feed_Rss - */ - public function render() - { - if (!$this->_container->getEncoding()) { - $this->_container->setEncoding('UTF-8'); - } - $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $this->_dom->substituteEntities = false; - $rss = $this->_dom->createElement('rss'); - $this->setRootElement($rss); - $rss->setAttribute('version', '2.0'); - - $channel = $this->_dom->createElement('channel'); - $rss->appendChild($channel); - $this->_dom->appendChild($rss); - $this->_setLanguage($this->_dom, $channel); - $this->_setBaseUrl($this->_dom, $channel); - $this->_setTitle($this->_dom, $channel); - $this->_setDescription($this->_dom, $channel); - $this->_setImage($this->_dom, $channel); - $this->_setDateCreated($this->_dom, $channel); - $this->_setDateModified($this->_dom, $channel); - $this->_setLastBuildDate($this->_dom, $channel); - $this->_setGenerator($this->_dom, $channel); - $this->_setLink($this->_dom, $channel); - $this->_setAuthors($this->_dom, $channel); - $this->_setCopyright($this->_dom, $channel); - $this->_setCategories($this->_dom, $channel); - - foreach ($this->_extensions as $ext) { - $ext->setType($this->getType()); - $ext->setRootElement($this->getRootElement()); - $ext->setDomDocument($this->getDomDocument(), $channel); - $ext->render(); - } - - foreach ($this->_container as $entry) { - if ($this->getDataContainer()->getEncoding()) { - $entry->setEncoding($this->getDataContainer()->getEncoding()); - } - if ($entry instanceof Zend_Feed_Writer_Entry) { - $renderer = new Zend_Feed_Writer_Renderer_Entry_Rss($entry); - } else { - continue; - } - if ($this->_ignoreExceptions === true) { - $renderer->ignoreExceptions(); - } - $renderer->setType($this->getType()); - $renderer->setRootElement($this->_dom->documentElement); - $renderer->render(); - $element = $renderer->getElement(); - $imported = $this->_dom->importNode($element, true); - $channel->appendChild($imported); - } - return $this; - } - - /** - * Set feed language - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLanguage(DOMDocument $dom, DOMElement $root) - { - $lang = $this->getDataContainer()->getLanguage(); - if (!$lang) { - return; - } - $language = $dom->createElement('language'); - $root->appendChild($language); - $language->nodeValue = $lang; - } - - /** - * Set feed title - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setTitle(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getTitle()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'RSS 2.0 feed elements MUST contain exactly one' - . ' title element but a title has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - $title = $dom->createElement('title'); - $root->appendChild($title); - $text = $dom->createTextNode($this->getDataContainer()->getTitle()); - $title->appendChild($text); - } - - /** - * Set feed description - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDescription(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDescription()) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'RSS 2.0 feed elements MUST contain exactly one' - . ' description element but one has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $subtitle = $dom->createElement('description'); - $root->appendChild($subtitle); - $text = $dom->createTextNode($this->getDataContainer()->getDescription()); - $subtitle->appendChild($text); - } - - /** - * Set date feed was last modified - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateModified(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDateModified()) { - return; - } - - $updated = $dom->createElement('pubDate'); - $root->appendChild($updated); - $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Zend_Date::RSS) - ); - $updated->appendChild($text); - } - - /** - * Set feed generator string - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setGenerator(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getGenerator()) { - $this->getDataContainer()->setGenerator('Zend_Feed_Writer', - Zend_Version::VERSION, 'http://framework.zend.com'); - } - - $gdata = $this->getDataContainer()->getGenerator(); - $generator = $dom->createElement('generator'); - $root->appendChild($generator); - $name = $gdata['name']; - if (array_key_exists('version', $gdata)) { - $name .= ' ' . $gdata['version']; - } - if (array_key_exists('uri', $gdata)) { - $name .= ' (' . $gdata['uri'] . ')'; - } - $text = $dom->createTextNode($name); - $generator->appendChild($text); - } - - /** - * Set link to feed - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLink(DOMDocument $dom, DOMElement $root) - { - $value = $this->getDataContainer()->getLink(); - if(!$value) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'RSS 2.0 feed elements MUST contain exactly one' - . ' link element but one has not been set'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $link = $dom->createElement('link'); - $root->appendChild($link); - $text = $dom->createTextNode($value); - $link->appendChild($text); - if (!Zend_Uri::check($value)) { - $link->setAttribute('isPermaLink', 'false'); - } - } - - /** - * Set feed authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(DOMDocument $dom, DOMElement $root) - { - $authors = $this->getDataContainer()->getAuthors(); - if (!$authors || empty($authors)) { - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('author'); - $name = $data['name']; - if (array_key_exists('email', $data)) { - $name = $data['email'] . ' (' . $data['name'] . ')'; - } - $text = $dom->createTextNode($name); - $author->appendChild($text); - $root->appendChild($author); - } - } - - /** - * Set feed copyright - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCopyright(DOMDocument $dom, DOMElement $root) - { - $copyright = $this->getDataContainer()->getCopyright(); - if (!$copyright) { - return; - } - $copy = $dom->createElement('copyright'); - $root->appendChild($copy); - $text = $dom->createTextNode($copyright); - $copy->appendChild($text); - } - - /** - * Set feed channel image - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setImage(DOMDocument $dom, DOMElement $root) - { - $image = $this->getDataContainer()->getImage(); - if (!$image) { - return; - } - if (!isset($image['title']) || empty($image['title']) - || !is_string($image['title'])) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'RSS 2.0 feed images must include a title'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (empty($image['link']) || !is_string($image['link']) - || !Zend_Uri::check($image['link'])) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Invalid parameter: parameter \'link\'' - . ' must be a non-empty string and valid URI/IRI'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $img = $dom->createElement('image'); - $root->appendChild($img); - $url = $dom->createElement('url'); - $text = $dom->createTextNode($image['uri']); - $url->appendChild($text); - $title = $dom->createElement('title'); - $text = $dom->createTextNode($image['title']); - $title->appendChild($text); - $link = $dom->createElement('link'); - $text = $dom->createTextNode($image['link']); - $link->appendChild($text); - $img->appendChild($url); - $img->appendChild($title); - $img->appendChild($link); - if (isset($image['height'])) { - if (!ctype_digit((string) $image['height']) || $image['height'] > 400) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Invalid parameter: parameter \'height\'' - . ' must be an integer not exceeding 400'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $height = $dom->createElement('height'); - $text = $dom->createTextNode($image['height']); - $height->appendChild($text); - $img->appendChild($height); - } - if (isset($image['width'])) { - if (!ctype_digit((string) $image['width']) || $image['width'] > 144) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Invalid parameter: parameter \'width\'' - . ' must be an integer not exceeding 144'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $width = $dom->createElement('width'); - $text = $dom->createTextNode($image['width']); - $width->appendChild($text); - $img->appendChild($width); - } - if (isset($image['description'])) { - if (empty($image['description']) || !is_string($image['description'])) { - // require_once 'Zend/Feed/Exception.php'; - $message = 'Invalid parameter: parameter \'description\'' - . ' must be a non-empty string'; - $exception = new Zend_Feed_Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $desc = $dom->createElement('description'); - $text = $dom->createTextNode($image['description']); - $desc->appendChild($text); - $img->appendChild($desc); - } - } - - /** - * Set date feed was created - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateCreated(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getDateCreated()) { - return; - } - if(!$this->getDataContainer()->getDateModified()) { - $this->getDataContainer()->setDateModified( - $this->getDataContainer()->getDateCreated() - ); - } - } - - /** - * Set date feed last build date - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLastBuildDate(DOMDocument $dom, DOMElement $root) - { - if(!$this->getDataContainer()->getLastBuildDate()) { - return; - } - - $lastBuildDate = $dom->createElement('lastBuildDate'); - $root->appendChild($lastBuildDate); - $text = $dom->createTextNode( - $this->getDataContainer()->getLastBuildDate()->get(Zend_Date::RSS) - ); - $lastBuildDate->appendChild($text); - } - - /** - * Set base URL to feed links - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setBaseUrl(DOMDocument $dom, DOMElement $root) - { - $baseUrl = $this->getDataContainer()->getBaseUrl(); - if (!$baseUrl) { - return; - } - $root->setAttribute('xml:base', $baseUrl); - } - - /** - * Set feed categories - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCategories(DOMDocument $dom, DOMElement $root) - { - $categories = $this->getDataContainer()->getCategories(); - if (!$categories) { - return; - } - foreach ($categories as $cat) { - $category = $dom->createElement('category'); - if (isset($cat['scheme'])) { - $category->setAttribute('domain', $cat['scheme']); - } - $text = $dom->createTextNode($cat['term']); - $category->appendChild($text); - $root->appendChild($category); - } - } -} diff --git a/libs/Zend/Feed/Writer/Renderer/RendererAbstract.php b/libs/Zend/Feed/Writer/Renderer/RendererAbstract.php deleted file mode 100644 index b3457ed643..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/RendererAbstract.php +++ /dev/null @@ -1,250 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RendererAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** @see Zend_Feed_Writer */ -// require_once 'Zend/Feed/Writer.php'; - -/** @see Zend_Version */ -// require_once 'Zend/Version.php'; - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Renderer_RendererAbstract -{ - /** - * Extensions - * @var array - */ - protected $_extensions = array(); - - /** - * @var mixed - */ - protected $_container = null; - - /** - * @var DOMDocument - */ - protected $_dom = null; - - /** - * @var bool - */ - protected $_ignoreExceptions = false; - - /** - * @var array - */ - protected $_exceptions = array(); - - /** - * Encoding of all text values - * - * @var string - */ - protected $_encoding = 'UTF-8'; - - /** - * Holds the value "atom" or "rss" depending on the feed type set when - * when last exported. - * - * @var string - */ - protected $_type = null; - - /** - * @var DOMElement - */ - protected $_rootElement = null; - - /** - * Constructor - * - * @param mixed $container - * @return void - */ - public function __construct($container) - { - $this->_container = $container; - $this->setType($container->getType()); - $this->_loadExtensions(); - } - - /** - * Save XML to string - * - * @return string - */ - public function saveXml() - { - return $this->getDomDocument()->saveXml(); - } - - /** - * Get DOM document - * - * @return DOMDocument - */ - public function getDomDocument() - { - return $this->_dom; - } - - /** - * Get document element from DOM - * - * @return DOMElement - */ - public function getElement() - { - return $this->getDomDocument()->documentElement; - } - - /** - * Get data container of items being rendered - * - * @return mixed - */ - public function getDataContainer() - { - return $this->_container; - } - - /** - * Set feed encoding - * - * @param string $enc - * @return Zend_Feed_Writer_Renderer_RendererAbstract - */ - public function setEncoding($enc) - { - $this->_encoding = $enc; - return $this; - } - - /** - * Get feed encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Indicate whether or not to ignore exceptions - * - * @param bool $bool - * @return Zend_Feed_Writer_Renderer_RendererAbstract - */ - public function ignoreExceptions($bool = true) - { - if (!is_bool($bool)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: $bool. Should be TRUE or FALSE (defaults to TRUE if null)'); - } - $this->_ignoreExceptions = $bool; - return $this; - } - - /** - * Get exception list - * - * @return array - */ - public function getExceptions() - { - return $this->_exceptions; - } - - /** - * Set the current feed type being exported to "rss" or "atom". This allows - * other objects to gracefully choose whether to execute or not, depending - * on their appropriateness for the current type, e.g. renderers. - * - * @param string $type - */ - public function setType($type) - { - $this->_type = $type; - } - - /** - * Retrieve the current or last feed type exported. - * - * @return string Value will be "rss" or "atom" - */ - public function getType() - { - return $this->_type; - } - - /** - * Sets the absolute root element for the XML feed being generated. This - * helps simplify the appending of namespace declarations, but also ensures - * namespaces are added to the root element - not scattered across the entire - * XML file - may assist namespace unsafe parsers and looks pretty ;). - * - * @param DOMElement $root - */ - public function setRootElement(DOMElement $root) - { - $this->_rootElement = $root; - } - - /** - * Retrieve the absolute root element for the XML feed being generated. - * - * @return DOMElement - */ - public function getRootElement() - { - return $this->_rootElement; - } - - /** - * Load extensions from Zend_Feed_Writer - * - * @return void - */ - protected function _loadExtensions() - { - Zend_Feed_Writer::registerCoreExtensions(); - $all = Zend_Feed_Writer::getExtensions(); - if (stripos(get_class($this), 'entry')) { - $exts = $all['entryRenderer']; - } else { - $exts = $all['feedRenderer']; - } - foreach ($exts as $extension) { - $className = Zend_Feed_Writer::getPluginLoader()->getClassName($extension); - $this->_extensions[$extension] = new $className( - $this->getDataContainer() - ); - $this->_extensions[$extension]->setEncoding($this->getEncoding()); - } - } -} diff --git a/libs/Zend/Feed/Writer/Renderer/RendererInterface.php b/libs/Zend/Feed/Writer/Renderer/RendererInterface.php deleted file mode 100644 index 89b4294416..0000000000 --- a/libs/Zend/Feed/Writer/Renderer/RendererInterface.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RendererInterface.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Feed_Writer_Renderer_RendererInterface -{ - /** - * Render feed/entry - * - * @return void - */ - public function render(); - - /** - * Save feed and/or entry to XML and return string - * - * @return string - */ - public function saveXml(); - - /** - * Get DOM document - * - * @return DOMDocument - */ - public function getDomDocument(); - - /** - * Get document element from DOM - * - * @return DOMElement - */ - public function getElement(); - - /** - * Get data container containing feed items - * - * @return mixed - */ - public function getDataContainer(); - - /** - * Should exceptions be ignored? - * - * @return mixed - */ - public function ignoreExceptions(); - - /** - * Get list of thrown exceptions - * - * @return array - */ - public function getExceptions(); - - /** - * Set the current feed type being exported to "rss" or "atom". This allows - * other objects to gracefully choose whether to execute or not, depending - * on their appropriateness for the current type, e.g. renderers. - * - * @param string $type - */ - public function setType($type); - - /** - * Retrieve the current or last feed type exported. - * - * @return string Value will be "rss" or "atom" - */ - public function getType(); - - /** - * Sets the absolute root element for the XML feed being generated. This - * helps simplify the appending of namespace declarations, but also ensures - * namespaces are added to the root element - not scattered across the entire - * XML file - may assist namespace unsafe parsers and looks pretty ;). - * - * @param DOMElement $root - */ - public function setRootElement(DOMElement $root); - - /** - * Retrieve the absolute root element for the XML feed being generated. - * - * @return DOMElement - */ - public function getRootElement(); -} diff --git a/libs/Zend/Feed/Writer/Source.php b/libs/Zend/Feed/Writer/Source.php deleted file mode 100644 index 3861fc77fc..0000000000 --- a/libs/Zend/Feed/Writer/Source.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -// require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php'; - - /** - * @category Zend - * @package Zend_Feed_Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Writer_Source extends Zend_Feed_Writer_Feed_FeedAbstract -{ - -} diff --git a/libs/Zend/Http/Client.php b/libs/Zend/Http/Client.php index 1cd17e8da4..5596a190ce 100644 --- a/libs/Zend/Http/Client.php +++ b/libs/Zend/Http/Client.php @@ -16,38 +16,33 @@ * @category Zend * @package Zend_Http * @subpackage Client - * @version $Id: Client.php 21952 2010-04-19 18:44:26Z shahar $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Client.php 17843 2009-08-27 14:40:35Z cogo $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Loader */ -// require_once 'Zend/Loader.php'; +require_once 'Zend/Loader.php'; /** * @see Zend_Uri */ -// require_once 'Zend/Uri.php'; +require_once 'Zend/Uri.php'; /** * @see Zend_Http_Client_Adapter_Interface */ -// require_once 'Zend/Http/Client/Adapter/Interface.php'; +require_once 'Zend/Http/Client/Adapter/Interface.php'; /** * @see Zend_Http_Response */ -// require_once 'Zend/Http/Response.php'; - -/** - * @see Zend_Http_Response_Stream - */ -// require_once 'Zend/Http/Response/Stream.php'; +require_once 'Zend/Http/Response.php'; /** * Zend_Http_Client is an implemetation of an HTTP client in PHP. The client @@ -60,7 +55,7 @@ * @package Zend_Http * @subpackage Client * @throws Zend_Http_Client_Exception - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Client @@ -76,7 +71,6 @@ class Zend_Http_Client const TRACE = 'TRACE'; const OPTIONS = 'OPTIONS'; const CONNECT = 'CONNECT'; - const MERGE = 'MERGE'; /** * Supported HTTP Authentication methods @@ -116,9 +110,7 @@ class Zend_Http_Client 'httpversion' => self::HTTP_1, 'keepalive' => false, 'storeresponse' => true, - 'strict' => true, - 'output_stream' => false, - 'encodecookies' => true, + 'strict' => true ); /** @@ -133,7 +125,7 @@ class Zend_Http_Client * * @var Zend_Uri_Http */ - protected $uri = null; + protected $uri; /** * Associative array of request headers @@ -271,15 +263,10 @@ class Zend_Http_Client if (!$uri instanceof Zend_Uri_Http) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception('Passed parameter is not a valid HTTP URI.'); } - // Set auth if username and password has been specified in the uri - if ($uri->getUsername() && $uri->getPassword()) { - $this->setAuth($uri->getUsername(), $uri->getPassword()); - } - // We have no ports, set the defaults if (! $uri->getPort()) { $uri->setPort(($uri->getScheme() == 'https' ? 443 : 80)); @@ -319,7 +306,7 @@ class Zend_Http_Client } elseif (! is_array($config)) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception('Array or Zend_Config object expected, got ' . gettype($config)); } @@ -350,7 +337,7 @@ class Zend_Http_Client { if (! preg_match('/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/', $method)) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("'{$method}' is not a valid HTTP request method."); } @@ -402,7 +389,7 @@ class Zend_Http_Client // Make sure the name is valid if we are in strict mode if ($this->config['strict'] && (! preg_match('/^[a-zA-Z0-9-]+$/', $name))) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("{$name} is not a valid HTTP header name"); } @@ -549,17 +536,12 @@ class Zend_Http_Client if ($user === false || $user === null) { $this->auth = null; - // Clear the auth information in the uri instance as well - if ($this->uri instanceof Zend_Uri_Http) { - $this->getUri()->setUsername(''); - $this->getUri()->setPassword(''); - } // Else, set up authentication } else { // Check we got a proper authentication type if (! defined('self::AUTH_' . strtoupper($type))) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("Invalid or not supported authentication type: '$type'"); } @@ -586,7 +568,7 @@ class Zend_Http_Client public function setCookieJar($cookiejar = true) { if (! class_exists('Zend_Http_CookieJar')) { - // require_once 'Zend/Http/CookieJar.php'; + require_once 'Zend/Http/CookieJar.php'; } if ($cookiejar instanceof Zend_Http_CookieJar) { @@ -597,7 +579,7 @@ class Zend_Http_Client $this->cookiejar = null; } else { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception('Invalid parameter type passed as CookieJar'); } @@ -626,7 +608,7 @@ class Zend_Http_Client public function setCookie($cookie, $value = null) { if (! class_exists('Zend_Http_Cookie')) { - // require_once 'Zend/Http/Cookie.php'; + require_once 'Zend/Http/Cookie.php'; } if (is_array($cookie)) { @@ -641,7 +623,7 @@ class Zend_Http_Client return $this; } - if ($value !== null && $this->config['encodecookies']) { + if ($value !== null) { $value = urlencode($value); } @@ -649,9 +631,7 @@ class Zend_Http_Client if ($cookie instanceof Zend_Http_Cookie) { $this->cookiejar->addCookie($cookie); } elseif (is_string($cookie) && $value !== null) { - $cookie = Zend_Http_Cookie::fromString("{$cookie}={$value}", - $this->uri, - $this->config['encodecookies']); + $cookie = Zend_Http_Cookie::fromString("{$cookie}={$value}", $this->uri); $this->cookiejar->addCookie($cookie); } } else { @@ -663,7 +643,7 @@ class Zend_Http_Client if (preg_match("/[=,; \t\r\n\013\014]/", $cookie)) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("Cookie name cannot contain these characters: =,; \t\r\n\013\014 ({$cookie})"); } @@ -703,7 +683,7 @@ class Zend_Http_Client if ($data === null) { if (($data = @file_get_contents($filename)) === false) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("Unable to read file '{$filename}' for upload"); } @@ -746,9 +726,7 @@ class Zend_Http_Client * 2. For backwards compatibilty: If someone uses the old post($data) method. * this method will be used to set the encoded data. * - * $data can also be stream (such as file) from which the data will be read. - * - * @param string|resource $data + * @param string $data * @param string $enctype * @return Zend_Http_Client */ @@ -756,13 +734,7 @@ class Zend_Http_Client { $this->raw_post_data = $data; $this->setEncType($enctype); - if (is_resource($data)) { - // We've got stream data - $stat = @fstat($data); - if($stat) { - $this->setHeaders(self::CONTENT_LENGTH, $stat['size']); - } - } + return $this; } @@ -772,13 +744,9 @@ class Zend_Http_Client * Should be used to reset the request parameters if the client is * used for several concurrent requests. * - * clearAll parameter controls if we clean just parameters or also - * headers and last_* - * - * @param bool $clearAll Should all data be cleared? * @return Zend_Http_Client */ - public function resetParameters($clearAll = false) + public function resetParameters() { // Reset parameter data $this->paramsGet = array(); @@ -786,18 +754,12 @@ class Zend_Http_Client $this->files = array(); $this->raw_post_data = null; - if($clearAll) { - $this->headers = array(); - $this->last_request = null; - $this->last_response = null; - } else { - // Clear outdated headers - if (isset($this->headers[strtolower(self::CONTENT_TYPE)])) { - unset($this->headers[strtolower(self::CONTENT_TYPE)]); - } - if (isset($this->headers[strtolower(self::CONTENT_LENGTH)])) { - unset($this->headers[strtolower(self::CONTENT_LENGTH)]); - } + // Clear outdated headers + if (isset($this->headers[strtolower(self::CONTENT_TYPE)])) { + unset($this->headers[strtolower(self::CONTENT_TYPE)]); + } + if (isset($this->headers[strtolower(self::CONTENT_LENGTH)])) { + unset($this->headers[strtolower(self::CONTENT_LENGTH)]); } return $this; @@ -841,12 +803,12 @@ class Zend_Http_Client if (is_string($adapter)) { if (!class_exists($adapter)) { try { - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; Zend_Loader::loadClass($adapter); } catch (Zend_Exception $e) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; - throw new Zend_Http_Client_Exception("Unable to load adapter '$adapter': {$e->getMessage()}", 0, $e); + require_once 'Zend/Http/Client/Exception.php'; + throw new Zend_Http_Client_Exception("Unable to load adapter '$adapter': {$e->getMessage()}"); } } @@ -855,7 +817,7 @@ class Zend_Http_Client if (! $adapter instanceof Zend_Http_Client_Adapter_Interface) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter'); } @@ -866,62 +828,6 @@ class Zend_Http_Client } /** - * Load the connection adapter - * - * @return Zend_Http_Client_Adapter_Interface $adapter - */ - public function getAdapter() - { - return $this->adapter; - } - - /** - * Set streaming for received data - * - * @param string|boolean $streamfile Stream file, true for temp file, false/null for no streaming - * @return Zend_Http_Client - */ - public function setStream($streamfile = true) - { - $this->setConfig(array("output_stream" => $streamfile)); - return $this; - } - - /** - * Get status of streaming for received data - * @return boolean|string - */ - public function getStream() - { - return $this->config["output_stream"]; - } - - /** - * Create temporary stream - * - * @return resource - */ - protected function _openTempStream() - { - $this->_stream_name = $this->config['output_stream']; - if(!is_string($this->_stream_name)) { - // If name is not given, create temp name - $this->_stream_name = tempnam(isset($this->config['stream_tmp_dir'])?$this->config['stream_tmp_dir']:sys_get_temp_dir(), - 'Zend_Http_Client'); - } - - if (false === ($fp = @fopen($this->_stream_name, "w+b"))) { - if ($this->adapter instanceof Zend_Http_Client_Adapter_Interface) { - $this->adapter->close(); - } - // require_once 'Zend/Http/Client/Exception.php'; - throw new Zend_Http_Client_Exception("Could not open temp file {$this->_stream_name}"); - } - - return $fp; - } - - /** * Send the HTTP request and return an HTTP response object * * @param string $method @@ -932,7 +838,7 @@ class Zend_Http_Client { if (! $this->uri instanceof Zend_Uri_Http) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception('No valid URI has been passed to the client'); } @@ -964,52 +870,21 @@ class Zend_Http_Client $body = $this->_prepareBody(); $headers = $this->_prepareHeaders(); - // check that adapter supports streaming before using it - if(is_resource($body) && !($this->adapter instanceof Zend_Http_Client_Adapter_Stream)) { - /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; - throw new Zend_Http_Client_Exception('Adapter does not support streaming'); - } - // Open the connection, send the request and read the response $this->adapter->connect($uri->getHost(), $uri->getPort(), ($uri->getScheme() == 'https' ? true : false)); - if($this->config['output_stream']) { - if($this->adapter instanceof Zend_Http_Client_Adapter_Stream) { - $stream = $this->_openTempStream(); - $this->adapter->setOutputStream($stream); - } else { - /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; - throw new Zend_Http_Client_Exception('Adapter does not support streaming'); - } - } - $this->last_request = $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body); $response = $this->adapter->read(); if (! $response) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception('Unable to read response, or response is empty'); } - if($this->config['output_stream']) { - rewind($stream); - // cleanup the adapter - $this->adapter->setOutputStream(null); - $response = Zend_Http_Response_Stream::fromStream($response, $stream); - $response->setStreamName($this->_stream_name); - if(!is_string($this->config['output_stream'])) { - // we used temp name, will need to clean up - $response->setCleanup(true); - } - } else { - $response = Zend_Http_Response::fromString($response); - } - + $response = Zend_Http_Response::fromString($response); if ($this->config['storeresponse']) { $this->last_response = $response; } @@ -1164,9 +1039,6 @@ class Zend_Http_Client return ''; } - if (isset($this->raw_post_data) && is_resource($this->raw_post_data)) { - return $this->raw_post_data; - } // If mbstring overloads substr and strlen functions, we have to // override it's internal encoding if (function_exists('mb_internal_encoding') && @@ -1228,7 +1100,7 @@ class Zend_Http_Client } /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("Cannot handle content type '{$this->enctype}' automatically." . " Please use Zend_Http_Client::setRawData to send this kind of content."); break; @@ -1389,7 +1261,7 @@ class Zend_Http_Client // In basic authentication, the user name cannot contain ":" if (strpos($user, ':') !== false) { /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("The user name cannot contain ':' in 'Basic' HTTP authentication"); } @@ -1404,7 +1276,7 @@ class Zend_Http_Client default: /** @see Zend_Http_Client_Exception */ - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("Not a supported HTTP authentication type: '$type'"); } diff --git a/libs/Zend/Http/Client/Adapter/Curl.php b/libs/Zend/Http/Client/Adapter/Curl.php index 4747bd898c..3335745c1f 100644 --- a/libs/Zend/Http/Client/Adapter/Curl.php +++ b/libs/Zend/Http/Client/Adapter/Curl.php @@ -16,24 +16,16 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @version $Id: Curl.php 22221 2010-05-21 07:00:58Z dragonbe $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Curl.php 17118 2009-07-26 09:41:41Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @see Zend_Uri_Http - */ -// require_once 'Zend/Uri/Http.php'; +/** Zend_Uri_Http */ +require_once 'Zend/Uri/Http.php'; -/** - * @see Zend_Http_Client_Adapter_Interface - */ -// require_once 'Zend/Http/Client/Adapter/Interface.php'; -/** - * @see Zend_Http_Client_Adapter_Stream - */ -// require_once 'Zend/Http/Client/Adapter/Stream.php'; +/** Zend_Http_Client_Adapter_Interface */ +require_once 'Zend/Http/Client/Adapter/Interface.php'; /** * An adapter class for Zend_Http_Client based on the curl extension. @@ -42,10 +34,10 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interface, Zend_Http_Client_Adapter_Stream +class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interface { /** * Parameters array @@ -73,7 +65,23 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac * * @var array */ - protected $_invalidOverwritableCurlOptions; + protected $_invalidOverwritableCurlOptions = array( + CURLOPT_HTTPGET, + CURLOPT_POST, + CURLOPT_PUT, + CURLOPT_CUSTOMREQUEST, + CURLOPT_HEADER, + CURLOPT_RETURNTRANSFER, + CURLOPT_HTTPHEADER, + CURLOPT_POSTFIELDS, + CURLOPT_INFILE, + CURLOPT_INFILESIZE, + CURLOPT_PORT, + CURLOPT_MAXREDIRS, + CURLOPT_TIMEOUT, + CURL_HTTP_VERSION_1_1, + CURL_HTTP_VERSION_1_0, + ); /** * Response gotten from server @@ -83,13 +91,6 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac protected $_response = null; /** - * Stream for storing output - * - * @var resource - */ - protected $out_stream; - - /** * Adapter constructor * * Config is set using setConfig() @@ -100,26 +101,9 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac public function __construct() { if (!extension_loaded('curl')) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('cURL extension has to be loaded to use this Zend_Http_Client adapter.'); } - $this->_invalidOverwritableCurlOptions = array( - CURLOPT_HTTPGET, - CURLOPT_POST, - CURLOPT_PUT, - CURLOPT_CUSTOMREQUEST, - CURLOPT_HEADER, - CURLOPT_RETURNTRANSFER, - CURLOPT_HTTPHEADER, - CURLOPT_POSTFIELDS, - CURLOPT_INFILE, - CURLOPT_INFILESIZE, - CURLOPT_PORT, - CURLOPT_MAXREDIRS, - CURLOPT_CONNECTTIMEOUT, - CURL_HTTP_VERSION_1_1, - CURL_HTTP_VERSION_1_0, - ); } /** @@ -135,7 +119,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac $config = $config->toArray(); } elseif (! is_array($config)) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception( 'Array or Zend_Config object expected, got ' . gettype($config) ); @@ -165,16 +149,6 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac } /** - * Retrieve the array of all configuration options - * - * @return array - */ - public function getConfig() - { - return $this->_config; - } - - /** * Direct setter for cURL adapter related options. * * @param string|int $option @@ -222,7 +196,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac } // Set timeout - curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $this->_config['timeout']); + curl_setopt($this->_curl, CURLOPT_TIMEOUT, $this->_config['timeout']); // Set Max redirects curl_setopt($this->_curl, CURLOPT_MAXREDIRS, $this->_config['maxredirects']); @@ -230,7 +204,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac if (!$this->_curl) { $this->close(); - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Unable to Connect to ' . $host . ':' . $port); } @@ -259,16 +233,16 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac * @return string $request * @throws Zend_Http_Client_Adapter_Exception If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option */ - public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $body = '') + public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '') { // Make sure we're properly connected if (!$this->_curl) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected"); } if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host"); } @@ -289,30 +263,20 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac case Zend_Http_Client::PUT: // There are two different types of PUT request, either a Raw Data string has been set // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used. - if(is_resource($body)) { - $this->_config['curloptions'][CURLOPT_INFILE] = $body; - } if (isset($this->_config['curloptions'][CURLOPT_INFILE])) { + if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) { + require_once 'Zend/Http/Client/Adapter/Exception.php'; + throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE."); + } + // Now we will probably already have Content-Length set, so that we have to delete it // from $headers at this point: foreach ($headers AS $k => $header) { - if (preg_match('/Content-Length:\s*(\d+)/i', $header, $m)) { - if(is_resource($body)) { - $this->_config['curloptions'][CURLOPT_INFILESIZE] = (int)$m[1]; - } + if (stristr($header, "Content-Length:") !== false) { unset($headers[$k]); } } - if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; - throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE."); - } - - if(is_resource($body)) { - $body = ''; - } - $curlMethod = CURLOPT_PUT; } else { $curlMethod = CURLOPT_CUSTOMREQUEST; @@ -334,43 +298,25 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac $curlMethod = CURLOPT_CUSTOMREQUEST; $curlValue = "TRACE"; break; - - case Zend_Http_Client::HEAD: - $curlMethod = CURLOPT_CUSTOMREQUEST; - $curlValue = "HEAD"; - break; default: // For now, through an exception for unsupported request methods - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Method currently not supported"); } - if(is_resource($body) && $curlMethod != CURLOPT_PUT) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; - throw new Zend_Http_Client_Adapter_Exception("Streaming requests are allowed only with PUT"); - } - // get http version to use - $curlHttp = ($httpVersion == 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0; + $curlHttp = ($http_ver = 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0; // mark as HTTP request and set HTTP method curl_setopt($this->_curl, $curlHttp, true); curl_setopt($this->_curl, $curlMethod, $curlValue); - if($this->out_stream) { - // headers will be read into the response - curl_setopt($this->_curl, CURLOPT_HEADER, false); - curl_setopt($this->_curl, CURLOPT_HEADERFUNCTION, array($this, "readHeader")); - // and data will be written into the file - curl_setopt($this->_curl, CURLOPT_FILE, $this->out_stream); - } else { - // ensure headers are also returned - curl_setopt($this->_curl, CURLOPT_HEADER, true); - - // ensure actual response is returned - curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true); - } + // ensure headers are also returned + curl_setopt($this->_curl, CURLOPT_HEADER, true); + + // ensure actual response is returned + curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true); // set additional headers $headers['Accept'] = ''; @@ -400,7 +346,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac foreach ((array)$this->_config['curloptions'] as $k => $v) { if (!in_array($k, $this->_invalidOverwritableCurlOptions)) { if (curl_setopt($this->_curl, $k, $v) == false) { - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception(sprintf("Unknown or erroreous cURL option '%s' set", $k)); } } @@ -408,18 +354,13 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac } // send the request - $response = curl_exec($this->_curl); - - // if we used streaming, headers are already there - if(!is_resource($this->out_stream)) { - $this->_response = $response; - } + $this->_response = curl_exec($this->_curl); $request = curl_getinfo($this->_curl, CURLINFO_HEADER_OUT); $request .= $body; if (empty($this->_response)) { - // require_once 'Zend/Http/Client/Exception.php'; + require_once 'Zend/Http/Client/Exception.php'; throw new Zend_Http_Client_Exception("Error in cURL request: " . curl_error($this->_curl)); } @@ -479,29 +420,4 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac { return $this->_curl; } - - /** - * Set output stream for the response - * - * @param resource $stream - * @return Zend_Http_Client_Adapter_Socket - */ - public function setOutputStream($stream) - { - $this->out_stream = $stream; - return $this; - } - - /** - * Header reader function for CURL - * - * @param resource $curl - * @param string $header - * @return int - */ - public function readHeader($curl, $header) - { - $this->_response .= $header; - return strlen($header); - } } diff --git a/libs/Zend/Http/Client/Adapter/Exception.php b/libs/Zend/Http/Client/Adapter/Exception.php index 082c8af302..b157e0facf 100644 --- a/libs/Zend/Http/Client/Adapter/Exception.php +++ b/libs/Zend/Http/Client/Adapter/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter_Exception - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Exception.php 17118 2009-07-26 09:41:41Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Http_Client_Exception */ -// require_once 'Zend/Http/Client/Exception.php'; +require_once 'Zend/Http/Client/Exception.php'; /** * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Client_Adapter_Exception extends Zend_Http_Client_Exception diff --git a/libs/Zend/Http/Client/Adapter/Interface.php b/libs/Zend/Http/Client/Adapter/Interface.php index be9d187947..46b84accbf 100644 --- a/libs/Zend/Http/Client/Adapter/Interface.php +++ b/libs/Zend/Http/Client/Adapter/Interface.php @@ -16,8 +16,8 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Interface.php 16214 2009-06-21 19:34:03Z thomas $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Http_Client_Adapter_Interface diff --git a/libs/Zend/Http/Client/Adapter/Proxy.php b/libs/Zend/Http/Client/Adapter/Proxy.php index cda6d62dbb..932b1b66b6 100644 --- a/libs/Zend/Http/Client/Adapter/Proxy.php +++ b/libs/Zend/Http/Client/Adapter/Proxy.php @@ -16,23 +16,23 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @version $Id: Proxy.php 20947 2010-02-06 17:09:07Z padraic $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Proxy.php 17118 2009-07-26 09:41:41Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Uri_Http */ -// require_once 'Zend/Uri/Http.php'; +require_once 'Zend/Uri/Http.php'; /** * @see Zend_Http_Client */ -// require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client.php'; /** * @see Zend_Http_Client_Adapter_Socket */ -// require_once 'Zend/Http/Client/Adapter/Socket.php'; +require_once 'Zend/Http/Client/Adapter/Socket.php'; /** * HTTP Proxy-supporting Zend_Http_Client adapter class, based on the default @@ -46,7 +46,7 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket @@ -91,11 +91,6 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket if (! $this->config['proxy_host']) { return parent::connect($host, $port, $secure); } - - /* Url might require stream context even if proxy connection doesn't */ - if ($secure) { - $this->config['sslusecontext'] = true; - } // Connect (a non-secure connection) to the proxy server return parent::connect( @@ -122,7 +117,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket // Make sure we're properly connected if (! $this->socket) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected"); } @@ -130,7 +125,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket $port = $this->config['proxy_port']; if ($this->connected_to[0] != "tcp://$host" || $this->connected_to[1] != $port) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong proxy server"); } @@ -172,7 +167,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket // Send the request if (! @fwrite($this->socket, $request)) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server"); } @@ -208,7 +203,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket // Send the request if (! @fwrite($this->socket, $request)) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server"); } @@ -225,7 +220,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket // Check that the response from the proxy is 200 if (Zend_Http_Response::extractCode($response) != 200) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Unable to connect to HTTPS proxy. Server response: " . $response); } @@ -245,7 +240,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket } if (! $success) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception("Unable to connect to" . " HTTPS server through proxy: could not negotiate secure connection."); } diff --git a/libs/Zend/Http/Client/Adapter/Socket.php b/libs/Zend/Http/Client/Adapter/Socket.php index 4f3d41722d..13427c749f 100644 --- a/libs/Zend/Http/Client/Adapter/Socket.php +++ b/libs/Zend/Http/Client/Adapter/Socket.php @@ -16,23 +16,19 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @version $Id: Socket.php 21778 2010-04-06 11:19:35Z shahar $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Socket.php 17124 2009-07-26 09:46:42Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Uri_Http */ -// require_once 'Zend/Uri/Http.php'; +require_once 'Zend/Uri/Http.php'; /** * @see Zend_Http_Client_Adapter_Interface */ -// require_once 'Zend/Http/Client/Adapter/Interface.php'; -/** - * @see Zend_Http_Client_Adapter_Stream - */ -// require_once 'Zend/Http/Client/Adapter/Stream.php'; +require_once 'Zend/Http/Client/Adapter/Interface.php'; /** * A sockets based (stream_socket_client) adapter class for Zend_Http_Client. Can be used @@ -41,10 +37,10 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interface, Zend_Http_Client_Adapter_Stream +class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interface { /** * The socket for server connection @@ -61,13 +57,6 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf protected $connected_to = array(null, null); /** - * Stream for storing output - * - * @var resource - */ - protected $out_stream = null; - - /** * Parameters array * * @var array @@ -76,8 +65,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf 'persistent' => false, 'ssltransport' => 'ssl', 'sslcert' => null, - 'sslpassphrase' => null, - 'sslusecontext' => false + 'sslpassphrase' => null ); /** @@ -113,7 +101,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf $config = $config->toArray(); } elseif (! is_array($config)) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception( 'Array or Zend_Config object expected, got ' . gettype($config) ); @@ -124,17 +112,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf } } - /** - * Retrieve the array of all configuration options - * - * @return array - */ - public function getConfig() - { - return $this->config; - } - - /** + /** * Set the stream context for the TCP connection to the server * * Can accept either a pre-existing stream context resource, or an array @@ -157,7 +135,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf } else { // Invalid parameter - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception( "Expecting either a stream context resource or array, got " . gettype($context) ); @@ -202,18 +180,18 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf // Now, if we are not connected, connect if (! is_resource($this->socket) || ! $this->config['keepalive']) { $context = $this->getStreamContext(); - if ($secure || $this->config['sslusecontext']) { + if ($secure) { if ($this->config['sslcert'] !== null) { if (! stream_context_set_option($context, 'ssl', 'local_cert', $this->config['sslcert'])) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Unable to set sslcert option'); } } if ($this->config['sslpassphrase'] !== null) { if (! stream_context_set_option($context, 'ssl', 'passphrase', $this->config['sslpassphrase'])) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Unable to set sslpassphrase option'); } } @@ -231,14 +209,14 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf if (! $this->socket) { $this->close(); - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception( 'Unable to Connect to ' . $host . ':' . $port . '. Error #' . $errno . ': ' . $errstr); } // Set the stream timeout if (! stream_set_timeout($this->socket, (int) $this->config['timeout'])) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Unable to set the connection timeout'); } @@ -261,14 +239,14 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf { // Make sure we're properly connected if (! $this->socket) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Trying to write but we are not connected'); } $host = $uri->getHost(); $host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host; if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Trying to write but we are connected to the wrong host'); } @@ -284,25 +262,14 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf $request .= "$v\r\n"; } - if(is_resource($body)) { - $request .= "\r\n"; - } else { - // Add the request body - $request .= "\r\n" . $body; - } - + // Add the request body + $request .= "\r\n" . $body; + // Send the request if (! @fwrite($this->socket, $request)) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Error writing request to server'); } - - if(is_resource($body)) { - if(stream_copy_to_stream($body, $this->socket) == 0) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; - throw new Zend_Http_Client_Adapter_Exception('Error writing request to server'); - } - } return $request; } @@ -317,7 +284,6 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf // First, read headers only $response = ''; $gotStatus = false; - $stream = !empty($this->config['stream']); while (($line = @fgets($this->socket)) !== false) { $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false); @@ -326,7 +292,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf if (rtrim($line) === '') break; } } - + $this->_checkSocketReadTimeout(); $statusCode = Zend_Http_Response::extractCode($response); @@ -353,7 +319,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf // If we got a 'transfer-encoding: chunked' header if (isset($headers['transfer-encoding'])) { - + if (strtolower($headers['transfer-encoding']) == 'chunked') { do { @@ -366,7 +332,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf $chunksize = trim($line); if (! ctype_xdigit($chunksize)) { $this->close(); - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('Invalid chunk size "' . $chunksize . '" unable to read chunked body'); } @@ -381,72 +347,46 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf $current_pos = ftell($this->socket); if ($current_pos >= $read_to) break; - if($this->out_stream) { - if(stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { - $this->_checkSocketReadTimeout(); - break; - } + $line = @fread($this->socket, $read_to - $current_pos); + if ($line === false || strlen($line) === 0) { + $this->_checkSocketReadTimeout(); + break; } else { - $line = @fread($this->socket, $read_to - $current_pos); - if ($line === false || strlen($line) === 0) { - $this->_checkSocketReadTimeout(); - break; - } - $chunk .= $line; + $chunk .= $line; } + } while (! feof($this->socket)); $chunk .= @fgets($this->socket); $this->_checkSocketReadTimeout(); - if(!$this->out_stream) { - $response .= $chunk; - } + $response .= $chunk; } while ($chunksize > 0); + } else { $this->close(); throw new Zend_Http_Client_Adapter_Exception('Cannot handle "' . $headers['transfer-encoding'] . '" transfer encoding'); } - - // We automatically decode chunked-messages when writing to a stream - // this means we have to disallow the Zend_Http_Response to do it again - if ($this->out_stream) { - $response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $response); - } + // Else, if we got the content-length header, read this number of bytes } elseif (isset($headers['content-length'])) { - // If we got more than one Content-Length header (see ZF-9404) use - // the last value sent - if (is_array($headers['content-length'])) { - $contentLength = $headers['content-length'][count($headers['content-length']) - 1]; - } else { - $contentLength = $headers['content-length']; - } - $current_pos = ftell($this->socket); $chunk = ''; - for ($read_to = $current_pos + $contentLength; + for ($read_to = $current_pos + $headers['content-length']; $read_to > $current_pos; $current_pos = ftell($this->socket)) { - if($this->out_stream) { - if(@stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { - $this->_checkSocketReadTimeout(); - break; - } - } else { - $chunk = @fread($this->socket, $read_to - $current_pos); - if ($chunk === false || strlen($chunk) === 0) { - $this->_checkSocketReadTimeout(); - break; - } - - $response .= $chunk; + $chunk = @fread($this->socket, $read_to - $current_pos); + if ($chunk === false || strlen($chunk) === 0) { + $this->_checkSocketReadTimeout(); + break; } + $response .= $chunk; + // Break if the connection ended prematurely if (feof($this->socket)) break; } @@ -455,19 +395,12 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf } else { do { - if($this->out_stream) { - if(@stream_copy_to_stream($this->socket, $this->out_stream) == 0) { - $this->_checkSocketReadTimeout(); - break; - } - } else { - $buff = @fread($this->socket, 8192); - if ($buff === false || strlen($buff) === 0) { - $this->_checkSocketReadTimeout(); - break; - } else { - $response .= $buff; - } + $buff = @fread($this->socket, 8192); + if ($buff === false || strlen($buff) === 0) { + $this->_checkSocketReadTimeout(); + break; + } else { + $response .= $buff; } } while (feof($this->socket) === false); @@ -507,7 +440,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf $timedout = $info['timed_out']; if ($timedout) { $this->close(); - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception( "Read timed out after {$this->config['timeout']} seconds", Zend_Http_Client_Adapter_Exception::READ_TIMEOUT @@ -515,19 +448,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf } } } - - /** - * Set output stream for the response - * - * @param resource $stream - * @return Zend_Http_Client_Adapter_Socket - */ - public function setOutputStream($stream) - { - $this->out_stream = $stream; - return $this; - } - + /** * Destructor: make sure the socket is disconnected * diff --git a/libs/Zend/Http/Client/Adapter/Stream.php b/libs/Zend/Http/Client/Adapter/Stream.php deleted file mode 100644 index 58dd921f20..0000000000 --- a/libs/Zend/Http/Client/Adapter/Stream.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Http - * @subpackage Client_Adapter - * @version $Id: Interface.php 16214 2009-06-21 19:34:03Z thomas $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * An interface description for Zend_Http_Client_Adapter_Stream classes. - * - * This interface decribes Zend_Http_Client_Adapter which supports streaming. - * - * @category Zend - * @package Zend_Http - * @subpackage Client_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Http_Client_Adapter_Stream -{ - /** - * Set output stream - * - * This function sets output stream where the result will be stored. - * - * @param resource $stream Stream to write the output to - * - */ - function setOutputStream($stream); -} diff --git a/libs/Zend/Http/Client/Adapter/Test.php b/libs/Zend/Http/Client/Adapter/Test.php index f974400868..e36f43ee84 100644 --- a/libs/Zend/Http/Client/Adapter/Test.php +++ b/libs/Zend/Http/Client/Adapter/Test.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @version $Id: Test.php 20096 2010-01-06 02:05:09Z bkarwin $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Test.php 17869 2009-08-28 10:37:13Z cogo $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Uri_Http */ -// require_once 'Zend/Uri/Http.php'; +require_once 'Zend/Uri/Http.php'; /** * @see Zend_Http_Response */ -// require_once 'Zend/Http/Response.php'; +require_once 'Zend/Http/Response.php'; /** * @see Zend_Http_Client_Adapter_Interface */ -// require_once 'Zend/Http/Client/Adapter/Interface.php'; +require_once 'Zend/Http/Client/Adapter/Interface.php'; /** * A testing-purposes adapter. @@ -44,7 +44,7 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interface @@ -72,13 +72,6 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac protected $responseIndex = 0; /** - * Wether or not the next request will fail with an exception - * - * @var boolean - */ - protected $_nextRequestWillFail = false; - - /** * Adapter constructor, currently empty. Config is set using setConfig() * */ @@ -86,19 +79,6 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac { } /** - * Set the nextRequestWillFail flag - * - * @param boolean $flag - * @return Zend_Http_Client_Adapter_Test - */ - public function setNextRequestWillFail($flag) - { - $this->_nextRequestWillFail = (bool) $flag; - - return $this; - } - - /** * Set the configuration array for the adapter * * @param Zend_Config | array $config @@ -109,7 +89,7 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac $config = $config->toArray(); } elseif (! is_array($config)) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception( 'Array or Zend_Config object expected, got ' . gettype($config) ); @@ -128,16 +108,9 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac * @param int $port * @param boolean $secure * @param int $timeout - * @throws Zend_Http_Client_Adapter_Exception */ public function connect($host, $port = 80, $secure = false) - { - if ($this->_nextRequestWillFail) { - $this->_nextRequestWillFail = false; - // require_once 'Zend/Http/Client/Adapter/Exception.php'; - throw new Zend_Http_Client_Adapter_Exception('Request failed'); - } - } + { } /** * Send request to the remote server @@ -229,7 +202,7 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac public function setResponseIndex($index) { if ($index < 0 || $index >= count($this->responses)) { - // require_once 'Zend/Http/Client/Adapter/Exception.php'; + require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception( 'Index out of range of response buffer size'); } diff --git a/libs/Zend/Http/Client/Exception.php b/libs/Zend/Http/Client/Exception.php index dc35e3a0e2..6d5efdf27e 100644 --- a/libs/Zend/Http/Client/Exception.php +++ b/libs/Zend/Http/Client/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Http * @subpackage Client_Exception - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Exception.php 16872 2009-07-20 11:47:08Z mikaelkael $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Http_Exception */ -// require_once 'Zend/Http/Exception.php'; +require_once 'Zend/Http/Exception.php'; /** * @category Zend * @package Zend_Http * @subpackage Client - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Client_Exception extends Zend_Http_Exception diff --git a/libs/Zend/Http/Cookie.php b/libs/Zend/Http/Cookie.php index 49d2ff6ad8..d8e278898a 100644 --- a/libs/Zend/Http/Cookie.php +++ b/libs/Zend/Http/Cookie.php @@ -16,15 +16,15 @@ * @category Zend * @package Zend_Http * @subpackage Cookie - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @version $Id: Cookie.php 21020 2010-02-11 17:27:23Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Cookie.php 17124 2009-07-26 09:46:42Z shahar $ * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Uri_Http */ -// require_once 'Zend/Uri/Http.php'; +require_once 'Zend/Uri/Http.php'; /** @@ -41,7 +41,7 @@ * * @category Zend * @package Zend_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Cookie @@ -89,13 +89,6 @@ class Zend_Http_Cookie protected $secure; /** - * Whether the cookie value has been encoded/decoded - * - * @var boolean - */ - protected $encodeValue; - - /** * Cookie object constructor * * @todo Add validation of each one of the parameters (legal domain, etc.) @@ -110,17 +103,17 @@ class Zend_Http_Cookie public function __construct($name, $value, $domain, $expires = null, $path = null, $secure = false) { if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("Cookie name cannot contain these characters: =,; \\t\\r\\n\\013\\014 ({$name})"); } if (! $this->name = (string) $name) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Cookies must have a name'); } if (! $this->domain = (string) $domain) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Cookies must have a domain'); } @@ -234,7 +227,7 @@ class Zend_Http_Cookie // Make sure we have a valid Zend_Uri_Http object if (! ($uri->valid() && ($uri->getScheme() == 'http' || $uri->getScheme() =='https'))) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Passed URI is not a valid HTTP or HTTPS URI'); } @@ -265,10 +258,7 @@ class Zend_Http_Cookie */ public function __toString() { - if ($this->encodeValue) { - return $this->name . '=' . urlencode($this->value) . ';'; - } - return $this->name . '=' . $this->value . ';'; + return $this->name . '=' . urlencode($this->value) . ';'; } /** @@ -276,16 +266,14 @@ class Zend_Http_Cookie * (for example the value of the Set-Cookie HTTP header) * * @param string $cookieStr - * @param Zend_Uri_Http|string $refUri Reference URI for default values (domain, path) - * @param boolean $encodeValue Weither or not the cookie's value should be - * passed through urlencode/urldecode + * @param Zend_Uri_Http|string $ref_uri Reference URI for default values (domain, path) * @return Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure. */ - public static function fromString($cookieStr, $refUri = null, $encodeValue = true) + public static function fromString($cookieStr, $ref_uri = null) { // Set default values - if (is_string($refUri)) { - $refUri = Zend_Uri_Http::factory($refUri); + if (is_string($ref_uri)) { + $ref_uri = Zend_Uri_Http::factory($ref_uri); } $name = ''; @@ -302,14 +290,12 @@ class Zend_Http_Cookie // Get the name and value of the cookie list($name, $value) = explode('=', trim(array_shift($parts)), 2); $name = trim($name); - if ($encodeValue) { - $value = urldecode(trim($value)); - } + $value = urldecode(trim($value)); // Set default domain and path - if ($refUri instanceof Zend_Uri_Http) { - $domain = $refUri->getHost(); - $path = $refUri->getPath(); + if ($ref_uri instanceof Zend_Uri_Http) { + $domain = $ref_uri->getHost(); + $path = $ref_uri->getPath(); $path = substr($path, 0, strrpos($path, '/')); } @@ -334,7 +320,7 @@ class Zend_Http_Cookie * * @see Zend_Date */ - // require_once 'Zend/Date.php'; + require_once 'Zend/Date.php'; $expireDate = new Zend_Date($v); $expires = $expireDate->getTimestamp(); @@ -356,9 +342,7 @@ class Zend_Http_Cookie } if ($name !== '') { - $ret = new self($name, $value, $domain, $expires, $path, $secure); - $ret->encodeValue = ($encodeValue) ? true : false; - return $ret; + return new self($name, $value, $domain, $expires, $path, $secure); } else { return false; } @@ -377,12 +361,12 @@ class Zend_Http_Cookie public static function matchCookieDomain($cookieDomain, $host) { if (! $cookieDomain) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$cookieDomain is expected to be a cookie domain"); } if (! $host) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$host is expected to be a host name"); } @@ -410,12 +394,12 @@ class Zend_Http_Cookie public static function matchCookiePath($cookiePath, $path) { if (! $cookiePath) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$cookiePath is expected to be a cookie path"); } if (! $path) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$path is expected to be a host name"); } diff --git a/libs/Zend/Http/CookieJar.php b/libs/Zend/Http/CookieJar.php index 3d00a8e0af..59afdfbd52 100644 --- a/libs/Zend/Http/CookieJar.php +++ b/libs/Zend/Http/CookieJar.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Http * @subpackage CookieJar - * @version $Id: CookieJar.php 20096 2010-01-06 02:05:09Z bkarwin $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: CookieJar.php 17124 2009-07-26 09:46:42Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Uri */ -// require_once "Zend/Uri.php"; +require_once "Zend/Uri.php"; /** * @see Zend_Http_Cookie */ -// require_once "Zend/Http/Cookie.php"; +require_once "Zend/Http/Cookie.php"; /** * @see Zend_Http_Response */ -// require_once "Zend/Http/Response.php"; +require_once "Zend/Http/Response.php"; /** * A Zend_Http_CookieJar object is designed to contain and maintain HTTP cookies, and should @@ -54,7 +54,7 @@ * @category Zend * @package Zend_Http * @subpackage CookieJar - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_CookieJar implements Countable, IteratorAggregate @@ -131,7 +131,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate $this->cookies[$domain][$path][$cookie->getName()] = $cookie; $this->_rawCookies[] = $cookie; } else { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Supplient argument is not a valid cookie string or object'); } } @@ -146,7 +146,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate public function addCookiesFromResponse($response, $ref_uri) { if (! $response instanceof Zend_Http_Response) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('$response is expected to be a Response object, ' . gettype($response) . ' was passed'); } @@ -190,7 +190,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate { if (is_string($uri)) $uri = Zend_Uri::factory($uri); if (! $uri instanceof Zend_Uri_Http) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("Invalid URI string or object passed"); } @@ -226,7 +226,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate } if (! $uri instanceof Zend_Uri_Http) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Invalid URI specified'); } @@ -249,7 +249,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate break; default: - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("Invalid value passed for \$ret_as: {$ret_as}"); break; } diff --git a/libs/Zend/Http/Exception.php b/libs/Zend/Http/Exception.php index 230c9c0a77..93a3869153 100644 --- a/libs/Zend/Http/Exception.php +++ b/libs/Zend/Http/Exception.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Http * @subpackage Exception - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Exception.php 16872 2009-07-20 11:47:08Z mikaelkael $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Http * @subpackage Client - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Exception extends Zend_Exception diff --git a/libs/Zend/Http/Response.php b/libs/Zend/Http/Response.php index decb5f357e..9db70f4e25 100644 --- a/libs/Zend/Http/Response.php +++ b/libs/Zend/Http/Response.php @@ -16,8 +16,8 @@ * @category Zend * @package Zend_Http * @subpackage Response - * @version $Id: Response.php 20096 2010-01-06 02:05:09Z bkarwin $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Response.php 17124 2009-07-26 09:46:42Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * * @package Zend_Http * @subpackage Response - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Response @@ -152,7 +152,7 @@ class Zend_Http_Response { // Make sure the response code is valid and set it if (self::responseCodeAsText($code) === null) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("{$code} is not a valid HTTP response code"); } @@ -160,7 +160,7 @@ class Zend_Http_Response // Make sure we got valid headers and set them if (! is_array($headers)) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('No valid headers were passed'); } @@ -176,7 +176,7 @@ class Zend_Http_Response // Set the HTTP version if (! preg_match('|^\d\.\d$|', $version)) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("Invalid HTTP response version: $version"); } @@ -572,7 +572,7 @@ class Zend_Http_Response while (trim($body)) { if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("Error parsing body - doesn't seem to be a chunked message"); } @@ -600,7 +600,7 @@ class Zend_Http_Response public static function decodeGzip($body) { if (! function_exists('gzinflate')) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception( 'zlib extension is required in order to decode "gzip" encoding' ); @@ -620,7 +620,7 @@ class Zend_Http_Response public static function decodeDeflate($body) { if (! function_exists('gzuncompress')) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception( 'zlib extension is required in order to decode "deflate" encoding' ); diff --git a/libs/Zend/Http/Response/Stream.php b/libs/Zend/Http/Response/Stream.php deleted file mode 100644 index 667ca321ab..0000000000 --- a/libs/Zend/Http/Response/Stream.php +++ /dev/null @@ -1,235 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Http - * @subpackage Response - * @version $Id: Response.php 17131 2009-07-26 10:03:39Z shahar $ - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Zend_Http_Response represents an HTTP 1.0 / 1.1 response message. It - * includes easy access to all the response's different elemts, as well as some - * convenience methods for parsing and validating HTTP responses. - * - * @package Zend_Http - * @subpackage Response - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_Response_Stream extends Zend_Http_Response -{ - /** - * Response as stream - * - * @var resource - */ - protected $stream; - - /** - * The name of the file containing the stream - * - * Will be empty if stream is not file-based. - * - * @var string - */ - protected $stream_name; - - /** - * Should we clean up the stream file when this response is closed? - * - * @var boolean - */ - protected $_cleanup; - - /** - * Get the response as stream - * - * @return resourse - */ - public function getStream() - { - return $this->stream; - } - - /** - * Set the response stream - * - * @param resourse $stream - * @return Zend_Http_Response_Stream - */ - public function setStream($stream) - { - $this->stream = $stream; - return $this; - } - - /** - * Get the cleanup trigger - * - * @return boolean - */ - public function getCleanup() { - return $this->_cleanup; - } - - /** - * Set the cleanup trigger - * - * @param $cleanup Set cleanup trigger - */ - public function setCleanup($cleanup = true) { - $this->_cleanup = $cleanup; - } - - /** - * Get file name associated with the stream - * - * @return string - */ - public function getStreamName() { - return $this->stream_name; - } - - /** - * Set file name associated with the stream - * - * @param string $stream_name Name to set - * @return Zend_Http_Response_Stream - */ - public function setStreamName($stream_name) { - $this->stream_name = $stream_name; - return $this; - } - - - /** - * HTTP response constructor - * - * In most cases, you would use Zend_Http_Response::fromString to parse an HTTP - * response string and create a new Zend_Http_Response object. - * - * NOTE: The constructor no longer accepts nulls or empty values for the code and - * headers and will throw an exception if the passed values do not form a valid HTTP - * responses. - * - * If no message is passed, the message will be guessed according to the response code. - * - * @param int $code Response code (200, 404, ...) - * @param array $headers Headers array - * @param string $body Response body - * @param string $version HTTP version - * @param string $message Response code as text - * @throws Zend_Http_Exception - */ - public function __construct($code, $headers, $body = null, $version = '1.1', $message = null) - { - - if(is_resource($body)) { - $this->setStream($body); - $body = ''; - } - parent::__construct($code, $headers, $body, $version, $message); - } - - /** - * Create a new Zend_Http_Response_Stream object from a string - * - * @param string $response_str - * @param resource $stream - * @return Zend_Http_Response_Stream - */ - public static function fromStream($response_str, $stream) - { - $code = self::extractCode($response_str); - $headers = self::extractHeaders($response_str); - $version = self::extractVersion($response_str); - $message = self::extractMessage($response_str); - - return new self($code, $headers, $stream, $version, $message); - } - - /** - * Get the response body as string - * - * This method returns the body of the HTTP response (the content), as it - * should be in it's readable version - that is, after decoding it (if it - * was decoded), deflating it (if it was gzip compressed), etc. - * - * If you want to get the raw body (as transfered on wire) use - * $this->getRawBody() instead. - * - * @return string - */ - public function getBody() - { - if($this->stream != null) { - $this->readStream(); - } - return parent::getBody(); - } - - /** - * Get the raw response body (as transfered "on wire") as string - * - * If the body is encoded (with Transfer-Encoding, not content-encoding - - * IE "chunked" body), gzip compressed, etc. it will not be decoded. - * - * @return string - */ - public function getRawBody() - { - if($this->stream) { - $this->readStream(); - } - return $this->body; - } - - /** - * Read stream content and return it as string - * - * Function reads the remainder of the body from the stream and closes the stream. - * - * @return string - */ - protected function readStream() - { - if(!is_resource($this->stream)) { - return ''; - } - - if(isset($headers['content-length'])) { - $this->body = stream_get_contents($this->stream, $headers['content-length']); - } else { - $this->body = stream_get_contents($this->stream); - } - fclose($this->stream); - $this->stream = null; - } - - public function __destruct() - { - if(is_resource($this->stream)) { - fclose($this->stream); - $this->stream = null; - } - if($this->_cleanup) { - @unlink($this->stream_name); - } - } - -} diff --git a/libs/Zend/Loader.php b/libs/Zend/Loader.php index b5ae731ef0..bfa962a62d 100644 --- a/libs/Zend/Loader.php +++ b/libs/Zend/Loader.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Loader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Loader.php 22020 2010-04-27 16:35:56Z matthew $ + * @version $Id: Loader.php 16206 2009-06-21 19:15:37Z thomas $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Loader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Loader @@ -56,24 +56,12 @@ class Zend_Loader } if ((null !== $dirs) && !is_string($dirs) && !is_array($dirs)) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception('Directory argument must be a string or an array'); } - // Autodiscover the path from the class name - // Implementation is PHP namespace-aware, and based on - // Framework Interop Group reference implementation: - // http://groups.google.com/group/php-standards/web/psr-0-final-proposal - $className = ltrim($class, '\\'); - $file = ''; - $namespace = ''; - if ($lastNsPos = strripos($className, '\\')) { - $namespace = substr($className, 0, $lastNsPos); - $className = substr($className, $lastNsPos + 1); - $file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; - } - $file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - + // autodiscover the path from the class name + $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; if (!empty($dirs)) { // use the autodiscovered path $dirPath = dirname($file); @@ -91,11 +79,12 @@ class Zend_Loader $file = basename($file); self::loadFile($file, $dirs, true); } else { - self::loadFile($file, null, true); + self::_securityCheck($file); + include $file; } if (!class_exists($class, false) && !interface_exists($class, false)) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception("File \"$file\" does not exist or class \"$class\" was not found in the file"); } } @@ -173,59 +162,11 @@ class Zend_Loader */ public static function isReadable($filename) { - if (is_readable($filename)) { - // Return early if the filename is readable without needing the - // include_path - return true; - } - - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' - && preg_match('/^[a-z]:/i', $filename) - ) { - // If on windows, and path provided is clearly an absolute path, - // return false immediately + if (!$fh = @fopen($filename, 'r', true)) { return false; } - - foreach (self::explodeIncludePath() as $path) { - if ($path == '.') { - if (is_readable($filename)) { - return true; - } - continue; - } - $file = $path . '/' . $filename; - if (is_readable($file)) { - return true; - } - } - return false; - } - - /** - * Explode an include path into an array - * - * If no path provided, uses current include_path. Works around issues that - * occur when the path includes stream schemas. - * - * @param string|null $path - * @return array - */ - public static function explodeIncludePath($path = null) - { - if (null === $path) { - $path = get_include_path(); - } - - if (PATH_SEPARATOR == ':') { - // On *nix systems, include_paths which include paths with a stream - // schema cannot be safely explode'd, so we have to be a bit more - // intelligent in the approach. - $paths = preg_split('#:(?!//)#', $path); - } else { - $paths = explode(PATH_SEPARATOR, $path); - } - return $paths; + @fclose($fh); + return true; } /** @@ -264,7 +205,7 @@ class Zend_Loader public static function registerAutoload($class = 'Zend_Loader', $enabled = true) { trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE); - // require_once 'Zend/Loader/Autoloader.php'; + require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); @@ -272,7 +213,7 @@ class Zend_Loader self::loadClass($class); $methods = get_class_methods($class); if (!in_array('autoload', (array) $methods)) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception("The class \"$class\" does not have an autoload() method"); } @@ -299,7 +240,7 @@ class Zend_Loader * Security check */ if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception('Security check: Illegal character in filename'); } } diff --git a/libs/Zend/Loader/Autoloader.php b/libs/Zend/Loader/Autoloader.php index 11ddf6eca4..d218331444 100644 --- a/libs/Zend/Loader/Autoloader.php +++ b/libs/Zend/Loader/Autoloader.php @@ -15,8 +15,8 @@ * @category Zend * @package Zend_Loader * @subpackage Autoloader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @version $Id: Autoloader.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Autoloader.php 18339 2009-09-21 15:05:25Z matthew $ * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,11 +25,11 @@ require_once 'Zend/Loader.php'; /** * Autoloader stack and namespace autoloader - * + * * @uses Zend_Loader_Autoloader * @package Zend_Loader * @subpackage Autoloader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Loader_Autoloader @@ -84,7 +84,7 @@ class Zend_Loader_Autoloader /** * Retrieve singleton instance - * + * * @return Zend_Loader_Autoloader */ public static function getInstance() @@ -97,7 +97,7 @@ class Zend_Loader_Autoloader /** * Reset the singleton instance - * + * * @return void */ public static function resetInstance() @@ -107,8 +107,8 @@ class Zend_Loader_Autoloader /** * Autoload a class - * - * @param string $class + * + * @param string $class * @return bool */ public static function autoload($class) @@ -138,7 +138,7 @@ class Zend_Loader_Autoloader /** * Set the default autoloader implementation - * + * * @param string|array $callback PHP callback * @return void */ @@ -154,7 +154,7 @@ class Zend_Loader_Autoloader /** * Retrieve the default autoloader callback - * + * * @return string|array PHP Callback */ public function getDefaultAutoloader() @@ -164,7 +164,7 @@ class Zend_Loader_Autoloader /** * Set several autoloader callbacks at once - * + * * @param array $autoloaders Array of PHP callbacks (or Zend_Loader_Autoloader_Interface implementations) to act as autoloaders * @return Zend_Loader_Autoloader */ @@ -176,7 +176,7 @@ class Zend_Loader_Autoloader /** * Get attached autoloader implementations - * + * * @return array */ public function getAutoloaders() @@ -186,7 +186,7 @@ class Zend_Loader_Autoloader /** * Return all autoloaders for a given namespace - * + * * @param string $namespace * @return array */ @@ -201,8 +201,8 @@ class Zend_Loader_Autoloader /** * Register a namespace to autoload - * - * @param string|array $namespace + * + * @param string|array $namespace * @return Zend_Loader_Autoloader */ public function registerNamespace($namespace) @@ -223,8 +223,8 @@ class Zend_Loader_Autoloader /** * Unload a registered autoload namespace - * - * @param string|array $namespace + * + * @param string|array $namespace * @return Zend_Loader_Autoloader */ public function unregisterNamespace($namespace) @@ -245,7 +245,7 @@ class Zend_Loader_Autoloader /** * Get a list of registered autoload namespaces - * + * * @return array */ public function getRegisteredNamespaces() @@ -281,8 +281,8 @@ class Zend_Loader_Autoloader /** * Get or set the value of the "suppress not found warnings" flag - * - * @param null|bool $flag + * + * @param null|bool $flag * @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise */ public function suppressNotFoundWarnings($flag = null) @@ -296,8 +296,8 @@ class Zend_Loader_Autoloader /** * Indicate whether or not this autoloader should be a fallback autoloader - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Loader_Autoloader */ public function setFallbackAutoloader($flag) @@ -308,7 +308,7 @@ class Zend_Loader_Autoloader /** * Is this instance acting as a fallback autoloader? - * + * * @return bool */ public function isFallbackAutoloader() @@ -319,11 +319,11 @@ class Zend_Loader_Autoloader /** * Get autoloaders to use when matching class * - * Determines if the class matches a registered namespace, and, if so, - * returns only the autoloaders for that namespace. Otherwise, it returns + * Determines if the class matches a registered namespace, and, if so, + * returns only the autoloaders for that namespace. Otherwise, it returns * all non-namespaced autoloaders. * - * @param string $class + * @param string $class * @return array Array of autoloaders to use */ public function getClassAutoloaders($class) @@ -365,7 +365,7 @@ class Zend_Loader_Autoloader /** * Add an autoloader to the beginning of the stack - * + * * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation * @param string|array $namespace Specific namespace(s) under which to register callback * @return Zend_Loader_Autoloader @@ -388,7 +388,7 @@ class Zend_Loader_Autoloader /** * Append an autoloader to the autoloader stack - * + * * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation * @param string|array $namespace Specific namespace(s) under which to register callback * @return Zend_Loader_Autoloader @@ -411,7 +411,7 @@ class Zend_Loader_Autoloader /** * Remove an autoloader from the autoloader stack - * + * * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation * @param null|string|array $namespace Specific namespace(s) from which to remove autoloader * @return Zend_Loader_Autoloader @@ -449,7 +449,7 @@ class Zend_Loader_Autoloader * Constructor * * Registers instance with spl_autoload stack - * + * * @return void */ protected function __construct() @@ -460,8 +460,8 @@ class Zend_Loader_Autoloader /** * Internal autoloader implementation - * - * @param string $class + * + * @param string $class * @return bool */ protected function _autoload($class) @@ -481,9 +481,9 @@ class Zend_Loader_Autoloader /** * Set autoloaders for a specific namespace - * - * @param array $autoloaders - * @param string $namespace + * + * @param array $autoloaders + * @param string $namespace * @return Zend_Loader_Autoloader */ protected function _setNamespaceAutoloaders(array $autoloaders, $namespace = '') @@ -495,15 +495,15 @@ class Zend_Loader_Autoloader /** * Retrieve the filesystem path for the requested ZF version - * - * @param string $path - * @param string $version + * + * @param string $path + * @param string $version * @return void */ protected function _getVersionPath($path, $version) { $type = $this->_getVersionType($version); - + if ($type == 'latest') { $version = 'latest'; } @@ -519,8 +519,8 @@ class Zend_Loader_Autoloader /** * Retrieve the ZF version type - * - * @param string $version + * + * @param string $version * @return string "latest", "major", "minor", or "specific" * @throws Zend_Loader_Exception if version string contains too many dots */ @@ -546,9 +546,9 @@ class Zend_Loader_Autoloader /** * Get available versions for the version type requested - * - * @param string $path - * @param string $version + * + * @param string $path + * @param string $version * @return array */ protected function _getAvailableVersions($path, $version) diff --git a/libs/Zend/Loader/Autoloader/Interface.php b/libs/Zend/Loader/Autoloader/Interface.php index 8bcaf14fb2..09983ae188 100644 --- a/libs/Zend/Loader/Autoloader/Interface.php +++ b/libs/Zend/Loader/Autoloader/Interface.php @@ -15,17 +15,17 @@ * @category Zend * @package Zend_Loader * @subpackage Autoloader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Interface.php 16541 2009-07-07 06:59:03Z bkarwin $ * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * Autoloader interface - * + * * @package Zend_Loader * @subpackage Autoloader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Loader_Autoloader_Interface diff --git a/libs/Zend/Loader/Autoloader/Resource.php b/libs/Zend/Loader/Autoloader/Resource.php index cd0a7fe7fc..15ae74c9a0 100644 --- a/libs/Zend/Loader/Autoloader/Resource.php +++ b/libs/Zend/Loader/Autoloader/Resource.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Loader * @subpackage Autoloader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @version $Id: Resource.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Resource.php 18173 2009-09-17 15:35:05Z padraic $ * @license http://framework.zend.com/license/new-bsd New BSD License */ /** Zend_Loader_Autoloader_Interface */ -// require_once 'Zend/Loader/Autoloader/Interface.php'; +require_once 'Zend/Loader/Autoloader/Interface.php'; /** * Resource loader - * + * * @uses Zend_Loader_Autoloader_Interface * @package Zend_Loader * @subpackage Autoloader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interface @@ -61,7 +61,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Constructor - * + * * @param array|Zend_Config $options Configuration options for resource autoloader * @return void */ @@ -71,7 +71,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac $options = $options->toArray(); } if (!is_array($options)) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('Options must be passed to resource loader constructor'); } @@ -81,7 +81,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac if ((null === $namespace) || (null === $this->getBasePath()) ) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('Resource loader requires both a namespace and a base path for initialization'); } @@ -94,7 +94,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Overloading: methods * - * Allow retrieving concrete resource object instances using 'get<Resourcename>()' + * Allow retrieving concrete resource object instances using 'get<Resourcename>()' * syntax. Example: * <code> * $loader = new Zend_Loader_Autoloader_Resource(array( @@ -105,9 +105,9 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac * * $foo = $loader->getModel('Foo'); // get instance of Stuff_Model_Foo class * </code> - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return mixed * @throws Zend_Loader_Exception if method not beginning with 'get' or not matching a valid resource type is called */ @@ -116,28 +116,28 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac if ('get' == substr($method, 0, 3)) { $type = strtolower(substr($method, 3)); if (!$this->hasResourceType($type)) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception("Invalid resource type $type; cannot load resource"); } if (empty($args)) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception("Cannot load resources; no resource specified"); } $resource = array_shift($args); return $this->load($resource, $type); } - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception("Method '$method' is not supported"); } /** - * Helper method to calculate the correct class path - * - * @param string $class - * @return False if not matched other wise the correct path + * Attempt to autoload a class + * + * @param string $class + * @return mixed False if not matched, otherwise result if include operation */ - public function getClassPath($class) + public function autoload($class) { $segments = explode('_', $class); $namespaceTopLevel = $this->getNamespace(); @@ -171,36 +171,15 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac return false; } - $final = substr($class, strlen($lastMatch) + 1); + $final = substr($class, strlen($lastMatch)); $path = $this->_components[$lastMatch]; - $classPath = $path . '/' . str_replace('_', '/', $final) . '.php'; - - if (Zend_Loader::isReadable($classPath)) { - return $classPath; - } - - return false; - } - - /** - * Attempt to autoload a class - * - * @param string $class - * @return mixed False if not matched, otherwise result if include operation - */ - public function autoload($class) - { - $classPath = $this->getClassPath($class); - if (false !== $classPath) { - return include $classPath; - } - return false; + return include $path . '/' . str_replace('_', '/', $final) . '.php'; } /** * Set class state from options - * - * @param array $options + * + * @param array $options * @return Zend_Loader_Autoloader_Resource */ public function setOptions(array $options) @@ -217,8 +196,8 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Set namespace that this autoloader handles - * - * @param string $namespace + * + * @param string $namespace * @return Zend_Loader_Autoloader_Resource */ public function setNamespace($namespace) @@ -229,7 +208,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Get namespace this autoloader handles - * + * * @return string */ public function getNamespace() @@ -239,8 +218,8 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Set base path for this set of resources - * - * @param string $path + * + * @param string $path * @return Zend_Loader_Autoloader_Resource */ public function setBasePath($path) @@ -248,10 +227,10 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac $this->_basePath = (string) $path; return $this; } - + /** * Get base path to this set of resources - * + * * @return string */ public function getBasePath() @@ -261,7 +240,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Add resource type - * + * * @param string $type identifier for the resource type being loaded * @param string $path path relative to resource base path containing the resource types * @param null|string $namespace sub-component namespace to append to base namespace that qualifies this resource type @@ -272,7 +251,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac $type = strtolower($type); if (!isset($this->_resourceTypes[$type])) { if (null === $namespace) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('Initial definition of a resource type must include a namespace'); } $namespaceTopLevel = $this->getNamespace(); @@ -282,7 +261,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac ); } if (!is_string($path)) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('Invalid path specification provided; must be string'); } $this->_resourceTypes[$type]['path'] = $this->getBasePath() . '/' . rtrim($path, '\/'); @@ -295,10 +274,10 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Add multiple resources at once * - * $types should be an associative array of resource type => specification - * pairs. Each specification should be an associative array containing - * minimally the 'path' key (specifying the path relative to the resource - * base path) and optionally the 'namespace' key (indicating the subcomponent + * $types should be an associative array of resource type => specification + * pairs. Each specification should be an associative array containing + * minimally the 'path' key (specifying the path relative to the resource + * base path) and optionally the 'namespace' key (indicating the subcomponent * namespace to append to the resource namespace). * * As an example: @@ -314,19 +293,19 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac * ), * )); * </code> - * - * @param array $types + * + * @param array $types * @return Zend_Loader_Autoloader_Resource */ public function addResourceTypes(array $types) { foreach ($types as $type => $spec) { if (!is_array($spec)) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('addResourceTypes() expects an array of arrays'); } if (!isset($spec['path'])) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('addResourceTypes() expects each array to include a paths element'); } $paths = $spec['path']; @@ -341,9 +320,9 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Overwrite existing and set multiple resource types at once - * + * * @see Zend_Loader_Autoloader_Resource::addResourceTypes() - * @param array $types + * @param array $types * @return Zend_Loader_Autoloader_Resource */ public function setResourceTypes(array $types) @@ -354,7 +333,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Retrieve resource type mappings - * + * * @return array */ public function getResourceTypes() @@ -364,8 +343,8 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Is the requested resource type defined? - * - * @param string $type + * + * @param string $type * @return bool */ public function hasResourceType($type) @@ -375,8 +354,8 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Remove the requested resource type - * - * @param string $type + * + * @param string $type * @return Zend_Loader_Autoloader_Resource */ public function removeResourceType($type) @@ -391,7 +370,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Clear all resource types - * + * * @return Zend_Loader_Autoloader_Resource */ public function clearResourceTypes() @@ -403,8 +382,8 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Set default resource type to use when calling load() - * - * @param string $type + * + * @param string $type * @return Zend_Loader_Autoloader_Resource */ public function setDefaultResourceType($type) @@ -417,7 +396,7 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Get default resource type to use when calling load() - * + * * @return string|null */ public function getDefaultResourceType() @@ -428,12 +407,12 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac /** * Object registry and factory * - * Loads the requested resource of type $type (or uses the default resource - * type if none provided). If the resource has been loaded previously, + * Loads the requested resource of type $type (or uses the default resource + * type if none provided). If the resource has been loaded previously, * returns the previous instance; otherwise, instantiates it. - * - * @param string $resource - * @param string $type + * + * @param string $resource + * @param string $type * @return object * @throws Zend_Loader_Exception if resource type not specified or invalid */ @@ -442,12 +421,12 @@ class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interfac if (null === $type) { $type = $this->getDefaultResourceType(); if (empty($type)) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('No resource type specified'); } } if (!$this->hasResourceType($type)) { - // require_once 'Zend/Loader/Exception.php'; + require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('Invalid resource type specified'); } $namespace = $this->_resourceTypes[$type]['namespace']; diff --git a/libs/Zend/Loader/Exception.php b/libs/Zend/Loader/Exception.php index 84d40420ef..99ad35db7b 100644 --- a/libs/Zend/Loader/Exception.php +++ b/libs/Zend/Loader/Exception.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Loader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Loader * @uses Zend_Exception - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Loader_Exception extends Zend_Exception -{}
\ No newline at end of file +class Zend_Loader_Exception extends Zend_Exception +{} diff --git a/libs/Zend/Loader/PluginLoader.php b/libs/Zend/Loader/PluginLoader.php index f3f6170c67..39ff94cfe5 100644 --- a/libs/Zend/Loader/PluginLoader.php +++ b/libs/Zend/Loader/PluginLoader.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PluginLoader.php 21170 2010-02-23 19:50:16Z matthew $ + * @version $Id: PluginLoader.php 18207 2009-09-17 22:29:50Z beberlei $ */ /** Zend_Loader_PluginLoader_Interface */ -// require_once 'Zend/Loader/PluginLoader/Interface.php'; +require_once 'Zend/Loader/PluginLoader/Interface.php'; /** Zend_Loader */ -// require_once 'Zend/Loader.php'; +require_once 'Zend/Loader.php'; /** * Generic plugin class loader @@ -32,7 +32,7 @@ * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface @@ -123,15 +123,9 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface */ protected function _formatPrefix($prefix) { - if($prefix == "") { - return $prefix; - } - - $last = strlen($prefix) - 1; - if ($prefix{$last} == '\\') { - return $prefix; - } - + if($prefix == "") { + return $prefix; + } return rtrim($prefix, '_') . '_'; } @@ -145,7 +139,7 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface public function addPrefixPath($prefix, $path) { if (!is_string($prefix) || !is_string($path)) { - // require_once 'Zend/Loader/PluginLoader/Exception.php'; + require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.'); } @@ -250,14 +244,14 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface } if (!isset($registry[$prefix])) { - // require_once 'Zend/Loader/PluginLoader/Exception.php'; + require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' was not found in the PluginLoader.'); } if ($path != null) { $pos = array_search($path, $registry[$prefix]); if ($pos === null) { - // require_once 'Zend/Loader/PluginLoader/Exception.php'; + require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' / Path ' . $path . ' was not found in the PluginLoader.'); } unset($registry[$prefix][$pos]); @@ -304,7 +298,7 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface public function getClassName($name) { $name = $this->_formatName($name); - if ($this->_useStaticRegistry + if ($this->_useStaticRegistry && isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]; @@ -317,14 +311,14 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Get path to plugin class - * - * @param mixed $name + * + * @param mixed $name * @return string|false False if not found */ public function getClassPath($name) { $name = $this->_formatName($name); - if ($this->_useStaticRegistry + if ($this->_useStaticRegistry && !empty(self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]; @@ -351,9 +345,9 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface * Load a plugin via the name provided * * @param string $name - * @param bool $throwExceptions Whether or not to throw exceptions if the + * @param bool $throwExceptions Whether or not to throw exceptions if the * class is not resolved - * @return string|false Class name of loaded class; false if $throwExceptions + * @return string|false Class name of loaded class; false if $throwExceptions * if false and no class found * @throws Zend_Loader_Exception if class not found */ @@ -408,14 +402,16 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface foreach ($registry as $prefix => $paths) { $message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths); } - // require_once 'Zend/Loader/PluginLoader/Exception.php'; + require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception($message); } if ($this->_useStaticRegistry) { self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className; + self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = (isset($loadFile) ? $loadFile : ''); } else { $this->_loadedPlugins[$name] = $className; + $this->_loadedPluginPaths[$name] = (isset($loadFile) ? $loadFile : ''); } return $className; } @@ -423,10 +419,10 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Set path to class file cache * - * Specify a path to a file that will add include_once statements for each + * Specify a path to a file that will add include_once statements for each * plugin class loaded. This is an opt-in feature for performance purposes. - * - * @param string $file + * + * @param string $file * @return void * @throws Zend_Loader_PluginLoader_Exception if file is not writeable or path does not exist */ @@ -438,15 +434,15 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface } if (!file_exists($file) && !file_exists(dirname($file))) { - // require_once 'Zend/Loader/PluginLoader/Exception.php'; + require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Specified file does not exist and/or directory does not exist (' . $file . ')'); } if (file_exists($file) && !is_writable($file)) { - // require_once 'Zend/Loader/PluginLoader/Exception.php'; + require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } if (!file_exists($file) && file_exists(dirname($file)) && !is_writable(dirname($file))) { - // require_once 'Zend/Loader/PluginLoader/Exception.php'; + require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } @@ -455,7 +451,7 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Retrieve class file cache path - * + * * @return string|null */ public static function getIncludeFileCache() @@ -465,8 +461,8 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Append an include_once statement to the class file cache - * - * @param string $incFile + * + * @param string $incFile * @return void */ protected static function _appendIncFile($incFile) diff --git a/libs/Zend/Loader/PluginLoader/Exception.php b/libs/Zend/Loader/PluginLoader/Exception.php index 7db26ae6be..9e0a744e5f 100644 --- a/libs/Zend/Loader/PluginLoader/Exception.php +++ b/libs/Zend/Loader/PluginLoader/Exception.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Loader_Exception */ -// require_once 'Zend/Loader/Exception.php'; +require_once 'Zend/Loader/Exception.php'; /** * Plugin class loader exceptions @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Loader_PluginLoader_Exception extends Zend_Loader_Exception diff --git a/libs/Zend/Loader/PluginLoader/Interface.php b/libs/Zend/Loader/PluginLoader/Interface.php index bfbbe50e3c..67da668506 100644 --- a/libs/Zend/Loader/PluginLoader/Interface.php +++ b/libs/Zend/Loader/PluginLoader/Interface.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @@ -26,7 +26,7 @@ * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Loader_PluginLoader_Interface @@ -39,7 +39,7 @@ interface Zend_Loader_PluginLoader_Interface * @return Zend_Loader_PluginLoader */ public function addPrefixPath($prefix, $path); - + /** * Remove a prefix (or prefixed-path) from the registry * @@ -48,7 +48,7 @@ interface Zend_Loader_PluginLoader_Interface * @return Zend_Loader_PluginLoader */ public function removePrefixPath($prefix, $path = null); - + /** * Whether or not a Helper by a specific name * @@ -64,7 +64,7 @@ interface Zend_Loader_PluginLoader_Interface * @return string */ public function getClassName($name); - + /** * Load a helper via the name provided * diff --git a/libs/Zend/Log.php b/libs/Zend/Log.php index 471c0e3cf4..04b7ebb85a 100644 --- a/libs/Zend/Log.php +++ b/libs/Zend/Log.php @@ -14,17 +14,17 @@ * * @category Zend * @package Zend_Log - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Log.php 20893 2010-02-03 22:59:25Z yoshida@zend.co.jp $ + * @version $Id: Log.php 16207 2009-06-21 19:17:51Z thomas $ */ /** * @category Zend * @package Zend_Log - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Log.php 20893 2010-02-03 22:59:25Z yoshida@zend.co.jp $ + * @version $Id: Log.php 16207 2009-06-21 19:17:51Z thomas $ */ class Zend_Log { @@ -59,19 +59,6 @@ class Zend_Log protected $_extras = array(); /** - * - * @var string - */ - protected $_defaultWriterNamespace = 'Zend_Log_Writer'; - - /** - * - * @var string - */ - protected $_defaultFilterNamespace = 'Zend_Log_Filter'; - - - /** * Class constructor. Create a new logger * * @param Zend_Log_Writer_Abstract|null $writer default writer @@ -87,146 +74,6 @@ class Zend_Log } /** - * Factory to construct the logger and one or more writers - * based on the configuration array - * - * @param array|Zend_Config Array or instance of Zend_Config - * @return Zend_Log - */ - static public function factory($config = array()) - { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } - - if (!is_array($config) || empty($config)) { - /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config'); - } - - $log = new Zend_Log; - - if (!is_array(current($config))) { - $log->addWriter(current($config)); - } else { - foreach($config as $writer) { - $log->addWriter($writer); - } - } - - return $log; - } - - - /** - * Construct a writer object based on a configuration array - * - * @param array $spec config array with writer spec - * @return Zend_Log_Writer_Abstract - */ - protected function _constructWriterFromConfig($config) - { - $writer = $this->_constructFromConfig('writer', $config, $this->_defaultWriterNamespace); - - if (!$writer instanceof Zend_Log_Writer_Abstract) { - /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception("{$writerName} does not extend Zend_Log_Writer_Abstract!"); - } - - if (isset($config['filterName'])) { - $filter = $this->_constructFilterFromConfig($config); - $writer->addFilter($filter); - } - - return $writer; - } - - /** - * Construct filter object from configuration array or Zend_Config object - * - * @param array|Zend_Config $config Zend_Config or Array - * @return Zend_Log_Filter_Interface - */ - protected function _constructFilterFromConfig($config) - { - $filter = $this->_constructFromConfig('filter', $config, $this->_defaultFilterNamespace); - - if (!$filter instanceof Zend_Log_Filter_Interface) { - /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception("{$filterName} does not implement Zend_Log_Filter_Interface"); - } - - return $filter; - } - - /** - * Construct a filter or writer from config - * - * @param string $type 'writer' of 'filter' - * @param mixed $config Zend_Config or Array - * @param string $namespace - * @return object - */ - protected function _constructFromConfig($type, $config, $namespace) - { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } - - if (!is_array($config) || empty($config)) { - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception( - 'Configuration must be an array or instance of Zend_Config' - ); - } - - $params = isset($config[ $type .'Params' ]) ? $config[ $type .'Params' ] : array(); - $className = $this->getClassName($config, $type, $namespace); - // if (!class_exists($className)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($className); - // } - - $reflection = new ReflectionClass($className); - if (!$reflection->implementsInterface('Zend_Log_FactoryInterface')) { - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception( - 'Driver does not implement Zend_Log_FactoryInterface and can not be constructed from config.' - ); - } - - return call_user_func(array($className, 'factory'), $params); - } - - /** - * Get the writer or filter full classname - * - * @param array $config - * @param string $type filter|writer - * @param string $defaultNamespace - * @return string full classname - */ - protected function getClassName($config, $type, $defaultNamespace) - { - if (!isset($config[ $type . 'Name' ])) { - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception("Specify {$type}Name in the configuration array"); - } - $className = $config[ $type . 'Name' ]; - - $namespace = $defaultNamespace; - if (isset($config[ $type . 'Namespace' ])) { - $namespace = $config[ $type . 'Namespace' ]; - } - - $fullClassName = $namespace . '_' . $className; - return $fullClassName; - } - - /** * Class destructor. Shutdown log writers * * @return void @@ -253,24 +100,10 @@ class Zend_Log { $priority = strtoupper($method); if (($priority = array_search($priority, $this->_priorities)) !== false) { - switch (count($params)) { - case 0: - /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception('Missing log message'); - case 1: - $message = array_shift($params); - $extras = null; - break; - default: - $message = array_shift($params); - $extras = array_shift($params); - break; - } - $this->log($message, $priority, $extras); + $this->log(array_shift($params), $priority); } else { /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Bad log priority'); } } @@ -280,22 +113,21 @@ class Zend_Log * * @param string $message Message to log * @param integer $priority Priority of message - * @param mixed $extras Extra information to log in event * @return void * @throws Zend_Log_Exception */ - public function log($message, $priority, $extras = null) + public function log($message, $priority) { // sanity checks if (empty($this->_writers)) { /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('No writers were added'); } if (! isset($this->_priorities[$priority])) { /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Bad log priority'); } @@ -306,25 +138,6 @@ class Zend_Log 'priorityName' => $this->_priorities[$priority]), $this->_extras); - // Check to see if any extra information was passed - if (!empty($extras)) { - $info = array(); - if (is_array($extras)) { - foreach ($extras as $key => $value) { - if (is_string($key)) { - $event[$key] = $value; - } else { - $info[] = $value; - } - } - } else { - $info = $extras; - } - if (!empty($info)) { - $event['info'] = $info; - } - } - // abort if rejected by the global filters foreach ($this->_filters as $filter) { if (! $filter->accept($event)) { @@ -353,7 +166,7 @@ class Zend_Log if (isset($this->_priorities[$priority]) || array_search($name, $this->_priorities)) { /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Existing priorities cannot be overwritten'); } @@ -371,16 +184,12 @@ class Zend_Log public function addFilter($filter) { if (is_integer($filter)) { - /** @see Zend_Log_Filter_Priority */ - // require_once 'Zend/Log/Filter/Priority.php'; + /** @see Zend_Log_Filter_Priority */ + require_once 'Zend/Log/Filter/Priority.php'; $filter = new Zend_Log_Filter_Priority($filter); - - } elseif ($filter instanceof Zend_Config || is_array($filter)) { - $filter = $this->_constructFilterFromConfig($filter); - - } elseif(! $filter instanceof Zend_Log_Filter_Interface) { + } elseif(!is_object($filter) || ! $filter instanceof Zend_Log_Filter_Interface) { /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Invalid filter provided'); } @@ -391,24 +200,11 @@ class Zend_Log * Add a writer. A writer is responsible for taking a log * message and writing it out to storage. * - * @param mixed $writer Zend_Log_Writer_Abstract or Config array + * @param Zend_Log_Writer_Abstract $writer * @return void */ - public function addWriter($writer) + public function addWriter(Zend_Log_Writer_Abstract $writer) { - if (is_array($writer) || $writer instanceof Zend_Config) { - $writer = $this->_constructWriterFromConfig($writer); - } - - if (!$writer instanceof Zend_Log_Writer_Abstract) { - /** @see Zend_Log_Exception */ - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception( - 'Writer must be an instance of Zend_Log_Writer_Abstract' - . ' or you should pass a configuration array' - ); - } - $this->_writers[] = $writer; } @@ -422,4 +218,5 @@ class Zend_Log public function setEventItem($name, $value) { $this->_extras = array_merge($this->_extras, array($name => $value)); } + } diff --git a/libs/Zend/Log/Exception.php b/libs/Zend/Log/Exception.php index b4bd50b5bb..4290898cdd 100644 --- a/libs/Zend/Log/Exception.php +++ b/libs/Zend/Log/Exception.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Log - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Log - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16219 2009-06-21 19:45:39Z thomas $ */ class Zend_Log_Exception extends Zend_Exception {} diff --git a/libs/Zend/Log/FactoryInterface.php b/libs/Zend/Log/FactoryInterface.php deleted file mode 100644 index 20a270747f..0000000000 --- a/libs/Zend/Log/FactoryInterface.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Log - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * @category Zend - * @package Zend_Log - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ -interface Zend_Log_FactoryInterface -{ - /** - * Construct a Zend_Log driver - * - * @param array|Zen_Config $config - * @return Zend_Log_FactoryInterface - */ - static public function factory($config); -} diff --git a/libs/Zend/Log/Filter/Abstract.php b/libs/Zend/Log/Filter/Abstract.php deleted file mode 100644 index e0e97b89f2..0000000000 --- a/libs/Zend/Log/Filter/Abstract.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Log - * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** @see Zend_Log_Filter_Interface */ -// require_once 'Zend/Log/Filter/Interface.php'; - -/** @see Zend_Log_FactoryInterface */ -// require_once 'Zend/Log/FactoryInterface.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ -abstract class Zend_Log_Filter_Abstract - implements Zend_Log_Filter_Interface, Zend_Log_FactoryInterface -{ - /** - * Validate and optionally convert the config to array - * - * @param array|Zend_Config $config Zend_Config or Array - * @return array - * @throws Zend_Log_Exception - */ - static protected function _parseConfig($config) - { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } - - if (!is_array($config)) { - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config'); - } - - return $config; - } -} diff --git a/libs/Zend/Log/Filter/Interface.php b/libs/Zend/Log/Filter/Interface.php index c2165d2ba6..104b578f91 100644 --- a/libs/Zend/Log/Filter/Interface.php +++ b/libs/Zend/Log/Filter/Interface.php @@ -15,18 +15,18 @@ * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16219 2009-06-21 19:45:39Z thomas $ */ interface Zend_Log_Filter_Interface { @@ -37,4 +37,5 @@ interface Zend_Log_Filter_Interface * @return boolean accepted? */ public function accept($event); + } diff --git a/libs/Zend/Log/Filter/Message.php b/libs/Zend/Log/Filter/Message.php index 4510888610..9a05deaedf 100644 --- a/libs/Zend/Log/Filter/Message.php +++ b/libs/Zend/Log/Filter/Message.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Message.php 20982 2010-02-08 15:51:36Z matthew $ + * @version $Id: Message.php 16219 2009-06-21 19:45:39Z thomas $ */ -/** Zend_Log_Filter_Abstract */ -// require_once 'Zend/Log/Filter/Abstract.php'; +/** Zend_Log_Filter_Interface */ +require_once 'Zend/Log/Filter/Interface.php'; /** * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Message.php 20982 2010-02-08 15:51:36Z matthew $ + * @version $Id: Message.php 16219 2009-06-21 19:45:39Z thomas $ */ -class Zend_Log_Filter_Message extends Zend_Log_Filter_Abstract +class Zend_Log_Filter_Message implements Zend_Log_Filter_Interface { /** * @var string @@ -47,32 +47,13 @@ class Zend_Log_Filter_Message extends Zend_Log_Filter_Abstract public function __construct($regexp) { if (@preg_match($regexp, '') === false) { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception("Invalid regular expression '$regexp'"); } $this->_regexp = $regexp; } /** - * Create a new instance of Zend_Log_Filter_Message - * - * @param array|Zend_Config $config - * @return Zend_Log_Filter_Message - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - $config = self::_parseConfig($config); - $config = array_merge(array( - 'regexp' => null - ), $config); - - return new self( - $config['regexp'] - ); - } - - /** * Returns TRUE to accept the message, FALSE to block it. * * @param array $event event data @@ -82,4 +63,5 @@ class Zend_Log_Filter_Message extends Zend_Log_Filter_Abstract { return preg_match($this->_regexp, $event['message']) > 0; } + } diff --git a/libs/Zend/Log/Filter/Priority.php b/libs/Zend/Log/Filter/Priority.php index 45ba7c953b..d19c3f9ec6 100644 --- a/libs/Zend/Log/Filter/Priority.php +++ b/libs/Zend/Log/Filter/Priority.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Priority.php 20260 2010-01-13 18:29:22Z ralph $ + * @version $Id: Priority.php 16219 2009-06-21 19:45:39Z thomas $ */ -/** Zend_Log_Filter_Abstract */ -// require_once 'Zend/Log/Filter/Abstract.php'; +/** Zend_Log_Filter_Interface */ +require_once 'Zend/Log/Filter/Interface.php'; /** * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Priority.php 20260 2010-01-13 18:29:22Z ralph $ + * @version $Id: Priority.php 16219 2009-06-21 19:45:39Z thomas $ */ -class Zend_Log_Filter_Priority extends Zend_Log_Filter_Abstract +class Zend_Log_Filter_Priority implements Zend_Log_Filter_Interface { /** * @var integer @@ -51,41 +51,15 @@ class Zend_Log_Filter_Priority extends Zend_Log_Filter_Abstract * @param string $operator Comparison operator * @throws Zend_Log_Exception */ - public function __construct($priority, $operator = NULL) + public function __construct($priority, $operator = '<=') { if (! is_integer($priority)) { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Priority must be an integer'); } $this->_priority = $priority; - $this->_operator = is_null($operator) ? '<=' : $operator; - } - - /** - * Create a new instance of Zend_Log_Filter_Priority - * - * @param array|Zend_Config $config - * @return Zend_Log_Filter_Priority - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - $config = self::_parseConfig($config); - $config = array_merge(array( - 'priority' => null, - 'operator' => null, - ), $config); - - // Add support for constants - if (!is_numeric($config['priority']) && isset($config['priority']) && defined($config['priority'])) { - $config['priority'] = constant($config['priority']); - } - - return new self( - (int) $config['priority'], - $config['operator'] - ); + $this->_operator = $operator; } /** @@ -98,4 +72,5 @@ class Zend_Log_Filter_Priority extends Zend_Log_Filter_Abstract { return version_compare($event['priority'], $this->_priority, $this->_operator); } + } diff --git a/libs/Zend/Log/Filter/Suppress.php b/libs/Zend/Log/Filter/Suppress.php index d87d2720a2..026db36727 100644 --- a/libs/Zend/Log/Filter/Suppress.php +++ b/libs/Zend/Log/Filter/Suppress.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Suppress.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Suppress.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Filter_Interface */ -// require_once 'Zend/Log/Filter/Interface.php'; +require_once 'Zend/Log/Filter/Interface.php'; /** * @category Zend * @package Zend_Log * @subpackage Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Suppress.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Suppress.php 16219 2009-06-21 19:45:39Z thomas $ */ -class Zend_Log_Filter_Suppress extends Zend_Log_Filter_Abstract +class Zend_Log_Filter_Suppress implements Zend_Log_Filter_Interface { /** * @var boolean @@ -63,15 +63,4 @@ class Zend_Log_Filter_Suppress extends Zend_Log_Filter_Abstract return $this->_accept; } - /** - * Create a new instance of Zend_Log_Filter_Suppress - * - * @param array|Zend_Config $config - * @return Zend_Log_Filter_Suppress - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - return new self(); - } } diff --git a/libs/Zend/Log/Formatter/Firebug.php b/libs/Zend/Log/Formatter/Firebug.php index a0238935ec..2d348d0c78 100644 --- a/libs/Zend/Log/Formatter/Firebug.php +++ b/libs/Zend/Log/Formatter/Firebug.php @@ -15,27 +15,27 @@ * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Firebug.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Firebug.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** Zend_Log_Formatter_Interface */ -// require_once 'Zend/Log/Formatter/Interface.php'; +require_once 'Zend/Log/Formatter/Interface.php'; /** * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Log_Formatter_Firebug implements Zend_Log_Formatter_Interface { /** * This method formats the event for the firebug writer. - * - * The default is to just send the message parameter, but through + * + * The default is to just send the message parameter, but through * extension of this class and calling the * {@see Zend_Log_Writer_Firebug::setFormatter()} method you can * pass as much of the event data as you are interested in. diff --git a/libs/Zend/Log/Formatter/Interface.php b/libs/Zend/Log/Formatter/Interface.php index 2d05145a3f..000734f393 100644 --- a/libs/Zend/Log/Formatter/Interface.php +++ b/libs/Zend/Log/Formatter/Interface.php @@ -15,18 +15,18 @@ * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16219 2009-06-21 19:45:39Z thomas $ */ interface Zend_Log_Formatter_Interface { diff --git a/libs/Zend/Log/Formatter/Simple.php b/libs/Zend/Log/Formatter/Simple.php index 22f5a116fc..0761404742 100644 --- a/libs/Zend/Log/Formatter/Simple.php +++ b/libs/Zend/Log/Formatter/Simple.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Simple.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Simple.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Formatter_Interface */ -// require_once 'Zend/Log/Formatter/Interface.php'; +require_once 'Zend/Log/Formatter/Interface.php'; /** * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Simple.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Simple.php 16219 2009-06-21 19:45:39Z thomas $ */ class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface { @@ -53,7 +53,7 @@ class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface } if (! is_string($format)) { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Format must be a string'); } diff --git a/libs/Zend/Log/Formatter/Xml.php b/libs/Zend/Log/Formatter/Xml.php index ebf3c29e97..ce0edb1301 100644 --- a/libs/Zend/Log/Formatter/Xml.php +++ b/libs/Zend/Log/Formatter/Xml.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Xml.php 20104 2010-01-06 21:26:01Z matthew $ + * @version $Id: Xml.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Formatter_Interface */ -// require_once 'Zend/Log/Formatter/Interface.php'; +require_once 'Zend/Log/Formatter/Interface.php'; /** * @category Zend * @package Zend_Log * @subpackage Formatter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Xml.php 20104 2010-01-06 21:26:01Z matthew $ + * @version $Id: Xml.php 16219 2009-06-21 19:45:39Z thomas $ */ class Zend_Log_Formatter_Xml implements Zend_Log_Formatter_Interface { @@ -44,44 +44,14 @@ class Zend_Log_Formatter_Xml implements Zend_Log_Formatter_Interface protected $_elementMap; /** - * @var string Encoding to use in XML - */ - protected $_encoding; - - /** * Class constructor * - * @param string $rootElement Name of root element * @param array $elementMap - * @param string $encoding Encoding to use (defaults to UTF-8) */ - public function __construct($rootElement = 'logEntry', $elementMap = null, $encoding = 'UTF-8') + public function __construct($rootElement = 'logEntry', $elementMap = null) { $this->_rootElement = $rootElement; $this->_elementMap = $elementMap; - $this->setEncoding($encoding); - } - - /** - * Get encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set encoding - * - * @param string $value - * @return Zend_Log_Formatter_Xml - */ - public function setEncoding($value) - { - $this->_encoding = (string) $value; - return $this; } /** @@ -101,13 +71,12 @@ class Zend_Log_Formatter_Xml implements Zend_Log_Formatter_Interface } } - $enc = $this->getEncoding(); - $dom = new DOMDocument('1.0', $enc); + $dom = new DOMDocument(); $elt = $dom->appendChild(new DOMElement($this->_rootElement)); foreach ($dataToInsert as $key => $value) { if($key == "message") { - $value = htmlspecialchars($value, ENT_COMPAT, $enc); + $value = htmlspecialchars($value); } $elt->appendChild(new DOMElement($key, $value)); } diff --git a/libs/Zend/Log/Writer/Abstract.php b/libs/Zend/Log/Writer/Abstract.php index 80b939db18..3e3be2d6cd 100644 --- a/libs/Zend/Log/Writer/Abstract.php +++ b/libs/Zend/Log/Writer/Abstract.php @@ -15,23 +15,23 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Filter_Priority */ -// require_once 'Zend/Log/Filter/Priority.php'; +require_once 'Zend/Log/Filter/Priority.php'; /** * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $ */ -abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface +abstract class Zend_Log_Writer_Abstract { /** * @var array of Zend_Log_Filter_Interface @@ -104,26 +104,4 @@ abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface */ abstract protected function _write($event); - /** - * Validate and optionally convert the config to array - * - * @param array|Zend_Config $config Zend_Config or Array - * @return array - * @throws Zend_Log_Exception - */ - static protected function _parseConfig($config) - { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } - - if (!is_array($config)) { - // require_once 'Zend/Log/Exception.php'; - throw new Zend_Log_Exception( - 'Configuration must be an array or instance of Zend_Config' - ); - } - - return $config; - } -} +}
\ No newline at end of file diff --git a/libs/Zend/Log/Writer/Db.php b/libs/Zend/Log/Writer/Db.php index 6f77a12cb7..2130efe28e 100644 --- a/libs/Zend/Log/Writer/Db.php +++ b/libs/Zend/Log/Writer/Db.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; +require_once 'Zend/Log/Writer/Abstract.php'; /** * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $ */ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract { @@ -67,38 +67,11 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract } /** - * Create a new instance of Zend_Log_Writer_Db - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Db - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - $config = self::_parseConfig($config); - $config = array_merge(array( - 'db' => null, - 'table' => null, - 'columnMap' => null, - ), $config); - - if (isset($config['columnmap'])) { - $config['columnMap'] = $config['columnmap']; - } - - return new self( - $config['db'], - $config['table'], - $config['columnMap'] - ); - } - - /** * Formatting is not possible on this writer */ public function setFormatter($formatter) { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception(get_class() . ' does not support formatting'); } @@ -121,7 +94,7 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract protected function _write($event) { if ($this->_db === null) { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Database adapter is null'); } @@ -136,4 +109,5 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract $this->_db->insert($this->_table, $dataToInsert); } + } diff --git a/libs/Zend/Log/Writer/Firebug.php b/libs/Zend/Log/Writer/Firebug.php index 585f6a3dc1..49eeae9a2d 100644 --- a/libs/Zend/Log/Writer/Firebug.php +++ b/libs/Zend/Log/Writer/Firebug.php @@ -15,30 +15,30 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Firebug.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Firebug.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** Zend_Log */ -// require_once 'Zend/Log.php'; +require_once 'Zend/Log.php'; /** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; +require_once 'Zend/Log/Writer/Abstract.php'; /** Zend_Log_Formatter_Firebug */ -// require_once 'Zend/Log/Formatter/Firebug.php'; +require_once 'Zend/Log/Formatter/Firebug.php'; /** Zend_Wildfire_Plugin_FirePhp */ -// require_once 'Zend/Wildfire/Plugin/FirePhp.php'; +require_once 'Zend/Wildfire/Plugin/FirePhp.php'; /** * Writes log messages to the Firebug Console via FirePHP. - * + * * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract @@ -56,47 +56,35 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract Zend_Log::NOTICE => Zend_Wildfire_Plugin_FirePhp::INFO, Zend_Log::INFO => Zend_Wildfire_Plugin_FirePhp::INFO, Zend_Log::DEBUG => Zend_Wildfire_Plugin_FirePhp::LOG); - + /** * The default logging style for un-mapped priorities * @var string - */ + */ protected $_defaultPriorityStyle = Zend_Wildfire_Plugin_FirePhp::LOG; - + /** * Flag indicating whether the log writer is enabled * @var boolean */ protected $_enabled = true; - + /** * Class constructor */ public function __construct() { - if (php_sapi_name() == 'cli') { + if (php_sapi_name()=='cli') { $this->setEnabled(false); } - + $this->_formatter = new Zend_Log_Formatter_Firebug(); } - - /** - * Create a new instance of Zend_Log_Writer_Firebug - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Firebug - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - return new self(); - } - + /** * Enable or disable the log writer. - * - * @param boolean $enabled Set to TRUE to enable the log writer + * + * @param boolean $enabled Set to TRUE to enable the log writer * @return boolean The previous value. */ public function setEnabled($enabled) @@ -105,43 +93,43 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract $this->_enabled = $enabled; return $previous; } - + /** * Determine if the log writer is enabled. - * + * * @return boolean Returns TRUE if the log writer is enabled. */ public function getEnabled() { return $this->_enabled; } - + /** * Set the default display style for user-defined priorities - * + * * @param string $style The default log display style * @return string Returns previous default log display style - */ + */ public function setDefaultPriorityStyle($style) { $previous = $this->_defaultPriorityStyle; $this->_defaultPriorityStyle = $style; return $previous; } - + /** * Get the default display style for user-defined priorities - * + * * @return string Returns the default log display style - */ + */ public function getDefaultPriorityStyle() { return $this->_defaultPriorityStyle; } - + /** * Set a display style for a logging priority - * + * * @param int $priority The logging priority * @param string $style The logging display style * @return string|boolean The previous logging display style if defined or TRUE otherwise @@ -158,7 +146,7 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract /** * Get a display style for a logging priority - * + * * @param int $priority The logging priority * @return string|boolean The logging display style if defined or FALSE otherwise */ @@ -181,15 +169,15 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract if (!$this->getEnabled()) { return; } - + if (array_key_exists($event['priority'],$this->_priorityStyles)) { $type = $this->_priorityStyles[$event['priority']]; } else { $type = $this->_defaultPriorityStyle; } - + $message = $this->_formatter->format($event); - + $label = isset($event['firebugLabel'])?$event['firebugLabel']:null; Zend_Wildfire_Plugin_FirePhp::getInstance()->send($message, diff --git a/libs/Zend/Log/Writer/Mail.php b/libs/Zend/Log/Writer/Mail.php index 70f57b8616..068bd33dc1 100644 --- a/libs/Zend/Log/Writer/Mail.php +++ b/libs/Zend/Log/Writer/Mail.php @@ -15,19 +15,19 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mail.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mail.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; +require_once 'Zend/Log/Writer/Abstract.php'; /** Zend_Log_Exception */ -// require_once 'Zend/Log/Exception.php'; +require_once 'Zend/Log/Exception.php'; /** Zend_Log_Formatter_Simple*/ -// require_once 'Zend/Log/Formatter/Simple.php'; +require_once 'Zend/Log/Formatter/Simple.php'; /** * Class used for writing log messages to email via Zend_Mail. @@ -39,9 +39,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mail.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mail.php 16219 2009-06-21 19:45:39Z thomas $ */ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract { @@ -117,18 +117,6 @@ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract $this->_layout = $layout; $this->_formatter = new Zend_Log_Formatter_Simple(); } - - /** - * Create a new instance of Zend_Log_Writer_Mail - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Mail - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - throw new Zend_Exception('Zend_Log_Writer_Mail does not currently implement a factory'); - } /** * Places event line into array of lines to be used as message body. diff --git a/libs/Zend/Log/Writer/Mock.php b/libs/Zend/Log/Writer/Mock.php index 1e14a2f00e..2a593c0d9e 100644 --- a/libs/Zend/Log/Writer/Mock.php +++ b/libs/Zend/Log/Writer/Mock.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mock.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mock.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; +require_once 'Zend/Log/Writer/Abstract.php'; /** * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mock.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mock.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract { @@ -63,16 +63,4 @@ class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract { $this->shutdown = true; } - - /** - * Create a new instance of Zend_Log_Writer_Mock - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Mock - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - return new self(); - } -} +}
\ No newline at end of file diff --git a/libs/Zend/Log/Writer/Null.php b/libs/Zend/Log/Writer/Null.php index f281883fbb..de791d3a99 100644 --- a/libs/Zend/Log/Writer/Null.php +++ b/libs/Zend/Log/Writer/Null.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Null.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Null.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; +require_once 'Zend/Log/Writer/Abstract.php'; /** * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Null.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Null.php 16219 2009-06-21 19:45:39Z thomas $ */ class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract { @@ -42,16 +42,5 @@ class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract protected function _write($event) { } - - /** - * Create a new instance of Zend_Log_Writer_Null - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Null - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - return new self(); - } -} + +}
\ No newline at end of file diff --git a/libs/Zend/Log/Writer/Stream.php b/libs/Zend/Log/Writer/Stream.php index b722dbb4bd..99b050ad6b 100644 --- a/libs/Zend/Log/Writer/Stream.php +++ b/libs/Zend/Log/Writer/Stream.php @@ -15,24 +15,24 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Stream.php 16219 2009-06-21 19:45:39Z thomas $ */ /** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; +require_once 'Zend/Log/Writer/Abstract.php'; /** Zend_Log_Formatter_Simple */ -// require_once 'Zend/Log/Formatter/Simple.php'; +require_once 'Zend/Log/Formatter/Simple.php'; /** * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Stream.php 16219 2009-06-21 19:45:39Z thomas $ */ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract { @@ -48,32 +48,23 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract * @param streamOrUrl Stream or URL to open as a stream * @param mode Mode, only applicable if a URL is given */ - public function __construct($streamOrUrl, $mode = NULL) + public function __construct($streamOrUrl, $mode = 'a') { - // Setting the default - if ($mode === NULL) { - $mode = 'a'; - } - if (is_resource($streamOrUrl)) { if (get_resource_type($streamOrUrl) != 'stream') { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Resource is not a stream'); } if ($mode != 'a') { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Mode cannot be changed on existing streams'); } $this->_stream = $streamOrUrl; } else { - if (is_array($streamOrUrl) && isset($streamOrUrl['stream'])) { - $streamOrUrl = $streamOrUrl['stream']; - } - if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; $msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\""; throw new Zend_Log_Exception($msg); } @@ -81,30 +72,7 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract $this->_formatter = new Zend_Log_Formatter_Simple(); } - - /** - * Create a new instance of Zend_Log_Writer_Mock - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Mock - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - $config = self::_parseConfig($config); - $config = array_merge(array( - 'stream' => null, - 'mode' => null, - ), $config); - $streamOrUrl = isset($config['url']) ? $config['url'] : $config['stream']; - - return new self( - $streamOrUrl, - $config['mode'] - ); - } - /** * Close the stream resource. * @@ -128,8 +96,9 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract $line = $this->_formatter->format($event); if (false === @fwrite($this->_stream, $line)) { - // require_once 'Zend/Log/Exception.php'; + require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception("Unable to write to stream"); } } + } diff --git a/libs/Zend/Log/Writer/Syslog.php b/libs/Zend/Log/Writer/Syslog.php index 310bcf54ec..3409ae56dc 100644 --- a/libs/Zend/Log/Writer/Syslog.php +++ b/libs/Zend/Log/Writer/Syslog.php @@ -15,13 +15,13 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Syslog.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Syslog.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; +require_once 'Zend/Log/Writer/Abstract.php'; /** * Writes log messages to syslog @@ -29,7 +29,7 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract @@ -95,18 +95,6 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract } $this->_initializeSyslog(); } - - /** - * Create a new instance of Zend_Log_Writer_Syslog - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Syslog - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - return new self(self::_parseConfig($config)); - } /** * Initialize syslog / set application name and facility diff --git a/libs/Zend/Log/Writer/ZendMonitor.php b/libs/Zend/Log/Writer/ZendMonitor.php deleted file mode 100644 index 59a648fa8b..0000000000 --- a/libs/Zend/Log/Writer/ZendMonitor.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Log - * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Log_Writer_Abstract */ -// require_once 'Zend/Log/Writer/Abstract.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage Writer - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ -class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract -{ - /** - * Is Zend Monitor enabled? - * @var bool - */ - protected $_isEnabled = true; - - /** - * @throws Zend_Log_Exception if Zend Monitor extension not present - */ - public function __construct() - { - if (!function_exists('monitor_custom_event')) { - $this->_isEnabled = false; - } - } - - /** - * Create a new instance of Zend_Log_Writer_ZendMonitor - * - * @param array|Zend_Config $config - * @return Zend_Log_Writer_Syslog - * @throws Zend_Log_Exception - */ - static public function factory($config) - { - return new self(); - } - - /** - * Is logging to this writer enabled? - * - * If the Zend Monitor extension is not enabled, this log writer will - * fail silently. You can query this method to determine if the log - * writer is enabled. - * - * @return bool - */ - public function isEnabled() - { - return $this->_isEnabled; - } - - /** - * Log a message to this writer. - * - * @param array $event log data event - * @return void - */ - public function write($event) - { - if (!$this->isEnabled()) { - return; - } - - parent::write($event); - } - - /** - * Write a message to the log. - * - * @param array $event log data event - * @return void - */ - protected function _write($event) - { - $priority = $event['priority']; - $message = $event['message']; - unset($event['priority'], $event['message']); - - if (!empty($event)) { - monitor_custom_event($priority, $message, $event); - } else { - monitor_custom_event($priority, $message); - } - } -} diff --git a/libs/Zend/Mail.php b/libs/Zend/Mail.php index 81d1b5051d..ca3641ea81 100644 --- a/libs/Zend/Mail.php +++ b/libs/Zend/Mail.php @@ -14,31 +14,31 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mail.php 20783 2010-01-31 08:06:30Z yoshida@zend.co.jp $ + * @version $Id: Mail.php 16207 2009-06-21 19:17:51Z thomas $ */ /** * @see Zend_Mail_Transport_Abstract */ -// require_once 'Zend/Mail/Transport/Abstract.php'; +require_once 'Zend/Mail/Transport/Abstract.php'; /** * @see Zend_Mime */ -// require_once 'Zend/Mime.php'; +require_once 'Zend/Mime.php'; /** * @see Zend_Mime_Message */ -// require_once 'Zend/Mime/Message.php'; +require_once 'Zend/Mime/Message.php'; /** * @see Zend_Mime_Part */ -// require_once 'Zend/Mime/Part.php'; +require_once 'Zend/Mime/Part.php'; /** @@ -46,7 +46,7 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail extends Zend_Mime_Message @@ -62,18 +62,6 @@ class Zend_Mail extends Zend_Mime_Message protected static $_defaultTransport = null; /** - * @var array - * @static - */ - protected static $_defaultFrom; - - /** - * @var array - * @static - */ - protected static $_defaultReplyTo; - - /** * Mail character set * @var string */ @@ -110,12 +98,6 @@ class Zend_Mail extends Zend_Mime_Message protected $_recipients = array(); /** - * Reply-To header - * @var string - */ - protected $_replyTo = null; - - /** * Return-Path header * @var string */ @@ -186,26 +168,6 @@ class Zend_Mail extends Zend_Mime_Message } /** - * Gets the default mail transport for all following uses of - * unittests - * - * @todo Allow passing a string to indicate the transport to load - * @todo Allow passing in optional options for the transport to load - */ - public static function getDefaultTransport() - { - return self::$_defaultTransport; - } - - /** - * Clear the default transport property - */ - public static function clearDefaultTransport() - { - self::$_defaultTransport = null; - } - - /** * Public constructor * * @param string $charset @@ -245,7 +207,7 @@ class Zend_Mail extends Zend_Mime_Message /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('Invalid content type "' . $type . '"'); } @@ -339,7 +301,7 @@ class Zend_Mail extends Zend_Mime_Message /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('Invalid encoding "' . $encoding . '"'); } $this->_headerEncoding = $encoding; @@ -496,7 +458,7 @@ class Zend_Mail extends Zend_Mime_Message */ protected function _encodeHeader($value) { - if (Zend_Mime::isPrintable($value) === false) { + if (Zend_Mime::isPrintable($value) === false) { if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) { $value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND); } else { @@ -560,62 +522,41 @@ class Zend_Mail extends Zend_Mime_Message } /** - * Adds To-header and recipient, $email can be an array, or a single string address + * Adds To-header and recipient * - * @param string|array $email + * @param string $email * @param string $name * @return Zend_Mail Provides fluent interface */ public function addTo($email, $name='') { - if (!is_array($email)) { - $email = array($name => $email); - } - - foreach ($email as $n => $recipient) { - $this->_addRecipientAndHeader('To', $recipient, is_int($n) ? '' : $n); - $this->_to[] = $recipient; - } - + $this->_addRecipientAndHeader('To', $email, $name); + $this->_to[] = $email; return $this; } /** - * Adds Cc-header and recipient, $email can be an array, or a single string address + * Adds Cc-header and recipient * - * @param string|array $email + * @param string $email * @param string $name * @return Zend_Mail Provides fluent interface */ public function addCc($email, $name='') { - if (!is_array($email)) { - $email = array($name => $email); - } - - foreach ($email as $n => $recipient) { - $this->_addRecipientAndHeader('Cc', $recipient, is_int($n) ? '' : $n); - } - + $this->_addRecipientAndHeader('Cc', $email, $name); return $this; } /** - * Adds Bcc recipient, $email can be an array, or a single string address + * Adds Bcc recipient * - * @param string|array $email + * @param string $email * @return Zend_Mail Provides fluent interface */ public function addBcc($email) { - if (!is_array($email)) { - $email = array($email); - } - - foreach ($email as $recipient) { - $this->_addRecipientAndHeader('Bcc', $recipient, ''); - } - + $this->_addRecipientAndHeader('Bcc', $email, ''); return $this; } @@ -656,19 +597,18 @@ class Zend_Mail extends Zend_Mime_Message */ public function setFrom($email, $name = null) { - if (null !== $this->_from) { + if ($this->_from === null) { + $email = $this->_filterEmail($email); + $name = $this->_filterName($name); + $this->_from = $email; + $this->_storeHeader('From', $this->_formatAddress($email, $name), true); + } else { /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('From Header set twice'); } - - $email = $this->_filterEmail($email); - $name = $this->_filterName($name); - $this->_from = $email; - $this->_storeHeader('From', $this->_formatAddress($email, $name), true); - return $this; } @@ -678,23 +618,10 @@ class Zend_Mail extends Zend_Mime_Message * @param string $email * @param string $name * @return Zend_Mail - * @throws Zend_Mail_Exception if called more than one time */ - public function setReplyTo($email, $name = null) + public function setReplyTo($email, $name=null) { - if (null !== $this->_replyTo) { - /** - * @see Zend_Mail_Exception - */ - // require_once 'Zend/Mail/Exception.php'; - throw new Zend_Mail_Exception('Reply-To Header set twice'); - } - - $email = $this->_filterEmail($email); - $name = $this->_filterName($name); - $this->_replyTo = $email; - $this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true); - + $this->_addRecipientAndHeader('Reply-To', $email, $name); return $this; } @@ -709,16 +636,6 @@ class Zend_Mail extends Zend_Mime_Message } /** - * Returns the current Reply-To address of the message - * - * @return string|null Reply-To address, null when not set - */ - public function getReplyTo() - { - return $this->_replyTo; - } - - /** * Clears the sender from the mail * * @return Zend_Mail Provides fluent interface @@ -731,119 +648,6 @@ class Zend_Mail extends Zend_Mime_Message return $this; } - /** - * Clears the current Reply-To address from the message - * - * @return Zend_Mail Provides fluent interface - */ - public function clearReplyTo() - { - $this->_replyTo = null; - $this->_clearHeader('Reply-To'); - - return $this; - } - - /** - * Sets Default From-email and name of the message - * - * @param string $email - * @param string Optional $name - * @return void - */ - public static function setDefaultFrom($email, $name = null) - { - self::$_defaultFrom = array('email' => $email, 'name' => $name); - } - - /** - * Returns the default sender of the mail - * - * @return null|array Null if none was set. - */ - public static function getDefaultFrom() - { - return self::$_defaultFrom; - } - - /** - * Clears the default sender from the mail - * - * @return void - */ - public static function clearDefaultFrom() - { - self::$_defaultFrom = null; - } - - /** - * Sets From-name and -email based on the defaults - * - * @return Zend_Mail Provides fluent interface - */ - public function setFromToDefaultFrom() { - $from = self::getDefaultFrom(); - if($from === null) { - // require_once 'Zend/Mail/Exception.php'; - throw new Zend_Mail_Exception( - 'No default From Address set to use'); - } - - $this->setFrom($from['email'], $from['name']); - - return $this; - } - - /** - * Sets Default ReplyTo-address and -name of the message - * - * @param string $email - * @param string Optional $name - * @return void - */ - public static function setDefaultReplyTo($email, $name = null) - { - self::$_defaultReplyTo = array('email' => $email, 'name' => $name); - } - - /** - * Returns the default Reply-To Address and Name of the mail - * - * @return null|array Null if none was set. - */ - public static function getDefaultReplyTo() - { - return self::$_defaultReplyTo; - } - - /** - * Clears the default ReplyTo-address and -name from the mail - * - * @return void - */ - public static function clearDefaultReplyTo() - { - self::$_defaultReplyTo = null; - } - - /** - * Sets ReplyTo-name and -email based on the defaults - * - * @return Zend_Mail Provides fluent interface - */ - public function setReplyToFromDefault() { - $replyTo = self::getDefaultReplyTo(); - if($replyTo === null) { - // require_once 'Zend/Mail/Exception.php'; - throw new Zend_Mail_Exception( - 'No default Reply-To Address set to use'); - } - - $this->setReplyTo($replyTo['email'], $replyTo['name']); - - return $this; - } - /** * Sets the Return-Path header of the message * @@ -861,7 +665,7 @@ class Zend_Mail extends Zend_Mime_Message /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('Return-Path Header set twice'); } return $this; @@ -913,7 +717,7 @@ class Zend_Mail extends Zend_Mime_Message /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('Subject set twice'); } return $this; @@ -945,9 +749,9 @@ class Zend_Mail extends Zend_Mime_Message /** * Sets Date-header * - * @param timestamp|string|Zend_Date $date + * @param string $date * @return Zend_Mail Provides fluent interface - * @throws Zend_Mail_Exception if called subsequent times or wrong date format. + * @throws Zend_Mail_Exception if called subsequent times */ public function setDate($date = null) { @@ -959,22 +763,22 @@ class Zend_Mail extends Zend_Mime_Message } else if (is_string($date)) { $date = strtotime($date); if ($date === false || $date < 0) { - /** - * @see Zend_Mail_Exception - */ - // require_once 'Zend/Mail/Exception.php'; - throw new Zend_Mail_Exception('String representations of Date Header must be ' . + /** + * @see Zend_Mail_Exception + */ + require_once 'Zend/Mail/Exception.php'; + throw new Zend_Mail_Exception('String representations of Date Header must be ' . 'strtotime()-compatible'); } $date = date('r', $date); } else if ($date instanceof Zend_Date) { $date = $date->get(Zend_Date::RFC_2822); } else { - /** - * @see Zend_Mail_Exception - */ - // require_once 'Zend/Mail/Exception.php'; - throw new Zend_Mail_Exception(__METHOD__ . ' only accepts UNIX timestamps, Zend_Date objects, ' . + /** + * @see Zend_Mail_Exception + */ + require_once 'Zend/Mail/Exception.php'; + throw new Zend_Mail_Exception(__METHOD__ . ' only accepts UNIX timestamps, Zend_Date objects, ' . ' and strtotime()-compatible strings'); } $this->_date = $date; @@ -983,8 +787,8 @@ class Zend_Mail extends Zend_Mime_Message /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; - throw new Zend_Mail_Exception('Date Header set twice'); + require_once 'Zend/Mail/Exception.php'; + throw new Zend_Mail_Exception('Date Header set twice'); } return $this; } @@ -1019,27 +823,27 @@ class Zend_Mail extends Zend_Mime_Message * true :Auto * false :No set * null :No set - * string:Sets given string (Angle brackets is not necessary) + * string:Sets string * @return Zend_Mail Provides fluent interface * @throws Zend_Mail_Exception */ public function setMessageId($id = true) { - if ($id === null || $id === false) { - return $this; - } elseif ($id === true) { + if ($id === null || $id === false) { + return $this; + } elseif ($id === true) { $id = $this->createMessageId(); - } + } if ($this->_messageId === null) { - $id = $this->_filterOther($id); + $id = $this->_filterOther($id); $this->_messageId = $id; - $this->_storeHeader('Message-Id', '<' . $this->_messageId . '>'); + $this->_storeHeader('Message-Id', $this->_messageId); } else { /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('Message-ID set twice'); } @@ -1080,25 +884,25 @@ class Zend_Mail extends Zend_Mime_Message $time = time(); if ($this->_from !== null) { - $user = $this->_from; + $user = $this->_from; } elseif (isset($_SERVER['REMOTE_ADDR'])) { - $user = $_SERVER['REMOTE_ADDR']; + $user = $_SERVER['REMOTE_ADDR']; } else { - $user = getmypid(); + $user = getmypid(); } - $rand = mt_rand(); + $rand = mt_rand(); - if ($this->_recipients !== array()) { + if ($this->_recipients !== array()) { $recipient = array_rand($this->_recipients); - } else { - $recipient = 'unknown'; - } + } else { + $recipient = 'unknown'; + } - if (isset($_SERVER["SERVER_NAME"])) { + if (isset($_SERVER["SERVER_NAME"])) { $hostName = $_SERVER["SERVER_NAME"]; } else { - $hostName = php_uname('n'); + $hostName = php_uname('n'); } return sha1($time . $user . $rand . $recipient) . '@' . $hostName; @@ -1116,14 +920,13 @@ class Zend_Mail extends Zend_Mime_Message public function addHeader($name, $value, $append = false) { $prohibit = array('to', 'cc', 'bcc', 'from', 'subject', - 'reply-to', 'return-path', - 'date', 'message-id', + 'return-path', 'date', 'message-id', ); if (in_array(strtolower($name), $prohibit)) { /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('Cannot set standard header from addHeader()'); } @@ -1156,7 +959,7 @@ class Zend_Mail extends Zend_Mime_Message { if ($transport === null) { if (! self::$_defaultTransport instanceof Zend_Mail_Transport_Abstract) { - // require_once 'Zend/Mail/Transport/Sendmail.php'; + require_once 'Zend/Mail/Transport/Sendmail.php'; $transport = new Zend_Mail_Transport_Sendmail(); } else { $transport = self::$_defaultTransport; @@ -1167,14 +970,6 @@ class Zend_Mail extends Zend_Mime_Message $this->setDate(); } - if(null === $this->_from && null !== self::getDefaultFrom()) { - $this->setFromToDefaultFrom(); - } - - if(null === $this->_replyTo && null !== self::getDefaultReplyTo()) { - $this->setReplyToFromDefault(); - } - $transport->send($this); return $this; @@ -1188,14 +983,14 @@ class Zend_Mail extends Zend_Mime_Message */ protected function _filterEmail($email) { - $rule = array("\r" => '', - "\n" => '', - "\t" => '', + $rule = array("\r" => '', + "\n" => '', + "\t" => '', '"' => '', - ',' => '', + ',' => '', '<' => '', '>' => '', - ); + ); return strtr($email, $rule); } @@ -1208,13 +1003,13 @@ class Zend_Mail extends Zend_Mime_Message */ protected function _filterName($name) { - $rule = array("\r" => '', + $rule = array("\r" => '', "\n" => '', "\t" => '', '"' => "'", '<' => '[', - '>' => ']', - ); + '>' => ']', + ); return trim(strtr($name, $rule)); } @@ -1248,8 +1043,7 @@ class Zend_Mail extends Zend_Mime_Message return $email; } else { $encodedName = $this->_encodeHeader($name); - if ($encodedName === $name && - ((strpos($name, '@') !== false) || (strpos($name, ',') !== false))) { + if ($encodedName === $name && strpos($name, ',') !== false) { $format = '"%s" <%s>'; } else { $format = '%s <%s>'; diff --git a/libs/Zend/Mail/Exception.php b/libs/Zend/Mail/Exception.php index c912769ee4..864d1ca932 100644 --- a/libs/Zend/Mail/Exception.php +++ b/libs/Zend/Mail/Exception.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Exception extends Zend_Exception diff --git a/libs/Zend/Mail/Message.php b/libs/Zend/Mail/Message.php index bff51340d2..5b35ab2f67 100644 --- a/libs/Zend/Mail/Message.php +++ b/libs/Zend/Mail/Message.php @@ -14,26 +14,26 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Message.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Message.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * Zend_Mail_Part */ -// require_once 'Zend/Mail/Part.php'; +require_once 'Zend/Mail/Part.php'; /** * Zend_Mail_Message_Interface */ -// require_once 'Zend/Mail/Message/Interface.php'; +require_once 'Zend/Mail/Message/Interface.php'; /** * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Message extends Zend_Mail_Part implements Zend_Mail_Message_Interface @@ -63,7 +63,7 @@ class Zend_Mail_Message extends Zend_Mail_Part implements Zend_Mail_Message_Inte /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('could not open file'); } } else { diff --git a/libs/Zend/Mail/Message/File.php b/libs/Zend/Mail/Message/File.php index 7857c743d6..6d621ae39c 100644 --- a/libs/Zend/Mail/Message/File.php +++ b/libs/Zend/Mail/Message/File.php @@ -14,26 +14,26 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: File.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: File.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * Zend_Mail_Part */ -// require_once 'Zend/Mail/Part/File.php'; +require_once 'Zend/Mail/Part/File.php'; /** * Zend_Mail_Message_Interface */ -// require_once 'Zend/Mail/Message/Interface.php'; +require_once 'Zend/Mail/Message/Interface.php'; /** * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Message_File extends Zend_Mail_Part_File implements Zend_Mail_Message_Interface @@ -59,7 +59,7 @@ class Zend_Mail_Message_File extends Zend_Mail_Part_File implements Zend_Mail_Me // set key and value to the same value for easy lookup $this->_flags = array_combine($params['flags'], $params['flags']); } - + parent::__construct($params); } diff --git a/libs/Zend/Mail/Message/Interface.php b/libs/Zend/Mail/Message/Interface.php index 833be6b44a..a9752a3230 100644 --- a/libs/Zend/Mail/Message/Interface.php +++ b/libs/Zend/Mail/Message/Interface.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/libs/Zend/Mail/Part.php b/libs/Zend/Mail/Part.php index bb7b38e447..4541a5acc1 100644 --- a/libs/Zend/Mail/Part.php +++ b/libs/Zend/Mail/Part.php @@ -14,27 +14,27 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Part.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Part.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mime_Decode */ -// require_once 'Zend/Mime/Decode.php'; +require_once 'Zend/Mime/Decode.php'; /** * @see Zend_Mail_Part_Interface */ -// require_once 'Zend/Mail/Part/Interface.php'; +require_once 'Zend/Mail/Part/Interface.php'; /** * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface @@ -108,14 +108,14 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('handler is not a valid mail handler'); } if (!isset($params['id'])) { /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('need a message id with a handler'); } @@ -176,7 +176,7 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('no content'); } } @@ -216,7 +216,7 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('no boundary found in content type to split message'); } $parts = Zend_Mime_Decode::splitMessageStruct($this->_content, $boundary); @@ -246,7 +246,7 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('part not found'); } @@ -261,7 +261,7 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('part not found'); } @@ -343,7 +343,7 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception("no Header with Name $name or $lowerName found"); } } @@ -381,7 +381,7 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface return false; } } - + /** * Get a specific field from a header like content type or all fields as array * diff --git a/libs/Zend/Mail/Part/File.php b/libs/Zend/Mail/Part/File.php index 581195bcc0..efa0538b4d 100644 --- a/libs/Zend/Mail/Part/File.php +++ b/libs/Zend/Mail/Part/File.php @@ -14,27 +14,27 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: File.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: File.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Mime_Decode */ -// require_once 'Zend/Mime/Decode.php'; +require_once 'Zend/Mime/Decode.php'; /** * @see Zend_Mail_Part */ -// require_once 'Zend/Mail/Part.php'; +require_once 'Zend/Mail/Part.php'; /** * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Part_File extends Zend_Mail_Part @@ -60,10 +60,10 @@ class Zend_Mail_Part_File extends Zend_Mail_Part /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('no file given in params'); } - + if (!is_resource($params['file'])) { $this->_fh = fopen($params['file'], 'r'); } else { @@ -73,7 +73,7 @@ class Zend_Mail_Part_File extends Zend_Mail_Part /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('could not open file'); } if (isset($params['startPos'])) { @@ -86,7 +86,7 @@ class Zend_Mail_Part_File extends Zend_Mail_Part } Zend_Mime_Decode::splitMessage($header, $this->_headers, $null); - + $this->_contentPos[0] = ftell($this->_fh); if ($endPos !== null) { $this->_contentPos[1] = $endPos; @@ -97,16 +97,16 @@ class Zend_Mail_Part_File extends Zend_Mail_Part if (!$this->isMultipart()) { return; } - + $boundary = $this->getHeaderField('content-type', 'boundary'); if (!$boundary) { /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('no boundary found in content type to split message'); } - + $part = array(); $pos = $this->_contentPos[0]; fseek($this->_fh, $pos); @@ -119,7 +119,7 @@ class Zend_Mail_Part_File extends Zend_Mail_Part /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('error reading file'); } @@ -141,7 +141,7 @@ class Zend_Mail_Part_File extends Zend_Mail_Part } } $this->_countParts = count($this->_partPos); - + } @@ -157,7 +157,7 @@ class Zend_Mail_Part_File extends Zend_Mail_Part { fseek($this->_fh, $this->_contentPos[0]); if ($stream !== null) { - return stream_copy_to_stream($this->_fh, $stream, $this->_contentPos[1] - $this->_contentPos[0]); + return stream_copy_to_stream($this->_fh, $stream, $this->_contentPos[1] - $this->_contentPos[0]); } $length = $this->_contentPos[1] - $this->_contentPos[0]; return $length < 1 ? '' : fread($this->_fh, $length); @@ -188,11 +188,11 @@ class Zend_Mail_Part_File extends Zend_Mail_Part /** * @see Zend_Mail_Exception */ - // require_once 'Zend/Mail/Exception.php'; + require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception('part not found'); } - return new self(array('file' => $this->_fh, 'startPos' => $this->_partPos[$num][0], + return new self(array('file' => $this->_fh, 'startPos' => $this->_partPos[$num][0], 'endPos' => $this->_partPos[$num][1])); } } diff --git a/libs/Zend/Mail/Part/Interface.php b/libs/Zend/Mail/Part/Interface.php index 2d8f6f8943..46cc4b0843 100644 --- a/libs/Zend/Mail/Part/Interface.php +++ b/libs/Zend/Mail/Part/Interface.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -95,7 +95,7 @@ interface Zend_Mail_Part_Interface extends RecursiveIterator * @throws Zend_Mail_Exception */ public function getHeader($name, $format = null); - + /** * Get a specific field from a header like content type or all fields as array * diff --git a/libs/Zend/Mail/Protocol/Abstract.php b/libs/Zend/Mail/Protocol/Abstract.php index cbfeaa8946..4ef5792b11 100644 --- a/libs/Zend/Mail/Protocol/Abstract.php +++ b/libs/Zend/Mail/Protocol/Abstract.php @@ -12,39 +12,39 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 21635 2010-03-24 15:25:13Z yoshida@zend.co.jp $ + * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Validate */ -// require_once 'Zend/Validate.php'; +require_once 'Zend/Validate.php'; /** * @see Zend_Validate_Hostname */ -// require_once 'Zend/Validate/Hostname.php'; +require_once 'Zend/Validate/Hostname.php'; /** * Zend_Mail_Protocol_Abstract * * Provides low-level methods for concrete adapters to communicate with a remote mail server and track requests and responses. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 21635 2010-03-24 15:25:13Z yoshida@zend.co.jp $ + * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $ * @todo Implement proxy settings */ abstract class Zend_Mail_Protocol_Abstract @@ -60,11 +60,6 @@ abstract class Zend_Mail_Protocol_Abstract */ const TIMEOUT_CONNECTION = 30; - /** - * Maximum of the transaction log - */ - const MAXIMUM_LOG = 64; - /** * Hostname or IP address of remote server @@ -111,16 +106,15 @@ abstract class Zend_Mail_Protocol_Abstract /** * String template for parsing server responses using sscanf (default: 3 digit code and response string) * @var resource - * @deprecated Since 1.10.3 */ protected $_template = '%d%s'; /** * Log of mail requests and server responses for a session - * @var array + * @var string */ - private $_log = array(); + private $_log; /** @@ -140,7 +134,7 @@ abstract class Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception(join(', ', $this->_validHost->getMessages())); } @@ -197,7 +191,7 @@ abstract class Zend_Mail_Protocol_Abstract */ public function getLog() { - return implode('', $this->_log); + return $this->_log; } @@ -208,23 +202,9 @@ abstract class Zend_Mail_Protocol_Abstract */ public function resetLog() { - $this->_log = array(); + $this->_log = ''; } - /** - * Add the transaction log - * - * @param string new transaction - * @return void - */ - protected function _addLog($value) - { - if (count($this->_log) >= self::MAXIMUM_LOG) { - array_shift($this->_log); - } - - $this->_log[] = $value; - } /** * Connect to the server using the supplied transport and target @@ -250,7 +230,7 @@ abstract class Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($errorStr); } @@ -258,7 +238,7 @@ abstract class Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Could not set stream timeout'); } @@ -292,7 +272,7 @@ abstract class Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host); } @@ -301,13 +281,13 @@ abstract class Zend_Mail_Protocol_Abstract $result = fwrite($this->_socket, $request . self::EOL); // Save request to internal log - $this->_addLog($request . self::EOL); + $this->_log .= $request . self::EOL; if ($result === false) { /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Could not send request to ' . $this->_host); } @@ -328,7 +308,7 @@ abstract class Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host); } @@ -341,7 +321,7 @@ abstract class Zend_Mail_Protocol_Abstract $reponse = fgets($this->_socket, 1024); // Save request to internal log - $this->_addLog($reponse); + $this->_log .= $reponse; // Check meta data to ensure connection is still valid $info = stream_get_meta_data($this->_socket); @@ -350,7 +330,7 @@ abstract class Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($this->_host . ' has timed out'); } @@ -358,7 +338,7 @@ abstract class Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Could not read from ' . $this->_host); } @@ -379,10 +359,8 @@ abstract class Zend_Mail_Protocol_Abstract protected function _expect($code, $timeout = null) { $this->_response = array(); - $cmd = ''; - $more = ''; - $msg = ''; - $errMsg = ''; + $cmd = ''; + $msg = ''; if (!is_array($code)) { $code = array($code); @@ -390,23 +368,17 @@ abstract class Zend_Mail_Protocol_Abstract do { $this->_response[] = $result = $this->_receive($timeout); - list($cmd, $more, $msg) = preg_split('/([\s-]+)/', $result, 2, PREG_SPLIT_DELIM_CAPTURE); - - if ($errMsg !== '') { - $errMsg .= ' ' . $msg; - } elseif ($cmd === null || !in_array($cmd, $code)) { - $errMsg = $msg; + sscanf($result, $this->_template, $cmd, $msg); + + if ($cmd === null || !in_array($cmd, $code)) { + /** + * @see Zend_Mail_Protocol_Exception + */ + require_once 'Zend/Mail/Protocol/Exception.php'; + throw new Zend_Mail_Protocol_Exception($result); } - } while (strpos($more, '-') === 0); // The '-' message prefix indicates an information string instead of a response string. - - if ($errMsg !== '') { - /** - * @see Zend_Mail_Protocol_Exception - */ - // require_once 'Zend/Mail/Protocol/Exception.php'; - throw new Zend_Mail_Protocol_Exception($errMsg); - } + } while (strpos($msg, '-') === 0); // The '-' message prefix indicates an information string instead of a response string. return $msg; } diff --git a/libs/Zend/Mail/Protocol/Exception.php b/libs/Zend/Mail/Protocol/Exception.php index 30999c2d14..117cafb56e 100644 --- a/libs/Zend/Mail/Protocol/Exception.php +++ b/libs/Zend/Mail/Protocol/Exception.php @@ -11,27 +11,27 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Mail/Exception.php'; +require_once 'Zend/Mail/Exception.php'; /** * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Protocol_Exception extends Zend_Mail_Exception diff --git a/libs/Zend/Mail/Protocol/Imap.php b/libs/Zend/Mail/Protocol/Imap.php index 286642fb48..2adc9efb14 100644 --- a/libs/Zend/Mail/Protocol/Imap.php +++ b/libs/Zend/Mail/Protocol/Imap.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Imap.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Imap.php 18499 2009-10-08 22:24:02Z yoshida@zend.co.jp $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Protocol_Imap @@ -50,7 +50,7 @@ class Zend_Mail_Protocol_Imap /** * Public constructor * - * @param string $host hostname or IP address of IMAP server, if given connect() is called + * @param string $host hostname of IP address of IMAP server, if given connect() is called * @param int|null $port port of IMAP server, null for default (143 or 993 for ssl) * @param bool $ssl use ssl? 'SSL', 'TLS' or false * @throws Zend_Mail_Protocol_Exception @@ -71,9 +71,9 @@ class Zend_Mail_Protocol_Imap } /** - * Open connection to IMAP server + * Open connection to POP3 server * - * @param string $host hostname or IP address of IMAP server + * @param string $host hostname of IP address of POP3 server * @param int|null $port of IMAP server, default is 143 (993 for ssl) * @param string|bool $ssl use 'SSL', 'TLS' or false * @return string welcome message @@ -96,16 +96,15 @@ class Zend_Mail_Protocol_Imap /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; - throw new Zend_Mail_Protocol_Exception('cannot connect to host; error = ' . $errstr . - ' (errno = ' . $errno . ' )'); + require_once 'Zend/Mail/Protocol/Exception.php'; + throw new Zend_Mail_Protocol_Exception('cannot connect to host : ' . $errno . ' : ' . $errstr); } if (!$this->_assumedNextLine('* OK')) { /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('host doesn\'t allow connection'); } @@ -116,7 +115,7 @@ class Zend_Mail_Protocol_Imap /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot enable TLS'); } } @@ -135,7 +134,7 @@ class Zend_Mail_Protocol_Imap /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot read - connection closed?'); } @@ -209,7 +208,7 @@ class Zend_Mail_Protocol_Imap $token = substr($token, 1); } if ($token[0] == '"') { - if (preg_match('%^\(*"((.|\\\\|\\")*?)" *%', $line, $matches)) { + if (preg_match('%^"((.|\\\\|\\")*?)" *%', $line, $matches)) { $tokens[] = $matches[1]; $line = substr($line, strlen($matches[0])); continue; @@ -348,14 +347,14 @@ class Zend_Mail_Protocol_Imap /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot write - connection closed?'); } if (!$this->_assumedNextLine('+ ')) { /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot send literal string'); } $line = $token[1]; @@ -368,7 +367,7 @@ class Zend_Mail_Protocol_Imap /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot write - connection closed?'); } } @@ -629,7 +628,7 @@ class Zend_Mail_Protocol_Imap /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('the single id was not found in response'); } diff --git a/libs/Zend/Mail/Protocol/Pop3.php b/libs/Zend/Mail/Protocol/Pop3.php index 78f01fe376..cc7d5b2f09 100644 --- a/libs/Zend/Mail/Protocol/Pop3.php +++ b/libs/Zend/Mail/Protocol/Pop3.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Pop3.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Pop3.php 16219 2009-06-21 19:45:39Z thomas $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Protocol_Pop3 @@ -34,7 +34,7 @@ class Zend_Mail_Protocol_Pop3 * Default timeout in seconds for initiating session */ const TIMEOUT_CONNECTION = 30; - + /** * saves if server supports top * @var null|bool @@ -57,7 +57,7 @@ class Zend_Mail_Protocol_Pop3 /** * Public constructor * - * @param string $host hostname or IP address of POP3 server, if given connect() is called + * @param string $host hostname of IP address of POP3 server, if given connect() is called * @param int|null $port port of POP3 server, null for default (110 or 995 for ssl) * @param bool|string $ssl use ssl? 'SSL', 'TLS' or false * @throws Zend_Mail_Protocol_Exception @@ -82,7 +82,7 @@ class Zend_Mail_Protocol_Pop3 /** * Open connection to POP3 server * - * @param string $host hostname or IP address of POP3 server + * @param string $host hostname of IP address of POP3 server * @param int|null $port of POP3 server, default is 110 (995 for ssl) * @param string|bool $ssl use 'SSL', 'TLS' or false * @return string welcome message @@ -105,9 +105,8 @@ class Zend_Mail_Protocol_Pop3 /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; - throw new Zend_Mail_Protocol_Exception('cannot connect to host; error = ' . $errstr . - ' (errno = ' . $errno . ' )'); + require_once 'Zend/Mail/Protocol/Exception.php'; + throw new Zend_Mail_Protocol_Exception('cannot connect to host : ' . $errno . ' : ' . $errstr); } $welcome = $this->readResponse(); @@ -127,7 +126,7 @@ class Zend_Mail_Protocol_Pop3 /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot enable TLS'); } } @@ -150,7 +149,7 @@ class Zend_Mail_Protocol_Pop3 /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('send failed - connection closed?'); } } @@ -170,7 +169,7 @@ class Zend_Mail_Protocol_Pop3 /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('read failed - connection closed?'); } @@ -186,7 +185,7 @@ class Zend_Mail_Protocol_Pop3 /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('last request failed'); } @@ -385,7 +384,7 @@ class Zend_Mail_Protocol_Pop3 /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('top not supported and no fallback wanted'); } } diff --git a/libs/Zend/Mail/Protocol/Smtp.php b/libs/Zend/Mail/Protocol/Smtp.php index a7d8153fa2..819b89551c 100644 --- a/libs/Zend/Mail/Protocol/Smtp.php +++ b/libs/Zend/Mail/Protocol/Smtp.php @@ -12,37 +12,37 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Smtp.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Smtp.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mime */ -// require_once 'Zend/Mime.php'; +require_once 'Zend/Mime.php'; /** * @see Zend_Mail_Protocol_Abstract */ -// require_once 'Zend/Mail/Protocol/Abstract.php'; +require_once 'Zend/Mail/Protocol/Abstract.php'; /** * Smtp implementation of Zend_Mail_Protocol_Abstract * * Minimum implementation according to RFC2821: EHLO, MAIL FROM, RCPT TO, DATA, RSET, NOOP, QUIT - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract @@ -140,7 +140,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($config['ssl'] . ' is unsupported SSL type'); break; } @@ -182,7 +182,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Cannot issue HELO to existing session'); } @@ -191,7 +191,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception(join(', ', $this->_validHost->getMessages())); } @@ -207,7 +207,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS'); } $this->_ehlo($host); @@ -253,7 +253,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('A valid session has not been started'); } @@ -280,7 +280,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No sender reverse path has been supplied'); } @@ -305,7 +305,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No recipient forward path has been supplied'); } @@ -403,7 +403,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract /** * @see Zend_Mail_Protocol_Exception */ - // require_once 'Zend/Mail/Protocol/Exception.php'; + require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Already authenticated for this session'); } } diff --git a/libs/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php b/libs/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php index 523d383e23..ec5594e067 100644 --- a/libs/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php +++ b/libs/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php @@ -11,20 +11,20 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Crammd5.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Crammd5.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Protocol_Smtp */ -// require_once 'Zend/Mail/Protocol/Smtp.php'; +require_once 'Zend/Mail/Protocol/Smtp.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Protocol_Smtp_Auth_Crammd5 extends Zend_Mail_Protocol_Smtp diff --git a/libs/Zend/Mail/Protocol/Smtp/Auth/Login.php b/libs/Zend/Mail/Protocol/Smtp/Auth/Login.php index 892f6724ec..a624792f4d 100644 --- a/libs/Zend/Mail/Protocol/Smtp/Auth/Login.php +++ b/libs/Zend/Mail/Protocol/Smtp/Auth/Login.php @@ -11,20 +11,20 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Login.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Login.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Protocol_Smtp */ -// require_once 'Zend/Mail/Protocol/Smtp.php'; +require_once 'Zend/Mail/Protocol/Smtp.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Protocol_Smtp_Auth_Login extends Zend_Mail_Protocol_Smtp diff --git a/libs/Zend/Mail/Protocol/Smtp/Auth/Plain.php b/libs/Zend/Mail/Protocol/Smtp/Auth/Plain.php index 02784cb9d3..26e65d3009 100644 --- a/libs/Zend/Mail/Protocol/Smtp/Auth/Plain.php +++ b/libs/Zend/Mail/Protocol/Smtp/Auth/Plain.php @@ -11,20 +11,20 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Plain.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Plain.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Protocol_Smtp */ -// require_once 'Zend/Mail/Protocol/Smtp.php'; +require_once 'Zend/Mail/Protocol/Smtp.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Mail * @subpackage Protocol - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Protocol_Smtp_Auth_Plain extends Zend_Mail_Protocol_Smtp diff --git a/libs/Zend/Mail/Storage.php b/libs/Zend/Mail/Storage.php index 771f7ae23b..4c1a321962 100644 --- a/libs/Zend/Mail/Storage.php +++ b/libs/Zend/Mail/Storage.php @@ -14,15 +14,15 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Storage.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Storage.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage diff --git a/libs/Zend/Mail/Storage/Abstract.php b/libs/Zend/Mail/Storage/Abstract.php index 0d5f1ed1e7..052654b706 100644 --- a/libs/Zend/Mail/Storage/Abstract.php +++ b/libs/Zend/Mail/Storage/Abstract.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Mail_Storage_Abstract implements Countable, ArrayAccess, SeekableIterator @@ -78,11 +78,11 @@ abstract class Zend_Mail_Storage_Abstract implements Countable, ArrayAccess, See $var = strtolower(substr($var, 3)); return isset($this->_has[$var]) ? $this->_has[$var] : null; } - + /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception($var . ' not found'); } @@ -264,7 +264,7 @@ abstract class Zend_Mail_Storage_Abstract implements Countable, ArrayAccess, See /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot write mail messages via array access'); } diff --git a/libs/Zend/Mail/Storage/Exception.php b/libs/Zend/Mail/Storage/Exception.php index 29cbc26981..497ab2c7ce 100644 --- a/libs/Zend/Mail/Storage/Exception.php +++ b/libs/Zend/Mail/Storage/Exception.php @@ -11,27 +11,27 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Exception */ -// require_once 'Zend/Mail/Exception.php'; +require_once 'Zend/Mail/Exception.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Exception extends Zend_Mail_Exception diff --git a/libs/Zend/Mail/Storage/Folder.php b/libs/Zend/Mail/Storage/Folder.php index 51d8a61a5d..1fc9641fdf 100644 --- a/libs/Zend/Mail/Storage/Folder.php +++ b/libs/Zend/Mail/Storage/Folder.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Folder.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Folder.php 16219 2009-06-21 19:45:39Z thomas $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Folder implements RecursiveIterator @@ -154,7 +154,7 @@ class Zend_Mail_Storage_Folder implements RecursiveIterator /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("no subfolder named $name"); } diff --git a/libs/Zend/Mail/Storage/Folder/Interface.php b/libs/Zend/Mail/Storage/Folder/Interface.php index b5c89ac917..683dc22e43 100644 --- a/libs/Zend/Mail/Storage/Folder/Interface.php +++ b/libs/Zend/Mail/Storage/Folder/Interface.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16219 2009-06-21 19:45:39Z thomas $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Mail_Storage_Folder_Interface diff --git a/libs/Zend/Mail/Storage/Folder/Maildir.php b/libs/Zend/Mail/Storage/Folder/Maildir.php index 228465a9e3..c2bf340c7d 100644 --- a/libs/Zend/Mail/Storage/Folder/Maildir.php +++ b/libs/Zend/Mail/Storage/Folder/Maildir.php @@ -11,37 +11,37 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Maildir.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Maildir.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Storage_Folder */ -// require_once 'Zend/Mail/Storage/Folder.php'; +require_once 'Zend/Mail/Storage/Folder.php'; /** * @see Zend_Mail_Storage_Folder_Interface */ -// require_once 'Zend/Mail/Storage/Folder/Interface.php'; +require_once 'Zend/Mail/Storage/Folder/Interface.php'; /** * @see Zend_Mail_Storage_Maildir */ -// require_once 'Zend/Mail/Storage/Maildir.php'; +require_once 'Zend/Mail/Storage/Maildir.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir implements Zend_Mail_Storage_Folder_Interface @@ -90,7 +90,7 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('no valid dirname given in params'); } @@ -123,7 +123,7 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("can't read folders in maildir"); } $dirs = array(); @@ -152,7 +152,7 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('error while reading maildir'); } array_push($stack, $parent); @@ -171,7 +171,7 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('error while reading maildir'); } } @@ -208,7 +208,7 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("folder $rootFolder not found"); } return $currentFolder; @@ -238,17 +238,17 @@ class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir impleme /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; - throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable", 0, $e); + require_once 'Zend/Mail/Storage/Exception.php'; + throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable"); } // seems like file has vanished; rebuilding folder tree - but it's still an exception $this->_buildFolderTree($this->_rootdir); /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('seems like the maildir has vanished, I\'ve rebuild the ' . - 'folder tree, search for an other folder and try again', 0, $e); + 'folder tree, search for an other folder and try again'); } } diff --git a/libs/Zend/Mail/Storage/Folder/Mbox.php b/libs/Zend/Mail/Storage/Folder/Mbox.php index fc1d50b2a0..e942322980 100644 --- a/libs/Zend/Mail/Storage/Folder/Mbox.php +++ b/libs/Zend/Mail/Storage/Folder/Mbox.php @@ -11,37 +11,37 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mbox.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mbox.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Storage_Folder */ -// require_once 'Zend/Mail/Storage/Folder.php'; +require_once 'Zend/Mail/Storage/Folder.php'; /** * @see Zend_Mail_Storage_Folder_Interface */ -// require_once 'Zend/Mail/Storage/Folder/Interface.php'; +require_once 'Zend/Mail/Storage/Folder/Interface.php'; /** * @see Zend_Mail_Storage_Mbox */ -// require_once 'Zend/Mail/Storage/Mbox.php'; +require_once 'Zend/Mail/Storage/Mbox.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Zend_Mail_Storage_Folder_Interface @@ -86,7 +86,7 @@ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Ze /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('use Zend_Mail_Storage_Mbox for a single file'); } @@ -94,7 +94,7 @@ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Ze /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('no valid dirname given in params'); } @@ -130,7 +130,7 @@ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Ze /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("can't read dir $currentDir"); } while (($entry = readdir($dh)) !== false) { @@ -182,7 +182,7 @@ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Ze /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("folder $rootFolder not found"); } return $currentFolder; @@ -212,17 +212,17 @@ class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Ze /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; - throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable", 0, $e); + require_once 'Zend/Mail/Storage/Exception.php'; + throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable"); } // seems like file has vanished; rebuilding folder tree - but it's still an exception $this->_buildFolderTree($this->_rootdir); /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('seems like the mbox file has vanished, I\'ve rebuild the ' . - 'folder tree, search for an other folder and try again', 0, $e); + 'folder tree, search for an other folder and try again'); } } diff --git a/libs/Zend/Mail/Storage/Imap.php b/libs/Zend/Mail/Storage/Imap.php index 2efc5b856b..2495e90782 100644 --- a/libs/Zend/Mail/Storage/Imap.php +++ b/libs/Zend/Mail/Storage/Imap.php @@ -11,56 +11,56 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Imap.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Imap.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Storage_Abstract */ -// require_once 'Zend/Mail/Storage/Abstract.php'; +require_once 'Zend/Mail/Storage/Abstract.php'; /** * @see Zend_Mail_Protocol_Imap */ -// require_once 'Zend/Mail/Protocol/Imap.php'; +require_once 'Zend/Mail/Protocol/Imap.php'; /** * @see Zend_Mail_Storage_Writable_Interface */ -// require_once 'Zend/Mail/Storage/Writable/Interface.php'; +require_once 'Zend/Mail/Storage/Writable/Interface.php'; /** * @see Zend_Mail_Storage_Folder_Interface */ -// require_once 'Zend/Mail/Storage/Folder/Interface.php'; +require_once 'Zend/Mail/Storage/Folder/Interface.php'; /** * @see Zend_Mail_Storage_Folder */ -// require_once 'Zend/Mail/Storage/Folder.php'; +require_once 'Zend/Mail/Storage/Folder.php'; /** * @see Zend_Mail_Message */ -// require_once 'Zend/Mail/Message.php'; +require_once 'Zend/Mail/Message.php'; /** * @see Zend_Mail_Storage */ -// require_once 'Zend/Mail/Storage.php'; +require_once 'Zend/Mail/Storage.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract @@ -116,14 +116,14 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('No selected folder to count'); } if ($flags === null) { return count($this->_protocol->search(array('ALL'))); } - + $params = array(); foreach ((array)$flags as $flag) { if (isset(self::$_searchFlags[$flag])) { @@ -189,7 +189,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } @@ -213,7 +213,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } @@ -250,8 +250,8 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; - throw new Zend_Mail_Storage_Exception('cannot select INBOX, is this a valid transport?', 0, $e); + require_once 'Zend/Mail/Storage/Exception.php'; + throw new Zend_Mail_Storage_Exception('cannot select INBOX, is this a valid transport?'); } return; } @@ -260,7 +260,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('need at least user in params'); } @@ -275,7 +275,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot login, user or password wrong'); } $this->selectFolder(isset($params->folder) ? $params->folder : 'INBOX'); @@ -305,7 +305,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('could not do nothing'); } } @@ -325,7 +325,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot set deleted flag'); } // TODO: expunge here or at close? we can handle an error here better and are more fail safe @@ -333,7 +333,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('message marked as deleted, but could not expunge'); } } @@ -379,7 +379,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('unique id not found'); } @@ -399,7 +399,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('folder not found'); } @@ -437,7 +437,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('error while constructing folder tree'); } } @@ -463,7 +463,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot change folder, maybe it does not exist'); } } @@ -506,7 +506,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot create folder'); } } @@ -528,7 +528,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot delete folder'); } } @@ -553,7 +553,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot rename folder'); } } @@ -582,7 +582,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot create message, please check if the folder exists and your flags'); } } @@ -601,7 +601,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot copy message, does the folder exist?'); } } @@ -636,7 +636,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot set flags, have you tried to set the recent flag or special chars?'); } } diff --git a/libs/Zend/Mail/Storage/Maildir.php b/libs/Zend/Mail/Storage/Maildir.php index 736b70cc66..3954db4a1c 100644 --- a/libs/Zend/Mail/Storage/Maildir.php +++ b/libs/Zend/Mail/Storage/Maildir.php @@ -11,37 +11,37 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Maildir.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Maildir.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Storage_Abstract */ -// require_once 'Zend/Mail/Storage/Abstract.php'; +require_once 'Zend/Mail/Storage/Abstract.php'; /** * @see Zend_Mail_Message_File */ -// require_once 'Zend/Mail/Message/File.php'; +require_once 'Zend/Mail/Message/File.php'; /** * @see Zend_Mail_Storage */ -// require_once 'Zend/Mail/Storage.php'; +require_once 'Zend/Mail/Storage.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract @@ -71,7 +71,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract 'R' => Zend_Mail_Storage::FLAG_ANSWERED, 'S' => Zend_Mail_Storage::FLAG_SEEN, 'T' => Zend_Mail_Storage::FLAG_DELETED); - + // TODO: getFlags($id) for fast access if headers are not needed (i.e. just setting flags)? /** @@ -86,7 +86,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract return count($this->_files); } - $count = 0; + $count = 0; if (!is_array($flags)) { foreach ($this->_files as $file) { if (isset($file['flaglookup'][$flags])) { @@ -95,7 +95,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract } return $count; } - + $flags = array_flip($flags); foreach ($this->_files as $file) { foreach ($flags as $flag => $v) { @@ -122,7 +122,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('id does not exist'); } @@ -134,7 +134,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('field does not exist'); } @@ -179,7 +179,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract return new $this->_messageClass(array('file' => $this->_getFileData($id, 'filename'), 'flags' => $this->_getFileData($id, 'flags'))); } - + return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $this->getRawHeader($id), 'flags' => $this->_getFileData($id, 'flags'))); } @@ -200,7 +200,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } @@ -234,7 +234,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } @@ -270,7 +270,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('no valid dirname given in params'); } @@ -278,7 +278,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('invalid maildir given'); } @@ -322,7 +322,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot open maildir'); } $this->_getMaildirFiles($dh, $dirname . '/cur/'); @@ -336,7 +336,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot read recent mails in maildir'); } } @@ -422,7 +422,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('maildir is (currently) read-only'); } @@ -469,7 +469,7 @@ class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('unique id not found'); } } diff --git a/libs/Zend/Mail/Storage/Mbox.php b/libs/Zend/Mail/Storage/Mbox.php index 97bc56e394..8fad784c5d 100644 --- a/libs/Zend/Mail/Storage/Mbox.php +++ b/libs/Zend/Mail/Storage/Mbox.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mbox.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mbox.php 16219 2009-06-21 19:45:39Z thomas $ */ @@ -25,24 +25,24 @@ * @see Zend_Loader * May be used in constructor, but commented out for now */ -// // require_once 'Zend/Loader.php'; +// require_once 'Zend/Loader.php'; /** * @see Zend_Mail_Storage_Abstract */ -// require_once 'Zend/Mail/Storage/Abstract.php'; +require_once 'Zend/Mail/Storage/Abstract.php'; /** * @see Zend_Mail_Message_File */ -// require_once 'Zend/Mail/Message/File.php'; +require_once 'Zend/Mail/Message/File.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract @@ -124,7 +124,7 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('id does not exist'); } @@ -180,7 +180,7 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } $messagePos = $this->_getPos($id); @@ -204,7 +204,7 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } $messagePos = $this->_getPos($id); @@ -224,12 +224,12 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract if (is_array($params)) { $params = (object)$params; } - + if (!isset($params->filename) /* || Zend_Loader::isReadable($params['filename']) */) { /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('no valid filename given in params'); } @@ -290,7 +290,7 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot open mbox file'); } $this->_filename = $filename; @@ -301,7 +301,7 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('file is not a valid mbox format'); } @@ -362,7 +362,7 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('mbox is read-only'); } @@ -438,7 +438,7 @@ class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot open mbox file'); } } diff --git a/libs/Zend/Mail/Storage/Pop3.php b/libs/Zend/Mail/Storage/Pop3.php index 0841c3c352..b3ea092032 100644 --- a/libs/Zend/Mail/Storage/Pop3.php +++ b/libs/Zend/Mail/Storage/Pop3.php @@ -11,37 +11,37 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Pop3.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Pop3.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Storage_Abstract */ -// require_once 'Zend/Mail/Storage/Abstract.php'; +require_once 'Zend/Mail/Storage/Abstract.php'; /** * @see Zend_Mail_Protocol_Pop3 */ -// require_once 'Zend/Mail/Protocol/Pop3.php'; +require_once 'Zend/Mail/Protocol/Pop3.php'; /** * @see Zend_Mail_Message */ -// require_once 'Zend/Mail/Message.php'; +require_once 'Zend/Mail/Message.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Pop3 extends Zend_Mail_Storage_Abstract @@ -112,7 +112,7 @@ class Zend_Mail_Storage_Pop3 extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } @@ -135,7 +135,7 @@ class Zend_Mail_Storage_Pop3 extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('not implemented'); } @@ -177,7 +177,7 @@ class Zend_Mail_Storage_Pop3 extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('need at least user in params'); } @@ -244,7 +244,7 @@ class Zend_Mail_Storage_Pop3 extends Zend_Mail_Storage_Abstract } $count = $this->countMessages(); if ($count < 1) { - return array(); + return array(); } $range = range(1, $count); return array_combine($range, $range); @@ -279,7 +279,7 @@ class Zend_Mail_Storage_Pop3 extends Zend_Mail_Storage_Abstract /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('unique id not found'); } diff --git a/libs/Zend/Mail/Storage/Writable/Interface.php b/libs/Zend/Mail/Storage/Writable/Interface.php index 982b44eeb9..fd73380df7 100644 --- a/libs/Zend/Mail/Storage/Writable/Interface.php +++ b/libs/Zend/Mail/Storage/Writable/Interface.php @@ -11,13 +11,13 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16219 2009-06-21 19:45:39Z thomas $ */ @@ -25,7 +25,7 @@ * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/libs/Zend/Mail/Storage/Writable/Maildir.php b/libs/Zend/Mail/Storage/Writable/Maildir.php index 3519a4b411..303b86066d 100644 --- a/libs/Zend/Mail/Storage/Writable/Maildir.php +++ b/libs/Zend/Mail/Storage/Writable/Maildir.php @@ -11,32 +11,32 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Maildir.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Maildir.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Storage_Folder_Maildir */ -// require_once 'Zend/Mail/Storage/Folder/Maildir.php'; +require_once 'Zend/Mail/Storage/Folder/Maildir.php'; /** * @see Zend_Mail_Storage_Writable_Interface */ -// require_once 'Zend/Mail/Storage/Writable/Interface.php'; +require_once 'Zend/Mail/Storage/Writable/Interface.php'; /** * @category Zend * @package Zend_Mail * @subpackage Storage - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Maildir @@ -49,7 +49,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai * @var bool|int */ protected $_quota; - + /** * create a new maildir * @@ -66,7 +66,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('maildir must be a directory if already exists'); } } else { @@ -74,7 +74,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; $dir = dirname($dir); if (!file_exists($dir)) { throw new Zend_Mail_Storage_Exception("parent $dir not found"); @@ -85,7 +85,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai } } } - + foreach (array('cur', 'tmp', 'new') as $subdir) { if (!@mkdir($dir . DIRECTORY_SEPARATOR . $subdir)) { // ignore if dir exists (i.e. was already valid maildir or two processes try to create one) @@ -93,13 +93,13 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('could not create subdir ' . $subdir); } } } } - + /** * Create instance with parameters * Additional parameters are (see parent for more): @@ -112,11 +112,11 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai if (is_array($params)) { $params = (object)$params; } - + if (!empty($params->create) && isset($params->dirname) && !file_exists($params->dirname . DIRECTORY_SEPARATOR . 'cur')) { self::initMaildir($params->dirname); } - + parent::__construct($params); } @@ -154,7 +154,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('folder already exists'); } @@ -162,7 +162,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('invalid name - folder parts may not be empty'); } @@ -178,7 +178,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('invalid name - no directory seprator allowed in folder name'); } @@ -199,7 +199,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('error while creating new folder, may be created incompletly'); } @@ -241,7 +241,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('delete children first'); } @@ -249,7 +249,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('wont delete INBOX'); } @@ -257,7 +257,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('wont delete selected folder'); } @@ -271,7 +271,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("error opening $subdir"); } while (($entry = readdir($dh)) !== false) { @@ -282,7 +282,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("error cleaning $subdir"); } } @@ -292,7 +292,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("error removing $subdir"); } } @@ -304,7 +304,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("error removing maindir"); } @@ -345,7 +345,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('new folder cannot be a child of old folder'); } @@ -356,7 +356,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('wont rename INBOX'); } @@ -364,7 +364,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('wont rename selected folder'); } @@ -387,7 +387,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('error while moving ' . $subdir); } } @@ -442,7 +442,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('problems creating tmp dir'); } } @@ -464,7 +464,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('could not open temp file'); } break; @@ -476,7 +476,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("tried $max_tries unique ids for a temp file, but all were taken" . ' - giving up'); } @@ -500,7 +500,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('recent flag may not be set'); } @@ -520,7 +520,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('unknown flag(s): ' . $wanted_flags); } @@ -545,8 +545,8 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; - throw new Zend_Mail_Storage_Exception('storage is over quota!'); + require_once 'Zend/Mail/Storage/Exception.php'; + throw new Zend_Mail_Storage_Exception('storage is over quota!'); } if ($folder === null) { @@ -587,7 +587,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot link message file to final dir'); } @unlink($temp_file['filename']); @@ -618,10 +618,10 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; - throw new Zend_Mail_Storage_Exception('storage is over quota!'); + require_once 'Zend/Mail/Storage/Exception.php'; + throw new Zend_Mail_Storage_Exception('storage is over quota!'); } - + if (!($folder instanceof Zend_Mail_Storage_Folder)) { $folder = $this->getFolders($folder); } @@ -656,13 +656,13 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot copy message file'); } else if (!link($temp_file['filename'], $new_file)) { /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot link message file to final dir'); } @unlink($temp_file['filename']); @@ -677,7 +677,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai 'flags' => $flags, 'filename' => $new_file); } - + if ($this->_quota) { $this->_addQuotaEntry((int)$size, 1); } @@ -695,16 +695,16 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai if (!($folder instanceof Zend_Mail_Storage_Folder)) { $folder = $this->getFolders($folder); } - + if ($folder->getGlobalName() == $this->_currentFolder || ($this->_currentFolder == 'INBOX' && $folder->getGlobalName() == '/')) { /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('target is current folder'); } - + $filedata = $this->_getFileData($id); $old_file = $filedata['filename']; $flags = $filedata['flags']; @@ -734,7 +734,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot move message file'); } @unlink($temp_file['filename']); @@ -770,7 +770,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot rename file'); } @@ -790,16 +790,16 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai public function removeMessage($id) { $filename = $this->_getFileData($id, 'filename'); - + if ($this->_quota) { $size = filesize($filename); } - + if (!@unlink($filename)) { /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot remove message'); } unset($this->_files[$id - 1]); @@ -809,7 +809,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai $this->_addQuotaEntry(0 - (int)$size, -1); } } - + /** * enable/disable quota and set a quota value if wanted or needed * @@ -824,7 +824,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai public function setQuota($value) { $this->_quota = $value; } - + /** * get currently set quota * @@ -839,7 +839,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai /** * @see Zend_Mail_Storage_Exception */ - // require_once 'Zend/Mail/Storage/Exception.php'; + require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot open maildirsize'); } $definition = fgets($fh); @@ -855,10 +855,10 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai } return $quota; } - + return $this->_quota; } - + /** * @see http://www.inter7.com/courierimap/README.maildirquota.html "Calculating maildirsize" */ @@ -873,10 +873,10 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai try { $quota = $this->getQuota(true); } catch (Zend_Mail_Storage_Exception $e) { - throw new Zend_Mail_Storage_Exception('no quota definition found', 0, $e); + throw new Zend_Mail_Storage_Exception('no quota defintion found'); } } - + $folders = new RecursiveIteratorIterator($this->getFolders(), RecursiveIteratorIterator::SELF_FIRST); foreach ($folders as $folder) { $subdir = $folder->getGlobalName(); @@ -888,29 +888,29 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai if ($subdir == 'Trash') { continue; } - + foreach (array('cur', 'new') as $subsubdir) { $dirname = $this->_rootdir . $subdir . DIRECTORY_SEPARATOR . $subsubdir . DIRECTORY_SEPARATOR; if (!file_exists($dirname)) { continue; } // NOTE: we are using mtime instead of "the latest timestamp". The latest would be atime - // and as we are accessing the directory it would make the whole calculation useless. + // and as we are accessing the directory it would make the whole calculation useless. $timestamps[$dirname] = filemtime($dirname); $dh = opendir($dirname); - // NOTE: Should have been checked in constructor. Not throwing an exception here, quotas will + // NOTE: Should have been checked in constructor. Not throwing an exception here, quotas will // therefore not be fully enforeced, but next request will fail anyway, if problem persists. if (!$dh) { continue; } - - + + while (($entry = readdir()) !== false) { if ($entry[0] == '.' || !is_file($dirname . $entry)) { continue; } - + if (strpos($entry, ',S=')) { strtok($entry, '='); $filesize = strtok(':'); @@ -930,7 +930,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai } } } - + $tmp = $this->_createTmpFile(); $fh = $tmp['handle']; $definition = array(); @@ -951,10 +951,10 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai break; } } - + return array('size' => $total_size, 'count' => $messages, 'quota' => $quota); } - + /** * @see http://www.inter7.com/courierimap/README.maildirquota.html "Calculating the quota for a Maildir++" */ @@ -1001,9 +1001,9 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai $messages += $count; } } - + $over_quota = false; - $over_quota = $over_quota || (isset($quota['size']) && $total_size > $quota['size']); + $over_quota = $over_quota || (isset($quota['size']) && $total_size > $quota['size']); $over_quota = $over_quota || (isset($quota['count']) && $messages > $quota['count']); // NOTE: $maildirsize equals false if it wasn't set (AKA we recalculated) or it's only // one line, because $maildirsize[0] gets unsetted. @@ -1015,18 +1015,18 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai $messages = $result['count']; $quota = $result['quota']; $over_quota = false; - $over_quota = $over_quota || (isset($quota['size']) && $total_size > $quota['size']); + $over_quota = $over_quota || (isset($quota['size']) && $total_size > $quota['size']); $over_quota = $over_quota || (isset($quota['count']) && $messages > $quota['count']); } - + if ($fh) { // TODO is there a safe way to keep the handle open for writing? fclose($fh); } - + return array('size' => $total_size, 'count' => $messages, 'quota' => $quota, 'over_quota' => $over_quota); } - + protected function _addQuotaEntry($size, $count = 1) { if (!file_exists($this->_rootdir . 'maildirsize')) { // TODO: should get file handler from _calculateQuota @@ -1035,7 +1035,7 @@ class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Mai $count = (int)$count; file_put_contents($this->_rootdir . 'maildirsize', "$size $count\n", FILE_APPEND); } - + /** * check if storage is currently over quota * diff --git a/libs/Zend/Mail/Transport/Abstract.php b/libs/Zend/Mail/Transport/Abstract.php index 74d6ab005f..5ef4b7019c 100644 --- a/libs/Zend/Mail/Transport/Abstract.php +++ b/libs/Zend/Mail/Transport/Abstract.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 17334 2009-08-01 01:25:22Z yoshida@zend.co.jp $ */ /** * @see Zend_Mime */ -// require_once 'Zend/Mime.php'; +require_once 'Zend/Mime.php'; /** @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Mail_Transport_Abstract @@ -140,7 +140,7 @@ abstract class Zend_Mail_Transport_Abstract } $this->_headers['Content-Type'] = array( - $type . ';' + $type . '; charset=' . $this->_mail->getCharset() . ';' . $this->EOL . " " . 'boundary="' . $boundary . '"' ); @@ -184,7 +184,7 @@ abstract class Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('Missing Zend_Mail object in _mail property'); } @@ -213,7 +213,7 @@ abstract class Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Exception('At least one mail header line is too long'); } } @@ -280,7 +280,7 @@ abstract class Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('No body specified'); } @@ -319,7 +319,7 @@ abstract class Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('Empty mail cannot be sent'); } diff --git a/libs/Zend/Mail/Transport/Exception.php b/libs/Zend/Mail/Transport/Exception.php index cf4165a886..9947f45a79 100644 --- a/libs/Zend/Mail/Transport/Exception.php +++ b/libs/Zend/Mail/Transport/Exception.php @@ -11,27 +11,27 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mail_Exception */ -// require_once 'Zend/Mail/Exception.php'; +require_once 'Zend/Mail/Exception.php'; /** * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Transport_Exception extends Zend_Mail_Exception diff --git a/libs/Zend/Mail/Transport/Sendmail.php b/libs/Zend/Mail/Transport/Sendmail.php index c12eb46a23..cef1e2091f 100644 --- a/libs/Zend/Mail/Transport/Sendmail.php +++ b/libs/Zend/Mail/Transport/Sendmail.php @@ -11,20 +11,20 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sendmail.php 21605 2010-03-22 15:09:03Z yoshida@zend.co.jp $ + * @version $Id: Sendmail.php 18264 2009-09-18 18:25:38Z beberlei $ */ /** * @see Zend_Mail_Transport_Abstract */ -// require_once 'Zend/Mail/Transport/Abstract.php'; +require_once 'Zend/Mail/Transport/Abstract.php'; /** @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract @@ -53,6 +53,7 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract */ public $parameters; + /** * EOL character string * @var string @@ -60,28 +61,15 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract */ public $EOL = PHP_EOL; - /** - * error information - * @var string - */ - protected $_errstr; /** * Constructor. * - * @param string|array|Zend_Config $parameters OPTIONAL (Default: null) + * @param string $parameters OPTIONAL (Default: null) * @return void */ public function __construct($parameters = null) { - if ($parameters instanceof Zend_Config) { - $parameters = $parameters->toArray(); - } - - if (is_array($parameters)) { - $parameters = implode(' ', $parameters); - } - $this->parameters = $parameters; } @@ -91,50 +79,30 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract * * @access public * @return void - * @throws Zend_Mail_Transport_Exception if parameters is set - * but not a string * @throws Zend_Mail_Transport_Exception on mail() failure */ public function _sendMail() { if ($this->parameters === null) { - set_error_handler(array($this, '_handleMailErrors')); $result = mail( $this->recipients, $this->_mail->getSubject(), $this->body, $this->header); - restore_error_handler(); } else { - if(!is_string($this->parameters)) { - /** - * @see Zend_Mail_Transport_Exception - * - * Exception is thrown here because - * $parameters is a public property - */ - // require_once 'Zend/Mail/Transport/Exception.php'; - throw new Zend_Mail_Transport_Exception( - 'Parameters were set but are not a string' - ); - } - - set_error_handler(array($this, '_handleMailErrors')); $result = mail( $this->recipients, $this->_mail->getSubject(), $this->body, $this->header, $this->parameters); - restore_error_handler(); } - - if ($this->_errstr !== null || !$result) { + if (!$result) { /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; - throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr); + require_once 'Zend/Mail/Transport/Exception.php'; + throw new Zend_Mail_Transport_Exception('Unable to send mail'); } } @@ -157,7 +125,7 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('_prepareHeaders requires a registered Zend_Mail object'); } @@ -169,7 +137,7 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('Missing To addresses'); } } else { @@ -178,7 +146,7 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('Missing To header'); } @@ -201,20 +169,5 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract $this->header = rtrim($this->header); } - /** - * Temporary error handler for PHP native mail(). - * - * @param int $errno - * @param string $errstr - * @param string $errfile - * @param string $errline - * @param array $errcontext - * @return true - */ - public function _handleMailErrors($errno, $errstr, $errfile = null, $errline = null, array $errcontext = null) - { - $this->_errstr = $errstr; - return true; - } - } + diff --git a/libs/Zend/Mail/Transport/Smtp.php b/libs/Zend/Mail/Transport/Smtp.php index 288cb4644f..0c1f7cb0b9 100644 --- a/libs/Zend/Mail/Transport/Smtp.php +++ b/libs/Zend/Mail/Transport/Smtp.php @@ -11,30 +11,30 @@ * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. - * + * * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Smtp.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Smtp.php 16219 2009-06-21 19:45:39Z thomas $ */ /** * @see Zend_Mime */ -// require_once 'Zend/Mime.php'; +require_once 'Zend/Mime.php'; /** * @see Zend_Mail_Protocol_Smtp */ -// require_once 'Zend/Mail/Protocol/Smtp.php'; +require_once 'Zend/Mail/Protocol/Smtp.php'; /** * @see Zend_Mail_Transport_Abstract */ -// require_once 'Zend/Mail/Transport/Abstract.php'; +require_once 'Zend/Mail/Transport/Abstract.php'; /** @@ -45,7 +45,7 @@ * @category Zend * @package Zend_Mail * @subpackage Transport - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract @@ -111,9 +111,6 @@ class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract * @param string $host OPTIONAL (Default: 127.0.0.1) * @param array|null $config OPTIONAL (Default: null) * @return void - * - * @todo Someone please make this compatible - * with the SendMail transport class. */ public function __construct($host = '127.0.0.1', Array $config = array()) { @@ -180,7 +177,6 @@ class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract * developer to add a custom adapter if required before mail is sent. * * @return void - * @todo Rename this to sendMail, it's a public method... */ public function _sendMail() { @@ -191,10 +187,10 @@ class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract if ($this->_auth) { $connectionClass .= '_Auth_' . ucwords($this->_auth); } - // if (!class_exists($connectionClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($connectionClass); - // } + if (!class_exists($connectionClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($connectionClass); + } $this->setConnection(new $connectionClass($this->_host, $this->_port, $this->_config)); $this->_connection->connect(); $this->_connection->helo($this->_name); @@ -203,8 +199,8 @@ class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract $this->_connection->rset(); } - // Set sender email address - $this->_connection->mail($this->_mail->getFrom()); + // Set mail return path from sender email address + $this->_connection->mail($this->_mail->getReturnPath()); // Set recipient forward paths foreach ($this->_mail->getRecipients() as $recipient) { @@ -231,7 +227,7 @@ class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract /** * @see Zend_Mail_Transport_Exception */ - // require_once 'Zend/Mail/Transport/Exception.php'; + require_once 'Zend/Mail/Transport/Exception.php'; throw new Zend_Mail_Transport_Exception('_prepareHeaders requires a registered Zend_Mail object'); } diff --git a/libs/Zend/Mime.php b/libs/Zend/Mime.php index aa3582efe9..921cc1f16f 100644 --- a/libs/Zend/Mime.php +++ b/libs/Zend/Mime.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mime.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Mime.php 16541 2009-07-07 06:59:03Z bkarwin $ */ @@ -25,7 +25,7 @@ * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mime diff --git a/libs/Zend/Mime/Decode.php b/libs/Zend/Mime/Decode.php index b996a4a028..c50b495cfd 100644 --- a/libs/Zend/Mime/Decode.php +++ b/libs/Zend/Mime/Decode.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Decode.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Decode.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * @see Zend_Mime */ -// require_once 'Zend/Mime.php'; +require_once 'Zend/Mime.php'; /** * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mime_Decode diff --git a/libs/Zend/Mime/Exception.php b/libs/Zend/Mime/Exception.php index cb76e79c50..4d2811f048 100644 --- a/libs/Zend/Mime/Exception.php +++ b/libs/Zend/Mime/Exception.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mime_Exception extends Zend_Exception diff --git a/libs/Zend/Mime/Message.php b/libs/Zend/Mime/Message.php index 781ac99246..537107d2c7 100644 --- a/libs/Zend/Mime/Message.php +++ b/libs/Zend/Mime/Message.php @@ -14,27 +14,27 @@ * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Message.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Message.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Mime */ -// require_once 'Zend/Mime.php'; +require_once 'Zend/Mime.php'; /** * Zend_Mime_Part */ -// require_once 'Zend/Mime/Part.php'; +require_once 'Zend/Mime/Part.php'; /** * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mime_Message @@ -242,7 +242,7 @@ class Zend_Mime_Message */ public static function createFromMessage($message, $boundary, $EOL = Zend_Mime::LINEEND) { - // require_once 'Zend/Mime/Decode.php'; + require_once 'Zend/Mime/Decode.php'; $parts = Zend_Mime_Decode::splitMessageStruct($message, $boundary, $EOL); $res = new self(); diff --git a/libs/Zend/Mime/Part.php b/libs/Zend/Mime/Part.php index 96e20d09a3..6609b51a76 100644 --- a/libs/Zend/Mime/Part.php +++ b/libs/Zend/Mime/Part.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Part.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Part.php 16541 2009-07-07 06:59:03Z bkarwin $ */ /** * Zend_Mime */ -// require_once 'Zend/Mime.php'; +require_once 'Zend/Mime.php'; /** * Class representing a MIME part. * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mime_Part { @@ -92,7 +92,7 @@ class Zend_Mime_Part { public function getEncodedStream() { if (!$this->_isStream) { - // require_once 'Zend/Mime/Exception.php'; + require_once 'Zend/Mime/Exception.php'; throw new Zend_Mime_Exception('Attempt to get a stream from a string part'); } @@ -109,7 +109,7 @@ class Zend_Mime_Part { ) ); if (!is_resource($filter)) { - // require_once 'Zend/Mime/Exception.php'; + require_once 'Zend/Mime/Exception.php'; throw new Zend_Mime_Exception('Failed to append quoted-printable filter'); } break; @@ -124,7 +124,7 @@ class Zend_Mime_Part { ) ); if (!is_resource($filter)) { - // require_once 'Zend/Mime/Exception.php'; + require_once 'Zend/Mime/Exception.php'; throw new Zend_Mime_Exception('Failed to append base64 filter'); } break; diff --git a/libs/Zend/Registry.php b/libs/Zend/Registry.php index 845ef66bba..d801d1220b 100644 --- a/libs/Zend/Registry.php +++ b/libs/Zend/Registry.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Registry - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Registry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Registry.php 16207 2009-06-21 19:17:51Z thomas $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Registry - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Registry extends ArrayObject @@ -66,7 +66,7 @@ class Zend_Registry extends ArrayObject public static function setInstance(Zend_Registry $registry) { if (self::$_registry !== null) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } @@ -97,22 +97,22 @@ class Zend_Registry extends ArrayObject public static function setClassName($registryClassName = 'Zend_Registry') { if (self::$_registry !== null) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } if (!is_string($registryClassName)) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception("Argument is not a class name"); } /** * @see Zend_Loader */ - // if (!class_exists($registryClassName)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($registryClassName); - // } + if (!class_exists($registryClassName)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($registryClassName); + } self::$_registryClassName = $registryClassName; } @@ -143,7 +143,7 @@ class Zend_Registry extends ArrayObject $instance = self::getInstance(); if (!$instance->offsetExists($index)) { - // require_once 'Zend/Exception.php'; + require_once 'Zend/Exception.php'; throw new Zend_Exception("No entry is registered for key '$index'"); } diff --git a/libs/Zend/Session.php b/libs/Zend/Session.php index e361d15db2..31ab5a50a1 100644 --- a/libs/Zend/Session.php +++ b/libs/Zend/Session.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Session.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Session.php 18342 2009-09-21 16:31:18Z alexander $ * @since Preview Release 0.2 */ @@ -25,17 +25,17 @@ /** * @see Zend_Session_Abstract */ -// require_once 'Zend/Session/Abstract.php'; +require_once 'Zend/Session/Abstract.php'; /** * @see Zend_Session_Namespace */ -// require_once 'Zend/Session/Namespace.php'; +require_once 'Zend/Session/Namespace.php'; /** * @see Zend_Session_SaveHandler_Interface */ -// require_once 'Zend/Session/SaveHandler/Interface.php'; +require_once 'Zend/Session/SaveHandler/Interface.php'; /** @@ -43,7 +43,7 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Session extends Zend_Session_Abstract @@ -62,7 +62,7 @@ class Zend_Session extends Zend_Session_Abstract * @var bool|bitset This could also be a combiniation of error codes to catch */ protected static $_throwStartupExceptions = true; - + /** * Check whether or not the session was started * @@ -223,7 +223,7 @@ class Zend_Session extends Zend_Session_Abstract } else { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("Unknown option: $userOptionName = $userOptionValue"); } } @@ -244,14 +244,14 @@ class Zend_Session extends Zend_Session_Abstract foreach (self::$_localOptions as $localOptionName => $localOptionMemberName) { $options[$localOptionName] = self::${$localOptionMemberName}; } - + if ($optionName) { if (array_key_exists($optionName, $options)) { return $options[$optionName]; } return null; } - + return $options; } @@ -303,7 +303,7 @@ class Zend_Session extends Zend_Session_Abstract { if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("You must call " . __CLASS__ . '::' . __FUNCTION__ . "() before any output has been sent to the browser; output started in {$filename}/{$linenum}"); } @@ -427,7 +427,7 @@ class Zend_Session extends Zend_Session_Abstract public static function start($options = false) { if (self::$_sessionStarted && self::$_destroyed) { - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.'); } @@ -443,14 +443,14 @@ class Zend_Session extends Zend_Session_Abstract // In strict mode, do not allow auto-starting Zend_Session, such as via "new Zend_Session_Namespace()" if (self::$_strict && $options === true) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.'); } $filename = $linenum = null; if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}"); } @@ -458,7 +458,7 @@ class Zend_Session extends Zend_Session_Abstract // See http://www.php.net/manual/en/ref.session.php for explanation if (!self::$_unitTestEnabled && defined('SID')) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('session has already been started by session.auto-start or session_start()'); } @@ -466,23 +466,23 @@ class Zend_Session extends Zend_Session_Abstract * Hack to throw exceptions on start instead of php errors * @see http://framework.zend.com/issues/browse/ZF-1325 */ - + $errorLevel = (is_int(self::$_throwStartupExceptions)) ? self::$_throwStartupExceptions : E_ALL; - + /** @see Zend_Session_Exception */ if (!self::$_unitTestEnabled) { - + if (self::$_throwStartupExceptions) { - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; set_error_handler(array('Zend_Session_Exception', 'handleSessionStartError'), $errorLevel); } - + $startedCleanly = session_start(); - + if (self::$_throwStartupExceptions) { restore_error_handler(); } - + if (!$startedCleanly || Zend_Session_Exception::$sessionStartError != null) { if (self::$_throwStartupExceptions) { set_error_handler(array('Zend_Session_Exception', 'handleSilentWriteClose'), $errorLevel); @@ -528,7 +528,7 @@ class Zend_Session extends Zend_Session_Abstract // Expire Namespace by Time (ENT) if (isset($namespace_metadata['ENT']) && ($namespace_metadata['ENT'] > 0) && (time() > $namespace_metadata['ENT']) ) { unset($_SESSION[$namespace]); - unset($_SESSION['__ZF'][$namespace]); + unset($_SESSION['__ZF'][$namespace]['ENT']); } // Expire Namespace by Global Hop (ENGH) @@ -540,7 +540,7 @@ class Zend_Session extends Zend_Session_Abstract parent::$_expiringData[$namespace] = $_SESSION[$namespace]; unset($_SESSION[$namespace]); } - unset($_SESSION['__ZF'][$namespace]); + unset($_SESSION['__ZF'][$namespace]['ENGH']); } } @@ -550,11 +550,12 @@ class Zend_Session extends Zend_Session_Abstract if (time() > $time) { unset($_SESSION[$namespace][$variable]); unset($_SESSION['__ZF'][$namespace]['ENVT'][$variable]); + + if (empty($_SESSION['__ZF'][$namespace]['ENVT'])) { + unset($_SESSION['__ZF'][$namespace]['ENVT']); + } } } - if (empty($_SESSION['__ZF'][$namespace]['ENVT'])) { - unset($_SESSION['__ZF'][$namespace]['ENVT']); - } } // Expire Namespace Variables by Global Hop (ENVGH) @@ -570,9 +571,6 @@ class Zend_Session extends Zend_Session_Abstract unset($_SESSION['__ZF'][$namespace]['ENVGH'][$variable]); } } - if(empty($_SESSION['__ZF'][$namespace]['ENVGH'])) { - unset($_SESSION['__ZF'][$namespace]['ENVGH']); - } } } @@ -632,20 +630,20 @@ class Zend_Session extends Zend_Session_Abstract { if (!self::$_unitTestEnabled && defined('SID')) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('The session has already been started. The session id must be set first.'); } if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("You must call ".__CLASS__.'::'.__FUNCTION__. "() before any output has been sent to the browser; output started in {$filename}/{$linenum}"); } if (!is_string($id) || $id === '') { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('You must provide a non-empty string as a session identifier.'); } @@ -774,14 +772,14 @@ class Zend_Session extends Zend_Session_Abstract private static function _processValidators() { foreach ($_SESSION['__ZF']['VALID'] as $validator_name => $valid_data) { - // if (!class_exists($validator_name)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($validator_name); - // } + if (!class_exists($validator_name)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($validator_name); + } $validator = new $validator_name; if ($validator->validate() === false) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("This session is not valid according to {$validator_name}."); } } @@ -838,7 +836,7 @@ class Zend_Session extends Zend_Session_Abstract { if (parent::$_readable === false) { /** @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(parent::_THROW_NOT_READABLE_MSG); } diff --git a/libs/Zend/Session/Abstract.php b/libs/Zend/Session/Abstract.php index 2c5b613e95..448afbf5c5 100644 --- a/libs/Zend/Session/Abstract.php +++ b/libs/Zend/Session/Abstract.php @@ -15,9 +15,9 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 16210 2009-06-21 19:22:17Z thomas $ * @since Preview Release 0.2 */ @@ -27,7 +27,7 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Session_Abstract @@ -82,7 +82,7 @@ abstract class Zend_Session_Abstract /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG); } @@ -108,7 +108,7 @@ abstract class Zend_Session_Abstract /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(self::_THROW_NOT_WRITABLE_MSG); } @@ -143,7 +143,7 @@ abstract class Zend_Session_Abstract /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG); } diff --git a/libs/Zend/Session/Exception.php b/libs/Zend/Session/Exception.php index dc8aa638ff..29ca6aa954 100644 --- a/libs/Zend/Session/Exception.php +++ b/libs/Zend/Session/Exception.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16210 2009-06-21 19:22:17Z thomas $ * @since Preview Release 0.2 */ @@ -24,7 +24,7 @@ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** @@ -32,7 +32,7 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Session_Exception extends Zend_Exception diff --git a/libs/Zend/Session/Namespace.php b/libs/Zend/Session/Namespace.php index ef811a066b..a18a66c99a 100644 --- a/libs/Zend/Session/Namespace.php +++ b/libs/Zend/Session/Namespace.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Namespace.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Namespace.php 16210 2009-06-21 19:22:17Z thomas $ * @since Preview Release 0.2 */ @@ -24,13 +24,13 @@ /** * @see Zend_Session */ -// require_once 'Zend/Session.php'; +require_once 'Zend/Session.php'; /** * @see Zend_Session_Abstract */ -// require_once 'Zend/Session/Abstract.php'; +require_once 'Zend/Session/Abstract.php'; /** @@ -38,7 +38,7 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAggregate @@ -84,11 +84,11 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg } return; } - + self::$_singleInstances = array(); return; } - + /** * __construct() - Returns an instance object bound to a particular, isolated section * of the session, identified by $namespace name (defaulting to 'Default'). @@ -105,7 +105,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('Session namespace must be a non-empty string.'); } @@ -113,7 +113,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('Session namespace must not start with an underscore.'); } @@ -121,7 +121,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('Session namespace must not start with a number.'); } @@ -129,7 +129,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("A session namespace object already exists for this namespace ('$namespace'), and no additional accessors (session namespace objects) for this namespace are permitted."); } @@ -146,7 +146,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG); } @@ -167,7 +167,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg self::$_expiringData[$namespace] = $_SESSION[$namespace]; unset($_SESSION[$namespace]); } - unset($_SESSION['__ZF'][$namespace]); + unset($_SESSION['__ZF'][$namespace]['ENNH']); } } @@ -184,9 +184,6 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg unset($_SESSION['__ZF'][$namespace]['ENVNH'][$variable]); } } - if(empty($_SESSION['__ZF'][$namespace]['ENVNH'])) { - unset($_SESSION['__ZF'][$namespace]['ENVNH']); - } } } @@ -280,7 +277,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("The '$name' key must be a non-empty string"); } @@ -302,7 +299,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('This session/namespace has been marked as read-only.'); } @@ -310,7 +307,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("The '$name' key must be a non-empty string"); } @@ -318,7 +315,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG); } @@ -367,7 +364,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('Result must be an array. Got: ' . gettype($result)); } $_SESSION[$this->_namespace] = $result; @@ -387,7 +384,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("The '$name' key must be a non-empty string"); } @@ -407,7 +404,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("The '$name' key must be a non-empty string"); } @@ -430,7 +427,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG); } @@ -438,7 +435,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('Seconds must be positive.'); } @@ -478,7 +475,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG); } @@ -486,7 +483,7 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg /** * @see Zend_Session_Exception */ - // require_once 'Zend/Session/Exception.php'; + require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception('Hops must be positive number.'); } @@ -517,13 +514,4 @@ class Zend_Session_Namespace extends Zend_Session_Abstract implements IteratorAg } } - /** - * Returns the namespace name - * - * @return string - */ - public function getNamespace() - { - return $this->_namespace; - } } diff --git a/libs/Zend/Session/SaveHandler/DbTable.php b/libs/Zend/Session/SaveHandler/DbTable.php index b59526d3a9..84a7f73180 100644 --- a/libs/Zend/Session/SaveHandler/DbTable.php +++ b/libs/Zend/Session/SaveHandler/DbTable.php @@ -15,30 +15,30 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DbTable.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: DbTable.php 16933 2009-07-21 20:24:35Z matthew $ */ /** * @see Zend_Session */ -// require_once 'Zend/Session.php'; +require_once 'Zend/Session.php'; /** * @see Zend_Db_Table_Abstract */ -// require_once 'Zend/Db/Table/Abstract.php'; +require_once 'Zend/Db/Table/Abstract.php'; /** * @see Zend_Db_Table_Row_Abstract */ -// require_once 'Zend/Db/Table/Row/Abstract.php'; +require_once 'Zend/Db/Table/Row/Abstract.php'; /** * @see Zend_Config */ -// require_once 'Zend/Config.php'; +require_once 'Zend/Config.php'; /** * Zend_Session_SaveHandler_DbTable @@ -46,11 +46,11 @@ * @category Zend * @package Zend_Session * @subpackage SaveHandler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Session_SaveHandler_DbTable - extends Zend_Db_Table_Abstract +class Zend_Session_SaveHandler_DbTable + extends Zend_Db_Table_Abstract implements Zend_Session_SaveHandler_Interface { const PRIMARY_ASSIGNMENT = 'primaryAssignment'; @@ -168,7 +168,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception( '$config must be an instance of Zend_Config or array of key/value pairs containing ' @@ -232,7 +232,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception(); } else if (empty($lifetime)) { $this->_lifetime = (int) ini_get('session.gc_maxlifetime'); @@ -420,7 +420,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception('session.save_path is a path and not a table name.'); } @@ -452,7 +452,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception( "Value for configuration option '" . self::PRIMARY_ASSIGNMENT . "' must have an assignment " @@ -461,7 +461,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception( "Value for configuration option '" . self::PRIMARY_ASSIGNMENT . "' must have an assignment " @@ -481,7 +481,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception( "Configuration must define '" . self::MODIFIED_COLUMN . "' which names the " @@ -490,7 +490,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception( "Configuration must define '" . self::LIFETIME_COLUMN . "' which names the " @@ -499,7 +499,7 @@ class Zend_Session_SaveHandler_DbTable /** * @see Zend_Session_SaveHandler_Exception */ - // require_once 'Zend/Session/SaveHandler/Exception.php'; + require_once 'Zend/Session/SaveHandler/Exception.php'; throw new Zend_Session_SaveHandler_Exception( "Configuration must define '" . self::DATA_COLUMN . "' which names the " @@ -516,7 +516,7 @@ class Zend_Session_SaveHandler_DbTable */ protected function _getPrimary($id, $type = null) { - $this->_setupPrimaryKey(); + $this->_setupPrimaryKey(); if ($type === null) { $type = self::PRIMARY_TYPE_NUM; diff --git a/libs/Zend/Session/SaveHandler/Exception.php b/libs/Zend/Session/SaveHandler/Exception.php index 249dcfa930..bb2124702d 100644 --- a/libs/Zend/Session/SaveHandler/Exception.php +++ b/libs/Zend/Session/SaveHandler/Exception.php @@ -15,22 +15,22 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16210 2009-06-21 19:22:17Z thomas $ */ /** * @see Zend_Session_Exception */ -// require_once 'Zend/Session/Exception.php'; +require_once 'Zend/Session/Exception.php'; /** * Zend_Session_SaveHandler_Exception * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Session_SaveHandler_Exception extends Zend_Session_Exception diff --git a/libs/Zend/Session/SaveHandler/Interface.php b/libs/Zend/Session/SaveHandler/Interface.php index 6e426974a7..2e4945a5d7 100644 --- a/libs/Zend/Session/SaveHandler/Interface.php +++ b/libs/Zend/Session/SaveHandler/Interface.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16210 2009-06-21 19:22:17Z thomas $ * @since Preview Release 0.2 */ @@ -26,7 +26,7 @@ * @category Zend * @package Zend_Session * @subpackage SaveHandler - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @see http://php.net/session_set_save_handler */ diff --git a/libs/Zend/Session/Validator/Abstract.php b/libs/Zend/Session/Validator/Abstract.php index 6c4caaeb94..e1a53f971a 100644 --- a/libs/Zend/Session/Validator/Abstract.php +++ b/libs/Zend/Session/Validator/Abstract.php @@ -14,16 +14,16 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Abstract.php 16210 2009-06-21 19:22:17Z thomas $ * @since Preview Release 0.2 */ /** * @see Zend_Session_Validator_Interface */ -// require_once 'Zend/Session/Validator/Interface.php'; +require_once 'Zend/Session/Validator/Interface.php'; /** * Zend_Session_Validator_Abstract @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Session * @subpackage Validator - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Session_Validator_Abstract implements Zend_Session_Validator_Interface diff --git a/libs/Zend/Session/Validator/HttpUserAgent.php b/libs/Zend/Session/Validator/HttpUserAgent.php index fef7d33329..3dccf9e32f 100644 --- a/libs/Zend/Session/Validator/HttpUserAgent.php +++ b/libs/Zend/Session/Validator/HttpUserAgent.php @@ -14,16 +14,16 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HttpUserAgent.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: HttpUserAgent.php 16210 2009-06-21 19:22:17Z thomas $ * @since Preview Release 0.2 */ /** * @see Zend_Session_Validator_Abstract */ -// require_once 'Zend/Session/Validator/Abstract.php'; +require_once 'Zend/Session/Validator/Abstract.php'; /** * Zend_Session_Validator_HttpUserAgent @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Session * @subpackage Validator - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Session_Validator_HttpUserAgent extends Zend_Session_Validator_Abstract diff --git a/libs/Zend/Session/Validator/Interface.php b/libs/Zend/Session/Validator/Interface.php index eab9d186cd..b0d9825e90 100644 --- a/libs/Zend/Session/Validator/Interface.php +++ b/libs/Zend/Session/Validator/Interface.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Session - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Interface.php 16210 2009-06-21 19:22:17Z thomas $ * @since Preview Release 0.2 */ @@ -26,7 +26,7 @@ * @category Zend * @package Zend_Session * @subpackage Validator - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Session_Validator_Interface diff --git a/libs/Zend/Uri.php b/libs/Zend/Uri.php index ad4c43ee99..abbe5a248c 100644 --- a/libs/Zend/Uri.php +++ b/libs/Zend/Uri.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Uri - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Uri.php 22083 2010-05-03 18:49:28Z shahar $ + * @version $Id: Uri.php 16207 2009-06-21 19:17:51Z thomas $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Uri - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Uri @@ -44,7 +44,7 @@ abstract class Zend_Uri static protected $_config = array( 'allow_unwise' => false ); - + /** * Return a string representation of this URI. * @@ -79,16 +79,14 @@ abstract class Zend_Uri * Create a new Zend_Uri object for a URI. If building a new URI, then $uri should contain * only the scheme (http, ftp, etc). Otherwise, supply $uri with the complete URI. * - * @param string $uri The URI form which a Zend_Uri instance is created - * @param string $className The name of the class to use in order to manipulate URI + * @param string $uri The URI form which a Zend_Uri instance is created * @throws Zend_Uri_Exception When an empty string was supplied for the scheme * @throws Zend_Uri_Exception When an illegal scheme is supplied * @throws Zend_Uri_Exception When the scheme is not supported - * @throws Zend_Uri_Exception When $className doesn't exist or doesn't implements Zend_Uri * @return Zend_Uri * @link http://www.faqs.org/rfcs/rfc2396.html */ - public static function factory($uri = 'http', $className = null) + public static function factory($uri = 'http') { // Separate the scheme from the scheme-specific parts $uri = explode(':', $uri, 2); @@ -96,53 +94,40 @@ abstract class Zend_Uri $schemeSpecific = isset($uri[1]) === true ? $uri[1] : ''; if (strlen($scheme) === 0) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('An empty string was supplied for the scheme'); } // Security check: $scheme is used to load a class file, so only alphanumerics are allowed. if (ctype_alnum($scheme) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted'); } - if ($className === null) { - /** - * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the - * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. - */ - switch ($scheme) { - case 'http': - // Break intentionally omitted - case 'https': - $className = 'Zend_Uri_Http'; - break; - - case 'mailto': - // TODO - default: - // require_once 'Zend/Uri/Exception.php'; - throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported"); - break; - } + /** + * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the + * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. + */ + switch ($scheme) { + case 'http': + // Break intentionally omitted + case 'https': + $className = 'Zend_Uri_Http'; + break; + + case 'mailto': + // TODO + default: + require_once 'Zend/Uri/Exception.php'; + throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported"); + break; } - // if (!class_exists($className)) { - // require_once 'Zend/Loader.php'; - // try { - // Zend_Loader::loadClass($className); - // } catch (Exception $e) { - // require_once 'Zend/Uri/Exception.php'; - // throw new Zend_Uri_Exception("\"$className\" not found"); - // } - // } - - $schemeHandler = new $className($scheme, $schemeSpecific); - - if (! $schemeHandler instanceof Zend_Uri) { - // require_once 'Zend/Uri/Exception.php'; - throw new Zend_Uri_Exception("\"$className\" is not an instance of Zend_Uri"); + if (!class_exists($className)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($className); } + $schemeHandler = new $className($scheme, $schemeSpecific); return $schemeHandler; } @@ -164,21 +149,15 @@ abstract class Zend_Uri /** * Set global configuration options * - * @param Zend_Config|array $config + * @param array $config */ - static public function setConfig($config) + static public function setConfig(array $config) { - if ($config instanceof Zend_Config) { - $config = $config->toArray(); - } elseif (!is_array($config)) { - throw new Zend_Uri_Exception("Config must be an array or an instance of Zend_Config."); - } - foreach ($config as $k => $v) { self::$_config[$k] = $v; } } - + /** * Zend_Uri and its subclasses cannot be instantiated directly. * Use Zend_Uri::factory() to return a new Zend_Uri object. diff --git a/libs/Zend/Uri/Exception.php b/libs/Zend/Uri/Exception.php index ba2f1a8342..5f68ac9f67 100644 --- a/libs/Zend/Uri/Exception.php +++ b/libs/Zend/Uri/Exception.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Uri - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16208 2009-06-21 19:19:26Z thomas $ */ /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; /** * Exceptions for Zend_Uri * * @category Zend * @package Zend_Uri - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Uri_Exception extends Zend_Exception diff --git a/libs/Zend/Uri/Http.php b/libs/Zend/Uri/Http.php index 48911dad64..c8ef6ac360 100644 --- a/libs/Zend/Uri/Http.php +++ b/libs/Zend/Uri/Http.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Uri - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Http.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Http.php 16208 2009-06-21 19:19:26Z thomas $ */ /** * @see Zend_Uri */ -// require_once 'Zend/Uri.php'; +require_once 'Zend/Uri.php'; /** * @see Zend_Validate_Hostname */ -// require_once 'Zend/Validate/Hostname.php'; +require_once 'Zend/Validate/Hostname.php'; /** * HTTP(S) URI handler @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Uri * @uses Zend_Uri - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Uri_Http extends Zend_Uri @@ -152,7 +152,7 @@ class Zend_Uri_Http extends Zend_Uri // Validate the URI if ($this->valid() === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Invalid URI supplied'); } } @@ -170,7 +170,7 @@ class Zend_Uri_Http extends Zend_Uri public static function fromString($uri) { if (is_string($uri) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('$uri is not a string'); } @@ -179,7 +179,7 @@ class Zend_Uri_Http extends Zend_Uri $schemeSpecific = isset($uri[1]) === true ? $uri[1] : ''; if (in_array($scheme, array('http', 'https')) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Invalid scheme: '$scheme'"); } @@ -201,7 +201,7 @@ class Zend_Uri_Http extends Zend_Uri $pattern = '~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~'; $status = @preg_match($pattern, $schemeSpecific, $matches); if ($status === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: scheme-specific decomposition failed'); } @@ -220,7 +220,7 @@ class Zend_Uri_Http extends Zend_Uri $pattern = '~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~'; $status = @preg_match($pattern, $combo, $matches); if ($status === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: authority decomposition failed'); } @@ -247,7 +247,7 @@ class Zend_Uri_Http extends Zend_Uri public function getUri() { if ($this->valid() === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('One or more parts of the URI are invalid'); } @@ -320,7 +320,7 @@ class Zend_Uri_Http extends Zend_Uri self::CHAR_ALNUM . self::CHAR_MARK . ';:&=+$,' . '])+$/', $username); if ($status === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: username validation failed'); } @@ -337,7 +337,7 @@ class Zend_Uri_Http extends Zend_Uri public function setUsername($username) { if ($this->validateUsername($username) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Username \"$username\" is not a valid HTTP username"); } @@ -387,7 +387,7 @@ class Zend_Uri_Http extends Zend_Uri self::CHAR_ALNUM . self::CHAR_MARK . ';:&=+$,' . '])+$/', $password); if ($status === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: password validation failed.'); } @@ -404,7 +404,7 @@ class Zend_Uri_Http extends Zend_Uri public function setPassword($password) { if ($this->validatePassword($password) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Password \"$password\" is not a valid HTTP password."); } @@ -459,7 +459,7 @@ class Zend_Uri_Http extends Zend_Uri public function setHost($host) { if ($this->validateHost($host) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Host \"$host\" is not a valid HTTP host"); } @@ -511,7 +511,7 @@ class Zend_Uri_Http extends Zend_Uri public function setPort($port) { if ($this->validatePort($port) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Port \"$port\" is not a valid HTTP port."); } @@ -554,7 +554,7 @@ class Zend_Uri_Http extends Zend_Uri $pattern = '/^' . $this->_regex['path'] . '$/'; $status = @preg_match($pattern, $path); if ($status === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: path validation failed'); } @@ -571,7 +571,7 @@ class Zend_Uri_Http extends Zend_Uri public function setPath($path) { if ($this->validatePath($path) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Path \"$path\" is not a valid HTTP path"); } @@ -592,23 +592,6 @@ class Zend_Uri_Http extends Zend_Uri } /** - * Returns the query portion of the URL (after ?) as a - * key-value-array. If the query is empty an empty array - * is returned - * - * @return array - */ - public function getQueryAsArray() - { - $query = $this->getQuery(); - $querryArray = array(); - if ($query !== false) { - parse_str($query, $querryArray); - } - return $querryArray; - } - - /** * Returns true if and only if the query string passes validation. If no query is passed, * then the query string contained in the instance variable is used. * @@ -632,7 +615,7 @@ class Zend_Uri_Http extends Zend_Uri $pattern = '/^' . $this->_regex['uric'] . '*$/'; $status = @preg_match($pattern, $query); if ($status === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: query validation failed'); } @@ -640,32 +623,6 @@ class Zend_Uri_Http extends Zend_Uri } /** - * Add or replace params in the query string for the current URI, and - * return the old query. - * - * @param array $queryParams - * @return string Old query string - */ - public function addReplaceQueryParameters(array $queryParams) - { - $queryParams = array_merge($this->getQueryAsArray(), $queryParams); - return $this->setQuery($queryParams); - } - - /** - * Remove params in the query string for the current URI, and - * return the old query. - * - * @param array $queryParamKeys - * @return string Old query string - */ - public function removeQueryParameters(array $queryParamKeys) - { - $queryParams = array_diff_key($this->getQueryAsArray(), array_fill_keys($queryParamKeys, 0)); - return $this->setQuery($queryParams); - } - - /** * Set the query string for the current URI, and return the old query * string This method accepts both strings and arrays. * @@ -697,7 +654,7 @@ class Zend_Uri_Http extends Zend_Uri // Make sure the query is valid, and set it if ($this->validateQuery($query) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("'$query' is not a valid query string"); } @@ -740,7 +697,7 @@ class Zend_Uri_Http extends Zend_Uri $pattern = '/^' . $this->_regex['uric'] . '*$/'; $status = @preg_match($pattern, $fragment); if ($status === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: fragment validation failed'); } @@ -757,7 +714,7 @@ class Zend_Uri_Http extends Zend_Uri public function setFragment($fragment) { if ($this->validateFragment($fragment) === false) { - // require_once 'Zend/Uri/Exception.php'; + require_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment"); } diff --git a/libs/Zend/Validate.php b/libs/Zend/Validate.php index f14eb671e7..cb87ba5120 100644 --- a/libs/Zend/Validate.php +++ b/libs/Zend/Validate.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Validate.php 21340 2010-03-05 15:33:49Z thomas $ + * @version $Id: Validate.php 16286 2009-06-25 15:11:37Z thomas $ */ /** * @see Zend_Validate_Interface */ -// require_once 'Zend/Validate/Interface.php'; +require_once 'Zend/Validate/Interface.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate implements Zend_Validate_Interface @@ -195,52 +195,30 @@ class Zend_Validate implements Zend_Validate_Interface public static function is($value, $classBaseName, array $args = array(), $namespaces = array()) { $namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('Zend_Validate')); - $className = ucfirst($classBaseName); - try { - if (!class_exists($className, false)) { - // require_once 'Zend/Loader.php'; - foreach($namespaces as $namespace) { - $class = $namespace . '_' . $className; - $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; - if (Zend_Loader::isReadable($file)) { - Zend_Loader::loadClass($class); - $className = $class; - break; - } + foreach ($namespaces as $namespace) { + $className = $namespace . '_' . ucfirst($classBaseName); + try { + if (!class_exists($className)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($className); } - } - - $class = new ReflectionClass($className); - if ($class->implementsInterface('Zend_Validate_Interface')) { - if ($class->hasMethod('__construct')) { - $keys = array_keys($args); - $numeric = false; - foreach($keys as $key) { - if (is_numeric($key)) { - $numeric = true; - break; - } - } - - if ($numeric) { + $class = new ReflectionClass($className); + if ($class->implementsInterface('Zend_Validate_Interface')) { + if ($class->hasMethod('__construct')) { $object = $class->newInstanceArgs($args); } else { - $object = $class->newInstance($args); + $object = $class->newInstance(); } - } else { - $object = $class->newInstance(); + return $object->isValid($value); } - - return $object->isValid($value); + } catch (Zend_Validate_Exception $ze) { + // if there is an exception while validating throw it + throw $ze; + } catch (Zend_Exception $ze) { + // fallthrough and continue for missing validation classes } - } catch (Zend_Validate_Exception $ze) { - // if there is an exception while validating throw it - throw $ze; - } catch (Exception $e) { - // fallthrough and continue for missing validation classes } - - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Validate class not found from basename '$classBaseName'"); } @@ -251,7 +229,7 @@ class Zend_Validate implements Zend_Validate_Interface */ public static function getMessageLength() { - // require_once 'Zend/Validate/Abstract.php'; + require_once 'Zend/Validate/Abstract.php'; return Zend_Validate_Abstract::getMessageLength(); } @@ -262,29 +240,7 @@ class Zend_Validate implements Zend_Validate_Interface */ public static function setMessageLength($length = -1) { - // require_once 'Zend/Validate/Abstract.php'; + require_once 'Zend/Validate/Abstract.php'; Zend_Validate_Abstract::setMessageLength($length); } - - /** - * Returns the default translation object - * - * @return Zend_Translate_Adapter|null - */ - public static function getDefaultTranslator($translator = null) - { - // require_once 'Zend/Validate/Abstract.php'; - return Zend_Validate_Abstract::getDefaultTranslator(); - } - - /** - * Sets a default translation object for all validation objects - * - * @param Zend_Translate|Zend_Translate_Adapter|null $translator - */ - public static function setDefaultTranslator($translator = null) - { - // require_once 'Zend/Validate/Abstract.php'; - Zend_Validate_Abstract::setDefaultTranslator($translator); - } } diff --git a/libs/Zend/Validate/Abstract.php b/libs/Zend/Validate/Abstract.php index cbecc5eebf..3107360619 100644 --- a/libs/Zend/Validate/Abstract.php +++ b/libs/Zend/Validate/Abstract.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 21726 2010-03-31 19:57:27Z rob $ + * @version $Id: Abstract.php 18688 2009-10-25 16:08:24Z thomas $ */ /** * @see Zend_Validate_Interface */ -// require_once 'Zend/Validate/Interface.php'; +require_once 'Zend/Validate/Interface.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface @@ -149,7 +149,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } if (!isset($this->_messageTemplates[$messageKey])) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("No message template exists for key '$messageKey'"); } @@ -191,7 +191,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface /** * @see Zend_Validate_Exception */ - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("No property exists by the name '$property'"); } @@ -251,11 +251,11 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } /** - * @param string $messageKey + * @param string $messageKey OPTIONAL * @param string $value OPTIONAL * @return void */ - protected function _error($messageKey, $value = null) + protected function _error($messageKey = null, $value = null) { if ($messageKey === null) { $keys = array_keys($this->_messageTemplates); @@ -328,7 +328,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } elseif ($translator instanceof Zend_Translate) { $this->_translator = $translator->getAdapter(); } else { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid translator specified'); } return $this; @@ -353,16 +353,6 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } /** - * Does this validator have its own specific translator? - * - * @return bool - */ - public function hasTranslator() - { - return (bool)$this->_translator; - } - - /** * Set default translation object for all validate objects * * @param Zend_Translate|Zend_Translate_Adapter|null $translator @@ -375,7 +365,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } elseif ($translator instanceof Zend_Translate) { self::$_defaultTranslator = $translator->getAdapter(); } else { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid translator specified'); } } @@ -388,7 +378,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface public static function getDefaultTranslator() { if (null === self::$_defaultTranslator) { - // require_once 'Zend/Registry.php'; + require_once 'Zend/Registry.php'; if (Zend_Registry::isRegistered('Zend_Translate')) { $translator = Zend_Registry::get('Zend_Translate'); if ($translator instanceof Zend_Translate_Adapter) { @@ -403,16 +393,6 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } /** - * Is there a default translation object set? - * - * @return boolean - */ - public static function hasDefaultTranslator() - { - return (bool)self::$_defaultTranslator; - } - - /** * Indicate whether or not translation should be disabled * * @param bool $flag diff --git a/libs/Zend/Validate/Alnum.php b/libs/Zend/Validate/Alnum.php index 9db12a3062..c2f2f46642 100644 --- a/libs/Zend/Validate/Alnum.php +++ b/libs/Zend/Validate/Alnum.php @@ -14,33 +14,33 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Alnum.php 20442 2010-01-20 15:15:40Z matthew $ + * @version $Id: Alnum.php 17467 2009-08-08 18:06:55Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Alnum extends Zend_Validate_Abstract { const INVALID = 'alnumInvalid'; const NOT_ALNUM = 'notAlnum'; - const STRING_EMPTY = 'alnumStringEmpty'; + const STRING_EMPTY = 'stringEmpty'; /** * Whether to allow white space characters; off by default * * @var boolean - * @deprecated + * @depreciated */ public $allowWhiteSpace; @@ -58,30 +58,18 @@ class Zend_Validate_Alnum extends Zend_Validate_Abstract */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be float, string, or integer", - self::NOT_ALNUM => "'%value%' contains characters which are non alphabetic and no digits", - self::STRING_EMPTY => "'%value%' is an empty string", + self::NOT_ALNUM => "'%value%' has not only alphabetic and digit characters", + self::STRING_EMPTY => "'%value%' is an empty string" ); /** * Sets default option values for this instance * - * @param boolean|Zend_Config $allowWhiteSpace + * @param boolean $allowWhiteSpace * @return void */ public function __construct($allowWhiteSpace = false) { - if ($allowWhiteSpace instanceof Zend_Config) { - $allowWhiteSpace = $allowWhiteSpace->toArray(); - } - - if (is_array($allowWhiteSpace)) { - if (array_key_exists('allowWhiteSpace', $allowWhiteSpace)) { - $allowWhiteSpace = $allowWhiteSpace['allowWhiteSpace']; - } else { - $allowWhiteSpace = false; - } - } - $this->allowWhiteSpace = (boolean) $allowWhiteSpace; } @@ -133,7 +121,7 @@ class Zend_Validate_Alnum extends Zend_Validate_Abstract /** * @see Zend_Filter_Alnum */ - // require_once 'Zend/Filter/Alnum.php'; + require_once 'Zend/Filter/Alnum.php'; self::$_filter = new Zend_Filter_Alnum(); } diff --git a/libs/Zend/Validate/Alpha.php b/libs/Zend/Validate/Alpha.php index 42864fa561..ce1f01872f 100644 --- a/libs/Zend/Validate/Alpha.php +++ b/libs/Zend/Validate/Alpha.php @@ -14,33 +14,33 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Alpha.php 20442 2010-01-20 15:15:40Z matthew $ + * @version $Id: Alpha.php 16223 2009-06-21 20:04:53Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Alpha extends Zend_Validate_Abstract { const INVALID = 'alphaInvalid'; const NOT_ALPHA = 'notAlpha'; - const STRING_EMPTY = 'alphaStringEmpty'; + const STRING_EMPTY = 'stringEmpty'; /** * Whether to allow white space characters; off by default * * @var boolean - * @deprecated + * @depreciated */ public $allowWhiteSpace; @@ -58,30 +58,18 @@ class Zend_Validate_Alpha extends Zend_Validate_Abstract */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be a string", - self::NOT_ALPHA => "'%value%' contains non alphabetic characters", + self::NOT_ALPHA => "'%value%' has not only alphabetic characters", self::STRING_EMPTY => "'%value%' is an empty string" ); /** * Sets default option values for this instance * - * @param boolean|Zend_Config $allowWhiteSpace + * @param boolean $allowWhiteSpace * @return void */ public function __construct($allowWhiteSpace = false) { - if ($allowWhiteSpace instanceof Zend_Config) { - $allowWhiteSpace = $allowWhiteSpace->toArray(); - } - - if (is_array($allowWhiteSpace)) { - if (array_key_exists('allowWhiteSpace', $allowWhiteSpace)) { - $allowWhiteSpace = $allowWhiteSpace['allowWhiteSpace']; - } else { - $allowWhiteSpace = false; - } - } - $this->allowWhiteSpace = (boolean) $allowWhiteSpace; } @@ -133,7 +121,7 @@ class Zend_Validate_Alpha extends Zend_Validate_Abstract /** * @see Zend_Filter_Alpha */ - // require_once 'Zend/Filter/Alpha.php'; + require_once 'Zend/Filter/Alpha.php'; self::$_filter = new Zend_Filter_Alpha(); } diff --git a/libs/Zend/Validate/Barcode.php b/libs/Zend/Validate/Barcode.php index 111010880e..374a9e5449 100644 --- a/libs/Zend/Validate/Barcode.php +++ b/libs/Zend/Validate/Barcode.php @@ -14,164 +14,70 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Barcode.php 21748 2010-04-03 10:29:56Z thomas $ + * @version $Id: Barcode.php 16223 2009-06-21 20:04:53Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; - -/** - * @see Zend_Loader - */ -// require_once 'Zend/Loader.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Barcode extends Zend_Validate_Abstract { - const INVALID = 'barcodeInvalid'; - const FAILED = 'barcodeFailed'; - const INVALID_CHARS = 'barcodeInvalidChars'; - const INVALID_LENGTH = 'barcodeInvalidLength'; - - protected $_messageTemplates = array( - self::FAILED => "'%value%' failed checksum validation", - self::INVALID_CHARS => "'%value%' contains invalid characters", - self::INVALID_LENGTH => "'%value%' should have a length of %length% characters", - self::INVALID => "Invalid type given, value should be string", - ); - - /** - * Additional variables available for validation failure messages - * - * @var array - */ - protected $_messageVariables = array( - 'length' => '_length' - ); - - /** - * Length for the set subtype - * - * @var integer - */ - protected $_length; - /** - * Barcode adapter + * Barcode validator * - * @var Zend_Validate_Barcode_BarcodeAdapter + * @var Zend_Validate_Abstract */ - protected $_adapter; + protected $_barcodeValidator; /** * Generates the standard validator object * - * @param string|Zend_Config| - * Zend_Validate_Barcode_BarcodeAdapter $adapter Barcode adapter to use + * @param string $barcodeType - Barcode validator to use * @return void * @throws Zend_Validate_Exception */ - public function __construct($adapter) - { - if ($adapter instanceof Zend_Config) { - $adapter = $adapter->toArray(); - } - - $options = null; - $checksum = null; - if (is_array($adapter)) { - if (array_key_exists('options', $adapter)) { - $options = $adapter['options']; - } - - if (array_key_exists('checksum', $adapter)) { - $checksum = $adapter['checksum']; - } - - if (array_key_exists('adapter', $adapter)) { - $adapter = $adapter['adapter']; - } else { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Missing option 'adapter'"); - } - } - - $this->setAdapter($adapter, $options); - if ($checksum !== null) { - $this->setChecksum($checksum); - } - } - - /** - * Returns the set adapter - * - * @return Zend_Validate_Barcode_BarcodeAdapter - */ - public function getAdapter() + public function __construct($barcodeType) { - return $this->_adapter; + $this->setType($barcodeType); } /** - * Sets a new barcode adapter + * Sets a new barcode validator * - * @param string|Zend_Validate_Barcode $adapter Barcode adapter to use - * @param array $options Options for this adapter + * @param string $barcodeType - Barcode validator to use * @return void * @throws Zend_Validate_Exception */ - public function setAdapter($adapter, $options = null) + public function setType($barcodeType) { - $adapter = ucfirst(strtolower($adapter)); - // require_once 'Zend/Loader.php'; - if (Zend_Loader::isReadable('Zend/Validate/Barcode/' . $adapter. '.php')) { - $adapter = 'Zend_Validate_Barcode_' . $adapter; - } - - // if (!class_exists($adapter)) { - // Zend_Loader::loadClass($adapter); - // } - - $this->_adapter = new $adapter($options); - if (!$this->_adapter instanceof Zend_Validate_Barcode_AdapterInterface) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception( - "Adapter " . $adapter . " does not implement Zend_Validate_Barcode_AdapterInterface" - ); + switch (strtolower($barcodeType)) { + case 'upc': + case 'upc-a': + require_once 'Zend/Validate/Barcode/UpcA.php'; + $class = 'Zend_Validate_Barcode_UpcA'; + break; + case 'ean13': + case 'ean-13': + require_once 'Zend/Validate/Barcode/Ean13.php'; + $class = 'Zend_Validate_Barcode_Ean13'; + break; + default: + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception("Barcode type '$barcodeType' is not supported'"); + break; } - return $this; - } - - /** - * Returns the checksum option - * - * @return boolean - */ - public function getChecksum() - { - return $this->getAdapter()->getCheck(); - } - - /** - * Sets the checksum option - * - * @param boolean $checksum - * @return Zend_Validate_Barcode - */ - public function setChecksum($checksum) - { - $this->getAdapter()->setCheck($checksum); - return $this; + $this->_barcodeValidator = new $class; } /** @@ -184,34 +90,6 @@ class Zend_Validate_Barcode extends Zend_Validate_Abstract */ public function isValid($value) { - if (!is_string($value)) { - $this->_error(self::INVALID); - return false; - } - - $this->_setValue($value); - $adapter = $this->getAdapter(); - $this->_length = $adapter->getLength(); - $result = $adapter->checkLength($value); - if (!$result) { - $this->_error(self::INVALID_LENGTH); - return false; - } - - $result = $adapter->checkChars($value); - if (!$result) { - $this->_error(self::INVALID_CHARS); - return false; - } - - if ($this->getChecksum()) { - $result = $adapter->checksum($value); - if (!$result) { - $this->_error(self::FAILED); - return false; - } - } - - return true; + return call_user_func(array($this->_barcodeValidator, 'isValid'), $value); } } diff --git a/libs/Zend/Validate/Barcode/AdapterAbstract.php b/libs/Zend/Validate/Barcode/AdapterAbstract.php deleted file mode 100644 index 7cbb4644f8..0000000000 --- a/libs/Zend/Validate/Barcode/AdapterAbstract.php +++ /dev/null @@ -1,315 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterInterface - */ -// require_once 'Zend/Validate/Barcode/AdapterInterface.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Validate_Barcode_AdapterAbstract - implements Zend_Validate_Barcode_AdapterInterface -{ - /** - * Allowed barcode lengths - * @var integer|array|string - */ - protected $_length; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters; - - /** - * Callback to checksum function - * @var string|array - */ - protected $_checksum; - - /** - * Is a checksum value included? - * @var boolean - */ - protected $_hasChecksum = true; - - /** - * Checks the length of a barcode - * - * @param string $value The barcode to check for proper length - * @return boolean - */ - public function checkLength($value) - { - if (!is_string($value)) { - return false; - } - - $fixum = strlen($value); - $found = false; - $length = $this->getLength(); - if (is_array($length)) { - foreach ($length as $value) { - if ($fixum == $value) { - $found = true; - } - - if ($value == -1) { - $found = true; - } - } - } elseif ($fixum == $length) { - $found = true; - } elseif ($length == -1) { - $found = true; - } elseif ($length == 'even') { - $count = $fixum % 2; - $found = ($count == 0) ? true : false; - } elseif ($length == 'odd') { - $count = $fixum % 2; - $found = ($count == 1) ? true : false; - } - - return $found; - } - - /** - * Checks for allowed characters within the barcode - * - * @param string $value The barcode to check for allowed characters - * @return boolean - */ - public function checkChars($value) - { - if (!is_string($value)) { - return false; - } - - $characters = $this->getCharacters(); - if ($characters == 128) { - for ($x = 0; $x < 128; ++$x) { - $value = str_replace(chr($x), '', $value); - } - } else { - $chars = str_split($characters); - foreach ($chars as $char) { - $value = str_replace($char, '', $value); - } - } - - if (strlen($value) > 0) { - return false; - } - - return true; - } - - /** - * Validates the checksum - * - * @param string $value The barcode to check the checksum for - * @return boolean - */ - public function checksum($value) - { - $checksum = $this->getChecksum(); - if (!empty($checksum)) { - if (method_exists($this, $checksum)) { - return call_user_func(array($this, $checksum), $value); - } - } - - return false; - } - - /** - * Returns the allowed barcode length - * - * @return string - */ - public function getLength() - { - return $this->_length; - } - - /** - * Returns the allowed characters - * - * @return integer|string - */ - public function getCharacters() - { - return $this->_characters; - } - - /** - * Returns the checksum function name - * - */ - public function getChecksum() - { - return $this->_checksum; - } - - /** - * Returns if barcode uses checksum - * - * @return boolean - */ - public function getCheck() - { - return $this->_hasChecksum; - } - - /** - * Sets the checksum validation - * - * @param boolean $check - * @return Zend_Validate_Barcode_AdapterAbstract - */ - public function setCheck($check) - { - $this->_hasChecksum = (boolean) $check; - return $this; - } - - /** - * Validates the checksum (Modulo 10) - * GTIN implementation factor 3 - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _gtin($value) - { - $barcode = substr($value, 0, -1); - $sum = 0; - $length = strlen($barcode) - 1; - - for ($i = 0; $i <= $length; $i++) { - if (($i % 2) === 0) { - $sum += $barcode[$length - $i] * 3; - } else { - $sum += $barcode[$length - $i]; - } - } - - $calc = $sum % 10; - $checksum = ($calc === 0) ? 0 : (10 - $calc); - if ($value[$length + 1] != $checksum) { - return false; - } - - return true; - } - - /** - * Validates the checksum (Modulo 10) - * IDENTCODE implementation factors 9 and 4 - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _identcode($value) - { - $barcode = substr($value, 0, -1); - $sum = 0; - $length = strlen($value) - 2; - - for ($i = 0; $i <= $length; $i++) { - if (($i % 2) === 0) { - $sum += $barcode[$length - $i] * 4; - } else { - $sum += $barcode[$length - $i] * 9; - } - } - - $calc = $sum % 10; - $checksum = ($calc === 0) ? 0 : (10 - $calc); - if ($value[$length + 1] != $checksum) { - return false; - } - - return true; - } - - /** - * Validates the checksum (Modulo 10) - * CODE25 implementation factor 3 - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _code25($value) - { - $barcode = substr($value, 0, -1); - $sum = 0; - $length = strlen($barcode) - 1; - - for ($i = 0; $i <= $length; $i++) { - if (($i % 2) === 0) { - $sum += $barcode[$i] * 3; - } else { - $sum += $barcode[$i]; - } - } - - $calc = $sum % 10; - $checksum = ($calc === 0) ? 0 : (10 - $calc); - if ($value[$length + 1] != $checksum) { - return false; - } - - return true; - } - - /** - * Validates the checksum () - * POSTNET implementation - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _postnet($value) - { - $checksum = substr($value, -1, 1); - $values = str_split(substr($value, 0, -1)); - - $check = 0; - foreach($values as $row) { - $check += $row; - } - - $check %= 10; - $check = 10 - $check; - if ($check == $checksum) { - return true; - } - - return false; - } -} diff --git a/libs/Zend/Validate/Barcode/AdapterInterface.php b/libs/Zend/Validate/Barcode/AdapterInterface.php deleted file mode 100644 index 325c6048f3..0000000000 --- a/libs/Zend/Validate/Barcode/AdapterInterface.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Validate_Barcode_AdapterInterface -{ - /** - * Checks the length of a barcode - * - * @param string $value The barcode to check for proper length - * @return boolean - */ - public function checkLength($value); - - /** - * Checks for allowed characters within the barcode - * - * @param string $value The barcode to check for allowed characters - * @return boolean - */ - public function checkChars($value); - - /** - * Validates the checksum - * - * @param string $value The barcode to check the checksum for - * @return boolean - */ - public function checksum($value); - - /** - * Returns if barcode uses a checksum - * - * @return boolean - */ - public function getCheck(); - - /** - * Sets the checksum validation - * - * @param boolean $check - * @return Zend_Validate_Barcode_Adapter Provides fluid interface - */ - public function setCheck($check); -} diff --git a/libs/Zend/Validate/Barcode/Code25.php b/libs/Zend/Validate/Barcode/Code25.php deleted file mode 100644 index 6d1525da4c..0000000000 --- a/libs/Zend/Validate/Barcode/Code25.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Code25 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = -1; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_code25'; - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } -} diff --git a/libs/Zend/Validate/Barcode/Code25interleaved.php b/libs/Zend/Validate/Barcode/Code25interleaved.php deleted file mode 100644 index 54fd90bd28..0000000000 --- a/libs/Zend/Validate/Barcode/Code25interleaved.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Code25interleaved extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 'even'; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_code25'; - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } -} diff --git a/libs/Zend/Validate/Barcode/Code39.php b/libs/Zend/Validate/Barcode/Code39.php deleted file mode 100644 index 8208cffb9e..0000000000 --- a/libs/Zend/Validate/Barcode/Code39.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Code39 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = -1; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ -.$/+%'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_code39'; - - /** - * @var array - */ - protected $_check = array( - '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, - '7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, - 'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20, - 'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27, - 'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34, - 'Z' => 35, '-' => 36, '.' => 37, ' ' => 38, '$' => 39, '/' => 40, '+' => 41, - '%' => 42, - ); - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } - - /** - * Validates the checksum (Modulo 43) - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _code39($value) - { - $checksum = substr($value, -1, 1); - $value = str_split(substr($value, 0, -1)); - $count = 0; - foreach($value as $char) { - $count += $this->_check[$char]; - } - - $mod = $count % 43; - if ($mod == $this->_check[$checksum]) { - return true; - } - - return false; - } -} diff --git a/libs/Zend/Validate/Barcode/Code39ext.php b/libs/Zend/Validate/Barcode/Code39ext.php deleted file mode 100644 index 5b90254c50..0000000000 --- a/libs/Zend/Validate/Barcode/Code39ext.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Code39ext extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = -1; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = 128; - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } -} diff --git a/libs/Zend/Validate/Barcode/Code93.php b/libs/Zend/Validate/Barcode/Code93.php deleted file mode 100644 index 36a6567f36..0000000000 --- a/libs/Zend/Validate/Barcode/Code93.php +++ /dev/null @@ -1,120 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Code93 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = -1; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ -.$/+%'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_code93'; - - /** - * Note that the characters !"§& are only synonyms - * @var array - */ - protected $_check = array( - '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, - '7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, - 'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20, - 'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27, - 'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34, - 'Z' => 35, '-' => 36, '.' => 37, ' ' => 38, '$' => 39, '/' => 40, '+' => 41, - '%' => 42, '!' => 43, '"' => 44, '§' => 45, '&' => 46, - ); - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } - - /** - * Validates the checksum (Modulo CK) - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _code93($value) - { - $checksum = substr($value, -2, 2); - $value = str_split(substr($value, 0, -2)); - $count = 0; - $length = count($value) % 20; - foreach($value as $char) { - if ($length == 0) { - $length = 20; - } - - $count += $this->_check[$char] * $length; - --$length; - } - - $check = array_search(($count % 47), $this->_check); - $value[] = $check; - $count = 0; - $length = count($value) % 15; - foreach($value as $char) { - if ($length == 0) { - $length = 15; - } - - $count += $this->_check[$char] * $length; - --$length; - } - $check .= array_search(($count % 47), $this->_check); - - if ($check == $checksum) { - return true; - } - - return false; - } -} diff --git a/libs/Zend/Validate/Barcode/Code93ext.php b/libs/Zend/Validate/Barcode/Code93ext.php deleted file mode 100644 index 2aaf343162..0000000000 --- a/libs/Zend/Validate/Barcode/Code93ext.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Code93ext extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = -1; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = 128; - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } -} diff --git a/libs/Zend/Validate/Barcode/Ean12.php b/libs/Zend/Validate/Barcode/Ean12.php deleted file mode 100644 index 26dee47fb5..0000000000 --- a/libs/Zend/Validate/Barcode/Ean12.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Ean12 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 12; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Ean13.php b/libs/Zend/Validate/Barcode/Ean13.php index d5387e52f9..068809248c 100644 --- a/libs/Zend/Validate/Barcode/Ean13.php +++ b/libs/Zend/Validate/Barcode/Ean13.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,39 +15,96 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Ean13.php 16223 2009-06-21 20:04:53Z thomas $ */ + /** - * @see Zend_Validate_Barcode_AdapterAbstract + * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Barcode_AdapterAbstract +class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract { /** - * Allowed barcode lengths - * @var integer + * Validation failure message key for when the value is + * an invalid barcode + */ + const INVALID = 'invalid'; + + /** + * Validation failure message key for when the value is + * not 13 characters long */ - protected $_length = 13; + const INVALID_LENGTH = 'invalidLength'; /** - * Allowed barcode characters - * @var string + * Validation failure message key for when the value + * does not only contain numeric characters */ - protected $_characters = '0123456789'; + const NOT_NUMERIC = 'ean13NotNumeric'; /** - * Checksum function - * @var string + * Validation failure message template definitions + * + * @var array */ - protected $_checksum = '_gtin'; + protected $_messageTemplates = array( + self::INVALID => "'%value%' is an invalid EAN-13 barcode", + self::INVALID_LENGTH => "'%value%' should be 13 characters", + self::NOT_NUMERIC => "'%value%' should contain only numeric characters", + ); + + /** + * Defined by Zend_Validate_Interface + * + * Returns true if and only if $value contains a valid barcode + * + * @param string $value + * @return boolean + */ + public function isValid($value) + { + if (!is_string($value) || !ctype_digit($value)) { + $this->_error(self::NOT_NUMERIC); + return false; + } + + $this->_setValue($value); + if (strlen($value) !== 13) { + $this->_error(self::INVALID_LENGTH); + return false; + } + + $barcode = strrev(substr($value, 0, -1)); + $oddSum = 0; + $evenSum = 0; + + for ($i = 0; $i < 12; $i++) { + if ($i % 2 === 0) { + $oddSum += $barcode[$i] * 3; + } elseif ($i % 2 === 1) { + $evenSum += $barcode[$i]; + } + } + + $calculation = ($oddSum + $evenSum) % 10; + $checksum = ($calculation === 0) ? 0 : 10 - $calculation; + + if ($value[12] != $checksum) { + $this->_error(self::INVALID); + return false; + } + + return true; + } } diff --git a/libs/Zend/Validate/Barcode/Ean14.php b/libs/Zend/Validate/Barcode/Ean14.php deleted file mode 100644 index 19756c8ee7..0000000000 --- a/libs/Zend/Validate/Barcode/Ean14.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Ean14 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 14; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Ean18.php b/libs/Zend/Validate/Barcode/Ean18.php deleted file mode 100644 index 7c6519959f..0000000000 --- a/libs/Zend/Validate/Barcode/Ean18.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Ean18 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 18; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Ean2.php b/libs/Zend/Validate/Barcode/Ean2.php deleted file mode 100644 index 009bfe5e57..0000000000 --- a/libs/Zend/Validate/Barcode/Ean2.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Ean2 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 2; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } -} diff --git a/libs/Zend/Validate/Barcode/Ean5.php b/libs/Zend/Validate/Barcode/Ean5.php deleted file mode 100644 index 7574e897e4..0000000000 --- a/libs/Zend/Validate/Barcode/Ean5.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Ean5 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 5; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } -} diff --git a/libs/Zend/Validate/Barcode/Ean8.php b/libs/Zend/Validate/Barcode/Ean8.php deleted file mode 100644 index ca68fe45d9..0000000000 --- a/libs/Zend/Validate/Barcode/Ean8.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Ean8 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = array(7, 8); - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; - - /** - * Overrides parent checkLength - * - * @param string $value Value - * @return boolean - */ - public function checkLength($value) - { - if (strlen($value) == 7) { - $this->setCheck(false); - } else { - $this->setCheck(true); - } - - return parent::checkLength($value); - } -} diff --git a/libs/Zend/Validate/Barcode/Gtin12.php b/libs/Zend/Validate/Barcode/Gtin12.php deleted file mode 100644 index 7453e05f64..0000000000 --- a/libs/Zend/Validate/Barcode/Gtin12.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Gtin12 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 12; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Gtin13.php b/libs/Zend/Validate/Barcode/Gtin13.php deleted file mode 100644 index c466f5896a..0000000000 --- a/libs/Zend/Validate/Barcode/Gtin13.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Gtin13 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 13; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Gtin14.php b/libs/Zend/Validate/Barcode/Gtin14.php deleted file mode 100644 index 7c5c1cdb5b..0000000000 --- a/libs/Zend/Validate/Barcode/Gtin14.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Gtin14 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 14; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Identcode.php b/libs/Zend/Validate/Barcode/Identcode.php deleted file mode 100644 index 6899c17910..0000000000 --- a/libs/Zend/Validate/Barcode/Identcode.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Identcode extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 12; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_identcode'; -} diff --git a/libs/Zend/Validate/Barcode/Intelligentmail.php b/libs/Zend/Validate/Barcode/Intelligentmail.php deleted file mode 100644 index a0e81cfca6..0000000000 --- a/libs/Zend/Validate/Barcode/Intelligentmail.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_IntelligentMail extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = array(20, 25, 29, 31); - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Constructor - * - * Sets check flag to false. - * - * @return void - */ - public function __construct() - { - $this->setCheck(false); - } -} diff --git a/libs/Zend/Validate/Barcode/Issn.php b/libs/Zend/Validate/Barcode/Issn.php deleted file mode 100644 index e9507c9a5f..0000000000 --- a/libs/Zend/Validate/Barcode/Issn.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Issn extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = array(8, 13); - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789X'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; - - /** - * Allows X on length of 8 chars - * - * @param string $value The barcode to check for allowed characters - * @return boolean - */ - public function checkChars($value) - { - if (strlen($value) != 8) { - if (strpos($value, 'X') !== false) { - return false; - } - } - - return parent::checkChars($value); - } - - /** - * Validates the checksum - * - * @param string $value The barcode to check the checksum for - * @return boolean - */ - public function checksum($value) - { - if (strlen($value) == 8) { - $this->_checksum = '_issn'; - } else { - $this->_checksum = '_gtin'; - } - - return parent::checksum($value); - } - - /** - * Validates the checksum () - * ISSN implementation (reversed mod11) - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _issn($value) - { - $checksum = substr($value, -1, 1); - $values = str_split(substr($value, 0, -1)); - $check = 0; - $multi = 8; - foreach($values as $token) { - if ($token == 'X') { - $token = 10; - } - - $check += ($token * $multi); - --$multi; - } - - $check %= 11; - $check = 11 - $check; - if ($check == $checksum) { - return true; - } else if (($check == 10) && ($checksum == 'X')) { - return true; - } - - return false; - } -} diff --git a/libs/Zend/Validate/Barcode/Itf14.php b/libs/Zend/Validate/Barcode/Itf14.php deleted file mode 100644 index 10cfeb761c..0000000000 --- a/libs/Zend/Validate/Barcode/Itf14.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Itf14 extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 14; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Leitcode.php b/libs/Zend/Validate/Barcode/Leitcode.php deleted file mode 100644 index 52f1fc0428..0000000000 --- a/libs/Zend/Validate/Barcode/Leitcode.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Leitcode extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 14; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_identcode'; -} diff --git a/libs/Zend/Validate/Barcode/Planet.php b/libs/Zend/Validate/Barcode/Planet.php deleted file mode 100644 index b4eaf66cb9..0000000000 --- a/libs/Zend/Validate/Barcode/Planet.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Planet extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = array(12, 14); - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_postnet'; -} diff --git a/libs/Zend/Validate/Barcode/Postnet.php b/libs/Zend/Validate/Barcode/Postnet.php deleted file mode 100644 index 9d2ff879b8..0000000000 --- a/libs/Zend/Validate/Barcode/Postnet.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Postnet extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = array(6, 7, 10, 12); - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_postnet'; -} diff --git a/libs/Zend/Validate/Barcode/Royalmail.php b/libs/Zend/Validate/Barcode/Royalmail.php deleted file mode 100644 index 0bcdf1e16c..0000000000 --- a/libs/Zend/Validate/Barcode/Royalmail.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Royalmail extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = -1; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - - protected $_rows = array( - '0' => 1, '1' => 1, '2' => 1, '3' => 1, '4' => 1, '5' => 1, - '6' => 2, '7' => 2, '8' => 2, '9' => 2, 'A' => 2, 'B' => 2, - 'C' => 3, 'D' => 3, 'E' => 3, 'F' => 3, 'G' => 3, 'H' => 3, - 'I' => 4, 'J' => 4, 'K' => 4, 'L' => 4, 'M' => 4, 'N' => 4, - 'O' => 5, 'P' => 5, 'Q' => 5, 'R' => 5, 'S' => 5, 'T' => 5, - 'U' => 0, 'V' => 0, 'W' => 0, 'X' => 0, 'Y' => 0, 'Z' => 0, - ); - - protected $_columns = array( - '0' => 1, '1' => 2, '2' => 3, '3' => 4, '4' => 5, '5' => 0, - '6' => 1, '7' => 2, '8' => 3, '9' => 4, 'A' => 5, 'B' => 0, - 'C' => 1, 'D' => 2, 'E' => 3, 'F' => 4, 'G' => 5, 'H' => 0, - 'I' => 1, 'J' => 2, 'K' => 3, 'L' => 4, 'M' => 5, 'N' => 0, - 'O' => 1, 'P' => 2, 'Q' => 3, 'R' => 4, 'S' => 5, 'T' => 0, - 'U' => 1, 'V' => 2, 'W' => 3, 'X' => 4, 'Y' => 5, 'Z' => 0, - ); - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_royalmail'; - - /** - * Validates the checksum () - * - * @param string $value The barcode to validate - * @return boolean - */ - protected function _royalmail($value) - { - $checksum = substr($value, -1, 1); - $values = str_split(substr($value, 0, -1)); - $rowvalue = 0; - $colvalue = 0; - foreach($values as $row) { - $rowvalue += $this->_rows[$row]; - $colvalue += $this->_columns[$row]; - } - - $rowvalue %= 6; - $colvalue %= 6; - - $rowchkvalue = array_keys($this->_rows, $rowvalue); - $colchkvalue = array_keys($this->_columns, $colvalue); - $chkvalue = current(array_intersect($rowchkvalue, $colchkvalue)); - if ($chkvalue == $checksum) { - return true; - } - - return false; - } - - /** - * Allows start and stop tag within checked chars - * - * @param string $value The barcode to check for allowed characters - * @return boolean - */ - public function checkChars($value) - { - if ($value[0] == '(') { - $value = substr($value, 1); - - if ($value[strlen($value) - 1] == ')') { - $value = substr($value, 0, -1); - } else { - return false; - } - } - - return parent::checkChars($value); - } -} diff --git a/libs/Zend/Validate/Barcode/Sscc.php b/libs/Zend/Validate/Barcode/Sscc.php deleted file mode 100644 index b44b19a561..0000000000 --- a/libs/Zend/Validate/Barcode/Sscc.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ean13.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Sscc extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 18; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/UpcA.php b/libs/Zend/Validate/Barcode/UpcA.php new file mode 100644 index 0000000000..cf33f31fab --- /dev/null +++ b/libs/Zend/Validate/Barcode/UpcA.php @@ -0,0 +1,103 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Validate + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id: UpcA.php 16223 2009-06-21 20:04:53Z thomas $ + */ + + +/** + * @see Zend_Validate_Abstract + */ +require_once 'Zend/Validate/Abstract.php'; + + +/** + * @category Zend + * @package Zend_Validate + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Validate_Barcode_UpcA extends Zend_Validate_Abstract +{ + /** + * Validation failure message key for when the value is + * an invalid barcode + */ + const INVALID = 'invalid'; + + /** + * Validation failure message key for when the value is + * not 12 characters long + */ + const INVALID_LENGTH = 'invalidLength'; + + /** + * Validation failure message template definitions + * + * @var array + */ + protected $_messageTemplates = array( + self::INVALID => "'%value%' is an invalid UPC-A barcode", + self::INVALID_LENGTH => "'%value%' should be 12 characters", + ); + + /** + * Defined by Zend_Validate_Interface + * + * Returns true if and only if $value contains a valid barcode + * + * @param string $value + * @return boolean + */ + public function isValid($value) + { + if (!is_string($value)) { + $this->_error(self::INVALID); + return false; + } + + $this->_setValue($value); + if (strlen($value) !== 12) { + $this->_error(self::INVALID_LENGTH); + return false; + } + + $barcode = substr($value, 0, -1); + $oddSum = 0; + $evenSum = 0; + + for ($i = 0; $i < 11; $i++) { + if ($i % 2 === 0) { + $oddSum += $barcode[$i] * 3; + } elseif ($i % 2 === 1) { + $evenSum += $barcode[$i]; + } + } + + $calculation = ($oddSum + $evenSum) % 10; + $checksum = ($calculation === 0) ? 0 : 10 - $calculation; + + if ($value[11] != $checksum) { + $this->_error(self::INVALID); + return false; + } + + return true; + } +} diff --git a/libs/Zend/Validate/Barcode/Upca.php b/libs/Zend/Validate/Barcode/Upca.php deleted file mode 100644 index 2f0411ef95..0000000000 --- a/libs/Zend/Validate/Barcode/Upca.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Upca.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Upca extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = 12; - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; -} diff --git a/libs/Zend/Validate/Barcode/Upce.php b/libs/Zend/Validate/Barcode/Upce.php deleted file mode 100644 index 3199f19b90..0000000000 --- a/libs/Zend/Validate/Barcode/Upce.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: UpcA.php 18028 2009-09-08 20:52:23Z thomas $ - */ - -/** - * @see Zend_Validate_Barcode_AdapterAbstract - */ -// require_once 'Zend/Validate/Barcode/AdapterAbstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Barcode_Upce extends Zend_Validate_Barcode_AdapterAbstract -{ - /** - * Allowed barcode lengths - * @var integer - */ - protected $_length = array(6, 7, 8); - - /** - * Allowed barcode characters - * @var string - */ - protected $_characters = '0123456789'; - - /** - * Checksum function - * @var string - */ - protected $_checksum = '_gtin'; - - /** - * Overrides parent checkLength - * - * @param string $value Value - * @return boolean - */ - public function checkLength($value) - { - if (strlen($value) != 8) { - $this->setCheck(false); - } else { - $this->setCheck(true); - } - - return parent::checkLength($value); - } -} diff --git a/libs/Zend/Validate/Between.php b/libs/Zend/Validate/Between.php index 7245295dbb..b9fd7c2dc6 100644 --- a/libs/Zend/Validate/Between.php +++ b/libs/Zend/Validate/Between.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,20 +15,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Between.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Between.php 16223 2009-06-21 20:04:53Z thomas $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Between extends Zend_Validate_Abstract @@ -88,44 +91,17 @@ class Zend_Validate_Between extends Zend_Validate_Abstract /** * Sets validator options - * Accepts the following option keys: - * 'min' => scalar, minimum border - * 'max' => scalar, maximum border - * 'inclusive' => boolean, inclusive border values * - * @param array|Zend_Config $options + * @param mixed $min + * @param mixed $max + * @param boolean $inclusive * @return void */ - public function __construct($options) + public function __construct($min, $max, $inclusive = true) { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['min'] = array_shift($options); - if (!empty($options)) { - $temp['max'] = array_shift($options); - } - - if (!empty($options)) { - $temp['inclusive'] = array_shift($options); - } - - $options = $temp; - } - - if (!array_key_exists('min', $options) || !array_key_exists('max', $options)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Missing option. 'min' and 'max' has to be given"); - } - - if (!array_key_exists('inclusive', $options)) { - $options['inclusive'] = true; - } - - $this->setMin($options['min']) - ->setMax($options['max']) - ->setInclusive($options['inclusive']); + $this->setMin($min) + ->setMax($max) + ->setInclusive($inclusive); } /** diff --git a/libs/Zend/Validate/Callback.php b/libs/Zend/Validate/Callback.php deleted file mode 100644 index 398e27324c..0000000000 --- a/libs/Zend/Validate/Callback.php +++ /dev/null @@ -1,174 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Callback.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Validate_Abstract - */ -// require_once 'Zend/Validate/Abstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Callback extends Zend_Validate_Abstract -{ - /** - * Invalid callback - */ - const INVALID_CALLBACK = 'callbackInvalid'; - - /** - * Invalid value - */ - const INVALID_VALUE = 'callbackValue'; - - /** - * Validation failure message template definitions - * - * @var array - */ - protected $_messageTemplates = array( - self::INVALID_VALUE => "'%value%' is not valid", - self::INVALID_CALLBACK => "Failure within the callback, exception returned", - ); - - /** - * Callback in a call_user_func format - * - * @var string|array - */ - protected $_callback = null; - - /** - * Default options to set for the filter - * - * @var mixed - */ - protected $_options = array(); - - /** - * Sets validator options - * - * @param string|array $callback - * @param mixed $max - * @param boolean $inclusive - * @return void - */ - public function __construct($callback = null) - { - if (is_callable($callback)) { - $this->setCallback($callback); - } elseif (is_array($callback)) { - if (isset($callback['callback'])) { - $this->setCallback($callback['callback']); - } - if (isset($callback['options'])) { - $this->setOptions($callback['options']); - } - } - - if (null === ($initializedCallack = $this->getCallback())) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('No callback registered'); - } - } - - /** - * Returns the set callback - * - * @return mixed - */ - public function getCallback() - { - return $this->_callback; - } - - /** - * Sets the callback - * - * @param string|array $callback - * @return Zend_Validate_Callback Provides a fluent interface - */ - public function setCallback($callback) - { - if (!is_callable($callback)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Invalid callback given'); - } - $this->_callback = $callback; - return $this; - } - - /** - * Returns the set options for the callback - * - * @return mixed - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Sets options for the callback - * - * @param mixed $max - * @return Zend_Validate_Callback Provides a fluent interface - */ - public function setOptions($options) - { - $this->_options = (array) $options; - return $this; - } - - /** - * Defined by Zend_Validate_Interface - * - * Returns true if and only if the set callback returns - * for the provided $value - * - * @param mixed $value - * @return boolean - */ - public function isValid($value) - { - $this->_setValue($value); - - $options = $this->getOptions(); - $callback = $this->getCallback(); - $args = func_get_args(); - $options = array_merge($args, $options); - - try { - if (!call_user_func_array($callback, $options)) { - $this->_error(self::INVALID_VALUE); - return false; - } - } catch (Exception $e) { - $this->_error(self::INVALID_CALLBACK); - return false; - } - - return true; - } -} diff --git a/libs/Zend/Validate/Ccnum.php b/libs/Zend/Validate/Ccnum.php index 8c2a8beb14..489573c48d 100644 --- a/libs/Zend/Validate/Ccnum.php +++ b/libs/Zend/Validate/Ccnum.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,20 +15,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ccnum.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Ccnum.php 16223 2009-06-21 20:04:53Z thomas $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Ccnum extends Zend_Validate_Abstract @@ -59,11 +62,6 @@ class Zend_Validate_Ccnum extends Zend_Validate_Abstract self::CHECKSUM => "Luhn algorithm (mod-10 checksum) failed on '%value%'" ); - public function __construct() - { - trigger_error('Using the Ccnum validator is deprecated in favor of the CreditCard validator'); - } - /** * Defined by Zend_Validate_Interface * @@ -80,7 +78,7 @@ class Zend_Validate_Ccnum extends Zend_Validate_Abstract /** * @see Zend_Filter_Digits */ - // require_once 'Zend/Filter/Digits.php'; + require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } @@ -109,4 +107,5 @@ class Zend_Validate_Ccnum extends Zend_Validate_Abstract return true; } + } diff --git a/libs/Zend/Validate/CreditCard.php b/libs/Zend/Validate/CreditCard.php deleted file mode 100644 index 9c8c039718..0000000000 --- a/libs/Zend/Validate/CreditCard.php +++ /dev/null @@ -1,317 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CreditCard.php 21570 2010-03-19 19:00:50Z thomas $ - */ - -/** - * @see Zend_Validate_Abstract - */ -// require_once 'Zend/Validate/Abstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_CreditCard extends Zend_Validate_Abstract -{ - /** - * Detected CCI list - * - * @var string - */ - const ALL = 'All'; - const AMERICAN_EXPRESS = 'American_Express'; - const UNIONPAY = 'Unionpay'; - const DINERS_CLUB = 'Diners_Club'; - const DINERS_CLUB_US = 'Diners_Club_US'; - const DISCOVER = 'Discover'; - const JCB = 'JCB'; - const LASER = 'Laser'; - const MAESTRO = 'Maestro'; - const MASTERCARD = 'Mastercard'; - const SOLO = 'Solo'; - const VISA = 'Visa'; - - const CHECKSUM = 'creditcardChecksum'; - const CONTENT = 'creditcardContent'; - const INVALID = 'creditcardInvalid'; - const LENGTH = 'creditcardLength'; - const PREFIX = 'creditcardPrefix'; - const SERVICE = 'creditcardService'; - const SERVICEFAILURE = 'creditcardServiceFailure'; - - /** - * Validation failure message template definitions - * - * @var array - */ - protected $_messageTemplates = array( - self::CHECKSUM => "Luhn algorithm (mod-10 checksum) failed on '%value%'", - self::CONTENT => "'%value%' must contain only digits", - self::INVALID => "Invalid type given, value should be a string", - self::LENGTH => "'%value%' contains an invalid amount of digits", - self::PREFIX => "'%value%' is not from an allowed institute", - self::SERVICE => "Validation of '%value%' has been failed by the service", - self::SERVICEFAILURE => "The service returned a failure while validating '%value%'", - ); - - /** - * List of allowed CCV lengths - * - * @var array - */ - protected $_cardLength = array( - self::AMERICAN_EXPRESS => array(15), - self::DINERS_CLUB => array(14), - self::DINERS_CLUB_US => array(16), - self::DISCOVER => array(16), - self::JCB => array(16), - self::LASER => array(16, 17, 18, 19), - self::MAESTRO => array(12, 13, 14, 15, 16, 17, 18, 19), - self::MASTERCARD => array(16), - self::SOLO => array(16, 18, 19), - self::UNIONPAY => array(16, 17, 18, 19), - self::VISA => array(16), - ); - - /** - * List of accepted CCV provider tags - * - * @var array - */ - protected $_cardType = array( - self::AMERICAN_EXPRESS => array('34', '37'), - self::DINERS_CLUB => array('300', '301', '302', '303', '304', '305', '36'), - self::DINERS_CLUB_US => array('54', '55'), - self::DISCOVER => array('6011', '622126', '622127', '622128', '622129', '62213', - '62214', '62215', '62216', '62217', '62218', '62219', - '6222', '6223', '6224', '6225', '6226', '6227', '6228', - '62290', '62291', '622920', '622921', '622922', '622923', - '622924', '622925', '644', '645', '646', '647', '648', - '649', '65'), - self::JCB => array('3528', '3529', '353', '354', '355', '356', '357', '358'), - self::LASER => array('6304', '6706', '6771', '6709'), - self::MAESTRO => array('5018', '5020', '5038', '6304', '6759', '6761', '6763'), - self::MASTERCARD => array('51', '52', '53', '54', '55'), - self::SOLO => array('6334', '6767'), - self::UNIONPAY => array('622126', '622127', '622128', '622129', '62213', '62214', - '62215', '62216', '62217', '62218', '62219', '6222', '6223', - '6224', '6225', '6226', '6227', '6228', '62290', '62291', - '622920', '622921', '622922', '622923', '622924', '622925'), - self::VISA => array('4'), - ); - - /** - * CCIs which are accepted by validation - * - * @var array - */ - protected $_type = array(); - - /** - * Service callback for additional validation - * - * @var callback - */ - protected $_service; - - /** - * Constructor - * - * @param string|array $type OPTIONAL Type of CCI to allow - */ - public function __construct($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['type'] = array_shift($options); - if (!empty($options)) { - $temp['service'] = array_shift($options); - } - - $options = $temp; - } - - if (!array_key_exists('type', $options)) { - $options['type'] = self::ALL; - } - - $this->setType($options['type']); - if (array_key_exists('service', $options)) { - $this->setService($options['service']); - } - } - - /** - * Returns a list of accepted CCIs - * - * @return array - */ - public function getType() - { - return $this->_type; - } - - /** - * Sets CCIs which are accepted by validation - * - * @param string|array $type Type to allow for validation - * @return Zend_Validate_CreditCard Provides a fluid interface - */ - public function setType($type) - { - $this->_type = array(); - return $this->addType($type); - } - - /** - * Adds a CCI to be accepted by validation - * - * @param string|array $type Type to allow for validation - * @return Zend_Validate_CreditCard Provides a fluid interface - */ - public function addType($type) - { - if (is_string($type)) { - $type = array($type); - } - - foreach($type as $typ) { - if (defined('self::' . strtoupper($typ)) && !in_array($typ, $this->_type)) { - $this->_type[] = $typ; - } - - if (($typ == self::ALL)) { - $this->_type = array_keys($this->_cardLength); - } - } - - return $this; - } - - /** - * Returns the actual set service - * - * @return callback - */ - public function getService() - { - return $this->_service; - } - - /** - * Sets a new callback for service validation - * - * @param unknown_type $service - */ - public function setService($service) - { - if (!is_callable($service)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Invalid callback given'); - } - - $this->_service = $service; - return $this; - } - - /** - * Defined by Zend_Validate_Interface - * - * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum) - * - * @param string $value - * @return boolean - */ - public function isValid($value) - { - $this->_setValue($value); - - if (!is_string($value)) { - $this->_error(self::INVALID, $value); - return false; - } - - if (!ctype_digit($value)) { - $this->_error(self::CONTENT, $value); - return false; - } - - $length = strlen($value); - $types = $this->getType(); - $foundp = false; - $foundl = false; - foreach ($types as $type) { - foreach ($this->_cardType[$type] as $prefix) { - if (substr($value, 0, strlen($prefix)) == $prefix) { - $foundp = true; - if (in_array($length, $this->_cardLength[$type])) { - $foundl = true; - break 2; - } - } - } - } - - if ($foundp == false){ - $this->_error(self::PREFIX, $value); - return false; - } - - if ($foundl == false) { - $this->_error(self::LENGTH, $value); - return false; - } - - $sum = 0; - $weight = 2; - - for ($i = $length - 2; $i >= 0; $i--) { - $digit = $weight * $value[$i]; - $sum += floor($digit / 10) + $digit % 10; - $weight = $weight % 2 + 1; - } - - if ((10 - $sum % 10) % 10 != $value[$length - 1]) { - $this->_error(self::CHECKSUM, $value); - return false; - } - - if (!empty($this->_service)) { - try { - // require_once 'Zend/Validate/Callback.php'; - $callback = new Zend_Validate_Callback($this->_service); - $callback->setOptions($this->_type); - if (!$callback->isValid($value)) { - $this->_error(self::SERVICE, $value); - return false; - } - } catch (Zend_Exception $e) { - $this->_error(self::SERVICEFAILURE, $value); - return false; - } - } - - return true; - } -} diff --git a/libs/Zend/Validate/Date.php b/libs/Zend/Validate/Date.php index 22e49b7aee..5dbcc6d702 100644 --- a/libs/Zend/Validate/Date.php +++ b/libs/Zend/Validate/Date.php @@ -14,26 +14,27 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Date.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Date.php 17696 2009-08-20 20:12:33Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Date extends Zend_Validate_Abstract { const INVALID = 'dateInvalid'; - const INVALID_DATE = 'dateInvalidDate'; + const NOT_YYYY_MM_DD = 'dateNotYYYY-MM-DD'; + const INVALID_DATE = 'dateInvalidDate'; const FALSEFORMAT = 'dateFalseFormat'; /** @@ -43,15 +44,9 @@ class Zend_Validate_Date extends Zend_Validate_Abstract */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be string, integer, array or Zend_Date", + self::NOT_YYYY_MM_DD => "'%value%' is not of the format YYYY-MM-DD", self::INVALID_DATE => "'%value%' does not appear to be a valid date", - self::FALSEFORMAT => "'%value%' does not fit the date format '%format%'", - ); - - /** - * @var array - */ - protected $_messageVariables = array( - 'format' => '_format' + self::FALSEFORMAT => "'%value%' does not fit given date format" ); /** @@ -71,36 +66,22 @@ class Zend_Validate_Date extends Zend_Validate_Abstract /** * Sets validator options * - * @param string|Zend_Config $options OPTIONAL + * @param string $format OPTIONAL + * @param string|Zend_Locale $locale OPTIONAL * @return void */ - public function __construct($options = array()) + public function __construct($format = null, $locale = null) { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['format'] = array_shift($options); - if (!empty($options)) { - $temp['locale'] = array_shift($options); - } - - $options = $temp; - } - - if (array_key_exists('format', $options)) { - $this->setFormat($options['format']); - } - - if (!array_key_exists('locale', $options)) { - // require_once 'Zend/Registry.php'; + $this->setFormat($format); + if ($locale === null) { + require_once 'Zend/Registry.php'; if (Zend_Registry::isRegistered('Zend_Locale')) { - $options['locale'] = Zend_Registry::get('Zend_Locale'); + $locale = Zend_Registry::get('Zend_Locale'); } } - if (array_key_exists('locale', $options)) { - $this->setLocale($options['locale']); + if ($locale !== null) { + $this->setLocale($locale); } } @@ -122,7 +103,7 @@ class Zend_Validate_Date extends Zend_Validate_Abstract */ public function setLocale($locale = null) { - // require_once 'Zend/Locale.php'; + require_once 'Zend/Locale.php'; $this->_locale = Zend_Locale::findLocale($locale); return $this; } @@ -171,7 +152,7 @@ class Zend_Validate_Date extends Zend_Validate_Abstract if (($this->_format !== null) || ($this->_locale !== null) || is_array($value) || $value instanceof Zend_Date) { - // require_once 'Zend/Date.php'; + require_once 'Zend/Date.php'; if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) { if ($this->_checkFormat($value) === false) { $this->_error(self::FALSEFORMAT); @@ -182,9 +163,7 @@ class Zend_Validate_Date extends Zend_Validate_Abstract } } else { if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) { - $this->_format = 'yyyy-MM-dd'; - $this->_error(self::FALSEFORMAT); - $this->_format = null; + $this->_error(self::NOT_YYYY_MM_DD); return false; } @@ -208,7 +187,7 @@ class Zend_Validate_Date extends Zend_Validate_Abstract private function _checkFormat($value) { try { - // require_once 'Zend/Locale/Format.php'; + require_once 'Zend/Locale/Format.php'; $parsed = Zend_Locale_Format::getDate($value, array( 'date_format' => $this->_format, 'format_type' => 'iso', 'fix_date' => false)); diff --git a/libs/Zend/Validate/Db/Abstract.php b/libs/Zend/Validate/Db/Abstract.php index 5811c495a9..e5103ff4ed 100644 --- a/libs/Zend/Validate/Db/Abstract.php +++ b/libs/Zend/Validate/Db/Abstract.php @@ -1,4 +1,5 @@ -<?php +<?php + /** * Zend Framework * @@ -14,285 +15,134 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 22225 2010-05-21 09:12:52Z bittarman $ - */ - + * @version $Id: Abstract.php 17160 2009-07-26 19:46:24Z bittarman $ + */ + /** * @see Zend_Validate_Abstract - */ -// require_once 'Zend/Validate/Abstract.php'; - + */ +require_once 'Zend/Validate/Abstract.php'; + /** * Class for Database record validation - * + * * @category Zend * @package Zend_Validate * @uses Zend_Validate_Abstract - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract -{ + */ +abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract +{ /** * Error constants - */ - const ERROR_NO_RECORD_FOUND = 'noRecordFound'; - const ERROR_RECORD_FOUND = 'recordFound'; - + */ + const ERROR_NO_RECORD_FOUND = 'noRecordFound'; + const ERROR_RECORD_FOUND = 'recordFound'; + /** * @var array Message templates - */ - protected $_messageTemplates = array( - self::ERROR_NO_RECORD_FOUND => 'No record matching %value% was found', - self::ERROR_RECORD_FOUND => 'A record matching %value% was found', - ); + */ + protected $_messageTemplates = array(self::ERROR_NO_RECORD_FOUND => 'No record matching %value% was found', + self::ERROR_RECORD_FOUND => 'A record matching %value% was found'); /** * @var string - */ + */ protected $_schema = null; - + /** * @var string - */ - protected $_table = ''; - + */ + protected $_table = ''; + /** * @var string - */ - protected $_field = ''; - + */ + protected $_field = ''; + /** * @var mixed - */ - protected $_exclude = null; - + */ + protected $_exclude = null; + /** * Database adapter to use. If null isValid() will use Zend_Db::getInstance instead * * @var unknown_type - */ - protected $_adapter = null; - + */ + protected $_adapter = null; + /** - * Provides basic configuration for use with Zend_Validate_Db Validators + * Provides basic configuration for use with Zend_Validate_Db Validators * Setting $exclude allows a single record to be excluded from matching. * Exclude can either be a String containing a where clause, or an array with `field` and `value` keys - * to define the where clause added to the sql. - * A database adapter may optionally be supplied to avoid using the registered default adapter. - * - * The following option keys are supported: - * 'table' => The database table to validate against - * 'schema' => The schema keys - * 'field' => The field to check for a match - * 'exclude' => An optional where clause or field/value pair to exclude from the query - * 'adapter' => An optional database adapter to use - * - * @param array|Zend_Config $options Options to use for this validator - */ - public function __construct($options) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (func_num_args() > 1) { - $options = func_get_args(); - $temp['table'] = array_shift($options); - $temp['field'] = array_shift($options); - if (!empty($options)) { - $temp['exclude'] = array_shift($options); - } - - if (!empty($options)) { - $temp['adapter'] = array_shift($options); - } - - $options = $temp; - } - - if (!array_key_exists('table', $options) && !array_key_exists('schema', $options)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Table or Schema option missing!'); - } - - if (!array_key_exists('field', $options)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Field option missing!'); - } - - if (array_key_exists('adapter', $options)) { - $this->setAdapter($options['adapter']); - } - - if (array_key_exists('exclude', $options)) { - $this->setExclude($options['exclude']); - } - - $this->setField($options['field']); - if (array_key_exists('table', $options)) { - $this->setTable($options['table']); - } - - if (array_key_exists('schema', $options)) { - $this->setSchema($options['schema']); + * to define the where clause added to the sql. + * A database adapter may optionally be supplied to avoid using the registered default adapter. + * + * @param string||array $table The database table to validate against, or array with table and schema keys + * @param string $field The field to check for a match + * @param string||array $exclude An optional where clause or field/value pair to exclude from the query + * @param Zend_Db_Adapter_Abstract $adapter An optional database adapter to use. + */ + public function __construct($table, $field, $exclude = null, Zend_Db_Adapter_Abstract $adapter = null) + { + if ($adapter !== null) { + $this->_adapter = $adapter; + } + $this->_exclude = $exclude; + $this->_field = (string) $field; + + if (is_array($table)) { + $this->_table = (isset($table['table'])) ? $table['table'] : ''; + $this->_schema = (isset($table['schema'])) ? $table['schema'] : null; + } else { + $this->_table = (string) $table; } - } - - /** - * Returns the set adapter - * - * @return Zend_Db_Adapter - */ - public function getAdapter() - { - return $this->_adapter; - } - - /** - * Sets a new database adapter - * - * @param Zend_Db_Adapter_Abstract $adapter - * @return Zend_Validate_Db_Abstract - */ - public function setAdapter($adapter) - { - if (!($adapter instanceof Zend_Db_Adapter_Abstract)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Adapter option must be a database adapter!'); - } - - $this->_adapter = $adapter; - return $this; - } - - /** - * Returns the set exclude clause - * - * @return string|array - */ - public function getExclude() - { - return $this->_exclude; - } - - /** - * Sets a new exclude clause - * - * @param string|array $exclude - * @return Zend_Validate_Db_Abstract - */ - public function setExclude($exclude) - { - $this->_exclude = $exclude; - return $this; - } - - /** - * Returns the set field - * - * @return string|array - */ - public function getField() - { - return $this->_field; - } - - /** - * Sets a new field - * - * @param string $field - * @return Zend_Validate_Db_Abstract - */ - public function setField($field) - { - $this->_field = (string) $field; - return $this; - } - - /** - * Returns the set table - * - * @return string - */ - public function getTable() - { - return $this->_table; - } - - /** - * Sets a new table - * - * @param string $table - * @return Zend_Validate_Db_Abstract - */ - public function setTable($table) - { - $this->_table = (string) $table; - return $this; - } - - /** - * Returns the set schema - * - * @return string - */ - public function getSchema() - { - return $this->_schema; - } - - /** - * Sets a new schema - * - * @param string $schema - * @return Zend_Validate_Db_Abstract - */ - public function setSchema($schema) - { - $this->_schema = $schema; - return $this; - } + } + /** * Run query and returns matches, or null if no matches are found. * * @param String $value * @return Array when matches are found. - */ - protected function _query($value) - { + */ + protected function _query($value) + { /** * Check for an adapter being defined. if not, fetch the default adapter. - */ + */ if ($this->_adapter === null) { $this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); if (null === $this->_adapter) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('No database adapter present'); } } /** * Build select object - */ + */ $select = new Zend_Db_Select($this->_adapter); $select->from($this->_table, array($this->_field), $this->_schema) - ->where($this->_adapter->quoteIdentifier($this->_field, true).' = ?', $value); - if ($this->_exclude !== null) { - if (is_array($this->_exclude)) { - $select->where($this->_adapter->quoteIdentifier($this->_exclude['field'], true).' != ?', $this->_exclude['value']); - } else { - $select->where($this->_exclude); - } - } - $select->limit(1); - + ->where($this->_adapter->quoteIdentifier($this->_field).' = ?', $value); + if ($this->_exclude !== null) { + if (is_array($this->_exclude)) { + $select->where($this->_adapter->quoteIdentifier($this->_exclude['field']).' != ?', $this->_exclude['value']); + } else { + $select->where($this->_exclude); + } + } + $select->limit(1); + /** * Run query - */ - $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); - - return $result; - } + */ + $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); + + return $result; + } } diff --git a/libs/Zend/Validate/Db/NoRecordExists.php b/libs/Zend/Validate/Db/NoRecordExists.php index 700102e436..e9c0db49a8 100644 --- a/libs/Zend/Validate/Db/NoRecordExists.php +++ b/libs/Zend/Validate/Db/NoRecordExists.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,15 +15,15 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NoRecordExists.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: NoRecordExists.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_Db_Abstract */ -// require_once 'Zend/Validate/Db/Abstract.php'; +require_once 'Zend/Validate/Db/Abstract.php'; /** * Confirms a record does not exist in a table. @@ -30,7 +31,7 @@ * @category Zend * @package Zend_Validate * @uses Zend_Validate_Db_Abstract - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Db_NoRecordExists extends Zend_Validate_Db_Abstract diff --git a/libs/Zend/Validate/Db/RecordExists.php b/libs/Zend/Validate/Db/RecordExists.php index bf96b96f5c..2d753e4b0a 100644 --- a/libs/Zend/Validate/Db/RecordExists.php +++ b/libs/Zend/Validate/Db/RecordExists.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,38 +15,39 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RecordExists.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - + * @version $Id: RecordExists.php 16971 2009-07-22 18:05:45Z mikaelkael $ + */ + + /** * @see Zend_Validate_Db_Abstract - */ -// require_once 'Zend/Validate/Db/Abstract.php'; - + */ +require_once 'Zend/Validate/Db/Abstract.php'; + /** * Confirms a record exists in a table. - * + * * @category Zend * @package Zend_Validate * @uses Zend_Validate_Db_Abstract - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Db_RecordExists extends Zend_Validate_Db_Abstract -{ - public function isValid($value) - { - $valid = true; - $this->_setValue($value); - - $result = $this->_query($value); - if (!$result) { - $valid = false; - $this->_error(self::ERROR_NO_RECORD_FOUND); - } - - return $valid; - } + */ +class Zend_Validate_Db_RecordExists extends Zend_Validate_Db_Abstract +{ + public function isValid($value) + { + $valid = true; + $this->_setValue($value); + + $result = $this->_query($value); + if (!$result) { + $valid = false; + $this->_error(self::ERROR_NO_RECORD_FOUND); + } + + return $valid; + } } diff --git a/libs/Zend/Validate/Digits.php b/libs/Zend/Validate/Digits.php index 9194568e27..12e6c4e454 100644 --- a/libs/Zend/Validate/Digits.php +++ b/libs/Zend/Validate/Digits.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,26 +15,28 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Digits.php 21136 2010-02-22 22:30:50Z thomas $ + * @version $Id: Digits.php 16933 2009-07-21 20:24:35Z matthew $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Digits extends Zend_Validate_Abstract { const NOT_DIGITS = 'notDigits'; - const STRING_EMPTY = 'digitsStringEmpty'; + const STRING_EMPTY = 'stringEmpty'; const INVALID = 'digitsInvalid'; /** @@ -49,7 +52,7 @@ class Zend_Validate_Digits extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_DIGITS => "'%value%' contains characters which are not digits; but only digits are allowed", + self::NOT_DIGITS => "'%value%' contains not only digit characters", self::STRING_EMPTY => "'%value%' is an empty string", self::INVALID => "Invalid type given, value should be string, integer or float", ); @@ -77,7 +80,7 @@ class Zend_Validate_Digits extends Zend_Validate_Abstract } if (null === self::$_filter) { - // require_once 'Zend/Filter/Digits.php'; + require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } @@ -88,4 +91,5 @@ class Zend_Validate_Digits extends Zend_Validate_Abstract return true; } + } diff --git a/libs/Zend/Validate/EmailAddress.php b/libs/Zend/Validate/EmailAddress.php index c008dcfe9f..4948bb83f3 100644 --- a/libs/Zend/Validate/EmailAddress.php +++ b/libs/Zend/Validate/EmailAddress.php @@ -14,25 +14,25 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EmailAddress.php 21461 2010-03-10 22:34:03Z thomas $ + * @version $Id: EmailAddress.php 16223 2009-06-21 20:04:53Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @see Zend_Validate_Hostname */ -// require_once 'Zend/Validate/Hostname.php'; +require_once 'Zend/Validate/Hostname.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract @@ -41,7 +41,6 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract const INVALID_FORMAT = 'emailAddressInvalidFormat'; const INVALID_HOSTNAME = 'emailAddressInvalidHostname'; const INVALID_MX_RECORD = 'emailAddressInvalidMxRecord'; - const INVALID_SEGMENT = 'emailAddressInvalidSegment'; const DOT_ATOM = 'emailAddressDotAtom'; const QUOTED_STRING = 'emailAddressQuotedString'; const INVALID_LOCAL_PART = 'emailAddressInvalidLocalPart'; @@ -52,38 +51,13 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be a string", - self::INVALID_FORMAT => "'%value%' is no valid email address in the basic format local-part@hostname", - self::INVALID_HOSTNAME => "'%hostname%' is no valid hostname for email address '%value%'", + self::INVALID_FORMAT => "'%value%' is not a valid email address in the basic format local-part@hostname", + self::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'", self::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'", - self::INVALID_SEGMENT => "'%hostname%' is not in a routable network segment. The email address '%value%' should not be resolved from public network.", - self::DOT_ATOM => "'%localPart%' can not be matched against dot-atom format", - self::QUOTED_STRING => "'%localPart%' can not be matched against quoted-string format", - self::INVALID_LOCAL_PART => "'%localPart%' is no valid local part for email address '%value%'", - self::LENGTH_EXCEEDED => "'%value%' exceeds the allowed length", - ); - - /** - * @see http://en.wikipedia.org/wiki/IPv4 - * @var array - */ - protected $_invalidIp = array( - '0' => '0.0.0.0/8', - '10' => '10.0.0.0/8', - '127' => '127.0.0.0/8', - '128' => '128.0.0.0/16', - '169' => '169.254.0.0/16', - '172' => '172.16.0.0/12', - '191' => '191.255.0.0/16', - '192' => array( - '192.0.0.0/24', - '192.0.2.0/24', - '192.88.99.0/24', - '192.168.0.0/16' - ), - '198' => '198.18.0.0/15', - '223' => '223.255.255.0/24', - '224' => '224.0.0.0/4', - '240' => '240.0.0.0/4' + self::DOT_ATOM => "'%localPart%' not matched against dot-atom format", + self::QUOTED_STRING => "'%localPart%' not matched against quoted-string format", + self::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'", + self::LENGTH_EXCEEDED => "'%value%' exceeds the allowed length" ); /** @@ -95,128 +69,46 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract ); /** - * @var string - */ - protected $_hostname; - - /** - * @var string - */ - protected $_localPart; - - /** - * Internal options array + * Local object for validating the hostname part of an email address + * + * @var Zend_Validate_Hostname + * @depreciated */ - protected $_options = array( - 'mx' => false, - 'deep' => false, - 'domain' => true, - 'allow' => Zend_Validate_Hostname::ALLOW_DNS, - 'hostname' => null - ); + public $hostnameValidator; /** - * Instantiates hostname validator for local use + * Whether we check for a valid MX record via DNS * - * The following option keys are supported: - * 'hostname' => A hostname validator, see Zend_Validate_Hostname - * 'allow' => Options for the hostname validator, see Zend_Validate_Hostname::ALLOW_* - * 'mx' => If MX check should be enabled, boolean - * 'deep' => If a deep MX check should be done, boolean - * - * @param array|Zend_Config $options OPTIONAL - * @return void + * @var boolean */ - public function __construct($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['allow'] = array_shift($options); - if (!empty($options)) { - $temp['mx'] = array_shift($options); - } - - if (!empty($options)) { - $temp['hostname'] = array_shift($options); - } - - $options = $temp; - } - - $options += $this->_options; - $this->setOptions($options); - } + protected $_validateMx = false; /** - * Returns all set Options - * - * @return array + * @var string */ - public function getOptions() - { - return $this->_options; - } + protected $_hostname; /** - * Set options for the email validator - * - * @param array $options - * @return Zend_Validate_EmailAddress fluid interface + * @var string */ - public function setOptions(array $options = array()) - { - if (array_key_exists('messages', $options)) { - $this->setMessages($options['messages']); - } - - if (array_key_exists('hostname', $options)) { - if (array_key_exists('allow', $options)) { - $this->setHostnameValidator($options['hostname'], $options['allow']); - } else { - $this->setHostnameValidator($options['hostname']); - } - } - - if (array_key_exists('mx', $options)) { - $this->setValidateMx($options['mx']); - } - - if (array_key_exists('deep', $options)) { - $this->setDeepMxCheck($options['deep']); - } - - if (array_key_exists('domain', $options)) { - $this->setDomainCheck($options['domain']); - } - - return $this; - } + protected $_localPart; /** - * Sets the validation failure message template for a particular key - * Adds the ability to set messages to the attached hostname validator + * Instantiates hostname validator for local use + * + * You can pass a bitfield to determine what types of hostnames are allowed. + * These bitfields are defined by the ALLOW_* constants in Zend_Validate_Hostname + * The default is to allow DNS hostnames only * - * @param string $messageString - * @param string $messageKey OPTIONAL - * @return Zend_Validate_Abstract Provides a fluent interface - * @throws Zend_Validate_Exception + * @param integer $allow OPTIONAL + * @param bool $validateMx OPTIONAL + * @param Zend_Validate_Hostname $hostnameValidator OPTIONAL + * @return void */ - public function setMessage($messageString, $messageKey = null) + public function __construct($allow = Zend_Validate_Hostname::ALLOW_DNS, $validateMx = false, Zend_Validate_Hostname $hostnameValidator = null) { - $messageKeys = $messageKey; - if ($messageKey === null) { - $keys = array_keys($this->_messageTemplates); - $messageKeys = current($keys); - } - - if (!isset($this->_messageTemplates[$messageKeys])) { - $this->_options['hostname']->setMessage($messageString, $messageKey); - } - - $this->_messageTemplates[$messageKeys] = $messageString; - return $this; + $this->setValidateMx($validateMx); + $this->setHostnameValidator($hostnameValidator, $allow); } /** @@ -226,7 +118,7 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract */ public function getHostnameValidator() { - return $this->_options['hostname']; + return $this->hostnameValidator; } /** @@ -236,17 +128,14 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract */ public function setHostnameValidator(Zend_Validate_Hostname $hostnameValidator = null, $allow = Zend_Validate_Hostname::ALLOW_DNS) { - if (!$hostnameValidator) { + if ($hostnameValidator === null) { $hostnameValidator = new Zend_Validate_Hostname($allow); } - - $this->_options['hostname'] = $hostnameValidator; - $this->_options['allow'] = $allow; - return $this; + $this->hostnameValidator = $hostnameValidator; } /** - * Whether MX checking via getmxrr is supported or not + * Whether MX checking via dns_get_mx is supported or not * * This currently only works on UNIX systems * @@ -254,17 +143,7 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract */ public function validateMxSupported() { - return function_exists('getmxrr'); - } - - /** - * Returns the set validateMx option - * - * @return boolean - */ - public function getValidateMx() - { - return $this->_options['mx']; + return function_exists('dns_get_mx'); } /** @@ -272,236 +151,11 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract * * This only applies when DNS hostnames are validated * - * @param boolean $mx Set allowed to true to validate for MX records, and false to not validate them - * @return Zend_Validate_EmailAddress Fluid Interface - */ - public function setValidateMx($mx) - { - if ((bool) $mx && !$this->validateMxSupported()) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('MX checking not available on this system'); - } - - $this->_options['mx'] = (bool) $mx; - return $this; - } - - /** - * Returns the set deepMxCheck option - * - * @return boolean - */ - public function getDeepMxCheck() - { - return $this->_options['deep']; - } - - /** - * Set whether we check MX record should be a deep validation - * - * @param boolean $deep Set deep to true to perform a deep validation process for MX records - * @return Zend_Validate_EmailAddress Fluid Interface + * @param boolean $allowed Set allowed to true to validate for MX records, and false to not validate them */ - public function setDeepMxCheck($deep) + public function setValidateMx($allowed) { - $this->_options['deep'] = (bool) $deep; - return $this; - } - - /** - * Returns the set domainCheck option - * - * @return unknown - */ - public function getDomainCheck() - { - return $this->_options['domain']; - } - - /** - * Sets if the domain should also be checked - * or only the local part of the email address - * - * @param boolean $domain - * @return Zend_Validate_EmailAddress Fluid Interface - */ - public function setDomainCheck($domain = true) - { - $this->_options['domain'] = (boolean) $domain; - return $this; - } - - /** - * Returns if the given host is reserved - * - * @param string $host - * @return boolean - */ - private function _isReserved($host){ - if (!preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $host)) { - $host = gethostbyname($host); - } - - $octet = explode('.',$host); - if ((int)$octet[0] >= 224) { - return true; - } else if (array_key_exists($octet[0], $this->_invalidIp)) { - foreach ((array)$this->_invalidIp[$octet[0]] as $subnetData) { - // we skip the first loop as we already know that octet matches - for ($i = 1; $i < 4; $i++) { - if (strpos($subnetData, $octet[$i]) !== $i * 4) { - break; - } - } - - $host = explode("/", $subnetData); - $binaryHost = ""; - $tmp = explode(".", $host[0]); - for ($i = 0; $i < 4 ; $i++) { - $binaryHost .= str_pad(decbin($tmp[$i]), 8, "0", STR_PAD_LEFT); - } - - $segmentData = array( - 'network' => (int)$this->_toIp(str_pad(substr($binaryHost, 0, $host[1]), 32, 0)), - 'broadcast' => (int)$this->_toIp(str_pad(substr($binaryHost, 0, $host[1]), 32, 1)) - ); - - for ($j = $i; $j < 4; $j++) { - if ((int)$octet[$j] < $segmentData['network'][$j] || - (int)$octet[$j] > $segmentData['broadcast'][$j]) { - return false; - } - } - } - - return true; - } else { - return false; - } - } - - /** - * Converts a binary string to an IP address - * - * @param string $binary - * @return mixed - */ - private function _toIp($binary) - { - $ip = array(); - $tmp = explode(".", chunk_split($binary, 8, ".")); - for ($i = 0; $i < 4 ; $i++) { - $ip[$i] = bindec($tmp[$i]); - } - - return $ip; - } - - /** - * Internal method to validate the local part of the email address - * - * @return boolean - */ - private function _validateLocalPart() - { - // First try to match the local part on the common dot-atom format - $result = false; - - // Dot-atom characters are: 1*atext *("." 1*atext) - // atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*", - // "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~" - $atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e'; - if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->_localPart)) { - $result = true; - } else { - // Try quoted string format - - // Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE - // qtext: Non white space controls, and the rest of the US-ASCII characters not - // including "\" or the quote character - $noWsCtl = '\x01-\x08\x0b\x0c\x0e-\x1f\x7f'; - $qtext = $noWsCtl . '\x21\x23-\x5b\x5d-\x7e'; - $ws = '\x20\x09'; - if (preg_match('/^\x22([' . $ws . $qtext . '])*[$ws]?\x22$/', $this->_localPart)) { - $result = true; - } else { - $this->_error(self::DOT_ATOM); - $this->_error(self::QUOTED_STRING); - $this->_error(self::INVALID_LOCAL_PART); - } - } - - return $result; - } - - /** - * Internal method to validate the servers MX records - * - * @return boolean - */ - private function _validateMXRecords() - { - $mxHosts = array(); - $result = getmxrr($this->_hostname, $mxHosts); - if (!$result) { - $this->_error(self::INVALID_MX_RECORD); - } else if ($this->_options['deep'] && function_exists('checkdnsrr')) { - $validAddress = false; - $reserved = true; - foreach ($mxHosts as $hostname) { - $res = $this->_isReserved($hostname); - if (!$res) { - $reserved = false; - } - - if (!$res - && (checkdnsrr($hostname, "A") - || checkdnsrr($hostname, "AAAA") - || checkdnsrr($hostname, "A6"))) { - $validAddress = true; - break; - } - } - - if (!$validAddress) { - $result = false; - if ($reserved) { - $this->_error(self::INVALID_SEGMENT); - } else { - $this->_error(self::INVALID_MX_RECORD); - } - } - } - - return $result; - } - - /** - * Internal method to validate the hostname part of the email address - * - * @return boolean - */ - private function _validateHostnamePart() - { - $hostname = $this->_options['hostname']->setTranslator($this->getTranslator()) - ->isValid($this->_hostname); - if (!$hostname) { - $this->_error(self::INVALID_HOSTNAME); - - // Get messages and errors from hostnameValidator - foreach ($this->_options['hostname']->getMessages() as $code => $message) { - $this->_messages[$code] = $message; - } - - foreach ($this->_options['hostname']->getErrors() as $error) { - $this->_errors[] = $error; - } - } else if ($this->_options['mx']) { - // MX check on hostname - $hostname = $this->_validateMXRecords(); - } - - return $hostname; + $this->_validateMx = (bool) $allowed; } /** @@ -522,8 +176,9 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract return false; } - $matches = array(); - $length = true; + $matches = array(); + $length = true; + $this->_setValue($value); // Split email address up and disallow '..' @@ -542,19 +197,68 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract } // Match hostname part - if ($this->_options['domain']) { - $hostname = $this->_validateHostnamePart(); + $hostnameResult = $this->hostnameValidator->setTranslator($this->getTranslator()) + ->isValid($this->_hostname); + if (!$hostnameResult) { + $this->_error(self::INVALID_HOSTNAME); + + // Get messages and errors from hostnameValidator + foreach ($this->hostnameValidator->getMessages() as $code => $message) { + $this->_messages[$code] = $message; + } + foreach ($this->hostnameValidator->getErrors() as $error) { + $this->_errors[] = $error; + } + } else if ($this->_validateMx) { + // MX check on hostname via dns_get_record() + if ($this->validateMxSupported()) { + $result = dns_get_mx($this->_hostname, $mxHosts); + if (count($mxHosts) < 1) { + $hostnameResult = false; + $this->_error(self::INVALID_MX_RECORD); + } + } else { + /** + * MX checks are not supported by this system + * @see Zend_Validate_Exception + */ + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception('Internal error: MX checking not available on this system'); + } } - $local = $this->_validateLocalPart(); + // First try to match the local part on the common dot-atom format + $localResult = false; - // If both parts valid, return true - if ($local && $length) { - if (($this->_options['domain'] && $hostname) || !$this->_options['domain']) { - return true; + // Dot-atom characters are: 1*atext *("." 1*atext) + // atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*", + // "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~" + $atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e'; + if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->_localPart)) { + $localResult = true; + } else { + // Try quoted string format + + // Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE + // qtext: Non white space controls, and the rest of the US-ASCII characters not + // including "\" or the quote character + $noWsCtl = '\x01-\x08\x0b\x0c\x0e-\x1f\x7f'; + $qtext = $noWsCtl . '\x21\x23-\x5b\x5d-\x7e'; + $ws = '\x20\x09'; + if (preg_match('/^\x22([' . $ws . $qtext . '])*[$ws]?\x22$/', $this->_localPart)) { + $localResult = true; + } else { + $this->_error(self::DOT_ATOM); + $this->_error(self::QUOTED_STRING); + $this->_error(self::INVALID_LOCAL_PART); } } - return false; + // If both parts valid, return true + if ($localResult && $hostnameResult && $length) { + return true; + } else { + return false; + } } } diff --git a/libs/Zend/Validate/Exception.php b/libs/Zend/Validate/Exception.php index fd34efe0c1..d6b646f1cd 100644 --- a/libs/Zend/Validate/Exception.php +++ b/libs/Zend/Validate/Exception.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,20 +15,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Exception.php 16223 2009-06-21 20:04:53Z thomas $ */ + /** * @see Zend_Exception */ -// require_once 'Zend/Exception.php'; +require_once 'Zend/Exception.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Exception extends Zend_Exception diff --git a/libs/Zend/Validate/File/Count.php b/libs/Zend/Validate/File/Count.php index a4bff7ee8c..f2dfac7413 100644 --- a/libs/Zend/Validate/File/Count.php +++ b/libs/Zend/Validate/File/Count.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Count.php 21326 2010-03-04 20:32:39Z thomas $ + * @version $Id: Count.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for counting all given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Count extends Zend_Validate_Abstract @@ -37,16 +37,16 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract /**#@+ * @const string Error constants */ - const TOO_MANY = 'fileCountTooMany'; - const TOO_FEW = 'fileCountTooFew'; + const TOO_MUCH = 'fileCountTooMuch'; + const TOO_LESS = 'fileCountTooLess'; /**#@-*/ /** * @var array Error message templates */ protected $_messageTemplates = array( - self::TOO_MANY => "Too many files, maximum '%max%' are allowed but '%count%' are given", - self::TOO_FEW => "Too few files, minimum '%min%' are expected but '%count%' are given", + self::TOO_MUCH => "Too much files, maximum '%max%' are allowed but '%count%' are given", + self::TOO_LESS => "Too less files, minimum '%min%' are expected but '%count%' are given" ); /** @@ -110,11 +110,13 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract } elseif (is_string($options) || is_numeric($options)) { $options = array('max' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple arguments are deprecated in favor of an array of named arguments', E_USER_NOTICE); $options['min'] = func_get_arg(0); $options['max'] = func_get_arg(1); } @@ -152,13 +154,13 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract } if (!is_string($min) and !is_numeric($min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $min = (integer) $min; if (($this->_max !== null) && ($min > $this->_max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum file count, but $min >" . " {$this->_max}"); } @@ -191,13 +193,13 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract } if (!is_string($max) and !is_numeric($max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $max = (integer) $max; if (($this->_min !== null) && ($max < $this->_min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but " . "$max < {$this->_min}"); } @@ -241,25 +243,14 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract */ public function isValid($value, $file = null) { - if (($file !== null) && !array_key_exists('destination', $file)) { - $file['destination'] = dirname($value); - } - - if (($file !== null) && array_key_exists('tmp_name', $file)) { - $value = $file['destination'] . DIRECTORY_SEPARATOR . $file['name']; - } - - if (($file === null) || !empty($file['tmp_name'])) { - $this->addFile($value); - } - + $this->addFile($value); $this->_count = count($this->_files); if (($this->_max !== null) && ($this->_count > $this->_max)) { - return $this->_throw($file, self::TOO_MANY); + return $this->_throw($file, self::TOO_MUCH); } if (($this->_min !== null) && ($this->_count < $this->_min)) { - return $this->_throw($file, self::TOO_FEW); + return $this->_throw($file, self::TOO_LESS); } return true; diff --git a/libs/Zend/Validate/File/Crc32.php b/libs/Zend/Validate/File/Crc32.php index 31b420585e..fd46d81b6b 100644 --- a/libs/Zend/Validate/File/Crc32.php +++ b/libs/Zend/Validate/File/Crc32.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Crc32.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Crc32.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_Hash */ -// require_once 'Zend/Validate/File/Hash.php'; +require_once 'Zend/Validate/File/Hash.php'; /** * Validator for the crc32 hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash @@ -45,9 +45,9 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given crc32 hashes", - self::NOT_DETECTED => "A crc32 hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found", + self::DOES_NOT_MATCH => "The file '%value%' does not match the given crc32 hashes", + self::NOT_DETECTED => "There was no crc32 hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -70,7 +70,7 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } @@ -157,7 +157,7 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/ExcludeExtension.php b/libs/Zend/Validate/File/ExcludeExtension.php index 94fb27bb6d..74264de98c 100644 --- a/libs/Zend/Validate/File/ExcludeExtension.php +++ b/libs/Zend/Validate/File/ExcludeExtension.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExcludeExtension.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: ExcludeExtension.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/File/Extension.php'; +require_once 'Zend/Validate/File/Extension.php'; /** * Validator for the excluding file extensions * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension @@ -44,8 +44,8 @@ class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_EXTENSION => "File '%value%' has a false extension", - self::NOT_FOUND => "File '%value%' could not be found", + self::FALSE_EXTENSION => "The file '%value%' has a false extension", + self::NOT_FOUND => "The file '%value%' was not found" ); /** @@ -61,7 +61,7 @@ class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/ExcludeMimeType.php b/libs/Zend/Validate/File/ExcludeMimeType.php index 436caa1f02..4984b79cfb 100644 --- a/libs/Zend/Validate/File/ExcludeMimeType.php +++ b/libs/Zend/Validate/File/ExcludeMimeType.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExcludeMimeType.php 21936 2010-04-18 16:23:34Z thomas $ + * @version $Id: ExcludeMimeType.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_MimeType */ -// require_once 'Zend/Validate/File/MimeType.php'; +require_once 'Zend/Validate/File/MimeType.php'; /** * Validator for the mime type of a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType @@ -59,7 +59,7 @@ class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType } // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } @@ -73,7 +73,7 @@ class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType $mime = new finfo($const); } - if (!empty($mime)) { + if ($mime !== false) { $this->_type = $mime->file($value); } unset($mime); diff --git a/libs/Zend/Validate/File/Exists.php b/libs/Zend/Validate/File/Exists.php index 6ecd11f1f0..835b4c2c70 100644 --- a/libs/Zend/Validate/File/Exists.php +++ b/libs/Zend/Validate/File/Exists.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exists.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Exists.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator which checks if the file already exists in the directory * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Exists extends Zend_Validate_Abstract @@ -43,7 +43,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_EXIST => "File '%value%' does not exist", + self::DOES_NOT_EXIST => "The file '%value%' does not exist" ); /** @@ -72,7 +72,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract } else if (is_string($directory)) { $directory = explode(',', $directory); } else if (!is_array($directory)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } @@ -122,7 +122,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract if (is_string($directory)) { $directory = explode(',', $directory); } else if (!is_array($directory)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } diff --git a/libs/Zend/Validate/File/Extension.php b/libs/Zend/Validate/File/Extension.php index 8d903e4093..58ab0b21af 100644 --- a/libs/Zend/Validate/File/Extension.php +++ b/libs/Zend/Validate/File/Extension.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Extension.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Extension.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the file extension of a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Extension extends Zend_Validate_Abstract @@ -44,8 +44,8 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_EXTENSION => "File '%value%' has a false extension", - self::NOT_FOUND => "File '%value%' could not be found", + self::FALSE_EXTENSION => "The file '%value%' has a false extension", + self::NOT_FOUND => "The file '%value%' was not found" ); /** @@ -81,6 +81,8 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple arguments to constructor are deprecated in favor of options array', E_USER_NOTICE); $case = func_get_arg(1); $this->setCase($case); } @@ -187,7 +189,7 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/FilesSize.php b/libs/Zend/Validate/File/FilesSize.php index ca20ad50af..167304b771 100644 --- a/libs/Zend/Validate/File/FilesSize.php +++ b/libs/Zend/Validate/File/FilesSize.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FilesSize.php 20455 2010-01-20 22:54:18Z thomas $ + * @version $Id: FilesSize.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_Size */ -// require_once 'Zend/Validate/File/Size.php'; +require_once 'Zend/Validate/File/Size.php'; /** * Validator for the size of all files which will be validated in sum * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size @@ -47,7 +47,7 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size protected $_messageTemplates = array( self::TOO_BIG => "All files in sum should have a maximum size of '%max%' but '%size%' were detected", self::TOO_SMALL => "All files in sum should have a minimum size of '%min%' but '%size%' were detected", - self::NOT_READABLE => "One or more files can not be read", + self::NOT_READABLE => "One or more files can not be read" ); /** @@ -76,11 +76,14 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size } elseif (is_scalar($options)) { $options = array('max' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); + $argv = func_get_args(); array_shift($argv); $options['max'] = array_shift($argv); @@ -104,7 +107,7 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size */ public function isValid($value, $file = null) { - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (is_string($value)) { $value = array($value); } @@ -128,14 +131,12 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size // limited to 2GB files $size += @filesize($files); - $this->_size = $size; + $this->_setSize($size); if (($max !== null) && ($max < $size)) { if ($this->useByteString()) { - $this->_max = $this->_toByteString($max); - $this->_size = $this->_toByteString($size); + $this->setMax($this->_toByteString($max)); $this->_throw($file, self::TOO_BIG); - $this->_max = $max; - $this->_size = $size; + $this->setMax($max); } else { $this->_throw($file, self::TOO_BIG); } @@ -145,11 +146,9 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size // Check that aggregate files are >= minimum size if (($min !== null) && ($size < $min)) { if ($this->useByteString()) { - $this->_min = $this->_toByteString($min); - $this->_size = $this->_toByteString($size); + $this->setMin($this->_toByteString($min)); $this->_throw($file, self::TOO_SMALL); - $this->_min = $min; - $this->_size = $size; + $this->setMin($min); } else { $this->_throw($file, self::TOO_SMALL); } diff --git a/libs/Zend/Validate/File/Hash.php b/libs/Zend/Validate/File/Hash.php index 6ade30cf41..d2e8c2c645 100644 --- a/libs/Zend/Validate/File/Hash.php +++ b/libs/Zend/Validate/File/Hash.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Hash.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Hash.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Hash extends Zend_Validate_Abstract @@ -45,9 +45,9 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given hashes", - self::NOT_DETECTED => "A hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found" + self::DOES_NOT_MATCH => "The file '%value%' does not match the given hashes", + self::NOT_DETECTED => "There was no hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -70,11 +70,13 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); $options['algorithm'] = func_get_arg(1); } @@ -116,7 +118,7 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract if (is_string($options)) { $options = array($options); } else if (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("False parameter given"); } @@ -129,7 +131,7 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract } if (!in_array($algorithm, $known)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Unknown algorithm '{$algorithm}'"); } @@ -152,7 +154,7 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/ImageSize.php b/libs/Zend/Validate/File/ImageSize.php index 54c1457500..c01ec97341 100644 --- a/libs/Zend/Validate/File/ImageSize.php +++ b/libs/Zend/Validate/File/ImageSize.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ImageSize.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: ImageSize.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the image size of a image file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract @@ -53,7 +53,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract self::HEIGHT_TOO_BIG => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected", self::HEIGHT_TOO_SMALL => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected", self::NOT_DETECTED => "The size of image '%value%' could not be detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::NOT_READABLE => "The image '%value%' can not be read" ); /** @@ -127,6 +127,8 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract if ($options instanceof Zend_Config) { $options = $options->toArray(); } elseif (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); if (!is_array($options)) { $options = array('minwidth' => $options); } @@ -140,7 +142,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract } } } else if (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } @@ -205,7 +207,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract { if (isset($options['minwidth'])) { if (($this->_maxwidth !== null) and ($options['minwidth'] > $this->_maxwidth)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum image width must be less than or equal to the " . " maximum image width, but {$options['minwidth']} > {$this->_maxwidth}"); } @@ -213,7 +215,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract if (isset($options['maxheight'])) { if (($this->_maxheight !== null) and ($options['minheight'] > $this->_maxheight)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum image height must be less than or equal to the " . " maximum image height, but {$options['minheight']} > {$this->_maxheight}"); } @@ -242,7 +244,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract { if (isset($options['maxwidth'])) { if (($this->_minwidth !== null) and ($options['maxwidth'] < $this->_minwidth)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum image width must be greater than or equal to the " . "minimum image width, but {$options['maxwidth']} < {$this->_minwidth}"); } @@ -250,7 +252,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract if (isset($options['maxheight'])) { if (($this->_minheight !== null) and ($options['maxheight'] < $this->_minheight)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum image height must be greater than or equal to the " . "minimum image height, but {$options['maxheight']} < {$this->_minwidth}"); } @@ -308,7 +310,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } diff --git a/libs/Zend/Validate/File/IsCompressed.php b/libs/Zend/Validate/File/IsCompressed.php index dc0d99abb5..3254d57341 100644 --- a/libs/Zend/Validate/File/IsCompressed.php +++ b/libs/Zend/Validate/File/IsCompressed.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IsCompressed.php 21138 2010-02-22 22:37:11Z thomas $ + * @version $Id: IsCompressed.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_MimeType */ -// require_once 'Zend/Validate/File/MimeType.php'; +require_once 'Zend/Validate/File/MimeType.php'; /** * Validator which checks if the file already exists in the directory * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType @@ -45,9 +45,9 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_TYPE => "File '%value%' is not compressed, '%type%' detected", - self::NOT_DETECTED => "The mimetype of file '%value%' could not been detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::FALSE_TYPE => "The file '%value%' is not compressed, '%type%' detected", + self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected", + self::NOT_READABLE => "The file '%value%' can not be read" ); /** @@ -60,90 +60,27 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType { if ($mimetype instanceof Zend_Config) { $mimetype = $mimetype->toArray(); + } else if (empty($mimetype)) { + $mimetype = array( + 'application/x-tar', + 'application/x-cpio', + 'application/x-debian-package', + 'application/x-archive', + 'application/x-arc', + 'application/x-arj', + 'application/x-lharc', + 'application/x-lha', + 'application/x-rar', + 'application/zip', + 'application/zoo', + 'application/x-eet', + 'application/x-java-pack200', + 'application/x-compress', + 'application/x-gzip', + 'application/x-bzip2' + ); } - $temp = array(); - // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen - $default = array( - 'application/arj', - 'application/gnutar', - 'application/lha', - 'application/lzx', - 'application/vnd.ms-cab-compressed', - 'application/x-ace-compressed', - 'application/x-arc', - 'application/x-archive', - 'application/x-arj', - 'application/x-bzip', - 'application/x-bzip2', - 'application/x-cab-compressed', - 'application/x-compress', - 'application/x-compressed', - 'application/x-cpio', - 'application/x-debian-package', - 'application/x-eet', - 'application/x-gzip', - 'application/x-java-pack200', - 'application/x-lha', - 'application/x-lharc', - 'application/x-lzh', - 'application/x-lzma', - 'application/x-lzx', - 'application/x-rar', - 'application/x-sit', - 'application/x-stuffit', - 'application/x-tar', - 'application/zip', - 'application/zoo', - 'multipart/x-gzip', - ); - - if (is_array($mimetype)) { - $temp = $mimetype; - if (array_key_exists('magicfile', $temp)) { - unset($temp['magicfile']); - } - - if (array_key_exists('headerCheck', $temp)) { - unset($temp['headerCheck']); - } - - if (empty($temp)) { - $mimetype += $default; - } - } - - if (empty($mimetype)) { - $mimetype = $default; - } - - parent::__construct($mimetype); - } - - /** - * Throws an error of the given type - * Duplicates parent method due to OOP Problem with late static binding in PHP 5.2 - * - * @param string $file - * @param string $errorType - * @return false - */ - protected function _throw($file, $errorType) - { - $this->_value = $file['name']; - switch($errorType) { - case Zend_Validate_File_MimeType::FALSE_TYPE : - $errorType = self::FALSE_TYPE; - break; - case Zend_Validate_File_MimeType::NOT_DETECTED : - $errorType = self::NOT_DETECTED; - break; - case Zend_Validate_File_MimeType::NOT_READABLE : - $errorType = self::NOT_READABLE; - break; - } - - $this->_error($errorType); - return false; + $this->setMimeType($mimetype); } } diff --git a/libs/Zend/Validate/File/IsImage.php b/libs/Zend/Validate/File/IsImage.php index d602ebe763..3904af1f90 100644 --- a/libs/Zend/Validate/File/IsImage.php +++ b/libs/Zend/Validate/File/IsImage.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IsImage.php 21138 2010-02-22 22:37:11Z thomas $ + * @version $Id: IsImage.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_MimeType */ -// require_once 'Zend/Validate/File/MimeType.php'; +require_once 'Zend/Validate/File/MimeType.php'; /** * Validator which checks if the file already exists in the directory * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType @@ -45,9 +45,9 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_TYPE => "File '%value%' is no image, '%type%' detected", - self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::FALSE_TYPE => "The file '%value%' is no image, '%type%' detected", + self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected", + self::NOT_READABLE => "The file '%value%' can not be read" ); /** @@ -60,114 +60,31 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType { if ($mimetype instanceof Zend_Config) { $mimetype = $mimetype->toArray(); + } else if (empty($mimetype)) { + $mimetype = array( + 'image/x-quicktime', + 'image/jp2', + 'image/x-xpmi', + 'image/x-portable-bitmap', + 'image/x-portable-greymap', + 'image/x-portable-pixmap', + 'image/x-niff', + 'image/tiff', + 'image/png', + 'image/x-unknown', + 'image/gif', + 'image/x-ms-bmp', + 'application/dicom', + 'image/vnd.adobe.photoshop', + 'image/vnd.djvu', + 'image/x-cpi', + 'image/jpeg', + 'image/x-ico', + 'image/x-coreldraw', + 'image/svg+xml' + ); } - $temp = array(); - // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen - // http://www.iana.org/assignments/media-types/image/ - $default = array( - 'application/cdf', - 'application/dicom', - 'application/fractals', - 'application/postscript', - 'application/vnd.hp-hpgl', - 'application/vnd.oasis.opendocument.graphics', - 'application/x-cdf', - 'application/x-cmu-raster', - 'application/x-ima', - 'application/x-inventor', - 'application/x-koan', - 'application/x-portable-anymap', - 'application/x-world-x-3dmf', - 'image/bmp', - 'image/c', - 'image/cgm', - 'image/fif', - 'image/gif', - 'image/jpeg', - 'image/jpm', - 'image/jpx', - 'image/jp2', - 'image/naplps', - 'image/pjpeg', - 'image/png', - 'image/svg', - 'image/svg+xml', - 'image/tiff', - 'image/vnd.adobe.photoshop', - 'image/vnd.djvu', - 'image/vnd.fpx', - 'image/vnd.net-fpx', - 'image/x-cmu-raster', - 'image/x-cmx', - 'image/x-coreldraw', - 'image/x-cpi', - 'image/x-emf', - 'image/x-ico', - 'image/x-icon', - 'image/x-jg', - 'image/x-ms-bmp', - 'image/x-niff', - 'image/x-pict', - 'image/x-pcx', - 'image/x-portable-anymap', - 'image/x-portable-bitmap', - 'image/x-portable-greymap', - 'image/x-portable-pixmap', - 'image/x-quicktime', - 'image/x-rgb', - 'image/x-tiff', - 'image/x-unknown', - 'image/x-windows-bmp', - 'image/x-xpmi', - ); - - if (is_array($mimetype)) { - $temp = $mimetype; - if (array_key_exists('magicfile', $temp)) { - unset($temp['magicfile']); - } - - if (array_key_exists('headerCheck', $temp)) { - unset($temp['headerCheck']); - } - - if (empty($temp)) { - $mimetype += $default; - } - } - - if (empty($mimetype)) { - $mimetype = $default; - } - - parent::__construct($mimetype); - } - - /** - * Throws an error of the given type - * Duplicates parent method due to OOP Problem with late static binding in PHP 5.2 - * - * @param string $file - * @param string $errorType - * @return false - */ - protected function _throw($file, $errorType) - { - $this->_value = $file['name']; - switch($errorType) { - case Zend_Validate_File_MimeType::FALSE_TYPE : - $errorType = self::FALSE_TYPE; - break; - case Zend_Validate_File_MimeType::NOT_DETECTED : - $errorType = self::NOT_DETECTED; - break; - case Zend_Validate_File_MimeType::NOT_READABLE : - $errorType = self::NOT_READABLE; - break; - } - - $this->_error($errorType); - return false; + $this->setMimeType($mimetype); } } diff --git a/libs/Zend/Validate/File/Md5.php b/libs/Zend/Validate/File/Md5.php index e76df71917..cfbd83fb53 100644 --- a/libs/Zend/Validate/File/Md5.php +++ b/libs/Zend/Validate/File/Md5.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Md5.php 20442 2010-01-20 15:15:40Z matthew $ + * @version $Id: Md5.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Hash */ -// require_once 'Zend/Validate/File/Hash.php'; +require_once 'Zend/Validate/File/Hash.php'; /** * Validator for the md5 hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash @@ -45,9 +45,9 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given md5 hashes", - self::NOT_DETECTED => "A md5 hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found", + self::DOES_NOT_MATCH => "The file '%value%' does not match the given md5 hashes", + self::NOT_DETECTED => "There was no md5 hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -72,7 +72,7 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } @@ -123,7 +123,7 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash * Adds the md5 hash for one or multiple files * * @param string|array $options - * @param string $algorithm (Deprecated) Algorithm to use, fixed to md5 + * @param string $algorithm (Depreciated) Algorithm to use, fixed to md5 * @return Zend_Validate_File_Hash Provides a fluent interface */ public function addHash($options) @@ -161,7 +161,7 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/MimeType.php b/libs/Zend/Validate/File/MimeType.php index a31a7d35a3..2bf372c4fc 100644 --- a/libs/Zend/Validate/File/MimeType.php +++ b/libs/Zend/Validate/File/MimeType.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MimeType.php 21936 2010-04-18 16:23:34Z thomas $ + * @version $Id: MimeType.php 18513 2009-10-12 16:17:35Z matthew $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the mime type of a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract @@ -46,9 +46,9 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'", - self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::FALSE_TYPE => "The file '%value%' has a false mimetype of '%type%'", + self::NOT_DETECTED => "The mimetype of file '%value%' could not been detected", + self::NOT_READABLE => "The file '%value%' can not be read" ); /** @@ -80,13 +80,6 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract protected $_magicfile; /** - * Finfo object to use - * - * @var resource - */ - protected $_finfo; - - /** * If no $_ENV['MAGIC'] is set, try and autodiscover it based on common locations * @var array */ @@ -124,18 +117,16 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract } elseif (is_string($mimetype)) { $mimetype = explode(',', $mimetype); } elseif (!is_array($mimetype)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Invalid options to validator provided"); } if (isset($mimetype['magicfile'])) { $this->setMagicFile($mimetype['magicfile']); - unset($mimetype['magicfile']); } if (isset($mimetype['headerCheck'])) { - $this->enableHeaderCheck($mimetype['headerCheck']); - unset($mimetype['headerCheck']); + $this->enableHeaderCheck(true); } $this->setMimeType($mimetype); @@ -148,62 +139,33 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract */ public function getMagicFile() { - if (null === $this->_magicfile) { - if (!empty($_ENV['MAGIC'])) { - $this->setMagicFile($_ENV['MAGIC']); - } elseif (!(@ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1)) { - // require_once 'Zend/Validate/Exception.php'; - foreach ($this->_magicFiles as $file) { - // supressing errors which are thrown due to openbase_dir restrictions - try { - $this->setMagicFile($file); - if ($this->_magicfile !== null) { - break; - } - } catch (Zend_Validate_Exception $e) { - // Intentionally, catch and fall through - } + if (null === $this->_magicfile && empty($_ENV['MAGIC'])) { + foreach ($this->_magicFiles as $file) { + if (file_exists($file)) { + $this->setMagicFile($file); + break; } } - - if ($this->_magicfile === null) { - $this->_magicfile = false; - } } - return $this->_magicfile; } /** * Sets the magicfile to use * if null, the MAGIC constant from php is used - * if the MAGIC file is errorous, no file will be set * * @param string $file - * @throws Zend_Validate_Exception When finfo can not read the magicfile * @return Zend_Validate_File_MimeType Provides fluid interface */ public function setMagicFile($file) { if (empty($file)) { $this->_magicfile = null; - } else if (!(class_exists('finfo', false))) { - $this->_magicfile = null; - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Magicfile can not be set. There is no finfo extension installed'); } else if (!is_readable($file)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('The given magicfile can not be read'); } else { - $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - $this->_finfo = @finfo_open($const, $file); - if (empty($this->_finfo)) { - $this->_finfo = null; - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('The given magicfile is not accepted by finfo'); - } else { - $this->_magicfile = $file; - } + $this->_magicfile = (string) $file; } return $this; @@ -275,7 +237,7 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract if (is_string($mimetype)) { $mimetype = explode(',', $mimetype); } elseif (!is_array($mimetype)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Invalid options to validator provided"); } @@ -324,7 +286,7 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract } // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } @@ -332,27 +294,24 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract $mimefile = $this->getMagicFile(); if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - if (!empty($mimefile) && empty($this->_finfo)) { - $this->_finfo = @finfo_open($const, $mimefile); - } - - if (empty($this->_finfo)) { - $this->_finfo = @finfo_open($const); + if (!empty($mimefile)) { + $mime = new finfo($const, $mimefile); + } else { + $mime = new finfo($const); } - $this->_type = null; - if (!empty($this->_finfo)) { - $this->_type = finfo_file($this->_finfo, $value); + if ($mime !== false) { + $this->_type = $mime->file($value); } + unset($mime); } - if (empty($this->_type) && - (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) { + if (empty($this->_type)) { + if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { $this->_type = mime_content_type($value); - } - - if (empty($this->_type) && $this->_headerCheck) { - $this->_type = $file['type']; + } elseif ($this->_headerCheck) { + $this->_type = $file['type']; + } } if (empty($this->_type)) { @@ -366,7 +325,6 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract $types = explode('/', $this->_type); $types = array_merge($types, explode('-', $this->_type)); - $types = array_merge($types, explode(';', $this->_type)); foreach($mimetype as $mime) { if (in_array($mime, $types)) { return true; diff --git a/libs/Zend/Validate/File/NotExists.php b/libs/Zend/Validate/File/NotExists.php index a5afe94686..0cc3c87ac9 100644 --- a/libs/Zend/Validate/File/NotExists.php +++ b/libs/Zend/Validate/File/NotExists.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NotExists.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: NotExists.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Exists */ -// require_once 'Zend/Validate/File/Exists.php'; +require_once 'Zend/Validate/File/Exists.php'; /** * Validator which checks if the destination file does not exist * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists @@ -43,7 +43,7 @@ class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_EXIST => "File '%value%' exists", + self::DOES_EXIST => "The file '%value%' does exist" ); /** diff --git a/libs/Zend/Validate/File/Sha1.php b/libs/Zend/Validate/File/Sha1.php index 1b5f8ee622..9dd4418d71 100644 --- a/libs/Zend/Validate/File/Sha1.php +++ b/libs/Zend/Validate/File/Sha1.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sha1.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Sha1.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Hash */ -// require_once 'Zend/Validate/File/Hash.php'; +require_once 'Zend/Validate/File/Hash.php'; /** * Validator for the sha1 hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash @@ -45,9 +45,9 @@ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given sha1 hashes", - self::NOT_DETECTED => "A sha1 hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found", + self::DOES_NOT_MATCH => "The file '%value%' does not match the given sha1 hashes", + self::NOT_DETECTED => "There was no sha1 hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -72,7 +72,7 @@ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } @@ -159,7 +159,7 @@ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/Size.php b/libs/Zend/Validate/File/Size.php index a3431cfae1..4c41178966 100644 --- a/libs/Zend/Validate/File/Size.php +++ b/libs/Zend/Validate/File/Size.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Size.php 20455 2010-01-20 22:54:18Z thomas $ + * @version $Id: Size.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the maximum size of a file up to a max of 2GB * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Size extends Zend_Validate_Abstract @@ -48,7 +48,7 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract protected $_messageTemplates = array( self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", - self::NOT_FOUND => "File '%value%' could not be found", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -107,11 +107,13 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract } elseif (is_string($options) || is_numeric($options)) { $options = array('max' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); $argv = func_get_args(); array_shift($argv); $options['max'] = array_shift($argv); @@ -181,14 +183,14 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract public function setMin($min) { if (!is_string($min) and !is_numeric($min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $min = (integer) $this->_fromByteString($min); $max = $this->getMax(true); if (($max !== null) && ($min > $max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum filesize, but $min >" . " $max"); } @@ -223,14 +225,14 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract public function setMax($max) { if (!is_string($max) && !is_numeric($max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $max = (integer) $this->_fromByteString($max); $min = $this->getMin(true); if (($min !== null) && ($max < $min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum filesize, but " . "$max < $min"); } @@ -274,14 +276,13 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } // limited to 4GB files - $size = sprintf("%u", @filesize($value)); - $this->_size = $size; + $size = sprintf("%u", @filesize($value)); // Check to see if it's smaller than min size $min = $this->getMin(true); diff --git a/libs/Zend/Validate/File/Upload.php b/libs/Zend/Validate/File/Upload.php index 9a12f301d1..fd1bdfe754 100644 --- a/libs/Zend/Validate/File/Upload.php +++ b/libs/Zend/Validate/File/Upload.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Upload.php 20431 2010-01-19 21:36:05Z thomas $ + * @version $Id: Upload.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the maximum size of a file up to a max of 2GB * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Upload extends Zend_Validate_Abstract @@ -53,16 +53,16 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::INI_SIZE => "File '%value%' exceeds the defined ini size", - self::FORM_SIZE => "File '%value%' exceeds the defined form size", - self::PARTIAL => "File '%value%' was only partially uploaded", - self::NO_FILE => "File '%value%' was not uploaded", - self::NO_TMP_DIR => "No temporary directory was found for file '%value%'", - self::CANT_WRITE => "File '%value%' can't be written", - self::EXTENSION => "A PHP extension returned an error while uploading the file '%value%'", - self::ATTACK => "File '%value%' was illegally uploaded. This could be a possible attack", - self::FILE_NOT_FOUND => "File '%value%' was not found", - self::UNKNOWN => "Unknown error while uploading file '%value%'" + self::INI_SIZE => "The file '%value%' exceeds the defined ini size", + self::FORM_SIZE => "The file '%value%' exceeds the defined form size", + self::PARTIAL => "The file '%value%' was only partially uploaded", + self::NO_FILE => "The file '%value%' was not uploaded", + self::NO_TMP_DIR => "No temporary directory was found for the file '%value%'", + self::CANT_WRITE => "The file '%value%' can't be written", + self::EXTENSION => "The extension returned an error while uploading the file '%value%'", + self::ATTACK => "The file '%value%' was illegal uploaded, possible attack", + self::FILE_NOT_FOUND => "The file '%value%' was not found", + self::UNKNOWN => "Unknown error while uploading the file '%value%'" ); /** @@ -112,7 +112,7 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract } if (count($return) === 0) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The file '$file' was not found"); } diff --git a/libs/Zend/Validate/File/WordCount.php b/libs/Zend/Validate/File/WordCount.php index e69bf1db79..b5249532d3 100644 --- a/libs/Zend/Validate/File/WordCount.php +++ b/libs/Zend/Validate/File/WordCount.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: WordCount.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: WordCount.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Count */ -// require_once 'Zend/Validate/File/Count.php'; +require_once 'Zend/Validate/File/Count.php'; /** * Validator for counting all words in a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_WordCount extends Zend_Validate_File_Count @@ -48,7 +48,7 @@ class Zend_Validate_File_WordCount extends Zend_Validate_File_Count protected $_messageTemplates = array( self::TOO_MUCH => "Too much words, maximum '%max%' are allowed but '%count%' were counted", self::TOO_LESS => "Too less words, minimum '%min%' are expected but '%count%' were counted", - self::NOT_FOUND => "File '%value%' could not be found", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -64,7 +64,7 @@ class Zend_Validate_File_WordCount extends Zend_Validate_File_Count public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/Float.php b/libs/Zend/Validate/Float.php index 37755a8ab7..bfa5e62c14 100644 --- a/libs/Zend/Validate/Float.php +++ b/libs/Zend/Validate/Float.php @@ -14,25 +14,25 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Float.php 21664 2010-03-27 21:39:38Z thomas $ + * @version $Id: Float.php 17470 2009-08-08 22:27:09Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @see Zend_Locale_Format */ -// require_once 'Zend/Locale/Format.php'; +require_once 'Zend/Locale/Format.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Float extends Zend_Validate_Abstract @@ -45,7 +45,7 @@ class Zend_Validate_Float extends Zend_Validate_Abstract */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be float, string, or integer", - self::NOT_FLOAT => "'%value%' does not appear to be a float", + self::NOT_FLOAT => "'%value%' does not appear to be a float" ); protected $_locale; @@ -53,30 +53,13 @@ class Zend_Validate_Float extends Zend_Validate_Abstract /** * Constructor for the float validator * - * @param string|Zend_Config|Zend_Locale $locale + * @param string|Zend_Locale $locale */ public function __construct($locale = null) { - if ($locale instanceof Zend_Config) { - $locale = $locale->toArray(); - } - - if (is_array($locale)) { - if (array_key_exists('locale', $locale)) { - $locale = $locale['locale']; - } else { - $locale = null; - } + if ($locale !== null) { + $this->setLocale($locale); } - - if (empty($locale)) { - // require_once 'Zend/Registry.php'; - if (Zend_Registry::isRegistered('Zend_Locale')) { - $locale = Zend_Registry::get('Zend_Locale'); - } - } - - $this->setLocale($locale); } /** @@ -94,7 +77,7 @@ class Zend_Validate_Float extends Zend_Validate_Abstract */ public function setLocale($locale = null) { - // require_once 'Zend/Locale.php'; + require_once 'Zend/Locale.php'; $this->_locale = Zend_Locale::findLocale($locale); return $this; } @@ -114,19 +97,28 @@ class Zend_Validate_Float extends Zend_Validate_Abstract return false; } - if (is_float($value)) { - return true; - } - $this->_setValue($value); - try { - if (!Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) { + if ($this->_locale === null) { + $locale = localeconv(); + $valueFiltered = str_replace($locale['thousands_sep'], '', (string) $value); + $valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered); + + if (strval(floatval($valueFiltered)) != $valueFiltered) { + $this->_error(self::NOT_FLOAT); + return false; + } + + } else { + try { + if (!Zend_Locale_Format::isFloat($value, array('locale' => 'en')) && + !Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) { + $this->_error(self::NOT_FLOAT); + return false; + } + } catch (Zend_Locale_Exception $e) { $this->_error(self::NOT_FLOAT); return false; } - } catch (Zend_Locale_Exception $e) { - $this->_error(self::NOT_FLOAT); - return false; } return true; diff --git a/libs/Zend/Validate/GreaterThan.php b/libs/Zend/Validate/GreaterThan.php index a9b7a21879..3c7b7931c9 100644 --- a/libs/Zend/Validate/GreaterThan.php +++ b/libs/Zend/Validate/GreaterThan.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,20 +15,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: GreaterThan.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: GreaterThan.php 17470 2009-08-08 22:27:09Z thomas $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_GreaterThan extends Zend_Validate_Abstract @@ -39,7 +42,7 @@ class Zend_Validate_GreaterThan extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_GREATER => "'%value%' is not greater than '%min%'", + self::NOT_GREATER => "'%value%' is not greater than '%min%'" ); /** @@ -59,24 +62,11 @@ class Zend_Validate_GreaterThan extends Zend_Validate_Abstract /** * Sets validator options * - * @param mixed|Zend_Config $min + * @param mixed $min * @return void */ public function __construct($min) { - if ($min instanceof Zend_Config) { - $min = $min->toArray(); - } - - if (is_array($min)) { - if (array_key_exists('min', $min)) { - $min = $min['min']; - } else { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Missing option 'min'"); - } - } - $this->setMin($min); } diff --git a/libs/Zend/Validate/Hex.php b/libs/Zend/Validate/Hex.php index b2080d3aaa..85d3e3a7a2 100644 --- a/libs/Zend/Validate/Hex.php +++ b/libs/Zend/Validate/Hex.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,20 +15,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Hex.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Hex.php 17470 2009-08-08 22:27:09Z thomas $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Hex extends Zend_Validate_Abstract @@ -42,7 +45,7 @@ class Zend_Validate_Hex extends Zend_Validate_Abstract */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be a string", - self::NOT_HEX => "'%value%' has not only hexadecimal digit characters", + self::NOT_HEX => "'%value%' has not only hexadecimal digit characters" ); /** diff --git a/libs/Zend/Validate/Hostname.php b/libs/Zend/Validate/Hostname.php index 1732e69c77..dd254d5596 100644 --- a/libs/Zend/Validate/Hostname.php +++ b/libs/Zend/Validate/Hostname.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Hostname.php 21063 2010-02-15 23:00:17Z thomas $ + * @version $Id: Hostname.php 17141 2009-07-26 12:49:17Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @see Zend_Validate_Ip */ -// require_once 'Zend/Validate/Ip.php'; +require_once 'Zend/Validate/Ip.php'; /** * Please note there are two standalone test scripts for testing IDN characters due to problems @@ -41,7 +41,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Hostname extends Zend_Validate_Abstract @@ -64,13 +64,13 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract self::INVALID => "Invalid type given, value should be a string", self::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed", self::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list", - self::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash in an invalid position", + self::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position", self::INVALID_HOSTNAME_SCHEMA => "'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'", self::UNDECIPHERABLE_TLD => "'%value%' appears to be a DNS hostname but cannot extract TLD part", self::INVALID_HOSTNAME => "'%value%' does not match the expected structure for a DNS hostname", self::INVALID_LOCAL_NAME => "'%value%' does not appear to be a valid local network name", self::LOCAL_NAME_NOT_ALLOWED => "'%value%' appears to be a local network name but local network names are not allowed", - self::CANNOT_DECODE_PUNYCODE => "'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded", + self::CANNOT_DECODE_PUNYCODE => "'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded" ); /** @@ -101,6 +101,27 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract const ALLOW_ALL = 7; /** + * Whether IDN domains are validated + * + * @var boolean + */ + private $_validateIdn = true; + + /** + * Whether TLDs are validated against a known list + * + * @var boolean + */ + private $_validateTld = true; + + /** + * Bit field of ALLOW constants; determines which types of hostnames are allowed + * + * @var integer + */ + protected $_allow; + + /** * Array of valid top-level-domains * * @see ftp://data.iana.org/TLD/tlds-alpha-by-domain.txt List of all TLDs by domain @@ -200,12 +221,6 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract 'DE' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿăąāćĉčċďđĕěėęēğĝġģĥħĭĩįīıĵķĺľļłńňņŋŏőōœĸŕřŗśŝšşťţŧŭůűũųūŵŷźžż]{1,63}$/iu'), 'DK' => array(1 => '/^[\x{002d}0-9a-zäéöü]{1,63}$/iu'), 'ES' => array(1 => '/^[\x{002d}0-9a-zàáçèéíïñòóúü·]{1,63}$/iu'), - 'EU' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿ]{1,63}$/iu', - 2 => '/^[\x{002d}0-9a-zāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĺļľŀłńņňʼnŋōŏőœŕŗřśŝšťŧũūŭůűųŵŷźżž]{1,63}$/iu', - 3 => '/^[\x{002d}0-9a-zșț]{1,63}$/iu', - 4 => '/^[\x{002d}0-9a-zΐάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ]{1,63}$/iu', - 5 => '/^[\x{002d}0-9a-zабвгдежзийклмнопрстуфхцчшщъыьэюя]{1,63}$/iu', - 6 => '/^[\x{002d}0-9a-zἀ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾰ-ᾴᾶᾷῂῃῄῆῇῐ-ΐῖῗῠ-ῧῲῳῴῶῷ]{1,63}$/iu'), 'FI' => array(1 => '/^[\x{002d}0-9a-zäåö]{1,63}$/iu'), 'GR' => array(1 => '/^[\x{002d}0-9a-zΆΈΉΊΌΎ-ΡΣ-ώἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼῂῃῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲῳῴῶ-ῼ]{1,63}$/iu'), 'HK' => 'Zend/Validate/Hostname/Cn.php', @@ -305,13 +320,6 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract '网络' => array(1 => 20), ); - protected $_options = array( - 'allow' => self::ALLOW_DNS, - 'idn' => true, - 'tld' => true, - 'ip' => null - ); - /** * Sets validator options * @@ -322,77 +330,16 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract * @return void * @see http://www.iana.org/cctld/specifications-policies-cctlds-01apr02.htm Technical Specifications for ccTLDs */ - public function __construct($options = array()) + public function __construct($allow = self::ALLOW_DNS, $validateIdn = true, $validateTld = true, Zend_Validate_Ip $ipValidator = null) { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['allow'] = array_shift($options); - if (!empty($options)) { - $temp['idn'] = array_shift($options); - } - - if (!empty($options)) { - $temp['tld'] = array_shift($options); - } - - if (!empty($options)) { - $temp['ip'] = array_shift($options); - } - - $options = $temp; - } - - $options += $this->_options; - $this->setOptions($options); - } - - /** - * Returns all set options - * - * @return array - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Sets the options for this validator - * - * @param array $options - * @return Zend_Validate_Hostname - */ - public function setOptions($options) - { - if (array_key_exists('allow', $options)) { - $this->setAllow($options['allow']); - } + // Set allow options + $this->setAllow($allow); - if (array_key_exists('idn', $options)) { - $this->setValidateIdn($options['idn']); - } - - if (array_key_exists('tld', $options)) { - $this->setValidateTld($options['tld']); - } - - if (array_key_exists('ip', $options)) { - $this->setIpValidator($options['ip']); - } + // Set validation options + $this->_validateIdn = $validateIdn; + $this->_validateTld = $validateTld; - return $this; - } - - /** - * Returns the set ip validator - * - * @return Zend_Validate_Ip - */ - public function getIpValidator() - { - return $this->_options['ip']; + $this->setIpValidator($ipValidator); } /** @@ -404,9 +351,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract if ($ipValidator === null) { $ipValidator = new Zend_Validate_Ip(); } - - $this->_options['ip'] = $ipValidator; - return $this; + $this->_ipValidator = $ipValidator; } /** @@ -416,7 +361,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract */ public function getAllow() { - return $this->_options['allow']; + return $this->_allow; } /** @@ -427,21 +372,11 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract */ public function setAllow($allow) { - $this->_options['allow'] = $allow; + $this->_allow = $allow; return $this; } /** - * Returns the set idn option - * - * @return boolean - */ - public function getValidateIdn() - { - return $this->_options['idn']; - } - - /** * Set whether IDN domains are validated * * This only applies when DNS hostnames are validated @@ -450,18 +385,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract */ public function setValidateIdn ($allowed) { - $this->_options['idn'] = (bool) $allowed; - return $this; - } - - /** - * Returns the set tld option - * - * @return boolean - */ - public function getValidateTld() - { - return $this->_options['tld']; + $this->_validateIdn = (bool) $allowed; } /** @@ -473,8 +397,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract */ public function setValidateTld ($allowed) { - $this->_options['tld'] = (bool) $allowed; - return $this; + $this->_validateTld = (bool) $allowed; } /** @@ -494,10 +417,11 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract } $this->_setValue($value); + // Check input against IP address schema if (preg_match('/^[0-9.a-e:.]*$/i', $value) && - $this->_options['ip']->setTranslator($this->getTranslator())->isValid($value)) { - if (!($this->_options['allow'] & self::ALLOW_IP)) { + $this->_ipValidator->setTranslator($this->getTranslator())->isValid($value)) { + if (!($this->_allow & self::ALLOW_IP)) { $this->_error(self::IP_ADDRESS_NOT_ALLOWED); return false; } else { @@ -528,7 +452,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract // Match TLD against known list $this->_tld = strtolower($matches[1]); - if ($this->_options['tld']) { + if ($this->_validateTld) { if (!in_array($this->_tld, $this->_validTlds)) { $this->_error(self::UNKNOWN_TLD); $status = false; @@ -542,17 +466,18 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract * @see Zend_Validate_Hostname_Interface */ $regexChars = array(0 => '/^[a-z0-9\x2d]{1,63}$/i'); - if ($this->_options['idn'] && isset($this->_validIdns[strtoupper($this->_tld)])) { + if ($this->_validateIdn && isset($this->_validIdns[strtoupper($this->_tld)])) { if (is_string($this->_validIdns[strtoupper($this->_tld)])) { - $regexChars += include(dirname(__FILE__) . '/../../' . $this->_validIdns[strtoupper($this->_tld)]); + $regexChars += include($this->_validIdns[strtoupper($this->_tld)]); } else { $regexChars += $this->_validIdns[strtoupper($this->_tld)]; } } // Check each hostname part - $check = 0; + $valid = true; foreach ($domainParts as $domainPart) { + // Decode Punycode domainnames to IDN if (strpos($domainPart, 'xn--') === 0) { $domainPart = $this->decodePunycode(substr($domainPart, 4)); @@ -565,16 +490,20 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract if ((strpos($domainPart, '-') === 0) || ((strlen($domainPart) > 2) && (strpos($domainPart, '-', 2) == 2) && (strpos($domainPart, '-', 3) == 3)) || (strpos($domainPart, '-') === (strlen($domainPart) - 1))) { - $this->_error(self::INVALID_DASH); + $this->_error(self::INVALID_DASH); $status = false; break 2; } // Check each domain part - $checked = false; + $check = false; foreach($regexChars as $regexKey => $regexChar) { $status = @preg_match($regexChar, $domainPart); - if ($status > 0) { + if ($status === false) { + iconv_set_encoding('internal_encoding', $origenc); + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception('Internal error: DNS validation failed'); + } elseif ($status !== 0) { $length = 63; if (array_key_exists(strtoupper($this->_tld), $this->_idnLength) && (array_key_exists($regexKey, $this->_idnLength[strtoupper($this->_tld)]))) { @@ -584,22 +513,23 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract if (iconv_strlen($domainPart, 'UTF-8') > $length) { $this->_error(self::INVALID_HOSTNAME); } else { - $checked = true; - break; + $check = true; + break 2; } } } - if ($checked) { - ++$check; + if (!$check) { + $valid = false; } } - // If one of the labels doesn't match, the hostname is invalid - if ($check !== count($domainParts)) { + // If all labels didn't match, the hostname is invalid + if (!$valid) { $this->_error(self::INVALID_HOSTNAME_SCHEMA); $status = false; } + } else { // Hostname not long enough $this->_error(self::UNDECIPHERABLE_TLD); @@ -610,20 +540,28 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract iconv_set_encoding('internal_encoding', $origenc); // If the input passes as an Internet domain name, and domain names are allowed, then the hostname // passes validation - if ($status && ($this->_options['allow'] & self::ALLOW_DNS)) { + if ($status && ($this->_allow & self::ALLOW_DNS)) { return true; } - } else if ($this->_options['allow'] & self::ALLOW_DNS) { + } else { $this->_error(self::INVALID_HOSTNAME); } // Check input against local network name schema; last chance to pass validation $regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}){1,254}$/'; $status = @preg_match($regexLocal, $value); + if (false === $status) { + /** + * Regex error + * @see Zend_Validate_Exception + */ + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception('Internal error: local network name validation failed'); + } // If the input passes as a local network name, and local network names are allowed, then the // hostname passes validation - $allowLocal = $this->_options['allow'] & self::ALLOW_LOCAL; + $allowLocal = $this->_allow & self::ALLOW_LOCAL; if ($status && $allowLocal) { return true; } diff --git a/libs/Zend/Validate/Hostname/Biz.php b/libs/Zend/Validate/Hostname/Biz.php index 38762217d8..f2e3e7a009 100644 --- a/libs/Zend/Validate/Hostname/Biz.php +++ b/libs/Zend/Validate/Hostname/Biz.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Biz.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Biz.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/libs/Zend/Validate/Hostname/Cn.php b/libs/Zend/Validate/Hostname/Cn.php index feee54ade2..1bcd91eb95 100644 --- a/libs/Zend/Validate/Hostname/Cn.php +++ b/libs/Zend/Validate/Hostname/Cn.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Cn.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Cn.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/libs/Zend/Validate/Hostname/Com.php b/libs/Zend/Validate/Hostname/Com.php index 413971fec5..19290b300f 100644 --- a/libs/Zend/Validate/Hostname/Com.php +++ b/libs/Zend/Validate/Hostname/Com.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Com.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Com.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/libs/Zend/Validate/Hostname/Jp.php b/libs/Zend/Validate/Hostname/Jp.php index 02f278e2bd..0888472e61 100644 --- a/libs/Zend/Validate/Hostname/Jp.php +++ b/libs/Zend/Validate/Hostname/Jp.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Jp.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Jp.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/libs/Zend/Validate/Iban.php b/libs/Zend/Validate/Iban.php index 097cd32cbd..071651fd96 100644 --- a/libs/Zend/Validate/Iban.php +++ b/libs/Zend/Validate/Iban.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Iban.php 21563 2010-03-19 10:10:45Z thomas $ + * @version $Id: Iban.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validates IBAN Numbers (International Bank Account Numbers) * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Iban extends Zend_Validate_Abstract @@ -44,9 +44,9 @@ class Zend_Validate_Iban extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOTSUPPORTED => "Unknown country within the IBAN '%value%'", - self::FALSEFORMAT => "'%value%' has a false IBAN format", - self::CHECKFAILED => "'%value%' has failed the IBAN check", + self::NOTSUPPORTED => "'%value%' does not have IBAN", + self::FALSEFORMAT => "'%value%' has a false format", + self::CHECKFAILED => "'%value%' has failed the IBAN check" ); /** @@ -106,31 +106,12 @@ class Zend_Validate_Iban extends Zend_Validate_Abstract /** * Sets validator options * - * @param string|Zend_Config|Zend_Locale $locale OPTIONAL + * @param string|Zend_Locale $locale OPTIONAL * @return void */ public function __construct($locale = null) { - if ($locale instanceof Zend_Config) { - $locale = $locale->toArray(); - } - - if (is_array($locale)) { - if (array_key_exists('locale', $locale)) { - $locale = $locale['locale']; - } else { - $locale = null; - } - } - - if ($locale !== false) { - // require_once 'Zend/Registry.php'; - if (Zend_Registry::isRegistered('Zend_Locale')) { - $locale = Zend_Registry::get('Zend_Locale'); - } - } - - if (!empty($locale)) { + if ($locale !== null) { $this->setLocale($locale); } } @@ -153,13 +134,11 @@ class Zend_Validate_Iban extends Zend_Validate_Abstract */ public function setLocale($locale = null) { - if ($locale !== false) { - // require_once 'Zend/Locale.php'; - $locale = Zend_Locale::findLocale($locale); - if (strlen($locale) < 4) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Region must be given for IBAN validation'); - } + require_once 'Zend/Locale.php'; + $locale = Zend_Locale::findLocale($locale); + if (strlen($locale) < 4) { + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception('Region must be given for IBAN validation'); } $this->_locale = $locale; diff --git a/libs/Zend/Validate/Identical.php b/libs/Zend/Validate/Identical.php index 7b37574050..d1a046ea9f 100644 --- a/libs/Zend/Validate/Identical.php +++ b/libs/Zend/Validate/Identical.php @@ -14,18 +14,18 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Identical.php 22077 2010-05-02 13:44:46Z thomas $ + * @version $Id: Identical.php 17684 2009-08-20 09:20:36Z yoshida@zend.co.jp $ */ /** @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Identical extends Zend_Validate_Abstract @@ -42,7 +42,7 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_SAME => "The two given tokens do not match", + self::NOT_SAME => "The token '%token%' does not match the given token '%value%'", self::MISSING_TOKEN => 'No token was provided to match against', ); @@ -59,7 +59,6 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract */ protected $_tokenString; protected $_token; - protected $_strict = true; /** * Sets validator options @@ -69,32 +68,12 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract */ public function __construct($token = null) { - if ($token instanceof Zend_Config) { - $token = $token->toArray(); - } - - if (is_array($token) && array_key_exists('token', $token)) { - if (array_key_exists('strict', $token)) { - $this->setStrict($token['strict']); - } - - $this->setToken($token['token']); - } else if (null !== $token) { + if (null !== $token) { $this->setToken($token); } } /** - * Retrieve token - * - * @return string - */ - public function getToken() - { - return $this->_token; - } - - /** * Set token against which to compare * * @param mixed $token @@ -108,24 +87,13 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract } /** - * Returns the strict parameter - * - * @return boolean - */ - public function getStrict() - { - return $this->_strict; - } - - /** - * Sets the strict parameter + * Retrieve token * - * @param Zend_Validate_Identical + * @return string */ - public function setStrict($strict) + public function getToken() { - $this->_strict = (boolean) $strict; - return $this; + return $this->_token; } /** @@ -135,26 +103,19 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract * matches that token. * * @param mixed $value - * @param array $context * @return boolean */ - public function isValid($value, $context = null) + public function isValid($value) { $this->_setValue((string) $value); - - if (($context !== null) && isset($context) && array_key_exists($this->getToken(), $context)) { - $token = $context[$this->getToken()]; - } else { - $token = $this->getToken(); - } + $token = $this->getToken(); if ($token === null) { $this->_error(self::MISSING_TOKEN); return false; } - $strict = $this->getStrict(); - if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) { + if ($value !== $token) { $this->_error(self::NOT_SAME); return false; } diff --git a/libs/Zend/Validate/InArray.php b/libs/Zend/Validate/InArray.php index 3b1870543c..56940eb1aa 100644 --- a/libs/Zend/Validate/InArray.php +++ b/libs/Zend/Validate/InArray.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,31 +15,34 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: InArray.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: InArray.php 17470 2009-08-08 22:27:09Z thomas $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_InArray extends Zend_Validate_Abstract { + const NOT_IN_ARRAY = 'notInArray'; /** * @var array */ protected $_messageTemplates = array( - self::NOT_IN_ARRAY => "'%value%' was not found in the haystack", + self::NOT_IN_ARRAY => "'%value%' was not found in the haystack" ); /** @@ -53,54 +57,19 @@ class Zend_Validate_InArray extends Zend_Validate_Abstract * * @var boolean */ - protected $_strict = false; - - /** - * Whether a recursive search should be done - * - * @var boolean - */ - protected $_recursive = false; + protected $_strict; /** * Sets validator options * - * @param array|Zend_Config $haystack + * @param array $haystack + * @param boolean $strict * @return void */ - public function __construct($options) + public function __construct(array $haystack, $strict = false) { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Array expected as parameter'); - } else { - $count = func_num_args(); - $temp = array(); - if ($count > 1) { - $temp['haystack'] = func_get_arg(0); - $temp['strict'] = func_get_arg(1); - $options = $temp; - } else { - $temp = func_get_arg(0); - if (!array_key_exists('haystack', $options)) { - $options = array(); - $options['haystack'] = $temp; - } else { - $options = $temp; - } - } - } - - $this->setHaystack($options['haystack']); - if (array_key_exists('strict', $options)) { - $this->setStrict($options['strict']); - } - - if (array_key_exists('recursive', $options)) { - $this->setRecursive($options['recursive']); - } + $this->setHaystack($haystack) + ->setStrict($strict); } /** @@ -143,29 +112,7 @@ class Zend_Validate_InArray extends Zend_Validate_Abstract */ public function setStrict($strict) { - $this->_strict = (boolean) $strict; - return $this; - } - - /** - * Returns the recursive option - * - * @return boolean - */ - public function getRecursive() - { - return $this->_recursive; - } - - /** - * Sets the recursive option - * - * @param boolean $recursive - * @return Zend_Validate_InArray Provides a fluent interface - */ - public function setRecursive($recursive) - { - $this->_recursive = (boolean) $recursive; + $this->_strict = $strict; return $this; } @@ -181,24 +128,11 @@ class Zend_Validate_InArray extends Zend_Validate_Abstract public function isValid($value) { $this->_setValue($value); - if ($this->getRecursive()) { - $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($this->_haystack)); - foreach($iterator as $element) { - if ($this->_strict) { - if ($element === $value) { - return true; - } - } else if ($element == $value) { - return true; - } - } - } else { - if (in_array($value, $this->_haystack, $this->_strict)) { - return true; - } + if (!in_array($value, $this->_haystack, $this->_strict)) { + $this->_error(self::NOT_IN_ARRAY); + return false; } - - $this->_error(self::NOT_IN_ARRAY); - return false; + return true; } + } diff --git a/libs/Zend/Validate/Int.php b/libs/Zend/Validate/Int.php index 89fa168627..1e34ee3427 100644 --- a/libs/Zend/Validate/Int.php +++ b/libs/Zend/Validate/Int.php @@ -14,25 +14,25 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Int.php 20532 2010-01-22 20:18:23Z thomas $ + * @version $Id: Int.php 17470 2009-08-08 22:27:09Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @see Zend_Locale_Format */ -// require_once 'Zend/Locale/Format.php'; +require_once 'Zend/Locale/Format.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Int extends Zend_Validate_Abstract @@ -44,8 +44,8 @@ class Zend_Validate_Int extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::INVALID => "Invalid type given, value should be string or integer", - self::NOT_INT => "'%value%' does not appear to be an integer", + self::INVALID => "Invalid type given, value should be a string or a integer", + self::NOT_INT => "'%value%' does not appear to be an integer" ); protected $_locale; @@ -53,29 +53,10 @@ class Zend_Validate_Int extends Zend_Validate_Abstract /** * Constructor for the integer validator * - * @param string|Zend_Config|Zend_Locale $locale + * @param string|Zend_Locale $locale */ public function __construct($locale = null) { - if ($locale instanceof Zend_Config) { - $locale = $locale->toArray(); - } - - if (is_array($locale)) { - if (array_key_exists('locale', $locale)) { - $locale = $locale['locale']; - } else { - $locale = null; - } - } - - if (empty($locale)) { - // require_once 'Zend/Registry.php'; - if (Zend_Registry::isRegistered('Zend_Locale')) { - $locale = Zend_Registry::get('Zend_Locale'); - } - } - if ($locale !== null) { $this->setLocale($locale); } @@ -96,7 +77,7 @@ class Zend_Validate_Int extends Zend_Validate_Abstract */ public function setLocale($locale = null) { - // require_once 'Zend/Locale.php'; + require_once 'Zend/Locale.php'; $this->_locale = Zend_Locale::findLocale($locale); return $this; } @@ -116,10 +97,6 @@ class Zend_Validate_Int extends Zend_Validate_Abstract return false; } - if (is_int($value)) { - return true; - } - $this->_setValue($value); if ($this->_locale === null) { $locale = localeconv(); @@ -133,7 +110,8 @@ class Zend_Validate_Int extends Zend_Validate_Abstract } else { try { - if (!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) { + if (!Zend_Locale_Format::isInteger($value, array('locale' => 'en')) && + !Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) { $this->_error(self::NOT_INT); return false; } diff --git a/libs/Zend/Validate/Interface.php b/libs/Zend/Validate/Interface.php index 9dfca94219..842a57a8d1 100644 --- a/libs/Zend/Validate/Interface.php +++ b/libs/Zend/Validate/Interface.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,15 +15,16 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Interface.php 16223 2009-06-21 20:04:53Z thomas $ */ + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Validate_Interface @@ -51,4 +53,19 @@ interface Zend_Validate_Interface * @return array */ public function getMessages(); + + /** + * Returns an array of message codes that explain why a previous isValid() call + * returned false. + * + * If isValid() was never called or if the most recent isValid() call + * returned true, then this method returns an empty array. + * + * This is now the same as calling array_keys() on the return value from getMessages(). + * + * @return array + * @deprecated Since 1.5.0 + */ + public function getErrors(); + } diff --git a/libs/Zend/Validate/Ip.php b/libs/Zend/Validate/Ip.php index 992e60a787..a89bb36fe7 100644 --- a/libs/Zend/Validate/Ip.php +++ b/libs/Zend/Validate/Ip.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Ip.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Ip.php 17470 2009-08-08 22:27:09Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Ip extends Zend_Validate_Abstract @@ -40,78 +40,10 @@ class Zend_Validate_Ip extends Zend_Validate_Abstract */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be a string", - self::NOT_IP_ADDRESS => "'%value%' does not appear to be a valid IP address", + self::NOT_IP_ADDRESS => "'%value%' does not appear to be a valid IP address" ); /** - * internal options - * - * @var array - */ - protected $_options = array( - 'allowipv6' => true, - 'allowipv4' => true - ); - - /** - * Sets validator options - * - * @param array $options OPTIONAL Options to set, see the manual for all available options - * @return void - */ - public function __construct($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['allowipv6'] = array_shift($options); - if (!empty($options)) { - $temp['allowipv4'] = array_shift($options); - } - - $options = $temp; - } - - $options += $this->_options; - $this->setOptions($options); - } - - /** - * Returns all set options - * - * @return array - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Sets the options for this validator - * - * @param array $options - * @return Zend_Validate_Ip - */ - public function setOptions($options) - { - if (array_key_exists('allowipv6', $options)) { - $this->_options['allowipv6'] = (boolean) $options['allowipv6']; - } - - if (array_key_exists('allowipv4', $options)) { - $this->_options['allowipv4'] = (boolean) $options['allowipv4']; - } - - if (!$this->_options['allowipv4'] && !$this->_options['allowipv6']) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Nothing to validate. Check your options'); - } - - return $this; - } - - /** * Defined by Zend_Validate_Interface * * Returns true if and only if $value is a valid IP address @@ -127,65 +59,18 @@ class Zend_Validate_Ip extends Zend_Validate_Abstract } $this->_setValue($value); - if (($this->_options['allowipv4'] && !$this->_options['allowipv6'] && !$this->_validateIPv4($value)) || - (!$this->_options['allowipv4'] && $this->_options['allowipv6'] && !$this->_validateIPv6($value)) || - ($this->_options['allowipv4'] && $this->_options['allowipv6'] && !$this->_validateIPv4($value) && !$this->_validateIPv6($value))) { - $this->_error(self::NOT_IP_ADDRESS); - return false; - } - - return true; - } - - /** - * Validates an IPv4 address - * - * @param string $value - */ - protected function _validateIPv4($value) { - $ip2long = ip2long($value); - if($ip2long === false) { - return false; - } - - return $value == long2ip($ip2long); - } - /** - * Validates an IPv6 address - * - * @param string $value Value to check against - * @return boolean True when $value is a valid ipv6 address - * False otherwise - */ - protected function _validateIPv6($value) { - if (strlen($value) < 3) { - return $value == '::'; - } - - if (strpos($value, '.')) { - $lastcolon = strrpos($value, ':'); - if (!($lastcolon && $this->_validateIPv4(substr($value, $lastcolon + 1)))) { + if ((ip2long($value) === false) || (long2ip(ip2long($value)) !== $value)) { + if (!function_exists('inet_pton')) { + $this->_error(self::NOT_IP_ADDRESS); + return false; + } else if ((@inet_pton($value) === false) ||(inet_ntop(@inet_pton($value)) !== $value)) { + $this->_error(self::NOT_IP_ADDRESS); return false; } - - $value = substr($value, 0, $lastcolon) . ':0:0'; } - if (strpos($value, '::') === false) { - return preg_match('/\A(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}\z/i', $value); - } - - $colonCount = substr_count($value, ':'); - if ($colonCount < 8) { - return preg_match('/\A(?::|(?:[a-f0-9]{1,4}:)+):(?:(?:[a-f0-9]{1,4}:)*[a-f0-9]{1,4})?\z/i', $value); - } - - // special case with ending or starting double colon - if ($colonCount == 8) { - return preg_match('/\A(?:::)?(?:[a-f0-9]{1,4}:){6}[a-f0-9]{1,4}(?:::)?\z/i', $value); - } - - return false; + return true; } + } diff --git a/libs/Zend/Validate/Isbn.php b/libs/Zend/Validate/Isbn.php deleted file mode 100644 index e977871b20..0000000000 --- a/libs/Zend/Validate/Isbn.php +++ /dev/null @@ -1,279 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Isbn.php 21761 2010-04-04 21:37:18Z thomas $ - */ - -/** - * @see Zend_Validate_Abstract - */ -// require_once 'Zend/Validate/Abstract.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Isbn extends Zend_Validate_Abstract -{ - const AUTO = 'auto'; - const ISBN10 = '10'; - const ISBN13 = '13'; - const INVALID = 'isbnInvalid'; - const NO_ISBN = 'isbnNoIsbn'; - - /** - * Validation failure message template definitions. - * - * @var array - */ - protected $_messageTemplates = array( - self::INVALID => "Invalid type given, value should be string or integer", - self::NO_ISBN => "'%value%' is no valid ISBN number", - ); - - /** - * Allowed type. - * - * @var string - */ - protected $_type = self::AUTO; - - /** - * Separator character. - * - * @var string - */ - protected $_separator = ''; - - /** - * Set up options. - * - * @param Zend_Config|array $options - * @throws Zend_Validate_Exception When $options is not valid - * @return void - */ - public function __construct($options = array()) - { - // prepare options - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - if (!is_array($options)) { - /** - * @see Zend_Validate_Exception - */ - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Invalid options provided.'); - } - - // set type - if (array_key_exists('type', $options)) { - $this->setType($options['type']); - } - - // set separator - if (array_key_exists('separator', $options)) { - $this->setSeparator($options['separator']); - } - } - - /** - * Detect input format. - * - * @return string - */ - protected function _detectFormat() - { - // prepare separator and pattern list - $sep = quotemeta($this->_separator); - $patterns = array(); - $lengths = array(); - - // check for ISBN-10 - if ($this->_type == self::ISBN10 || $this->_type == self::AUTO) { - if (empty($sep)) { - $pattern = '/^[0-9]{9}[0-9X]{1}$/'; - $length = 10; - } else { - $pattern = "/^[0-9]{1,7}[{$sep}]{1}[0-9]{1,7}[{$sep}]{1}[0-9]{1,7}[{$sep}]{1}[0-9X]{1}$/"; - $length = 13; - } - - $patterns[$pattern] = self::ISBN10; - $lengths[$pattern] = $length; - } - - // check for ISBN-13 - if ($this->_type == self::ISBN13 || $this->_type == self::AUTO) { - if (empty($sep)) { - $pattern = '/^[0-9]{13}$/'; - $length = 13; - } else { - $pattern = "/^[0-9]{1,9}[{$sep}]{1}[0-9]{1,5}[{$sep}]{1}[0-9]{1,9}[{$sep}]{1}[0-9]{1,9}[{$sep}]{1}[0-9]{1}$/"; - $length = 17; - } - - $patterns[$pattern] = self::ISBN13; - $lengths[$pattern] = $length; - } - - // check pattern list - foreach ($patterns as $pattern => $type) { - if ((strlen($this->_value) == $lengths[$pattern]) && preg_match($pattern, $this->_value)) { - return $type; - } - } - - return null; - } - - /** - * Defined by Zend_Validate_Interface. - * - * Returns true if and only if $value is a valid ISBN. - * - * @param string $value - * @return boolean - */ - public function isValid($value) - { - if (!is_string($value) && !is_int($value)) { - $this->_error(self::INVALID); - return false; - } - - $value = (string) $value; - $this->_setValue($value); - - switch ($this->_detectFormat()) { - case self::ISBN10: - // sum - $isbn10 = str_replace($this->_separator, '', $value); - $sum = 0; - for ($i = 0; $i < 9; $i++) { - $sum += (10 - $i) * $isbn10{$i}; - } - - // checksum - $checksum = 11 - ($sum % 11); - if ($checksum == 11) { - $checksum = '0'; - } elseif ($checksum == 10) { - $checksum = 'X'; - } - break; - - case self::ISBN13: - // sum - $isbn13 = str_replace($this->_separator, '', $value); - $sum = 0; - for ($i = 0; $i < 12; $i++) { - if ($i % 2 == 0) { - $sum += $isbn13{$i}; - } else { - $sum += 3 * $isbn13{$i}; - } - } - // checksum - $checksum = 10 - ($sum % 10); - if ($checksum == 10) { - $checksum = '0'; - } - break; - - default: - $this->_error(self::NO_ISBN); - return false; - } - - // validate - if (substr($this->_value, -1) != $checksum) { - $this->_error(self::NO_ISBN); - return false; - } - return true; - } - - /** - * Set separator characters. - * - * It is allowed only empty string, hyphen and space. - * - * @param string $separator - * @throws Zend_Validate_Exception When $separator is not valid - * @return Zend_Validate_Isbn Provides a fluent interface - */ - public function setSeparator($separator) - { - // check separator - if (!in_array($separator, array('-', ' ', ''))) { - /** - * @see Zend_Validate_Exception - */ - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Invalid ISBN separator.'); - } - - $this->_separator = $separator; - return $this; - } - - /** - * Get separator characters. - * - * @return string - */ - public function getSeparator() - { - return $this->_separator; - } - - /** - * Set allowed ISBN type. - * - * @param string $type - * @throws Zend_Validate_Exception When $type is not valid - * @return Zend_Validate_Isbn Provides a fluent interface - */ - public function setType($type) - { - // check type - if (!in_array($type, array(self::AUTO, self::ISBN10, self::ISBN13))) { - /** - * @see Zend_Validate_Exception - */ - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Invalid ISBN type'); - } - - $this->_type = $type; - return $this; - } - - /** - * Get allowed ISBN type. - * - * @return string - */ - public function getType() - { - return $this->_type; - } -} diff --git a/libs/Zend/Validate/LessThan.php b/libs/Zend/Validate/LessThan.php index 213c766f88..5d4e155559 100644 --- a/libs/Zend/Validate/LessThan.php +++ b/libs/Zend/Validate/LessThan.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,24 +15,27 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LessThan.php 20182 2010-01-10 21:12:01Z thomas $ + * @version $Id: LessThan.php 17470 2009-08-08 22:27:09Z thomas $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_LessThan extends Zend_Validate_Abstract { + const NOT_LESS = 'notLessThan'; /** @@ -58,24 +62,11 @@ class Zend_Validate_LessThan extends Zend_Validate_Abstract /** * Sets validator options * - * @param mixed|Zend_Config $max + * @param mixed $max * @return void */ public function __construct($max) { - if ($max instanceof Zend_Config) { - $max = $max->toArray(); - } - - if (is_array($max)) { - if (array_key_exists('max', $max)) { - $max = $max['max']; - } else { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Missing option 'max'"); - } - } - $this->setMax($max); } diff --git a/libs/Zend/Validate/NotEmpty.php b/libs/Zend/Validate/NotEmpty.php index e370459cf9..304cf4fe70 100644 --- a/libs/Zend/Validate/NotEmpty.php +++ b/libs/Zend/Validate/NotEmpty.php @@ -14,51 +14,27 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NotEmpty.php 20193 2010-01-11 10:40:43Z thomas $ + * @version $Id: NotEmpty.php 18186 2009-09-17 18:57:00Z matthew $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract { - const BOOLEAN = 1; - const INTEGER = 2; - const FLOAT = 4; - const STRING = 8; - const ZERO = 16; - const EMPTY_ARRAY = 32; - const NULL = 64; - const PHP = 127; - const SPACE = 128; - const ALL = 255; - const INVALID = 'notEmptyInvalid'; const IS_EMPTY = 'isEmpty'; - protected $_constants = array( - self::BOOLEAN => 'boolean', - self::INTEGER => 'integer', - self::FLOAT => 'float', - self::STRING => 'string', - self::ZERO => 'zero', - self::EMPTY_ARRAY => 'array', - self::NULL => 'null', - self::PHP => 'php', - self::SPACE => 'space', - self::ALL => 'all' - ); - /** * @var array */ @@ -68,80 +44,6 @@ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract ); /** - * Internal type to detect - * - * @var integer - */ - protected $_type = 237; - - /** - * 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['type'] = array_shift($options); - } - - $options = $temp; - } - - if (is_array($options) && array_key_exists('type', $options)) { - $this->setType($options['type']); - } - } - - /** - * Returns the set types - * - * @return array - */ - public function getType() - { - return $this->_type; - } - - /** - * Set the types - * - * @param integer|array $type - * @throws Zend_Validate_Exception - * @return Zend_Validate_NotEmpty - */ - 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) && in_array($type, $this->_constants)) { - $type = array_search($type, $this->_constants); - } - - if (!is_int($type) || ($type < 0) || ($type > self::ALL)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Unknown type'); - } - - $this->_type = $type; - return $this; - } - - /** * Defined by Zend_Validate_Interface * * Returns true if and only if $value is not an empty value. @@ -157,81 +59,21 @@ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract return false; } - $type = $this->getType(); $this->_setValue($value); - - // SPACE (' ') - if ($type >= self::SPACE) { - $type -= self::SPACE; - if (is_string($value) && (preg_match('/^\s+$/s', $value))) { - $this->_error(self::IS_EMPTY); - return false; - } - } - - // NULL (null) - if ($type >= self::NULL) { - $type -= self::NULL; - if (is_null($value)) { - $this->_error(self::IS_EMPTY); - return false; - } - } - - // EMPTY_ARRAY (array()) - if ($type >= self::EMPTY_ARRAY) { - $type -= self::EMPTY_ARRAY; - if (is_array($value) && ($value == array())) { - $this->_error(self::IS_EMPTY); - return false; - } - } - - // ZERO ('0') - if ($type >= self::ZERO) { - $type -= self::ZERO; - if (is_string($value) && ($value == '0')) { - $this->_error(self::IS_EMPTY); - return false; - } - } - - // STRING ('') - if ($type >= self::STRING) { - $type -= self::STRING; - if (is_string($value) && ($value == '')) { - $this->_error(self::IS_EMPTY); - return false; - } - } - - // FLOAT (0.0) - if ($type >= self::FLOAT) { - $type -= self::FLOAT; - if (is_float($value) && ($value == 0.0)) { - $this->_error(self::IS_EMPTY); - return false; - } - } - - // INTEGER (0) - if ($type >= self::INTEGER) { - $type -= self::INTEGER; - if (is_int($value) && ($value == 0)) { - $this->_error(self::IS_EMPTY); - return false; - } - } - - // BOOLEAN (false) - if ($type >= self::BOOLEAN) { - $type -= self::BOOLEAN; - if (is_bool($value) && ($value == false)) { - $this->_error(self::IS_EMPTY); - return false; - } + if (is_string($value) + && (('' === $value) + || preg_match('/^\s+$/s', $value)) + ) { + $this->_error(self::IS_EMPTY); + return false; + } elseif (is_int($value) && (0 === $value)) { + return true; + } elseif (!is_string($value) && empty($value)) { + $this->_error(self::IS_EMPTY); + return false; } return true; } + } diff --git a/libs/Zend/Validate/PostCode.php b/libs/Zend/Validate/PostCode.php deleted file mode 100644 index 1ba58a996b..0000000000 --- a/libs/Zend/Validate/PostCode.php +++ /dev/null @@ -1,210 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PostCode.php 21487 2010-03-14 10:17:35Z thomas $ - */ - -/** - * @see Zend_Validate_Abstract - */ -// require_once 'Zend/Validate/Abstract.php'; - -/** - * @see Zend_Locale_Format - */ -// require_once 'Zend/Locale/Format.php'; - -/** - * @category Zend - * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_PostCode extends Zend_Validate_Abstract -{ - const INVALID = 'postcodeInvalid'; - const NO_MATCH = 'postcodeNoMatch'; - - /** - * @var array - */ - protected $_messageTemplates = array( - self::INVALID => "Invalid type given. The value should be a string or a integer", - self::NO_MATCH => "'%value%' does not appear to be a postal code", - ); - - /** - * Locale to use - * - * @var string - */ - protected $_locale; - - /** - * Manual postal code format - * - * @var unknown_type - */ - protected $_format; - - /** - * Constructor for the integer validator - * - * Accepts either a string locale, a Zend_Locale object, or an array or - * Zend_Config object containing the keys "locale" and/or "format". - * - * @param string|Zend_Locale|array|Zend_Config $options - * @throws Zend_Validate_Exception On empty format - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - if (empty($options)) { - // require_once 'Zend/Registry.php'; - if (Zend_Registry::isRegistered('Zend_Locale')) { - $this->setLocale(Zend_Registry::get('Zend_Locale')); - } - } elseif (is_array($options)) { - // Received - if (array_key_exists('locale', $options)) { - $this->setLocale($options['locale']); - } - - if (array_key_exists('format', $options)) { - $this->setFormat($options['format']); - } - } elseif ($options instanceof Zend_Locale || is_string($options)) { - // Received Locale object or string locale - $this->setLocale($options); - } - - $format = $this->getFormat(); - if (empty($format)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("A postcode-format string has to be given for validation"); - } - } - - /** - * Returns the set locale - * - * @return string|Zend_Locale The set locale - */ - public function getLocale() - { - return $this->_locale; - } - - /** - * Sets the locale to use - * - * @param string|Zend_Locale $locale - * @throws Zend_Validate_Exception On unrecognised region - * @throws Zend_Validate_Exception On not detected format - * @return Zend_Validate_PostCode Provides fluid interface - */ - public function setLocale($locale = null) - { - // require_once 'Zend/Locale.php'; - $this->_locale = Zend_Locale::findLocale($locale); - $locale = new Zend_Locale($this->_locale); - $region = $locale->getRegion(); - if (empty($region)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Unable to detect a region for the locale '$locale'"); - } - - $format = Zend_Locale::getTranslation( - $locale->getRegion(), - 'postaltoterritory', - $this->_locale - ); - - if (empty($format)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'"); - } - - $this->setFormat($format); - return $this; - } - - /** - * Returns the set postal code format - * - * @return string - */ - public function getFormat() - { - return $this->_format; - } - - /** - * Sets a self defined postal format as regex - * - * @param string $format - * @throws Zend_Validate_Exception On empty format - * @return Zend_Validate_PostCode Provides fluid interface - */ - public function setFormat($format) - { - if (empty($format) || !is_string($format)) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("A postcode-format string has to be given for validation"); - } - - if ($format[0] !== '/') { - $format = '/^' . $format; - } - - if ($format[strlen($format) - 1] !== '/') { - $format .= '$/'; - } - - $this->_format = $format; - return $this; - } - - /** - * Defined by Zend_Validate_Interface - * - * Returns true if and only if $value is a valid postalcode - * - * @param string $value - * @return boolean - */ - public function isValid($value) - { - $this->_setValue($value); - if (!is_string($value) && !is_int($value)) { - $this->_error(self::INVALID); - return false; - } - - $format = $this->getFormat(); - if (!preg_match($format, $value)) { - $this->_error(self::NO_MATCH); - return false; - } - - return true; - } -} diff --git a/libs/Zend/Validate/Regex.php b/libs/Zend/Validate/Regex.php index e46143287f..e4707f5f60 100644 --- a/libs/Zend/Validate/Regex.php +++ b/libs/Zend/Validate/Regex.php @@ -1,4 +1,5 @@ <?php + /** * Zend Framework * @@ -14,35 +15,35 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Regex.php 21574 2010-03-19 20:00:37Z thomas $ + * @version $Id: Regex.php 17470 2009-08-08 22:27:09Z thomas $ */ + /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; + /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Regex extends Zend_Validate_Abstract { const INVALID = 'regexInvalid'; const NOT_MATCH = 'regexNotMatch'; - const ERROROUS = 'regexErrorous'; /** * @var array */ protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be string, integer or float", - self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'", - self::ERROROUS => "There was an internal error while using the pattern '%pattern%'", + self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'" ); /** @@ -62,25 +63,11 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract /** * Sets validator options * - * @param string|Zend_Config $pattern - * @throws Zend_Validate_Exception On missing 'pattern' parameter + * @param string $pattern * @return void */ public function __construct($pattern) { - if ($pattern instanceof Zend_Config) { - $pattern = $pattern->toArray(); - } - - if (is_array($pattern)) { - if (array_key_exists('pattern', $pattern)) { - $pattern = $pattern['pattern']; - } else { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Missing option 'pattern'"); - } - } - $this->setPattern($pattern); } @@ -98,19 +85,11 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract * Sets the pattern option * * @param string $pattern - * @throws Zend_Validate_Exception if there is a fatal error in pattern matching * @return Zend_Validate_Regex Provides a fluent interface */ public function setPattern($pattern) { $this->_pattern = (string) $pattern; - $status = @preg_match($this->_pattern, "Test"); - - if (false === $status) { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'"); - } - return $this; } @@ -120,6 +99,7 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract * Returns true if and only if $value matches against the pattern option * * @param string $value + * @throws Zend_Validate_Exception if there is a fatal error in pattern matching * @return boolean */ public function isValid($value) @@ -133,15 +113,14 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract $status = @preg_match($this->_pattern, $value); if (false === $status) { - $this->_error(self::ERROROUS); - return false; + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$value'"); } - if (!$status) { $this->_error(self::NOT_MATCH); return false; } - return true; } + } diff --git a/libs/Zend/Validate/Sitemap/Changefreq.php b/libs/Zend/Validate/Sitemap/Changefreq.php index 6f023856dc..9ff2715d20 100644 --- a/libs/Zend/Validate/Sitemap/Changefreq.php +++ b/libs/Zend/Validate/Sitemap/Changefreq.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Changefreq.php 21365 2010-03-07 09:38:41Z thomas $ + * @version $Id: Changefreq.php 17470 2009-08-08 22:27:09Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validates whether a given value is valid as a sitemap <changefreq> value @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract @@ -42,8 +42,7 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract * Validation key for not valid * */ - const NOT_VALID = 'sitemapChangefreqNotValid'; - const INVALID = 'sitemapChangefreqInvalid'; + const NOT_VALID = 'invalidSitemapChangefreq'; /** * Validation failure message template definitions @@ -51,8 +50,7 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_VALID => "'%value%' is no valid sitemap changefreq", - self::INVALID => "Invalid type given, the value should be a string", + self::NOT_VALID => "'%value%' is not a valid sitemap changefreq", ); /** @@ -75,12 +73,8 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract */ public function isValid($value) { - if (!is_string($value)) { - $this->_error(self::INVALID); - return false; - } - $this->_setValue($value); + if (!is_string($value)) { return false; } diff --git a/libs/Zend/Validate/Sitemap/Lastmod.php b/libs/Zend/Validate/Sitemap/Lastmod.php index aa2266ecd9..4f01d1a781 100644 --- a/libs/Zend/Validate/Sitemap/Lastmod.php +++ b/libs/Zend/Validate/Sitemap/Lastmod.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Lastmod.php 21365 2010-03-07 09:38:41Z thomas $ + * @version $Id: Lastmod.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validates whether a given value is valid as a sitemap <lastmod> value @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract @@ -42,14 +42,13 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract * Regular expression to use when validating * */ - const LASTMOD_REGEX = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3])(:[0-5][0-9])(:[0-5][0-9])?(\\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])?$/'; + const LASTMOD_REGEX = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3])(:[0-5][0-9]){2}(\\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])?$/m'; /** * Validation key for not valid * */ - const NOT_VALID = 'sitemapLastmodNotValid'; - const INVALID = 'sitemapLastmodInvalid'; + const NOT_VALID = 'invalidSitemapLastmod'; /** * Validation failure message template definitions @@ -57,8 +56,7 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_VALID => "'%value%' is no valid sitemap lastmod", - self::INVALID => "Invalid type given, the value should be a string", + self::NOT_VALID => "'%value%' is not a valid sitemap lastmod", ); /** @@ -71,18 +69,13 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract */ public function isValid($value) { - if (!is_string($value)) { - $this->_error(self::INVALID); - return false; - } - $this->_setValue($value); - $result = @preg_match(self::LASTMOD_REGEX, $value); - if ($result != 1) { - $this->_error(self::NOT_VALID); + + if (!is_string($value)) { return false; } - return true; + return @preg_match(self::LASTMOD_REGEX, $value) == 1; } + } diff --git a/libs/Zend/Validate/Sitemap/Loc.php b/libs/Zend/Validate/Sitemap/Loc.php index 180f669a01..92d5272030 100644 --- a/libs/Zend/Validate/Sitemap/Loc.php +++ b/libs/Zend/Validate/Sitemap/Loc.php @@ -15,20 +15,20 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Loc.php 21365 2010-03-07 09:38:41Z thomas $ + * @version $Id: Loc.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @see Zend_Uri */ -// require_once 'Zend/Uri.php'; +require_once 'Zend/Uri.php'; /** * Validates whether a given value is valid as a sitemap <loc> value @@ -38,7 +38,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract @@ -47,8 +47,7 @@ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract * Validation key for not valid * */ - const NOT_VALID = 'sitemapLocNotValid'; - const INVALID = 'sitemapLocInvalid'; + const NOT_VALID = 'invalidSitemapLoc'; /** * Validation failure message template definitions @@ -56,8 +55,7 @@ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_VALID => "'%value%' is no valid sitemap location", - self::INVALID => "Invalid type given, the value should be a string", + self::NOT_VALID => "'%value%' is not a valid sitemap location", ); /** @@ -70,18 +68,12 @@ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract */ public function isValid($value) { - if (!is_string($value)) { - $this->_error(self::INVALID); - return false; - } - $this->_setValue($value); - $result = Zend_Uri::check($value); - if ($result !== true) { - $this->_error(self::NOT_VALID); + + if (!is_string($value)) { return false; } - return true; + return Zend_Uri::check($value); } } diff --git a/libs/Zend/Validate/Sitemap/Priority.php b/libs/Zend/Validate/Sitemap/Priority.php index 58772d5b2d..3568a9fc0f 100644 --- a/libs/Zend/Validate/Sitemap/Priority.php +++ b/libs/Zend/Validate/Sitemap/Priority.php @@ -15,15 +15,15 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Priority.php 21365 2010-03-07 09:38:41Z thomas $ + * @version $Id: Priority.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validates whether a given value is valid as a sitemap <priority> value @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract @@ -42,8 +42,7 @@ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract * Validation key for not valid * */ - const NOT_VALID = 'sitemapPriorityNotValid'; - const INVALID = 'sitemapPriorityInvalid'; + const NOT_VALID = 'invalidSitemapPriority'; /** * Validation failure message template definitions @@ -51,8 +50,7 @@ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_VALID => "'%value%' is no valid sitemap priority", - self::INVALID => "Invalid type given, the value should be a integer, a float or a numeric string", + self::NOT_VALID => "'%value%' is not a valid sitemap priority", ); /** @@ -65,18 +63,13 @@ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract */ public function isValid($value) { - if (!is_numeric($value)) { - $this->_error(self::INVALID); - return false; - } - $this->_setValue($value); - $value = (float) $value; - if ($value < 0 || $value > 1) { - $this->_error(self::NOT_VALID); + + if (!is_numeric($value)) { return false; } - return true; + $value = (float)$value; + return $value >= 0 && $value <= 1; } } diff --git a/libs/Zend/Validate/StringLength.php b/libs/Zend/Validate/StringLength.php index c9362ace22..7ec9125f92 100644 --- a/libs/Zend/Validate/StringLength.php +++ b/libs/Zend/Validate/StringLength.php @@ -14,20 +14,20 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringLength.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: StringLength.php 16223 2009-06-21 20:04:53Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_StringLength extends Zend_Validate_Abstract @@ -42,7 +42,7 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract protected $_messageTemplates = array( self::INVALID => "Invalid type given, value should be a string", self::TOO_SHORT => "'%value%' is less than %min% characters long", - self::TOO_LONG => "'%value%' is more than %max% characters long", + self::TOO_LONG => "'%value%' is greater than %max% characters long" ); /** @@ -79,39 +79,15 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract /** * Sets validator options * - * @param integer|array|Zend_Config $options + * @param integer $min + * @param integer $max * @return void */ - public function __construct($options = array()) + public function __construct($min = 0, $max = null, $encoding = null) { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['min'] = array_shift($options); - if (!empty($options)) { - $temp['max'] = array_shift($options); - } - - if (!empty($options)) { - $temp['encoding'] = array_shift($options); - } - - $options = $temp; - } - - if (!array_key_exists('min', $options)) { - $options['min'] = 0; - } - - $this->setMin($options['min']); - if (array_key_exists('max', $options)) { - $this->setMax($options['max']); - } - - if (array_key_exists('encoding', $options)) { - $this->setEncoding($options['encoding']); - } + $this->setMin($min); + $this->setMax($max); + $this->setEncoding($encoding); } /** @@ -137,7 +113,7 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract /** * @see Zend_Validate_Exception */ - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum length, but $min >" . " $this->_max"); } @@ -170,7 +146,7 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract /** * @see Zend_Validate_Exception */ - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum length, but " . "$max < $this->_min"); } else { @@ -202,7 +178,7 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract $orig = iconv_get_encoding('internal_encoding'); $result = iconv_set_encoding('internal_encoding', $encoding); if (!$result) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Given encoding not supported on this OS!'); } diff --git a/libs/Zend/Version.php b/libs/Zend/Version.php index 392ae3c7df..ded3d4cdd1 100644 --- a/libs/Zend/Version.php +++ b/libs/Zend/Version.php @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Version - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Version.php 22304 2010-05-26 14:25:33Z matthew $ + * @version $Id: Version.php 18706 2009-10-26 13:15:20Z matthew $ */ /** @@ -24,7 +24,7 @@ * * @category Zend * @package Zend_Version - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ final class Zend_Version @@ -32,7 +32,7 @@ final class Zend_Version /** * Zend Framework version identification - see compareVersion() */ - const VERSION = '1.10.5'; + const VERSION = '1.9.5'; /** * Compare the specified Zend Framework version string $version |