From cb826f10883ed8d09aee922493617927e43f5948 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Fri, 15 Sep 2023 16:11:39 +0200 Subject: [PATCH] Change no data page logic according to core changes (#684) * Adjustments according to core changes * Moved SPA/PWA class to TagManager * apply some review feedback --- SiteContentDetection/SpaPwa.php | 54 +++++++++++++++++++++++++++++++++ TagManager.php | 19 +++++------- templates/trackingSPA.twig | 7 ++++- 3 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 SiteContentDetection/SpaPwa.php diff --git a/SiteContentDetection/SpaPwa.php b/SiteContentDetection/SpaPwa.php new file mode 100644 index 000000000..9af2063aa --- /dev/null +++ b/SiteContentDetection/SpaPwa.php @@ -0,0 +1,54 @@ +action = Piwik::getAction(); + $view->showContainerRow = $model->getNumContainersTotal() > 1; + return $view->render(); + } +} diff --git a/TagManager.php b/TagManager.php index 8a5d36939..17601af59 100644 --- a/TagManager.php +++ b/TagManager.php @@ -61,6 +61,7 @@ public function registerEvents() 'SitesManager.addSite.end' => 'onSiteAdded', 'System.addSystemSummaryItems' => 'addSystemSummaryItems', 'Template.endTrackingCodePage' => 'addTagManagerCode', + 'Template.siteWithoutDataTab.MatomoTagManager.content' => 'setTagManagerCode', 'Template.endTrackingHelpPage' => 'addTagManagerTrackingCodeHelp', 'Template.endTrackingCodePageTableOfContents' => 'endTrackingCodePageTableOfContents', 'Tracker.PageUrl.getQueryParametersToExclude' => 'getQueryParametersToExclude', @@ -69,8 +70,7 @@ public function registerEvents() 'Access.Capability.addCapabilities' => 'addCapabilities', 'TwoFactorAuth.requiresTwoFactorAuthentication' => 'requiresTwoFactorAuthentication', 'Db.getTablesInstalled' => 'getTablesInstalled', - 'Template.embedReactTagManagerTrackingCode' => 'embedReactTagManagerTrackingCode', - 'Template.embedSPATagManagerTrackingCode' => 'embedSPATagManagerTrackingCode', + 'Template.siteWithoutDataTab.ReactJs.content' => 'embedReactTagManagerTrackingCode', ); } @@ -271,21 +271,18 @@ public function addTagManagerCode(&$out) $out .= $view->render(); } - public function embedReactTagManagerTrackingCode(&$out) + public function setTagManagerCode(&$out) { - Piwik::checkUserHasSomeViewAccess(); - $model = $this->getContainerModel(); - $view = new View("@TagManager/trackingCodeReact"); - $view->action = Piwik::getAction(); - $view->showContainerRow = $model->getNumContainersTotal() > 1; - $out .= $view->render(); + $newContent = ''; + $this->addTagManagerCode($newContent); + $out = $newContent; } - public function embedSPATagManagerTrackingCode(&$out) + public function embedReactTagManagerTrackingCode(&$out) { Piwik::checkUserHasSomeViewAccess(); $model = $this->getContainerModel(); - $view = new View("@TagManager/trackingSPA"); + $view = new View("@TagManager/trackingCodeReact"); $view->action = Piwik::getAction(); $view->showContainerRow = $model->getNumContainersTotal() > 1; $out .= $view->render(); diff --git a/templates/trackingSPA.twig b/templates/trackingSPA.twig index e02536d92..02e2d0c5f 100644 --- a/templates/trackingSPA.twig +++ b/templates/trackingSPA.twig @@ -1,6 +1,11 @@ +

{{ 'SitesManager_SiteWithoutDataSPADescription'|translate('', '', '', '')|raw }}

+
+

{{ 'SitesManager_SiteWithoutDataCloudflareFollowStepsIntro'|translate }}

-
\ No newline at end of file + +
+

{{ 'SitesManager_SiteWithoutDataSPAFollowStepCompleted'|translate('','')|raw }}

\ No newline at end of file