mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
#355 CSV Import (non interactive) now supporting localized column headers, making it possible to import directly data generated by the interactive export. NOTE: to achieve this, the default separator is now the coma (whereas the default separator in XCel sheets is the semicolumn)
SVN:trunk[1122]
This commit is contained in:
@@ -92,48 +92,6 @@ try
|
||||
return ($bCondition xor $bInverseCondition) ? ' checked' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user friendly name for an 'extended' attribute code i.e 'name', becomes 'Name' and 'org_id->name' becomes 'Organization->Name'
|
||||
* @param string $sClassName The name of the class
|
||||
* @param string $sAttCodeEx Either an attribute code of ext_key_name->att_code
|
||||
* @return string A user friendly format of the string: AttributeName or AttributeName->ExtAttributeName
|
||||
*/
|
||||
function GetFriendlyAttCodeName($sClassName, $sAttCodeEx)
|
||||
{
|
||||
$sFriendlyName = '';
|
||||
if (preg_match('/(.+)->(.+)/', $sAttCodeEx, $aMatches) > 0)
|
||||
{
|
||||
$sAttribute = $aMatches[1];
|
||||
$sField = $aMatches[2];
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttribute);
|
||||
if ($oAttDef->IsExternalKey())
|
||||
{
|
||||
$sTargetClass = $oAttDef->GetTargetClass();
|
||||
$oTargetAttDef = MetaModel::GetAttributeDef($sTargetClass, $sField);
|
||||
$sFriendlyName = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
// hum, hum... should never happen, we'd better raise an exception
|
||||
throw(new Exception(Dict::Format('UI:CSVImport:ErrorExtendedAttCode', $sAttCodeEx, $sAttribute, $sClassName)));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($sAttCodeEx == 'id')
|
||||
{
|
||||
$sFriendlyName = Dict::S('UI:CSVImport:idField');
|
||||
}
|
||||
else
|
||||
{
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCodeEx);
|
||||
$sFriendlyName = $oAttDef->GetLabel();
|
||||
}
|
||||
}
|
||||
return $sFriendlyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of occurences of each char from the set in the specified string
|
||||
* @param string $sString The input data
|
||||
@@ -369,7 +327,7 @@ try
|
||||
{
|
||||
if (!empty($sAttCode) && ($sAttCode != ':none:') && ($sAttCode != 'finalclass'))
|
||||
{
|
||||
$sHtml .= "<th style=\"padding:2px;border-right: 2px #fff solid;\">".GetFriendlyAttCodeName($sClassName, $sAttCode)."</th>";
|
||||
$sHtml .= "<th style=\"padding:2px;border-right: 2px #fff solid;\">".BulkChange::GetFriendlyAttCodeName($sClassName, $sAttCode)."</th>";
|
||||
}
|
||||
}
|
||||
$sHtml .= '<th>Message</th>';
|
||||
|
||||
Reference in New Issue
Block a user