You are here

function _plupload_requirements_version in Plupload integration 7

Same name and namespace in other branches
  1. 8 plupload.install \_plupload_requirements_version()
  2. 7.2 plupload.install \_plupload_requirements_version()
  3. 2.0.x plupload.install \_plupload_requirements_version()

Returns the version of the installed plupload library.

Return value

string The version of installed Plupload or NULL if unable to detect version.

1 call to _plupload_requirements_version()
plupload_requirements in ./plupload.install
Implements hook_requirements().

File

./plupload.install, line 89
Install, update and uninstall functions for the Plupload module.

Code

function _plupload_requirements_version() {
  $library_path = _plupload_library_path();
  $jspath = $library_path . '/js/plupload.js';

  // Read contents of Plupload's javascript file.
  $configcontents = @file_get_contents($jspath);
  if (!$configcontents) {
    return NULL;
  }

  // Search for version string using a regular expression.
  $matches = array();
  if (preg_match('#VERSION:\\"(\\d+[\\.\\d+]*)\\"#', $configcontents, $matches)) {
    return $matches[1];
  }

  // After 1.5.8 Plupload stopped adding version string to .js file. Let's check
  // first line of changelog.txt.
  $library_path = _plupload_library_path();
  $clpath = $library_path . '/changelog.txt';
  $configcontents = @file_get_contents($clpath);
  if (!$configcontents) {
    return NULL;
  }
  $lines = explode("\n", $configcontents);
  if (preg_match('#^Version (\\d+[\\.\\d+]*)#', $lines[0], $matches)) {
    return $matches[1];
  }
  return NULL;
}