Changeset 608


Ignore:
Timestamp:
04/27/09 21:48:15 (3 years ago)
Author:
jf.hovinne
Message:

Drupal integration: improve version detection hook.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/apps/drupal/wysiwyg/editors/wymeditor.inc

    r607 r608  
    3535    'settings callback' => 'wysiwyg_wymeditor_settings', 
    3636    'versions' => array( 
    37       '0.5' => array( 
     37      '0.5-b3' => array( 
    3838        'js files' => array('wymeditor.js') 
    3939      ), 
     
    5353 */ 
    5454function wysiwyg_wymeditor_version($editor) { 
    55   $library = $editor['library path'] . '/jquery.wymeditor.js'; 
    56   if (!file_exists($library)) { 
    57     return; 
     55  $script = wysiwyg_get_path('wymeditor/wymeditor') . '/jquery.wymeditor.js'; 
     56  $script = fopen($script, 'r'); 
     57  fgets($script); 
     58  $line = fgets($script); 
     59  if (preg_match('@version\s([0-9a-z\.\-]+)$@', $line, $version)) { 
     60    fclose($script); 
     61    return $version[1]; 
    5862  } 
    59   $library = fopen($library, 'r'); 
    60   $max_lines = 200; 
    61   while ($max_lines && $line = fgets($library)) { 
    62     if (strpos($line, 'VERSION             :') !== FALSE) { 
    63       if (preg_match('@VERSION\s*:\s*"([0-9\.]+)@', $line, $version)) { 
    64         fclose($library); 
    65         return $version[1]; 
    66       } 
    67     } 
    68     $max_lines--; 
    69   } 
    70   fclose($library); 
    7163} 
    7264 
Note: See TracChangeset for help on using the changeset viewer.