From 6f04525cdf0d04e70f1e2719d5fa554cb8cb13ad Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 12 Feb 2020 15:00:10 +0100 Subject: [PATCH] :art: cleanup code --- pages/ajax.csvimport.php | 15 ++++++++++--- pages/csvimport.php | 47 ++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/pages/ajax.csvimport.php b/pages/ajax.csvimport.php index 73ee62445..e833817e4 100644 --- a/pages/ajax.csvimport.php +++ b/pages/ajax.csvimport.php @@ -28,9 +28,12 @@ require_once(APPROOT.'/application/csvpage.class.inc.php'); /** * Determines if the name of the field to be mapped correspond * to the name of an external key or an Id of the given class + * * @param string $sClassName The name of the class * @param string $sFieldCode The attribute code of the field , or empty if no match + * * @return bool true if the field corresponds to an id/External key, false otherwise + * @throws \Exception */ function IsIdField($sClassName, $sFieldCode) { @@ -52,10 +55,13 @@ function IsIdField($sClassName, $sFieldCode) /** * Get all the fields xxx->yyy based on the field xxx which is an external key - * @param string $sExtKeyAttCode Attribute code of the external key + * + * @param $sAttCode * @param AttributeDefinition $oExtKeyAttDef Attribute definition of the external key * @param bool $bAdvanced True if advanced mode - * @return Ash List of codes=>display name: xxx->yyy where yyy are the reconciliation keys for the object xxx + * + * @return array List of codes=>display name: xxx->yyy where yyy are the reconciliation keys for the object xxx + * @throws \CoreException */ function GetMappingsForExtKey($sAttCode, AttributeDefinition $oExtKeyAttDef, $bAdvanced) { @@ -88,12 +94,15 @@ function GetMappingsForExtKey($sAttCode, AttributeDefinition $oExtKeyAttDef, $bA * If not in advanced mode, all "id" fields (id and external keys) must be mapped to ":none:" (i.e -- ignore this field --) * External fields that do not correspond to a reconciliation key must be mapped to ":none:" * Otherwise, if a field equals either the 'code' or the 'label' (translated) of a field, then it's mapped automatically + * * @param string $sClassName Name of the class used for the mapping * @param string $sFieldName Name of the field, as it comes from the data file (header line) * @param integer $iFieldIndex Number of the field in the sequence * @param bool $bAdvancedMode Whether or not advanced mode was chosen * @param string $sDefaultChoice If set, this will be the item selected by default + * * @return string The HTML code corresponding to the drop-down list for this field + * @throws \CoreException */ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMode, $sDefaultChoice) { @@ -213,7 +222,7 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo $sSelected = ' selected'; } - $sHtml .= "\n"; + $sHtml .= "\n"; } $sHtml .= "\n"; return $sHtml; diff --git a/pages/csvimport.php b/pages/csvimport.php index ba3810b6a..cf618ce23 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -37,16 +37,18 @@ try /** * Helper function to build a select from the list of valid classes for a given action + * * @param string $sName The name of the select in the HTML form - * @param string $sDefaulfValue The defaut value (i.e the value selected by default) + * @param $sDefaultValue * @param integer $iWidthPx The width (in pixels) of the drop-down list * @param integer $iActionCode The ActionCode (from UserRights) to check for authorization for the classes + * * @return string The HTML fragment corresponding to the select tag */ function GetClassesSelect($sName, $sDefaultValue, $iWidthPx, $iActionCode = null) { $sHtml = "

'); $sConfirm = $bShouldConfirm ? 'true' : 'false'; - $oPage->add('

"); + $oPage->add('

"); } else { @@ -1153,27 +1154,27 @@ EOF $oPage->add('

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

'); $oPage->add('
'); $oPage->add('
'); - $oPage->add('
'); + $oPage->add(''); $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('

'.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('

'.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('

'.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('

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

'); - $oPage->add('

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

'); - $oPage->add('

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

'); + $oPage->add('

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

'); + $oPage->add('

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

'); $oPage->add('

'); $oPage->add('

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

'); - $oPage->add('

'); - $oPage->add('

'); + $oPage->add('

'); + $oPage->add('

'); $oPage->add('

'); $oPage->add(''); $oPage->add(''); @@ -1317,16 +1318,16 @@ EOF '

'; $sFileLoadHtml .= '

'.Dict::S('UI:CSVImport:Encoding').': '; - $sFileLoadHtml .= ''; // IE 8 has some troubles if the font is different $aPossibleEncodings = utils::GetPossibleEncodings(MetaModel::GetConfig()->GetCSVImportCharsets()); foreach($aPossibleEncodings as $sIconvCode => $sDisplayName ) { $sSelected = ''; if ($sEncoding == $sIconvCode) { - $sSelected = ' selected'; + $sSelected = 'selected'; } - $sFileLoadHtml .= ''; + $sFileLoadHtml .= ''; } $sFileLoadHtml .= '

'; $sFileLoadHtml .= '

'.