-
Notifications
You must be signed in to change notification settings - Fork 8
/
StatisticsPlugin.inc.php
120 lines (96 loc) · 2.93 KB
/
StatisticsPlugin.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
<?php
/**
* @file plugins/generic/statistics/StatisticsPlugin.inc.php
*
* Copyright (c) 2016 Fran Máñez - Universitat Politècnica de Catalunya (UPC)
* fran.upc@gmail.com
*
* @class StatisticsPlugin
*
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class StatisticsPlugin extends GenericPlugin {
/**
* Called as a plugin is registered to the registry
* @param $category String Name of category plugin was registered to
* @return boolean True iff plugin initialized successfully; if false,
* the plugin will not be registered.
*/
function register($category, $path) {
$success = parent::register($category, $path);
if ($success && $this->getEnabled()) {
HookRegistry::register ('LoadHandler', array(&$this, 'handleRequest'));
HookRegistry::register ('Templates::Common::Header::Navbar::CurrentJournal', array(&$this, 'displayHeaderLink'));
$this->import('StatisticsChartsDAO');
$statisticsChartsDao = new StatisticsChartsDAO();
DAORegistry::registerDAO('StatisticsChartsDAO', $statisticsChartsDao);
}
return $success;
}
function getName() {
return 'StatisticsPlugin';
}
function getDisplayName() {
return __('plugins.generic.statistics.name');
}
function getDescription() {
return __('plugins.generic.statistics.description');
}
/**
* Get the filename of the ADODB schema for this plugin.
*/
function getInstallSchemaFile() {
return $this->getPluginPath() . '/' . 'schema.xml';
}
function displayHeaderLink($hookName, $params) {
$journal =& Request::getJournal();
if (!$journal) return false;
if ($this->getEnabled()) {
$smarty =& $params[1];
$output =& $params[2];
$templateMgr = TemplateManager::getManager();
$output .= '<li><a href="' . $templateMgr->smartyUrl(array('page'=>'statistics'), $smarty) . '" target="_parent">' . $templateMgr->smartyTranslate(array('key'=>'plugins.generic.statistics.name'), $smarty) . '</a></li>';
}
return false;
}
function handleRequest($hookName, $args) {
$page =& $args[0];
$op =& $args[1];
$sourceFile =& $args[2];
// If the request is for the log analyzer itself, handle it.
if ($page === 'statistics') {
$this->import('StatisticsHandler');
Registry::set('plugin', $this);
define('HANDLER_CLASS', 'StatisticsHandler');
return true;
}
return false;
}
function isSitePlugin() {
return true;
}
function getManagementVerbs() {
$verbs = array();
return parent::getManagementVerbs($verbs);
}
/*
* Execute a management verb on this plugin
* @param $verb string
* @param $args array
* @param $message string Location for the plugin to put a result msg
* @return boolean
*/
function manage($verb, $args, &$message) {
if (!parent::manage($verb, $args, $message)) return false;
switch ($verb) {
case 'statistics':
Request::redirect(null, 'statistics');
return false;
default:
// Unknown management verb
assert(false);
return false;
}
}
}
?>