mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 00:03:58 +01:00 
			
		
		
		
	Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
		
							parent
							
								
									5a580df460
								
							
						
					
					
						commit
						235a541597
					
				
					 793 changed files with 60746 additions and 23753 deletions
				
			
		|  | @ -1,23 +1,25 @@ | |||
| <?php | ||||
| /** | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * | ||||
|  * Licensed under The MIT License | ||||
|  * For full copyright and license information, please see the LICENSE.txt | ||||
|  * Redistributions of files must retain the above copyright notice. | ||||
|  * | ||||
|  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP(tm) Project | ||||
|  * @since         CakePHP(tm) v 1.3 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Hash', 'Utility'); | ||||
| 
 | ||||
| /** | ||||
|  * A single Route used by the Router to connect requests to | ||||
|  * parameter maps. | ||||
|  * | ||||
|  * Not normally created as a standalone.  Use Router::connect() to create | ||||
|  * Not normally created as a standalone. Use Router::connect() to create | ||||
|  * Routes for your application. | ||||
|  * | ||||
|  * @package Cake.Routing.Route | ||||
|  | @ -69,7 +71,7 @@ class CakeRoute { | |||
| 	protected $_compiledRoute = null; | ||||
| 
 | ||||
| /** | ||||
|  * HTTP header shortcut map.  Used for evaluating header-based route expressions. | ||||
|  * HTTP header shortcut map. Used for evaluating header-based route expressions. | ||||
|  * | ||||
|  * @var array | ||||
|  */ | ||||
|  | @ -95,14 +97,16 @@ class CakeRoute { | |||
| /** | ||||
|  * Check if a Route has been compiled into a regular expression. | ||||
|  * | ||||
|  * @return boolean | ||||
|  * @return bool | ||||
|  */ | ||||
| 	public function compiled() { | ||||
| 		return !empty($this->_compiledRoute); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Compiles the route's regular expression.  Modifies defaults property so all necessary keys are set | ||||
|  * Compiles the route's regular expression. | ||||
|  * | ||||
|  * Modifies defaults property so all necessary keys are set | ||||
|  * and populates $this->names with the named routing elements. | ||||
|  * | ||||
|  * @return array Returns a string regular expression of the compiled route. | ||||
|  | @ -116,8 +120,10 @@ class CakeRoute { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Builds a route regular expression.  Uses the template, defaults and options | ||||
|  * properties to compile a regular expression that can be used to parse request strings. | ||||
|  * Builds a route regular expression. | ||||
|  * | ||||
|  * Uses the template, defaults and options properties to compile a | ||||
|  * regular expression that can be used to parse request strings. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -153,7 +159,8 @@ class CakeRoute { | |||
| 		if (preg_match('#\/\*\*$#', $route)) { | ||||
| 			$parsed = preg_replace('#/\\\\\*\\\\\*$#', '(?:/(?P<_trailing_>.*))?', $parsed); | ||||
| 			$this->_greedy = true; | ||||
| 		} elseif (preg_match('#\/\*$#', $route)) { | ||||
| 		} | ||||
| 		if (preg_match('#\/\*$#', $route)) { | ||||
| 			$parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed); | ||||
| 			$this->_greedy = true; | ||||
| 		} | ||||
|  | @ -162,25 +169,30 @@ class CakeRoute { | |||
| 		$this->_compiledRoute = '#^' . $parsed . '[/]*$#'; | ||||
| 		$this->keys = $names; | ||||
| 
 | ||||
| 		//remove defaults that are also keys. They can cause match failures
 | ||||
| 		// Remove defaults that are also keys. They can cause match failures
 | ||||
| 		foreach ($this->keys as $key) { | ||||
| 			unset($this->defaults[$key]); | ||||
| 		} | ||||
| 
 | ||||
| 		$keys = $this->keys; | ||||
| 		sort($keys); | ||||
| 		$this->keys = array_reverse($keys); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Checks to see if the given URL can be parsed by this route. | ||||
|  * If the route can be parsed an array of parameters will be returned; if not | ||||
|  * false will be returned. String urls are parsed if they match a routes regular expression. | ||||
|  * | ||||
|  * @param string $url The url to attempt to parse. | ||||
|  * If the route can be parsed an array of parameters will be returned; if not | ||||
|  * false will be returned. String URLs are parsed if they match a routes regular expression. | ||||
|  * | ||||
|  * @param string $url The URL to attempt to parse. | ||||
|  * @return mixed Boolean false on failure, otherwise an array or parameters | ||||
|  */ | ||||
| 	public function parse($url) { | ||||
| 		if (!$this->compiled()) { | ||||
| 			$this->compile(); | ||||
| 		} | ||||
| 		if (!preg_match($this->_compiledRoute, $url, $route)) { | ||||
| 		if (!preg_match($this->_compiledRoute, urldecode($url), $route)) { | ||||
| 			return false; | ||||
| 		} | ||||
| 		foreach ($this->defaults as $key => $val) { | ||||
|  | @ -218,19 +230,13 @@ class CakeRoute { | |||
| 			if (isset($route[$key])) { | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (is_integer($key)) { | ||||
| 			if (is_int($key)) { | ||||
| 				$route['pass'][] = $value; | ||||
| 				continue; | ||||
| 			} | ||||
| 			$route[$key] = $value; | ||||
| 		} | ||||
| 
 | ||||
| 		foreach ($this->keys as $key) { | ||||
| 			if (isset($route[$key])) { | ||||
| 				$route[$key] = rawurldecode($route[$key]); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if (isset($route['_args_'])) { | ||||
| 			list($pass, $named) = $this->_parseArgs($route['_args_'], $route); | ||||
| 			$route['pass'] = array_merge($route['pass'], $pass); | ||||
|  | @ -239,7 +245,7 @@ class CakeRoute { | |||
| 		} | ||||
| 
 | ||||
| 		if (isset($route['_trailing_'])) { | ||||
| 			$route['pass'][] = rawurldecode($route['_trailing_']); | ||||
| 			$route['pass'][] = $route['_trailing_']; | ||||
| 			unset($route['_trailing_']); | ||||
| 		} | ||||
| 
 | ||||
|  | @ -259,7 +265,7 @@ class CakeRoute { | |||
|  * Parse passed and Named parameters into a list of passed args, and a hash of named parameters. | ||||
|  * The local and global configuration for named parameters will be used. | ||||
|  * | ||||
|  * @param string $args A string with the passed & named params.  eg. /1/page:2 | ||||
|  * @param string $args A string with the passed & named params. eg. /1/page:2 | ||||
|  * @param string $context The current route context, which should contain controller/action keys. | ||||
|  * @return array Array of ($pass, $named) | ||||
|  */ | ||||
|  | @ -289,12 +295,10 @@ class CakeRoute { | |||
| 			$separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; | ||||
| 			if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { | ||||
| 				list($key, $val) = explode($namedConfig['separator'], $param, 2); | ||||
| 				$key = rawurldecode($key); | ||||
| 				$val = rawurldecode($val); | ||||
| 				$hasRule = isset($rules[$key]); | ||||
| 				$passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context)); | ||||
| 				if ($passIt) { | ||||
| 					$pass[] = rawurldecode($param); | ||||
| 					$pass[] = $param; | ||||
| 				} else { | ||||
| 					if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { | ||||
| 						$matches = array_reverse($matches); | ||||
|  | @ -315,20 +319,22 @@ class CakeRoute { | |||
| 					$named = array_merge_recursive($named, array($key => $val)); | ||||
| 				} | ||||
| 			} else { | ||||
| 				$pass[] = rawurldecode($param); | ||||
| 				$pass[] = $param; | ||||
| 			} | ||||
| 		} | ||||
| 		return array($pass, $named); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Return true if a given named $param's $val matches a given $rule depending on $context. Currently implemented | ||||
|  * rule types are controller, action and match that can be combined with each other. | ||||
|  * Check if a named parameter matches the current rules. | ||||
|  * | ||||
|  * Return true if a given named $param's $val matches a given $rule depending on $context. | ||||
|  * Currently implemented rule types are controller, action and match that can be combined with each other. | ||||
|  * | ||||
|  * @param string $val The value of the named parameter | ||||
|  * @param array $rule The rule(s) to apply, can also be a match string | ||||
|  * @param string $context An array with additional context information (controller / action) | ||||
|  * @return boolean | ||||
|  * @return bool | ||||
|  */ | ||||
| 	protected function _matchNamed($val, $rule, $context) { | ||||
| 		if ($rule === true || $rule === false) { | ||||
|  | @ -359,15 +365,18 @@ class CakeRoute { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Apply persistent parameters to a url array. Persistent parameters are a special | ||||
|  * Apply persistent parameters to a URL array. Persistent parameters are a special | ||||
|  * key used during route creation to force route parameters to persist when omitted from | ||||
|  * a url array. | ||||
|  * a URL array. | ||||
|  * | ||||
|  * @param array $url The array to apply persistent parameters to. | ||||
|  * @param array $params An array of persistent values to replace persistent ones. | ||||
|  * @return array An array with persistent parameters applied. | ||||
|  */ | ||||
| 	public function persistParams($url, $params) { | ||||
| 		if (empty($this->options['persist']) || !is_array($this->options['persist'])) { | ||||
| 			return $url; | ||||
| 		} | ||||
| 		foreach ($this->options['persist'] as $persistKey) { | ||||
| 			if (array_key_exists($persistKey, $params) && !isset($url[$persistKey])) { | ||||
| 				$url[$persistKey] = $params[$persistKey]; | ||||
|  | @ -377,12 +386,14 @@ class CakeRoute { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Attempt to match a url array.  If the url matches the route parameters and settings, then | ||||
|  * return a generated string url.  If the url doesn't match the route parameters, false will be returned. | ||||
|  * This method handles the reverse routing or conversion of url arrays into string urls. | ||||
|  * Check if a URL array matches this route instance. | ||||
|  * | ||||
|  * If the URL matches the route parameters and settings, then | ||||
|  * return a generated string URL. If the URL doesn't match the route parameters, false will be returned. | ||||
|  * This method handles the reverse routing or conversion of URL arrays into string URLs. | ||||
|  * | ||||
|  * @param array $url An array of parameters to check matching with. | ||||
|  * @return mixed Either a string url for the parameters if they match or false. | ||||
|  * @return mixed Either a string URL for the parameters if they match or false. | ||||
|  */ | ||||
| 	public function match($url) { | ||||
| 		if (!$this->compiled()) { | ||||
|  | @ -413,7 +424,6 @@ class CakeRoute { | |||
| 		$named = $pass = array(); | ||||
| 
 | ||||
| 		foreach ($url as $key => $value) { | ||||
| 
 | ||||
| 			// keys that exist in the defaults and have different values is a match failure.
 | ||||
| 			$defaultExists = array_key_exists($key, $defaults); | ||||
| 			if ($defaultExists && $defaults[$key] != $value) { | ||||
|  | @ -438,8 +448,7 @@ class CakeRoute { | |||
| 			} | ||||
| 
 | ||||
| 			// pull out named params if named params are greedy or a rule exists.
 | ||||
| 			if ( | ||||
| 				($greedyNamed || isset($allowedNamedParams[$key])) && | ||||
| 			if (($greedyNamed || isset($allowedNamedParams[$key])) && | ||||
| 				($value !== false && $value !== null) && | ||||
| 				(!in_array($key, $prefixes)) | ||||
| 			) { | ||||
|  | @ -470,10 +479,12 @@ class CakeRoute { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Converts a matching route array into a url string. Composes the string url using the template | ||||
|  * Converts a matching route array into a URL string. | ||||
|  * | ||||
|  * Composes the string URL using the template | ||||
|  * used to create the route. | ||||
|  * | ||||
|  * @param array $params The params to convert to a string url. | ||||
|  * @param array $params The params to convert to a string URL. | ||||
|  * @return string Composed route string. | ||||
|  */ | ||||
| 	protected function _writeUrl($params) { | ||||
|  | @ -481,7 +492,7 @@ class CakeRoute { | |||
| 			$prefixed = $params['prefix'] . '_'; | ||||
| 		} | ||||
| 		if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) { | ||||
| 			$params['action'] = substr($params['action'], strlen($prefixed) * -1); | ||||
| 			$params['action'] = substr($params['action'], strlen($prefixed)); | ||||
| 			unset($params['prefix']); | ||||
| 		} | ||||
| 
 | ||||
|  | @ -508,24 +519,48 @@ class CakeRoute { | |||
| 		} | ||||
| 		$out = $this->template; | ||||
| 
 | ||||
| 		$search = $replace = array(); | ||||
| 		foreach ($this->keys as $key) { | ||||
| 			$string = null; | ||||
| 			if (isset($params[$key])) { | ||||
| 				$string = $params[$key]; | ||||
| 			} elseif (strpos($out, $key) != strlen($out) - strlen($key)) { | ||||
| 				$key .= '/'; | ||||
| 			} | ||||
| 			$search[] = ':' . $key; | ||||
| 			$replace[] = $string; | ||||
| 		} | ||||
| 		$out = str_replace($search, $replace, $out); | ||||
| 		if (!empty($this->keys)) { | ||||
| 			$search = $replace = array(); | ||||
| 
 | ||||
| 		if (strpos($this->template, '*')) { | ||||
| 			foreach ($this->keys as $key) { | ||||
| 				$string = null; | ||||
| 				if (isset($params[$key])) { | ||||
| 					$string = $params[$key]; | ||||
| 				} elseif (strpos($out, $key) != strlen($out) - strlen($key)) { | ||||
| 					$key .= '/'; | ||||
| 				} | ||||
| 				$search[] = ':' . $key; | ||||
| 				$replace[] = $string; | ||||
| 			} | ||||
| 			$out = str_replace($search, $replace, $out); | ||||
| 		} | ||||
| 
 | ||||
| 		if (strpos($this->template, '**') !== false) { | ||||
| 			$out = str_replace('**', $params['pass'], $out); | ||||
| 			$out = str_replace('%2F', '/', $out); | ||||
| 		} elseif (strpos($this->template, '*') !== false) { | ||||
| 			$out = str_replace('*', $params['pass'], $out); | ||||
| 		} | ||||
| 		$out = str_replace('//', '/', $out); | ||||
| 		return $out; | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Set state magic method to support var_export | ||||
|  * | ||||
|  * This method helps for applications that want to implement | ||||
|  * router caching. | ||||
|  * | ||||
|  * @param array $fields Key/Value of object attributes | ||||
|  * @return CakeRoute A new instance of the route | ||||
|  */ | ||||
| 	public static function __set_state($fields) { | ||||
| 		$class = function_exists('get_called_class') ? get_called_class() : __CLASS__; | ||||
| 		$obj = new $class(''); | ||||
| 		foreach ($fields as $field => $value) { | ||||
| 			$obj->$field = $value; | ||||
| 		} | ||||
| 		return $obj; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko