You are here

class date_navigation_plugin_style in Date 6

Same name and namespace in other branches
  1. 6.2 includes/date_navigation_plugin_style.inc \date_navigation_plugin_style
  2. 7 date_views/includes/date_navigation_plugin_style.inc \date_navigation_plugin_style

Style plugin to create date back/next navigation.

The style plugin passes some argument values to the theme, and ensures that the date argument is present and that the default value is set to the current date.

Hierarchy

Expanded class hierarchy of date_navigation_plugin_style

1 string reference to 'date_navigation_plugin_style'
date_api_views_plugins in ./date_api.views.inc
Implementation of hook_views_plugins

File

./date_api.views.inc, line 448
Defines date-related Views data and plugins:

View source
class date_navigation_plugin_style extends views_plugin_style {

  /**
   * Style validation.
   */
  function validate() {
    $errors = parent::validate();
    $arguments = $this->display->handler
      ->get_option('arguments');
    if (!in_array('date_argument', array_keys($arguments))) {
      $errors[] = t('The @style requires the Calendar: Date argument.', array(
        '@style' => $this->definition['title'],
      ));
    }
    else {
      if ($arguments['date_argument']['default_argument_type'] != 'date') {
        $errors[] = t('The @style requires the Calendar: Date argument to provide a default argument set to default to the current date.', array(
          '@style' => $this->definition['title'],
        ));
      }
    }
    return $errors;
  }
  function query() {
    include_once drupal_get_path('module', 'date_api') . '/date_api_sql.inc';

    // Bring the argument information into the view so our theme can access it.
    $i = 0;
    foreach ($this->view->argument as $delta => $argument) {
      if ($argument['id'] == 'date_argument') {
        $this->view->date_type = $argument['handler']->date_type;
        $this->view->date_arg = $argument['handler']->argument;
        $this->view->date_arg_pos = $i;
        $this->view->year = $argument['handler']->year;
        $this->view->month = $argument['handler']->month;
        $this->view->day = $argument['handler']->day;
        $this->view->week = $argument['handler']->week;
        $this->view->min_date = $argument['handler']->min_date;
        $this->view->max_date = $argument['handler']->max_date;
      }
      $i++;
    }

    // bring the node type into the query so we can use it in the theme
    $this->view->query
      ->add_field('node', 'type');
    parent::query();
  }

  /**
   * Render the calendar navigation style.
   */
  function render() {
    return theme($this
      ->theme_functions(), $this->view, $this->options, array());
  }

}

Members