Index: branches/5.3.x/core/units/email_templates/email_template_eh.php =================================================================== diff -u -N -r15988 -r16323 --- branches/5.3.x/core/units/email_templates/email_template_eh.php (.../email_template_eh.php) (revision 15988) +++ branches/5.3.x/core/units/email_templates/email_template_eh.php (.../email_template_eh.php) (revision 16323) @@ -1,6 +1,6 @@ getUnitConfig(); - foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - if ( $module_name == 'In-Portal' ) { - continue; - } + $fields = $config->getFields(); + $fields['Module']['options'] = $this->_getModules(); - $options[$module_name] = $module_name; + if ( $this->Application->findModule('Name', 'Custom') ) { + $fields['Module']['default'] = 'Custom'; } - $config = $event->getUnitConfig(); - - $fields = $config->getFields(); - $fields['Module']['options'] = $options; $config->setFields($fields); + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + $ml_helper->replaceMLCalculatedFields($event); + if ( $this->Application->GetVar('regional') ) { $config->setPopulateMlFields(true); } } /** + * Returns modules, where e-mail event can be added to + * + * @return Array + * @access protected + */ + protected function _getModules() + { + $ret = Array (); + + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { + if ( $module_name == 'In-Portal' ) { + continue; + } + + $ret[$module_name] = $module_name; + } + + return $ret; + } + + /** * Prepare temp tables and populate it * with items selected in the grid * @@ -303,6 +324,16 @@ $object->SetDBField('ReplacementTagsXML', $xml); $this->setRequired($event); + + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + $translation_fields = $this->getTranslationFields(); + $source_language = $ml_helper->getSourceLanguage($object->GetDBField('TranslateFromLanguage')); + + foreach ($translation_fields as $translation_field) { + $object->SetDBField('Source' . $translation_field, $object->GetDBField('l' . $source_language . '_' . $translation_field)); + } } /** @@ -386,8 +417,8 @@ */ function translationChanged($object) { + $translation_fields = $this->getTranslationFields(); $changed_fields = array_keys($object->GetChangedFields()); - $translation_fields = Array ('Subject', 'HtmlBody', 'PlainTextBody'); foreach ($changed_fields as $changed_field) { $changed_field = preg_replace('/^l[\d]+_/', '', $changed_field); @@ -401,6 +432,17 @@ } /** + * Returns fields, that can be translated + * + * @return Array + * @access protected + */ + protected function getTranslationFields() + { + return Array ('Subject', 'HtmlBody', 'PlainTextBody'); + } + + /** * Don't allow to enable/disable events in non-debug mode * * @param kEvent $event @@ -678,4 +720,22 @@ $this->clearSelectedIDs($event); } - } \ No newline at end of file + + /** + * Updates translation state for all saved phrases + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnBeforeCopyToLive(kEvent $event) + { + parent::OnBeforeCopyToLive($event); + + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + $ml_helper->updateTranslationState($event); + } + + } Index: branches/5.3.x/core/units/email_templates/email_template_tp.php =================================================================== diff -u -N -r15698 -r16323 --- branches/5.3.x/core/units/email_templates/email_template_tp.php (.../email_template_tp.php) (revision 15698) +++ branches/5.3.x/core/units/email_templates/email_template_tp.php (.../email_template_tp.php) (revision 16323) @@ -1,6 +1,6 @@ SetFieldOptions('RecipientType', $field_options); } - } \ No newline at end of file + /** + * Determine if primary translation should be shown + * + * @param Array $params + * @return string + * @access protected + */ + protected function ShowSourceLanguage($params) + { + if ( $this->IsNewItem($params) ) { + return false; + } + + $object = $this->getObject($params); + /* @var $object kDBItem */ + + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + return !$ml_helper->editingInSourceLanguage($object->GetDBField('TranslateFromLanguage')); + } + + /** + * Shows field label with %s replaced with source translation language + * + * @param Array $params + * @return string + * @access protected + */ + protected function SourceLanguageTitle($params) + { + $object = $this->getObject($params); + /* @var $object kDBItem */ + + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + return $ml_helper->replaceSourceLanguage($object, $params['label']); + } + + } Index: branches/5.3.x/core/admin_templates/languages/email_template_edit.tpl =================================================================== diff -u -N -r15690 -r16323 --- branches/5.3.x/core/admin_templates/languages/email_template_edit.tpl (.../email_template_edit.tpl) (revision 15690) +++ branches/5.3.x/core/admin_templates/languages/email_template_edit.tpl (.../email_template_edit.tpl) (revision 16323) @@ -11,10 +11,26 @@