From 8530db347bfe08a2fd5b5dfca712138d2382cdcd Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 21 Nov 2018 17:35:33 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B01788=20Portal:=20Fix=20regression,=20ico?= =?UTF-8?q?ns=20not=20displayed=20in=20service=20catalog=20(introduced=20i?= =?UTF-8?q?n=20ab1715ed)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../browsebrickcontroller.class.inc.php | 64 ++++++++++++------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php index 449ad8d56..6d98cad1a 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php @@ -24,6 +24,7 @@ use Symfony\Component\HttpFoundation\Request; use UserRights; use Dict; use MetaModel; +use AttributeImage; use DBSearch; use DBObjectSet; use BinaryExpression; @@ -633,18 +634,30 @@ class BrowseBrickController extends BrickController $sPropertyName = substr($sOptionalAttribute, 0, -4); $oAttDef = MetaModel::GetAttributeDef(get_class($value), $aLevelsProperties[$key][$sOptionalAttribute]); - $tmpAttValue = $value->GetAsHTML($aLevelsProperties[$key][$sOptionalAttribute]); - if($sOptionalAttribute === 'image_att') - { - if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) - { - $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($value), 'sObjectId' => $value->GetKey(), 'sObjectField' => $aLevelsProperties[$key][$sOptionalAttribute], 'cache' => 86400)); - } - else - { - $tmpAttValue = $oAttDef->Get('default_image'); - } - } + if($oAttDef instanceof AttributeImage) + { + $tmpAttValue = $value->Get($aLevelsProperties[$key][$sOptionalAttribute]); + if ($sOptionalAttribute === 'image_att') + { + if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) + { + $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array( + 'sObjectClass' => get_class($value), + 'sObjectId' => $value->GetKey(), + 'sObjectField' => $aLevelsProperties[$key][$sOptionalAttribute], + 'cache' => 86400 + )); + } + else + { + $tmpAttValue = $oAttDef->Get('default_image'); + } + } + } + else + { + $tmpAttValue = $value->GetAsHTML($aLevelsProperties[$key][$sOptionalAttribute]); + } $aRow[$key][$sPropertyName] = $tmpAttValue; } @@ -726,17 +739,24 @@ class BrowseBrickController extends BrickController $sPropertyName = substr($sOptionalAttribute, 0, -4); $oAttDef = MetaModel::GetAttributeDef(get_class($aCurrentRowValues[0]), $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); - $tmpAttValue = $aCurrentRowValues[0]->GetAsHTML($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); - if($sOptionalAttribute === 'image_att') + if($oAttDef instanceof AttributeImage) { - if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) - { - $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($aCurrentRowValues[0]), 'sObjectId' => $aCurrentRowValues[0]->GetKey(), 'sObjectField' => $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute], 'cache' => 86400)); - } - else - { - $tmpAttValue = $oAttDef->Get('default_image'); - } + $tmpAttValue = $aCurrentRowValues[0]->Get($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); + if($sOptionalAttribute === 'image_att') + { + if (is_object($tmpAttValue) && !$tmpAttValue->IsEmpty()) + { + $tmpAttValue = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($aCurrentRowValues[0]), 'sObjectId' => $aCurrentRowValues[0]->GetKey(), 'sObjectField' => $aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute], 'cache' => 86400)); + } + else + { + $tmpAttValue = $oAttDef->Get('default_image'); + } + } + } + else + { + $tmpAttValue = $aCurrentRowValues[0]->GetAsHTML($aLevelsProperties[$aCurrentRowKeys[0]][$sOptionalAttribute]); } $aItems[$sCurrentIndex][$sPropertyName] = $tmpAttValue;