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