Index: admin_templates/regional/languages_edit.tpl =================================================================== --- admin_templates/regional/languages_edit.tpl (revision 14590) +++ admin_templates/regional/languages_edit.tpl (working copy) @@ -58,30 +58,30 @@
- - - - + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + - + @@ -105,6 +105,8 @@ + +
Index: admin_templates/regional/languages_list.tpl =================================================================== --- admin_templates/regional/languages_list.tpl (revision 14590) +++ admin_templates/regional/languages_list.tpl (working copy) @@ -6,56 +6,92 @@ -
- Index: install/english.lang =================================================================== --- install/english.lang (revision 14614) +++ install/english.lang (working copy) @@ -566,6 +566,7 @@ U3VibWlzc2lvbiBOb3RpZmljYXRpb24gRW1haWw= U3VnZ2VzdGVkIENvcnJlY3Rpb24= UG9pbnRzIHRvIFNlY3Rpb24= + U3luY2hyb25pemUgTGFuZ3VhZ2U= VGFibGUgTmFtZSBpbiBEYXRhYmFzZSA= VGFn SXRlbQ== @@ -771,6 +772,8 @@ U3RhdGU= U3ViLW1hdGNo U3VjY2Vzcw== + RnJvbSBvdGhlcnM= + VG8gb3RoZXJz U3lzdGVt VGFi VGVtcGxhdGU= Index: install/install_schema.sql =================================================================== --- install/install_schema.sql (revision 14614) +++ install/install_schema.sql (working copy) @@ -147,6 +147,7 @@ FilenameReplacements text, Locale varchar(10) NOT NULL DEFAULT 'en-US', UserDocsUrl varchar(255) NOT NULL DEFAULT '', + SynchronizationModes varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (LanguageId), KEY Enabled (Enabled), KEY PrimaryLang (PrimaryLang), Index: install/upgrades.sql =================================================================== --- install/upgrades.sql (revision 14614) +++ install/upgrades.sql (working copy) @@ -2129,3 +2129,5 @@ ALTER TABLE FormFields ADD UploadExtensions VARCHAR(255) NOT NULL DEFAULT '' AFTER Validation, ADD UploadMaxSize INT NULL AFTER UploadExtensions; + +ALTER TABLE Language ADD SynchronizationModes VARCHAR(255) NOT NULL DEFAULT ''; \ No newline at end of file Index: kernel/constants.php =================================================================== --- kernel/constants.php (revision 14628) +++ kernel/constants.php (working copy) @@ -161,4 +161,10 @@ class UserType { const USER = 0; const ADMIN = 1; + } + + class Language { + const SYNCHRONIZE_TO_OTHERS = 1; + const SYNCHRONIZE_FROM_OTHERS = 2; + const SYNCHRONIZE_DEFAULT = '|1|2|'; } \ No newline at end of file Index: units/helpers/language_import_helper.php =================================================================== --- units/helpers/language_import_helper.php (revision 14628) +++ units/helpers/language_import_helper.php (working copy) @@ -734,6 +734,7 @@ 'LocalName' => $language_node->Attributes['PACKNAME'], 'Encoding' => $language_node->Attributes['ENCODING'], 'Charset' => 'utf-8', + 'SynchronizationModes' => Language::SYNCHRONIZE_DEFAULT, ); if ($version > 1) { Index: units/languages/languages_config.php =================================================================== --- units/languages/languages_config.php (revision 14590) +++ units/languages/languages_config.php (working copy) @@ -180,8 +180,8 @@ 'options' => Array ('m/d/Y' => 'mm/dd/yyyy', 'd/m/Y' => 'dd/mm/yyyy', 'm.d.Y' => 'mm.dd.yyyy', 'd.m.Y' => 'dd.mm.yyyy'), 'not_null' => 1, 'required' => 1, 'default' => 'm/d/Y' ), - 'InputTimeFormat' => Array ( - 'type' => 'string', + 'InputTimeFormat' => Array ( + 'type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array ('g:i:s A' => 'g:i:s A', 'g:i A' => 'g:i A', 'H:i:s' => 'H:i:s', 'H:i' => 'H:i'), 'not_null' => '1', 'required' => 1, 'default' => 'g:i:s A', @@ -207,6 +207,11 @@ 'not_null' => 1, 'default' => 'en-US', ), 'UserDocsUrl' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), + 'SynchronizationModes' => Array ( + 'type' => 'string', 'max_len' => 255, + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_SynchronizeToOthers', 2 => 'la_opt_SynchronizeFromOthers'), 'use_phrases' => 1, 'multiple' => 1, + 'not_null' => 1, 'default' => '' + ), ), 'VirtualFields' => Array ( @@ -234,7 +239,8 @@ 'AdminInterfaceLang' => Array ('filter_block' => 'grid_options_filter', 'width' => 150, ), 'Charset' => Array ('filter_block' => 'grid_like_filter', 'width' => 100, ), 'Priority' => Array ('filter_block' => 'grid_like_filter', 'width' => 60, ), - 'Enabled' => Array ('filter_block' => 'grid_options_filter', 'width' => 60, ), + 'Enabled' => Array ('filter_block' => 'grid_options_filter', 'width' => 80, ), + 'SynchronizationModes' => Array ('filter_block' => 'grid_picker_filter', 'width' => 120, 'format' => ', ', 'hidden' => 1), ), ), Index: units/languages/languages_event_handler.php =================================================================== --- units/languages/languages_event_handler.php (revision 14628) +++ units/languages/languages_event_handler.php (working copy) @@ -317,7 +317,7 @@ // create multilingual columns for phrases & email events table first (actual for 6+ language) $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); /* @var $ml_helper kMultiLanguageHelper */ - + $ml_helper->createFields('phrases'); $ml_helper->createFields('emailevents'); @@ -365,6 +365,7 @@ $primary_lang_id = $this->Conn->GetOne($sql); $object->SetDBField('CopyFromLanguage', $primary_lang_id); + $object->SetDBField('SynchronizationModes', Language::SYNCHRONIZE_DEFAULT); } /** @@ -617,31 +618,46 @@ * Copy missing phrases across all system languages (starting from primary) * * @param kEvent $event + * @return void + * @access protected */ - function OnSynchronizeLanguages(&$event) + protected function OnSynchronizeLanguages(&$event) { - if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { $event->status = kEvent::erFAIL; return; } + $source_languages = $target_languages = Array (); + // get language list with primary language first - $sql = 'SELECT LanguageId + $sql = 'SELECT SynchronizationModes, LanguageId FROM ' . TABLE_PREFIX . 'Language + WHERE SynchronizationModes <> "" ORDER BY PrimaryLang DESC'; + $languages = $this->Conn->GetCol($sql, 'LanguageId'); - $source_langs = $this->Conn->GetCol($sql); - $target_langs = $source_langs; + foreach ($languages as $language_id => $synchronization_modes) { + $synchronization_modes = explode('|', substr($synchronization_modes, 1, -1)); - foreach ($source_langs as $source_id) { - foreach ($target_langs as $target_id) { - if ($source_id == $target_id) { + if ( in_array(Language::SYNCHRONIZE_TO_OTHERS, $synchronization_modes) ) { + $source_languages[] = $language_id; + } + + if ( in_array(Language::SYNCHRONIZE_FROM_OTHERS, $synchronization_modes) ) { + $target_languages[] = $language_id; + } + } + + foreach ($source_languages as $source_id) { + foreach ($target_languages as $target_id) { + if ( $source_id == $target_id ) { continue; } $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 = "")'; + WHERE COALESCE(l' . $target_id . '_Translation, "") = "" AND COALESCE(l' . $source_id . '_Translation, "") <> ""'; $this->Conn->Query($sql); } }