diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-01-31 21:36:37 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-01-31 21:36:37 +0000 |
commit | 171de5d46db2523bfd581a726979209efb608998 (patch) | |
tree | 3ed90a14890e4868412b6a5a6e98664105cd8c4d | |
parent | 96c039680a0215df683f089abdf6cbb4448e1b2e (diff) | |
download | brdo-171de5d46db2523bfd581a726979209efb608998.tar.gz brdo-171de5d46db2523bfd581a726979209efb608998.tar.bz2 |
- Patch #16303 by Gerhard: fixed PHP notices.
-rw-r--r-- | includes/tablesort.inc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/includes/tablesort.inc b/includes/tablesort.inc index 6be5a5540..ad0268352 100644 --- a/includes/tablesort.inc +++ b/includes/tablesort.inc @@ -74,7 +74,8 @@ function tablesort_sql($header, $before = '') { */ function tablesort_header($cell, $header, $ts) { // Special formatting for the currently sorted column header. - if (is_array($cell) && $cell['field']) { + if (is_array($cell) && isset($cell['field'])) { + $title = t('sort by %s', array('%s' => $cell['data'])); if ($cell['data'] == $ts['name']) { $ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc'); $cell['class'] = 'active'; @@ -84,8 +85,8 @@ function tablesort_header($cell, $header, $ts) { 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 +111,7 @@ function tablesort_header($cell, $header, $ts) { * 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 +136,7 @@ function tablesort_cell($cell, $header, $ts, $i) { */ 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 +156,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 +190,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". |