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:
authorThomas Steur <thomas.steur@googlemail.com>2014-03-06 08:26:25 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-03-06 08:26:25 +0400
commitad9ab5d884bab393467b4b9140e3460f99b46f8b (patch)
treeb1a2a236fe65f6a4a3cebf3ad45879d880c58293 /plugins/Insights/Visualizations
parent593dbc8e0e8e521e17e1c784c2d6d4debbbc510b (diff)
refs #57 more tweaks to insights and movers and shakers and more tests
Diffstat (limited to 'plugins/Insights/Visualizations')
-rw-r--r--plugins/Insights/Visualizations/Insight.php46
-rw-r--r--plugins/Insights/Visualizations/Insight/Config.php17
2 files changed, 30 insertions, 33 deletions
diff --git a/plugins/Insights/Visualizations/Insight.php b/plugins/Insights/Visualizations/Insight.php
index 24d4ebd244..6853776cca 100644
--- a/plugins/Insights/Visualizations/Insight.php
+++ b/plugins/Insights/Visualizations/Insight.php
@@ -14,12 +14,12 @@ use Piwik\DataTable;
use Piwik\Period\Range;
use Piwik\Plugin\ViewDataTable;
use Piwik\Plugin\Visualization;
+use Piwik\Plugins\Insights\API;
use Piwik\Plugins\Insights\Model;
/**
* InsightsVisualization Visualization.
*
- * @property Insight\Config $config
* @property Insight\RequestConfig $requestConfig
*/
class Insight extends Visualization
@@ -31,6 +31,10 @@ class Insight extends Visualization
public function beforeLoadDataTable()
{
+ if (!self::canDisplayViewDataTable($this)) {
+ return;
+ }
+
$report = $this->requestConfig->apiMethodToRequestDataTable;
$report = str_replace('.', '_', $report);
@@ -64,11 +68,6 @@ class Insight extends Visualization
);
}
- public static function getDefaultConfig()
- {
- return new Insight\Config();
- }
-
public static function getDefaultRequestConfig()
{
return new Insight\RequestConfig();
@@ -81,14 +80,34 @@ class Insight extends Visualization
public function beforeRender()
{
- $this->assignTemplateVar('period', Common::getRequestVar('period', null, 'string'));
-
$this->config->datatable_js_type = 'InsightsDataTable';
$this->config->show_limit_control = true;
$this->config->show_pagination_control = false;
$this->config->show_offset_information = false;
$this->config->show_search = false;
- $this->config->title = 'Insights of ' . $this->config->title;
+
+ if (!self::canDisplayViewDataTable($this)) {
+ $this->assignTemplateVar('cannotDisplayReport', true);
+ return;
+ }
+
+ $period = Common::getRequestVar('period', null, 'string');
+ $date = Common::getRequestVar('date', null, 'string');
+ $idSite = Common::getRequestVar('idSite', null, 'string');
+ $segment = Common::getRequestVar('segment', false, 'string');
+
+ $this->assignTemplateVar('period', $period);
+
+ $reportId = $this->requestConfig->request_parameters_to_modify['reportUniqueId'];
+ $comparedToXPeriods = $this->requestConfig->compared_to_x_periods_ago;
+ $limitIncreaser = min($this->requestConfig->request_parameters_to_modify['limitIncreaser'], 2);
+ $limitDecreaser = min($this->requestConfig->request_parameters_to_modify['limitDecreaser'], 2);
+
+ $shaker = API::getInstance()->getMoversAndShakers(
+ $idSite, $period, $date, $reportId, $segment, $comparedToXPeriods, $limitIncreaser, $limitDecreaser
+ );
+
+ $this->assignTemplateVar('shaker', $shaker);
}
public static function canDisplayViewDataTable(ViewDataTable $view)
@@ -96,14 +115,9 @@ class Insight extends Visualization
$period = Common::getRequestVar('period', null, 'string');
$date = Common::getRequestVar('date', null, 'string');
- try {
- $model = new Model();
- $lastDate = $model->getLastDate($date, $period, 1);
- } catch (\Exception $e) {
- return false;
- }
+ $canGenerateInsights = API::getInstance()->canGenerateInsights($period, $date);
- if (empty($lastDate)) {
+ if (!$canGenerateInsights) {
return false;
}
diff --git a/plugins/Insights/Visualizations/Insight/Config.php b/plugins/Insights/Visualizations/Insight/Config.php
deleted file mode 100644
index 327572aaf4..0000000000
--- a/plugins/Insights/Visualizations/Insight/Config.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- */
-
-namespace Piwik\Plugins\Insights\Visualizations\Insight;
-
-use Piwik\ViewDataTable\Config as VisualizationConfig;
-
-class Config extends VisualizationConfig
-{
- public $show_filter_by = true;
-}