[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/station/schedule/views/ -> station_schedule_handler_argument_day.inc (source)

   1  <?php
   2  // $Id: station_schedule_handler_argument_day.inc,v 1.2 2009/09/21 21:36:20 drewish Exp $
   3  
   4  /**
   5   * @file
   6   * Views argument handler for Image size argument.
   7   */
   8  
   9  /**
  10   * Argument handler for the schedule item's day of the week.
  11   */
  12  class station_schedule_handler_argument_day extends views_handler_argument {
  13    function title() {
  14      return station_day_name(station_valid_day($this->argument));
  15    }
  16  
  17    /**
  18     * Build the summary query based on a formula
  19     */
  20    function summary_query() {
  21      $this->ensure_my_table();
  22  
  23      // Convert the Group the programs by day.
  24      $min_in_day = MINUTES_IN_DAY;
  25      $formula = "CAST($this->table_alias.start / $min_in_day AS UNSIGNED INTEGER) %% 7";
  26  
  27      // Add the field.
  28      $suggested_alias = $this->table_alias .'_start_group';
  29      $this->base_alias = $this->name_alias = $this->query->add_field(NULL, $formula, $suggested_alias);
  30      $this->query->set_count_field(NULL, $formula, $suggested_alias);
  31  
  32      return $this->summary_basics(FALSE);
  33    }
  34  
  35    function summary_name($data) {
  36      return station_day_name($data->{$this->name_alias});
  37    }
  38  
  39    /**
  40     * Build the query based upon the formula
  41     */
  42    function query() {
  43      $this->ensure_my_table();
  44  
  45      $day = station_valid_day($this->argument);
  46      $start = $day * MINUTES_IN_DAY;
  47      $finish = ($day + 1) * MINUTES_IN_DAY;
  48  
  49      // The idea is that we want all the items that end after the day begins or
  50      // start before the day ends.
  51      $formula = "$this->table_alias.finish > %d AND $this->table_alias.start < %d";
  52      $this->query->add_where(0, $formula, $start, $finish);
  53    }
  54  }


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