-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomThemePlugin.inc.php
More file actions
109 lines (81 loc) · 3.25 KB
/
CustomThemePlugin.inc.php
File metadata and controls
109 lines (81 loc) · 3.25 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
<?php
import('lib.pkp.classes.plugins.ThemePlugin');
class CustomThemePlugin extends ThemePlugin {
/**
* @copydoc ThemePlugin::isActive()
*/
public function isActive() {
if (defined('SESSION_DISABLE_INIT')) return true;
return parent::isActive();
}
public function init() {
$this->setParent('defaultthemeplugin');
$this->removeOption('typography');
$this->removeOption('useHomepageImageAsHeader');
// size logo small screens
$this->addOption('sizeLogoSmallScreen', 'text', array(
'label' => 'plugins.themes.custom.option.sizeLogoSmall',
'description' => 'plugins.themes.custom.option.sizeLogoSmallDescription'
));
// size logo large screens
$this->addOption('sizeLogoLargeScreen', 'text', array(
'label' => 'plugins.themes.custom.option.sizeLogoLarge',
'description' => 'plugins.themes.custom.option.sizeLogoLargeDescription'
));
$this->addOption('colourFooter', 'colour', array(
'label' => 'plugins.themes.custom.option.colourFooterLabel',
'description' => 'plugins.themes.custom.option.colourFooterDescription',
'default' => '#bfbfbf',
));
$this->addOption('colourText', 'colour', array(
'label' => 'plugins.themes.custom.option.colourTextLabel',
'description' => 'plugins.themes.custom.option.colourTextDescription',
'default' => '#2c2c2c',
));
/////////////////////////////
$sizeLogoSmallScreen = 0;
if (is_numeric($this->getOption('sizeLogoSmallScreen'))) {
$sizeLogoSmallScreen = intval($this->getOption('sizeLogoSmallScreen'));
}
$sizeLogoSmallScreenMargin = $sizeLogoSmallScreen + 20;
$sizeLogoLargeScreen = 0;
if (is_numeric($this->getOption('sizeLogoLargeScreen'))) {
$sizeLogoLargeScreen = intval($this->getOption('sizeLogoLargeScreen'));
}
$sizeLogoLargeScreenMargin = $sizeLogoLargeScreen + 20;
$colourFooter = $this->getOption('colourFooter');
$colourText = $this->getOption('colourText');
////////////////////////////////////////////////////////////////////////////////////
$additionalLessVariables = array();
$additionalLessVariables[] = '@custom-size-logo-ls: '.$sizeLogoLargeScreen.'px;';
$additionalLessVariables[] = '@custom-size-logo-ss: '.$sizeLogoSmallScreen.'px;';
$additionalLessVariables[] = '@custom-size-logo-ls-margin: '.$sizeLogoLargeScreenMargin.'px;';
$additionalLessVariables[] = '@custom-size-logo-ss-margin: '.$sizeLogoSmallScreenMargin.'px;';
$additionalLessVariables[] = '@text: ' .$colourText.';';
$additionalLessVariables[] = '@custom-colour-footer: ' . $colourFooter . ';';
if (!$this->isColourDark($colourFooter)) {
$additionalLessVariables[] = '@custom-colour-text-footer: '.$colourText.';';
} else {
$additionalLessVariables[] = '@custom-colour-text-footer: #fff;';
}
$this->modifyStyle('stylesheet', array('addLess' => array('styles/custom.less')));
if (!empty($additionalLessVariables)) {
$this->modifyStyle('stylesheet', array('addLessVariables' => join($additionalLessVariables)));
}
}
/**
* Get the display name of this plugin
* @return string
*/
function getDisplayName() {
return __('plugins.themes.custom.name');
}
/**
* Get the description of this plugin
* @return string
*/
function getDescription() {
return __('plugins.themes.custom.description');
}
}
?>