Open Journal Systems
3.3.0
PageHandler.inc.php
1
<?php
2
17
import
(
'classes.handler.Handler'
);
18
19
class
PageHandler
extends
Handler
{
20
21
//
22
// Implement template methods from PKPHandler
23
//
27
function
authorize
($request, &$args, $roleAssignments) {
28
import
(
'lib.pkp.classes.security.authorization.PKPSiteAccessPolicy'
);
29
$this->
addPolicy
(
new
PKPSiteAccessPolicy
(
30
$request,
31
array(
'tasks'
,
'css'
),
32
SITE_ACCESS_ALL_ROLES
33
));
34
35
$this->
setEnforceRestrictedSite
(
false
);
36
return
parent::authorize($request, $args, $roleAssignments);
37
}
38
39
40
//
41
// Public operations
42
//
49
function
tasks
($args, $request) {
50
$this->
setupTemplate
($request);
51
$templateMgr =
TemplateManager::getManager
($request);
52
return
$templateMgr->fetchJson(
'controllers/page/tasks.tpl'
);
53
}
54
60
function
css
($args, $request) {
61
header(
'Content-Type: text/css'
);
62
63
$templateManager =
TemplateManager::getManager
($request);
64
65
$name = $request->getUserVar(
'name'
);
66
if
(empty($name)) {
67
$name =
'pkp-lib'
;
68
}
69
switch
($name) {
70
71
// The core app stylesheet
72
case
'pkp-lib'
:
73
$cachedFile = $templateManager->getCachedLessFilePath($name);
74
if
(!file_exists($cachedFile)) {
75
$styles = $templateManager->compileLess($name,
'styles/index.less'
);
76
if
(!$templateManager->cacheLess($cachedFile, $styles)) {
77
echo $styles;
78
die;
79
}
80
}
81
break
;
82
83
default
:
84
85
// Backwards compatibility. This hook is deprecated.
86
if
(
HookRegistry::getHooks
(
'PageHandler::displayCss'
)) {
87
$result =
''
;
88
$lastModified =
null
;
89
HookRegistry::call
(
'PageHandler::displayCss'
, array($request, &$name, &$result, &$lastModified));
90
if
($lastModified) header(
'Last-Modified: '
. gmdate(
'D, d M Y H:i:s'
, $lastModified) .
' GMT'
);
91
header(
'Content-Length: '
. strlen($result));
92
echo $result;
93
die;
94
95
}
else
{
96
$cachedFile = $templateManager->getCachedLessFilePath($name);
97
if
(!file_exists($cachedFile)) {
98
99
// Process styles registered with the current theme
100
$styles =
''
;
101
$themes =
PluginRegistry::loadCategory
(
'themes'
,
true
);
102
foreach
($themes as $theme) {
103
if
($theme->isActive()) {
104
$style = $theme->getStyle($name);
105
if
(!empty($style)) {
106
107
// Compile and cache the stylesheet
108
$styles = $templateManager->compileLess(
109
$name,
110
$style[
'style'
],
111
array(
112
'baseUrl'
=> isset($style[
'baseUrl'
]) ? $style[
'baseUrl'
] :
null
,
113
'addLess'
=> isset($style[
'addLess'
]) ? $style[
'addLess'
] :
null
,
114
'addLessVariables'
=> isset($style[
'addLessVariables'
]) ? $style[
'addLessVariables'
] :
null
,
115
)
116
);
117
}
118
break
;
119
}
120
}
121
122
// If we still haven't found styles, fire off a hook
123
// which allows other types of plugins to handle
124
// requests
125
if
(!$styles) {
126
HookRegistry::call
(
127
'PageHandler::getCompiledLess'
,
128
array(
129
'request'
=> $request,
130
'name'
=> &$name,
131
'styles'
=> &$styles,
132
)
133
);
134
}
135
136
// Give up if there are still no styles
137
if
(!$styles) {
138
die;
139
}
140
141
// Try to save the styles to a cached file. If we can't,
142
// just print them out
143
if
(!$templateManager->cacheLess($cachedFile, $styles)) {
144
echo $styles;
145
die;
146
}
147
}
148
}
149
break
;
150
}
151
152
// Deliver the cached file
153
header(
'Last-Modified: '
. gmdate(
'D, d M Y H:i:s'
, filemtime($cachedFile)).
' GMT'
);
154
header(
'Content-Length: '
. filesize($cachedFile));
155
readfile($cachedFile);
156
die;
157
}
158
}
159
160
PageHandler\tasks
tasks($args, $request)
Definition:
PageHandler.inc.php:49
PageHandler\authorize
authorize($request, &$args, $roleAssignments)
Definition:
PageHandler.inc.php:27
PluginRegistry\loadCategory
static loadCategory($category, $enabledOnly=false, $mainContextId=null)
Definition:
PluginRegistry.inc.php:103
PKPTemplateManager\getManager
static & getManager($request=null)
Definition:
PKPTemplateManager.inc.php:1239
HookRegistry\getHooks
static & getHooks($hookName=null)
Definition:
HookRegistry.inc.php:28
PageHandler
Handler for requests for page components such as the header, tasks, usernav, and CSS.
Definition:
PageHandler.inc.php:19
PKPHandler\setupTemplate
setupTemplate($request)
Definition:
PKPHandler.inc.php:466
PageHandler\css
css($args, $request)
Definition:
PageHandler.inc.php:60
PKPHandler\setEnforceRestrictedSite
setEnforceRestrictedSite($enforceRestrictedSite)
Definition:
PKPHandler.inc.php:91
PKPHandler\addPolicy
addPolicy($authorizationPolicy, $addToTop=false)
Definition:
PKPHandler.inc.php:157
HookRegistry\call
static call($hookName, $args=null)
Definition:
HookRegistry.inc.php:86
Handler
Base request handler application class.
Definition:
Handler.inc.php:18
PKPSiteAccessPolicy
Class to that makes sure that a user is logged in.
Definition:
PKPSiteAccessPolicy.inc.php:20
lib
pkp
controllers
page
PageHandler.inc.php
Generated on Fri Aug 28 2020 14:52:58 for Open Journal Systems by
1.8.17