From 5878b18b02f05723202bd72e05a32d9fbe3a6586 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Mon, 12 Apr 2021 10:21:28 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03921=20-=20Attribute=20file:=20Simplify?= =?UTF-8?q?=20size=20format=20in=20the=20backoffice=20(similar=20to=20the?= =?UTF-8?q?=20portal)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/cmdbchangeop.class.inc.php | 17 ++++++----------- core/ormdocument.class.inc.php | 3 ++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/core/cmdbchangeop.class.inc.php b/core/cmdbchangeop.class.inc.php index d9021c061..02dbd41f9 100644 --- a/core/cmdbchangeop.class.inc.php +++ b/core/cmdbchangeop.class.inc.php @@ -436,24 +436,19 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute $oMonoObjectSet = new DBObjectSet($oTargetSearch); if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES) { - if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) - { + if (MetaModel::IsValidAttCode($this->Get('objclass'), $this->Get('attcode'))) { $oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode')); $sAttName = $oAttDef->GetLabel(); - } - else - { + } else { // The attribute was renamed or removed from the object ? $sAttName = $this->Get('attcode'); } + /** @var \ormDocument $oPrevDoc */ $oPrevDoc = $this->Get('prevdata'); - if ($oPrevDoc->IsEmpty()) - { + if ($oPrevDoc->IsEmpty()) { $sPrevious = ''; $sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sPrevious); - } - else - { + } else { $sFieldAsHtml = $oPrevDoc->GetAsHTML(); $sDisplayLabel = Dict::S('UI:OpenDocumentInNewWindow_'); @@ -463,7 +458,7 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute $sDownloadUrl = $oPrevDoc->GetDownloadURL(get_class($this), $this->GetKey(), 'prevdata'); $sDocView = << +{$sFieldAsHtml} {$sDisplayLabel} / {$sDownloadLabel} HTML; $sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sDocView); diff --git a/core/ormdocument.class.inc.php b/core/ormdocument.class.inc.php index ed5f16b70..1af6b5c67 100644 --- a/core/ormdocument.class.inc.php +++ b/core/ormdocument.class.inc.php @@ -118,7 +118,8 @@ class ormDocument else { $data = $this->GetData(); - $sResult = htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8').' [ '.$this->GetMimeType().', size: '.strlen($data).' byte(s) ]
'; + $sSize = utils::BytesToFriendlyFormat(strlen($data)); + $sResult = htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8').' ('.$sSize.')
'; } return $sResult; }