source: sipes/modules_contrib/views/handlers/views_handler_argument_formula.inc @ 65dadeb

stableversion-3.0
Last change on this file since 65dadeb was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100644
File size: 1.3 KB
Línea 
1<?php
2/**
3 * Abstract argument handler for simple formulae.
4 *
5 * Child classes of this object should implement summary_argument, at least.
6 *
7 * Definition terms:
8 * - formula: The formula to use for this handler.
9 *
10 * @ingroup views_argument_handlers
11 */
12class views_handler_argument_formula extends views_handler_argument {
13  var $formula = NULL;
14  /**
15   * Constructor
16   */
17  function construct() {
18    parent::construct();
19
20    if (!empty($this->definition['formula'])) {
21      $this->formula = $this->definition['formula'];
22    }
23  }
24
25  function get_formula() {
26    return str_replace('***table***', $this->table_alias, $this->formula);
27  }
28
29  /**
30   * Build the summary query based on a formula
31   */
32  function summary_query() {
33    $this->ensure_my_table();
34    // Now that our table is secure, get our formula.
35    $formula = $this->get_formula();
36
37    // Add the field.
38    $this->base_alias = $this->name_alias = $this->query->add_field(NULL, $formula, $this->field);
39    $this->query->set_count_field(NULL, $formula, $this->field);
40
41    return $this->summary_basics(FALSE);
42  }
43
44  /**
45   * Build the query based upon the formula
46   */
47  function query() {
48    $this->ensure_my_table();
49    // Now that our table is secure, get our formula.
50    $formula = $this->get_formula();
51
52    $this->query->add_where(0, "$formula = '%s'", $this->argument);
53  }
54}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.