tablesort.inc 4.5 KB

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