|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* File holding the ChameleonTemplate 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
|
|
|
|
|
27
|
|
|
namespace Skins\Chameleon; |
|
28
|
|
|
|
|
29
|
|
|
use BaseTemplate; |
|
30
|
|
|
use SkinChameleon; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* BaseTemplate class for the Chameleon skin |
|
34
|
|
|
* |
|
35
|
|
|
* @author Stephan Gambke |
|
36
|
|
|
* @since 1.0 |
|
37
|
|
|
* @ingroup Skins |
|
38
|
|
|
*/ |
|
39
|
|
|
class ChameleonTemplate extends BaseTemplate { |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Outputs the entire contents of the page |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function execute() { |
|
45
|
|
|
|
|
46
|
1 |
|
$this->getSkin()->getComponentFactory()->setSkinTemplate( $this ); |
|
47
|
|
|
$this->getSkin()->addSkinModulesToOutput(); |
|
48
|
|
|
$this->set( 'bottomscripts', $this->getSkin()->bottomScripts() ); |
|
49
|
|
|
|
|
50
|
|
|
// output the head element |
|
51
|
|
|
// The headelement defines the <body> tag itself, it shouldn't be included in the html text |
|
52
|
|
|
// To add attributes or classes to the body tag override addToBodyAttributes() in SkinChameleon |
|
53
|
|
|
$this->html( 'headelement' ); |
|
54
|
|
|
echo $this->getSkin()->getComponentFactory()->getRootComponent()->getHtml(); |
|
55
|
|
|
$this->printTrail(); |
|
56
|
|
|
echo "</body>\n</html>"; |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Overrides method in parent class that is unprotected against non-existent indexes in $this->data |
|
62
|
|
|
* |
|
63
|
|
|
* @param string $key |
|
64
|
|
|
* |
|
65
|
|
|
* @return string|void |
|
66
|
|
|
*/ |
|
67
|
|
|
function html( $key ) { |
|
68
|
|
|
echo $this->get( $key ); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Get the Skin object related to this object |
|
73
|
|
|
* |
|
74
|
|
|
* @return SkinChameleon |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function getSkin() { |
|
77
|
1 |
|
return parent::getSkin(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param \DOMElement $description |
|
82
|
|
|
* @param int $indent |
|
83
|
|
|
* @param string $htmlClassAttribute |
|
84
|
|
|
* |
|
85
|
|
|
* @throws \MWException |
|
86
|
|
|
* @return \Skins\Chameleon\Components\Container |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getComponent( \DOMElement $description, $indent = 0, $htmlClassAttribute = '' ) { |
|
89
|
|
|
return $this->getSkin()->getComponentFactory()->getComponent( $description, $indent, $htmlClassAttribute ); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Generates a list item for a navigation, portlet, portal, sidebar... list |
|
94
|
|
|
* |
|
95
|
|
|
* Overrides the parent function to ensure ids are unique. |
|
96
|
|
|
* |
|
97
|
|
|
* @param $key string, usually a key from the list you are generating this link from. |
|
98
|
|
|
* @param $item array, of list item data containing some of a specific set of keys. |
|
99
|
|
|
* |
|
100
|
|
|
* The "id" and "class" keys will be used as attributes for the list item, |
|
101
|
|
|
* if "active" contains a value of true a "active" class will also be appended to class. |
|
102
|
|
|
* |
|
103
|
|
|
* @param $options array |
|
104
|
|
|
* |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
|
|
function makeListItem( $key, $item, $options = array() ) { |
|
108
|
|
|
|
|
109
|
|
|
foreach ( array( 'id', 'single-id' ) as $attrib ) { |
|
110
|
|
|
|
|
111
|
|
|
if ( isset ( $item[ $attrib ] ) ) { |
|
112
|
|
|
$item[ $attrib ] = IdRegistry::getRegistry()->getId( $item[ $attrib ], $this ); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
return parent::makeListItem( $key, $item, $options ); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|