mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
modifying Dispatcher::_getNameArgs()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3202 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
86fc29facb
commit
03756a8cf2
1 changed files with 39 additions and 29 deletions
|
@ -195,17 +195,17 @@ class Dispatcher extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($controller->params['pass'])) {
|
if (!empty($controller->params['pass'])) {
|
||||||
if ($controller->namedArgs !== false) {
|
|
||||||
if (is_array($controller->namedArgs) && in_array($params['action'], array_keys($controller->namedArgs))) {
|
|
||||||
$this->_getNamedArgs($controller->params['pass'], $controller->namedArgs[$params['action']]);
|
|
||||||
} elseif (is_int($controller->namedArgs) && $controller->namedArgs > 0) {
|
|
||||||
$this->_getNamedArgs($controller->params['pass'], $controller->namedArgs);
|
|
||||||
} elseif ($controller->namedArgs === true) {
|
|
||||||
$this->_getNamedArgs($controller->params['pass']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$controller->passed_args =& $controller->params['pass'];
|
$controller->passed_args =& $controller->params['pass'];
|
||||||
$controller->passedArgs =& $controller->params['pass'];
|
$controller->passedArgs =& $controller->params['pass'];
|
||||||
|
if (is_array($controller->namedArgs) && in_array($params['action'], array_keys($controller->namedArgs))) {
|
||||||
|
|
||||||
|
$this->passedArgs =& $controller->params['pass'];
|
||||||
|
$this->_getNamedArgs($controller->namedArgs[$params['action']]);
|
||||||
|
|
||||||
|
$controller->passedArgs =& $this->passedArgs;
|
||||||
|
$controller->namedArgs =& $this->namedArgs;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$controller->passed_args = null;
|
$controller->passed_args = null;
|
||||||
$controller->passedArgs = null;
|
$controller->passedArgs = null;
|
||||||
|
@ -378,7 +378,7 @@ class Dispatcher extends Object {
|
||||||
if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) {
|
if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) {
|
||||||
|
|
||||||
if(!empty($r[1])) {
|
if(!empty($r[1])) {
|
||||||
return $base.$r[1];
|
return $base.$r[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -395,11 +395,11 @@ class Dispatcher extends Object {
|
||||||
$appDir = '/'.APP_DIR;
|
$appDir = '/'.APP_DIR;
|
||||||
}
|
}
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[1].$appDir.'/';
|
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[1].$appDir.'/';
|
||||||
return $base.$regs[1].$appDir;
|
return $base.$regs[1].$appDir;
|
||||||
|
|
||||||
} elseif (preg_match('/^(.*)\\/'.WEBROOT_DIR.'([^\/i]*)|index\\\.php$/', $scriptName, $regs)) {
|
} elseif (preg_match('/^(.*)\\/'.WEBROOT_DIR.'([^\/i]*)|index\\\.php$/', $scriptName, $regs)) {
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/';
|
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/';
|
||||||
return $base.$regs[0];
|
return $base.$regs[0];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
|
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
|
||||||
|
@ -431,23 +431,33 @@ class Dispatcher extends Object {
|
||||||
* @param unknown_type $params
|
* @param unknown_type $params
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function _getNamedArgs(&$params, $start = 0) {
|
function _getNamedArgs($args)
|
||||||
if(is_array($params)) {
|
{
|
||||||
$a = array();
|
if(!is_array($args)) {
|
||||||
$args = $params;
|
$args = func_get_args();
|
||||||
$c = count($args);
|
}
|
||||||
|
if(!is_array($args)) {
|
||||||
|
$args = explode(',',$controller->namedArgs[$params['action']]);
|
||||||
|
}
|
||||||
|
|
||||||
for ($l = $start; $l < $c; $l++) {
|
$this->namedArgs = array();
|
||||||
if(isset($args[$l])) {
|
|
||||||
if ($l+1 < count($args)) {
|
if(is_array($this->passedArgs) && is_array($args))
|
||||||
$a[$args[$l]] = $args[$l+1];
|
{
|
||||||
} else {
|
foreach ($args as $arg)
|
||||||
$a[$args[$l]] = null;
|
{
|
||||||
}
|
if(in_array($arg, $this->passedArgs))
|
||||||
|
{
|
||||||
|
$key = array_search($arg,$this->passedArgs);
|
||||||
|
$value = $key + 1;
|
||||||
|
$this->namedArgs[$arg] = $this->passedArgs[$value];
|
||||||
|
|
||||||
|
unset($this->passedArgs[$key]);
|
||||||
|
unset($this->passedArgs[$value]);
|
||||||
}
|
}
|
||||||
$l++;
|
|
||||||
}
|
}
|
||||||
$params = $a;
|
$this->passedArgs = array_values($this->passedArgs);
|
||||||
|
return $this->namedArgs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue