16 import(
'classes.handler.Handler');
17 import(
'classes.statistics.StatisticsHelper');
28 parent::__construct();
30 [ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR],
31 [
'editorial',
'publications',
'users']
41 public function authorize($request, &$args, $roleAssignments) {
42 import(
'lib.pkp.classes.security.authorization.ContextAccessPolicy');
44 return parent::authorize($request, $args, $roleAssignments);
58 $dispatcher = $request->getDispatcher();
59 $context = $request->getContext();
62 $dispatcher->handle404();
68 $dateStart = date(
'Y-m-d', strtotime(
'-91 days'));
69 $dateEnd = date(
'Y-m-d', strtotime(
'yesterday'));
72 'contextIds' => [$context->getId()],
75 $totals =
Services::get(
'editorialStats')->getOverview($args);
76 $averages =
Services::get(
'editorialStats')->getAverages($args);
77 $dateRangeTotals =
Services::get(
'editorialStats')->getOverview(
81 'dateStart' => $dateStart,
82 'dateEnd' => $dateEnd,
97 'submissionsDeclinedDeskReject',
98 'submissionsDeclinedPostReview',
102 'declinedReviewRate',
107 foreach ($totals as $i => $stat) {
109 'key' => $stat[
'key'],
110 'name' => __($stat[
'name']),
111 'total' => $stat[
'value'],
112 'dateRange' => $dateRangeTotals[$i][
'value'],
114 if (in_array($stat[
'key'], $indentStats)) {
115 $row[
'name'] =
' ' . $row[
'name'];
117 if (in_array($stat[
'key'], $percentageStats)) {
118 $row[
'total'] = ($stat[
'value'] * 100) .
'%';
119 $row[
'dateRange'] = ($dateRangeTotals[$i][
'value'] * 100) .
'%';
123 $row[
'description'] = $description;
125 if (array_key_exists($stat[
'key'], $averages)
126 && $averages[$stat[
'key']] !== -1
127 && $row[
'total'] > 0) {
128 $row[
'total'] = __(
'stats.countWithYearlyAverage', [
129 'count' => $stat[
'value'],
130 'average' => $averages[$stat[
'key']],
141 'count' =>
Services::get(
'editorialStats')->countActiveByStages($stageId, $args),
146 $statsComponent = new \PKP\components\PKPStatsEditorialPage(
147 $dispatcher->url($request, ROUTE_API, $context->getPath(),
'stats/editorial'),
149 'activeByStage' => $activeByStage,
150 'averagesApiUrl' => $dispatcher->url($request, ROUTE_API, $context->getPath(),
'stats/editorial/averages'),
151 'dateStart' => $dateStart,
152 'dateEnd' => $dateEnd,
153 'dateRangeOptions' => [
155 'dateStart' => date(
'Y-m-d', strtotime(
'-91 days')),
156 'dateEnd' => $dateEnd,
157 'label' => __(
'stats.dateRange.last90Days'),
160 'dateStart' => date(
'Y-m-d', strtotime(date(
'Y') .
'-01-01')),
161 'dateEnd' => $dateEnd,
162 'label' => __(
'stats.dateRange.thisYear'),
165 'dateStart' => date(
'Y-m-d', strtotime((date(
'Y') - 1) .
'-01-01')),
166 'dateEnd' => date(
'Y-m-d', strtotime((date(
'Y') - 1) .
'-12-31')),
167 'label' => __(
'stats.dateRange.lastYear'),
170 'dateStart' => date(
'Y-m-d', strtotime((date(
'Y') - 2) .
'-01-01')),
171 'dateEnd' => date(
'Y-m-d', strtotime((date(
'Y') - 1) .
'-12-31')),
172 'label' => __(
'stats.dateRange.lastTwoYears'),
175 'percentageStats' => $percentageStats,
179 'label' => __(
'common.name'),
183 'name' =>
'dateRange',
184 'label' => $dateStart .
' — ' . $dateEnd,
185 'value' =>
'dateRange',
189 'label' => __(
'stats.total'),
193 'tableRows' => $tableRows,
197 $templateMgr->setLocaleKeys([
198 'stats.descriptionForStat',
199 'stats.countWithYearlyAverage',
201 $templateMgr->setState($statsComponent->getConfig());
202 $templateMgr->assign([
203 'pageComponent' =>
'StatsEditorialPage',
204 'pageTitle' => __(
'stats.editorialActivity'),
207 $templateMgr->display(
'stats/editorial.tpl');
217 $dispatcher = $request->getDispatcher();
218 $context = $request->getContext();
221 $dispatcher->handle404();
230 $dateStart = date(
'Y-m-d', strtotime(
'-31 days'));
231 $dateEnd = date(
'Y-m-d', strtotime(
'yesterday'));
234 $timeline =
Services::get(
'stats')->getTimeline(STATISTICS_DIMENSION_DAY, [
235 'assocTypes' => ASSOC_TYPE_SUBMISSION,
236 'contextIds' => $context->getId(),
238 'dateStart' => $dateStart,
239 'dateEnd' => $dateEnd,
242 $statsComponent = new \PKP\components\PKPStatsPublicationPage(
243 $dispatcher->url($request, ROUTE_API, $context->getPath(),
'stats/publications'),
245 'timeline' => $timeline,
246 'timelineInterval' => STATISTICS_DIMENSION_DAY,
247 'timelineType' =>
'abstract',
251 'label' => __(
'common.title'),
254 'name' =>
'abstractViews',
255 'label' => __(
'submission.abstractViews'),
256 'value' =>
'abstractViews',
259 'name' =>
'galleyViews',
260 'label' => __(
'stats.fileViews'),
261 'value' =>
'galleyViews',
265 'label' => __(
'stats.pdf'),
266 'value' =>
'pdfViews',
270 'label' => __(
'stats.html'),
271 'value' =>
'htmlViews',
275 'label' => __(
'common.other'),
276 'value' =>
'otherViews',
280 'label' => __(
'stats.total'),
282 'orderBy' =>
'total',
283 'initialOrderDirection' =>
true,
287 'dateStart' => $dateStart,
288 'dateEnd' => $dateEnd,
289 'dateRangeOptions' => [
291 'dateStart' => $dateStart,
292 'dateEnd' => $dateEnd,
293 'label' => __(
'stats.dateRange.last30Days'),
296 'dateStart' => date(
'Y-m-d', strtotime(
'-91 days')),
297 'dateEnd' => $dateEnd,
298 'label' => __(
'stats.dateRange.last90Days'),
301 'dateStart' => date(
'Y-m-d', strtotime(
'-12 months')),
302 'dateEnd' => $dateEnd,
303 'label' => __(
'stats.dateRange.last12Months'),
308 'label' => __(
'stats.dateRange.allDates'),
311 'orderBy' =>
'total',
312 'orderDirection' =>
true,
316 $templateMgr->setState($statsComponent->getConfig());
317 $templateMgr->assign([
318 'pageComponent' =>
'StatsPublicationsPage',
319 'pageTitle' => __(
'stats.publicationStats'),
320 'pageWidth' => PAGE_WIDTH_WIDE,
323 $templateMgr->display(
'stats/publications.tpl');
332 public function users($args, $request) {
333 $dispatcher = $request->getDispatcher();
334 $context = $request->getContext();
337 $dispatcher->handle404();
342 $templateMgr->assign([
343 'pageTitle' => __(
'stats.userStatistics'),
344 'userStats' => array_map(
346 $item[
'name'] = __($item[
'name']);
349 Services::get(
'user')->getRolesOverview([
'contextId' => $context->getId()])
352 $templateMgr->display(
'stats/users.tpl');
363 case 'daysToDecision':
return __(
'stats.description.daysToDecision');
364 case 'acceptanceRate':
return __(
'stats.description.acceptRejectRate');
365 case 'declineRate':
return __(
'stats.description.acceptRejectRate');