Index: imce.module =================================================================== --- imce.module (revision 317) +++ imce.module (working copy) @@ -892,3 +892,36 @@ function imce_integrate($e, $check=NULL) $state[$e] = TRUE; } } \ No newline at end of file + +/** + * Implementation of hook_wysiwyg_plugin(). + */ +function imce_wysiwyg_plugin($editor) { + static $access, $integrated; + + switch ($editor) { + case 'tinymce': + if (!isset($access)) { + $access = user_access('access imce'); + } + if ($access) { + $result = array( + 'imce' => array( + 'extensions' => array('imce' => t('IMCE')), + 'url' => 'http://drupal.org/project/imce', + 'options' => array( + 'file_browser_callback' => 'imceImageBrowser', + 'inline_styles' => TRUE, + ), + 'load' => TRUE, + ), + ); + if (!isset($integrated)) { + $integrated = TRUE; + drupal_add_js(array('imce'=>array('url' => url('imce/browse'), 'wysiwyg_module' => true)), 'setting'); + drupal_add_js(drupal_get_path('module', 'imce') .'/imce_set_tinymce.js'); + } + return $result; + } + } +} \ No newline at end of file Index: imce_set_tinymce.js =================================================================== --- imce_set_tinymce.js (revision 317) +++ imce_set_tinymce.js (working copy) @@ -19,11 +19,22 @@ function imceImageBrowser(field_name, ur //if (type!='image') return;//work for only images var width = 640; var height = 480; - window.open(imceBrowserURL||'/?q=imce/browse', '', 'width='+ width +', height='+ height +', resizable=1').focus(); + if (typeof(imceBrowserURL) != 'undefined') { + browserUrl = imceBrowserURL; + } else if (typeof(Drupal.settings.imce)!='undefined') { + browserUrl = Drupal.settings.imce.url; + } else { + browserUrl = '/?q=imce/browse'; + } + window.open(browserUrl, '', 'width='+ width +', height='+ height +', resizable=1').focus(); imceTinyWin = win; imceTinyField = win.document.forms[0].elements[field_name]; imceTinyType = type; imceTinyURL = url; } -$(document).ready(imceInitiateTinyMCE); +$(document).ready(function() { + if ('undefined' == typeof(Drupal.settings.imce) || !Drupal.settings.imce.wysiwyg_module){ + imceInitiateTinyMCE(); + } +}); \ No newline at end of file