You are here

public function JuiceboxXmlViewsStyle::__construct in Juicebox HTML5 Responsive Image Galleries 7.2

Constructor.

Parameters

array $id_args: An indexed array of arguments that describe this gallery (and make up its XML URL). This information uniquely identifies the gallery and contains all the descriptive data needed to load it.

File

plugins/JuiceboxXmlViewsStyle.inc, line 33
Juicebox XML loader that's used to load (and build via loaded methods) the XML associated with a Drupal views style formatter plugin.

Class

JuiceboxXmlViewsStyle
Class to load and build the XML associated with a Drupal views style formatter plugin.

Code

public function __construct($id_args) {

  // We need at least 3 data sources to build a view-based gallery (the type
  // along with 2 identifiers for the view display).
  if (empty($id_args) || count($id_args) < 3) {
    throw new Exception(t('Cannot initiate view style Juicebox XML due to insufficient ID args.'));
  }

  // Set data sources as properties.
  $this->viewName = $id_args[1];
  $this->viewDisplay = $id_args[2];
  $this->viewArgs = array_slice($id_args, 3);
  $this->view = views_get_view($this->viewName);
  if (empty($this->view)) {
    throw new Exception(t('Cannot initiate view style Juicebox XML because view @view cannot be found.', array(
      '@view' => $this->viewName,
    )));
  }
}