parent
50ca1aec1a
commit
5c3eb1d796
|
@ -39,8 +39,6 @@ class Zend_View_Helper_QUrl extends Zend_View_Helper_Abstract
|
|||
$params = array();
|
||||
}
|
||||
return Url::fromPath($url, $params);
|
||||
$params = array_map('rawurlencode', $params);
|
||||
return $this->view->baseUrl(vsprintf($url, $params));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
|||
continue;
|
||||
}
|
||||
if ($key === 'target') {
|
||||
$attibutes[] = 'target="'.$val.'"';
|
||||
$attributes[] = 'target="'.$val.'"';
|
||||
}
|
||||
if ($key === 'style' && is_array($val)) {
|
||||
if (empty($val)) {
|
||||
|
|
|
@ -94,6 +94,7 @@ class Url
|
|||
$urlObject->setPath($urlParts["path"]);
|
||||
}
|
||||
if (isset($urlParts["query"])) {
|
||||
$urlParams = array();
|
||||
parse_str($urlParts["query"], $urlParams);
|
||||
$params = array_merge($urlParams, $params);
|
||||
}
|
||||
|
@ -149,9 +150,10 @@ class Url
|
|||
*/
|
||||
public function getRelativeUrl()
|
||||
{
|
||||
if (empty($this->params))
|
||||
return ltrim($this->path,'/');
|
||||
return ltrim($this->path,'/').'?'.http_build_query($this->params);
|
||||
if (empty($this->params)) {
|
||||
return ltrim($this->path, '/');
|
||||
}
|
||||
return ltrim($this->path, '/').'?'.http_build_query($this->params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,7 +169,7 @@ class Url
|
|||
}
|
||||
|
||||
/**
|
||||
* Add a set of parameters to the query part
|
||||
* Add a set of parameters to the query part if the keys don't exist yet
|
||||
*
|
||||
* @param array $params The parameters to add
|
||||
* @return $this
|
||||
|
|
|
@ -352,6 +352,25 @@ class UrlTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
function testAddParamAfterCreation()
|
||||
{
|
||||
$url = Url::fromPath('/my/test/url.html?param=val¶m2=val2¶m3=val3', array(), new RequestMock());
|
||||
$url->addParams(array(
|
||||
"param4" => "val4",
|
||||
"param3" => "newval3"
|
||||
));
|
||||
$this->assertEquals(
|
||||
"val4",
|
||||
$url->getParam("param4", "wrongval"),
|
||||
"Asserting that a parameter can be added with addParam"
|
||||
);
|
||||
$this->assertEquals(
|
||||
"val3",
|
||||
$url->getParam("param3", "wrongval"),
|
||||
"Asserting that addParam doesn't overwrite existing parameters"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether toString is the same as getAbsoluteUrl
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue