You are here

function juicebox_library_detect in Juicebox HTML5 Responsive Image Galleries 7.2

Get/detect the details of a Juicebox javascript library without loading it.

This is essentially a wrapper for libraries_detect() with some caching added. It also allows library info to be fetched independently from the currently loaded version if needed (e.g., to accomodate XML requests that don't come from this site).

Parameters

boolean $force_local: Whether-or-not to force detection of the LOCALLY installed Juicebox library details. If FALSE Libraries API detection may be bypased if library version details can be detected through the URL.

boolean $reset: Whether-or-not to bypass and reset any caching information.

Return value

array An associative array of the library information.

4 calls to juicebox_library_detect()
juicebox in ./juicebox.module
Factory to instantiate a Juicebox object along with its dependencies.
juicebox_admin_settings in includes/juicebox.admin.inc
Menu callback: global configuration options to control Juicebox behaviour.
juicebox_preprocess_juicebox_debug_markup in themes/juicebox.theme.inc
Proprocess logic for the juicebox_debug_markup theme function.
juicebox_requirements in ./juicebox.install
Implements hook_requirements().

File

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

Code

function juicebox_library_detect($force_local = FALSE, $reset = FALSE) {

  // We use our own static cache for this. Libraries API detection has a static
  // cache, but as we may be bypassing full local detection in certain
  // situations, we can't always use it.
  $library =& drupal_static(__FUNCTION__, array());
  if (!$library || $reset) {

    // See if we have been passed version details in the URL. If so we bypass
    // local detection and build our own libraries array.
    $query = drupal_get_query_parameters();
    if (!empty($query['jb-version']) && !$force_local) {
      juicebox_library_info($library);
      $version_number = check_plain($query['jb-version']);
      if (!empty($query['jb-pro'])) {
        $library['pro'] = TRUE;
        $version = 'Pro';
      }
      else {
        $version = 'Lite';
      }
      $library['version'] = $version . ' ' . $version_number;
      juicebox_library_post_detect($library);
    }
    else {

      // We maintain our own DB cache here because libraries_detect() does not
      // have one. libaries_load() has one, but we don't want to be actually
      // loading the library here.
      $library = cache_get('juicebox_local_library', 'cache');
      if ($library && !$reset) {
        $library = $library->data;
      }
      else {
        $library = libraries_detect('juicebox');
        cache_set('juicebox_local_library', $library, 'cache');
      }
    }
  }
  return $library;
}