You are here

function JuiceboxFormatterViewsStyle::validate in Juicebox HTML5 Responsive Image Galleries 7.2

Define validation rules for the plugin display.

Overrides views_plugin_style::validate

File

plugins/JuiceboxFormatterViewsStyle.inc, line 139
Contains the Juicebox views style plugin.

Class

JuiceboxFormatterViewsStyle
Style plugin to render each item in a views list.

Code

function validate() {
  $errors = parent::validate();

  // Make sure block caching is not enabled. With block caching enabled the
  // Juicebox javascript library may not get included.
  if (isset($this->display->handler->options['block_caching']) && $this->display->handler->options['block_caching'] != DRUPAL_NO_CACHE) {
    $errors[] = t('The Juicebox style cannot be used with block caching. Please disable the "Block caching" option for this display.');
  }

  // Make sure the pager is not enabled.
  if ($this->display->handler
    ->use_pager()) {
    $errors[] = t('The Juicebox style cannot be used with a pager. Please disable the "Use pager" option for this display.');
  }

  // We want to somewhat "nag" the user if they have not yet configured the
  // Juicebox-specific plugin settings (because things won't work until they
  // do). However, we do NOT want to formally set an error. This is because
  // this validate method can run on pages where the user can't actaully touch
  // the Juicebox-specific plugin settings (such as
  // admin/structure/views/add).
  if (empty($this->options['image_field']) || empty($this->options['thumb_field'])) {
    drupal_set_message(t("To ensure a fully functional Juicebox gallery please remember to add at least one field of type Image, File or File ID to your Juicebox view display, and to configure all Juicebox Gallery format settings. Once you have completed these steps, re-save your view to remove this warning."), 'warning', FALSE);
  }

  // Set warning about depreciated "Base file ID" source option if it's used.
  if ($this->options['image_field'] == 'file_base' || $this->options['thumb_field'] == 'file_base') {
    drupal_set_message(t('A Juicebox gallery used in your view is configured with an obsolete source setting of "Base file ID". Please add a File ID field to the related display and choose that instead for your image or thumb source within the Juicebox Gallery format settings. Once you have completed these steps, re-save your view to remove this warning.'), 'warning', FALSE);
  }
  return $errors;
}