diff options
author | Peter Zhang <peter@innocraft.com> | 2021-12-20 06:43:49 +0300 |
---|---|---|
committer | Peter Zhang <peter@innocraft.com> | 2021-12-20 06:43:49 +0300 |
commit | b3043977fdf4d0c97005220ba807e56443700e16 (patch) | |
tree | 111a91ecda67300f5c05115c8c0269800805382a /plugins/Goals | |
parent | 71ad61f59750d613eccc8f6fe1eca586a61763d2 (diff) |
Revert "convert sparkline api to one request - fixes archive (#18493)"
This reverts commit 36f83c1468d3ba7bb74a1a755c804f4df21ad78e.
Diffstat (limited to 'plugins/Goals')
-rw-r--r-- | plugins/Goals/API.php | 2 | ||||
-rw-r--r-- | plugins/Goals/Controller.php | 27 | ||||
-rw-r--r-- | plugins/Goals/Pages.php | 23 | ||||
-rw-r--r-- | plugins/Goals/Reports/Get.php | 4 | ||||
-rw-r--r-- | plugins/Goals/Reports/GetMetrics.php | 8 | ||||
-rw-r--r-- | plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png | 4 |
6 files changed, 20 insertions, 48 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php index fe69afa1ce..ba67f6aa1d 100644 --- a/plugins/Goals/API.php +++ b/plugins/Goals/API.php @@ -67,7 +67,7 @@ class API extends \Piwik\Plugin\API public function getGoal($idSite, $idGoal) { Piwik::checkUserHasViewAccess($idSite); - + $goal = $this->getModel()->getActiveGoal($idSite, $idGoal); if (!empty($goal)) { diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index fd7ddc109a..02f8ee5c9e 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -8,7 +8,6 @@ */ namespace Piwik\Plugins\Goals; -use Piwik\API\Proxy; use Piwik\API\Request; use Piwik\Common; use Piwik\DataTable; @@ -17,13 +16,10 @@ use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal; use Piwik\FrontController; use Piwik\Piwik; use Piwik\Plugin\Manager; -use Piwik\Plugin\ViewDataTable; -use Piwik\Plugins\CoreVisualizations\Visualizations\Sparklines; use Piwik\Plugins\Live\Live; use Piwik\Plugins\Referrers\API as APIReferrers; use Piwik\Translation\Translator; use Piwik\View; -use Piwik\ViewDataTable\Factory as ViewDataTableFactory; /** * @@ -223,29 +219,6 @@ class Controller extends \Piwik\Plugin\Controller return $this->renderView($view); } - public function getSparklines() - { - $content = ""; - $goals = Request::processRequest('Goals.getGoals', ['idSite' => $this->idSite, 'filter_limit' => '-1'], []); - - foreach ($goals as $goal) { - $params = [ - 'idGoal' => $goal['idgoal'], - 'allow_multiple' => (int) $goal['allow_multiple'], - 'only_summary' => 1, - ]; - - \Piwik\Context::executeWithQueryParameters($params, function() use (&$content) { - //load Visualisations Sparkline - $view = ViewDataTableFactory::build(Sparklines::ID, 'Goals.getMetrics', 'Goals.' . __METHOD__, true); - $view->config->show_title = true; - $content .= $view->render(); - }); - } - - return $content; - } - private function getColumnTranslation($nameToLabel, $columnName, $idGoal) { $columnTranslation = ''; diff --git a/plugins/Goals/Pages.php b/plugins/Goals/Pages.php index 59ebb7b19d..6b105bfb9a 100644 --- a/plugins/Goals/Pages.php +++ b/plugins/Goals/Pages.php @@ -54,18 +54,23 @@ class Pages $config->setSubcategoryId($subcategory); $config->setName(''); $config->setOrder(15); - $config->setModule('Goals'); - $config->setAction('getMetrics'); $config->setIsNotWidgetizable(); $widgets[] = $config; - // load sparkline - $config = $this->factory->createCustomWidget('getSparklines'); - $config->setSubcategoryId($subcategory); - $config->setName(''); - $config->setOrder(25); - $config->setIsNotWidgetizable(); - $widgets[] = $config; + foreach ($goals as $goal) { + $name = Common::sanitizeInputValue($goal['name']); + $goalTranslated = Piwik::translate('Goals_GoalX', array($name)); + + $config = $this->factory->createWidget(); + $config->setName($goalTranslated); + $config->setSubcategoryId($subcategory); + $config->forceViewDataTable(Sparklines::ID); + $config->setParameters(array('idGoal' => $goal['idgoal'])); + $config->setOrder(25); + $config->setIsNotWidgetizable(); + $config->addParameters(array('allow_multiple' => (int) $goal['allow_multiple'], 'only_summary' => '1')); + $widgets[] = $config; + } $container = $this->createWidgetizableWidgetContainer('GoalsOverview', $subcategory, $widgets); diff --git a/plugins/Goals/Reports/Get.php b/plugins/Goals/Reports/Get.php index 445f6fd1cc..c29bdf4426 100644 --- a/plugins/Goals/Reports/Get.php +++ b/plugins/Goals/Reports/Get.php @@ -66,7 +66,7 @@ class Get extends Base if (empty($idSite)) { return; } - + $goals = $this->getGoals(); $reports = Goals::getReportsWithGoalMetrics(); @@ -193,7 +193,7 @@ class Get extends Base } else { $view->config->title = Piwik::translate('General_EvolutionOverPeriod'); } - + if (empty($view->config->columns_to_display)) { $view->config->columns_to_display = array('nb_conversions'); } diff --git a/plugins/Goals/Reports/GetMetrics.php b/plugins/Goals/Reports/GetMetrics.php index bf2d1c3ac8..32cb019800 100644 --- a/plugins/Goals/Reports/GetMetrics.php +++ b/plugins/Goals/Reports/GetMetrics.php @@ -10,10 +10,8 @@ namespace Piwik\Plugins\Goals\Reports; use Piwik\Piwik; use Piwik\Plugins\CoreHome\Columns\Metrics\ConversionRate; -use Piwik\Report\ReportWidgetFactory; -use Piwik\Widget\WidgetsList; -class GetMetrics extends Get +class GetMetrics extends Base { protected function init() { @@ -28,10 +26,6 @@ class GetMetrics extends Get $this->parameters = null; } - public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) - { - } - public function configureReportMetadata(&$availableReports, $infos) { } diff --git a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png index 500b46f795..9addb5c878 100644 --- a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png +++ b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d67025f70426ce81442c1fd0fc4ed2da51d0209fb4882863dc2b21009efa2d46 -size 163865 +oid sha256:47f4954791162c63495b422e2bbf6eef330cd819ecb3f4490d0edc7dc7b9cbca +size 164421 |