You are here

public function date_views_argument_handler_simple::init in Date 7.3

Same name and namespace in other branches
  1. 8 date_views/includes/date_views_argument_handler_simple.inc \date_views_argument_handler_simple::init()
  2. 7.2 date_views/includes/date_views_argument_handler_simple.inc \date_views_argument_handler_simple::init()

Init the handler with necessary data.

Parameters

view $view: The $view object this handler is attached to.

array $options: The item from the database; the actual contents of this will vary based upon the type of handler.

Overrides views_handler_argument::init

1 call to date_views_argument_handler_simple::init()
date_views_argument_handler::init in date_views/includes/date_views_argument_handler.inc
Init the handler with necessary data.
1 method overrides date_views_argument_handler_simple::init()
date_views_argument_handler::init in date_views/includes/date_views_argument_handler.inc
Init the handler with necessary data.

File

date_views/includes/date_views_argument_handler_simple.inc, line 16
Date API views argument handler.

Class

date_views_argument_handler_simple
Date API views argument handler.

Code

public function init(&$view, &$options) {
  parent::init($view, $options);

  // Add a date handler.
  module_load_include('inc', 'date_api', 'date_api_sql');
  $this->date_handler = new date_sql_handler(DATE_UNIX);
  if (!empty($this->definition['field_name'])) {
    $field = field_info_field($this->definition['field_name']);
    if (!empty($field) && !empty($field['type'])) {
      $this->date_handler->date_type = $field['type'];
      $this->original_table = $this->definition['table'];
    }
    $this->date_handler->db_timezone = date_get_timezone_db($field['settings']['tz_handling']);
    $this->date_handler->local_timezone = date_get_timezone($field['settings']['tz_handling']);
  }
  $this->date_handler->granularity = $this->options['granularity'];

  // This value needs to be initialized so it exists even if the query
  // doesn't run.
  $this->date_handler->placeholders = array();
  $this->format = $this->date_handler
    ->views_formats($this->date_handler->granularity, 'display');
  $this->sql_format = $this->date_handler
    ->views_formats($this->date_handler->granularity, 'sql');

  // $this->arg_format is the format the parent date handler will use to
  // create a default argument.
  $this->arg_format = $this
    ->format();

  // Identify the base table for this field. It will be used to call for the
  // right query field options.
  $this->base_table = $this->table;
}