blob: 9e0980f050383857c5e74aa570e6b7d9f6befcb3 (
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\ExampleReport\Reports;
use Piwik\Piwik;
use Piwik\Plugin\Report;
use Piwik\Plugin\ViewDataTable;
use Piwik\Plugins\Actions\Columns\ExitPageUrl;
use Piwik\View;
/**
* This class defines a new report.
*
* See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
*/
class GetExampleReport extends Base
{
protected function init()
{
parent::init();
$this->name = Piwik::translate('ExampleReportName');
$this->dimension = new ExitPageUrl();
$this->documentation = Piwik::translate('ExampleReportDocumentation');
// This defines in which order your report appears in the mobile app, in the menu and in the list of widgets
$this->order = 999;
// By default standard metrics are defined but you can customize them by defining an array of metric names
// $this->metrics = array('nb_visits', 'nb_hits');
// Uncomment the next line if your report does not contain any processed metrics, otherwise default
// processed metrics will be assigned
// $this->processedMetrics = array();
// Uncomment the next line if your report defines goal metrics
// $this->hasGoalMetrics = true;
// Uncomment the next line if your report should be able to load subtables. You can define any action here
// $this->actionToLoadSubTables = $this->action;
// Uncomment the next line if your report always returns a constant count of rows, for instance always
// 24 rows for 1-24hours
// $this->constantRowsCount = true;
// If a subcategory is specified, the report will be displayed in the menu under this menu item
// $this->subCategory = 'ExampleReportName';
}
/**
* Here you can configure how your report should be displayed. For instance whether your report supports a search
* etc. You can also change the default request config. For instance change how many rows are displayed by default.
*
* @param ViewDataTable $view
*/
public function configureView(ViewDataTable $view)
{
if (!empty($this->dimension)) {
$view->config->addTranslations(array('label' => $this->dimension->getName()));
}
// $view->config->show_search = false;
// $view->requestConfig->filter_sort_column = 'nb_visits';
// $view->requestConfig->filter_limit = 10';
$view->config->columns_to_display = array_merge(array('label'), $this->metrics);
}
/**
* Here you can define related reports that will be shown below the reports. Just return an array of related
* report instances if there are any.
*
* @return \Piwik\Plugin\Report[]
*/
public function getRelatedReports()
{
return array(); // eg return array(new XyzReport());
}
/**
* A report is usually completely automatically rendered for you but you can render the report completely
* customized if you wish. Just overwrite the method and make sure to return a string containing the content of the
* report. Don't forget to create the defined twig template within the templates folder of your plugin in order to
* make it work. Usually you should NOT have to overwrite this render method.
*
* @return string
public function render()
{
$view = new View('@ExampleReport/getExampleReport');
$view->myData = array();
return $view->render();
}
*/
/**
* By default your report is available to all users having at least view access. If you do not want this, you can
* limit the audience by overwriting this method.
*
* @return bool
public function isEnabled()
{
return Piwik::hasUserSuperUserAccess()
}
*/
}
|