Chris@0: 'table' have the option of Chris@0: * having column headers that the user can click on to sort the table by that Chris@0: * column. Chris@0: */ Chris@0: Chris@18: use Drupal\Core\Utility\TableSort; Chris@0: Chris@0: /** Chris@0: * Initializes the table sort context. Chris@18: * Chris@18: * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use Chris@18: * \Drupal\Core\Utility\TableSort::getContextFromRequest() instead. Chris@18: * Chris@18: * @see \Drupal\Core\Utility\TableSortInterface::getContextFromRequest() Chris@18: * @see https://www.drupal.org/node/3009182 Chris@0: */ Chris@0: function tablesort_init($header) { Chris@18: @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); Chris@18: return TableSort::getContextFromRequest($header, \Drupal::request()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Formats a column header. Chris@0: * Chris@0: * If the cell in question is the column header for the current sort criterion, Chris@0: * it gets special formatting. All possible sort criteria become links. Chris@0: * Chris@0: * @param string $cell_content Chris@0: * The cell content to format. Passed by reference. Chris@0: * @param array $cell_attributes Chris@0: * The cell attributes. Passed by reference. Chris@0: * @param array $header Chris@0: * An array of column headers in the format described in '#type' => 'table'. Chris@0: * @param array $ts Chris@0: * The current table sort context as returned from tablesort_init(). Chris@18: * Chris@18: * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use Chris@18: * \Drupal\Core\Utility\TableSort::header() instead. Chris@18: * Chris@18: * @see \Drupal\Core\Utility\TableSortInterface::header() Chris@18: * @see https://www.drupal.org/node/3009182 Chris@0: */ Chris@0: function tablesort_header(&$cell_content, array &$cell_attributes, array $header, array $ts) { Chris@18: @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); Chris@18: TableSort::header($cell_content, $cell_attributes, $header, $ts); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Composes a URL query parameter array for table sorting links. Chris@0: * Chris@0: * @return Chris@0: * A URL query parameter array that consists of all components of the current Chris@0: * page request except for those pertaining to table sorting. Chris@18: * Chris@18: * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use Chris@18: * \Drupal\Core\Utility\TableSort::getQueryParameters() instead. Chris@18: * Chris@18: * @see \Drupal\Core\Utility\TableSort::getQueryParameters() Chris@18: * @see https://www.drupal.org/node/3009182 Chris@0: */ Chris@0: function tablesort_get_query_parameters() { Chris@18: @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); Chris@18: return TableSort::getQueryParameters(\Drupal::request()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Determines the current sort criterion. Chris@0: * Chris@0: * @param $headers Chris@0: * An array of column headers in the format described in '#type' => 'table'. Chris@0: * Chris@0: * @return Chris@0: * An associative array describing the criterion, containing the keys: Chris@0: * - "name": The localized title of the table column. Chris@0: * - "sql": The name of the database field to sort on. Chris@18: * Chris@18: * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use Chris@18: * \Drupal\Core\Utility\TableSort::getOrder() instead. Chris@18: * Chris@18: * @see \Drupal\Core\Utility\TableSortInterface::getOrder() Chris@18: * @see https://www.drupal.org/node/3009182 Chris@0: */ Chris@0: function tablesort_get_order($headers) { Chris@18: @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); Chris@18: return TableSort::getOrder($headers, \Drupal::request()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Determines the current sort direction. Chris@0: * Chris@0: * @param $headers Chris@0: * An array of column headers in the format described in '#type' => 'table'. Chris@0: * Chris@0: * @return Chris@0: * The current sort direction ("asc" or "desc"). Chris@18: * Chris@18: * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use Chris@18: * \Drupal\Core\Utility\TableSort::getSort() instead. Chris@18: * Chris@18: * @see \Drupal\Core\Utility\TableSortInterface::getSort() Chris@18: * @see https://www.drupal.org/node/3009182 Chris@0: */ Chris@0: function tablesort_get_sort($headers) { Chris@18: @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); Chris@18: return TableSort::getSort($headers, \Drupal::request()); Chris@0: }