diff --git a/wysiwyg_spellcheck.module b/wysiwyg_spellcheck.module index d55115e..3a18c43 100644 --- a/wysiwyg_spellcheck.module +++ b/wysiwyg_spellcheck.module @@ -6,11 +6,18 @@ * wysiwyg_spellcheck is a plugin for wysiwyg editors */ -function _wysiwyg_spellcheck_default_path() { - return - function_exists('wysiwyg_get_path') - ? wysiwyg_get_path('tinymce') . '/jscripts/tiny_mce/plugins/spellchecker' - : 'sites/all/libraries/tinymce/jscripts/tiny_mce/plugins/spellchecker'; +function _wysiwyg_default_path($editor) { + // Get base path. + $path = function_exists('wysiwyg_get_path') ? wysiwyg_get_path($editor) : 'sites/all/libraries/jscripts/' . $editor; + + // Get spellcheck plugin path. + switch ($editor) { + case 'tinymce': + $path .= '/jscripts/tiny_mce/plugins/spellchecker'; + case 'ckeditor': + $path .= '/plugins/aspell'; + } + return $path; } /** @@ -18,7 +25,7 @@ function _wysiwyg_spellcheck_default_path() { */ function wysiwyg_spellcheck_help($path, $arg) { if ($path == 'admin/modules#description') { - return t('Enables TinyMCE spellchecker plugin in Wysiwyg editor.'); + return t('Enables the TinyMCE spellchecker or CKEditor ASpell plugin in Wysiwyg editor.'); } } @@ -28,29 +35,29 @@ function wysiwyg_spellcheck_help($path, $arg) { function wysiwyg_spellcheck_wysiwyg_plugin($editor) { switch ($editor) { case 'tinymce': -//if ($version > 3) { -// $path = drupal_get_path('module', 'wysiwyg_spellcheck'); - $path = variable_get('wysiwyg_spellcheck_tinymce_spellchecker_location', _wysiwyg_spellcheck_default_path()); - if (file_exists("$path/editor_plugin.js")) return array( -// SEE http://drupal.org/files/issues/wysiwyg_api_documentation.patch - 'spellchecker' => array( -// 'path' => $editor['library path'] .'/plugins/spellchecker', - 'path' => $path . '/editor_plugin.js', -// 'path' => $path . '/editor_plugin_src.js', - 'buttons' => array('spellchecker' => t('Spell Check')), - 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker', - 'load' => TRUE, - ), - ); -//} // if ($version) - } -} + $path = variable_get('wysiwyg_spellcheck_' . $editor . '_spellchecker_location', _wysiwyg_default_path($editor)); + if (file_exists("$path/editor_plugin.js")) { + return array( + 'spellchecker' => array( + 'path' => $path . '/editor_plugin.js', + 'buttons' => array('spellchecker' => t('Spell Check')), + 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker', + 'load' => TRUE, + ), + ); + } -/** - * Implementation of hook_init(). - */ -function wysiwyg_spellcheck_init() { -// $path = drupal_get_path('module', 'wysiwyg_spellcheck'); -// drupal_add_js($path . '/tinymce/spellchecker/any.js'); -// drupal_add_js('var anyvar = "/' . $path . '/mimetex/mimetex.cgi";', 'inline'); + case 'ckeditor': + $path = variable_get('wysiwyg_spellcheck_' . $editor . '_spellchecker_location', _wysiwyg_default_path($editor)); + if (file_exists("$path/plugin.js")) { + return array( + 'aspell' => array( + 'path' => $path, + 'buttons' => array('SpellCheck' => t('Server Side Spell Check')), + 'url' => 'http://cksource.com/forums/viewtopic.php?p=51193#p51193', + 'load' => TRUE, + ), + ); + } + } }