tablesort_get_sort

Versions
4.6 – 7
tablesort_get_sort($headers)

Determine the current sort direction.

Parameters

$headers An array of column headers in the format described in theme_table().

Return value

The current sort direction ("asc" or "desc").

Code

includes/tablesort.inc, line 186

<?php
function tablesort_get_sort($headers) {
  if (isset($_GET['sort'])) {
    return ($_GET['sort'] == 'desc') ? 'desc' : 'asc';
  }
  // User has not specified a sort. Use default if specified; otherwise use "asc".
  else {
    foreach ($headers as $header) {
      if (is_array($header) && array_key_exists('sort', $header)) {
        return $header['sort'];
      }
    }
  }
  return 'asc';
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.