forked from bozana/usageStats
-
Notifications
You must be signed in to change notification settings - Fork 34
/
OMPUsageStatsReportPlugin.inc.php
135 lines (116 loc) · 4.82 KB
/
OMPUsageStatsReportPlugin.inc.php
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* @file plugins/generic/usageStats/OMPUsageStatsReportPlugin.inc.php
*
* Copyright (c) 2013-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class OMPUsageStatsReportPlugin
* @ingroup plugins_generic_usageStats
*
* @brief OMP default statistics report plugin (and metrics provider)
*/
use PKP\statistics\PKPStatisticsHelper;
import('plugins.generic.usageStats.PKPUsageStatsReportPlugin');
define('OMP_METRIC_TYPE_COUNTER', 'omp::counter');
class OMPUsageStatsReportPlugin extends PKPUsageStatsReportPlugin {
/**
* @copydoc ReportPlugin::getMetrics()
*/
function getMetrics($metricType = null, $columns = null, $filters = null, $orderBy = null, $range = null) {
// Validate the metric type.
if (!(is_scalar($metricType) || count($metricType) === 1)) return null;
if (is_array($metricType)) $metricType = array_pop($metricType);
if ($metricType !== OMP_METRIC_TYPE_COUNTER) return null;
return parent::getMetrics($metricType, $columns, $filters, $orderBy, $range);
}
/**
* @copydoc ReportPlugin::getMetricTypes()
*/
function getMetricTypes() {
return array(OMP_METRIC_TYPE_COUNTER);
}
/**
* @copydoc ReportPlugin::getMetricDisplayType()
*/
function getMetricDisplayType($metricType) {
if ($metricType !== OMP_METRIC_TYPE_COUNTER) return null;
return parent::getMetricDisplayType($metricType);
}
/**
* @copydoc ReportPlugin::getMetricFullName()
*/
function getMetricFullName($metricType) {
if ($metricType !== OMP_METRIC_TYPE_COUNTER) return null;
return parent::getMetricDisplayType($metricType);
}
/**
* @copydoc ReportPlugin::getColumns()
*/
function getColumns($metricType) {
if ($metricType !== OMP_METRIC_TYPE_COUNTER) return array();
return array(
PKPStatisticsHelper::STATISTICS_DIMENSION_ASSOC_ID,
PKPStatisticsHelper::STATISTICS_DIMENSION_ASSOC_TYPE,
PKPStatisticsHelper::STATISTICS_DIMENSION_FILE_TYPE,
PKPStatisticsHelper::STATISTICS_DIMENSION_REPRESENTATION_ID,
PKPStatisticsHelper::STATISTICS_DIMENSION_SUBMISSION_ID,
PKPStatisticsHelper::STATISTICS_DIMENSION_CONTEXT_ID,
PKPStatisticsHelper::STATISTICS_DIMENSION_SERIES_ID,
PKPStatisticsHelper::STATISTICS_DIMENSION_CITY,
PKPStatisticsHelper::STATISTICS_DIMENSION_REGION,
PKPStatisticsHelper::STATISTICS_DIMENSION_COUNTRY,
PKPStatisticsHelper::STATISTICS_DIMENSION_DAY,
PKPStatisticsHelper::STATISTICS_DIMENSION_MONTH,
PKPStatisticsHelper::STATISTICS_METRIC
);
}
/**
* @copydoc ReportPlugin::getObjectTypes()
*/
function getObjectTypes($metricType) {
if ($metricType !== OMP_METRIC_TYPE_COUNTER) return array();
return array(
ASSOC_TYPE_PRESS,
ASSOC_TYPE_SERIES,
ASSOC_TYPE_MONOGRAPH,
ASSOC_TYPE_SUBMISSION_FILE
);
}
/**
* @copydoc ReportPlugin::getDefaultReportTemplates()
*/
function getDefaultReportTemplates($metricTypes = null) {
$reports = parent::getDefaultReportTemplates($metricTypes);
// Define the press report template.
$reports[0]['nameLocaleKey'] = 'manager.statistics.reports.defaultReport.pressIndexPageViews';
$contextReportTemplate = current($reports);
$metricType = $contextReportTemplate['metricType'];
$aggregationColumns = $this->getAggregationColumns();
// Monograph file downloads.
$columns = array(PKPStatisticsHelper::STATISTICS_DIMENSION_ASSOC_TYPE,
PKPStatisticsHelper::STATISTICS_DIMENSION_SERIES_ID,
PKPStatisticsHelper::STATISTICS_DIMENSION_SUBMISSION_ID,
PKPStatisticsHelper::STATISTICS_DIMENSION_MONTH,
PKPStatisticsHelper::STATISTICS_DIMENSION_COUNTRY);
$filter = array(PKPStatisticsHelper::STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_SUBMISSION_FILE);
array_unshift($reports, array('nameLocaleKey' => 'manager.statistics.reports.defaultReport.monographDownloads',
'metricType' => $metricType, 'columns' => $columns, 'filter' => $filter,
'aggregationColumns' => $aggregationColumns));
// Monograph abstract views.
$filter = array(PKPStatisticsHelper::STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_SUBMISSION);
array_unshift($reports, array('nameLocaleKey' => 'manager.statistics.reports.defaultReport.monographAbstract',
'metricType' => $metricType, 'columns' => $columns, 'filter' => $filter,
'aggregationColumns' => $aggregationColumns));
// Series main page views.
$columns = array(PKPStatisticsHelper::STATISTICS_DIMENSION_ASSOC_TYPE,
PKPStatisticsHelper::STATISTICS_DIMENSION_MONTH,
PKPStatisticsHelper::STATISTICS_DIMENSION_COUNTRY);
$filter = array(PKPStatisticsHelper::STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_SERIES);
array_unshift($reports, array('nameLocaleKey' => 'manager.statistics.reports.defaultReport.seriesIndexPageViews',
'metricType' => $metricType, 'columns' => $columns, 'filter' => $filter,
'aggregationColumns' => $aggregationColumns));
return $reports;
}
}