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

AllColumns.php « HtmlTable « Visualizations « CoreVisualizations « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f655655c54c7376dc974db71cb40043e350153e (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
<?php
/**
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */

namespace Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;

use Piwik\DataTable;
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;

/**
 * DataTable Visualization that derives from HtmlTable and sets show_extra_columns to true.
 */
class AllColumns extends HtmlTable
{
    const ID = 'tableAllColumns';
    const FOOTER_ICON       = 'icon-table-more';
    const FOOTER_ICON_TITLE = 'General_DisplayTableWithMoreMetrics';

    public function beforeRender()
    {
        $this->config->show_extra_columns  = true;

        parent::beforeRender();
    }

    public function beforeGenericFiltersAreAppliedToLoadedDataTable()
    {
        $this->config->datatable_css_class = 'dataTableVizAllColumns';
        
        $this->dataTable->filter('AddColumnsProcessedMetrics');

        $properties = $this->config;

        $this->dataTable->filter(function (DataTable $dataTable) use ($properties) {
            $columnsToDisplay = array('label', 'nb_visits');

            $columns = $dataTable->getColumns();

            if (in_array('nb_uniq_visitors', $columns)) {
                $columnsToDisplay[] = 'nb_uniq_visitors';
            }

            if (in_array('nb_users', $columns)) {
                $columnsToDisplay[] = 'nb_users';
            }

            $columnsToDisplay = array_merge(
                $columnsToDisplay, array('nb_actions', 'nb_actions_per_visit', 'avg_time_on_site', 'bounce_rate')
            );

            // only display conversion rate for the plugins that do not provide "per goal" metrics
            // otherwise, conversion rate is meaningless as a whole (since we don't process 'cross goals' conversions)
            if (!$properties->show_goals) {
                $columnsToDisplay[] = 'conversion_rate';
            }

            $properties->columns_to_display = $columnsToDisplay;
        });

        parent::beforeGenericFiltersAreAppliedToLoadedDataTable();
    }

    public function beforeLoadDataTable()
    {
        parent::beforeLoadDataTable();

        unset($this->requestConfig->request_parameters_to_modify['pivotBy']);
        unset($this->requestConfig->request_parameters_to_modify['pivotByColumn']);
    }

    protected function isPivoted()
    {
        return false; // Pivot not supported
    }
}