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

MultiRowEvolution.php « DataTableRowAction « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3594675f41a27c93098b56c233edbb36f07b619f (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
<?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 CoreHome
 */
namespace Piwik\Plugins\CoreHome\DataTableRowAction;

use Piwik\Common;
use Piwik\ViewDataTable;
use Piwik\Plugins\CoreHome\DataTableRowAction\RowEvolution;

/**
 * MULTI ROW EVOLUTION
 * The class handles the popover that shows the evolution of a multiple rows in a data table
 * @package CoreHome
 */
class MultiRowEvolution extends RowEvolution
{
    /** 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 = 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 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);
    }
}