1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File holding the MainContent 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\Components; |
28
|
|
|
|
29
|
|
|
use Skins\Chameleon\IdRegistry; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The NavbarHorizontal class. |
33
|
|
|
* |
34
|
|
|
* A horizontal navbar containing the sidebar items. |
35
|
|
|
* Does not include standard items (toolbox, search, language links). They need to be added to the page elsewhere |
36
|
|
|
* |
37
|
|
|
* The navbar is a list of lists wrapped in a nav element: <nav role="navigation" id="p-navbar" > |
38
|
|
|
* |
39
|
|
|
* @author Stephan Gambke |
40
|
|
|
* @since 1.0 |
41
|
|
|
* @ingroup Skins |
42
|
|
|
*/ |
43
|
|
|
class MainContent extends Component { |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Builds the HTML code for this component |
47
|
|
|
* |
48
|
|
|
* @return String the HTML code |
49
|
|
|
*/ |
50
|
8 |
|
public function getHtml() { |
51
|
|
|
|
52
|
8 |
|
$skintemplate = $this->getSkinTemplate(); |
53
|
8 |
|
$idRegistry = IdRegistry::getRegistry(); |
54
|
|
|
|
55
|
|
|
// START content |
56
|
|
|
$ret = |
57
|
8 |
|
$this->indent() . '<!-- start the content area -->' . |
58
|
8 |
|
$this->indent() . $idRegistry->openElement( 'div', |
59
|
8 |
|
array( 'id' => 'content', 'class' => 'mw-body ' . $this->getClassString() ) |
60
|
8 |
|
) . |
61
|
|
|
|
62
|
8 |
|
$idRegistry->element( 'a', array( 'id' => 'top' ) ) . |
63
|
8 |
|
$this->indent(1) . $idRegistry->element( 'div', array( 'id' => 'mw-indicators', 'class' => 'mw-indicators', ), $this->buildMwIndicators() ) . |
64
|
|
|
|
65
|
8 |
|
$this->indent() . '<div ' . \Html::expandAttributes( array( |
66
|
8 |
|
'id' => $idRegistry->getId( 'mw-js-message' ), |
67
|
|
|
'style' => 'display:none;' |
68
|
8 |
|
) |
69
|
8 |
|
) . $skintemplate->get( 'userlangattributes' ) . '></div>'; |
70
|
|
|
|
71
|
8 |
|
$ret .= $this->buildContentHeader(); |
72
|
8 |
|
$ret .= $this->buildContentBody(); |
73
|
8 |
|
$ret .= $this->buildCategoryLinks(); |
74
|
|
|
|
75
|
8 |
|
$ret .= $this->indent( -1 ) . '</div>'; |
76
|
|
|
// END content |
77
|
|
|
|
78
|
8 |
|
return $ret; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
8 |
|
protected function buildContentHeader() { |
85
|
|
|
|
86
|
8 |
|
$skintemplate = $this->getSkinTemplate(); |
87
|
8 |
|
$idRegistry = IdRegistry::getRegistry(); |
88
|
|
|
|
89
|
8 |
|
$ret = $this->indent() . '<div class ="contentHeader">' . |
90
|
|
|
|
91
|
8 |
|
$this->indent( 1 ) . '<!-- title of the page -->' . |
92
|
8 |
|
$this->indent() . $idRegistry->element( 'h1', array( 'id' => 'firstHeading', 'class' => 'firstHeading' ), $skintemplate->get( 'title' ) ) . |
93
|
|
|
|
94
|
8 |
|
$this->indent() . '<!-- tagline; usually goes something like "From WikiName" primary purpose of this seems to be for printing to identify the source of the content -->' . |
95
|
8 |
|
$this->indent() . $idRegistry->element( 'div', array( 'id'=> 'siteSub' ), $skintemplate->getMsg( 'tagline' )->escaped() ); |
96
|
|
|
|
97
|
8 |
View Code Duplication |
if ( $skintemplate->get( 'subtitle' ) ) { |
98
|
|
|
|
99
|
|
|
// TODO: should not use class 'small', better use class 'contentSub' and do styling in a less file |
100
|
|
|
$ret .= |
101
|
8 |
|
$this->indent() . '<!-- subtitle line; used for various things like the subpage hierarchy -->' . |
102
|
8 |
|
$this->indent() . $idRegistry->element( 'div', array( 'id' => 'contentSub', 'class' => 'small' ), $skintemplate->get( 'subtitle' ) ); |
103
|
|
|
|
104
|
8 |
|
} |
105
|
|
|
|
106
|
8 |
View Code Duplication |
if ( $skintemplate->get( 'undelete' ) ) { |
107
|
|
|
// TODO: should not use class 'small', better use class 'contentSub2' and do styling in a less file |
108
|
|
|
$ret .= |
109
|
8 |
|
$this->indent() . '<!-- undelete message -->' . |
110
|
8 |
|
$this->indent() . $idRegistry->element( 'div', array( 'id' => 'contentSub2', 'class' => 'small' ), $skintemplate->get( 'undelete' ) ); |
111
|
8 |
|
} |
112
|
|
|
|
113
|
|
|
// TODO: Do we need this? Seems to be an accessibility thing. It's used in vector to jump to the nav wich is at the bottom of the document, but our nav is usually at the top |
114
|
8 |
|
$ret .= $idRegistry->element( 'div', array( 'id' => 'jump-to-nav', 'class' => 'mw-jump' ), |
115
|
8 |
|
$skintemplate->getMsg( 'jumpto' )->escaped() . '<a href="#mw-navigation">' . $skintemplate->getMsg( 'jumptonavigation' )->escaped() . '</a>' . |
116
|
8 |
|
$skintemplate->getMsg( 'comma-separator' )->escaped() . '<a href="#p-search">' . $skintemplate->getMsg( 'jumptosearch' )->escaped() . '</a>' |
117
|
8 |
|
); |
118
|
|
|
|
119
|
8 |
|
$ret .= $this->indent( -1 ) . '</div>'; |
120
|
8 |
|
return $ret; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
8 |
|
protected function buildContentBody() { |
127
|
8 |
|
return $this->indent() . IdRegistry::getRegistry()->element( 'div', array( 'id' => 'bodyContent' ), |
128
|
8 |
|
$this->indent( 1 ) . '<!-- body text -->' . "\n" . |
129
|
8 |
|
$this->indent() . $this->getSkinTemplate()->get( 'bodytext' ) . |
130
|
8 |
|
$this->indent() . '<!-- end body text -->' . |
131
|
8 |
|
$this->buildDataAfterContent() . |
132
|
8 |
|
$this->indent( -1 ) |
133
|
8 |
|
); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
8 |
|
protected function buildCategoryLinks() { |
140
|
|
|
// TODO: Category links should be a separate component, but |
141
|
|
|
// * dataAfterContent should come after the the category links. |
142
|
|
|
// * only one extension is known to use it dataAfterContent and it is geared specifically towards MonoBook |
143
|
|
|
// => provide an attribut hideCatLinks for the XML and -if present- hide category links and assume somebody knows what they are doing |
144
|
|
|
return |
145
|
8 |
|
$this->indent() . '<!-- category links -->' . |
146
|
8 |
|
$this->indent() . $this->getSkinTemplate()->get( 'catlinks' ); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return string |
151
|
|
|
*/ |
152
|
8 |
|
protected function buildDataAfterContent() { |
153
|
|
|
|
154
|
8 |
|
$skinTemplate = $this->getSkinTemplate(); |
155
|
|
|
|
156
|
8 |
|
if ( $skinTemplate->get( 'dataAfterContent' ) ) { |
157
|
|
|
return |
158
|
8 |
|
$this->indent() . '<!-- data blocks which should go somewhere after the body text, but not before the catlinks block-->' . |
159
|
8 |
|
$this->indent() . $skinTemplate->get( 'dataAfterContent' ); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
return ''; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
8 |
|
private function buildMwIndicators() { |
169
|
|
|
|
170
|
8 |
|
$idRegistry = IdRegistry::getRegistry(); |
171
|
8 |
|
$indicators = $this->getSkinTemplate()->get( 'indicators' ); |
172
|
|
|
|
173
|
8 |
|
if ( !is_array( $indicators ) || count( $indicators ) === 0 ) { |
174
|
8 |
|
return ''; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
$this->indent( 1 ); |
178
|
|
|
|
179
|
|
|
$ret = ''; |
180
|
|
|
|
181
|
|
|
foreach ( $indicators as $id => $content ) { |
182
|
|
|
$id = \Sanitizer::escapeId( "mw-indicator-$id" ); |
183
|
|
|
|
184
|
|
|
$ret .= |
185
|
|
|
$this->indent() . |
186
|
|
|
$idRegistry->element( 'div', |
187
|
|
|
array( |
188
|
|
|
'id' => $id, |
189
|
|
|
'class' => "mw-indicator $id", |
190
|
|
|
), |
191
|
|
|
$content |
192
|
|
|
); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
$ret .= $this->indent( -1 ); |
196
|
|
|
|
197
|
|
|
return $ret; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
} |
201
|
|
|
|