blob: 1e761a0aae0d4504e1cefc0a7ccc4e07e6344d44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
* @package Piwik_CoreHome
*/
/**
* MULTI ROW EVOLUTION
* The class handles the popover that shows the evolution of a multiple rows in a data table
* @package Piwik_CoreHome
*/
class Piwik_CoreHome_DataTableRowAction_MultiRowEvolution
extends Piwik_CoreHome_DataTableRowAction_RowEvolution
{
const IS_MULTI_EVOLUTION_PARAM = 'is_multi_evolution';
/** The requested metric */
protected $metric;
/** Show all metrics in the evolution graph when the popover opens */
protected $initiallyShowAllMetrics = true;
/** The metrics available in the metrics select */
protected $metricsForSelect;
/**
* The constructor
* @param int
* @param Piwik_Date ($this->date from controller)
*/
public function __construct($idSite, $date)
{
$this->metric = Piwik_Common::getRequestVar('column', '', 'string');
parent::__construct($idSite, $date);
}
protected function loadEvolutionReport($column = false)
{
// set the "column" parameter for the API.getRowEvolution call
parent::loadEvolutionReport($this->metric);
}
protected function extractEvolutionReport($report)
{
$this->metric = $report['column'];
$this->dataTable = $report['reportData'];
$this->availableMetrics = $report['metadata']['metrics'];
$this->metricsForSelect = $report['metadata']['columns'];
$this->dimension = $report['metadata']['dimension'];
}
/**
* Render the popover
* @param Piwik_CoreHome_Controller
* @param Piwik_View (the popover_rowevolution template)
*/
public function renderPopover($controller, $view)
{
// add data for metric select box
$view->availableMetrics = $this->metricsForSelect;
$view->selectedMetric = $this->metric;
$view->availableRecordsText = $this->dimension . ': '
. Piwik_Translate('RowEvolution_ComparingRecords', array(count($this->availableMetrics)));
return parent::renderPopover($controller, $view);
}
/**
* Generic method to get an evolution graph or a sparkline for the row evolution popover.
* Do as much as possible from outside the controller.
*
* @return Piwik_ViewDataTable
*/
public function getRowEvolutionGraph()
{
$view = parent::getRowEvolutionGraph();
$view->setCustomParameter(self::IS_MULTI_EVOLUTION_PARAM, 1); // set in JS
return $view;
}
}
|