mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: added optional separator for http_build_query in HTTP:setGetVar(). this fixes sorting columns in ModelAdmin (ticket #5325).
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@103012 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0b44d49167
commit
7037afc879
@ -89,9 +89,10 @@ class HTTP {
|
||||
* @param String $varname
|
||||
* @param String $varvalue
|
||||
* @param String $currentURL Relative or absolute URL (Optional).
|
||||
* @param String $separator Separator for http_build_query(). (Optional).
|
||||
* @return String Absolute URL
|
||||
*/
|
||||
public static function setGetVar($varname, $varvalue, $currentURL = null) {
|
||||
public static function setGetVar($varname, $varvalue, $currentURL = null, $separator = '&') {
|
||||
$uri = $currentURL ? $currentURL : Director::makeRelative($_SERVER['REQUEST_URI']);
|
||||
|
||||
$isRelative = false;
|
||||
@ -111,7 +112,7 @@ class HTTP {
|
||||
$params = array();
|
||||
if(isset($parts['query'])) parse_str($parts['query'], $params);
|
||||
$params[$varname] = $varvalue;
|
||||
|
||||
|
||||
// Generate URI segments and formatting
|
||||
$scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
|
||||
$user = (isset($parts['user']) && $parts['user'] != '') ? $parts['user'] : '';
|
||||
@ -126,7 +127,7 @@ class HTTP {
|
||||
$path = (isset($parts['path']) && $parts['path'] != '') ? $parts['path'] : '';
|
||||
|
||||
// handle URL params which are existing / new
|
||||
$params = ($params) ? '?' . http_build_query($params, null, '&') : '';
|
||||
$params = ($params) ? '?' . http_build_query($params, null, $separator) : '';
|
||||
|
||||
// keep fragments (anchors) intact.
|
||||
$fragment = (isset($parts['fragment']) && $parts['fragment'] != '') ? '#'.$parts['fragment'] : '';
|
||||
|
@ -323,20 +323,20 @@ JS
|
||||
// sorting links (only if we have a form to refresh with)
|
||||
if($this->form) {
|
||||
$sortLink = $this->Link();
|
||||
$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][sort]", $fieldName, $sortLink);
|
||||
$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][sort]", $fieldName, $sortLink,'&');
|
||||
|
||||
// Apply sort direction to the current sort field
|
||||
if(!empty($_REQUEST['ctf'][$this->Name()]['sort']) && ($_REQUEST['ctf'][$this->Name()]['sort'] == $fieldName)) {
|
||||
$dir = isset($_REQUEST['ctf'][$this->Name()]['dir']) ? $_REQUEST['ctf'][$this->Name()]['dir'] : null;
|
||||
$dir = trim(strtolower($dir));
|
||||
$newDir = ($dir == 'desc') ? null : 'desc';
|
||||
$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][dir]", Convert::raw2xml($newDir), $sortLink);
|
||||
$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][dir]", Convert::raw2xml($newDir), $sortLink,'&');
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['ctf'][$this->Name()]['search']) && is_array($_REQUEST['ctf'][$this->Name()]['search'])) {
|
||||
foreach($_REQUEST['ctf'][$this->Name()]['search'] as $parameter => $value) {
|
||||
$XML_search = Convert::raw2xml($value);
|
||||
$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][search][$parameter]", $XML_search, $sortLink);
|
||||
$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][search][$parameter]", $XML_search, $sortLink,'&');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user