You are here

function date_navigation_plugin_style::validate in Date 7

Same name and namespace in other branches
  1. 6.2 includes/date_navigation_plugin_style.inc \date_navigation_plugin_style::validate()
  2. 6 date_api.views.inc \date_navigation_plugin_style::validate()

Style validation.

Overrides views_plugin_style::validate

File

date_views/includes/date_navigation_plugin_style.inc, line 20
Views navigation style plugin for Date API.

Class

date_navigation_plugin_style
Style plugin to create date back/next navigation.

Code

function validate() {
  $errors = parent::validate();
  $arguments = $this->display->handler
    ->get_option('arguments');
  $count = 0;
  $found = FALSE;
  foreach ($arguments as $id => $argument) {
    if ($argument['field'] == 'date_argument') {
      if ($count > 0) {
        $errors[] = t('The %style cannot use more than one Date: Date argument.', array(
          '%style' => $this->definition['title'],
        ));
      }
      elseif ($argument['default_argument_type'] != 'date') {
        $errors[] = t('The %style requires the Date: Date argument be set to default to the current date.', array(
          '%style' => $this->definition['title'],
        ));
      }
      $count++;
      $found = TRUE;
    }
  }
  if (!$found) {
    $errors[] = t('The %style requires the Date: Date argument.', array(
      '%style' => $this->definition['title'],
    ));
  }
  return $errors;
}