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