[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

   1  <?php
   2  // $Id: views_handler_sort_formula.inc,v 1.1 2008/09/03 19:21:28 merlinofchaos Exp $
   3  /**
   4   * Base sort handler that has no options and performs a simple sort
   5   *
   6   * Definition items:
   7   * - formula: The formula to use to sort on, such as with a random sort.
   8   *            The formula should be an array, with keys for database
   9   *            types, and 'default' for non-specified. 'default' is
  10   *            required, all others ('mysql', 'mysqli' and 'pgsql' are
  11   *            optional). It is recommended you use 'default' for mysql
  12   *            and create specific overrides for pgsql when the formulae
  13   *            differ.
  14   *
  15   * @ingroup views_sort_handlers
  16   */
  17  class views_handler_sort_formula extends views_handler_sort {
  18    /**
  19     * Constructor to take the formula this sorts on.
  20     */
  21    function construct() {
  22      $this->formula = $this->definition['formula'];
  23      if (is_array($this->formula) && !isset($this->formula['default'])) {
  24        $this->error = t('views_handler_sort_formula missing default: @formula', array('@formula' => var_export($this->formula, TRUE)));
  25      }
  26      parent::construct();
  27    }
  28    /**
  29     * Called to add the sort to a query.
  30     */
  31    function query() {
  32      if (is_array($this->formula)) {
  33        global $db_type;
  34        if (isset($this->formula[$db_type])) {
  35          $formula = $this->formula[$db_type];
  36        }
  37        else {
  38          $formula = $this->formula['default'];
  39        }
  40      }
  41      else {
  42        $formula = $this->formula;
  43      }
  44      $this->ensure_my_table();
  45      // Add the field.
  46      $this->query->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field);
  47    }
  48  }


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