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