N°9347 - Get Software logo as SoftwareInstance icon

This commit is contained in:
v-dumas
2026-03-13 15:40:42 +01:00
parent a810f3b79f
commit 7aaf3da4d5

View File

@@ -2210,7 +2210,40 @@
</items>
</list>
</presentation>
<methods/>
<methods>
<method id="GetIcon">
<comment> /**
* Overrides the GetIcon method to return the logo of the associated Software if any, otherwise the default icon of the class will be returned
*
*/</comment>
<static>false</static>
<access>public</access>
<type>Custom</type>
<code><![CDATA[ public function GetIcon($bImgTag = true)
{
// If there is an image defined on the associated Software, we use it
$sIconClass = 'Software'; // the class storing the image which will be used as icon for the current object
$sExtKeyCode = 'software_id'; // the attribute code pointing to the class having the image to display
$sIconAttCode = 'logo'; // the attribute code of the image to display on the IconClass
$iObj = $this->Get($sExtKeyCode);
if ($iObj > 0) {
$oObj = MetaModel::GetObject($sIconClass, $iObj, true, true);
$oImage = $oObj->Get($sIconAttCode);
$sIconUrl = $oImage->IsEmpty() ? '' : $oImage->GetDisplayURL($sIconClass, $iObj, $sIconAttCode);
if (strlen($sIconUrl) > 0) {
if ($bImgTag) {
return "<img src=\"$sIconUrl\" alt=''/>";
} else {
return $sIconUrl;
}
}
}
// Return the default image
return parent::GetIcon($bImgTag);
}]]></code>
</method>
</methods>
</class>
<class id="Middleware" _delta="define">
<parent>SoftwareInstance</parent>