Re: [fw-general] Wildcards routes and reset parameter

2007-03-22 Thread Martel Valgoerad

Olivier Sirven wrote:

(...)

I have tried to add the "reset" parameter to true but then I don't have any 
parameter at all, just "/":

echo $this->url(array('key1' => 'newvalue'), 'root', true);

Is it a bug or a feature? 


It's more a bug than a feature. Fixed with commit 4715. Good catch, thanks :)

If this is a feature, is there a way to assemble a wildcard route without 
taking into account the current parameters?


There is another way to reset parameters. You can leave $reset as false but 
pass 'var' => null to assemble if you wish to reset specific url variables only.


--
Martel Valgoerad aka Michal Minicki | [EMAIL PROTECTED] | 
http://aie.pl/martel.asc
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Idleness is not doing nothing. Idleness is being free to do anything." --
Floyd Dell


Re: [fw-general] Wildcards routes and reset parameter

2007-03-21 Thread Olivier Sirven
Hi,

I did the same...but I have to say it sounds strange to me to have to write 
another assemble method to manage something supposed to work out of the 
box...maybe there is a good reason for this behaviour but I really don't get 
it ;)

Olivier

Le mercredi 21 mars 2007, Jens Wabnitz a écrit :
> Hi Olivier,
>
> i stumbled across the same issue.
> My workarond was to build my own route class which modifies the assemble
> method.
> Now if reset is true assemble takes account of my given parameters but
> resets the request parameters..


Re: [fw-general] Wildcards routes and reset parameter

2007-03-21 Thread Jens Wabnitz
Hi Olivier,

i stumbled across the same issue.
My workarond was to build my own route class which modifies the assemble
method.
Now if reset is true assemble takes account of my given parameters but
resets the request parameters..

Hope that helps

Bye
Jens


Olivier Sirven schrieb:
> Hi,
>
> I have created a route this way:
> $router = new Zend_Controller_Router_Rewrite();
> $route = new Zend_Controller_Router_Route('/*',
>   array('controller' => 'index',
> 'action' => 'index'));
> $router->addRoute('root', $route);
> And the current request uri is something like this:
> /key1/value1/key2/value2
>
> Within a view I use the Url helper like this:
> echo $this->url(array('key1' => 'newvalue'), 'root');
>
> I thought it should returns something like "/key1/newvalue" but it returns 
> something like "/key1/newvalue/key2/value2".
> I have tried to add the "reset" parameter to true but then I don't have any 
> parameter at all, just "/":
> echo $this->url(array('key1' => 'newvalue'), 'root', true);
>
> Is it a bug or a feature? 
> If this is a feature, is there a way to assemble a wildcard route without 
> taking into account the current parameters?
>
>   

/**
 * Assembles user submitted parameters forming a URL path defined by this 
route
 *
 * @param array An array of variable and value pairs used as parameters
 * @return string Route path with user submitted parameters
 */
public function assemble($data = array(), $reset = false)
{

$url = array();
foreach ($this->_parts as $key => $part) {
$resetPart = false;
if (isset($part['name']) && array_key_exists($part['name'], $data) 
&& $data[$part['name']] === null) {
$resetPart = true;
}


if (isset($part['name'])) {

if (isset($data[$part['name']]) && !$resetPart) {
$url[$key] = $data[$part['name']];
unset($data[$part['name']]);
} elseif (!$reset && !$resetPart && 
isset($this->_values[$part['name']])) {
$url[$key] = $this->_values[$part['name']];
} elseif (!$reset && !$resetPart && 
isset($this->_params[$part['name']])) {
$url[$key] = $this->_params[$part['name']];
} elseif (isset($this->_defaults[$part['name']])) {
$url[$key] = $this->_defaults[$part['name']];
} else
throw new Zend_Controller_Router_Exception($part['name'] . 
' is not specified');

} else {
if ($part['regex'] != '\*') {
$url[$key] = $part['regex'];
} else {
if (!$reset) {
$wildcards = $data + $this->_params;
} else {
$wildcards = $data;
}
foreach ($wildcards as $var => $value) {
  if ($value !== null) {
$url[$var] = $var . self::URI_DELIMITER . 
$value;
  }
}
}
}

}
return implode(self::URI_DELIMITER, $url);
}

[fw-general] Wildcards routes and reset parameter

2007-03-21 Thread Olivier Sirven
Hi,

I have created a route this way:
$router = new Zend_Controller_Router_Rewrite();
$route = new Zend_Controller_Router_Route('/*',
  array('controller' => 'index',
'action' => 'index'));
$router->addRoute('root', $route);
And the current request uri is something like this:
/key1/value1/key2/value2

Within a view I use the Url helper like this:
echo $this->url(array('key1' => 'newvalue'), 'root');

I thought it should returns something like "/key1/newvalue" but it returns 
something like "/key1/newvalue/key2/value2".
I have tried to add the "reset" parameter to true but then I don't have any 
parameter at all, just "/":
echo $this->url(array('key1' => 'newvalue'), 'root', true);

Is it a bug or a feature? 
If this is a feature, is there a way to assemble a wildcard route without 
taking into account the current parameters?

-- 
Olivier