Index: includes/tablesort.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/tablesort.inc,v retrieving revision 1.30 diff -u -F^f -r1.30 tablesort.inc --- includes/tablesort.inc 21 Nov 2004 08:25:17 -0000 1.30 +++ includes/tablesort.inc 27 Jan 2005 16:56:32 -0000 @@ -1,3 +1,8 @@ +From killesreiter@physik.uni-freiburg.de Thu Jan 27 17:55:38 2005 +Date: Thu, 27 Jan 2005 14:37:12 +0100 +From: killesreiter@physik.uni-freiburg.de +To: gerhard@killesreiter.de + $cell['data'])); if ($cell['data'] == $ts['name']) { $ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc'); $cell['class'] = 'active'; @@ -84,8 +90,8 @@ function tablesort_header($cell, $header else { // If the user clicks a different header, we want to sort ascending initially. $ts['sort'] = 'asc'; + $image = ''; } - $title = t('sort by %s', array('%s' => $cell['data'])); $cell['data'] = l($cell['data'] . $image, $_GET['q'], array('title' => $title), 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']). $ts['query_string']); unset($cell['field'], $cell['sort']); @@ -110,7 +116,7 @@ function tablesort_header($cell, $header * A properly formatted cell, ready for _theme_table_cell(). */ function tablesort_cell($cell, $header, $ts, $i) { - if ($header[$i]['data'] == $ts['name'] && $header[$i]['field']) { + if (isset($header[$i]) && $header[$i]['data'] == $ts['name'] && $header[$i]['field']) { if (is_array($cell)) { if (isset($cell['class'])) { $cell['class'] .= ' active'; @@ -135,6 +141,7 @@ function tablesort_cell($cell, $header, */ 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; @@ -154,18 +161,18 @@ function tablesort_get_querystring() { * - "sql": The name of the database field to sort on. */ function tablesort_get_order($headers) { - $order = $_GET['order']; + $order = isset($_GET['order']) ? $_GET['order'] : ''; foreach ($headers as $header) { - if ($order == $header['data']) { + if (isset($header['data']) && $order == $header['data']) { return array('name' => $header['data'], 'sql' => $header['field']); } - if ($header['sort'] == 'asc' || $header['sort'] == 'desc') { + if (isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) { $default = array('name' => $header['data'], 'sql' => $header['field']); } } - if ($default) { + if (isset($default)) { return $default; } else { @@ -188,7 +195,7 @@ function tablesort_get_order($headers) { * The current sort direction ("asc" or "desc"). */ function tablesort_get_sort($headers) { - if ($_GET['sort']) { + if (isset($_GET['sort'])) { return ($_GET['sort'] == 'desc') ? 'desc' : 'asc'; } // User has not specified a sort. Use default if specified; otherwise use "asc".