From 76f98be7165b4aa2ed20d4257f921fe4f9aeba99 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 12 Feb 2024 17:00:20 +0100 Subject: [PATCH] CoverPage: Don't use `StyleWithNonce` for cli interactions --- library/Reporting/Web/Widget/CoverPage.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/library/Reporting/Web/Widget/CoverPage.php b/library/Reporting/Web/Widget/CoverPage.php index 5b95a45..03a27f6 100644 --- a/library/Reporting/Web/Widget/CoverPage.php +++ b/library/Reporting/Web/Widget/CoverPage.php @@ -2,10 +2,12 @@ namespace Icinga\Module\Reporting\Web\Widget; +use Icinga\Application\Icinga; use Icinga\Module\Reporting\Common\Macros; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; use ipl\Web\Compat\StyleWithNonce; +use ipl\Web\Style; class CoverPage extends BaseHtmlElement { @@ -139,7 +141,13 @@ public function setTitle($title) protected function assemble() { if ($this->hasBackgroundImage()) { - $coverPageBackground = (new StyleWithNonce()) + if (Icinga::app()->isWeb()) { + $coverPageBackground = new StyleWithNonce(); + } else { + $coverPageBackground = new Style(); + } + + $coverPageBackground ->setModule('reporting') ->addFor($this, [ 'background-image' => sprintf("url('%s')", Template::getDataUrl($this->getBackgroundImage())) @@ -150,7 +158,13 @@ protected function assemble() $content = Html::tag('div', ['class' => 'cover-page-content']); if ($this->hasColor()) { - $coverPageLogo = (new StyleWithNonce()) + if (Icinga::app()->isWeb()) { + $coverPageLogo = new StyleWithNonce(); + } else { + $coverPageLogo = new Style(); + } + + $coverPageLogo ->setModule('reporting') ->addFor($content, ['color' => $this->getColor()]);