[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/date/includes/ -> date_navigation_plugin_style.inc (source)

   1  <?php
   2  // $Id: date_navigation_plugin_style.inc,v 1.1.2.9 2009/01/24 00:41:45 karens Exp $
   3  /**
   4   * Style plugin to create date back/next navigation.
   5   * 
   6   * The style plugin passes some argument values to the theme, and
   7   * ensures that the date argument is present and that the default
   8   * value is set to the current date.
   9   */
  10  class date_navigation_plugin_style extends views_plugin_style {
  11    
  12    /**
  13     * Style validation.
  14     */
  15    function validate() {
  16      $errors = parent::validate();
  17      
  18      $arguments = $this->display->handler->get_option('arguments');
  19      $count = 0;
  20      $found = FALSE;
  21      foreach ($arguments as $id => $argument) {
  22        if ($argument['field'] == 'date_argument') {
  23          if ($count > 0) {
  24            $errors[] = t('The %style cannot use more than one Date: Date argument.', array('%style' => $this->definition['title']));          
  25          }
  26          elseif ($argument['default_argument_type'] != 'date') {
  27            $errors[] = t('The %style requires the Date: Date argument be set to default to the current date.', array('%style' => $this->definition['title']));      
  28          }
  29          $count++;
  30          $found = TRUE;
  31        }
  32      }
  33      if (!$found) {
  34        $errors[] = t('The %style requires the Date: Date argument.', array('%style' => $this->definition['title']));      
  35      }
  36      return $errors;
  37    }
  38    
  39    function query() {
  40      require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_sql.inc');
  41          
  42      // Bring the argument information into the view so our theme can access it.
  43      $i = 0;    
  44      foreach ($this->view->argument as $id => $argument) {
  45        if ($id == 'date_argument') {
  46          $this->view->date_info->granularity = $argument->granularity;
  47          $this->view->date_info->date_arg = !empty($this->view->args) && count($this->view->args) > $argument->position ? $this->view->args[$argument->position] : '';
  48          $this->view->date_info->date_arg_pos = $i;
  49          $this->view->date_info->year = isset($argument->year) ? $argument->year : NULL;
  50          $this->view->date_info->month = isset($argument->month) ? $argument->month: NULL;
  51          $this->view->date_info->day = isset($argument->day) ? $argument->day : NULL;
  52          $this->view->date_info->week = isset($argument->week) ? $argument->week : NULL;
  53          $this->view->date_info->min_date = $argument->min_date;
  54          $this->view->date_info->max_date = $argument->max_date;
  55          $this->view->date_info->url = $this->view->get_url();
  56        }
  57        $i++;
  58      }
  59       
  60      // bring the node type into the query so we can use it in the theme
  61      $this->view->query->add_field('node', 'type');
  62       
  63    }
  64  }


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