You are here

function superfish_library_path in Superfish 8

Same name and namespace in other branches
  1. 6 superfish.admin.inc \superfish_library_path()

Returns the Superfish library folder location.

5 calls to superfish_library_path()
superfish_effects in ./superfish.module
Generate a list of available slide-in effects.
superfish_library_check in ./superfish.module
Verifies Superfish library is present.
superfish_library_info_build in ./superfish.module
Implements hook_library_info_build().
superfish_library_version in ./superfish.module
Checks Superfish library version.
superfish_requirements in ./superfish.install
Implements hook_requirements().

File

./superfish.module, line 197
The jQuery Superfish plugin for Drupal menus.

Code

function superfish_library_path($library = 'superfish') {
  $directory = FALSE;

  // Ensure the Libraries API module is installed and working.
  if (function_exists('libraries_get_path')) {
    $directory = libraries_get_path($library);
    if ($directory) {
      return $directory;
    }
    elseif (ucfirst($library) !== $library) {
      $directory = libraries_get_path(ucfirst($library));
      if ($directory) {
        return $directory;
      }
    }
  }

  // Otherwise use the default directory.
  if (\Drupal::hasContainer()) {
    $profile = \Drupal::installProfile();
  }
  else {
    $profile = BootstrapConfigStorageFactory::getDatabaseStorage()
      ->read('core.extension')['profile'];
  }
  if (file_exists('profiles/' . $profile . '/libraries/' . $library)) {
    $directory = 'profiles/' . $profile . '/libraries/' . $library;
  }
  elseif (file_exists('profiles/contrib/' . $profile . '/libraries/' . $library)) {
    $directory = 'profiles/contrib/' . $profile . '/libraries/' . $library;
  }
  elseif (file_exists('profiles/custom/' . $profile . '/libraries/' . $library)) {
    $directory = 'profiles/custom/' . $profile . '/libraries/' . $library;
  }
  elseif (file_exists('libraries/' . $library)) {
    $directory = 'libraries/' . $library;
  }
  elseif (file_exists('sites/all/libraries/' . $library)) {
    $directory = 'sites/all/libraries/' . $library;
  }
  elseif (file_exists('sites/default/libraries/' . $library)) {
    $directory = 'sites/default/libraries/' . $library;
  }
  if (!$directory && ucfirst($library) !== $library) {
    $directory = superfish_library_path(ucfirst($library));
  }
  return $directory;
}