Index: branches/5.1.x/core/units/languages/languages_event_handler.php =================================================================== diff -u -r13140 -r13151 --- branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13140) +++ branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13151) @@ -1,6 +1,6 @@ Application->StoreVar($var_name, serialize($pending_actions)); - - if ($object->IsTempTable()) { - // 2. phrases import - $phrases_live = $this->Application->getUnitOption('phrases','TableName'); - $phrases_temp = $this->Application->GetTempName($phrases_live, 'prefix:phrases'); - - $sql = 'INSERT INTO ' . $phrases_temp . '(Phrase, PhraseKey, Translation, PhraseType, PhraseId, LanguageId, LastChanged, LastChangeIP, Module) - SELECT Phrase, PhraseKey, Translation, PhraseType, 0-PhraseId, ' . $dst_language . ', ' . adodb_mktime() . ', "", Module - FROM ' . $phrases_live . ' - WHERE LanguageId = ' . $src_language; - $this->Conn->Query($sql); - } - $object->SetDBField('CopyLabels', 0); } } @@ -234,14 +221,14 @@ // create multilingual columns for phrases & email events table first (actual for 6+ language) $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); -// $ml_helper->createFields('phrases'); + $ml_helper->createFields('phrases'); $ml_helper->createFields('emailevents'); foreach ($pending_actions as $src_language => $dst_language) { // phrases import - /*$sql = 'UPDATE ' . $this->Application->getUnitOption('phrases', 'TableName') . ' + $sql = 'UPDATE ' . $this->Application->getUnitOption('phrases', 'TableName') . ' SET l' . $dst_language . '_Translation = l' . $src_language . '_Translation'; - $this->Conn->Query($sql);*/ + $this->Conn->Query($sql); // events import $sql = 'UPDATE ' . $this->Application->getUnitOption('emailevents', 'TableName') . ' @@ -511,38 +498,11 @@ continue; } - $this->_addMissingPhrase($source_id, $target_id); + $sql = 'UPDATE ' . TABLE_PREFIX . 'Phrase + SET l' . $target_id . '_Translation = l' . $source_id . '_Translation + WHERE (l' . $target_id . '_Translation IS NULL) OR (l' . $target_id . '_Translation = "")'; + $this->Conn->Query($sql); } } } - - /** - * Copy missing phrases from $from_lang to $to_lang - * - * @param int $from_lang - * @param int $to_lang - */ - function _addMissingPhrase($from_lang, $to_lang) - { - $tmp_name = TABLE_PREFIX . 'PhraseCopy_' . $this->Application->GetSID(); - $q = 'CREATE TABLE ' . $tmp_name . ' - SELECT - source.Phrase, - source.PhraseKey, - source.Translation, - source.PhraseType, - NULL As PhraseId, - ' . $to_lang . ' AS LanguageId, - source.LastChanged, - source.LastChangeIP, - source.Module - FROM ' . TABLE_PREFIX . 'Phrase source - WHERE source.LanguageId = ' . $from_lang . ' - AND source.Phrase NOT IN (SELECT Phrase FROM ' . TABLE_PREFIX . 'Phrase target WHERE target.LanguageId = ' . $to_lang . ')'; - $this->Conn->Query($q); - - $this->Conn->Query('INSERT INTO ' . TABLE_PREFIX . 'Phrase SELECT * FROM ' . $tmp_name); - $this->Conn->Query('DROP TABLE ' . $tmp_name); - } - } \ No newline at end of file