Merge "Reorganize commonPrint.css"
[lhc/web/wiklou.git] / skins / MonoBook.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 * @todo document
24 * @file
25 * @ingroup Skins
26 */
27
28 if ( !defined( 'MEDIAWIKI' ) ) {
29 die( -1 );
30 }
31
32 /**
33 * Inherit main code from SkinTemplate, set the CSS and template filter.
34 * @todo document
35 * @ingroup Skins
36 */
37 class SkinMonoBook extends SkinTemplate {
38 /** Using monobook. */
39 public $skinname = 'monobook';
40 public $stylename = 'monobook';
41 public $template = 'MonoBookTemplate';
42 public $useHeadElement = true;
43
44 /**
45 * @param OutputPage $out
46 */
47 function setupSkinUserCss( OutputPage $out ) {
48 parent::setupSkinUserCss( $out );
49
50 $out->addModuleStyles( array( 'mediawiki.skinning.interface', 'skins.monobook.styles' ) );
51
52 // TODO: Migrate all of these
53 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
54 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
55 }
56 }
57
58 /**
59 * @todo document
60 * @ingroup Skins
61 */
62 class MonoBookTemplate extends BaseTemplate {
63
64 /**
65 * Template filter callback for MonoBook skin.
66 * Takes an associative array of data set from a SkinTemplate-based
67 * class, and a wrapper for MediaWiki's localization database, and
68 * outputs a formatted page.
69 *
70 * @access private
71 */
72 function execute() {
73 // Suppress warnings to prevent notices about missing indexes in $this->data
74 wfSuppressWarnings();
75
76 $this->html( 'headelement' );
77 ?><div id="globalWrapper">
78 <div id="column-content">
79 <div id="content" class="mw-body-primary" role="main">
80 <a id="top"></a>
81 <?php
82 if ( $this->data['sitenotice'] ) {
83 ?>
84 <div id="siteNotice"><?php
85 $this->html( 'sitenotice' )
86 ?></div><?php
87 }
88 ?>
89
90 <h1 id="firstHeading" class="firstHeading" lang="<?php
91 $this->data['pageLanguage'] =
92 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
93 $this->text( 'pageLanguage' );
94 ?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1>
95
96 <div id="bodyContent" class="mw-body">
97 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
98 <div id="contentSub"<?php
99 $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' )
100 ?></div>
101 <?php if ( $this->data['undelete'] ) { ?>
102 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
103 <?php
104 }
105 ?><?php
106 if ( $this->data['newtalk'] ) {
107 ?>
108 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
109 <?php
110 }
111 ?>
112 <div id="jump-to-nav" class="mw-jump"><?php
113 $this->msg( 'jumpto' )
114 ?> <a href="#column-one"><?php
115 $this->msg( 'jumptonavigation' )
116 ?></a><?php
117 $this->msg( 'comma-separator' )
118 ?><a href="#searchInput"><?php
119 $this->msg( 'jumptosearch' )
120 ?></a></div>
121
122 <!-- start content -->
123 <?php $this->html( 'bodytext' ) ?>
124 <?php
125 if ( $this->data['catlinks'] ) {
126 $this->html( 'catlinks' );
127 }
128 ?>
129 <!-- end content -->
130 <?php
131 if ( $this->data['dataAfterContent'] ) {
132 $this->html( 'dataAfterContent'
133 );
134 }
135 ?>
136 <div class="visualClear"></div>
137 </div>
138 </div>
139 </div>
140 <div id="column-one"<?php $this->html( 'userlangattributes' ) ?>>
141 <h2><?php $this->msg( 'navigation-heading' ) ?></h2>
142 <?php $this->cactions(); ?>
143 <div class="portlet" id="p-personal" role="navigation">
144 <h3><?php $this->msg( 'personaltools' ) ?></h3>
145
146 <div class="pBody">
147 <ul<?php $this->html( 'userlangattributes' ) ?>>
148 <?php foreach ( $this->getPersonalTools() as $key => $item ) { ?>
149 <?php echo $this->makeListItem( $key, $item ); ?>
150
151 <?php
152 }
153 ?>
154 </ul>
155 </div>
156 </div>
157 <div class="portlet" id="p-logo" role="banner">
158 <?php
159 echo Html::element( 'a', array(
160 'href' => $this->data['nav_urls']['mainpage']['href'],
161 'style' => "background-image: url({$this->data['logopath']});" )
162 + Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?>
163
164 </div>
165 <?php
166 $this->renderPortals( $this->data['sidebar'] );
167 ?>
168 </div><!-- end of the left (by default at least) column -->
169 <div class="visualClear"></div>
170 <?php
171 $validFooterIcons = $this->getFooterIcons( "icononly" );
172 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
173
174 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
175 ?>
176 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
177 <?php
178 $footerEnd = '</div>';
179 } else {
180 $footerEnd = '';
181 }
182
183 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
184 ?>
185 <div id="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
186 <?php foreach ( $footerIcons as $icon ) { ?>
187 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
188
189 <?php
190 }
191 ?>
192 </div>
193 <?php
194 }
195
196 if ( count( $validFooterLinks ) > 0 ) {
197 ?>
198 <ul id="f-list">
199 <?php
200 foreach ( $validFooterLinks as $aLink ) {
201 ?>
202 <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
203 <?php
204 }
205 ?>
206 </ul>
207 <?php
208 }
209
210 echo $footerEnd;
211 ?>
212
213 </div>
214 <?php
215 $this->printTrail();
216 echo Html::closeElement( 'body' );
217 echo Html::closeElement( 'html' );
218 wfRestoreWarnings();
219 } // end of execute() method
220
221 /*************************************************************************************************/
222
223 /**
224 * @param array $sidebar
225 */
226 protected function renderPortals( $sidebar ) {
227 if ( !isset( $sidebar['SEARCH'] ) ) {
228 $sidebar['SEARCH'] = true;
229 }
230 if ( !isset( $sidebar['TOOLBOX'] ) ) {
231 $sidebar['TOOLBOX'] = true;
232 }
233 if ( !isset( $sidebar['LANGUAGES'] ) ) {
234 $sidebar['LANGUAGES'] = true;
235 }
236
237 foreach ( $sidebar as $boxName => $content ) {
238 if ( $content === false ) {
239 continue;
240 }
241
242 if ( $boxName == 'SEARCH' ) {
243 $this->searchBox();
244 } elseif ( $boxName == 'TOOLBOX' ) {
245 $this->toolbox();
246 } elseif ( $boxName == 'LANGUAGES' ) {
247 $this->languageBox();
248 } else {
249 $this->customBox( $boxName, $content );
250 }
251 }
252 }
253
254 function searchBox() {
255 global $wgUseTwoButtonsSearchForm;
256 ?>
257 <div id="p-search" class="portlet" role="search">
258 <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
259
260 <div id="searchBody" class="pBody">
261 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
262 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
263 <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?>
264
265 <?php
266 echo $this->makeSearchButton(
267 "go",
268 array( "id" => "searchGoButton", "class" => "searchButton" )
269 );
270
271 if ( $wgUseTwoButtonsSearchForm ) {
272 ?>&#160;
273 <?php echo $this->makeSearchButton(
274 "fulltext",
275 array( "id" => "mw-searchButton", "class" => "searchButton" )
276 );
277 } else {
278 ?>
279
280 <div><a href="<?php
281 $this->text( 'searchaction' )
282 ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
283 } ?>
284
285 </form>
286
287 <?php $this->renderAfterPortlet( 'search' ); ?>
288 </div>
289 </div>
290 <?php
291 }
292
293 /**
294 * Prints the cactions bar.
295 * Shared between MonoBook and Modern
296 */
297 function cactions() {
298 ?>
299 <div id="p-cactions" class="portlet" role="navigation">
300 <h3><?php $this->msg( 'views' ) ?></h3>
301
302 <div class="pBody">
303 <ul><?php
304 foreach ( $this->data['content_actions'] as $key => $tab ) {
305 echo '
306 ' . $this->makeListItem( $key, $tab );
307 } ?>
308
309 </ul>
310 <?php $this->renderAfterPortlet( 'cactions' ); ?>
311 </div>
312 </div>
313 <?php
314 }
315
316 /*************************************************************************************************/
317 function toolbox() {
318 ?>
319 <div class="portlet" id="p-tb" role="navigation">
320 <h3><?php $this->msg( 'toolbox' ) ?></h3>
321
322 <div class="pBody">
323 <ul>
324 <?php
325 foreach ( $this->getToolbox() as $key => $tbitem ) {
326 ?>
327 <?php echo $this->makeListItem( $key, $tbitem ); ?>
328
329 <?php
330 }
331 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
332 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
333 ?>
334 </ul>
335 <?php $this->renderAfterPortlet( 'tb' ); ?>
336 </div>
337 </div>
338 <?php
339 }
340
341 /*************************************************************************************************/
342 function languageBox() {
343 if ( $this->data['language_urls'] !== false ) {
344 ?>
345 <div id="p-lang" class="portlet" role="navigation">
346 <h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3>
347
348 <div class="pBody">
349 <ul>
350 <?php foreach ( $this->data['language_urls'] as $key => $langlink ) { ?>
351 <?php echo $this->makeListItem( $key, $langlink ); ?>
352
353 <?php
354 }
355 ?>
356 </ul>
357
358 <?php $this->renderAfterPortlet( 'lang' ); ?>
359 </div>
360 </div>
361 <?php
362 }
363 }
364
365 /*************************************************************************************************/
366 /**
367 * @param string $bar
368 * @param array|string $cont
369 */
370 function customBox( $bar, $cont ) {
371 $portletAttribs = array(
372 'class' => 'generated-sidebar portlet',
373 'id' => Sanitizer::escapeId( "p-$bar" ),
374 'role' => 'navigation'
375 );
376
377 $tooltip = Linker::titleAttrib( "p-$bar" );
378 if ( $tooltip !== false ) {
379 $portletAttribs['title'] = $tooltip;
380 }
381 echo ' ' . Html::openElement( 'div', $portletAttribs );
382 $msgObj = wfMessage( $bar );
383 ?>
384
385 <h3><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $bar ); ?></h3>
386 <div class='pBody'>
387 <?php
388 if ( is_array( $cont ) ) {
389 ?>
390 <ul>
391 <?php
392 foreach ( $cont as $key => $val ) {
393 ?>
394 <?php echo $this->makeListItem( $key, $val ); ?>
395
396 <?php
397 }
398 ?>
399 </ul>
400 <?php
401 } else {
402 # allow raw HTML block to be defined by extensions
403 print $cont;
404 }
405
406 $this->renderAfterPortlet( $bar );
407 ?>
408 </div>
409 </div>
410 <?php
411 }
412 } // end of class