From a206af1813f69330b47a304d1ff4ed4ffa8de521 Mon Sep 17 00:00:00 2001 From: Benjamin Dalsass Date: Mon, 26 Jun 2023 15:11:41 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06005=20-=20CSV=20import=20:=20import=20a?= =?UTF-8?q?n=20object=20and=20a=20linkset=20fails=20-=20Restore=20old=20ge?= =?UTF-8?q?t=20as=20html=20for=20linked=20set=20with=20display=20style=20t?= =?UTF-8?q?ab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/attributedef.class.inc.php | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index a148522fc9..8751a0d042 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -1772,7 +1772,53 @@ class AttributeLinkedSet extends AttributeDefinition } /** @inheritDoc * */ - public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true): string + public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true) + { + if($this->GetDisplayStyle() === LINKSET_DISPLAY_STYLE_TAB){ + return $this->GetAsHTMLForTab($sValue, $oHostObject, $bLocalize); + } + else{ + return $this->GetAsHTMLForProperty($sValue, $oHostObject, $bLocalize); + } + } + + public function GetAsHTMLForTab($sValue, $oHostObject = null, $bLocalize = true) + { + if (is_object($sValue) && ($sValue instanceof ormLinkSet)) + { + $sValue->Rewind(); + $aItems = array(); + while ($oObj = $sValue->Fetch()) + { + // Show only relevant information (hide the external key to the current object) + $aAttributes = array(); + foreach(MetaModel::ListAttributeDefs($this->GetLinkedClass()) as $sAttCode => $oAttDef) + { + if ($sAttCode == $this->GetExtKeyToMe()) + { + continue; + } + if ($oAttDef->IsExternalField()) + { + continue; + } + $sAttValue = $oObj->GetAsHTML($sAttCode); + if (strlen($sAttValue) > 0) + { + $aAttributes[] = $sAttValue; + } + } + $sAttributes = implode(', ', $aAttributes); + $aItems[] = $sAttributes; + } + + return implode('
', $aItems); + } + + return null; + } + + public function GetAsHTMLForProperty($sValue, $oHostObject = null, $bLocalize = true): string { try {