You are here

function wysiwyg_wymeditor_version in Wysiwyg 6.2

Same name and namespace in other branches
  1. 5.2 editors/wymeditor.inc \wysiwyg_wymeditor_version()
  2. 7.2 editors/wymeditor.inc \wysiwyg_wymeditor_version()

Detect editor version.

Parameters

$editor: An array containing editor properties as returned from hook_editor().

Return value

The installed editor version.

1 string reference to 'wysiwyg_wymeditor_version'
wysiwyg_wymeditor_editor in editors/wymeditor.inc
Plugin implementation of hook_editor().

File

editors/wymeditor.inc, line 54
Editor integration functions for WYMeditor.

Code

function wysiwyg_wymeditor_version(&$editor) {
  $script = $editor['library path'] . '/jquery.wymeditor.js';
  if (!file_exists($script)) {
    $script = $editor['library path'] . '/wymeditor/jquery.wymeditor.js';
    if (!file_exists($script)) {
      return;
    }
    $editor['library path'] .= '/wymeditor';
    $editor['editor path'] .= '/wymeditor';
  }
  $script = fopen($script, 'r');
  for ($i = 0; $i < 189; $i++) {
    $line = fgets($script);
    if (preg_match('@version\\s+([0-9\\.]+(?:-?[a-z0-9\\.]+)?[^\\.])@', $line, $version)) {
      fclose($script);
      return trim($version[1]);
    }
  }
  fclose($script);
}