Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.528 diff -u -r1.528 common.inc --- includes/common.inc 17 Mar 2006 18:56:25 -0000 1.528 +++ includes/common.inc 27 Mar 2006 00:36:25 -0000 @@ -156,6 +156,41 @@ */ /** + * Parse an array into a valid urlencoded query string. + * + * @param $query + * The array to be processed e.g. $_GET + * @param $exclude + * The array filled with keys to be excluded + * @param $parent + * Should not be passed, only used in recursive calls + * @return + * urlencoded string which can be appended to/as the URL query string + */ +function drupal_query_string_encode($query, $exclude = array(), $parent = '') { + $params = array(); + + foreach ( $query as $key => $value ) { + if (in_array($key, $exclude)) { + continue; + } + + if ($parent) { + $key = $parent .'['. $key .']'; + } + + if (is_array($value)) { + $params[] = drupal_query_string_encode($value, array(), $key); + } + else { + $params[] = urlencode($key) .'='. urlencode($value); + } + } + + return implode('&', $params); +} + +/** * Prepare a destination query string for use in combination with * drupal_goto(). Used to direct the user back to the referring page * after completing a form. By default the current URL is returned. @@ -171,16 +206,12 @@ } else { $path = $_GET['q']; - $params = array(); - foreach ($_GET as $key => $value) { - if ($key == 'q') { - continue; - } - $params[] = urlencode($key) .'='. urlencode($value); - } - if (count($params)) { + $query = drupal_query_string_encode($_GET, array('q')); + + if ($query != '') { $path .= '?'; } + return 'destination='. urlencode($path . implode('&', $params)); } } Index: includes/pager.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/pager.inc,v retrieving revision 1.53 diff -u -r1.53 pager.inc --- includes/pager.inc 15 Jan 2006 16:55:35 -0000 1.53 +++ includes/pager.inc 27 Mar 2006 00:38:54 -0000 @@ -49,7 +49,7 @@ * @ingroup database */ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { - global $pager_page_array, $pager_total, $pager_total_items; + global $pager_page_array, $pager_total, $pager_total_items, $pager_url_query; $page = isset($_GET['page']) ? $_GET['page'] : ''; // Substitute in query arguments. @@ -68,6 +68,9 @@ // Convert comma-separated $page to an array, used by other functions. $pager_page_array = explode(',', $page); + // Generate the query to be appended to l() + $pager_url_query[$element] = drupal_query_string_encode($_GET, array('q', 'page')); + // We calculate the total of pages as ceil(items / limit). if (count($args)) { $pager_total_items[$element] = db_result(db_query($count_query, $args)); @@ -351,6 +354,8 @@ * An HTML string that generates the link. */ function theme_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) { + global $pager_url_query; + $page = isset($_GET['page']) ? $_GET['page'] : ''; if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) { $parameters['page'] = $new_page; @@ -361,6 +366,10 @@ $query[] = $key .'='. $value; } + if ($pager_url_query[$element] != '') { + $query[] = $pager_url_query[$element]; + } + // Set each pager link title if (!isset($attributes['title'])) { static $titles = null; Index: includes/tablesort.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/tablesort.inc,v retrieving revision 1.37 diff -u -r1.37 tablesort.inc --- includes/tablesort.inc 10 Dec 2005 19:26:47 -0000 1.37 +++ includes/tablesort.inc 27 Mar 2006 00:40:30 -0000 @@ -135,13 +135,13 @@ */ function tablesort_get_querystring() { $cgi = $_SERVER['REQUEST_METHOD'] == 'GET' ? $_GET : $_POST; - $query_string = ''; - foreach ($cgi as $key => $val) { - if ($key != 'order' && $key != 'sort' && $key != 'q') { - $query_string .= '&'. $key .'='. $val; - } + $query_string = drupal_query_string_encode($cgi, array('q', 'order', 'sort')); + + if ($query_string != '') { + return '&'. $query_string; } - return $query_string; + + return ''; } /**