diff --git a/core/ormlinkset.class.inc.php b/core/ormlinkset.class.inc.php index 56573dc517..e116dd88ac 100644 --- a/core/ormlinkset.class.inc.php +++ b/core/ormlinkset.class.inc.php @@ -789,6 +789,30 @@ public function GetValues() return $aValues; } + /** + * List the objects by name + * @return array of linked object friendly-names + * @throws \CoreException + */ + public function GetLabels() + { + /** @var \AttributeLinkedSet|\AttributeLinkedSetIndirect $oAttDef */ + $oAttDef = MetaModel::GetAttributeDef($this->sHostClass, $this->sAttCode); + $sNameField = ($oAttDef->IsIndirect() ? $oAttDef->GetExtKeyToRemote().'_' : '').'friendlyname'; + + $aLabels = array(); + foreach ($this->aPreserved as $oLink) { + $aLabels[] = $oLink->Get($sNameField); + } + foreach ($this->aAdded as $oLink) { + $aLabels[] = $oLink->Get($sNameField); + } + + sort($aLabels); + + return $aLabels; + } + /** * @return \DBObjectSet|null */ diff --git a/core/spreadsheetbulkexport.class.inc.php b/core/spreadsheetbulkexport.class.inc.php index 2006729ba0..65f190b5dd 100644 --- a/core/spreadsheetbulkexport.class.inc.php +++ b/core/spreadsheetbulkexport.class.inc.php @@ -308,6 +308,15 @@ public function GetNextChunk(&$aStatus) } elseif ($oAttDef instanceof AttributeTagSet) { $sField = utils::HtmlEntities($oObj->GetAsCSV($sAttCode, $this->bLocalizeOutput, '')); $sData .= "$sField"; + } else if ($oAttDef instanceof AttributeLinkedSet) { + if ($this->bLocalizeOutput) { + /** @var \ormLinkSet $oLinkSet */ + $oLinkSet = $oObj->Get($sAttCode); + $sField = implode('
', $oLinkSet->GetLabels()); + } else { + $sField = $oObj->GetEditValue($sAttCode); + } + $sData .= "$sField"; } else { $rawValue = $oObj->Get($sAttCode); if ($this->bLocalizeOutput) { diff --git a/sources/Core/AttributeDefinition/AttributeLinkedSet.php b/sources/Core/AttributeDefinition/AttributeLinkedSet.php index 840c9eaeaf..ef6e867e28 100644 --- a/sources/Core/AttributeDefinition/AttributeLinkedSet.php +++ b/sources/Core/AttributeDefinition/AttributeLinkedSet.php @@ -446,6 +446,7 @@ public function EnumTemplateVerbs() return [ '' => 'Plain text (unlocalized) representation', 'html' => 'HTML representation (unordered list)', + 'csv' => 'CSV representation (unordered list)', ]; } @@ -487,6 +488,9 @@ public function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = case 'html': return ''; + case 'csv': + return $this->GetAsCSV($value, oHostObject: $oHostObject, bLocalize: $bLocalize); + default: throw new Exception("Unknown verb '$sVerb' for attribute ".$this->GetCode().' in class '.get_class($oHostObject)); }