5 * Squirrelspell setup file, as defined by the SquirrelMail-1.2 API.
7 * Copyright (c) 1999-2005 The SquirrelMail Project Team
8 * Licensed under the GNU GPL. For full terms see the file COPYING.
10 * @author Konstantin Riabitsev <icon@duke.edu>
13 * @subpackage squirrelspell
17 if (! defined('SM_PATH')) define('SM_PATH','../../');
20 * Standard SquirrelMail plugin initialization API.
24 function squirrelmail_plugin_init_squirrelspell() {
25 global $squirrelmail_plugin_hooks;
26 $squirrelmail_plugin_hooks['compose_button_row']['squirrelspell'] =
27 'squirrelspell_setup';
28 $squirrelmail_plugin_hooks['optpage_register_block']['squirrelspell'] =
29 'squirrelspell_optpage_register_block';
30 $squirrelmail_plugin_hooks['options_link_and_description']['squirrelspell'] =
31 'squirrelspell_options';
32 $squirrelmail_plugin_hooks['right_main_after_header']['squirrelspell'] =
33 'squirrelspell_upgrade';
37 * This function formats and adds the plugin and its description to the
42 function squirrelspell_optpage_register_block() {
43 global $optpage_blocks;
45 * Check if this browser is capable of using the plugin
47 if (checkForJavascript()) {
49 * The browser checks out.
50 * Register Squirrelspell with the $optpage_blocks array.
54 'name' => _("SpellChecker Options"),
55 'url' => '../plugins/squirrelspell/sqspell_options.php',
56 'desc' => _("Here you may set up how your personal dictionary is stored, edit it, or choose which languages should be available to you when spell-checking."),
62 * This function adds a "Check Spelling" link to the "Compose" row
63 * during message composition.
67 function squirrelspell_setup() {
69 * Check if this browser is capable of displaying SquirrelSpell
72 if (checkForJavascript()) {
74 * Some people may choose to disable javascript even though their
75 * browser is capable of using it. So these freaks don't complain,
76 * use document.write() so the "Check Spelling" button is not
77 * displayed if js is off in the browser.
79 echo "<script type=\"text/javascript\">\n".
81 'document.write("<input type=\"button\" value=\"'.
83 '\" name=\"check_spelling\" onclick=\"window.open(\'../plugins/squirrelspell/sqspell_'.
84 'interface.php\', \'sqspell\', \'status=yes,width=550,height=370,'.
85 'resizable=yes\')\" />");' . "\n".
92 * Transparently upgrades user's dictionaries when message listing is loaded
93 * @since 1.5.1 (sqspell 0.5)
95 function squirrelspell_upgrade() {
96 // globalize configuration vars before loading config.
97 // Vars are not available to scripts if not globalized before loading config.
98 // FIXME: move configuration loading to loading_prefs hook.
99 global $SQSPELL_APP, $SQSPELL_APP_DEFAULT, $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
100 include_once(SM_PATH
. 'plugins/squirrelspell/sqspell_config.php');
101 include_once(SM_PATH
. 'plugins/squirrelspell/sqspell_functions.php');
103 if (! sqspell_check_version(0,5)) {
104 $langs=sqspell_getSettings_old(null);
105 $words=sqspell_getWords_old();
106 sqspell_saveSettings($langs);
107 foreach ($langs as $lang) {
108 $lang_words=sqspell_getLang_old($words,$lang);
109 $aLang_words=explode("\n",$lang_words);
111 foreach($aLang_words as $word) {
112 if (! preg_match("/^#/",$word) && trim($word)!='') {
116 sqspell_writeWords($new_words,$lang);
118 // bump up version number
119 setPref($data_dir,$username,'sqspell_version','0.5');
124 * Function that displays internal squirrelspell version
125 * @since 1.5.1 (sqspell 0.5)
126 * @return string plugin's version
127 * @todo remove 'cvs' part from version when plugin's code is
130 function squirrelspell_version() {