You are here

function _cloud_zoom_get_path in Cloud Zoom 8

Same name and namespace in other branches
  1. 7 cloud_zoom.module \_cloud_zoom_get_path()

Retrieve the expected path to the example library.

Return value

The path where the example library is to be expected to be installed. Returns FALSE if the library is not found.

1 call to _cloud_zoom_get_path()
cloud_zoom_library in ./cloud_zoom.module
Implements hook_library()

File

./cloud_zoom.module, line 100
This module integrates the Cloud Zoom JQuery library from: http://www.professorcloud.com/mainsite/cloud-zoom.htm

Code

function _cloud_zoom_get_path() {
  static $path = NULL;
  if (isset($path)) {
    return $path;
  }
  $path = FALSE;

  // Check if the libraries module is installed and if the example library is
  // being supplied through the libraries module.
  if (module_exists('libraries')) {

    // Check if the library is found. If no library is found libraries_get_path()
    // will still return sites/all/libraries as a path.
    $libraries = libraries_get_libraries();
    if (isset($libraries['cloud-zoom'])) {
      $libraries_path = libraries_get_path('cloud-zoom');
      if (_cloud_zoom_check_path($libraries_path)) {
        $path = $libraries_path;
      }
    }
  }

  // Check in the cloud-zoom directory within the module directory.
  if (!$path) {
    $module_path = drupal_get_path('module', 'cloud_zoom') . '/cloud-zoom';
    if (_cloud_zoom_check_path($module_path)) {
      $path = $module_path;
    }
  }

  // Check if the example library is in the include path.
  if (!$path) {
    $include_paths = explode(PATH_SEPARATOR, get_include_path());
    foreach ($include_paths as $include_path) {
      if (is_dir($include_path . '/example')) {
        $path = $include_path . '/example';
        continue;
      }
    }
  }
  return $path;
}