Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions core/ormlinkset.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,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
*/
Expand Down
11 changes: 11 additions & 0 deletions core/spreadsheetbulkexport.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,17 @@ public function GetNextChunk(&$aStatus)
$sField = utils::HtmlEntities($oObj->GetAsCSV($sAttCode, $this->bLocalizeOutput, ''));
$sData .= "<td x:str>$sField</td>";
}
else if ($oAttDef instanceof AttributeLinkedSet)
{
if ($this->bLocalizeOutput) {
/** @var \ormLinkSet $oLinkSet */
$oLinkSet = $oObj->Get($sAttCode);
$sField = implode('<br/>', $oLinkSet->GetLabels());
} else {
$sField = $oObj->GetEditValue($sAttCode);
}
$sData .= "<td x:str>$sField</td>";
}
else {
$rawValue = $oObj->Get($sAttCode);
if ($this->bLocalizeOutput) {
Expand Down
4 changes: 4 additions & 0 deletions sources/Core/AttributeDefinition/AttributeLinkedSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ public function EnumTemplateVerbs()
return array(
'' => 'Plain text (unlocalized) representation',
'html' => 'HTML representation (unordered list)',
'csv' => 'CSV representation (unordered list)',
);
}

Expand Down Expand Up @@ -479,6 +480,9 @@ public function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize =
case 'html':
return '<ul><li>'.implode("</li><li>", $aNames).'</li></ul>';

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));
}
Expand Down