From 238cbe4d7038ad622b339c6a78f9e0ee7135e194 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Fri, 8 Apr 2022 05:41:31 +0200 Subject: Removes some useless code (#19035) --- plugins/Ecommerce/Controller.php | 65 +++++++++----------------- plugins/Ecommerce/templates/getSparklines.twig | 5 +- 2 files changed, 24 insertions(+), 46 deletions(-) diff --git a/plugins/Ecommerce/Controller.php b/plugins/Ecommerce/Controller.php index 739e051f70..e218d9c38c 100644 --- a/plugins/Ecommerce/Controller.php +++ b/plugins/Ecommerce/Controller.php @@ -1,11 +1,13 @@ translator = $translator; - parent::__construct($translator, $translationHelper); + parent::__construct($translator); } public function getSparklines() { - $idGoal = Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER; - $view = new View('@Ecommerce/getSparklines'); - $view->onlyConversionOverview = false; - $view->conversionsOverViewEnabled = true; - - if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) { - $goalDefinition['name'] = $this->translator->translate('Goals_Ecommerce'); - $goalDefinition['allow_multiple'] = true; - } else { - $goals = Request::processRequest('Goals.getGoals', ['idSite' => $this->idSite, 'filter_limit' => '-1'], $default = []); - if (!isset($goals[$idGoal])) { - Piwik::redirectToModule('Goals', 'index', array('idGoal' => null)); - } - $goalDefinition = $goals[$idGoal]; - } $this->setGeneralVariablesView($view); - $goal = $this->getMetricsForGoal($idGoal); + $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER); foreach ($goal as $name => $value) { $view->$name = $value; } - if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) { - $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART); - foreach ($goal as $name => $value) { - $name = 'cart_' . $name; - $view->$name = $value; - } + $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART); + foreach ($goal as $name => $value) { + $name = 'cart_' . $name; + $view->$name = $value; } - $view->idGoal = $idGoal; - $view->goalAllowMultipleConversionsPerVisit = $goalDefinition['allow_multiple']; - return $view->render(); } public function getConversionsOverview() { - $view = new View('@Ecommerce/conversionOverview'); - $idGoal = Common::getRequestVar('idGoal', null, 'string'); - $period = Common::getRequestVar('period', null, 'string'); + $view = new View('@Ecommerce/conversionOverview'); + $idGoal = Common::getRequestVar('idGoal', null, 'string'); + $period = Common::getRequestVar('period', null, 'string'); $segment = Common::getRequestVar('segment', '', 'string'); - $date = Common::getRequestVar('date', '', 'string'); + $date = Common::getRequestVar('date', '', 'string'); $goalMetrics = Request::processRequest('Goals.get', [ 'idGoal' => $idGoal, @@ -87,14 +68,15 @@ class Controller extends \Piwik\Plugins\Goals\Controller 'date' => $date, 'period' => $period, 'segment' => Common::unsanitizeInputValue($segment), - 'filter_limit' => '-1' + 'filter_limit' => '-1', ], $default = []); $dataRow = $goalMetrics->getFirstRow(); - $view->visitorLogEnabled = Manager::getInstance()->isPluginActivated('Live') && Live::isVisitorLogEnabled($this->idSite); - $view->idSite = $this->idSite; - $view->idGoal = $idGoal; + $view->visitorLogEnabled = Manager::getInstance()->isPluginActivated('Live') + && Live::isVisitorLogEnabled($this->idSite); + $view->idSite = $this->idSite; + $view->idGoal = $idGoal; if ($dataRow) { $view->revenue = $dataRow->getColumn('revenue'); @@ -109,7 +91,7 @@ class Controller extends \Piwik\Plugins\Goals\Controller public function getEcommerceLog($fetch = false) { - $saveGET = $_GET; + $saveGET = $_GET; $originalQuery = $_SERVER['QUERY_STRING']; if (!empty($_GET['segment'])) { @@ -119,12 +101,11 @@ class Controller extends \Piwik\Plugins\Goals\Controller } $_SERVER['QUERY_STRING'] = Http::buildQuery($_GET); - $_GET['widget'] = 1; - $output = FrontController::getInstance()->dispatch('Live', 'getVisitorLog', array($fetch)); - $_GET = $saveGET; + $_GET['widget'] = 1; + $output = FrontController::getInstance()->dispatch('Live', 'getVisitorLog', [$fetch]); + $_GET = $saveGET; $_SERVER['QUERY_STRING'] = $originalQuery; return $output; } - } diff --git a/plugins/Ecommerce/templates/getSparklines.twig b/plugins/Ecommerce/templates/getSparklines.twig index 67dc12d006..37f12b3d2d 100644 --- a/plugins/Ecommerce/templates/getSparklines.twig +++ b/plugins/Ecommerce/templates/getSparklines.twig @@ -5,10 +5,7 @@ {{ nb_conversions|number }} {{ 'General_EcommerceOrders'|translate }} - - {% if goalAllowMultipleConversionsPerVisit is defined and goalAllowMultipleConversionsPerVisit %} - ({{ 'General_NVisits'|translate(""~nb_visits_converted~"")|raw }}) - {% endif %} + ({{ 'General_NVisits'|translate(""~nb_visits_converted~"")|raw }}) -- cgit v1.2.3