Index: branches/5.1.x/core/units/helpers/language_import_helper.php =================================================================== diff -u -N -r13276 -r13453 --- branches/5.1.x/core/units/helpers/language_import_helper.php (.../language_import_helper.php) (revision 13276) +++ branches/5.1.x/core/units/helpers/language_import_helper.php (.../language_import_helper.php) (revision 13453) @@ -1,6 +1,6 @@ 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" . '' . "\n"; + if ($events) { + $ret .= "\t\t" . '' . "\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) : ''; + $ret .= sprintf($event_tpl, $event['MessageType'], $event['Event'], $event['Type'], $data); } - $data = $this->_exportEncoding == 'base64' ? base64_encode($template) : ''; - $ret .= sprintf($event_tpl, $event['MessageType'], $event['Event'], $event['Type'], $data); + $ret .= "\t\t" . '' . "\n"; } - $ret .= "\t\t" . '' . "\n"; + $ret .= "\t" . '' . "\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: branches/5.1.x/core/units/phrases/phrases_config.php =================================================================== diff -u -N -r13159 -r13453 --- branches/5.1.x/core/units/phrases/phrases_config.php (.../phrases_config.php) (revision 13159) +++ branches/5.1.x/core/units/phrases/phrases_config.php (.../phrases_config.php) (revision 13453) @@ -1,6 +1,6 @@ '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: branches/5.1.x/core/admin_templates/regional/languages_export.tpl =================================================================== diff -u -N -r12127 -r13453 --- branches/5.1.x/core/admin_templates/regional/languages_export.tpl (.../languages_export.tpl) (revision 12127) +++ branches/5.1.x/core/admin_templates/regional/languages_export.tpl (.../languages_export.tpl) (revision 13453) @@ -44,7 +44,79 @@ - + + + + + id="_" value="" onclick="update_checkbox_options(/^_([0-9A-Za-z-]+)/, '');"/> + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + +
+ + + + + + + +
+ + + + Index: branches/5.1.x/core/units/phrases/phrases_event_handler.php =================================================================== diff -u -N -r13151 -r13453 --- branches/5.1.x/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 13151) +++ branches/5.1.x/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 13453) @@ -1,6 +1,6 @@ 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); Index: branches/5.1.x/core/units/languages/languages_event_handler.php =================================================================== diff -u -N -r13403 -r13453 --- branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13403) +++ branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13453) @@ -1,6 +1,6 @@ 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( !getArrayValue($field_values,'LangFile') ) - { - $object->SetError('LangFile', 'required'); - $event->redirect = false; - return false; + if (!$object->Validate()) { + $event->status = erFAIL; + return ; } - 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 */ if ($object->GetDBField('DoNotEncode')) { $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: branches/5.1.x/core/units/phrases/phrase_tp.php =================================================================== diff -u -N -r13151 -r13453 --- branches/5.1.x/core/units/phrases/phrase_tp.php (.../phrase_tp.php) (revision 13151) +++ branches/5.1.x/core/units/phrases/phrase_tp.php (.../phrase_tp.php) (revision 13453) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/install/english.lang =================================================================== diff -u -N -r13390 -r13453 --- branches/5.1.x/core/install/english.lang (.../english.lang) (revision 13390) +++ branches/5.1.x/core/install/english.lang (.../english.lang) (revision 13453) @@ -33,6 +33,8 @@ U2F2ZSBDaGFuZ2Vz U2VjdGlvbiBQcm9wZXJ0aWVz U2VjdGlvbiBUZW1wbGF0ZQ== + U2VsZWN0IEFsbA== + VW5zZWxlY3Q= VXA= VXNl Q2FuY2Vs @@ -64,6 +66,7 @@ RWZmZWN0aXZl RW1haWw= RS1tYWlsIENvbW11bmljYXRpb24gUm9sZQ== + RW1haWwgRXZlbnRz UXVldWU= U2VudA== VG90YWw= @@ -140,6 +143,7 @@ QWNjZXNz Vmlldw== UGhyYXNl + UGhyYXNlcw== VHlwZQ== VXNlciBJRA== UHJlZml4 @@ -642,9 +646,11 @@ RXZlbnQ= RXhwaXJl RXhwb3J0IGNvbHVtbnM= + RXhwb3J0IFNwZWNpZmllZCBFbWFpbCBFdmVudHM= RXhwb3J0IEZpbGVuYW1l RXhwb3J0IGZvcm1hdA== RXhwb3J0IE1vZHVsZXM= + RXhwb3J0IFNwZWNpZmllZCBQaHJhc2Vz RXhwb3J0IFBocmFzZSBUeXBlcw== RXhwb3J0IFByZXNldCBUaXRsZQ== RXhwb3J0IFByZXNldA== @@ -859,6 +865,8 @@ SGlkZQ== QWxsIEZpbGVz Q1NWIEZpbGVz + U2luZ2xlIEVtYWlsIEV2ZW50IHBlciBsaW5lIChmb3JtYXRzO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