annotate core/includes/tablesort.inc @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /**
Chris@0 4 * @file
Chris@0 5 * Functions to aid in the creation of sortable tables.
Chris@0 6 *
Chris@0 7 * All tables created when rendering a '#type' => 'table' have the option of
Chris@0 8 * having column headers that the user can click on to sort the table by that
Chris@0 9 * column.
Chris@0 10 */
Chris@0 11
Chris@18 12 use Drupal\Core\Utility\TableSort;
Chris@0 13
Chris@0 14 /**
Chris@0 15 * Initializes the table sort context.
Chris@18 16 *
Chris@18 17 * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use
Chris@18 18 * \Drupal\Core\Utility\TableSort::getContextFromRequest() instead.
Chris@18 19 *
Chris@18 20 * @see \Drupal\Core\Utility\TableSortInterface::getContextFromRequest()
Chris@18 21 * @see https://www.drupal.org/node/3009182
Chris@0 22 */
Chris@0 23 function tablesort_init($header) {
Chris@18 24 @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 25 return TableSort::getContextFromRequest($header, \Drupal::request());
Chris@0 26 }
Chris@0 27
Chris@0 28 /**
Chris@0 29 * Formats a column header.
Chris@0 30 *
Chris@0 31 * If the cell in question is the column header for the current sort criterion,
Chris@0 32 * it gets special formatting. All possible sort criteria become links.
Chris@0 33 *
Chris@0 34 * @param string $cell_content
Chris@0 35 * The cell content to format. Passed by reference.
Chris@0 36 * @param array $cell_attributes
Chris@0 37 * The cell attributes. Passed by reference.
Chris@0 38 * @param array $header
Chris@0 39 * An array of column headers in the format described in '#type' => 'table'.
Chris@0 40 * @param array $ts
Chris@0 41 * The current table sort context as returned from tablesort_init().
Chris@18 42 *
Chris@18 43 * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use
Chris@18 44 * \Drupal\Core\Utility\TableSort::header() instead.
Chris@18 45 *
Chris@18 46 * @see \Drupal\Core\Utility\TableSortInterface::header()
Chris@18 47 * @see https://www.drupal.org/node/3009182
Chris@0 48 */
Chris@0 49 function tablesort_header(&$cell_content, array &$cell_attributes, array $header, array $ts) {
Chris@18 50 @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 51 TableSort::header($cell_content, $cell_attributes, $header, $ts);
Chris@0 52 }
Chris@0 53
Chris@0 54 /**
Chris@0 55 * Composes a URL query parameter array for table sorting links.
Chris@0 56 *
Chris@0 57 * @return
Chris@0 58 * A URL query parameter array that consists of all components of the current
Chris@0 59 * page request except for those pertaining to table sorting.
Chris@18 60 *
Chris@18 61 * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use
Chris@18 62 * \Drupal\Core\Utility\TableSort::getQueryParameters() instead.
Chris@18 63 *
Chris@18 64 * @see \Drupal\Core\Utility\TableSort::getQueryParameters()
Chris@18 65 * @see https://www.drupal.org/node/3009182
Chris@0 66 */
Chris@0 67 function tablesort_get_query_parameters() {
Chris@18 68 @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 69 return TableSort::getQueryParameters(\Drupal::request());
Chris@0 70 }
Chris@0 71
Chris@0 72 /**
Chris@0 73 * Determines the current sort criterion.
Chris@0 74 *
Chris@0 75 * @param $headers
Chris@0 76 * An array of column headers in the format described in '#type' => 'table'.
Chris@0 77 *
Chris@0 78 * @return
Chris@0 79 * An associative array describing the criterion, containing the keys:
Chris@0 80 * - "name": The localized title of the table column.
Chris@0 81 * - "sql": The name of the database field to sort on.
Chris@18 82 *
Chris@18 83 * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use
Chris@18 84 * \Drupal\Core\Utility\TableSort::getOrder() instead.
Chris@18 85 *
Chris@18 86 * @see \Drupal\Core\Utility\TableSortInterface::getOrder()
Chris@18 87 * @see https://www.drupal.org/node/3009182
Chris@0 88 */
Chris@0 89 function tablesort_get_order($headers) {
Chris@18 90 @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 91 return TableSort::getOrder($headers, \Drupal::request());
Chris@0 92 }
Chris@0 93
Chris@0 94 /**
Chris@0 95 * Determines the current sort direction.
Chris@0 96 *
Chris@0 97 * @param $headers
Chris@0 98 * An array of column headers in the format described in '#type' => 'table'.
Chris@0 99 *
Chris@0 100 * @return
Chris@0 101 * The current sort direction ("asc" or "desc").
Chris@18 102 *
Chris@18 103 * @deprecated as of Drupal 8.7.x and will be removed before Drupal 9.0.0. Use
Chris@18 104 * \Drupal\Core\Utility\TableSort::getSort() instead.
Chris@18 105 *
Chris@18 106 * @see \Drupal\Core\Utility\TableSortInterface::getSort()
Chris@18 107 * @see https://www.drupal.org/node/3009182
Chris@0 108 */
Chris@0 109 function tablesort_get_sort($headers) {
Chris@18 110 @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 111 return TableSort::getSort($headers, \Drupal::request());
Chris@0 112 }