2003-08-21 15:47:50 +00:00
< ? php
2004-07-22 16:06:54 +00:00
/**
* @ file
* Functions to aid in the creation of sortable tables .
*
2014-03-12 15:46:33 +00:00
* All tables created when rendering a '#type' => 'table' have the option of
2014-02-06 10:35:47 +00:00
* having column headers that the user can click on to sort the table by that
* column .
2004-07-22 16:06:54 +00:00
*/
2018-11-22 08:40:04 +00:00
use Drupal\Core\Utility\TableSort ;
2016-02-11 20:54:33 +00:00
2004-07-22 16:06:54 +00:00
/**
2013-01-10 23:50:55 +00:00
* Initializes the table sort context .
2018-11-22 08:40:04 +00:00
*
* @ deprecated as of Drupal 8.7 . x and will be removed before Drupal 9.0 . 0. Use
* \Drupal\Core\Utility\TableSort :: getContextFromRequest () instead .
*
* @ see \Drupal\Core\Utility\TableSortInterface :: getContextFromRequest ()
* @ see https :// www . drupal . org / node / 3009182
2004-07-22 16:06:54 +00:00
*/
2006-11-17 06:53:31 +00:00
function tablesort_init ( $header ) {
2018-11-22 08:40:04 +00:00
@ trigger_error ( __FUNCTION__ . '() is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Utility\TableSort::getContextFromRequest() instead. See https://www.drupal.org/node/3009182' , E_USER_DEPRECATED );
return TableSort :: getContextFromRequest ( $header , \Drupal :: request ());
2003-08-21 15:47:50 +00:00
}
2004-07-22 16:06:54 +00:00
/**
2013-01-10 23:50:55 +00:00
* Formats a column header .
2004-07-22 16:06:54 +00:00
*
* If the cell in question is the column header for the current sort criterion ,
* it gets special formatting . All possible sort criteria become links .
*
2014-04-23 10:53:03 +00:00
* @ param string $cell_content
* The cell content to format . Passed by reference .
* @ param array $cell_attributes
* The cell attributes . Passed by reference .
* @ param array $header
2014-03-12 15:46:33 +00:00
* An array of column headers in the format described in '#type' => 'table' .
2014-04-23 10:53:03 +00:00
* @ param array $ts
2004-07-22 16:06:54 +00:00
* The current table sort context as returned from tablesort_init () .
2018-11-22 08:40:04 +00:00
*
* @ deprecated as of Drupal 8.7 . x and will be removed before Drupal 9.0 . 0. Use
* \Drupal\Core\Utility\TableSort :: header () instead .
*
* @ see \Drupal\Core\Utility\TableSortInterface :: header ()
* @ see https :// www . drupal . org / node / 3009182
2004-07-22 16:06:54 +00:00
*/
2014-04-23 10:53:03 +00:00
function tablesort_header ( & $cell_content , array & $cell_attributes , array $header , array $ts ) {
2018-11-22 08:40:04 +00:00
@ trigger_error ( __FUNCTION__ . '() is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Utility\TableSort::header() instead. See https://www.drupal.org/node/3009182' , E_USER_DEPRECATED );
TableSort :: header ( $cell_content , $cell_attributes , $header , $ts );
2003-08-21 15:47:50 +00:00
}
2004-07-22 16:06:54 +00:00
/**
2013-01-10 23:50:55 +00:00
* Composes a URL query parameter array for table sorting links .
2004-07-22 16:06:54 +00:00
*
* @ return
2009-09-29 15:31:17 +00:00
* A URL query parameter array that consists of all components of the current
* page request except for those pertaining to table sorting .
2018-11-22 08:40:04 +00:00
*
* @ deprecated as of Drupal 8.7 . x and will be removed before Drupal 9.0 . 0. Use
* \Drupal\Core\Utility\TableSort :: getQueryParameters () instead .
*
* @ see \Drupal\Core\Utility\TableSort :: getQueryParameters ()
* @ see https :// www . drupal . org / node / 3009182
2004-07-22 16:06:54 +00:00
*/
2009-09-29 15:31:17 +00:00
function tablesort_get_query_parameters () {
2018-11-22 08:40:04 +00:00
@ trigger_error ( __FUNCTION__ . '() is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Utility\TableSort::getQueryParameters() instead. See https://www.drupal.org/node/3009182' , E_USER_DEPRECATED );
return TableSort :: getQueryParameters ( \Drupal :: request ());
2003-08-21 15:47:50 +00:00
}
2004-07-22 16:06:54 +00:00
/**
2013-01-10 23:50:55 +00:00
* Determines the current sort criterion .
2004-07-22 16:06:54 +00:00
*
* @ param $headers
2014-03-12 15:46:33 +00:00
* An array of column headers in the format described in '#type' => 'table' .
2013-01-10 23:50:55 +00:00
*
2004-07-22 16:06:54 +00:00
* @ return
* An associative array describing the criterion , containing the keys :
* - " name " : The localized title of the table column .
* - " sql " : The name of the database field to sort on .
2018-11-22 08:40:04 +00:00
*
* @ deprecated as of Drupal 8.7 . x and will be removed before Drupal 9.0 . 0. Use
* \Drupal\Core\Utility\TableSort :: getOrder () instead .
*
* @ see \Drupal\Core\Utility\TableSortInterface :: getOrder ()
* @ see https :// www . drupal . org / node / 3009182
2004-07-22 16:06:54 +00:00
*/
2006-11-17 06:53:31 +00:00
function tablesort_get_order ( $headers ) {
2018-11-22 08:40:04 +00:00
@ trigger_error ( __FUNCTION__ . '() is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Utility\TableSort::getOrder() instead. See https://www.drupal.org/node/3009182' , E_USER_DEPRECATED );
return TableSort :: getOrder ( $headers , \Drupal :: request ());
2003-08-21 15:47:50 +00:00
}
2004-07-22 16:06:54 +00:00
/**
2013-01-10 23:50:55 +00:00
* Determines the current sort direction .
2004-07-22 16:06:54 +00:00
*
* @ param $headers
2014-03-12 15:46:33 +00:00
* An array of column headers in the format described in '#type' => 'table' .
2013-01-10 23:50:55 +00:00
*
2004-07-22 16:06:54 +00:00
* @ return
* The current sort direction ( " asc " or " desc " ) .
2018-11-22 08:40:04 +00:00
*
* @ deprecated as of Drupal 8.7 . x and will be removed before Drupal 9.0 . 0. Use
* \Drupal\Core\Utility\TableSort :: getSort () instead .
*
* @ see \Drupal\Core\Utility\TableSortInterface :: getSort ()
* @ see https :// www . drupal . org / node / 3009182
2004-07-22 16:06:54 +00:00
*/
2006-11-17 06:53:31 +00:00
function tablesort_get_sort ( $headers ) {
2018-11-22 08:40:04 +00:00
@ trigger_error ( __FUNCTION__ . '() is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Utility\TableSort::getSort() instead. See https://www.drupal.org/node/3009182' , E_USER_DEPRECATED );
return TableSort :: getSort ( $headers , \Drupal :: request ());
2003-08-21 15:47:50 +00:00
}