-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultJournalsUcThemePlugin.php
123 lines (103 loc) · 3.68 KB
/
DefaultJournalsUcThemePlugin.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
<?php
/**
* @file plugins/themes/defaultJournalsUc/DefaultJournalsUcThemePlugin.inc.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Copyright (c) 2021 Sean Crowe
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class DefaultJournalsUcThemePlugin
* @ingroup plugins_themes_default_journals uc
*
* @brief Default journals_at_uc theme
*/
namespace APP\plugins\themes\defaultJournalsUc;
use PKP\plugins\ThemePlugin;
use PKP\plugins\Hook;
class DefaultJournalsUcThemePlugin extends ThemePlugin {
/**
* Initialize the theme's styles, scripts and hooks. This is only run for
* the currently active theme.
*
* @return null
*/
public function init() {
// Initialize the parent theme
$this->setParent('defaultthemeplugin');
// Add custom styles
$this->modifyStyle('stylesheet', array('addLess' => array('styles/index.less')));
// Remove the typography options of the parent theme.
// `removeOption` was introduced in OJS 3.0.2
if (method_exists($this, 'removeOption')) {
$this->removeOption('typography');
}
// Remove base color option from the parent theme.
if (method_exists($this, 'removeOption')) {
$this->removeOption('baseColour');
}
// Remove show description in journal index option from the parent theme.
if (method_exists($this, 'removeOption')) {
$this->removeOption('showDescriptionInJournalIndex');
}
// Remove home page image header option from the parent theme.
if (method_exists($this, 'removeOption')) {
$this->removeOption('useHomepageImageAsHeader');
}
$this->addOption('proceedingsArray', 'FieldText', [
'label' => __('plugins.themes.defaultJournalsUc.option.proceedingsArray.label'),
'description' => __('plugins.themes.defaultJournalsUc.option.proceedingsArray.description'),
'default' => ''
]);
// Load the Montserrat and Open Sans fonts
$this->addStyle(
'font',
'//fonts.googleapis.com/css?family=Montserrat:400,700|Noto+Serif:400,400i,700,700i',
array('baseUrl' => '')
);
// Dequeue any fonts loaded by parent theme
// `removeStyle` was introduced in OJS 3.0.2
if (method_exists($this, 'removeStyle')) {
$this->removeStyle('fontNotoSans');
$this->removeStyle('fontNotoSerif');
$this->removeStyle('fontNotoSansNotoSerif');
$this->removeStyle('fontLato');
$this->removeStyle('fontLora');
$this->removeStyle('fontLoraOpenSans');
$this->removeStyle('fontNotoSerif');
$this->removeStyle('fontNotoSerif');
$this->removeStyle('fontNotoSerif');
$this->removeStyle('fontNotoSerif');
$this->removeStyle('fontNotoSerif');
}
// Start with a fresh array of additionalLessVariables so that we can
// ignore those added by the parent theme. This gets rid of @font
// variable overrides from the typography option
$additionalLessVariables = array();
$proceedings = $this->getOption('proceedingsArray');
Hook::add('TemplateManager::display', array($this, 'loadTemplateData'));
}
public function loadTemplateData($hookName, $args) {
// Retrieve the TemplateManager and the template filename
$templateMgr = $args[0];
$template = $args[1];
// Don't do anything if we're not loading the right template
$proceedingsArray = explode(",", $this->getOption('proceedingsArray'));
$templateMgr->assign('proceedings', $proceedingsArray);
}
/**
* Get the display name of this plugin
* @return string
*/
function getDisplayName() {
return __('plugins.themes.defaultJournalsUc.name');
}
/**
* Get the description of this plugin
* @return string
*/
function getDescription() {
return __('plugins.themes.defaultJournalsUc.description');
}
}
?>