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:
gwoo 2006-07-04 21:25:21 +00:00
parent 86fc29facb
commit 03756a8cf2

View file

@ -195,17 +195,17 @@ class Dispatcher extends Object {
}
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->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 {
$controller->passed_args = null;
$controller->passedArgs = null;
@ -378,7 +378,7 @@ class Dispatcher extends Object {
if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) {
if(!empty($r[1])) {
return $base.$r[1];
return $base.$r[1];
}
}
} else {
@ -395,11 +395,11 @@ class Dispatcher extends Object {
$appDir = '/'.APP_DIR;
}
!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)) {
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/';
return $base.$regs[0];
return $base.$regs[0];
} else {
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
@ -431,23 +431,33 @@ class Dispatcher extends Object {
* @param unknown_type $params
* @return unknown
*/
function _getNamedArgs(&$params, $start = 0) {
if(is_array($params)) {
$a = array();
$args = $params;
$c = count($args);
function _getNamedArgs($args)
{
if(!is_array($args)) {
$args = func_get_args();
}
if(!is_array($args)) {
$args = explode(',',$controller->namedArgs[$params['action']]);
}
for ($l = $start; $l < $c; $l++) {
if(isset($args[$l])) {
if ($l+1 < count($args)) {
$a[$args[$l]] = $args[$l+1];
} else {
$a[$args[$l]] = null;
}
$this->namedArgs = array();
if(is_array($this->passedArgs) && is_array($args))
{
foreach ($args as $arg)
{
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;
}
}
}