You are here

function juicebox_style_plugin::validate in Juicebox HTML5 Responsive Image Galleries 7

Define validation rules for the plugin display.

Overrides views_plugin_style::validate

File

plugins/juicebox_style_plugin.inc, line 152
Contains the Juicebox views style plugin.

Class

juicebox_style_plugin
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'])) {
    drupal_set_message(t("To ensure a fully functional Juicebox gallery please remember to add at least one image field to your Juicebox view display and configure the Juicebox Gallery format settings."), 'warning', FALSE);
  }
  return $errors;
}