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