imce_wysiwyg.module 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * @file
  4. * Makes IMCE available as plugin for client-side editors integrated via
  5. * Wysiwyg API.
  6. */
  7. /**
  8. * Implements hook_wysiwyg_plugin().
  9. */
  10. function imce_wysiwyg_plugin($editor, $version) {
  11. static $integrated = array();
  12. if (!module_invoke('imce', 'access')) {
  13. return;
  14. }
  15. // Load our invocation scripts.
  16. if (empty($integrated)) {
  17. $imcepath = drupal_get_path('module', 'imce');
  18. $path = drupal_get_path('module', 'imce_wysiwyg');
  19. drupal_add_js($imcepath . '/js/imce.js');
  20. drupal_add_js($imcepath . '/js/imce_set_app.js');
  21. drupal_add_js($path . '/js/imce_wysiwyg.js');
  22. }
  23. switch ($editor) {
  24. case 'tinymce':
  25. if (!isset($integrated[$editor])) {
  26. $integrated[$editor] = TRUE;
  27. // @todo If some other editor also needs the URL to be passed via
  28. // Drupal.settings.imce, then we need another sub-key '$editor'.
  29. $settings = array(
  30. 'imce' => array('url' => url('imce', array('query' => array('app' => $editor . '|url@')))),
  31. );
  32. drupal_add_js($settings, 'setting');
  33. }
  34. return array(
  35. 'imce' => array(
  36. 'extensions' => array('imce' => t('IMCE')),
  37. 'url' => 'http://drupal.org/project/imce',
  38. 'options' => array(
  39. 'file_browser_callback' => 'imceImageBrowser',
  40. 'inline_styles' => TRUE,
  41. ),
  42. 'load' => FALSE,
  43. ),
  44. );
  45. case 'ckeditor':
  46. $integrated[$editor] = TRUE;
  47. return array(
  48. 'imce' => array(
  49. 'extensions' => array('imce' => t('IMCE')),
  50. 'url' => 'http://drupal.org/project/imce',
  51. 'options' => array(
  52. 'filebrowserBrowseUrl' => url('imce', array('query' => array('app' => $editor . '|sendto@imceCkeditSendTo|params@'))),
  53. ),
  54. 'load' => FALSE,
  55. ),
  56. );
  57. case 'fckeditor':
  58. $integrated[$editor] = TRUE;
  59. return array(
  60. 'imce' => array(
  61. 'extensions' => array('imce' => t('IMCE')),
  62. 'url' => 'http://drupal.org/project/imce',
  63. 'options' => array(
  64. 'LinkBrowser' => TRUE,
  65. 'LinkBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl'))),
  66. 'ImageBrowser' => TRUE,
  67. 'ImageBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl|width@txtWidth|height@txtHeight'))),
  68. 'FlashBrowser' => TRUE,
  69. 'FlashBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl'))),
  70. ),
  71. 'load' => FALSE,
  72. ),
  73. );
  74. }
  75. }