-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathBootstrapThreeThemePlugin.php
187 lines (172 loc) · 5.8 KB
/
BootstrapThreeThemePlugin.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/**
* @file plugins/themes/bootstrap3/BootstrapThreeThemePlugin.php
*
* Copyright (c) 2014-2023 Simon Fraser University
* Copyright (c) 2003-2023 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class BootstrapThreeThemePlugin
* @brief Default theme
*/
namespace APP\plugins\themes\bootstrap3;
use APP\core\Application;
use APP\i18n\AppLocale;
use PKP\config\Config;
use PKP\facades\Locale;
use PKP\plugins\ThemePlugin;
class BootstrapThreeThemePlugin extends ThemePlugin {
/**
* Initialize the theme
*
* @return null
*/
public function init() {
// Register option for bootstrap themes
$this->addOption('bootstrapTheme', 'FieldOptions', [
'type' => 'radio',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.label'),
'description' => __('plugins.themes.bootstrap3.options.bootstrapTheme.description'),
'options' => [
[
'value' => 'bootstrap3',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.bootstrap3'),
],
[
'value' => 'cerulean',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.cerulean'),
],
[
'value' => 'cleanblog',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.cleanblog'),
],
[
'value' => 'cosmo',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.cosmo'),
],
[
'value' => 'cyborg',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.cyborg'),
],
[
'value' => 'darkly',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.darkly'),
],
[
'value' => 'flatly',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.flatly'),
],
[
'value' => 'journal',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.journal'),
],
[
'value' => 'lumen',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.lumen'),
],
[
'value' => 'paper',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.paper'),
],
[
'value' => 'readable',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.readable'),
],
[
'value' => 'sandstone',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.sandstone'),
],
[
'value' => 'simplex',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.simplex'),
],
[
'value' => 'slate',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.slate'),
],
[
'value' => 'spacelab',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.spacelab'),
],
[
'value' => 'superhero',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.superhero'),
],
[
'value' => 'united',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.united'),
],
[
'value' => 'yeti',
'label' => __('plugins.themes.bootstrap3.options.bootstrapTheme.yeti'),
],
],
]);
// Add usage stats display options
$this->addOption('displayStats', 'FieldOptions', [
'type' => 'radio',
'label' => __('plugins.themes.bootstrap3.option.displayStats.label'),
'options' => [
[
'value' => 'none',
'label' => __('plugins.themes.bootstrap3.option.displayStats.none'),
],
[
'value' => 'bar',
'label' => __('plugins.themes.bootstrap3.option.displayStats.bar'),
],
[
'value' => 'line',
'label' => __('plugins.themes.bootstrap3.option.displayStats.line'),
],
],
'default' => 'none',
]);
// Determine the path to the glyphicons font in Bootstrap
$iconFontPath = Application::get()->getRequest()->getBaseUrl() . '/' . $this->getPluginPath() . '/bootstrap/fonts/';
$bootstrapTheme = $this->getOption('bootstrapTheme');
if (empty($bootstrapTheme) || $bootstrapTheme === 'bootstrap3') {
$this->addStyle('bootstrap', 'styles/bootstrap.less');
$this->modifyStyle('bootstrap', ['addLessVariables' => '@icon-font-path:"' . $iconFontPath . '";']);
} else {
$this->addStyle('bootstrapTheme-' . $bootstrapTheme, 'styles/' . $bootstrapTheme . '.less');
$this->modifyStyle('bootstrapTheme-' . $bootstrapTheme, ['addLessVariables' => '@icon-font-path:"' . $iconFontPath . '";']);
}
$locale = Locale::getLocale();
$localeMetadata = Locale::getMetadata($locale);
if ($localeMetadata->isRightToLeft() === 'rtl') {
$this->addStyle('bootstrap-rtl', 'styles/bootstrap-rtl.min.css');
}
// Load jQuery from a CDN or, if CDNs are disabled, from a local copy.
$min = Config::getVar('general', 'enable_minified') ? '.min' : '';
$request = Application::get()->getRequest();
// Use an empty `baseUrl` argument to prevent the theme from looking for
// the files within the theme directory
$jquery = $request->getBaseUrl() . '/js/build/jquery/jquery' . $min . '.js';
$jqueryUI = $request->getBaseUrl() . '/js/build/jquery-ui/jquery-ui' . $min . '.js';
$this->addScript('jQuery', $jquery, array('baseUrl' => ''));
$this->addScript('jQueryUI', $jqueryUI, array('baseUrl' => ''));
$this->addScript('jQueryTagIt', $request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/jquery.tag-it.js', array('baseUrl' => ''));
// Load Bootstrap
$this->addScript('bootstrap', 'bootstrap/js/bootstrap.min.js');
// Add navigation menu areas for this theme
$this->addMenuArea(array('primary', 'user'));
}
/**
* Get the display name of this plugin
* @return string
*/
function getDisplayName() {
return __('plugins.themes.bootstrap3.name');
}
/**
* Get the description of this plugin
* @return string
*/
function getDescription() {
return __('plugins.themes.bootstrap3.description');
}
}
if (!PKP_STRICT_MODE) {
class_alias('\APP\plugins\themes\bootstrap3\BootstrapThreeThemePlugin', '\BootstrapThreeThemePlugin');
}