1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File holding the SkinChameleon class |
4
|
|
|
* |
5
|
|
|
* This file is part of the MediaWiki skin Chameleon. |
6
|
|
|
* |
7
|
|
|
* @copyright 2013 - 2014, Stephan Gambke |
8
|
|
|
* @license GNU General Public License, version 3 (or any later version) |
9
|
|
|
* |
10
|
|
|
* The Chameleon skin is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU General Public License as published by the Free |
12
|
|
|
* Software Foundation, either version 3 of the License, or (at your option) any |
13
|
|
|
* later version. |
14
|
|
|
* |
15
|
|
|
* The Chameleon skin is distributed in the hope that it will be useful, but |
16
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
18
|
|
|
* details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU General Public License along |
21
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>. |
22
|
|
|
* |
23
|
|
|
* @file |
24
|
|
|
* @ingroup Skins |
25
|
|
|
*/ |
26
|
|
|
use Skins\Chameleon\ComponentFactory; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* SkinTemplate class for the Chameleon skin |
30
|
|
|
* |
31
|
|
|
* @author Stephan Gambke |
32
|
|
|
* @since 1.0 |
33
|
|
|
* @ingroup Skins |
34
|
|
|
*/ |
35
|
|
|
class SkinChameleon extends SkinTemplate { |
36
|
|
|
|
37
|
|
|
public $skinname = 'chameleon'; |
38
|
|
|
public $stylename = 'chameleon'; |
39
|
|
|
public $template = '\Skins\Chameleon\ChameleonTemplate'; |
40
|
|
|
public $useHeadElement = true; |
41
|
|
|
|
42
|
|
|
private $componentFactory; |
43
|
|
|
private $output; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param $out OutputPage object |
47
|
|
|
*/ |
48
|
|
|
function setupSkinUserCss( OutputPage $out ) { |
49
|
|
|
|
50
|
|
|
$this->output = $out; |
51
|
|
|
|
52
|
|
|
// load Bootstrap styles |
53
|
|
|
$out->addModuleStyles( |
54
|
|
|
array( |
55
|
|
|
'ext.bootstrap.styles' |
56
|
|
|
) |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param \OutputPage $out |
62
|
|
|
*/ |
63
|
|
|
function initPage( OutputPage $out ) { |
64
|
|
|
|
65
|
|
|
parent::initPage( $out ); |
66
|
|
|
|
67
|
|
|
// Enable responsive behaviour on mobile browsers |
68
|
|
|
$out->addMeta( 'viewport', 'width=device-width, initial-scale=1.0' ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return ComponentFactory |
73
|
|
|
*/ |
74
|
1 |
|
public function getComponentFactory() { |
75
|
|
|
|
76
|
1 |
|
if ( ! isset( $this->componentFactory ) ) { |
77
|
1 |
|
$this->componentFactory = new \Skins\Chameleon\ComponentFactory( $GLOBALS['egChameleonLayoutFile'] ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return $this->componentFactory; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function addSkinModulesToOutput() { |
84
|
|
|
// load Bootstrap scripts |
85
|
|
|
$out = $this->output; |
86
|
|
|
$out->addModules( array( 'ext.bootstrap.scripts' ) ); |
87
|
|
|
$out->addModules( $this->getComponentFactory()->getRootComponent()->getResourceLoaderModules() ); |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param Title $title |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function getPageClasses( $title ) { |
96
|
|
|
$layoutName = Sanitizer::escapeClass( 'layout-' . basename( $GLOBALS['egChameleonLayoutFile'], '.xml' ) ); |
97
|
|
|
return implode( ' ', array( parent::getPageClasses( $title ), $layoutName ) ); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|