-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCspUIPlugin.php
More file actions
76 lines (56 loc) · 1.96 KB
/
CspUIPlugin.php
File metadata and controls
76 lines (56 loc) · 1.96 KB
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
<?php
/**
* @file plugins /generic/cspUI/CspUIPlugin.inc.php
*
* Copyright (c) 2020-2025 Lívia Gouvêa
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class CspUIPlugin
* @brief Customizes Vue.js templates and components for the interface of the journal Cadernos de Saúde Pública.
*/
namespace APP\plugins\generic\cspUI;
use PKP\plugins\GenericPlugin;
use APP\template\TemplateManager;
use APP\core\Application;
use PKP\plugins\Hook;
class CspUIPlugin extends GenericPlugin {
private const CSS_VERSION = '202603311146';
/**
* @copydoc Plugin::register()
*
* @param null|mixed $mainContextId
*/
public function register($category, $path, $mainContextId = null)
{
$success = parent::register($category, $path, $mainContextId);
if ($success && $this->getEnabled()) {
$request = Application::get()->getRequest();
$url = $request->getBaseUrl() . '/' . $this->getPluginPath() . '/styles/style.css';
$templateMgr = TemplateManager::getManager($request);
$templateMgr->addStyleSheet('CspUI' . self::CSS_VERSION, $url, ['contexts' => 'backend']);
Hook::add('TemplateManager::display', [$this, 'templateManagerDisplay']);
}
return $success;
}
public function getDisplayName()
{
return __('plugins.generic.cspUI.displayName');
}
public function getDescription()
{
return __('plugins.generic.cspUI.description');
}
public function templateManagerDisplay($hookName, $args){
$templateMgr = $args[0];
$request = Application::get()->getRequest();
$templateMgr->addJavaScript(
'cspJS',
$request->getBaseUrl() . '/' . $this->getPluginPath() . '/js/build.js',
[
'priority' => TemplateManager::STYLE_SEQUENCE_LATE,
'contexts' => ['backend']
]
);
return false;
}
}