Open Monograph Press  3.3.0
OMPUsageStatsReportPlugin.inc.php
1 <?php
2 
17 import('plugins.generic.usageStats.PKPUsageStatsReportPlugin');
18 
19 define('OMP_METRIC_TYPE_COUNTER', 'omp::counter');
20 
22 
26  function getMetrics($metricType = null, $columns = null, $filters = null, $orderBy = null, $range = null) {
27  // Validate the metric type.
28  if (!(is_scalar($metricType) || count($metricType) === 1)) return null;
29  if (is_array($metricType)) $metricType = array_pop($metricType);
30  if ($metricType !== OMP_METRIC_TYPE_COUNTER) return null;
31 
32  return parent::getMetrics($metricType, $columns, $filters, $orderBy, $range);
33  }
34 
38  function getMetricTypes() {
39  return array(OMP_METRIC_TYPE_COUNTER);
40  }
41 
45  function getMetricDisplayType($metricType) {
46  if ($metricType !== OMP_METRIC_TYPE_COUNTER) return null;
47  return parent::getMetricDisplayType($metricType);
48  }
49 
53  function getMetricFullName($metricType) {
54  if ($metricType !== OMP_METRIC_TYPE_COUNTER) return null;
55  return parent::getMetricDisplayType($metricType);
56  }
57 
61  function getColumns($metricType) {
62  if ($metricType !== OMP_METRIC_TYPE_COUNTER) return array();
63  return array(
64  STATISTICS_DIMENSION_ASSOC_ID,
65  STATISTICS_DIMENSION_ASSOC_TYPE,
66  STATISTICS_DIMENSION_FILE_TYPE,
67  STATISTICS_DIMENSION_REPRESENTATION_ID,
68  STATISTICS_DIMENSION_SUBMISSION_ID,
69  STATISTICS_DIMENSION_CONTEXT_ID,
70  STATISTICS_DIMENSION_SERIES_ID,
71  STATISTICS_DIMENSION_CITY,
72  STATISTICS_DIMENSION_REGION,
73  STATISTICS_DIMENSION_COUNTRY,
74  STATISTICS_DIMENSION_DAY,
75  STATISTICS_DIMENSION_MONTH,
76  STATISTICS_METRIC
77  );
78  }
79 
83  function getObjectTypes($metricType) {
84  if ($metricType !== OMP_METRIC_TYPE_COUNTER) return array();
85  return array(
86  ASSOC_TYPE_PRESS,
87  ASSOC_TYPE_SERIES,
88  ASSOC_TYPE_MONOGRAPH,
89  ASSOC_TYPE_SUBMISSION_FILE
90  );
91  }
92 
96  function getDefaultReportTemplates($metricTypes = null) {
97  $reports = parent::getDefaultReportTemplates($metricTypes);
98  // Define the press report template.
99  $reports[0]['nameLocaleKey'] = 'manager.statistics.reports.defaultReport.pressIndexPageViews';
100 
101  $contextReportTemplate = current($reports);
102  $metricType = $contextReportTemplate['metricType'];
103  $aggregationColumns = $this->getAggregationColumns();
104 
105  // Monograph file downloads.
106  $columns = array(STATISTICS_DIMENSION_ASSOC_TYPE,
107  STATISTICS_DIMENSION_SERIES_ID,
108  STATISTICS_DIMENSION_SUBMISSION_ID,
109  STATISTICS_DIMENSION_MONTH,
110  STATISTICS_DIMENSION_COUNTRY);
111  $filter = array(STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_SUBMISSION_FILE);
112  array_unshift($reports, array('nameLocaleKey' => 'manager.statistics.reports.defaultReport.monographDownloads',
113  'metricType' => $metricType, 'columns' => $columns, 'filter' => $filter,
114  'aggregationColumns' => $aggregationColumns));
115 
116  // Monograph abstract views.
117  $filter = array(STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_SUBMISSION);
118  array_unshift($reports, array('nameLocaleKey' => 'manager.statistics.reports.defaultReport.monographAbstract',
119  'metricType' => $metricType, 'columns' => $columns, 'filter' => $filter,
120  'aggregationColumns' => $aggregationColumns));
121 
122  // Series main page views.
123  $columns = array(STATISTICS_DIMENSION_ASSOC_TYPE,
124  STATISTICS_DIMENSION_MONTH,
125  STATISTICS_DIMENSION_COUNTRY);
126  $filter = array(STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_SERIES);
127  array_unshift($reports, array('nameLocaleKey' => 'manager.statistics.reports.defaultReport.seriesIndexPageViews',
128  'metricType' => $metricType, 'columns' => $columns, 'filter' => $filter,
129  'aggregationColumns' => $aggregationColumns));
130 
131  return $reports;
132  }
133 }
134 
PKPUsageStatsReportPlugin\getAggregationColumns
getAggregationColumns()
Definition: PKPUsageStatsReportPlugin.inc.php:149
PKPUsageStatsReportPlugin
OJS default statistics report plugin (and metrics provider)
Definition: PKPUsageStatsReportPlugin.inc.php:19
OMPUsageStatsReportPlugin\getMetricFullName
getMetricFullName($metricType)
Definition: OMPUsageStatsReportPlugin.inc.php:53
OMPUsageStatsReportPlugin
OMP default statistics report plugin (and metrics provider)
Definition: OMPUsageStatsReportPlugin.inc.php:21
OMPUsageStatsReportPlugin\getMetricDisplayType
getMetricDisplayType($metricType)
Definition: OMPUsageStatsReportPlugin.inc.php:45
OMPUsageStatsReportPlugin\getColumns
getColumns($metricType)
Definition: OMPUsageStatsReportPlugin.inc.php:61
OMPUsageStatsReportPlugin\getDefaultReportTemplates
getDefaultReportTemplates($metricTypes=null)
Definition: OMPUsageStatsReportPlugin.inc.php:96
OMPUsageStatsReportPlugin\getMetricTypes
getMetricTypes()
Definition: OMPUsageStatsReportPlugin.inc.php:38
OMPUsageStatsReportPlugin\getMetrics
getMetrics($metricType=null, $columns=null, $filters=null, $orderBy=null, $range=null)
Definition: OMPUsageStatsReportPlugin.inc.php:26
OMPUsageStatsReportPlugin\getObjectTypes
getObjectTypes($metricType)
Definition: OMPUsageStatsReportPlugin.inc.php:83