Index: branches/RC/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r11893 -r11913 --- branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 11893) +++ branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 11913) @@ -1,6 +1,6 @@ GetFormattedTotal($this->SelectParam($params, 'field,name'), $params['function']); } - function SetFCKDefaultLanguage() + /** + * Returns FCKEditor locale, that matches default site language + * + * @return string + */ + function _getFCKLanguage() { - $lang_id = $this->Application->GetDefaultLanguageId(); - $sql="SELECT Locale FROM ".TABLE_PREFIX."Language WHERE LanguageId = ".$lang_id; - $lang_prefix = strtolower($this->Conn->GetOne($sql)); - $lang_file=strtolower($this->Conn->GetOne($sql)).'.js'; - if (file_exists(FULL_PATH.EDITOR_PATH.'/editor/lang/'.$lang_file)) - { - return $lang_prefix; + static $language_code = null; + + if (!isset($language_code)) { + $language_code = 'en'; // defaut value + + $sql = 'SELECT Locale + FROM '. $this->Application->getUnitOption('lang', 'TableName') . ' + WHERE LanguageId = ' . $this->Application->GetDefaultLanguageId(); // $this->Application->GetVar('m_lang'); + $locale = strtolower( $this->Conn->GetOne($sql) ); + + if (file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale . '.js')) { + // found language file, that exactly matches locale name (e.g. "en") + $language_code = $locale; + } + else { + $locale = explode('-', $locale); + if (file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale[0] . '.js')) { + // language file matches first part of locale (e.g. "ru-RU") + $language_code = $locale[0]; + } + } } - $aLangPrefix = explode("-",$lang_prefix); - if (file_exists(FULL_PATH.EDITOR_PATH.'/editor/lang/'.$aLangPrefix[0].'.js')) - { - return $aLangPrefix[0]; - } - return 'en'; + + return $language_code; } @@ -2191,7 +2206,7 @@ $oFCKeditor->ToolbarSet = $page_id && $content_id ? 'Advanced' : 'Default'; $oFCKeditor->Value = $value; $oFCKeditor->PreviewUrl = $preview_url; - $oFCKeditor->DefaultLanguage = $this->SetFCKDefaultLanguage(); + $oFCKeditor->DefaultLanguage = $this->_getFCKLanguage(); $oFCKeditor->LateLoad = array_key_exists('late_load', $params) && $params['late_load']; $oFCKeditor->Config = Array ( //'UserFilesPath' => $pathtoroot.'kernel/user_files', @@ -2206,7 +2221,7 @@ 'newBgColor' => $bgcolor, 'PreviewUrl' => $preview_url, 'BaseUrl' => BASE_PATH . '/', - 'DefaultLanguage' => $this->SetFCKDefaultLanguage(), + 'DefaultLanguage' => $this->_getFCKLanguage(), 'EditorAreaStyles' => 'body { background-color: '.$bgcolor.' }', );