Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046589
D156.id462.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 28, 8:53 PM
Size
16 KB
Mime Type
text/x-diff
Expires
Sun, Jun 29, 8:53 PM (6 h, 1 m)
Engine
blob
Format
Raw Data
Handle
676606
Attached To
D156: INP-1505 - Restore e-mail template translation sync code removed during merge
D156.id462.diff
View Options
Index: branches/5.3.x/admin/system_presets/simple/email_templates_email-template.php
===================================================================
--- branches/5.3.x/admin/system_presets/simple/email_templates_email-template.php
+++ branches/5.3.x/admin/system_presets/simple/email_templates_email-template.php
@@ -18,7 +18,7 @@
'email_template_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'frontend_mail', 'view',*/ 'export', /*'dbl-click'*/),
// edit email template - general tab
-// 'email_template_edit' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
+ 'email_template_edit' => Array (/*'select',*/ 'setprimary', /*'cancel', 'reset_edit', 'prev', 'next'*/),
// edit email template - settings tab
// 'email_template_edit_settings' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
@@ -35,7 +35,7 @@
// virtual fields to hide
$virtual_hidden_fields = Array (
/*'RecipientType', 'RecipientName', 'RecipientAddressType',
- 'RecipientAddress', 'Tag', 'Replacement', 'ReplacementTagsXML',*/
+ 'RecipientAddress', 'Tag', 'Replacement', 'ReplacementTagsXML',*/ 'TranslationInSync', 'TranslateFromLanguage'
);
// fields to make required
@@ -52,6 +52,10 @@
'RecipientAddress', 'Tag', 'Replacement', 'ReplacementTagsXML',*/
);
+ $debug_only_virtual_fields = Array (
+ 'SourceSubject', 'SourceHtmlBody', 'SourcePlainTextBody',
+ );
+
// tabs during editing
$hide_edit_tabs = Array (
'Default' => Array (/*'general',*/ 'settings'),
@@ -60,5 +64,5 @@
// hide columns in grids
$hide_columns = Array (
// 'Default' => Array ('TemplateId', 'Description', 'TemplateName', 'Module', 'Type', 'Enabled', 'LastChanged'),
-// 'Emails' => Array ('TemplateId', 'TemplateName', 'Subject', 'Description', 'Type', 'Enabled', 'Module', 'FrontEndOnly', 'LastChanged'),
- );
\ No newline at end of file
+ 'Emails' => Array (/*'EventId', 'Event', 'Subject', 'Description', 'Type', 'Enabled', 'Module', 'FrontEndOnly', 'LastChanged',*/ 'TranslationInSync', 'TranslateFromLanguage'),
+ );
Index: branches/5.3.x/core/admin_templates/languages/email_template_edit.tpl
===================================================================
--- branches/5.3.x/core/admin_templates/languages/email_template_edit.tpl
+++ branches/5.3.x/core/admin_templates/languages/email_template_edit.tpl
@@ -11,10 +11,26 @@
<script type="text/javascript">
a_toolbar = new ToolBar();
a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ Application.SetVar('translation_save_mode', 1);
submit_event('email-template','<inp2:email-template_SaveEvent/>');
}
) );
+ <inp2:m_if check="lang_IsMultiLanguage">
+ a_toolbar.AddButton(
+ new ToolBarButton(
+ 'setprimary',
+ '<inp2:m_Phrase label="hint:la_ToolTip_SetPrimaryTranslation" escape="1"/>::<inp2:m_Phrase label="la_ToolTip_SetPrimaryTranslation" escape="1"/>',
+ function() {
+ Application.SetVar('translation_save_mode', 2);
+ submit_event('email-template','<inp2:email-template_SaveEvent/>');
+ }
+ )
+ );
+ </inp2:m_if>
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
cancel_edit('email-template','OnCancelEdit','<inp2:email-template_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
}
@@ -27,7 +43,7 @@
) );
<inp2:m_if check="email-template_IsSingle" inverse="inverse">
- a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+ a_toolbar.AddButton( new ToolBarSeparator('sep2') );
</inp2:m_if>
a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
@@ -53,6 +69,16 @@
<inp2:email-template_SaveWarning name="grid_save_warning"/>
<inp2:email-template_ErrorWarning name="form_error_warning"/>
+<inp2:m_DefineElement name="inp_primary_label">
+ <inp2:m_RenderElement design="form_row" pass_params="1">
+ <td class="control-cell" valign="top">
+ <div class="highlight-area" style="width: 735px; height: 234px;">
+ <inp2:{$prefix}_Field field="$field" nl2br="$nl2br"/>
+ </div>
+ </td>
+ </inp2:m_RenderElement>
+</inp2:m_DefineElement>
+
<div id="scroll_container">
<table class="edit-form">
<inp2:m_RenderElement name="subsection" prefix="email-template" fields="TemplateId,Description,Subject" title="la_section_General"/>
@@ -65,8 +91,16 @@
</inp2:m_if>
<inp2:m_RenderElement name="inp_label" prefix="email-template" field="Description" title="la_fld_Description"/>
+
+ <inp2:m_if check="email-template_ShowSourceLanguage">
+ <inp2:m_RenderElement name="inp_label" prefix="email-template" field="TranslationInSync"/>
+ </inp2:m_if>
+
<inp2:m_RenderElement name="inp_edit_box_ml" prefix="email-template" field="Subject" format="no_default" title="la_fld_Subject"/>
+ <inp2:m_if check="email-template_ShowSourceLanguage">
+ <inp2:m_RenderElement name="inp_label" prefix="email-template" field="SourceSubject" caption_render_as="source_language_field_caption_element"/>
+ </inp2:m_if>
<inp2:m_RenderElement name="subsection" prefix="email-template" fields="HtmlBody,PlainTextBody" title="la_section_Message"/>
<inp2:m_if check="m_IsDebugMode">
<inp2:m_RenderElement name="inp_edit_codemirror" prefix="email-template" field="HtmlBody" format="no_default" title="la_fld_HtmlVersion" language="text/html" allow_html="1" control_options="{min_height: 200}"/>
@@ -74,9 +108,17 @@
<inp2:m_RenderElement name="inp_edit_fck" prefix="email-template" field="HtmlBody" format="no_default" title="la_fld_HtmlVersion" rows="5" cols="60" control_options="{min_height: 200}"/>
</inp2:m_if>
+ <inp2:m_if check="email-template_ShowSourceLanguage">
+ <inp2:m_RenderElement name="inp_primary_label" prefix="email-template" field="SourceHtmlBody" caption_render_as="source_language_field_caption_element" nl2br="1"/>
+ </inp2:m_if>
+
<inp2:m_RenderElement name="inp_edit_textarea_ml" prefix="email-template" field="PlainTextBody" format="no_default" title="la_fld_TextVersion" control_options="{min_height: 200}"/>
+
+ <inp2:m_if check="email-template_ShowSourceLanguage">
+ <inp2:m_RenderElement name="inp_primary_label" prefix="email-template" field="SourcePlainTextBody" caption_render_as="source_language_field_caption_element" nl2br="1"/>
+ </inp2:m_if>
<inp2:m_RenderElement name="inp_edit_filler" control_options="{max_height: 8}"/>
</table>
</div>
-<inp2:m_include t="incs/footer"/>
\ No newline at end of file
+<inp2:m_include t="incs/footer"/>
Index: branches/5.3.x/core/units/email_templates/email_template_eh.php
===================================================================
--- branches/5.3.x/core/units/email_templates/email_template_eh.php
+++ branches/5.3.x/core/units/email_templates/email_template_eh.php
@@ -227,28 +227,49 @@
{
parent::OnAfterConfigRead($event);
- $options = Array ();
+ $config = $event->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
===================================================================
--- branches/5.3.x/core/units/email_templates/email_template_tp.php
+++ branches/5.3.x/core/units/email_templates/email_template_tp.php
@@ -99,4 +99,44 @@
$object->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/units/email_templates/email_templates_config.php
===================================================================
--- branches/5.3.x/core/units/email_templates/email_templates_config.php
+++ branches/5.3.x/core/units/email_templates/email_templates_config.php
@@ -51,7 +51,7 @@
'email_template_edit' => Array (
'prefixes' => Array ('email-template'),
'format' => '#email-template_status# - #email-template_titlefield# - !la_section_General!',
- 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
+ 'toolbar_buttons' => Array ('select', 'setprimary', 'cancel', 'reset_edit', 'prev', 'next'),
),
'email_template_edit_settings' => Array (
@@ -71,6 +71,8 @@
),
),
+ 'CheckSimulatniousEdit' => true,
+
'PermSection' => Array ('main' => 'in-portal:configemail'),
'Sections' => Array (
@@ -87,8 +89,24 @@
'TableName' => TABLE_PREFIX . 'EmailTemplates',
+ 'CalculatedFields' => Array (
+ '' => Array (
+ 'SourceSubject' => 'l%4$s_Subject',
+ 'SourceHtmlBody' => 'l%4$s_HtmlBody',
+ 'SourcePlainTextBody' => 'l%4$s_PlainTextBody',
+
+ 'CurrentSubject' => 'l%5$s_Subject',
+ 'CurrentHtmlBody' => 'l%5$s_HtmlBody',
+ 'CurrentPlainTextBody' => 'l%5$s_PlainTextBody',
+
+ 'TranslationInSync' => 'IF(l%5$s_TranslateFrom = 0, 1, 0)',
+ 'TranslateFromLanguage' => 'l%5$s_TranslateFrom',
+ ),
+ ),
+
'ListSQLs' => Array (
- '' => ' SELECT %1$s.* %2$s FROM %1$s',
+ '' => ' SELECT %1$s.* %2$s
+ FROM %1$s',
),
'ListSortings' => Array (
@@ -166,6 +184,12 @@
'default' => null
),
+ 'TranslateFrom' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kMultiLanguage', 'db_type' => 'int', 'index_type' => 'int',
+ 'not_null' => 1, 'default' => 0
+ ),
+
'Enabled' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
@@ -220,6 +244,25 @@
'Tag' => Array ('type' => 'string', 'default' => ''),
'Replacement' => Array ('type' => 'string', 'default' => ''),
'ReplacementTagsXML' => Array ('type' => 'string', 'default' => ''),
+
+ 'SourceSubject' => Array ('type' => 'string', 'default' => ''),
+ 'SourceHtmlBody' => Array ('type' => 'string', 'default' => ''),
+ 'SourcePlainTextBody' => Array ('type' => 'string', 'default' => ''),
+
+ 'CurrentSubject' => Array ('type' => 'string', 'default' => ''),
+ 'CurrentHtmlBody' => Array ('type' => 'string', 'default' => ''),
+ 'CurrentPlainTextBody' => Array ('type' => 'string', 'default' => ''),
+
+ 'TranslationInSync' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'default' => 0,
+ ),
+ 'TranslateFromLanguage' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Languages ORDER BY PackName', 'option_title_field' => 'PackName', 'option_key_field' => 'LanguageId',
+ 'default' => 0,
+ ),
),
'Grids' => Array (
@@ -251,14 +294,16 @@
'Fields' => Array (
'TemplateId' => Array ('title' => 'column:la_fld_Id', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
'TemplateName' => Array ('filter_block' => 'grid_like_combo_filter', 'width' => 250, ),
- 'Subject' => Array ('filter_block' => 'grid_like_filter', 'no_special' => 0, 'width' => 300, ),
+ 'CurrentSubject' => Array ('title' => 'column:la_fld_Subject', 'filter_block' => 'grid_like_filter', 'no_special' => 0, 'width' => 300, ),
'Description' => Array ('filter_block' => 'grid_like_filter', 'width' => 250, ),
'Type' => Array ('filter_block' => 'grid_options_filter', 'width' => 60, ),
'Enabled' => Array ('filter_block' => 'grid_options_filter', 'width' => 70, ),
'Module' => Array ('filter_block' => 'grid_multioptions_filter', 'width' => 100, ),
'FrontEndOnly' => Array ('filter_block' => 'grid_options_filter', 'width' => 120, 'hidden' => 1),
'LastChanged' => Array ('title' => 'column:la_fld_Modified', 'filter_block' => 'grid_date_range_filter', 'width' => 150),
+ 'TranslationInSync' => Array ('filter_block' => 'grid_options_filter', 'width' => 100, 'hidden' => 1),
+ 'TranslateFromLanguage' => Array ('filter_block' => 'grid_multioptions_filter', 'width' => 100, 'hidden' => 1),
),
),
),
- );
\ No newline at end of file
+ );
Event Timeline
Log In to Comment