forked from xdnan7/statistics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatisticsPlugin.php
133 lines (110 loc) · 3.2 KB
/
StatisticsPlugin.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
<?php
/**
* @file plugins/generic/statistics/StatisticsPlugin.inc.php
*
* Copyright (c) 2016 Fran Máñez - Universitat Politècnica de Catalunya (UPC)
*
* @class StatisticsPlugin
*
*/
namespace APP\plugins\generic\StatisticsPlugin;
use APP\core\Application;
use APP\core\Request;
use PKP\core\JSONMessage;
use PKP\core\PKPString;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;
use APP\template\TemplateManager;
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, $mainContextId = NULL)
{
$success = parent::register($category, $path);
if ($success && $this->getEnabled()) {
Hook::add('LoadHandler', array(&$this, 'handleRequest'));
// Hook::add ('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');
}
// function displayHeaderLink($hookName, $params) {
// $journal =& Application::get()
// ->getRequest()
// ->getContext();
// 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];
$handler = &$args[3];
// If the request is for the log analyzer itself, handle it.
if ($this->getEnabled() && $page === 'statistics') {
$handler = new StatisticsHandler($this);
// 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($args, $request)
{
return parent::manage($args, $request);
// if (!parent::manage($verb, $args)) return false;
// switch ($verb) {
// case 'statistics':
// Request::redirect(null, 'statistics');
// return false;
// default:
// // Unknown management verb
// assert(false);
// return false;
// }
}
}