thomascube
2008-08-18 326f3d91309c49dc7c6e995fafa478e455d03333
Set defaults for 'spellcheck_languages' and make sure the user language is set correctly

1 files modified
25 ■■■■■ changed files
program/steps/mail/compose.inc 25 ●●●●● patch | view | raw | blame | history
program/steps/mail/compose.inc
@@ -376,8 +376,8 @@
      $body = rcmail_create_draft_body($body, $isHtml);
  }
  $tinylang = substr($_SESSION['language'], 0, 2);
  if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js'))
  $lang = $tinylang = strtolower(substr($_SESSION['language'], 0, 2));
  if (!file_exists(INSTALL_PATH . 'program/js/tiny_mce/langs/'.$tinylang.'.js'))
    $tinylang = 'en'; 
  $OUTPUT->include_script('tiny_mce/tiny_mce.js');
@@ -403,11 +403,13 @@
  // include GoogieSpell
  if (!empty($CONFIG['enable_spellcheck'])) {
    $googie_lang_set = $editor_lang_set = '';
    if (!empty($CONFIG['spellcheck_languages']) && is_array($CONFIG['spellcheck_languages'])) {
      $googie_lang_set = "googie.setLanguages(".json_serialize($CONFIG['spellcheck_languages']).");\n";
      foreach ($CONFIG['spellcheck_languages'] as $key => $name)
        $editor_lang_set .= ($editor_lang_set ? ',' : '') . ($key == $tinylang ? '+' : '') . JQ($name).'='.JQ($key);
    $spellcheck_langs = (array)$RCMAIL->config->get('spellcheck_languages', array('da'=>'Dansk', 'de'=>'Deutsch', 'en' => 'English', 'es'=>'Español', 'fr'=>'Français', 'it'=>'Italiano', 'nl'=>'Nederlands', 'pl'=>'Polski', 'pt'=>'Português', 'fi'=>'Suomi', 'sv'=>'Svenska'));
    if (!$spellcheck_langs[$lang])
      $lang = 'en';
    $editor_lang_set = array();
    foreach ($spellcheck_langs as $key => $name) {
      $editor_lang_set[] = ($key == $lang ? '+' : '') . JQ($name).'='.JQ($key);
    }
    
    $OUTPUT->include_script('googiespell.js');
@@ -417,7 +419,8 @@
      "googie.lang_rsm_edt = \"%s\";\n".
      "googie.lang_close = \"%s\";\n".
      "googie.lang_revert = \"%s\";\n".
      "googie.lang_no_error_found = \"%s\";\n%s".
      "googie.lang_no_error_found = \"%s\";\n".
      "googie.setLanguages(%s);\n".
      "googie.setCurrentLanguage('%s');\n".
      "googie.decorateTextarea('%s');\n".
      "%s.set_env('spellcheck', googie);",
@@ -427,13 +430,13 @@
      JQ(Q(rcube_label('close'))),
      JQ(Q(rcube_label('revertto'))),
      JQ(Q(rcube_label('nospellerrors'))),
      $googie_lang_set,
      substr($_SESSION['language'], 0, 2),
      json_serialize($spellcheck_langs),
      $lang,
      $attrib['id'],
      JS_OBJECT_NAME), 'foot');
    rcube_add_label('checking');
    $OUTPUT->set_env('spellcheck_langs', $editor_lang_set);
    $OUTPUT->set_env('spellcheck_langs', join(',', $editor_lang_set));
  }
 
  $out .= "\n".'<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;border:none;visibility:hidden;"></iframe>';