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 = "";
- $sHtml .= "--- select one --- \n";
+ $sHtml .= "".Dict::S('UI:CSVImport:ClassesSelectOne')." \n";
$aValidClasses = array();
foreach(MetaModel::GetClasses('bizmodel') as $sClassName)
{
if (is_null($iActionCode) || UserRights::IsActionAllowed($sClassName, $iActionCode))
{
- $sSelected = ($sClassName == $sDefaultValue) ? " SELECTED" : "";
+ $sSelected = ($sClassName == $sDefaultValue) ? " selected" : "";
$sDescription = MetaModel::GetClassDescription($sClassName);
$sDisplayName = MetaModel::GetName($sClassName);
$aValidClasses[$sDisplayName] = "$sDisplayName ";
@@ -80,9 +80,9 @@ function GetFriendlyAttCodeName($sClassName, $sAttCodeEx)
$sFriendlyName = '';
if (preg_match('/(.+)->(.+)/', $sAttCodeEx, $aMatches) > 0)
{
- $Attribute = $aMatches[1];
+ $sAttribute = $aMatches[1];
$sField = $aMatches[2];
- $oAttDef = MetaModel::GetAttributeDef($sClassName, $Attribute);
+ $oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttribute);
if ($oAttDef->IsExternalKey())
{
$sTargetClass = $oAttDef->GetTargetClass();
@@ -92,7 +92,7 @@ function GetFriendlyAttCodeName($sClassName, $sAttCodeEx)
else
{
// hum, hum... should never happen, we'd better raise an exception
- throw(new Exception("Internal error: '$sAttCodeEx' is an incorrect code because '$sAttribute' is NOT an external key of the class '$sClassName'."));
+ throw(new Exception(Dict::Format('UI:CSVImport:ErrorExtendedAttCode', $sAttCodeEx, $sAttribute, $sClassName)));
}
}
@@ -100,7 +100,7 @@ function GetFriendlyAttCodeName($sClassName, $sAttCodeEx)
{
if ($sAttCodeEx == 'id')
{
- $sFriendlyName = 'id (Primary Key)';
+ $sFriendlyName = Dict::S('UI:CSVImport:idField');
}
else
{
@@ -209,6 +209,7 @@ function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true
$aFieldsMapping = utils::ReadParam('field', array());
$aSearchFields = utils::ReadParam('search_field', array());
$iCurrentStep = $bSimulate ? 4 : 5;
+ $bAdvanced = utils::ReadParam('advanced', 0);
// Parse the data set
$oCSVParser = new CSVParser($sCSVData, $sSeparator, $sTextQualifier);
@@ -452,7 +453,7 @@ function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true
$oPage->add(' ');
$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('
');
$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('
');
$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("\n");
+ $oPage->add("
".Dict::S('UI:Title:BulkImport+')." \n");
$oPage->AddTabContainer('tabs1');
- $sFileLoadHtml = '