diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-06-23 07:02:26 +0400 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-06-23 07:02:26 +0400 |
commit | 999f46479294713104c962bfe7469e9b6e7a4bbf (patch) | |
tree | a22e349d850bc2f2946a85a3cab373c4b6dc1809 /libs/Zend/Uri.php | |
parent | 462d78c290f19dd691d9634bf2b17d2adc4446af (diff) | |
parent | c0b42ff664a0846064df23db232ea774931ab7a3 (diff) |
0.6.3?
Diffstat (limited to 'libs/Zend/Uri.php')
-rw-r--r-- | libs/Zend/Uri.php | 85 |
1 files changed, 32 insertions, 53 deletions
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. |