You are here

function views_plugin_style_views_galleriffic::validate in Views Galleriffic 7

Make sure the display and all associated handlers are valid.

Return value

array Empty array if the display is valid; an array of error strings if it not.

Overrides views_plugin_style::validate

File

./views_plugin_style_views_galleriffic.inc, line 182
Provide the views gallariffic plugin object with default options and form.

Class

views_plugin_style_views_galleriffic
Implements of views_plugin_style().

Code

function validate() {
  $row_handler = $this->row_plugin->definition['handler'];
  switch ($row_handler) {
    case 'views_galleriffic_plugin_row_gallerifficrows':
      $errors = array();
      $row_fields = $this->row_plugin->options;

      // Check to make sure image fields aren't empty.
      foreach ($row_fields as $title => $result) {
        if (($title == 'slide_field' || $title == 'thumbnail_field') && empty($result)) {
          $errors[] = t('Views Galleriffic requires you to assign a field for "@field". Currently the "@field" is empty. Click \'Row Style: Galleriffic Fields\' to set.', array(
            '@field' => $title,
          ));
        }
      }

      // Check to make sure that two of the same image fields aren't selected.
      $results = array();
      foreach ($row_fields as $title => $result) {
        if ($result && in_array($result, $results)) {
          $errors[] = t("Views Galleriffic does not allow you to use the same field instance twice. You can use the same field twice, and are encouraged to for images. You just need to make two instances of the same field.  To do add the same field twice under 'Fields'. Give each a different label. Then select each instance of that field once under 'Row style: Galleriffic Fields'. See README.txt for details.");
        }
        $results[] = $result;
      }
      return $errors;
  }
}