Index: admin_templates/regional/languages_export.tpl
===================================================================
--- admin_templates/regional/languages_export.tpl (revision 13268)
+++ admin_templates/regional/languages_export.tpl (working copy)
@@ -44,7 +44,79 @@
</inp2:m_if>
<inp2:m_RenderElement name="inp_edit_checkboxes" prefix="phrases.export" field="PhraseType" title="!la_fld_ExportPhraseTypes!"/>
- <inp2:m_RenderElement name="inp_edit_checkboxes" no_empty="no_empty" prefix="phrases.export" field="Module" title="!la_fld_ExportModules!"/>
+
+ <inp2:m_DefineElement name="export_module_element">
+ <tr>
+ <td>
+ <input type="checkbox" <inp2:m_param name='checked'/> id="<inp2:{$prefix}_InputName field='$field'/>_<inp2:m_param name='key'/>" value="<inp2:m_param name='key'/>" onclick="update_checkbox_options(/^<inp2:{$prefix}_InputName field='$field' as_preg='1'/>_([0-9A-Za-z-]+)/, '<inp2:{$prefix}_InputName field='$field'/>');"/>
+ </td>
+ <td>
+ <label for="<inp2:{$prefix}_InputName field='$field'/>_<inp2:m_param name='key'/>">
+ <inp2:m_param name="option"/>
+ </label>
+ </td>
+ <td align="right">
+ <inp2:$prefix_PhraseCount module="$key"/>
+ </td>
+ <td align="right">
+ <inp2:$prefix_EventCount module="$key"/>
+ </td>
+ </tr>
+ </inp2:m_DefineElement>
+
+ <inp2:m_if check="phrases.export_FieldVisible" field="PhraseType">
+ <tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
+ <inp2:m_RenderElement name="inp_edit_field_caption" prefix="phrases.export" field="Module" title="la_fld_ExportModules"/>
+ <td class="control-cell">
+ <input type="button" class="button" id="btn-select-all" value="<inp2:m_Phrase name='la_btn_SelectAll' no_editing='1'/>"/>
+ <input type="button" class="button" id="btn-unselect" value="<inp2:m_Phrase name='la_btn_Unselect' no_editing='1'/>"/>
+ <br/><br/>
+
+ <style type="text/css">
+ table#modules {
+ border-collapse: collapse;
+ }
+
+ table#modules td, table#modules th {
+ border: 1px solid black;
+ padding: 3px;
+ }
+ </style>
+
+ <table id="modules" border="1">
+ <tr>
+ <th align="center" colspan="2"><inp2:m_Phrase name="la_col_Module"/></th>
+ <th align="center"><inp2:m_Phrase name="la_col_Phrases"/></th>
+ <th align="center"><inp2:m_Phrase name="la_col_EmailEvents"/></th>
+ </tr>
+ <inp2:phrases.export_PredefinedOptions prefix="phrases.export" field="Module" block="export_module_element" no_empty="1" selected="checked"/>
+ </table>
+
+ <script type="text/javascript">
+ $(document).ready(
+ function () {
+ $('#btn-select-all, #btn-unselect').click(
+ function ($e) {
+ var $checked = $(this).attr('id') == 'btn-select-all' ? 'checked' : '';
+ var $reg_exp = /^<inp2:phrases.export_InputName field='Module' as_preg='1'/>_([0-9A-Za-z-]+)/;
+
+ $("input[type='checkbox']", '#modules').attr('checked', $checked);
+ update_checkbox_options($reg_exp, '<inp2:phrases.export_InputName field='Module'/>');
+ }
+ );
+ }
+ );
+ </script>
+
+ <inp2:m_RenderElement prefix="phrases.export" name="inp_edit_hidden" field="Module" db="db"/>
+ </td>
+ <inp2:m_RenderElement name="inp_edit_error" prefix="phrases.export" field="Module"/>
+ </tr>
+ </inp2:m_if>
+
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="phrases.export" field="ExportPhrases" title="!la_fld_ExportPhrases!" allow_html="0" hint_label="la_hint_ExportPhrases"/>
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="phrases.export" field="ExportEmailEvents" title="!la_fld_ExportEmailEvents!" allow_html="0" hint_label="la_hint_ExportEmailEvents"/>
+
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="phrases.export" field="DoNotEncode" title="!la_fld_DoNotEncode!"/>
<inp2:m_RenderElement name="inp_edit_filler"/>
</table>
Index: install/english.lang
===================================================================
--- install/english.lang (revision 13268)
+++ install/english.lang (working copy)
@@ -32,6 +32,8 @@
<PHRASE Label="la_btn_SaveChanges" Module="Core" Type="1">U2F2ZSBDaGFuZ2Vz</PHRASE>
<PHRASE Label="la_btn_SectionProperties" Module="Core" Type="1">U2VjdGlvbiBQcm9wZXJ0aWVz</PHRASE>
<PHRASE Label="la_btn_SectionTemplate" Module="Core" Type="1">U2VjdGlvbiBUZW1wbGF0ZQ==</PHRASE>
+ <PHRASE Label="la_btn_SelectAll" Module="Core" Type="1">U2VsZWN0IEFsbA==</PHRASE>
+ <PHRASE Label="la_btn_Unselect" Module="Core" Type="1">VW5zZWxlY3Q=</PHRASE>
<PHRASE Label="la_btn_Up" Module="Core" Type="1">VXA=</PHRASE>
<PHRASE Label="la_Cancel" Module="Core" Type="1">Q2FuY2Vs</PHRASE>
<PHRASE Label="la_category" Module="Core" Type="1">U2VjdGlvbg==</PHRASE>
@@ -61,6 +63,7 @@
<PHRASE Label="la_col_Duration" Module="Core" Type="1">RHVyYXRpb24=</PHRASE>
<PHRASE Label="la_col_Effective" Module="Core" Type="1">RWZmZWN0aXZl</PHRASE>
<PHRASE Label="la_col_Email" Module="Core" Type="1">RW1haWw=</PHRASE>
+ <PHRASE Label="la_col_EmailEvents" Module="Core" Type="1">RW1haWwgRXZlbnRz</PHRASE>
<PHRASE Label="la_col_EmailsQueued" Module="Core" Type="1">UXVldWU=</PHRASE>
<PHRASE Label="la_col_EmailsSent" Module="Core" Type="1">U2VudA==</PHRASE>
<PHRASE Label="la_col_EmailsTotal" Module="Core" Type="1">VG90YWw=</PHRASE>
@@ -133,6 +136,7 @@
<PHRASE Label="la_col_PermissionValue" Module="Core" Type="1">QWNjZXNz</PHRASE>
<PHRASE Label="la_col_PermView" Module="Core" Type="1">Vmlldw==</PHRASE>
<PHRASE Label="la_col_Phrase" Module="Core" Type="1">UGhyYXNl</PHRASE>
+ <PHRASE Label="la_col_Phrases" Module="Core" Type="1">UGhyYXNlcw==</PHRASE>
<PHRASE Label="la_col_PhraseType" Module="Core" Type="1">VHlwZQ==</PHRASE>
<PHRASE Label="la_col_PortalUserId" Module="Core" Type="1">VXNlciBJRA==</PHRASE>
<PHRASE Label="la_col_Prefix" Module="Core" Type="1">UHJlZml4</PHRASE>
@@ -616,9 +620,11 @@
<PHRASE Label="la_fld_Event" Module="Core" Type="1">RXZlbnQ=</PHRASE>
<PHRASE Label="la_fld_Expire" Module="Core" Type="1">RXhwaXJl</PHRASE>
<PHRASE Label="la_fld_ExportColumns" Module="Core" Type="1">RXhwb3J0IGNvbHVtbnM=</PHRASE>
+ <PHRASE Label="la_fld_ExportEmailEvents" Module="Core" Type="1">RXhwb3J0IFNwZWNpZmllZCBFbWFpbCBFdmVudHM=</PHRASE>
<PHRASE Label="la_fld_ExportFileName" Module="Core" Type="1">RXhwb3J0IEZpbGVuYW1l</PHRASE>
<PHRASE Label="la_fld_ExportFormat" Module="Core" Type="1">RXhwb3J0IGZvcm1hdA==</PHRASE>
<PHRASE Label="la_fld_ExportModules" Module="Core" Type="1">RXhwb3J0IE1vZHVsZXM=</PHRASE>
+ <PHRASE Label="la_fld_ExportPhrases" Module="Core" Type="1">RXhwb3J0IFNwZWNpZmllZCBQaHJhc2Vz</PHRASE>
<PHRASE Label="la_fld_ExportPhraseTypes" Module="Core" Type="1">RXhwb3J0IFBocmFzZSBUeXBlcw==</PHRASE>
<PHRASE Label="la_fld_ExportPresetName" Module="Core" Type="1">RXhwb3J0IFByZXNldCBUaXRsZQ==</PHRASE>
<PHRASE Label="la_fld_ExportPresets" Module="Core" Type="1">RXhwb3J0IFByZXNldA==</PHRASE>
@@ -814,6 +820,8 @@
<PHRASE Label="la_Hide" Module="Core" Type="1">SGlkZQ==</PHRASE>
<PHRASE Label="la_hint_AllFiles" Module="Core" Type="1">QWxsIEZpbGVz</PHRASE>
<PHRASE Label="la_hint_CSVFiles" Module="Core" Type="1">Q1NWIEZpbGVz</PHRASE>
+ <PHRASE Label="la_hint_ExportEmailEvents" Module="Core" Type="1">U2luZ2xlIEVtYWlsIEV2ZW50IHBlciBsaW5lIChmb3JtYXRzOiBVU0VSLkFERCwgT1JERVIuU1VCTUlUKQ==</PHRASE>
+ <PHRASE Label="la_hint_ExportPhrases" Module="Core" Type="1">U2luZ2xlIFBocmFzZSBMYWJlbCBwZXIgbGluZSAoZm9ybWF0czogbGFfU2FtcGxlTGFiZWwsIGx1X0Zyb250RW5kTGFiZWwp</PHRASE>
<PHRASE Label="la_hint_ImageFiles" Module="Core" Type="1">SW1hZ2UgRmlsZXM=</PHRASE>
<PHRASE Label="la_Hot" Module="Core" Type="1">SG90</PHRASE>
<PHRASE Label="la_Html" Module="Core" Type="1">SFRNTA==</PHRASE>
@@ -1641,6 +1649,11 @@
<PHRASE Label="lu_opt_Cookies" Module="Core" Type="1">Q29va2llcw==</PHRASE>
<PHRASE Label="lu_opt_QueryString" Module="Core" Type="1">UXVlcnkgU3RyaW5nIChTSUQp</PHRASE>
<PHRASE Label="lu_PermName_Admin_desc" Module="Core" Type="1">QWRtaW4gTG9naW4=</PHRASE>
+ <PHRASE Label="lu_PermName_Category.AddPending_desc" Module="Core" Type="2">QWRkIFBlbmRpbmcgQ2F0ZWdvcnk=</PHRASE>
+ <PHRASE Label="lu_PermName_Category.Add_desc" Module="Core" Type="2">QWRkIENhdGVnb3J5</PHRASE>
+ <PHRASE Label="lu_PermName_Category.Delete_desc" Module="Core" Type="2">RGVsZXRlIENhdGVnb3J5</PHRASE>
+ <PHRASE Label="lu_PermName_Category.Modify_desc" Module="Core" Type="2">TW9kaWZ5IENhdGVnb3J5</PHRASE>
+ <PHRASE Label="lu_PermName_Category.View_desc" Module="Core" Type="2">VmlldyBDYXRlZ29yeQ==</PHRASE>
<PHRASE Label="lu_PermName_Debug.Info_desc" Module="Core" Type="1">QXBwZW5kIHBocGluZm8gdG8gYWxsIHBhZ2VzIChEZWJ1Zyk=</PHRASE>
<PHRASE Label="lu_PermName_Debug.Item_desc" Module="Core" Type="1">RGlzcGxheSBJdGVtIFF1ZXJpZXMgKERlYnVnKQ==</PHRASE>
<PHRASE Label="lu_PermName_Debug.List_desc" Module="Core" Type="1">RGlzcGxheSBJdGVtIExpc3QgUXVlcmllcyAoRGVidWcp</PHRASE>
@@ -1648,11 +1661,6 @@
<PHRASE Label="lu_PermName_Login_desc" Module="Core" Type="1">QWxsb3cgTG9naW4=</PHRASE>
<PHRASE Label="lu_PermName_Profile.Modify_desc" Module="Core" Type="1">Q2hhbmdlIFVzZXIgUHJvZmlsZXM=</PHRASE>
<PHRASE Label="lu_PermName_ShowLang_desc" Module="Core" Type="1">U2hvdyBMYW5ndWFnZSBUYWdz</PHRASE>
- <PHRASE Label="lu_PermName_Category.AddPending_desc" Module="Core" Type="2">QWRkIFBlbmRpbmcgQ2F0ZWdvcnk=</PHRASE>
- <PHRASE Label="lu_PermName_Category.Add_desc" Module="Core" Type="2">QWRkIENhdGVnb3J5</PHRASE>
- <PHRASE Label="lu_PermName_Category.Delete_desc" Module="Core" Type="2">RGVsZXRlIENhdGVnb3J5</PHRASE>
- <PHRASE Label="lu_PermName_Category.Modify_desc" Module="Core" Type="2">TW9kaWZ5IENhdGVnb3J5</PHRASE>
- <PHRASE Label="lu_PermName_Category.View_desc" Module="Core" Type="2">VmlldyBDYXRlZ29yeQ==</PHRASE>
</PHRASES>
<EVENTS>
<EVENT MessageType="html" Event="CATEGORY.ADD" Type="0">U3ViamVjdDogTmV3IENhdGVnb3J5ICI8aW5wMjpjX0ZpZWxkIG5hbWU9Ik5hbWUiLz4iIC0gQWRkZWQKCllvdXIgc3VnZ2VzdGVkIGNhdGVnb3J5ICI8aW5wMjpjX0ZpZWxkIG5hbWU9Ik5hbWUiLz4iIGhhcyBiZWVuIGFkZGVkLg==</EVENT>
Index: units/helpers/language_import_helper.php
===================================================================
--- units/helpers/language_import_helper.php (revision 13276)
+++ units/helpers/language_import_helper.php (working copy)
@@ -90,6 +90,16 @@
var $_exportEncoding = 'base64';
/**
+ * Exported data limits (all or only specified ones)
+ *
+ * @var Array
+ */
+ var $_exportLimits = Array (
+ 'phrases' => false,
+ 'emailevents' => false,
+ );
+
+ /**
* Debug language pack import process
*
* @var bool
@@ -225,18 +235,36 @@
$phrase_modules = array_map(Array (&$this->Conn, 'qstr'), $phrase_modules);
+ // apply phrase selection limit
+ if ($this->_exportLimits['phrases']) {
+ $escaped_phrases = array_map(Array (&$this->Conn, 'qstr'), $this->_exportLimits['phrases']);
+ $limit_where = 'Phrase IN (' . implode(',', $escaped_phrases) . ')';
+ }
+ else {
+ $limit_where = 'TRUE';
+ }
+
$sql = 'SELECT *
FROM ' . $this->Application->getUnitOption('phrases','TableName') . '
- WHERE PhraseType IN (' . implode(',', $phrase_types) . ') AND Module IN (' . implode(',', $phrase_modules) . ')
+ WHERE PhraseType IN (' . implode(',', $phrase_types) . ') AND Module IN (' . implode(',', $phrase_modules) . ') AND ' . $limit_where . '
ORDER BY Phrase';
$phrases = $this->Conn->Query($sql, 'PhraseId');
// email events
$module_sql = preg_replace('/(.*),/U', 'INSTR(Module,\'\\1\') OR ', implode(',', $module_ids) . ',');
+ // apply event selection limit
+ if ($this->_exportLimits['emailevents']) {
+ $escaped_email_events = array_map(Array (&$this->Conn, 'qstr'), $this->_exportLimits['emailevents']);
+ $limit_where = '`Event` IN (' . implode(',', $escaped_email_events) . ')';
+ }
+ else {
+ $limit_where = 'TRUE';
+ }
+
$sql = 'SELECT *
FROM ' . $this->Application->getUnitOption('emailevents','TableName') . '
- WHERE ' . substr($module_sql, 0, -4) . '
+ WHERE ' . substr($module_sql, 0, -4) . ' AND ' . $limit_where . '
ORDER BY `Event`, `Type`';
$events = $this->Conn->Query($sql, 'EventId');
@@ -274,26 +302,30 @@
}
// email events
- $ret .= "\t\t" . '<EVENTS>' . "\n";
+ if ($events) {
+ $ret .= "\t\t" . '<EVENTS>' . "\n";
- foreach ($events as $event_id => $event) {
- $fields_hash = Array (
- 'Headers' => $event['Headers'],
- 'Subject' => $event['l' . $language_id . '_Subject'],
- 'Body' => $event['l' . $language_id . '_Body'],
- );
+ foreach ($events as $event_id => $event) {
+ $fields_hash = Array (
+ 'Headers' => $event['Headers'],
+ 'Subject' => $event['l' . $language_id . '_Subject'],
+ 'Body' => $event['l' . $language_id . '_Body'],
+ );
- $template = $email_message_helper->buildTemplate($fields_hash);
+ $template = $email_message_helper->buildTemplate($fields_hash);
- if (!$template) {
- // email event is not translated on given language
- continue;
+ if (!$template) {
+ // email event is not translated on given language
+ continue;
+ }
+
+ $data = $this->_exportEncoding == 'base64' ? base64_encode($template) : '<![CDATA[' . $template . ']]>';
+ $ret .= sprintf($event_tpl, $event['MessageType'], $event['Event'], $event['Type'], $data);
}
- $data = $this->_exportEncoding == 'base64' ? base64_encode($template) : '<![CDATA[' . $template . ']]>';
- $ret .= sprintf($event_tpl, $event['MessageType'], $event['Event'], $event['Type'], $data);
+ $ret .= "\t\t" . '</EVENTS>' . "\n";
}
- $ret .= "\t\t" . '</EVENTS>' . "\n";
+
$ret .= "\t" . '</LANGUAGE>' . "\n";
}
@@ -315,6 +347,29 @@
}
/**
+ * Sets language pack data limits for export
+ *
+ * @param mixed $phrases
+ * @param mixed $email_events
+ */
+ function setExportLimits($phrases, $email_events)
+ {
+ if (!is_array($phrases)) {
+ $phrases = str_replace(',', "\n", $phrases);
+ $phrases = preg_replace("/\n+/", "\n", str_replace("\r", '', trim($phrases)));
+ $phrases = $phrases ? array_map('trim', explode("\n", $phrases)) : Array ();
+ }
+
+ if (!is_array($email_events)) {
+ $email_events = str_replace(',', "\n", $email_events);
+ $email_events = preg_replace("/\n+/", "\n", str_replace("\r", '', trim($email_events)));
+ $email_events = $email_events ? array_map('trim', explode("\n", $email_events)) : Array ();
+ }
+
+ $this->_exportLimits = Array ('phrases' => $phrases, 'emailevents' => $email_events);
+ }
+
+ /**
* Performs upgrade of given language pack part
*
* @param int $language_id
Index: units/languages/languages_event_handler.php
===================================================================
--- units/languages/languages_event_handler.php (revision 13268)
+++ units/languages/languages_event_handler.php (working copy)
@@ -396,29 +396,32 @@
function OnExportProgress(&$event)
{
$items_info = $this->Application->GetVar('phrases_export');
- if($items_info)
- {
- list($id,$field_values) = each($items_info);
- $object =& $this->Application->recallObject('phrases.export', 'phrases', Array('skip_autoload' => true) );
+ if ($items_info) {
+ list($id, $field_values) = each($items_info);
+ $object =& $this->Application->recallObject('phrases.export', null, Array('skip_autoload' => true));
+ /* @var $object kDBItem */
+
+ $object->setID($id);
$object->SetFieldsFromHash($field_values);
- $lang_ids = explode(',', $this->Application->RecallVar('export_language_ids') );
+ if (!$object->Validate()) {
+ $event->status = erFAIL;
+ return ;
+ }
- if( !getArrayValue($field_values,'LangFile') )
- {
- $object->SetError('LangFile', 'required');
- $event->redirect = false;
- return false;
- }
- if( !is_writable(EXPORT_PATH) )
- {
+ if (!is_writable(EXPORT_PATH)) {
+ $event->status = erFAIL;
$object->SetError('LangFile', 'write_error', 'la_ExportFolderNotWritable');
- $event->redirect = false;
- return false;
+
+ return ;
}
- if( substr($field_values['LangFile'], -5) != '.lang' ) $field_values['LangFile'] .= '.lang';
- $filename = EXPORT_PATH.'/'.$field_values['LangFile'];
+ if ( substr($field_values['LangFile'], -5) != '.lang') {
+ $field_values['LangFile'] .= '.lang';
+ }
+
+ $filename = EXPORT_PATH . '/' . $field_values['LangFile'];
+
$language_import_helper =& $this->Application->recallObject('LanguageImportHelper');
/* @var $language_import_helper LanguageImportHelper */
@@ -426,6 +429,9 @@
$language_import_helper->setExportEncoding('plain');
}
+ $language_import_helper->setExportLimits($field_values['ExportPhrases'], $field_values['ExportEmailEvents']);
+
+ $lang_ids = explode(',', $this->Application->RecallVar('export_language_ids') );
$language_import_helper->performExport($filename, $field_values['PhraseType'], $lang_ids, $field_values['Module']);
}
Index: units/phrases/phrase_tp.php
===================================================================
--- units/phrases/phrase_tp.php (revision 13268)
+++ units/phrases/phrase_tp.php (working copy)
@@ -24,4 +24,36 @@
{
return $this->Application->GetVar('simple_mode') && (int)$this->Application->ConfigValue('UsePopups');
}
+
+ function PhraseCount($params)
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ $sql = 'SELECT COUNT(*), Module
+ FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
+ GROUP BY Module';
+ $cache = $this->Conn->GetCol($sql, 'Module');
+ }
+
+ $module = $params['module'];
+
+ return array_key_exists($module, $cache) ? $cache[$module] : 0;
+ }
+
+ function EventCount($params)
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ $sql = 'SELECT COUNT(*), IF(Module LIKE "Core:%", "Core", Module) AS Module
+ FROM ' . $this->Application->getUnitOption('emailevents', 'TableName') . '
+ GROUP BY Module';
+ $cache = $this->Conn->GetCol($sql, 'Module');
+ }
+
+ $module = $params['module'];
+
+ return array_key_exists($module, $cache) ? $cache[$module] : 0;
+ }
}
\ No newline at end of file
Index: units/phrases/phrases_config.php
===================================================================
--- units/phrases/phrases_config.php (revision 13268)
+++ units/phrases/phrases_config.php (working copy)
@@ -154,6 +154,8 @@
'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
'default' => 0
),
+ 'ExportPhrases' => Array ('type' => 'string', 'default' => ''),
+ 'ExportEmailEvents' => Array ('type' => 'string', 'default' => ''),
),
'Grids' => Array (
Index: units/phrases/phrases_event_handler.php
===================================================================
--- units/phrases/phrases_event_handler.php (revision 13268)
+++ units/phrases/phrases_event_handler.php (working copy)
@@ -28,13 +28,12 @@
function prepareObject(&$object, &$event)
{
// don't call parent
-
- if ($event->Special == 'import') {
+ if ($event->Special == 'import' || $event->Special == 'export') {
$object->setRequired('LangFile', true);
$object->setRequired('Phrase', false);
$object->setRequired('l' . $this->Application->GetVar('m_lang') . '_Translation', false);
- // allow multiple phrase types to be selected during import
+ // allow multiple phrase types to be selected during import/export
$field_options = $object->GetFieldOptions('PhraseType');
$field_options['type'] = 'string';
$object->SetFieldOptions('PhraseType', $field_options);