[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

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


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7