Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/language_import_helper.php
Show First 20 Lines • Show All 801 Lines • ▼ Show 20 Line(s) | |||||
$fields_hash[$export_field] = (string)$language_node[$export_field]; | $fields_hash[$export_field] = (string)$language_node[$export_field]; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$container_nodes = Array ('PHRASES', 'EVENTS', 'COUNTRIES'); | $container_nodes = Array ('PHRASES', 'EVENTS', 'COUNTRIES'); | ||||
foreach ($language_node as $sub_node) { | foreach ($language_node as $sub_node) { | ||||
/* @var $sub_node SimpleXMLElement */ | /** @var SimpleXMLElement $sub_node */ | ||||
if ( in_array($sub_node->getName(), $container_nodes) ) { | if ( in_array($sub_node->getName(), $container_nodes) ) { | ||||
continue; | continue; | ||||
} | } | ||||
switch ($sub_node->getName()) { | switch ($sub_node->getName()) { | ||||
case 'REPLACEMENTS': | case 'REPLACEMENTS': | ||||
// added since v2 | // added since v2 | ||||
Show All 19 Lines | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
$this->_processLanguage($fields_hash); | $this->_processLanguage($fields_hash); | ||||
} | } | ||||
if ( !defined('IS_INSTALL') || !IS_INSTALL ) { | if ( !defined('IS_INSTALL') || !IS_INSTALL ) { | ||||
/** @var kMultiLanguageHelper $ml_helper */ | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | ||||
/* @var $ml_helper kMultiLanguageHelper */ | |||||
// create ML columns for new languages | // create ML columns for new languages | ||||
$ml_helper->resetState(); | $ml_helper->resetState(); | ||||
$ml_helper->massCreateFields(); | $ml_helper->massCreateFields(); | ||||
} | } | ||||
// create temp tables after new language columns were added | // create temp tables after new language columns were added | ||||
$this->_initImportTables(); | $this->_initImportTables(); | ||||
} | } | ||||
/** | /** | ||||
* Processes parsed XML | * Processes parsed XML | ||||
* | * | ||||
* @param SimpleXMLElement $languages | * @param SimpleXMLElement $languages | ||||
*/ | */ | ||||
function _processLanguageData($languages) | function _processLanguageData($languages) | ||||
{ | { | ||||
foreach ($languages as $language_node) { | foreach ($languages as $language_node) { | ||||
$encoding = (string)$language_node['Encoding']; | $encoding = (string)$language_node['Encoding']; | ||||
$language_id = $this->_languages[kUtil::crc32((string)$language_node['PackName'])]; | $language_id = $this->_languages[kUtil::crc32((string)$language_node['PackName'])]; | ||||
$container_nodes = Array ('PHRASES', 'EVENTS', 'COUNTRIES'); | $container_nodes = Array ('PHRASES', 'EVENTS', 'COUNTRIES'); | ||||
foreach ($language_node as $sub_node) { | foreach ($language_node as $sub_node) { | ||||
/* @var $sub_node SimpleXMLElement */ | /** @var SimpleXMLElement $sub_node */ | ||||
if ( !in_array($sub_node->getName(), $container_nodes) || !count($sub_node->children()) ) { | if ( !in_array($sub_node->getName(), $container_nodes) || !count($sub_node->children()) ) { | ||||
// PHP 5.3 version would be: !$sub_node->count() | // PHP 5.3 version would be: !$sub_node->count() | ||||
continue; | continue; | ||||
} | } | ||||
switch ($sub_node->getName()) { | switch ($sub_node->getName()) { | ||||
case 'PHRASES': | case 'PHRASES': | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
static $other_translations = Array (); | static $other_translations = Array (); | ||||
if ( $this->Application->isDebugMode() ) { | if ( $this->Application->isDebugMode() ) { | ||||
$this->Application->Debugger->profileStart('L[' . $language_id . ']P', 'Language: ' . $language_id . '; Phrases Import'); | $this->Application->Debugger->profileStart('L[' . $language_id . ']P', 'Language: ' . $language_id . '; Phrases Import'); | ||||
} | } | ||||
foreach ($phrases as $phrase_node) { | foreach ($phrases as $phrase_node) { | ||||
/* @var $phrase_node SimpleXMLElement */ | /** @var SimpleXMLElement $phrase_node */ | ||||
$phrase_key = mb_strtoupper($phrase_node['Label']); | $phrase_key = mb_strtoupper($phrase_node['Label']); | ||||
$fields_hash = Array ( | $fields_hash = Array ( | ||||
'Phrase' => (string)$phrase_node['Label'], | 'Phrase' => (string)$phrase_node['Label'], | ||||
'PhraseKey' => $phrase_key, | 'PhraseKey' => $phrase_key, | ||||
'PhraseType' => (int)$phrase_node['Type'], | 'PhraseType' => (int)$phrase_node['Type'], | ||||
'Module' => (string)$phrase_node['Module'] ? (string)$phrase_node['Module'] : 'Core', | 'Module' => (string)$phrase_node['Module'] ? (string)$phrase_node['Module'] : 'Core', | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
function _processEvents($events, $language_id, $language_encoding) | function _processEvents($events, $language_id, $language_encoding) | ||||
{ | { | ||||
static $other_translations = Array (); | static $other_translations = Array (); | ||||
if ( $this->Application->isDebugMode() ) { | if ( $this->Application->isDebugMode() ) { | ||||
$this->Application->Debugger->profileStart('L[' . $language_id . ']E', 'Language: ' . $language_id . '; Events Import'); | $this->Application->Debugger->profileStart('L[' . $language_id . ']E', 'Language: ' . $language_id . '; Events Import'); | ||||
} | } | ||||
/** @var kEmailTemplateHelper $email_template_helper */ | |||||
$email_template_helper = $this->Application->recallObject('kEmailTemplateHelper'); | $email_template_helper = $this->Application->recallObject('kEmailTemplateHelper'); | ||||
/* @var $email_template_helper kEmailTemplateHelper */ | |||||
foreach ($events as $event_node) { | foreach ($events as $event_node) { | ||||
/* @var $event_node SimpleXMLElement */ | /** @var SimpleXMLElement $event_node */ | ||||
$message_type = (string)$event_node['MessageType']; | $message_type = (string)$event_node['MessageType']; | ||||
$email_template_id = $this->_getEmailTemplateId((string)$event_node['Event'], (int)$event_node['Type']); | $email_template_id = $this->_getEmailTemplateId((string)$event_node['Event'], (int)$event_node['Type']); | ||||
if ( !$email_template_id ) { | if ( !$email_template_id ) { | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
* @param bool $process_states | * @param bool $process_states | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
function _processCountries($country_states, $language_id, $language_encoding, $process_states = false) | function _processCountries($country_states, $language_id, $language_encoding, $process_states = false) | ||||
{ | { | ||||
static $other_translations = Array (); | static $other_translations = Array (); | ||||
foreach ($country_states as $country_state_node) { | foreach ($country_states as $country_state_node) { | ||||
/* @var $country_state_node SimpleXMLElement */ | /** @var SimpleXMLElement $country_state_node */ | ||||
if ( $process_states ) { | if ( $process_states ) { | ||||
$country_state_id = $this->_getStateId((string)$country_states['Iso'], (string)$country_state_node['Iso']); | $country_state_id = $this->_getStateId((string)$country_states['Iso'], (string)$country_state_node['Iso']); | ||||
} | } | ||||
else { | else { | ||||
$country_state_id = $this->_getCountryId((string)$country_state_node['Iso']); | $country_state_id = $this->_getCountryId((string)$country_state_node['Iso']); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$tag_params = Array ( | $tag_params = Array ( | ||||
'grid' => $prefix == 'phrases' ? 'Phrases' : 'Emails', | 'grid' => $prefix == 'phrases' ? 'Phrases' : 'Emails', | ||||
'skip_counting' => 1, | 'skip_counting' => 1, | ||||
'per_page' => -1 | 'per_page' => -1 | ||||
); | ); | ||||
/** @var kDBList $list */ | |||||
$list = $this->Application->recallObject($prefix, $prefix . '_List', $tag_params); | $list = $this->Application->recallObject($prefix, $prefix . '_List', $tag_params); | ||||
/* @var $list kDBList */ | |||||
$sql = $list->getCountSQL($list->GetSelectSQL()); | $sql = $list->getCountSQL($list->GetSelectSQL()); | ||||
$sql = str_replace('COUNT(*) AS count', $list->TableName . '.' . $list->IDField, $sql); | $sql = str_replace('COUNT(*) AS count', $list->TableName . '.' . $list->IDField, $sql); | ||||
$ids = ''; | $ids = ''; | ||||
$rows = $this->Conn->GetIterator($sql); | $rows = $this->Conn->GetIterator($sql); | ||||
if ( count($rows) ) { | if ( count($rows) ) { | ||||
Show All 10 Lines |