You are here

function nice_menus_get_version in Nice Menus 7.2

Gets the version information from an arbitrary library.

Return value

A string containing the version of the library.

1 call to nice_menus_get_version()
nice_menus_library in ./nice_menus.module
Implements hook_library().

File

./nice_menus.module, line 209
Module to enable CSS dropdown and flyout menus.

Code

function nice_menus_get_version($file, $options = array()) {

  // Provide defaults.
  $options += array(
    'file' => '',
    'pattern' => '',
    'lines' => 10,
    'cols' => 200,
  );
  $file = DRUPAL_ROOT . '/' . $file;
  if (!is_file($file)) {
    return;
  }
  $file = fopen($file, 'r');
  while ($options['lines'] && ($line = fgets($file, $options['cols']))) {
    if (preg_match($options['pattern'], $line, $version)) {
      fclose($file);
      return $version[1];
    }
    $options['lines']--;
  }
  fclose($file);
}