* @copyright 1999-2022 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');
/**
* Workaround for including function squirrelspell_version() in SM 1.5 CVS,
* where plugins' setup.php is not included by default.
*/
include_once(SM_PATH . 'plugins/squirrelspell/setup.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() {
global $data_dir, $username;
$sqspell_show_button = getPref($data_dir, $username, 'sqspell_show_button', 1);
/**
* Check if this browser is capable of displaying SquirrelSpell
* correctly.
*/
if ($sqspell_show_button && checkForJavascript()) {
global $oTemplate, $base_uri, $nbsp;
$output = addButton(_("Check Spelling"),
'check_spelling',
array('onclick' => 'window.open(\'' . $base_uri
. 'plugins/squirrelspell/sqspell_interface.php\', \'sqspell\', \'status=yes,width=550,height=370,resizable=yes\')')) . $nbsp;
return array('compose_button_row' => $output);
}
}
/**
* Upgrade dictionaries (internal function)
*
* 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 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 string $body The body of the message to display.
* @return void
*/
function sqspell_makePage($title, $scriptsrc, $body){
global $color;
if (! sqgetGlobalVar('MOD', $MOD, SQ_GET) ) {
$MOD = 'options_main';
}
displayPageHeader($color);
echo "
\n";
/**
* Check if we need to link in a script.
*/
if($scriptsrc) {
echo "\n";
}
echo html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' ) . "\n"
. html_tag( 'tr', "\n" .
html_tag( 'td', '' . $title .'', 'center', $color[9] )
) . "\n"
. html_tag( 'tr', "\n" .
html_tag( 'td', '