You are here

function superfish_library_version in Superfish 7

Same name and namespace in other branches
  1. 8 superfish.module \superfish_library_version()
  2. 6 superfish.install \superfish_library_version()

A function to check the Superfish library version.

1 call to superfish_library_version()
superfish_requirements in ./superfish.install
Implements hook_requirements().

File

./superfish.install, line 79
Install, update and uninstall functions for the Superfish module.

Code

function superfish_library_version() {

  // Ensure the Libraries API module is installed and working.
  if (module_exists('libraries') && function_exists('libraries_get_path') && libraries_get_path('superfish') != '') {
    $directory = libraries_get_path('superfish');
  }
  elseif (file_exists('profiles/' . drupal_get_profile() . '/libraries/superfish')) {
    $directory = 'profiles/' . drupal_get_profile() . '/libraries/superfish';
  }
  else {
    $directory = 'sites/all/libraries/superfish';
  }

  // Get the library version.
  if (file_exists($directory . '/VERSION')) {
    $version = file_get_contents($directory . '/VERSION');

    // Removing blank lines and white spaces.
    $version = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/", "\n", trim($version));
    if (!empty($version)) {
      return $version;
    }
    else {
      return '';
    }
  }
  else {
    return '';
  }
}