You are here

function juicebox in Juicebox HTML5 Responsive Image Galleries 7.2

Factory to instantiate a Juicebox object along with its dependencies.

The object returned will be uninitialized and will not represent a specific gallery until the init() method is called. This allows this function, and the object produced, to also be used in configuration management (building conf form structures, etc.).

The specific classes and dependencies used can be modified via hook_juicebox_classes_alter().

Return value

JuiceboxGalleryWrapperInterface A new uninitialized Juicebox object.

5 calls to juicebox()
JuiceboxFormatterViewsStyle::__construct in plugins/JuiceboxFormatterViewsStyle.inc
Constructor.
JuiceboxXmlField::getXml in plugins/JuiceboxXmlField.inc
Get the XML based on loaded data.
juicebox_field_formatter_info in includes/juicebox.field.inc
Implements hook_field_formatter_info().
juicebox_field_formatter_settings_form in includes/juicebox.field.inc
Implements hook_field_formatter_settings_form().
juicebox_field_formatter_view in includes/juicebox.field.inc
Implements hook_field_formatter_view().
20 string references to 'juicebox'
JuiceboxConfCase::setUp in tests/JuiceboxConfCase.test
Define setup tasks.
JuiceboxConfGlobalCase::setUp in tests/JuiceboxConfGlobalCase.test
Define setup tasks.
JuiceboxFieldFormatterCase::setUp in tests/JuiceboxFieldFormatterCase.test
Define setup tasks.
JuiceboxFileCase::setUp in tests/JuiceboxFileCase.test
Define setup tasks.
JuiceboxFileEntityCase::setUp in tests/JuiceboxFileEntityCase.test
Define setup tasks.

... See full list

File

./juicebox.module, line 203
Provides Drupal integration with the Juicebox library. This file contains the relevant Drupal hook implementations and callbacks.

Code

function juicebox() {

  // Get the library data. We do this early (before instantiating) as the lib
  // details should be allowed to impact which classes are used.
  $library = juicebox_library_detect();

  // Calculate the classes that need to be instantiated.
  $classes = array(
    'gallery' => 'JuiceboxGallery',
    'juicebox' => 'JuiceboxGalleryDrupal',
  );

  // Allow the classes to be altered.
  drupal_alter('juicebox_classes', $classes, $library);
  if (class_exists($classes['gallery']) && class_exists($classes['juicebox'])) {

    // Instantiate the Juicebox gallery objects with the appropriate
    // object-specific options. Note that we don't set the ID here yet as that
    // will be added via a setter method later.
    $object_settings = array(
      'filter_markup' => variable_get('juicebox_apply_markup_filter', TRUE),
      'process_attributes' => TRUE,
    );
    $gallery = new $classes['gallery'](NULL, $object_settings);
    if (in_array('JuiceboxGalleryInterface', class_implements($gallery))) {
      $juicebox = new $classes['juicebox']($gallery, $library);
      if (in_array('JuiceboxGalleryDrupalInterface', class_implements($juicebox))) {
        return $juicebox;
      }
    }
  }

  // If we get here it means that something went wrong and the object could not
  // be created.
  throw new Exception(t('Cound not instantiate Juicebox gallery. Please try clearing the Drupal registry and all caches.'));
}