60fc0f279c7f8bab167bee0f8e270c3a0011b9e8
[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 * @todo document
9 * @file
10 * @ingroup Skins
11 */
12
13 if( !defined( 'MEDIAWIKI' ) )
14 die( -1 );
15
16 /**
17 * Inherit main code from SkinTemplate, set the CSS and template filter.
18 * @todo document
19 * @ingroup Skins
20 */
21 class SkinMonoBook extends SkinTemplate {
22 /** Using monobook. */
23 var $skinname = 'monobook', $stylename = 'monobook',
24 $template = 'MonoBookTemplate', $useHeadElement = true;
25
26 function setupSkinUserCss( OutputPage $out ) {
27 global $wgHandheldStyle;
28
29 parent::setupSkinUserCss( $out );
30
31 $out->addModuleStyles( 'monobook' );
32
33 // TODO: Migrate all of these
34 //$out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
35 //$out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
36 //$out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
37 //$out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
38
39 // TODO: migrate
40 //$out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
41
42 }
43 }
44
45 /**
46 * @todo document
47 * @ingroup Skins
48 */
49 class MonoBookTemplate extends QuickTemplate {
50 var $skin;
51 /**
52 * Template filter callback for MonoBook skin.
53 * Takes an associative array of data set from a SkinTemplate-based
54 * class, and a wrapper for MediaWiki's localization database, and
55 * outputs a formatted page.
56 *
57 * @access private
58 */
59 function execute() {
60 global $wgRequest;
61
62 $this->skin = $skin = $this->data['skin'];
63 $action = $wgRequest->getText( 'action' );
64
65 // Suppress warnings to prevent notices about missing indexes in $this->data
66 wfSuppressWarnings();
67
68 $this->html( 'headelement' );
69 ?><div id="globalWrapper">
70 <div id="column-content"><div id="content"<?php $this->html("specialpageattributes") ?>>
71 <a id="top"></a>
72 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
73
74 <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1>
75 <div id="bodyContent">
76 <div id="siteSub"><?php $this->msg('tagline') ?></div>
77 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
78 <?php if($this->data['undelete']) { ?>
79 <div id="contentSub2"><?php $this->html('undelete') ?></div>
80 <?php } ?><?php if($this->data['newtalk'] ) { ?>
81 <div class="usermessage"><?php $this->html('newtalk') ?></div>
82 <?php } ?><?php if($this->data['showjumplinks']) { ?>
83 <div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div>
84 <?php } ?>
85 <!-- start content -->
86 <?php $this->html('bodytext') ?>
87 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
88 <!-- end content -->
89 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
90 <div class="visualClear"></div>
91 </div>
92 </div></div>
93 <div id="column-one"<?php $this->html('userlangattributes') ?>>
94 <div id="p-cactions" class="portlet">
95 <h5><?php $this->msg('views') ?></h5>
96 <div class="pBody">
97 <ul><?php
98 foreach($this->data['content_actions'] as $key => $tab) {
99 echo '
100 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
101 if( $tab['class'] ) {
102 echo ' class="'.htmlspecialchars($tab['class']).'"';
103 }
104 echo '><a href="'.htmlspecialchars($tab['href']).'"';
105 # We don't want to give the watch tab an accesskey if the
106 # page is being edited, because that conflicts with the
107 # accesskey on the watch checkbox. We also don't want to
108 # give the edit tab an accesskey, because that's fairly su-
109 # perfluous and conflicts with an accesskey (Ctrl-E) often
110 # used for editing in Safari.
111 if( in_array( $action, array( 'edit', 'submit' ) )
112 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
113 echo $skin->tooltip( "ca-$key" );
114 } else {
115 echo $skin->tooltipAndAccesskey( "ca-$key" );
116 }
117 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
118 } ?>
119
120 </ul>
121 </div>
122 </div>
123 <div class="portlet" id="p-personal">
124 <h5><?php $this->msg('personaltools') ?></h5>
125 <div class="pBody">
126 <ul<?php $this->html('userlangattributes') ?>>
127 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
128 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
129 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
130 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
131 if(!empty($item['class'])) { ?> class="<?php
132 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
133 echo htmlspecialchars($item['text']) ?></a></li>
134 <?php } ?>
135 </ul>
136 </div>
137 </div>
138 <div class="portlet" id="p-logo">
139 <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
140 ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
141 echo $skin->tooltipAndAccesskey('p-logo') ?>></a>
142 </div>
143 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
144 <?php
145 $sidebar = $this->data['sidebar'];
146 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
147 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
148 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
149 foreach ($sidebar as $boxName => $cont) {
150 if ( $boxName == 'SEARCH' ) {
151 $this->searchBox();
152 } elseif ( $boxName == 'TOOLBOX' ) {
153 $this->toolbox();
154 } elseif ( $boxName == 'LANGUAGES' ) {
155 $this->languageBox();
156 } else {
157 $this->customBox( $boxName, $cont );
158 }
159 }
160 ?>
161 </div><!-- end of the left (by default at least) column -->
162 <div class="visualClear"></div>
163 <div id="footer"<?php $this->html('userlangattributes') ?>>
164 <?php
165 if($this->data['poweredbyico']) { ?>
166 <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>
167 <?php }
168 if($this->data['copyrightico']) { ?>
169 <div id="f-copyrightico"><?php $this->html('copyrightico') ?></div>
170 <?php }
171
172 // Generate additional footer links
173 $footerlinks = array(
174 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
175 'privacy', 'about', 'disclaimer', 'tagline',
176 );
177 $validFooterLinks = array();
178 foreach( $footerlinks as $aLink ) {
179 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
180 $validFooterLinks[] = $aLink;
181 }
182 }
183 if ( count( $validFooterLinks ) > 0 ) {
184 ?> <ul id="f-list">
185 <?php
186 foreach( $validFooterLinks as $aLink ) {
187 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
188 ?> <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
189 <?php }
190 }
191 ?>
192 </ul>
193 <?php }
194 ?>
195 </div>
196 </div>
197 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
198 <?php $this->html('reporttime') ?>
199 <?php if ( $this->data['debug'] ): ?>
200 <!-- Debug output:
201 <?php $this->text( 'debug' ); ?>
202
203 -->
204 <?php endif;
205
206 echo Html::closeElement( 'body' );
207 echo Html::closeElement( 'html' );
208 wfRestoreWarnings();
209 } // end of execute() method
210
211 /*************************************************************************************************/
212 function searchBox() {
213 global $wgUseTwoButtonsSearchForm;
214 ?>
215 <div id="p-search" class="portlet">
216 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
217 <div id="searchBody" class="pBody">
218 <form action="<?php $this->text('wgScript') ?>" id="searchform">
219 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
220 <?php
221 echo Html::input( 'search',
222 isset( $this->data['search'] ) ? $this->data['search'] : '', 'search',
223 array(
224 'id' => 'searchInput',
225 'title' => $this->skin->titleAttrib( 'search' ),
226 'accesskey' => $this->skin->accesskey( 'search' )
227 ) ); ?>
228
229 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?>&#160;
230 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
231
232 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
233
234 </form>
235 </div>
236 </div>
237 <?php
238 }
239
240 /*************************************************************************************************/
241 function toolbox() {
242 ?>
243 <div class="portlet" id="p-tb">
244 <h5><?php $this->msg('toolbox') ?></h5>
245 <div class="pBody">
246 <ul>
247 <?php
248 if($this->data['notspecialpage']) { ?>
249 <li id="t-whatlinkshere"><a href="<?php
250 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
251 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
252 <?php
253 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
254 <li id="t-recentchangeslinked"><a href="<?php
255 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
256 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li>
257 <?php }
258 }
259 if( isset( $this->data['nav_urls']['trackbacklink'] ) && $this->data['nav_urls']['trackbacklink'] ) { ?>
260 <li id="t-trackbacklink"><a href="<?php
261 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
262 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
263 <?php }
264 if($this->data['feeds']) { ?>
265 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
266 ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
267 echo htmlspecialchars($feed['href']) ?>" rel="alternate" type="application/<?php echo $key ?>+xml" class="feedlink"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&#160;
268 <?php } ?></li><?php
269 }
270
271 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
272
273 if($this->data['nav_urls'][$special]) {
274 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
275 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
276 <?php }
277 }
278
279 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
280 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
281 ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
282 }
283
284 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
285 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
286 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
287 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
288 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
289 }
290
291 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
292 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
293 ?>
294 </ul>
295 </div>
296 </div>
297 <?php
298 }
299
300 /*************************************************************************************************/
301 function languageBox() {
302 if( $this->data['language_urls'] ) {
303 ?>
304 <div id="p-lang" class="portlet">
305 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
306 <div class="pBody">
307 <ul>
308 <?php foreach($this->data['language_urls'] as $langlink) { ?>
309 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
310 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>" title="<?php
311 echo htmlspecialchars($langlink['title']) ?>"><?php echo $langlink['text'] ?></a></li>
312 <?php } ?>
313 </ul>
314 </div>
315 </div>
316 <?php
317 }
318 }
319
320 /*************************************************************************************************/
321 function customBox( $bar, $cont ) {
322 ?>
323 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
324 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
325 <div class='pBody'>
326 <?php if ( is_array( $cont ) ) { ?>
327 <ul>
328 <?php foreach($cont as $val) { ?>
329 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
330 if ( $val['active'] ) { ?> class="active" <?php }
331 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
332 <?php } ?>
333 </ul>
334 <?php } else {
335 # allow raw HTML block to be defined by extensions
336 print $cont;
337 }
338 ?>
339 </div>
340 </div>
341 <?php
342 }
343 } // end of class
344
345