You are here

function mobile_switch_mobile_detect_get_version in Mobile Switch 7.2

Detect the version number of a given Mobile Detect class file.

The class is given by path to file.

Parameters

$path: The path to the Mobile Detect class file. Example path: sites/all/libraries/Mobile_Detect/Mobile_Detect.php

Return value

string|boolean The detected version number or FALSE.

See also

mobile_switch_settings_form()

4 calls to mobile_switch_mobile_detect_get_version()
mobile_detect_import_settings_form in modules/mobile_detect_import/mobile_detect_import.admin.inc
Implements hook_form().
mobile_switch_requirements in ./mobile_switch.install
Implements hook_requirements().
mobile_switch_settings_form in includes/mobile_switch.admin.inc
Form constructor for the Basic settings form.
_mobile_detect_import_import in modules/mobile_detect_import/mobile_detect_import.import.inc
Helper function to update the Mobile Detect class file.

File

./mobile_switch.module, line 701
Provides various functionalities to develop mobile ready websites.

Code

function mobile_switch_mobile_detect_get_version($path, $pattern = MOBILE_SWITCH_LIBRARY_VERSION_PATTERN) {
  $version = FALSE;
  if (!file_exists($path)) {
    return $version;
  }
  $file = fopen($path, 'r');
  if ($file) {
    while ($line = fgets($file)) {
      if (preg_match($pattern, $line, $matches)) {
        $version = $matches[1];
        break;
      }
    }
    fclose($file);
  }
  return $version;
}