/[drupal]/contributions/modules/views/handlers/views_handler_argument_formula.inc
ViewVC logotype

Contents of /contributions/modules/views/handlers/views_handler_argument_formula.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Sep 3 19:21:28 2008 UTC (14 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, DRUPAL-6--2-6, DRUPAL-6--2-5, DRUPAL-6--2-4, DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--2-1, DRUPAL-6--2-0, DRUPAL-6--3-0-ALPHA1, DRUPAL-6--2-0-RC5, DRUPAL-6--2-0-RC4, DRUPAL-6--2-0-RC3, DRUPAL-6--2-0-RC2, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--3, DRUPAL-7--3
File MIME type: text/x-php
Major re-organization of handlers. PLEASE NOTE: This drastically affected the Views module API and until modules are updated to match, they will stop working. Efforts have been made to ensure that this won't cause your site to crash, but that's partly up to the individual module as well.
1 <?php
2 // $Id$
3 /**
4 * Abstract argument handler for simple formulae.
5 *
6 * Child classes of this object should implement summary_argument, at least.
7 *
8 * Definition terms:
9 * - formula: The formula to use for this handler.
10 *
11 * @ingroup views_argument_handlers
12 */
13 class views_handler_argument_formula extends views_handler_argument {
14 var $formula = NULL;
15 /**
16 * Constructor
17 */
18 function construct() {
19 parent::construct();
20
21 if (!empty($this->definition['formula'])) {
22 $this->formula = $this->definition['formula'];
23 }
24 }
25
26 function get_formula() {
27 return str_replace('***table***', $this->table_alias, $this->formula);
28 }
29
30 /**
31 * Build the summary query based on a formula
32 */
33 function summary_query() {
34 $this->ensure_my_table();
35 // Now that our table is secure, get our formula.
36 $formula = $this->get_formula();
37
38 // Add the field.
39 $this->base_alias = $this->name_alias = $this->query->add_field(NULL, $formula, $this->field);
40 $this->query->set_count_field(NULL, $formula, $this->field);
41
42 return $this->summary_basics(FALSE);
43 }
44
45 /**
46 * Build the query based upon the formula
47 */
48 function query() {
49 $this->ensure_my_table();
50 // Now that our table is secure, get our formula.
51 $formula = $this->get_formula();
52
53 $this->query->add_where(0, "$formula = '%s'", $this->argument);
54 }
55 }

  ViewVC Help
Powered by ViewVC 1.1.2