You are here

function itoggle_get_version in iToggle 7

Return the version of iToggle plugin that is installed.

This can be used by other modules' hook_requirements() to ensure that the proper version of iToggle plugin is installed.

This was borrowed from the Colorbox module

@link http://drupal.org/project/colorbox

See also

version_compare()

1 call to itoggle_get_version()
itoggle_requirements in ./itoggle.install
Implements hook_requirements(). This was borrowed from the Colorbox module

File

includes/itoggle.inc, line 108
iToggle module include.

Code

function itoggle_get_version($itoggle_js = NULL) {
  $version = 0;
  $pattern = '#Version: ([0-9\\.a-z]+)#';

  // No file is passed in so use the default location.
  if (is_null($itoggle_js)) {
    $itoggle_js = itoggle_get_js();
  }

  // Return the version of iToggle plugin, it it exists.
  if (file_exists($itoggle_js)) {
    $itoggle_plugin = file_get_contents($itoggle_js, NULL, NULL, 0, 256);
    if (preg_match($pattern, $itoggle_plugin, $matches)) {
      $version = $matches[1];
    }
  }
  return $version;
}