EditPage::newSectionSummary should return a value in all code paths
[lhc/web/wiklou.git] / skins / MonoBook / MonoBookTemplate.php
1 <?php
2 /**
3 * MonoBook nouveau.
4 *
5 * Translated from gwicke's previous TAL template version to remove
6 * dependency on PHPTAL.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
22 *
23 * @file
24 * @ingroup Skins
25 */
26
27 /**
28 * @ingroup Skins
29 */
30 class MonoBookTemplate extends BaseTemplate {
31
32 /**
33 * Template filter callback for MonoBook skin.
34 * Takes an associative array of data set from a SkinTemplate-based
35 * class, and a wrapper for MediaWiki's localization database, and
36 * outputs a formatted page.
37 *
38 * @access private
39 */
40 function execute() {
41 // Suppress warnings to prevent notices about missing indexes in $this->data
42 wfSuppressWarnings();
43
44 $this->html( 'headelement' );
45 ?><div id="globalWrapper">
46 <div id="column-content">
47 <div id="content" class="mw-body-primary" role="main">
48 <a id="top"></a>
49 <?php
50 if ( $this->data['sitenotice'] ) {
51 ?>
52 <div id="siteNotice"><?php
53 $this->html( 'sitenotice' )
54 ?></div><?php
55 }
56 ?>
57
58 <h1 id="firstHeading" class="firstHeading" lang="<?php
59 $this->data['pageLanguage'] =
60 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
61 $this->text( 'pageLanguage' );
62 ?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1>
63
64 <div id="bodyContent" class="mw-body">
65 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
66 <div id="contentSub"<?php
67 $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' )
68 ?></div>
69 <?php if ( $this->data['undelete'] ) { ?>
70 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
71 <?php
72 }
73 ?><?php
74 if ( $this->data['newtalk'] ) {
75 ?>
76 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
77 <?php
78 }
79 ?>
80 <div id="jump-to-nav" class="mw-jump"><?php
81 $this->msg( 'jumpto' )
82 ?> <a href="#column-one"><?php
83 $this->msg( 'jumptonavigation' )
84 ?></a><?php
85 $this->msg( 'comma-separator' )
86 ?><a href="#searchInput"><?php
87 $this->msg( 'jumptosearch' )
88 ?></a></div>
89
90 <!-- start content -->
91 <?php $this->html( 'bodytext' ) ?>
92 <?php
93 if ( $this->data['catlinks'] ) {
94 $this->html( 'catlinks' );
95 }
96 ?>
97 <!-- end content -->
98 <?php
99 if ( $this->data['dataAfterContent'] ) {
100 $this->html( 'dataAfterContent'
101 );
102 }
103 ?>
104 <div class="visualClear"></div>
105 </div>
106 </div>
107 </div>
108 <div id="column-one"<?php $this->html( 'userlangattributes' ) ?>>
109 <h2><?php $this->msg( 'navigation-heading' ) ?></h2>
110 <?php $this->cactions(); ?>
111 <div class="portlet" id="p-personal" role="navigation">
112 <h3><?php $this->msg( 'personaltools' ) ?></h3>
113
114 <div class="pBody">
115 <ul<?php $this->html( 'userlangattributes' ) ?>>
116 <?php foreach ( $this->getPersonalTools() as $key => $item ) { ?>
117 <?php echo $this->makeListItem( $key, $item ); ?>
118
119 <?php
120 }
121 ?>
122 </ul>
123 </div>
124 </div>
125 <div class="portlet" id="p-logo" role="banner">
126 <?php
127 echo Html::element( 'a', array(
128 'href' => $this->data['nav_urls']['mainpage']['href'],
129 'style' => "background-image: url({$this->data['logopath']});" )
130 + Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?>
131
132 </div>
133 <?php
134 $this->renderPortals( $this->data['sidebar'] );
135 ?>
136 </div><!-- end of the left (by default at least) column -->
137 <div class="visualClear"></div>
138 <?php
139 $validFooterIcons = $this->getFooterIcons( "icononly" );
140 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
141
142 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
143 ?>
144 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
145 <?php
146 $footerEnd = '</div>';
147 } else {
148 $footerEnd = '';
149 }
150
151 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
152 ?>
153 <div id="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
154 <?php foreach ( $footerIcons as $icon ) { ?>
155 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
156
157 <?php
158 }
159 ?>
160 </div>
161 <?php
162 }
163
164 if ( count( $validFooterLinks ) > 0 ) {
165 ?>
166 <ul id="f-list">
167 <?php
168 foreach ( $validFooterLinks as $aLink ) {
169 ?>
170 <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
171 <?php
172 }
173 ?>
174 </ul>
175 <?php
176 }
177
178 echo $footerEnd;
179 ?>
180
181 </div>
182 <?php
183 $this->printTrail();
184 echo Html::closeElement( 'body' );
185 echo Html::closeElement( 'html' );
186 wfRestoreWarnings();
187 } // end of execute() method
188
189 /*************************************************************************************************/
190
191 /**
192 * @param array $sidebar
193 */
194 protected function renderPortals( $sidebar ) {
195 if ( !isset( $sidebar['SEARCH'] ) ) {
196 $sidebar['SEARCH'] = true;
197 }
198 if ( !isset( $sidebar['TOOLBOX'] ) ) {
199 $sidebar['TOOLBOX'] = true;
200 }
201 if ( !isset( $sidebar['LANGUAGES'] ) ) {
202 $sidebar['LANGUAGES'] = true;
203 }
204
205 foreach ( $sidebar as $boxName => $content ) {
206 if ( $content === false ) {
207 continue;
208 }
209
210 if ( $boxName == 'SEARCH' ) {
211 $this->searchBox();
212 } elseif ( $boxName == 'TOOLBOX' ) {
213 $this->toolbox();
214 } elseif ( $boxName == 'LANGUAGES' ) {
215 $this->languageBox();
216 } else {
217 $this->customBox( $boxName, $content );
218 }
219 }
220 }
221
222 function searchBox() {
223 global $wgUseTwoButtonsSearchForm;
224 ?>
225 <div id="p-search" class="portlet" role="search">
226 <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
227
228 <div id="searchBody" class="pBody">
229 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
230 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
231 <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?>
232
233 <?php
234 echo $this->makeSearchButton(
235 "go",
236 array( "id" => "searchGoButton", "class" => "searchButton" )
237 );
238
239 if ( $wgUseTwoButtonsSearchForm ) {
240 ?>&#160;
241 <?php echo $this->makeSearchButton(
242 "fulltext",
243 array( "id" => "mw-searchButton", "class" => "searchButton" )
244 );
245 } else {
246 ?>
247
248 <div><a href="<?php
249 $this->text( 'searchaction' )
250 ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
251 } ?>
252
253 </form>
254
255 <?php $this->renderAfterPortlet( 'search' ); ?>
256 </div>
257 </div>
258 <?php
259 }
260
261 /**
262 * Prints the cactions bar.
263 * Shared between MonoBook and Modern
264 */
265 function cactions() {
266 ?>
267 <div id="p-cactions" class="portlet" role="navigation">
268 <h3><?php $this->msg( 'views' ) ?></h3>
269
270 <div class="pBody">
271 <ul><?php
272 foreach ( $this->data['content_actions'] as $key => $tab ) {
273 echo '
274 ' . $this->makeListItem( $key, $tab );
275 } ?>
276
277 </ul>
278 <?php $this->renderAfterPortlet( 'cactions' ); ?>
279 </div>
280 </div>
281 <?php
282 }
283
284 /*************************************************************************************************/
285 function toolbox() {
286 ?>
287 <div class="portlet" id="p-tb" role="navigation">
288 <h3><?php $this->msg( 'toolbox' ) ?></h3>
289
290 <div class="pBody">
291 <ul>
292 <?php
293 foreach ( $this->getToolbox() as $key => $tbitem ) {
294 ?>
295 <?php echo $this->makeListItem( $key, $tbitem ); ?>
296
297 <?php
298 }
299 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
300 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
301 ?>
302 </ul>
303 <?php $this->renderAfterPortlet( 'tb' ); ?>
304 </div>
305 </div>
306 <?php
307 }
308
309 /*************************************************************************************************/
310 function languageBox() {
311 if ( $this->data['language_urls'] !== false ) {
312 ?>
313 <div id="p-lang" class="portlet" role="navigation">
314 <h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3>
315
316 <div class="pBody">
317 <ul>
318 <?php foreach ( $this->data['language_urls'] as $key => $langlink ) { ?>
319 <?php echo $this->makeListItem( $key, $langlink ); ?>
320
321 <?php
322 }
323 ?>
324 </ul>
325
326 <?php $this->renderAfterPortlet( 'lang' ); ?>
327 </div>
328 </div>
329 <?php
330 }
331 }
332
333 /*************************************************************************************************/
334 /**
335 * @param string $bar
336 * @param array|string $cont
337 */
338 function customBox( $bar, $cont ) {
339 $portletAttribs = array(
340 'class' => 'generated-sidebar portlet',
341 'id' => Sanitizer::escapeId( "p-$bar" ),
342 'role' => 'navigation'
343 );
344
345 $tooltip = Linker::titleAttrib( "p-$bar" );
346 if ( $tooltip !== false ) {
347 $portletAttribs['title'] = $tooltip;
348 }
349 echo ' ' . Html::openElement( 'div', $portletAttribs );
350 $msgObj = wfMessage( $bar );
351 ?>
352
353 <h3><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $bar ); ?></h3>
354 <div class='pBody'>
355 <?php
356 if ( is_array( $cont ) ) {
357 ?>
358 <ul>
359 <?php
360 foreach ( $cont as $key => $val ) {
361 ?>
362 <?php echo $this->makeListItem( $key, $val ); ?>
363
364 <?php
365 }
366 ?>
367 </ul>
368 <?php
369 } else {
370 # allow raw HTML block to be defined by extensions
371 print $cont;
372 }
373
374 $this->renderAfterPortlet( $bar );
375 ?>
376 </div>
377 </div>
378 <?php
379 }
380 } // end of class