Commit 171de5d4 authored by Dries's avatar Dries

- Patch #16303 by Gerhard: fixed PHP notices.

parent 96c03968
......@@ -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".
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment