jwysiwyg.inc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @file
  4. * Editor integration functions for jWYSIWYG.
  5. */
  6. /**
  7. * Plugin implementation of hook_editor().
  8. */
  9. function wysiwyg_jwysiwyg_editor() {
  10. $editor['jwysiwyg'] = array(
  11. 'title' => 'jWYSIWYG',
  12. 'vendor url' => 'http://code.google.com/p/jwysiwyg/',
  13. 'download url' => 'http://code.google.com/p/jwysiwyg/downloads/list',
  14. 'libraries' => array(
  15. '' => array(
  16. 'title' => 'Source',
  17. 'files' => array('jquery.wysiwyg.js'),
  18. ),
  19. 'pack' => array(
  20. 'title' => 'Packed',
  21. 'files' => array('jquery.wysiwyg.pack.js'),
  22. ),
  23. ),
  24. 'version callback' => 'wysiwyg_jwysiwyg_version',
  25. // @todo Wrong property; add separate properties for editor requisites.
  26. 'css path' => wysiwyg_get_path('jwysiwyg'),
  27. 'versions' => array(
  28. '0.5' => array(
  29. 'js files' => array('jwysiwyg.js'),
  30. 'css files' => array('jquery.wysiwyg.css'),
  31. ),
  32. ),
  33. );
  34. return $editor;
  35. }
  36. /**
  37. * Detect editor version.
  38. *
  39. * @param $editor
  40. * An array containing editor properties as returned from hook_editor().
  41. *
  42. * @return
  43. * The installed editor version.
  44. */
  45. function wysiwyg_jwysiwyg_version($editor) {
  46. $script = $editor['library path'] . '/jquery.wysiwyg.js';
  47. if (!file_exists($script)) {
  48. return;
  49. }
  50. $script = fopen($script, 'r');
  51. fgets($script);
  52. $line = fgets($script);
  53. if (preg_match('@([0-9\.]+)$@', $line, $version)) {
  54. fclose($script);
  55. return $version[1];
  56. }
  57. fclose($script);
  58. }