- if (checkForJavascript()) {
- /**
- * Some people may choose to disable javascript even though their
- * browser is capable of using it. So these freaks don't complain,
- * use document.write() so the "Check Spelling" button is not
- * displayed if js is off in the browser.
- */
- echo "<script type=\"text/javascript\">\n".
- "<!--\n".
- 'document.write("<input type=\"button\" value=\"'.
- _("Check Spelling").
- '\" onclick=\"window.open(\'../plugins/squirrelspell/sqspell_'.
- 'interface.php\', \'sqspell\', \'status=yes,width=550,height=370,'.
- 'resizable=yes\')\" />");' . "\n".
- "//-->\n".
- "</script>\n";
+ echo "<script type=\"text/javascript\">\n".
+ "<!--\n".
+ 'document.write("<input type=\"button\" value=\"'.
+ _("Check Spelling").
+ '\" name=\"check_spelling\" onclick=\"window.open(\'../plugins/squirrelspell/sqspell_'.
+ 'interface.php\', \'sqspell\', \'status=yes,width=550,height=370,'.
+ 'resizable=yes\')\" />");' . "\n".
+ "//-->\n".
+ "</script>\n";
+ }
+}
+
+/**
+ * Transparently upgrades user's dictionaries when message listing is loaded
+ * @since 1.5.1 (sqspell 0.5)
+ */
+function squirrelspell_upgrade() {
+ // globalize configuration vars before loading config.
+ // Vars are not available to scripts if not globalized before loading config.
+ // FIXME: move configuration loading to loading_prefs hook.
+ global $SQSPELL_APP, $SQSPELL_APP_DEFAULT, $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
+ include_once(SM_PATH . 'plugins/squirrelspell/sqspell_config.php');
+ include_once(SM_PATH . 'plugins/squirrelspell/sqspell_functions.php');
+
+ if (! sqspell_check_version(0,5)) {
+ $langs=sqspell_getSettings_old(null);
+ $words=sqspell_getWords_old();
+ sqspell_saveSettings($langs);
+ foreach ($langs as $lang) {
+ $lang_words=sqspell_getLang_old($words,$lang);
+ $aLang_words=explode("\n",$lang_words);
+ $new_words=array();
+ foreach($aLang_words as $word) {
+ if (! preg_match("/^#/",$word) && trim($word)!='') {
+ $new_words[]=$word;
+ }
+ }
+ sqspell_writeWords($new_words,$lang);