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

Base.php « Reports « Events « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9d6b0ff1239547d704963854faf9e99ae0c8740c (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
<?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\Events\Reports;

use Piwik\EventDispatcher;
use Piwik\Common;
use Piwik\Plugin\ViewDataTable;
use Piwik\Plugins\Events\API;
use Piwik\Plugins\Events\Columns\Metrics\AverageEventValue;
use Piwik\Report\ReportWidgetFactory;
use Piwik\Widget\WidgetsList;

abstract class Base extends \Piwik\Plugin\Report
{
    protected function init()
    {
        $this->categoryId = 'General_Actions';
        $this->subcategoryId = 'Events_Events';
        $this->onlineGuideUrl = 'https://matomo.org/docs/event-tracking/';

        $this->processedMetrics = array(
            new AverageEventValue()
        );
    }

    public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
    {
        if (!$this->isSubtableReport) {
            $widget = $factory->createWidget()->setParameters(array(
                'secondaryDimension' => API::getInstance()->getDefaultSecondaryDimension($this->action)
            ));

            $widgetsList->addToContainerWidget('Events', $widget);
        }
    }

    public function configureView(ViewDataTable $view)
    {
        if (Common::getRequestVar('secondaryDimension', '', 'string')) {
            foreach (['pivotBy', 'pivotByColumn'] as $property) {
                $index = array_search($property, $view->requestConfig->overridableProperties);
                if ($index) {
                    unset($view->requestConfig->overridableProperties[$index]);
                }
            }
            $view->requestConfig->overridableProperties = array_values($view->requestConfig->overridableProperties);
        }

        $this->configureFooterMessage($view);
    }

    protected function configureFooterMessage(ViewDataTable $view)
    {
        if ($this->isSubtableReport) {
            // no footer message for subtables
            return;
        }

        $out = '';
        EventDispatcher::getInstance()->postEvent('Template.afterEventsReport', array(&$out));
        $view->config->show_footer_message = $out;
    }


}