X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Fsquirrelspell%2Fsqspell_functions.php;h=9489dc6697e7ffb2661e482ead7c0649464fa639;hp=a3acfeb0400f681f74845a22681d64f403ae4b77;hb=202bcbcc2b67c7c153db1b09b608b62beeba0496;hpb=8a9f9d0964e91d21ffd490b105a011687d8c729f
diff --git a/plugins/squirrelspell/sqspell_functions.php b/plugins/squirrelspell/sqspell_functions.php
index a3acfeb0..9489dc66 100644
--- a/plugins/squirrelspell/sqspell_functions.php
+++ b/plugins/squirrelspell/sqspell_functions.php
@@ -1,49 +1,135 @@
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage squirrelspell
+ */
+
+/** globalize configuration vars **/
+global $SQSPELL_APP, $SQSPELL_APP_DEFAULT, $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
+
+/**
+ * load plugin configuration
+ * @todo allow storing configuration file in config/ directory
+ */
+include_once(SM_PATH . 'plugins/squirrelspell/sqspell_config.php');
+
+/** Hooked functions **/
+
+/**
+ * Register option page block (internal function)
+ * @since 1.5.1 (sqspell 0.5)
+ * @return void
+ */
+function squirrelspell_optpage_block_function() {
+ global $optpage_blocks;
+
+ /**
+ * Dependency on JavaScript is checked by SquirrelMail scripts
+ * Register Squirrelspell with the $optpage_blocks array.
+ */
+ $optpage_blocks[] =
+ array(
+ 'name' => _("SpellChecker Options"),
+ 'url' => '../plugins/squirrelspell/sqspell_options.php',
+ '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."),
+ 'js' => TRUE);
+}
+
+/**
+ * This function adds a "Check Spelling" link to the "Compose" row
+ * during message composition (internal function).
+ * @since 1.5.1 (sqspell 0.5)
+ * @return void
+ */
+function squirrelspell_setup_function() {
+ /**
+ * Check if this browser is capable of displaying SquirrelSpell
+ * correctly.
+ */
+ 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 "\n";
+ }
+}
+
+/**
+ * Upgrade dictionaries (internal function)
*
- * @author Konstantin Riabitsev ($Author$)
- * @version $Date$
+ * Transparently upgrades user's dictionaries when message listing is loaded
+ * @since 1.5.1 (sqspell 0.5)
*/
+function squirrelspell_upgrade_function() {
+ global $data_dir, $username;
+
+ 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);
+ }
+ // bump up version number
+ setPref($data_dir,$username,'sqspell_version','0.5');
+ }
+}
+
+/** Internal functions **/
/**
* This function is the GUI wrapper for the options page. SquirrelSpell
* uses it for creating all Options pages.
*
- * @param $title The title of the page to display
- * @param $scriptsrc This is used to link a file.js into the
+ * @param string $title The title of the page to display
+ * @param string $scriptsrc This is used to link a file.js into the
* format. This
* allows to separate javascript from the rest of the
* plugin and place it into the js/ directory.
- * @param $body The body of the message to display.
+ * @param string $body The body of the message to display.
* @return void
*/
function sqspell_makePage($title, $scriptsrc, $body){
global $color, $SQSPELL_VERSION;
- if ( (float)substr(PHP_VERSION,0,3) < 4.1 ) {
- global $_GET;
- }
- if (isset($_GET['MOD'])) {
- $MOD = $_GET['MOD'];
- }
- else {
+ if (! sqgetGlobalVar('MOD', $MOD, SQ_GET) ) {
$MOD = 'options_main';
}
- displayPageHeader($color, 'None');
- echo "
\n";
+ displayPageHeader($color, 'None');
+ echo "
\n";
/**
* Check if we need to link in a script.
*/
- if($scriptsrc) {
+ if($scriptsrc) {
echo "\n";
}
echo html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' ) . "\n"
@@ -51,7 +137,7 @@ function sqspell_makePage($title, $scriptsrc, $body){
html_tag( 'td', '' . $title .'', 'center', $color[9] )
) . "\n"
. html_tag( 'tr', "\n" .
- html_tag( 'td', '
', 'left' )
+ html_tag( 'td', '
', 'left' )
) . "\n"
. html_tag( 'tr', "\n" .
html_tag( 'td', $body, 'left' )
@@ -60,9 +146,9 @@ function sqspell_makePage($title, $scriptsrc, $body){
* Generate a nice "Return to Options" link, unless this is the
* starting page.
*/
- if ($MOD != "options_main"){
+ if ($MOD != "options_main"){
echo html_tag( 'tr', "\n" .
- html_tag( 'td', '
', 'left' )
+ html_tag( 'td', '
', 'left' )
) . "\n"
. html_tag( 'tr', "\n" .
html_tag( 'td', ''
@@ -75,11 +161,12 @@ function sqspell_makePage($title, $scriptsrc, $body){
* Close the table and display the version.
*/
echo html_tag( 'tr', "\n" .
- html_tag( 'td', '
', 'left' )
+ html_tag( 'td', '
', 'left' )
) . "\n"
. html_tag( 'tr',
- html_tag( 'td', 'SquirrelSpell ' . $SQSPELL_VERSION, 'center', $color[9] )
- ) . "\n";
+ html_tag( 'td', 'SquirrelSpell ' . squirrelspell_version(), 'center', $color[9] )
+ ) . "\n\n";
+ echo '