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

GoalsPages.php « Visualizations « Goals « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 38a3fc8fef547b6ebc226f56314fbc2a29d13adc (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
<?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\Goals\Visualizations;

use Piwik\Piwik;

/**
 * DataTable Visualization that derives from HtmlTable and shows goals metrics for page conversions
 */
class GoalsPages extends Goals
{
    const ID = 'tableGoalsPages';

    public function beforeRender()
    {
        $this->removeExcludedColumns();
        $this->config->addTranslation('nb_hits', Piwik::translate('General_ColumnUniquePageviews'));
        $this->config->metrics_documentation['nb_hits'] = Piwik::translate('General_ColumnUniquePageviewsDocumentation');
        parent::beforeRender();
    }

    protected function setPropertiesForGoalsOverview($idSite)
    {
        $allGoals = $this->getGoals($idSite);

        // set view properties
        $this->config->columns_to_display = array('label', 'nb_hits');

        foreach ($allGoals as $goal) {
            $column        = "goal_{$goal['idgoal']}_nb_conversions_page_rate";
            $this->config->columns_to_display[]  = $column;
        }

    }

    protected function setPropertiesForGoals($idSite, $idGoals)
    {

        $allGoals = $this->getGoals($idSite);

        if ('all' === $idGoals) {
            $idGoals = array_keys($allGoals);
            $this->requestConfig->filter_sort_column = 'nb_hits';
        } else {
            // only sort by a goal's conversions if not showing all goals (for FULL_REPORT)
            $this->requestConfig->filter_sort_column = 'goal_' . reset($idGoals) . '_nb_conversions_attrib';
        }
        $this->requestConfig->filter_sort_order  = 'desc';

        $this->config->columns_to_display = array('label', 'nb_hits');

        $goalColumnTemplates = array(
            'goal_%s_nb_conversions_attrib',
            'goal_%s_revenue_attrib',
            'goal_%s_nb_conversions_page_rate',
        );

        // set columns to display (columns of same type but different goals will be next to each other,
        // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.)
        foreach ($idGoals as $idGoal) {
            foreach ($goalColumnTemplates as $columnTemplate) {
                $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal);
            }
        }

    }

}