diff options
author | Stefan Giehl <stefan@matomo.org> | 2022-04-08 06:41:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 06:41:31 +0300 |
commit | 238cbe4d7038ad622b339c6a78f9e0ee7135e194 (patch) | |
tree | 6f1a70b61c4f84d89e3ff86041fd201af0d2ed99 | |
parent | 6ab9923d6324c3d98765881e525d7ecf8ba9d831 (diff) |
Removes some useless code (#19035)
-rw-r--r-- | plugins/Ecommerce/Controller.php | 65 | ||||
-rw-r--r-- | 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 @@ <?php + /** * Matomo - free/libre analytics platform * - * @link https://matomo.org + * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * */ + namespace Piwik\Plugins\Ecommerce; use Piwik\API\Request; @@ -17,7 +19,6 @@ use Piwik\Plugin\Manager; use Piwik\Plugins\Live\Live; use Piwik\Translation\Translator; use Piwik\View; -use Piwik\Plugins\Goals\TranslationHelper; class Controller extends \Piwik\Plugins\Goals\Controller { @@ -26,60 +27,40 @@ class Controller extends \Piwik\Plugins\Goals\Controller */ private $translator; - public function __construct(Translator $translator, TranslationHelper $translationHelper) + public function __construct(Translator $translator) { $this->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 @@ <strong>{{ nb_conversions|number }}</strong> {{ 'General_EcommerceOrders'|translate }} <img src='plugins/Morpheus/images/ecommerceOrder.png'> - - {% if goalAllowMultipleConversionsPerVisit is defined and goalAllowMultipleConversionsPerVisit %} - ({{ 'General_NVisits'|translate("<strong>"~nb_visits_converted~"</strong>")|raw }}) - {% endif %} + ({{ 'General_NVisits'|translate("<strong>"~nb_visits_converted~"</strong>")|raw }}) </div> </div> |