mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°3203 - Datamodel: Add semantic for image & state attributes Part. I
This commit is contained in:
@@ -23,13 +23,31 @@ class TitleFactory
|
||||
public static function MakeForObjectDetails(DBObject $oObject, ?string $sId = null)
|
||||
{
|
||||
// TODO 3.0.0: Refactor all of this
|
||||
$sObjIconUrl = $oObject->GetIcon(false);
|
||||
$sObjClass = get_class($oObject);
|
||||
$sObjClassName = MetaModel::GetName($sObjClass);
|
||||
$sObjName = $oObject->GetName();
|
||||
|
||||
// Object icon
|
||||
// - Default icon is the class icon
|
||||
$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()){
|
||||
$sImageAttCode = MetaModel::GetImageAttributeCode($sObjClass);
|
||||
if(!empty($sImageAttCode)){
|
||||
/** @var \ormDocument $oImage */
|
||||
$oImage = $oObject->Get($sImageAttCode);
|
||||
if(!$oImage->IsEmpty()){
|
||||
$sObjIconUrl = $oImage->GetDisplayURL($sObjClass, $oObject->GetKey(), $sImageAttCode);
|
||||
$sIconCoverMethod = Title::ENUM_ICON_COVER_METHOD_COVER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$oTitle = new TitleForObjectDetails($sObjClassName, $sObjName, $sId);
|
||||
$oTitle->SetIcon($sObjIconUrl);
|
||||
$oTitle->SetIcon($sObjIconUrl, $sIconCoverMethod);
|
||||
|
||||
$sStatusAttCode = MetaModel::GetStateAttributeCode($sObjClass);
|
||||
if (!empty($sStatusAttCode)) {
|
||||
|
||||
Reference in New Issue
Block a user