diff -r 5a6b6e770365 -r 68c69c656a2c web/lib/Zend/Controller/Router/Route.php --- a/web/lib/Zend/Controller/Router/Route.php Thu May 07 15:10:09 2015 +0200 +++ b/web/lib/Zend/Controller/Router/Route.php Thu May 07 15:16:02 2015 +0200 @@ -15,8 +15,8 @@ * @category Zend * @package Zend_Controller * @subpackage Router - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @version $Id: Route.php 24593 2012-01-05 20:35:02Z matthew $ + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id$ * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,12 +28,13 @@ * * @package Zend_Controller * @subpackage Router - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @see http://manuals.rubyonrails.com/read/chapter/65 */ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract { + /** * Default translator * @@ -77,12 +78,16 @@ protected $_translatable = array(); protected $_urlVariable = ':'; + protected $_urlDelimiter = self::URI_DELIMITER; + protected $_regexDelimiter = '#'; + protected $_defaultRegex = null; /** * Holds names of all route's pattern variable names. Array index holds a position in URL. + * * @var array */ protected $_variables = array(); @@ -91,12 +96,14 @@ * Holds Route patterns for all URL parts. In case of a variable it stores it's regex * requirement or null. In case of a static part, it holds only it's direct value. * In case of a wildcard, it stores an asterisk (*) + * * @var array */ protected $_parts = array(); /** * Holds user submitted default values for route's variables. Name and value pairs. + * * @var array */ protected $_defaults = array(); @@ -104,6 +111,7 @@ /** * Holds user submitted regular expression patterns for route's variables' values. * Name and value pairs. + * * @var array */ protected $_requirements = array(); @@ -111,6 +119,7 @@ /** * Associative array filled on match() that holds matched path values * for given variable names. + * * @var array */ protected $_values = array(); @@ -118,6 +127,7 @@ /** * Associative array filled on match() that holds wildcard variable * names and values. + * * @var array */ protected $_wildcardData = array(); @@ -125,11 +135,13 @@ /** * Helper var that holds a count of route pattern's static parts * for validation + * * @var int */ protected $_staticCount = 0; - public function getVersion() { + public function getVersion() + { return 1; } @@ -137,11 +149,13 @@ * Instantiates route based on passed Zend_Config structure * * @param Zend_Config $config Configuration object + * @return Zend_Controller_Router_Route */ public static function getInstance(Zend_Config $config) { $reqs = ($config->reqs instanceof Zend_Config) ? $config->reqs->toArray() : array(); $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array(); + return new self($config->route, $defs, $reqs); } @@ -150,16 +164,19 @@ * to a corresponding atomic parts. These parts are assigned * a position which is later used for matching and preparing values. * - * @param string $route Map used to match with later submitted URL path - * @param array $defaults Defaults for map variables with keys as variable names - * @param array $reqs Regular expression requirements for variables (keys as variable names) + * @param string $route Map used to match with later submitted URL path + * @param array $defaults Defaults for map variables with keys as variable names + * @param array $reqs Regular expression requirements for variables (keys as variable names) * @param Zend_Translate $translator Translator to use for this instance + * @param mixed|null $locale */ - public function __construct($route, $defaults = array(), $reqs = array(), Zend_Translate $translator = null, $locale = null) + public function __construct( + $route, $defaults = array(), $reqs = array(), Zend_Translate $translator = null, $locale = null + ) { $route = trim($route, $this->_urlDelimiter); - $this->_defaults = (array) $defaults; - $this->_requirements = (array) $reqs; + $this->_defaults = (array)$defaults; + $this->_requirements = (array)$reqs; $this->_translator = $translator; $this->_locale = $locale; @@ -199,7 +216,9 @@ * Matches a user submitted path with parts defined by a map. Assigns and * returns an array of variables on a successful match. * - * @param string $path Path used to match against this routing map + * @param string $path Path used to match against this routing map + * @param boolean $partial + * @throws Zend_Controller_Router_Exception * @return array|false An array of assigned values or a false on a mismatch */ public function match($path, $partial = false) @@ -234,10 +253,12 @@ // If it's a wildcard, get the rest of URL as wildcard data and stop matching if ($this->_parts[$pos] == '*') { $count = count($path); - for($i = $pos; $i < $count; $i+=2) { + for ($i = $pos; $i < $count; $i += 2) { $var = urldecode($path[$i]); - if (!isset($this->_wildcardData[$var]) && !isset($this->_defaults[$var]) && !isset($values[$var])) { - $this->_wildcardData[$var] = (isset($path[$i+1])) ? urldecode($path[$i+1]) : null; + if (!isset($this->_wildcardData[$var]) && !isset($this->_defaults[$var]) + && !isset($values[$var]) + ) { + $this->_wildcardData[$var] = (isset($path[$i + 1])) ? urldecode($path[$i + 1]) : null; } } @@ -250,7 +271,11 @@ // Translate value if required $part = $this->_parts[$pos]; - if ($this->_isTranslated && (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@' && $name === null) || $name !== null && in_array($name, $this->_translatable)) { + if ($this->_isTranslated + && (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@' + && $name === null) + || $name !== null && in_array($name, $this->_translatable) + ) { if (substr($part, 0, 1) === '@') { $part = substr($part, 1); } @@ -270,7 +295,11 @@ } // If it's a variable with requirement, match a regex. If not - everything matches - if ($part !== null && !preg_match($this->_regexDelimiter . '^' . $part . '$' . $this->_regexDelimiter . 'iu', $pathPart)) { + if ($part !== null + && !preg_match( + $this->_regexDelimiter . '^' . $part . '$' . $this->_regexDelimiter . 'iu', $pathPart + ) + ) { return false; } @@ -305,14 +334,16 @@ $this->_values = $values; return $return; - } /** * Assembles user submitted parameters forming a URL path defined by this route * - * @param array $data An array of variable and value pairs used as parameters + * @param array $data An array of variable and value pairs used as parameters * @param boolean $reset Whether or not to set route defaults with those provided in $data + * @param boolean $encode + * @param boolean $partial + * @throws Zend_Controller_Router_Exception * @return string Route path with user submitted parameters */ public function assemble($data = array(), $reset = false, $encode = false, $partial = false) @@ -374,13 +405,15 @@ $url[$key] = $part; } } else { - if (!$reset) $data += $this->_wildcardData; + if (!$reset) { + $data += $this->_wildcardData; + } $defaults = $this->getDefaults(); foreach ($data as $var => $value) { if ($value !== null && (!isset($defaults[$var]) || $value != $defaults[$var])) { $url[$key++] = $var; $url[$key++] = $value; - $flag = true; + $flag = true; } } } @@ -394,20 +427,23 @@ if (isset($this->_variables[$key])) { $defaultValue = $this->getDefault($this->_variables[$key]); - if ($this->_isTranslated && $defaultValue !== null && isset($this->_translatable[$this->_variables[$key]])) { + if ($this->_isTranslated && $defaultValue !== null + && isset($this->_translatable[$this->_variables[$key]]) + ) { $defaultValue = $translator->translate($defaultValue, $locale); } } if ($flag || $value !== $defaultValue || $partial) { - if ($encode) $value = urlencode($value); + if ($encode) { + $value = urlencode($value); + } $return = $this->_urlDelimiter . $value . $return; - $flag = true; + $flag = true; } } return trim($return, $this->_urlDelimiter); - } /** @@ -416,10 +452,12 @@ * @param string $name Array key of the parameter * @return string Previously set default */ - public function getDefault($name) { + public function getDefault($name) + { if (isset($this->_defaults[$name])) { return $this->_defaults[$name]; } + return null; } @@ -428,7 +466,8 @@ * * @return array Route defaults */ - public function getDefaults() { + public function getDefaults() + { return $this->_defaults; } @@ -484,17 +523,19 @@ { if ($this->_translator !== null) { return $this->_translator; - } else if (($translator = self::getDefaultTranslator()) !== null) { - return $translator; } else { - try { - $translator = Zend_Registry::get('Zend_Translate'); - } catch (Zend_Exception $e) { - $translator = null; - } + if (($translator = self::getDefaultTranslator()) !== null) { + return $translator; + } else { + try { + $translator = Zend_Registry::get('Zend_Translate'); + } catch (Zend_Exception $e) { + $translator = null; + } - if ($translator instanceof Zend_Translate) { - return $translator; + if ($translator instanceof Zend_Translate) { + return $translator; + } } } @@ -543,17 +584,19 @@ { if ($this->_locale !== null) { return $this->_locale; - } else if (($locale = self::getDefaultLocale()) !== null) { - return $locale; } else { - try { - $locale = Zend_Registry::get('Zend_Locale'); - } catch (Zend_Exception $e) { - $locale = null; - } + if (($locale = self::getDefaultLocale()) !== null) { + return $locale; + } else { + try { + $locale = Zend_Registry::get('Zend_Locale'); + } catch (Zend_Exception $e) { + $locale = null; + } - if ($locale !== null) { - return $locale; + if ($locale !== null) { + return $locale; + } } }