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