"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.9/core/includes/tablesort.inc" (18 Nov 2020, 4628 Bytes) of package /linux/www/drupal-8.9.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) fasm source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "tablesort.inc" see the Fossies "Dox" file reference documentation.

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