The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit 76cb0c5a authored by Demian Katz's avatar Demian Katz
Browse files

Resolving VUFIND-849 (Clear page number when changing sort/limit).

parent 47df08a7
No related merge requests found
......@@ -334,7 +334,7 @@ class UrlQueryHelper
public function setSort($s, $escape = true)
{
return $this->updateQueryString(
'sort', $s, $this->params->getDefaultSort(), $escape
'sort', $s, $this->params->getDefaultSort(), $escape, true
);
}
......@@ -387,7 +387,7 @@ class UrlQueryHelper
public function setLimit($l, $escape = true)
{
return $this->updateQueryString(
'limit', $l, $this->options->getDefaultLimit(), $escape
'limit', $l, $this->options->getDefaultLimit(), $escape, true
);
}
......@@ -440,16 +440,17 @@ class UrlQueryHelper
/**
* Generic case of parameter rebuilding.
*
* @param string $field Field to update
* @param string $value Value to use (null to skip field entirely)
* @param string $default Default value (skip field if $value matches; null
* for no default).
* @param bool $escape Should we escape the string for use in the view?
* @param string $field Field to update
* @param string $value Value to use (null to skip field entirely)
* @param string $default Default value (skip field if $value matches; null
* for no default).
* @param bool $escape Should we escape the string for use in the view?
* @param bool $clearPage Should we clear the page number, if any?
*
* @return string
*/
protected function updateQueryString($field, $value, $default = null,
$escape = true
$escape = true, $clearPage = false
) {
$params = $this->getParamArray();
if (is_null($value) || $value == $default) {
......@@ -457,6 +458,9 @@ class UrlQueryHelper
} else {
$params[$field] = $value;
}
if ($clearPage && isset($params['page'])) {
unset($params['page']);
}
return '?' . $this->buildQueryString($params, $escape);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment