tablesort_get_order($headers)
Determines the current sort criterion.
$headers: An array of column headers in the format described in '#type' => 'table'.
An associative array describing the criterion, containing the keys:
function tablesort_get_order($headers) { $order = \Drupal::request()->query->get('order', ''); foreach ($headers as $header) { if (is_array($header)) { if (isset($header['data']) && $order == $header['data']) { $default = $header; break; } if (empty($default) && isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) { $default = $header; } } } if (!isset($default)) { $default = reset($headers); if (!is_array($default)) { $default = array('data' => $default); } } $default += array('data' => NULL, 'field' => NULL); return array('name' => $default['data'], 'sql' => $default['field']); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!tablesort.inc/function/tablesort_get_order/8.1.x