mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°9347 - Get Software logo as SoftwareInstance icon
This commit is contained in:
@@ -2210,7 +2210,40 @@
|
|||||||
</items>
|
</items>
|
||||||
</list>
|
</list>
|
||||||
</presentation>
|
</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>
|
||||||
<class id="Middleware" _delta="define">
|
<class id="Middleware" _delta="define">
|
||||||
<parent>SoftwareInstance</parent>
|
<parent>SoftwareInstance</parent>
|
||||||
|
|||||||
Reference in New Issue
Block a user