You are here

function splashify_get_library_path in Splashify 6

Gets the path to the folder in which the requested library is expected to live.

This is adapted from jquery_ui_get_path() in the jQuery UI module.

Parameters

string $library_name The name of the library (e.g., 'jstorage', not: 'jstorage.min.js')

Return value

mixed $path The path to the requested library's folder, or FALSE

2 calls to splashify_get_library_path()
splashify_init in ./splashify.display.inc
Implements hook_init().
splashify_requirements in ./splashify.install
Implements hook_requirements().

File

./splashify.module, line 134

Code

function splashify_get_library_path($library_name) {
  static $path;
  if (isset($path)) {
    return $path;
  }
  $path = FALSE;

  // Libraries API integration.
  if (function_exists('libraries_get_path')) {
    $path = libraries_get_path($library_name);

    // Libraries API 1.x returns a default path; 2.x returns FALSE.
    if ($path !== FALSE && !file_exists($path)) {
      $path = FALSE;
    }
  }
  elseif (file_exists('./sites/all/libraries/' . $library_name)) {
    $path = 'sites/all/libraries/' . $library_name;
  }

  // Check the module directory for backwards compatibility if other methods
  // failed.
  if (!$path) {

    // drupal_get_path() is not available during Drupal installation.
    if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') {
      $path = drupal_substr(dirname(__FILE__), drupal_strlen(getcwd()) + 1);
      $path = strtr($path, '\\', '/');
      $path .= '/' . $library_name;
    }
    else {

      // Unlikely it would be here, but may as well check
      $path = drupal_get_path('module', 'splashify') . '/' . $library_name;
    }
    if (!file_exists($path)) {
      $path = FALSE;
    }
  }
  return $path;
}