X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Ftranslate%2Fsetup.php;h=60ca8e1559b26551b13802cb0c72c6ad38b5c766;hp=7ba5dd8dda9f85a8e3cc3077b325ef93ec2020f3;hb=75b7d0427336801badc83fecdd4b25da55c6bb81;hpb=6fd953618853477f6ffe569ce3c9733ca9f9c2d0 diff --git a/plugins/translate/setup.php b/plugins/translate/setup.php index 7ba5dd8d..60ca8e15 100644 --- a/plugins/translate/setup.php +++ b/plugins/translate/setup.php @@ -1,22 +1,20 @@ 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 - * @access private - */ -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'); -} - - -/** - * Tries to select default translation combination - * - * 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. - * - * @param string $test language code that has to be tested. - * @return boolean true if language code matches user's language. - * @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. - * - * @access private - */ -function translate_lang_opt($from, $to, $value, $text) { - global $translate_dir; - - $ret = '