f8017a373447238283a1cf9fc8ed9bfe2c598048
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.
23 function squirrelmail_plugin_init_squirrelspell() {
24 global $squirrelmail_plugin_hooks;
25 $squirrelmail_plugin_hooks['compose_button_row']['squirrelspell'] =
26 'squirrelspell_setup';
27 $squirrelmail_plugin_hooks['optpage_register_block']['squirrelspell'] =
28 'squirrelspell_optpage_register_block';
29 $squirrelmail_plugin_hooks['options_link_and_description']['squirrelspell'] =
30 'squirrelspell_options';
31 $squirrelmail_plugin_hooks['right_main_after_header']['squirrelspell'] =
32 'squirrelspell_upgrade';
36 * This function formats and adds the plugin and its description to the
40 function squirrelspell_optpage_register_block() {
41 global $optpage_blocks;
43 * Check if this browser is capable of using the plugin
45 if (checkForJavascript()) {
47 * The browser checks out.
48 * Register Squirrelspell with the $optpage_blocks array.
52 'name' => _("SpellChecker Options"),
53 'url' => '../plugins/squirrelspell/sqspell_options.php',
54 '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."),
60 * This function adds a "Check Spelling" link to the "Compose" row
61 * during message composition.
64 function squirrelspell_setup() {
66 * Check if this browser is capable of displaying SquirrelSpell
69 if (checkForJavascript()) {
71 * Some people may choose to disable javascript even though their
72 * browser is capable of using it. So these freaks don't complain,
73 * use document.write() so the "Check Spelling" button is not
74 * displayed if js is off in the browser.
76 echo "<script type=\"text/javascript\">\n".
78 'document.write("<input type=\"button\" value=\"'.
80 '\" name=\"check_spelling\" onclick=\"window.open(\'../plugins/squirrelspell/sqspell_'.
81 'interface.php\', \'sqspell\', \'status=yes,width=550,height=370,'.
82 'resizable=yes\')\" />");' . "\n".
89 * Transparently upgrades user's dictionaries when message listing is loaded
90 * @since 1.5.1 (sqspell 0.5)
92 function squirrelspell_upgrade() {
93 // globalize configuration vars before loading config.
94 // Vars are not available to scripts if not globalized before loading config.
95 // FIXME: move configuration loading to loading_prefs hook.
96 global $SQSPELL_APP, $SQSPELL_APP_DEFAULT, $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
97 include_once(SM_PATH
. 'plugins/squirrelspell/sqspell_config.php');
98 include_once(SM_PATH
. 'plugins/squirrelspell/sqspell_functions.php');
100 if (! sqspell_check_version(0,5)) {
101 $langs=sqspell_getSettings_old(null);
102 $words=sqspell_getWords_old();
103 sqspell_saveSettings($langs);
104 foreach ($langs as $lang) {
105 $lang_words=sqspell_getLang_old($words,$lang);
106 $aLang_words=explode("\n",$lang_words);
108 foreach($aLang_words as $word) {
109 if (! preg_match("/^#/",$word) && trim($word)!='') {
113 sqspell_writeWords($new_words,$lang);
115 // bump up version number
116 setPref($data_dir,$username,'sqspell_version','0.5');
121 * Function that displays internal squirrelspell version
122 * @since 1.5.1 (sqspell 0.5)
123 * @return string plugin's version
124 * @todo remove 'cvs' part from version when plugin's code is
127 function squirrelspell_version() {