[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/views/handlers/ -> views_handler_sort.inc (source)

   1  <?php
   2  /**
   3   * @defgroup views_sort_handlers Views' sort handlers
   4   * @{
   5   * Handlers to tell Views how to sort queries
   6   */
   7  
   8  /**
   9   * Base sort handler that has no options and performs a simple sort
  10   */
  11  class views_handler_sort extends views_handler {
  12    /**
  13     * Called to add the sort to a query.
  14     */
  15    function query() {
  16      $this->ensure_my_table();
  17      // Add the field.
  18      $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
  19    }
  20  
  21    function option_definition() {
  22      $options = parent::option_definition();
  23  
  24      $options['order'] = array('default' => 'ASC');
  25  
  26      return $options;
  27    }
  28  
  29    /**
  30     * Display whether or not the sort order is ascending or descending
  31     */
  32    function admin_summary() {
  33      switch ($this->options['order']) {
  34        case 'ASC':
  35        case 'asc':
  36        default:
  37          $type = t('asc');
  38          break;
  39        case 'DESC';
  40        case 'desc';
  41          $type = t('desc');
  42          break;
  43      }
  44      return '<span class="views-ascending"><span>' . $type . '</span></span>';
  45    }
  46  
  47    /**
  48     * Basic options for all sort criteria
  49     */
  50    function options_form(&$form, &$form_state) {
  51      $form['order'] = array(
  52        '#type' => 'radios',
  53        '#title' => t('Sort order'),
  54        '#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')),
  55        '#default_value' => $this->options['order'],
  56      );
  57    }
  58  }
  59  
  60  /**
  61   * A special handler to take the place of missing or broken handlers.
  62   */
  63  class views_handler_sort_broken extends views_handler_sort {
  64    function ui_name($short = FALSE) {
  65      return t('Broken/missing handler');
  66    }
  67  
  68    function ensure_my_table() { /* No table to ensure! */ }
  69    function query() { /* No query to run */ }
  70    function options_form(&$form, &$form_state) {
  71      $form['markup'] = array(
  72        '#prefix' => '<div class="form-item description">',
  73        '#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'),
  74      );
  75    }
  76  
  77    /**
  78     * Determine if the handler is considered 'broken'
  79     */
  80    function broken() { return TRUE; }
  81  }
  82  
  83  
  84  /**
  85   * @}
  86   */


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7