You are here

class date_plugin_argument_default in Date 6

Default argument plugin to default to the current date.

Hierarchy

Expanded class hierarchy of date_plugin_argument_default

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

File

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

View source
class date_plugin_argument_default extends views_plugin_argument_default {
  var $option_name = 'default_argument_date';

  // If used on a date argument that is tracking granularity, use that
  // for the format, otherwise get a format to use for the argument.
  function argument_form(&$form, &$form_state) {
    if (!empty($this->argument->options['granularity'])) {
      return;
    }
    else {
      $form[$this->option_name] = array(
        '#title' => t('Current date format'),
        '#description' => t('Select a format to use when creating a missing argument from the current date.'),
        '#type' => 'select',
        '#options' => array(
          'Y-m-d' => 'YYYY-MM-DD',
          'Ymd' => 'YYYYMMDD',
          'Y-m' => 'YYYY-MM',
          'Ym' => 'YYYYMM',
          'Y' => 'YYYY',
          'Y-\\Ww' => 'YYYY-W99',
          'Y\\Ww' => 'YYYYW99',
        ),
        '#default_value' => $this
          ->format(),
        '#process' => array(
          'views_process_dependency',
        ),
        '#dependency' => array(
          'radio:options[default_action]' => array(
            'default',
          ),
          'radio:options[default_argument_type]' => array(
            $this->id,
          ),
        ),
        '#dependency_count' => 2,
      );
      $this
        ->check_access($form);
    }
  }
  function format() {
    if (!empty($this->argument->options['granularity'])) {
      $date_handler = new date_sql_handler();
      return $date_handler
        ->views_formats($this->argument->options['granularity']);
    }
    else {
      return !empty($this->argument->options[$this->option_name]) ? $this->argument->options[$this->option_name] : 'Y-m';
    }
  }
  function get_argument() {
    return date($this
      ->format(), time());
  }

}

Members