X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=plugins%2Ftranslate%2Fsetup.php;h=d7445bf43c272c05a2d9c74c92c758fb25f5eee6;hb=a4b225eeb8120e7102609f38039ee826d1cf5a49;hp=fcc010a9698cc87c5b6efd2035f081f6e36a6629;hpb=82d304a0501324b276cabab1870755d5352bd21c;p=squirrelmail.git diff --git a/plugins/translate/setup.php b/plugins/translate/setup.php index fcc010a9..d7445bf4 100644 --- a/plugins/translate/setup.php +++ b/plugins/translate/setup.php @@ -2,25 +2,31 @@ /** * setup.php * - * Copyright (c) 1999-2004 The SquirrelMail Project Team + * Easy plugin that sends the body of the message to a new browser + * window using the specified translator. + * + * Translation of composed messages is not supported. + * + * Copyright (c) 1999-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * $Id$ + * @version $Id$ * @package plugins * @subpackage translate */ -/* -Easy plugin that sends the body of the message to a new browser -window using the specified translator. - -Translation of composed messages is not supported. -*/ - +/** + * If SM_PATH isn't defined, define it. + * @ignore + */ +if (!defined('SM_PATH')) { + define('SM_PATH','../../'); +} /** * Initialize the translation plugin * @return void + * @access private */ function squirrelmail_plugin_init_translate() { global $squirrelmail_plugin_hooks; @@ -28,641 +34,64 @@ function squirrelmail_plugin_init_translate() { $squirrelmail_plugin_hooks['read_body_bottom']['translate'] = 'translate_read_form'; $squirrelmail_plugin_hooks['optpage_register_block']['translate'] = 'translate_optpage_register_block'; $squirrelmail_plugin_hooks['loading_prefs']['translate'] = 'translate_pref'; - $squirrelmail_plugin_hooks['compose_button_row']['translate'] = 'translate_button'; -} - - -/** - * Shows translation box in message display window - */ -function translate_read_form() { - global $color, $translate_server; - global $message, $translate_dir; - global $translate_show_read; - global $imapConnection, $wrap_at, $passed_id, $mailbox; - - if (!$translate_show_read) { - return; - } - - $translate_dir = 'to'; - -$trans_ar = $message->findDisplayEntity(array(), array('text/plain')); -$body = ''; -if ($trans_ar[0] != '') { - for ($i = 0; $i < count($trans_ar); $i++) { - $body .= formatBody($imapConnection, $message, $color, $wrap_at, $trans_ar[$i], $passed_id, $mailbox); - } - $hookResults = do_hook('message_body', $body); - $body = $hookResults[1]; - } else { - $body = 'Message can\'t be translated'; -} - - $new_body = $body; - $pos = strpos($new_body, - '">'. _("Download this as a file") . '
'); - if (is_int($pos)) { - $new_body = substr($new_body, 0, $pos); - } - - $trans = get_html_translation_table(HTML_ENTITIES); - $trans[' '] = ' '; - $trans = array_flip($trans); - $new_body = strtr($new_body, $trans); - - $new_body = urldecode($new_body); - $new_body = strip_tags($new_body); - - /* I really don't like this next part ... */ - $new_body = str_replace('"', "''", $new_body); - $new_body = strtr($new_body, "\n", ' '); - - $function = 'translate_form_' . $translate_server; - $function($new_body); + $squirrelmail_plugin_hooks['options_save']['translate'] = 'translate_save'; + $squirrelmail_plugin_hooks['optpage_set_loadinfo']['translate'] = 'translate_set_loadinfo'; + // $squirrelmail_plugin_hooks['compose_button_row']['translate'] = 'translate_button'; } /** - * Closes table tags in translation box + * Shows translation box in message display window + * @access private */ -function translate_table_end() { - ?> - - - - - - - _("Translation Options"), - 'url' => '../plugins/translate/options.php', - 'desc' => _("Which translator should be used when you get messages in a different language?"), - 'js' => false - ); -} - -/** - * Gets user's translation preferences - */ -function translate_pref() { - global $username, $data_dir; - global $translate_server, $translate_location; - global $translate_show_send, $translate_show_read; - global $translate_same_window; - - $translate_server = getPref($data_dir, $username, 'translate_server'); - if ($translate_server == '') { - $translate_server = 'babelfish'; - } - - $translate_location = getPref($data_dir, $username, 'translate_location'); - if ($translate_location == '') { - $translate_location = 'center'; - } - - $translate_show_send = getPref($data_dir, $username, 'translate_show_send'); - $translate_show_read = getPref($data_dir, $username, 'translate_show_read'); - $translate_same_window = getPref($data_dir, $username, 'translate_same_window'); + include_once(SM_PATH . 'plugins/translate/functions.php'); + translate_optpage_function(); } - /** - * Tries to select default translation combination - * - * @param string $test language code that has to be tested. - * @returm boolean true if language code matches user's language. - * - * This function could be speed up. - * It basically negates the process if a ! is found in the beginning and - * matches a * at the end with 0 or more characters. + * Calls user's translation preferences function + * @access private */ -function translate_does_it_match_language($test) { - global $squirrelmail_language; - $true = 1; - $false = 0; - $index = 0; - $smindex = 0; - - if (! $test || ! $squirrelmail_language) { - return $false; - } - - if ($test[$index] == '!') { - $index ++; - $true = 0; - $false = 1; - } - - if (($index == 0) && ($test == $squirrelmail_language)) { - return $true; - } - - while (isset($test[$index]) && $test[$index]) { - if ($test[$index] == '*') { - return $true; - } - if ($test[$index] != $squirrelmail_language[$smindex]) { - return $false; - } - $index ++; - $smindex ++; - } - - return $false; -} - -/** - * Creates language option selection box. - */ -function translate_lang_opt($from, $to, $value, $text) { - global $translate_dir; - - $ret = '