Index: trunk/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r1633 -r1636 --- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 1633) +++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 1636) @@ -524,10 +524,23 @@ return $value; } - function HasParam($params, $param_name) + /** + * Checks if parameter is passed + * Note: works like Tag and line simple method too + * + * @param Array $params + * @param string $param_name + * @return bool + */ + function HasParam($params, $param_name = null) { + if( !isset($param_name) ) + { + $param_name = $this->SelectParam($params, 'name'); + $params = $this->Application->Parser->Params; + } $value = getArrayValue($params, $param_name); - return $value && ($value != '$'.$param_name); + return $value && ($value != '$'.$param_name); } function PhraseField($params) Index: trunk/core/units/phrases/phrases_config.php =================================================================== diff -u -N -r1563 -r1636 --- trunk/core/units/phrases/phrases_config.php (.../phrases_config.php) (revision 1563) +++ trunk/core/units/phrases/phrases_config.php (.../phrases_config.php) (revision 1636) @@ -106,6 +106,7 @@ 'VirtualFields' => Array( 'PrimaryValue' => Array(), 'LangFile' => Array(), + 'ImportOverwrite' => Array(), ), 'Grids' => Array( Index: trunk/kernel/units/phrases/phrases_config.php =================================================================== diff -u -N -r1563 -r1636 --- trunk/kernel/units/phrases/phrases_config.php (.../phrases_config.php) (revision 1563) +++ trunk/kernel/units/phrases/phrases_config.php (.../phrases_config.php) (revision 1636) @@ -106,6 +106,7 @@ 'VirtualFields' => Array( 'PrimaryValue' => Array(), 'LangFile' => Array(), + 'ImportOverwrite' => Array(), ), 'Grids' => Array( Index: trunk/core/units/languages/import_xml.php =================================================================== diff -u -N -r1623 -r1636 --- trunk/core/units/languages/import_xml.php (.../import_xml.php) (revision 1623) +++ trunk/core/units/languages/import_xml.php (.../import_xml.php) (revision 1636) @@ -1,5 +1,8 @@ phrase_types_allowed = array_flip($phrase_types); + $this->import_mode = $import_mode; //if (in_array('In-Portal',) @@ -106,6 +146,14 @@ { case 'LANGUAGES LANGUAGE': $this->current_language = Array('PackName' => $attributes['PACKNAME'], 'LocalName' => $attributes['PACKNAME']); + + $sql = 'SELECT %s FROM %s WHERE PackName = %s'; + $sql = sprintf( $sql, + $this->lang_object->IDField, + kTempTablesHandler::GetLiveName($this->lang_object->TableName), + $this->Conn->qstr($this->current_event['PackName']) ); + $language_id = $this->Conn->GetOne($sql); + if($language_id) $this->current_language['LanguageId'] = $language_id; break; case 'LANGUAGES LANGUAGE PHRASES': Index: trunk/kernel/admin_templates/dummy.tpl =================================================================== diff -u -N -r1566 -r1636 --- trunk/kernel/admin_templates/dummy.tpl (.../dummy.tpl) (revision 1566) +++ trunk/kernel/admin_templates/dummy.tpl (.../dummy.tpl) (revision 1636) @@ -1 +1 @@ -kruta \ No newline at end of file + \ No newline at end of file Index: trunk/kernel/units/languages/import_xml.php =================================================================== diff -u -N -r1623 -r1636 --- trunk/kernel/units/languages/import_xml.php (.../import_xml.php) (revision 1623) +++ trunk/kernel/units/languages/import_xml.php (.../import_xml.php) (revision 1636) @@ -1,5 +1,8 @@ phrase_types_allowed = array_flip($phrase_types); + $this->import_mode = $import_mode; //if (in_array('In-Portal',) @@ -106,6 +146,14 @@ { case 'LANGUAGES LANGUAGE': $this->current_language = Array('PackName' => $attributes['PACKNAME'], 'LocalName' => $attributes['PACKNAME']); + + $sql = 'SELECT %s FROM %s WHERE PackName = %s'; + $sql = sprintf( $sql, + $this->lang_object->IDField, + kTempTablesHandler::GetLiveName($this->lang_object->TableName), + $this->Conn->qstr($this->current_event['PackName']) ); + $language_id = $this->Conn->GetOne($sql); + if($language_id) $this->current_language['LanguageId'] = $language_id; break; case 'LANGUAGES LANGUAGE PHRASES': Index: trunk/kernel/admin_templates/regional/languages_import.tpl =================================================================== diff -u -N -r1563 -r1636 --- trunk/kernel/admin_templates/regional/languages_import.tpl (.../languages_import.tpl) (revision 1563) +++ trunk/kernel/admin_templates/regional/languages_import.tpl (.../languages_import.tpl) (revision 1636) @@ -44,6 +44,8 @@ + + Index: trunk/core/admin_templates/dummy.tpl =================================================================== diff -u -N -r1566 -r1636 --- trunk/core/admin_templates/dummy.tpl (.../dummy.tpl) (revision 1566) +++ trunk/core/admin_templates/dummy.tpl (.../dummy.tpl) (revision 1636) @@ -1 +1 @@ -kruta \ No newline at end of file + \ No newline at end of file Index: trunk/kernel/units/languages/languages_event_handler.php =================================================================== diff -u -N -r1580 -r1636 --- trunk/kernel/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 1580) +++ trunk/kernel/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 1636) @@ -154,8 +154,7 @@ $lang_xml->Parse($field_values['LangFile']['tmp_name'], $field_values['PhraseType'], $field_values['Module']); } $event->redirect = 'dummy'; - $event->SetRedirectParam('lang_event', 'OnImportProgress'); - $event->SetRedirectParam('pass', 'all,lang'); + $event->SetRedirectParams( Array('lang_event' => 'OnImportProgress', 'pass' => 'all,lang', 'mode'=>$field_values['ImportOverwrite']) ); } /** @@ -168,13 +167,15 @@ define('IMPORT_BY', 300); // import this much records per step $template_name = 'regional/languages_import_step2'; + $import_mode = (int)$this->Application->GetVar('mode'); // 1 - overwrite existing phrases, 0 - don't overwrite existing phrases $import_source = (int)$this->Application->GetVar('source'); $import_steps = Array(0 => 'lang', 1 => 'phrases', 2 => 'emailmessages', 3 => 'finish'); $import_titles = Array(0 => 'la_ImportingLanguages', 1 => 'la_ImportingPhrases', 2 => 'la_ImportingEmailEvents', 3 => 'la_Done'); // --- BEFORE --- $import_prefix = $import_steps[$import_source]; $import_start = (int)$this->Application->GetVar('start'); + $id_field = $this->Application->getUnitOption($import_prefix,'IDField'); $dst_table = $this->Application->getUnitOption($import_prefix,'TableName'); $src_table = kTempTablesHandler::GetTempName($dst_table); @@ -193,6 +194,7 @@ } $import_start = 0; + $id_field = $this->Application->getUnitOption($import_prefix,'IDField'); $dst_table = $this->Application->getUnitOption($import_prefix,'TableName'); $src_table = kTempTablesHandler::GetTempName($dst_table); $import_total = $this->Conn->GetOne('SELECT COUNT(*) FROM '.$src_table); @@ -214,6 +216,9 @@ $sql = 'SELECT * FROM %s LIMIT %s,%s'; $rows = $this->Conn->Query( sprintf($sql,$src_table,$import_start,IMPORT_BY) ); + // if found and mode = 1 (overwrite) + //$search_sql = 'SELECT '.$id_field.' FROM '.$dst_table.' WHERE '; + $fields_sql = ''; foreach($fields as $field_name) { @@ -236,7 +241,7 @@ $sql = sprintf('INSERT INTO %s (%s) VALUES %s', $dst_table, $fields_sql, $values_sql); $this->Conn->Query($sql); - $event->setRedirectParams( Array('lang_event' => 'OnImportProgress', 'pass' => 'all,lang', 'start' => $import_start += count($rows), 'total' => $import_total, 'source' => $import_source) ); + $event->setRedirectParams( Array('lang_event' => 'OnImportProgress', 'pass' => 'all,lang', 'start' => $import_start += count($rows), 'total' => $import_total, 'source' => $import_source, 'mode' => $import_mode) ); } /** Index: trunk/core/units/languages/languages_event_handler.php =================================================================== diff -u -N -r1580 -r1636 --- trunk/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 1580) +++ trunk/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 1636) @@ -154,8 +154,7 @@ $lang_xml->Parse($field_values['LangFile']['tmp_name'], $field_values['PhraseType'], $field_values['Module']); } $event->redirect = 'dummy'; - $event->SetRedirectParam('lang_event', 'OnImportProgress'); - $event->SetRedirectParam('pass', 'all,lang'); + $event->SetRedirectParams( Array('lang_event' => 'OnImportProgress', 'pass' => 'all,lang', 'mode'=>$field_values['ImportOverwrite']) ); } /** @@ -168,13 +167,15 @@ define('IMPORT_BY', 300); // import this much records per step $template_name = 'regional/languages_import_step2'; + $import_mode = (int)$this->Application->GetVar('mode'); // 1 - overwrite existing phrases, 0 - don't overwrite existing phrases $import_source = (int)$this->Application->GetVar('source'); $import_steps = Array(0 => 'lang', 1 => 'phrases', 2 => 'emailmessages', 3 => 'finish'); $import_titles = Array(0 => 'la_ImportingLanguages', 1 => 'la_ImportingPhrases', 2 => 'la_ImportingEmailEvents', 3 => 'la_Done'); // --- BEFORE --- $import_prefix = $import_steps[$import_source]; $import_start = (int)$this->Application->GetVar('start'); + $id_field = $this->Application->getUnitOption($import_prefix,'IDField'); $dst_table = $this->Application->getUnitOption($import_prefix,'TableName'); $src_table = kTempTablesHandler::GetTempName($dst_table); @@ -193,6 +194,7 @@ } $import_start = 0; + $id_field = $this->Application->getUnitOption($import_prefix,'IDField'); $dst_table = $this->Application->getUnitOption($import_prefix,'TableName'); $src_table = kTempTablesHandler::GetTempName($dst_table); $import_total = $this->Conn->GetOne('SELECT COUNT(*) FROM '.$src_table); @@ -214,6 +216,9 @@ $sql = 'SELECT * FROM %s LIMIT %s,%s'; $rows = $this->Conn->Query( sprintf($sql,$src_table,$import_start,IMPORT_BY) ); + // if found and mode = 1 (overwrite) + //$search_sql = 'SELECT '.$id_field.' FROM '.$dst_table.' WHERE '; + $fields_sql = ''; foreach($fields as $field_name) { @@ -236,7 +241,7 @@ $sql = sprintf('INSERT INTO %s (%s) VALUES %s', $dst_table, $fields_sql, $values_sql); $this->Conn->Query($sql); - $event->setRedirectParams( Array('lang_event' => 'OnImportProgress', 'pass' => 'all,lang', 'start' => $import_start += count($rows), 'total' => $import_total, 'source' => $import_source) ); + $event->setRedirectParams( Array('lang_event' => 'OnImportProgress', 'pass' => 'all,lang', 'start' => $import_start += count($rows), 'total' => $import_total, 'source' => $import_source, 'mode' => $import_mode) ); } /** Index: trunk/kernel/admin_templates/incs/form_blocks.tpl =================================================================== diff -u -N -r1633 -r1636 --- trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 1633) +++ trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 1636) @@ -195,6 +195,7 @@ name="[]" id="_" value="">  + @@ -213,6 +214,7 @@ " name="" value=""> " type="checkbox" id="_cb_" name="_cb_" class="" onclick="update_checkbox(this, document.getElementById(''))" onchange=""> +   @@ -223,9 +225,9 @@ - + - +