-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPremiumThemePlugin.php
More file actions
253 lines (227 loc) · 8.51 KB
/
PremiumThemePlugin.php
File metadata and controls
253 lines (227 loc) · 8.51 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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?php
/**
* @file PremiumThemePlugin.php
*
* Premium Theme Plugin - Main Class
* A premium theme for Open Journal Systems 3.5+
*
* @package plugins.themes.premium
*/
namespace APP\plugins\themes\premium;
use APP\core\Application;
use APP\template\TemplateManager;
use PKP\config\Config;
use PKP\plugins\ThemePlugin;
use APP\plugins\themes\premium\Services\RelatedArticlesService;
class PremiumThemePlugin extends ThemePlugin
{
/**
* @copydoc Plugin::register()
*/
public function register($category, $path, $mainContextId = null)
{
$success = parent::register($category, $path, $mainContextId);
// Load locale data for translations
// This must be called for locale strings to be available
if ($success) {
$this->addLocaleData();
}
// DO NOT call init() here - let OJS call it automatically
// OJS will call init() on both parent and child themes in the correct order
// This ensures parent theme CSS loads first
return $success;
}
/**
* Initialize the theme's styles, scripts and hooks.
*/
public function init()
{
// CRITICAL: Use setParent() to inherit OJS core CSS
// Without this, OJS core CSS won't load and the site will be unstyled
// We use 'defaultthemeplugin' (lowercase class name) NOT 'default' (app name)
$this->setParent('defaultthemeplugin');
// Ensure locale data is loaded
$this->addLocaleData();
// Load primary stylesheet AFTER setParent so parent CSS loads first
// Use unique handle to avoid conflicts with parent's 'stylesheet'
$this->addStyle('premium-stylesheet', 'dist/styles/main.css', ['priority' => 'theme']);
// Load custom JavaScript
$this->addScript('premium-main', 'dist/js/app.js');
// Register theme options
$this->addOption('baseColour', 'FieldColor', [
'label' => __('plugins.themes.premium.option.baseColour.label'),
'description' => __('plugins.themes.premium.option.baseColour.description'),
'default' => '#1E6292',
]);
$this->addOption('layout', 'FieldOptions', [
'type' => 'radio',
'label' => __('plugins.themes.premium.option.layout.label'),
'description' => __('plugins.themes.premium.option.layout.description'),
'options' => [
[
'value' => '1col',
'label' => __('plugins.themes.premium.option.layout.1col'),
],
[
'value' => '2col',
'label' => __('plugins.themes.premium.option.layout.2col'),
],
[
'value' => '3col',
'label' => __('plugins.themes.premium.option.layout.3col'),
],
],
'default' => '2col',
]);
$this->addOption('colorScheme', 'FieldOptions', [
'type' => 'radio',
'label' => __('plugins.themes.premium.option.colorScheme.label'),
'description' => __('plugins.themes.premium.option.colorScheme.description'),
'options' => [
[
'value' => 'blue',
'label' => __('plugins.themes.premium.option.colorScheme.blue'),
],
[
'value' => 'green',
'label' => __('plugins.themes.premium.option.colorScheme.green'),
],
[
'value' => 'purple',
'label' => __('plugins.themes.premium.option.colorScheme.purple'),
],
[
'value' => 'red',
'label' => __('plugins.themes.premium.option.colorScheme.red'),
],
[
'value' => 'orange',
'label' => __('plugins.themes.premium.option.colorScheme.orange'),
],
],
'default' => 'blue',
]);
$this->addOption('darkMode', 'FieldOptions', [
'type' => 'radio',
'label' => __('plugins.themes.premium.option.darkMode.label'),
'description' => __('plugins.themes.premium.option.darkMode.description'),
'options' => [
[
'value' => 'auto',
'label' => __('plugins.themes.premium.option.darkMode.auto'),
],
[
'value' => 'light',
'label' => __('plugins.themes.premium.option.darkMode.light'),
],
[
'value' => 'dark',
'label' => __('plugins.themes.premium.option.darkMode.dark'),
],
],
'default' => 'auto',
]);
$this->addOption('showDescriptionInJournalIndex', 'FieldOptions', [
'label' => __('manager.setup.contextSummary'),
'options' => [
[
'value' => true,
'label' => __('plugins.themes.premium.option.showDescriptionInJournalIndex.option'),
],
],
'default' => false,
]);
$this->addOption('displayStats', 'FieldOptions', [
'type' => 'radio',
'label' => __('plugins.themes.premium.option.displayStats.label'),
'description' => __('plugins.themes.premium.option.displayStats.description'),
'options' => [
[
'value' => 'none',
'label' => __('plugins.themes.premium.option.displayStats.none'),
],
[
'value' => 'bar',
'label' => __('plugins.themes.premium.option.displayStats.bar'),
],
[
'value' => 'line',
'label' => __('plugins.themes.premium.option.displayStats.line'),
],
],
'default' => 'none',
]);
$this->addOption('showRelatedArticles', 'FieldOptions', [
'label' => __('plugins.themes.premium.option.showRelatedArticles.label'),
'description' => __('plugins.themes.premium.option.showRelatedArticles.description'),
'options' => [
[
'value' => true,
'label' => __('plugins.themes.premium.option.showRelatedArticles.option'),
],
],
'default' => true,
]);
$this->addOption('showSocialSharing', 'FieldOptions', [
'label' => __('plugins.themes.premium.option.showSocialSharing.label'),
'description' => __('plugins.themes.premium.option.showSocialSharing.description'),
'options' => [
[
'value' => true,
'label' => __('plugins.themes.premium.option.showSocialSharing.option'),
],
],
'default' => true,
]);
// Add navigation menu areas
$this->addMenuArea(['primary', 'user']);
// Pass theme options to templates
$request = Application::get()->getRequest();
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign([
'premiumLayout' => $this->getOption('layout'),
'premiumColorScheme' => $this->getOption('colorScheme'),
'premiumDarkMode' => $this->getOption('darkMode'),
'premiumBaseColour' => $this->getOption('baseColour'),
'activeTheme' => $this,
]);
}
/**
* Get the display name of this plugin
*
* @return string
*/
public function getDisplayName()
{
return __('plugins.themes.premium.name');
}
/**
* Get the description of this plugin
*
* @return string
*/
public function getDescription()
{
return __('plugins.themes.premium.description');
}
/**
* Get the name of the settings file to be installed on new journal
* creation.
*
* @return string
*/
public function getContextSpecificPluginSettingsFile()
{
return $this->getPluginPath() . '/settings.xml';
}
/**
* Get the name of the settings file to be installed site-wide when
* OJS is installed.
*
* @return string
*/
public function getInstallSitePluginSettingsFile()
{
return $this->getPluginPath() . '/settings.xml';
}
}