diff --git a/pages/csvimport.php b/pages/csvimport.php index 9d90ddac9..ddca29a4e 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -23,7 +23,7 @@ $oAppContext = new ApplicationContext(); $currentOrganization = utils::ReadParam('org_id', 1); $iStep = utils::ReadParam('step', 1); -$oPage = new iTopWebPage("iTop - Bulk import", $currentOrganization); +$oPage = new iTopWebPage(Dict::S('UI:Title:BulkImport'), $currentOrganization); /** * Helper function to build a select from the list of valid classes for a given action @@ -36,13 +36,13 @@ $oPage = new iTopWebPage("iTop - Bulk import", $currentOrganization); function GetClassesSelect($sName, $sDefaultValue, $iWidthPx, $iActionCode = null) { $sHtml = "'); $oPage->add(''); $oPage->add(''); - $oPage->add(''); + $oPage->add(''); foreach($aFieldsMapping as $iNumber => $sAttCode) { $oPage->add(''); @@ -466,17 +467,17 @@ function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true $aDisplayFilters = array(); if ($bSimulate) { - $aDisplayFilters['unchanged'] = '%d objects(s) will stay unchanged.'; - $aDisplayFilters['modified'] = '%d objects(s) will stay be modified.'; - $aDisplayFilters['added'] = '%d objects(s) will be added.'; - $aDisplayFilters['errors'] = '%d objects(s) will have errors.'; + $aDisplayFilters['unchanged'] = Dict::S('UI:CSVImport:ObjectsWillStayUnchanged'); + $aDisplayFilters['modified'] = Dict::S('UI:CSVImport:ObjectsWillBeModified'); + $aDisplayFilters['added'] = Dict::S('UI:CSVImport:ObjectsWillBeAdded'); + $aDisplayFilters['errors'] = Dict::S('UI:CSVImport:ObjectsWillHaveErrors'); } else { - $aDisplayFilters['unchanged'] = '%d objects(s) remained unchanged.'; - $aDisplayFilters['modified'] = '%d objects(s) were modified.'; - $aDisplayFilters['added'] = '%d objects(s) were added.'; - $aDisplayFilters['errors'] = '%d objects(s) had errors.'; + $aDisplayFilters['unchanged'] = Dict::S('UI:CSVImport:ObjectsRemainedUnchanged'); + $aDisplayFilters['modified'] = Dict::S('UI:CSVImport:ObjectsWereModified'); + $aDisplayFilters['added'] = Dict::S('UI:CSVImport:ObjectsWereAdded'); + $aDisplayFilters['errors'] = Dict::S('UI:CSVImport:ObjectsHadErrors'); } $oPage->add('

  '.sprintf($aDisplayFilters['unchanged'], $iUnchanged).'  '); $oPage->add('  '.sprintf($aDisplayFilters['modified'], $iModified).'  '); @@ -485,14 +486,14 @@ function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true $oPage->add('

'); $oPage->add($sHtml); $oPage->add('
'); - $oPage->add('

  '); + $oPage->add('

  '); if ($bSimulate) { - $oPage->add('

'); + $oPage->add('

'); } else { - $oPage->add('

'); + $oPage->add('

'); } $oPage->add(''); $oPage->add(' '); @@ -529,12 +530,12 @@ EOF */ function LoadData(WebPage $oPage, UserContext $oContext) { - $oPage->add('

Step 5 of 5: Import completed

'); + $oPage->add('

'.Dict::S('UI:Title:CSVImportStep5').'

'); $aResult = ProcessCSVData($oPage, $oContext, false /* simulate = false */); if (is_array($aResult)) { - $oPage->StartCollapsibleSection("Lines that could not be loaded:", false); - $oPage->p('The following lines have not been imported because they contain errors'); + $oPage->StartCollapsibleSection(Dict::S('UI:CSVImport:LinesNotImported'), false); + $oPage->p(Dict::S('UI:CSVImport:LinesNotImported+')); $oPage->add(''); @@ -550,7 +551,7 @@ function LoadData(WebPage $oPage, UserContext $oContext) */ function Preview(WebPage $oPage, UserContext $oContext) { - $oPage->add('

Step 4 of 5: Import simulation

'); + $oPage->add('

'.Dict::S('UI:Title:CSVImportStep4').'

'); ProcessCSVData($oPage, $oContext, true /* simulate */); } @@ -581,12 +582,15 @@ function SelectMapping(WebPage $oPage) $iSkippedLines = utils::ReadParam('nb_skipped_lines', '0'); } $sClassName = utils::ReadParam('class_name', ''); + $bAdvanced = utils::ReadParam('advanced', 0); - $oPage->add('

Step 3 of 5: Data mapping

'); + $oPage->add('

'.Dict::S('UI:Title:CSVImportStep3').'

'); $oPage->add('
'); - $oPage->add('

Select the class to import: '); - $oPage->add(GetClassesSelect('class_name', $sClassName, 300, UR_ACTION_BULK_MODIFY).'

'); - $oPage->add('


Select a class to configure the mapping

'); + $oPage->add('
'.Dict::S('UI:CSVImport:SelectClass').' '); + $oPage->add(GetClassesSelect('class_name', $sClassName, 300, UR_ACTION_BULK_MODIFY)); + $oPage->add(' '.Dict::S('UI:CSVImport:AdvancedMode').'
'); + $oPage->add(''); + $oPage->add('


'.Dict::S('UI:CSVImport:SelectAClassFirst').'

'); $oPage->add(''); $oPage->add(''); $oPage->add(''); @@ -596,10 +600,14 @@ function SelectMapping(WebPage $oPage) $oPage->add(''); $oPage->add(''); $oPage->add(''); - $oPage->add('

  '); - $oPage->add('

'); + $oPage->add('

  '); + $oPage->add('

'); $oPage->add('
'); $oPage->add('
'); + + $sAlertIncompleteMapping = Dict::S('UI:CSVImport:AlertIncompleteMapping'); + $sAlertNoSearchCriteria = Dict::S('UI:CSVImport:AlertNoSearchCriteria'); + $oPage->add_ready_script( <<add_script( << 0) + { + // The 'id' field was mapped, it's the only possible reconciliation key + $('#search_'+index).attr('checked', false); + $('#search_'+index).attr('disabled', true); + } + else + { + $('#search_'+index).attr('disabled', false); + if (nbSearchKeys == 0) + { + // No search key was selected, select the default ones + for(j =0; j < aDefaultKeys.length; j++) + { + if (sMappingValue == aDefaultKeys[j]) + { + $('#search_'+index).attr('checked', true); + } + } + } + } + } + } + } EOF ); } @@ -728,6 +823,8 @@ function SelectOptions(WebPage $oPage) $sOtherTextQualifier = in_array($sTextQualifier, array('"', "'")) ? '' : $sTextQualifier; $bHeaderLine = utils::ReadParam('header_line', 0); $sClassName = utils::ReadParam('class_name', ''); + $bAdvanced = utils::ReadParam('advanced', 0); + // Create a truncated version of the data used for the fast preview // Take about 20 lines of data... knowing that some lines may contain carriage returns $iMaxLines = 20; @@ -749,36 +846,37 @@ function SelectOptions(WebPage $oPage) } $sCSVDataTruncated = substr($sCSVData, 0, $iCurPos); - $oPage->add('

Step 2 of 5: CSV data options

'); + $oPage->add('

'.Dict::S('UI:Title:CSVImportStep2').'

'); $oPage->add('
'); $oPage->add('
'); $oPage->add('
'); - $oPage->add('

Separator character:

'); - $oPage->add('

, (comma)
'); - $oPage->add(' ; (semicolon)
'); - $oPage->add(' tab
'); - $oPage->add(' other: '); + $oPage->add('

'.Dict::S('UI:CSVImport:SeparatorCharacter').'

'); + $oPage->add('

'.Dict::S('UI:CSVImport:SeparatorComma+').'
'); + $oPage->add(' '.Dict::S('UI:CSVImport:SeparatorSemicolon+').'
'); + $oPage->add(' '.Dict::S('UI:CSVImport:SeparatorTab+').'
'); + $oPage->add(' '.Dict::S('UI:CSVImport:SeparatorOther').' '); $oPage->add('

'); $oPage->add('
'); - $oPage->add('

Text qualifier character:

'); - $oPage->add('

" (double quote)
'); - $oPage->add(' \' (simple quote)
'); - $oPage->add(' other: '); + $oPage->add('

'.Dict::S('UI:CSVImport:TextQualifierCharacter').'

'); + $oPage->add('

'.Dict::S('UI:CSVImport:QualifierDoubleQuote+').'
'); + $oPage->add(' '.Dict::S('UI:CSVImport:QualifierSimpleQuote+').'
'); + $oPage->add(' '.Dict::S('UI:CSVImport:QualifierOther').' '); $oPage->add('

'); $oPage->add('
'); - $oPage->add('

Comments and header:

'); - $oPage->add('

Treat the first line as a header (column names)

'); - $oPage->add('

Skip line(s) at the beginning of the file

'); + $oPage->add('

'.Dict::S('UI:CSVImport:CommentsAndHeader').'

'); + $oPage->add('

'.Dict::S('UI:CSVImport:TreatFirstLineAsHeader').'

'); + $oPage->add('

'.Dict::Format('UI:CSVImport:Skip_N_LinesAtTheBeginning', '').'

'); $oPage->add('

'); $oPage->add(''); $oPage->add(''); $oPage->add(''); + $oPage->add(''); $oPage->add(''); $oPage->add('
'); - $oPage->add('

Data Preview

'); + $oPage->add('

'.Dict::S('UI:CSVImport:CSVDataPreview').'

'); $oPage->add('
'); - $oPage->add(''); - $oPage->add(''); + $oPage->add(''); + $oPage->add(''); $oPage->add(''); $oPage->add('
'); @@ -847,27 +945,28 @@ EOF */ function Welcome(iTopWebPage $oPage) { - $oPage->add("

CSV import wizard

\n"); + $oPage->add("

".Dict::S('UI:Title:BulkImport+')."

\n"); $oPage->AddTabContainer('tabs1'); - $sFileLoadHtml = '

Select the file to import:

'. + $sFileLoadHtml = '

'.Dict::S('UI:CSVImport:SelectFile').'

'. '

'. - '

'. + '

'. '

'. '

'. '
'; - $oPage->AddToTab('tabs1', "Load from a file", $sFileLoadHtml); + $oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:LoadFromFile'), $sFileLoadHtml); $sCSVData = utils::ReadParam('csvdata', ''); $sSeparator = utils::ReadParam('separator', ''); $sTextQualifier = utils::ReadParam('text_qualifier', ''); $bHeaderLine = utils::ReadParam('header_line', true); $iSkippedLines = utils::ReadParam('nb_skipped_lines', ''); $sClassName = utils::ReadParam('class_name', ''); + $bAdvanced = utils::ReadParam('advanced', 0); $sCSVData = utils::ReadParam('csvdata', ''); - $sPasteDataHtml = '

Paste the data to import:

'. + $sPasteDataHtml = '

'.Dict::S('UI:CSVImport:PasteData').'

'. '

'. - '

'. + '

'. ''. ''. ''. @@ -875,15 +974,17 @@ function Welcome(iTopWebPage $oPage) ''. ''. ''. + ''. '
'; - $oPage->AddToTab('tabs1', "Copy and paste data", $sPasteDataHtml); - - $sTemplateHtml = '

Pick the template do download: '; + + $oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:CopyPaste'), $sPasteDataHtml); + $sTemplateHtml = '

'.Dict::S('UI:CSVImport:PickClassForTemplate').' '; $sTemplateHtml .= GetClassesSelect('template_class', '', 300, UR_ACTION_BULK_MODIFY); $sTemplateHtml .= '

'; $sTemplateHtml .= '
'; $sTemplateHtml .= '
'; - $oPage->AddToTab('tabs1', "Templates", $sTemplateHtml); + + $oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:Templates'), $sTemplateHtml); $oPage->add_script( <<