From 4b731dd336c7305bd0902feba0813751d2f1155f Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 22 Feb 2022 10:16:36 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B04836=20Better=20fix=20by=20adding=20Ajax?= =?UTF-8?q?Page::SetOutputDataOnly()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ajax.render.php | 3 +- sources/application/WebPage/AjaxPage.php | 41 ++++++++++++++++++------ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/pages/ajax.render.php b/pages/ajax.render.php index d5d909200..cf626e200 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -1060,7 +1060,8 @@ EOF $iCol = utils::ReadParam("iCol"); $sDashletIdOrig = utils::ReadParam("dashletid"); $sFinalDashletId = Dashboard::GetDashletUniqueId($bIsCustomized, $sDashboardDivId, $iRow, $iCol, $sDashletIdOrig); - $oPage = new DownloadPage(''); + $oPage = new AjaxPage(''); + $oPage->SetOutputDataOnly(true); $oPage->add($sFinalDashletId); break; diff --git a/sources/application/WebPage/AjaxPage.php b/sources/application/WebPage/AjaxPage.php index 778a269b2..e046765d7 100644 --- a/sources/application/WebPage/AjaxPage.php +++ b/sources/application/WebPage/AjaxPage.php @@ -25,10 +25,17 @@ class AjaxPage extends WebPage implements iTabbedPage /** @var string */ private $sPromiseId; + /** + * @var bool if false will also output extra JS & CSS + * @since 3.0.1 3.1.0 N°4836 Introduce this new option to AjaxPage, as sometimes we only need to return a simple string + */ + protected $bOutputDataOnly = false; + /** * constructor for the web page * * @param string $s_title Not used + * @param bool $bOutputExtraResources if true will output also JS & CSS resources */ function __construct($s_title) { @@ -50,6 +57,21 @@ class AjaxPage extends WebPage implements iTabbedPage $oKpi->ComputeStats(get_class($this).' creation', 'AjaxPage'); } + /** + * @see static::$bOutputDataOnly + * @param bool $bFlag + * + * @return $this + * + * @since 3.0.1 3.1.0 N°4836 Method creation : sometimes we only want to output a simple string + */ + public function SetOutputDataOnly(bool $bFlag) + { + $this->bOutputDataOnly = $bFlag; + + return $this; + } + /** * @inheritDoc * @throws \Exception @@ -162,18 +184,19 @@ class AjaxPage extends WebPage implements iTabbedPage header($s_header); } - // Prepare internal parts (js files, css files, js snippets, css snippets, ...) - // - Generate necessary dict. files - if ($this->bAddJSDict) { - $this->output_dict_entries(); + if (false === $this->bOutputDataOnly) { + // Prepare internal parts (js files, css files, js snippets, css snippets, ...) + // - Generate necessary dict. files + if ($this->bAddJSDict) { + $this->output_dict_entries(); + } + + ConsoleBlockRenderer::AddCssJsToPage($this, $this->oContentLayout); + + $this->outputCollapsibleSectionInit(); } - ConsoleBlockRenderer::AddCssJsToPage($this, $this->oContentLayout); - // Render the blocks - - $this->outputCollapsibleSectionInit(); - $aData = []; $aData['oLayout'] = $this->oContentLayout; $aData['aDeferredBlocks'] = $this->GetDeferredBlocks($this->oContentLayout);