Export for spreadsheets: transform keys (id of the queried object or external keys) into the corresponding friendly name

SVN:1.2[1815]
This commit is contained in:
Romain Quetiez
2012-01-30 10:58:21 +00:00
parent cf37a50b3d
commit c3de9ecf10
4 changed files with 72 additions and 21 deletions

View File

@@ -3506,6 +3506,43 @@ class AttributeFriendlyName extends AttributeComputedFieldVoid
public function GetKeyAttCode() {return $this->Get("extkey_attcode");}
public function GetLabel($sDefault = null)
{
$sLabel = parent::GetLabel('');
if (strlen($sLabel) == 0)
{
$sKeyAttCode = $this->Get("extkey_attcode");
if ($sKeyAttCode == 'id')
{
return Dict::S('Core:FriendlyName-Label');
}
else
{
$oExtKeyAttDef = MetaModel::GetAttributeDef($this->GetHostClass(), $sKeyAttCode);
$sLabel = $oExtKeyAttDef->GetLabel($this->m_sCode);
}
}
return $sLabel;
}
public function GetDescription($sDefault = null)
{
$sLabel = parent::GetDescription('');
if (strlen($sLabel) == 0)
{
$sKeyAttCode = $this->Get("extkey_attcode");
if ($sKeyAttCode == 'id')
{
return Dict::S('Core:FriendlyName-Description');
}
else
{
$oExtKeyAttDef = MetaModel::GetAttributeDef($this->GetHostClass(), $sKeyAttCode);
$sLabel = $oExtKeyAttDef->GetDescription('');
}
}
return $sLabel;
}
// n/a, the friendly name is made of a complex expression (see GetNameSpec)
protected function GetSQLCol() {return "";}