From fa0bb2b466b6266c5f6af7fcec7c20899a85ea25 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 4 Nov 2020 14:25:58 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03203=20-=20Fix=20regression:=20PHP=20not?= =?UTF-8?q?ice=20on=20object=20with=20no=20class=20icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/metamodel.class.php | 3 ++- sources/application/UI/Component/Title/TitleFactory.php | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 452c40aa8..7a6600c74 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -927,7 +927,8 @@ abstract class MetaModel { self::_check_subclass($sClass); - return self::$m_aClassParams[$sClass]["image_attcode"]; + // image_attcode isn't a mandatory class parameter, so it might not be in the $m_aClassParam array + return isset(self::$m_aClassParams[$sClass]["image_attcode"]) ? self::$m_aClassParams[$sClass]["image_attcode"] : ''; } /** diff --git a/sources/application/UI/Component/Title/TitleFactory.php b/sources/application/UI/Component/Title/TitleFactory.php index 14d3db57c..37123bca1 100644 --- a/sources/application/UI/Component/Title/TitleFactory.php +++ b/sources/application/UI/Component/Title/TitleFactory.php @@ -32,8 +32,8 @@ class TitleFactory $sObjIconUrl = $oObject->GetIcon(false); // Note: Class icons are a square image with no margin around, so they need to be zoomed out in the medallion $sIconCoverMethod = Title::ENUM_ICON_COVER_METHOD_ZOOMOUT; - // - Use object image from seantic attribute only if it's not the default image - if(!$oObject->IsNew()){ + // - Use object image from semantic attribute only if it's not the default image + if(!$oObject->IsNew() && MetaModel::HasImageAttributeCode($sObjClass)){ $sImageAttCode = MetaModel::GetImageAttributeCode($sObjClass); if(!empty($sImageAttCode)){ /** @var \ormDocument $oImage */ @@ -47,7 +47,10 @@ class TitleFactory } $oTitle = new TitleForObjectDetails($sObjClassName, $sObjName, $sId); - $oTitle->SetIcon($sObjIconUrl, $sIconCoverMethod); + + if(!empty($sObjIconUrl)) { + $oTitle->SetIcon($sObjIconUrl, $sIconCoverMethod); + } $sStatusAttCode = MetaModel::GetStateAttributeCode($sObjClass); if (!empty($sStatusAttCode)) {