mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-18 16:18:47 +02:00
N°9347 - Make the icon of ContainerImages using the one of Software class
This commit is contained in:
@@ -92,7 +92,40 @@
|
||||
<duplicates/>
|
||||
</field>
|
||||
</fields>
|
||||
<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>
|
||||
<presentation>
|
||||
<list>
|
||||
<items>
|
||||
|
||||
Reference in New Issue
Block a user