Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhang <peter@innocraft.com>2021-12-20 06:50:39 +0300
committerPeter Zhang <peter@innocraft.com>2021-12-20 06:50:39 +0300
commitd5997bd1dd1218c09d8369b880a732af2c69e685 (patch)
tree2e1aa83638ea28b02b99356df1f865a3854a4bc1 /plugins/Goals
parentb3043977fdf4d0c97005220ba807e56443700e16 (diff)
Revert "Revert "convert sparkline api to one request - fixes archive (#18493)""
This reverts commit b3043977fdf4d0c97005220ba807e56443700e16.
Diffstat (limited to 'plugins/Goals')
-rw-r--r--plugins/Goals/API.php2
-rw-r--r--plugins/Goals/Controller.php27
-rw-r--r--plugins/Goals/Pages.php23
-rw-r--r--plugins/Goals/Reports/Get.php4
-rw-r--r--plugins/Goals/Reports/GetMetrics.php8
-rw-r--r--plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png4
6 files changed, 48 insertions, 20 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index ba67f6aa1d..fe69afa1ce 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 02f8ee5c9e..fd7ddc109a 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\Goals;
+use Piwik\API\Proxy;
use Piwik\API\Request;
use Piwik\Common;
use Piwik\DataTable;
@@ -16,10 +17,13 @@ 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;
/**
*
@@ -219,6 +223,29 @@ 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 6b105bfb9a..59ebb7b19d 100644
--- a/plugins/Goals/Pages.php
+++ b/plugins/Goals/Pages.php
@@ -54,23 +54,18 @@ class Pages
$config->setSubcategoryId($subcategory);
$config->setName('');
$config->setOrder(15);
+ $config->setModule('Goals');
+ $config->setAction('getMetrics');
$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;
- }
+ // load sparkline
+ $config = $this->factory->createCustomWidget('getSparklines');
+ $config->setSubcategoryId($subcategory);
+ $config->setName('');
+ $config->setOrder(25);
+ $config->setIsNotWidgetizable();
+ $widgets[] = $config;
$container = $this->createWidgetizableWidgetContainer('GoalsOverview', $subcategory, $widgets);
diff --git a/plugins/Goals/Reports/Get.php b/plugins/Goals/Reports/Get.php
index c29bdf4426..445f6fd1cc 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 32cb019800..bf2d1c3ac8 100644
--- a/plugins/Goals/Reports/GetMetrics.php
+++ b/plugins/Goals/Reports/GetMetrics.php
@@ -10,8 +10,10 @@ 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 Base
+class GetMetrics extends Get
{
protected function init()
{
@@ -26,6 +28,10 @@ class GetMetrics extends Base
$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 9addb5c878..500b46f795 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:47f4954791162c63495b422e2bbf6eef330cd819ecb3f4490d0edc7dc7b9cbca
-size 164421
+oid sha256:d67025f70426ce81442c1fd0fc4ed2da51d0209fb4882863dc2b21009efa2d46
+size 163865