From 3d7df7600f9fef18b4925b191ce394ff4dcf9a5d Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Thu, 4 Nov 2021 14:55:53 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B04346=20-=20Restore=20HTML=20metadata=20(?= =?UTF-8?q?data-xxx)=20on=20lists=20in=20the=20backoffice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ajax.render.php | 6 ++++-- sources/Controller/AjaxRenderController.php | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pages/ajax.render.php b/pages/ajax.render.php index e1e5b1117..c5976a16f 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -77,9 +77,11 @@ try switch ($operation) { case 'search_and_refresh': - $oPage->SetContentType('application/json'); + $oPage = new JsonPage(); + // Feeds dataTables directly + $oPage->SetOutputDataOnly(true); $aResult = AjaxRenderController::SearchAndRefresh($sFilter); - $oPage->add(json_encode($aResult)); + $oPage->SetData($aResult); break; case 'search': diff --git a/sources/Controller/AjaxRenderController.php b/sources/Controller/AjaxRenderController.php index b50a6db47..ec36b3b4d 100644 --- a/sources/Controller/AjaxRenderController.php +++ b/sources/Controller/AjaxRenderController.php @@ -14,6 +14,7 @@ use AttributeOneWayPassword; use BinaryExpression; use BulkExport; use BulkExportException; +use cmdbAbstractObject; use CMDBObjectSet; use CMDBSource; use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableSettings; @@ -77,8 +78,20 @@ class AjaxRenderController $aObj[$sAlias."/hyperlink"] = $aObject[$sAlias]->GetHyperlink(); foreach ($aColumnsLoad[$sAlias] as $sAttCode) { $aObj[$sAlias."/".$sAttCode] = $aObject[$sAlias]->GetAsHTML($sAttCode); - $oRawValue = $aObject[$sAlias]->Get($sAttCode); - if (is_scalar($oRawValue)) { + $bExcludeRawValue = false; + // Only retrieve raw (stored) value for simple fields + foreach (cmdbAbstractObject::GetAttDefClassesToExcludeFromMarkupMetadataRawValue() as $sAttDefClassToExclude) + { + $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); + if (is_a($oAttDef, $sAttDefClassToExclude, true)) + { + $bExcludeRawValue = true; + break; + } + } + + if (!$bExcludeRawValue) { + $oRawValue = $aObject[$sAlias]->Get($sAttCode); $aObj[$sAlias."/".$sAttCode."/raw"] = $oRawValue; } }