849bdf42 |
1 | <?php |
d112ed5a |
2 | /** |
3 | * setup.php |
4 | * ----------- |
5 | * Squirrelspell setup file, as defined by the SquirrelMail-1.2 API. |
91e0dccc |
6 | * |
9eb3fcb3 |
7 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
d112ed5a |
8 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
9 | * |
7996c920 |
10 | * @author Konstantin Riabitsev <icon@duke.edu> |
11 | * @version $Id$ |
ea5f4b8e |
12 | * @package plugins |
13 | * @subpackage squirrelspell |
d112ed5a |
14 | */ |
849bdf42 |
15 | |
7996c920 |
16 | /** @ignore */ |
17 | if (! defined('SM_PATH')) define('SM_PATH','../../'); |
18 | |
d112ed5a |
19 | /** |
598294a7 |
20 | * Standard SquirrelMail plugin initialization API. |
d112ed5a |
21 | * @return void |
22 | */ |
23 | function squirrelmail_plugin_init_squirrelspell() { |
7996c920 |
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'; |
d112ed5a |
33 | } |
849bdf42 |
34 | |
d112ed5a |
35 | /** |
36 | * This function formats and adds the plugin and its description to the |
37 | * Options screen. |
d112ed5a |
38 | * @return void |
39 | */ |
40 | function squirrelspell_optpage_register_block() { |
7996c920 |
41 | global $optpage_blocks; |
42 | /** |
43 | * Check if this browser is capable of using the plugin |
44 | */ |
45 | if (checkForJavascript()) { |
d112ed5a |
46 | /** |
7996c920 |
47 | * The browser checks out. |
48 | * Register Squirrelspell with the $optpage_blocks array. |
d112ed5a |
49 | */ |
7996c920 |
50 | $optpage_blocks[] = |
51 | 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."), |
55 | 'js' => TRUE); |
56 | } |
d112ed5a |
57 | } |
849bdf42 |
58 | |
d112ed5a |
59 | /** |
60 | * This function adds a "Check Spelling" link to the "Compose" row |
61 | * during message composition. |
d112ed5a |
62 | * @return void |
63 | */ |
64 | function squirrelspell_setup() { |
7996c920 |
65 | /** |
66 | * Check if this browser is capable of displaying SquirrelSpell |
67 | * correctly. |
68 | */ |
69 | if (checkForJavascript()) { |
d112ed5a |
70 | /** |
7996c920 |
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. |
d112ed5a |
75 | */ |
7996c920 |
76 | echo "<script type=\"text/javascript\">\n". |
77 | "<!--\n". |
78 | 'document.write("<input type=\"button\" value=\"'. |
79 | _("Check Spelling"). |
80 | '\" name=\"check_spelling\" onclick=\"window.open(\'../plugins/squirrelspell/sqspell_'. |
81 | 'interface.php\', \'sqspell\', \'status=yes,width=550,height=370,'. |
82 | 'resizable=yes\')\" />");' . "\n". |
83 | "//-->\n". |
84 | "</script>\n"; |
85 | } |
86 | } |
87 | |
88 | /** |
89 | * Transparently upgrades user's dictionaries when message listing is loaded |
90 | * @since 1.5.1 (sqspell 0.5) |
91 | */ |
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'); |
99 | |
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); |
107 | $new_words=array(); |
108 | foreach($aLang_words as $word) { |
109 | if (! preg_match("/^#/",$word) && trim($word)!='') { |
773d8dcd |
110 | $new_words[]=$word; |
7996c920 |
111 | } |
112 | } |
113 | sqspell_writeWords($new_words,$lang); |
04fa3c41 |
114 | } |
7996c920 |
115 | // bump up version number |
116 | setPref($data_dir,$username,'sqspell_version','0.5'); |
117 | } |
118 | } |
119 | |
120 | /** |
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 |
125 | * stable enough |
126 | */ |
127 | function squirrelspell_version() { |
128 | return '0.5cvs'; |
d112ed5a |
129 | } |
f8a1ed5a |
130 | ?> |