diff --git a/core/HTTP.php b/core/HTTP.php index 1c4a6b6c7..0ce1a49b9 100644 --- a/core/HTTP.php +++ b/core/HTTP.php @@ -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'] : ''; diff --git a/forms/TableListField.php b/forms/TableListField.php index cb9fbd936..d8802ccef 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -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 {