Rm nonstandard and redundant styles for Special:SpecialPages; really no need for...
[lhc/web/wiklou.git] / skins / Vector.php
1 <?php
2 /**
3 * Vector - Modern version of MonoBook with fresh look and many usability
4 * improvements.
5 *
6 * @todo document
7 * @file
8 * @ingroup Skins
9 */
10
11 if( !defined( 'MEDIAWIKI' ) ) {
12 die( -1 );
13 }
14
15 /**
16 * SkinTemplate class for Vector skin
17 * @ingroup Skins
18 */
19 class SkinVector extends SkinTemplate {
20
21 var $skinname = 'vector', $stylename = 'vector',
22 $template = 'VectorTemplate', $useHeadElement = true;
23
24 /**
25 * Initializes output page and sets up skin-specific parameters
26 * @param $out OutputPage object to initialize
27 */
28 public function initPage( OutputPage $out ) {
29 global $wgLocalStylePath, $wgRequest;
30
31 parent::initPage( $out );
32
33 // Append CSS which includes IE only behavior fixes for hover support -
34 // this is better than including this in a CSS fille since it doesn't
35 // wait for the CSS file to load before fetching the HTC file.
36 $min = $wgRequest->getFuzzyBool( 'debug' ) ? '' : '.min';
37 $out->addHeadItem( 'csshover',
38 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
39 htmlspecialchars( $wgLocalStylePath ) .
40 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
41 );
42 }
43
44 /**
45 * Load skin and user CSS files in the correct order
46 * fixes bug 22916
47 * @param $out OutputPage object
48 */
49 function setupSkinUserCss( OutputPage $out ){
50 parent::setupSkinUserCss( $out );
51 $out->addModuleStyles( 'skins.vector' );
52 }
53 }
54
55 /**
56 * QuickTemplate class for Vector skin
57 * @ingroup Skins
58 */
59 class VectorTemplate extends BaseTemplate {
60
61 /* Members */
62
63 /**
64 * @var Skin Cached skin object
65 */
66 var $skin;
67
68 /* Functions */
69
70 /**
71 * Outputs the entire contents of the (X)HTML page
72 */
73 public function execute() {
74 global $wgLang, $wgVectorUseIconWatch;
75
76 $this->skin = $this->data['skin'];
77
78 // Build additional attributes for navigation urls
79 //$nav = $this->skin->buildNavigationUrls();
80 $nav = $this->data['content_navigation'];
81
82 if ( $wgVectorUseIconWatch ) {
83 $mode = $this->skin->getTitle()->userIsWatching() ? 'unwatch' : 'watch';
84 if ( isset($nav['actions'][$mode]) ) {
85 $nav['views'][$mode] = $nav['actions'][$mode];
86 $nav['views'][$mode]['class'] = rtrim('icon ' . $nav['views'][$mode]['class'], ' ');
87 $nav['views'][$mode]['primary'] = true;
88 unset($nav['actions'][$mode]);
89 }
90 }
91
92 $xmlID = '';
93 foreach ( $nav as $section => $links ) {
94 foreach ( $links as $key => $link ) {
95 if ( $section == "views" && !(isset($link["primary"]) && $link["primary"]) ) {
96 $link['class'] = rtrim('collapsible ' . $link['class'], ' ');
97 }
98
99 $xmlID = isset($link["id"]) ? $link["id"] : 'ca-' . $xmlID;
100 $nav[$section][$key]['attributes'] =
101 ' id="' . Sanitizer::escapeId( $xmlID ) . '"';
102 if ( $link['class'] ) {
103 $nav[$section][$key]['attributes'] .=
104 ' class="' . htmlspecialchars( $link['class'] ) . '"';
105 unset( $nav[$section][$key]['class'] );
106 }
107 if ( isset($link['tooltiponly']) && $link['tooltiponly'] ) {
108 $nav[$section][$key]['key'] =
109 $this->skin->tooltip( $xmlID );
110 } else {
111 $nav[$section][$key]['key'] =
112 $this->skin->tooltipAndAccesskey( $xmlID );
113 }
114 }
115 }
116 $this->data['namespace_urls'] = $nav['namespaces'];
117 $this->data['view_urls'] = $nav['views'];
118 $this->data['action_urls'] = $nav['actions'];
119 $this->data['variant_urls'] = $nav['variants'];
120
121 // Reverse horizontally rendered navigation elements
122 if ( $wgLang->isRTL() ) {
123 $this->data['view_urls'] =
124 array_reverse( $this->data['view_urls'] );
125 $this->data['namespace_urls'] =
126 array_reverse( $this->data['namespace_urls'] );
127 $this->data['personal_urls'] =
128 array_reverse( $this->data['personal_urls'] );
129 }
130 // Output HTML Page
131 $this->html( 'headelement' );
132 ?>
133 <div id="mw-page-base" class="noprint"></div>
134 <div id="mw-head-base" class="noprint"></div>
135 <!-- content -->
136 <div id="content"<?php $this->html('specialpageattributes') ?>>
137 <a id="top"></a>
138 <div id="mw-js-message" style="display:none;"<?php $this->html('userlangattributes') ?>></div>
139 <?php if ( $this->data['sitenotice'] ): ?>
140 <!-- sitenotice -->
141 <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
142 <!-- /sitenotice -->
143 <?php endif; ?>
144 <!-- firstHeading -->
145 <h1 id="firstHeading" class="firstHeading"><?php $this->html( 'title' ) ?></h1>
146 <!-- /firstHeading -->
147 <!-- bodyContent -->
148 <div id="bodyContent">
149 <!-- tagline -->
150 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
151 <!-- /tagline -->
152 <!-- subtitle -->
153 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html( 'subtitle' ) ?></div>
154 <!-- /subtitle -->
155 <?php if ( $this->data['undelete'] ): ?>
156 <!-- undelete -->
157 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
158 <!-- /undelete -->
159 <?php endif; ?>
160 <?php if($this->data['newtalk'] ): ?>
161 <!-- newtalk -->
162 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
163 <!-- /newtalk -->
164 <?php endif; ?>
165 <?php if ( $this->data['showjumplinks'] ): ?>
166 <!-- jumpto -->
167 <div id="jump-to-nav">
168 <?php $this->msg( 'jumpto' ) ?> <a href="#mw-head"><?php $this->msg( 'jumptonavigation' ) ?></a>,
169 <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a>
170 </div>
171 <!-- /jumpto -->
172 <?php endif; ?>
173 <!-- bodytext -->
174 <?php $this->html( 'bodytext' ) ?>
175 <!-- /bodytext -->
176 <?php if ( $this->data['catlinks'] ): ?>
177 <!-- catlinks -->
178 <?php $this->html( 'catlinks' ); ?>
179 <!-- /catlinks -->
180 <?php endif; ?>
181 <?php if ( $this->data['dataAfterContent'] ): ?>
182 <!-- dataAfterContent -->
183 <?php $this->html( 'dataAfterContent' ); ?>
184 <!-- /dataAfterContent -->
185 <?php endif; ?>
186 <div class="visualClear"></div>
187 </div>
188 <!-- /bodyContent -->
189 </div>
190 <!-- /content -->
191 <!-- header -->
192 <div id="mw-head" class="noprint">
193 <?php $this->renderNavigation( 'PERSONAL' ); ?>
194 <div id="left-navigation">
195 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
196 </div>
197 <div id="right-navigation">
198 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?>
199 </div>
200 </div>
201 <!-- /header -->
202 <!-- panel -->
203 <div id="mw-panel" class="noprint">
204 <!-- logo -->
205 <div id="p-logo"><a style="background-image: url(<?php $this->text( 'logopath' ) ?>);" href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>" <?php echo $this->skin->tooltipAndAccesskey( 'p-logo' ) ?>></a></div>
206 <!-- /logo -->
207 <?php $this->renderPortals( $this->data['sidebar'] ); ?>
208 </div>
209 <!-- /panel -->
210 <!-- footer -->
211 <div id="footer"<?php $this->html('userlangattributes') ?>>
212 <?php foreach( $this->getFooterLinks() as $category => $links ): ?>
213 <ul id="footer-<?php echo $category ?>">
214 <?php foreach( $links as $link ): ?>
215 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
216 <?php endforeach; ?>
217 </ul>
218 <?php endforeach; ?>
219 <?php $footericons = $this->getFooterIcons("icononly");
220 if ( count( $footericons ) > 0 ): ?>
221 <ul id="footer-icons" class="noprint">
222 <?php foreach ( $footericons as $blockName => $footerIcons ): ?>
223 <li id="footer-<?php echo htmlspecialchars($blockName); ?>ico">
224 <?php foreach ( $footerIcons as $icon ): ?>
225 <?php echo $this->skin->makeFooterIcon( $icon ); ?>
226
227 <?php endforeach; ?>
228 </li>
229 <?php endforeach; ?>
230 </ul>
231 <?php endif; ?>
232 <div style="clear:both"></div>
233 </div>
234 <!-- /footer -->
235 <!-- fixalpha -->
236 <script type="<?php $this->text('jsmimetype') ?>"> if ( window.isMSIE55 ) fixalpha(); </script>
237 <!-- /fixalpha -->
238 <?php $this->printTrail(); ?>
239
240 </body>
241 </html>
242 <?php
243 }
244
245 /**
246 * Render a series of portals
247 */
248 private function renderPortals( $portals ) {
249 // Force the rendering of the following portals
250 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
251 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
252 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
253 // Render portals
254 foreach ( $portals as $name => $content ) {
255 echo "\n<!-- {$name} -->\n";
256 switch( $name ) {
257 case 'SEARCH':
258 break;
259 case 'TOOLBOX':
260 $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
261 break;
262 case 'LANGUAGES':
263 if ( $this->data['language_urls'] ) {
264 $this->renderPortal("lang", $this->data['language_urls'], "otherlanguages");
265 }
266 break;
267 default:
268 $this->renderPortal($name, $content);
269 break;
270 }
271 echo "\n<!-- /{$name} -->\n";
272 }
273 }
274
275 private function renderPortal($name, $content, $msg=null, $hook=null) {
276 if ( !isset($msg) ) {
277 $msg = $name;
278 }
279 ?>
280 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo $this->skin->tooltip( 'p-' . $name ) ?>>
281 <h5<?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $msg ); if ( wfEmptyMsg( $msg, $out ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?></h5>
282 <div class="body">
283 <?php
284 if ( is_array( $content ) ): ?>
285 <ul>
286 <?php
287 foreach( $content as $key => $val ): ?>
288 <?php echo $this->makeListItem($key, $val); ?>
289
290 <?php
291 endforeach;
292 if ( isset($hook) ) {
293 wfRunHooks( $hook, array( &$this ) );
294 }
295 ?>
296 </ul>
297 <?php
298 else: ?>
299 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?>
300 <?php
301 endif; ?>
302 </div>
303 </div>
304 <?php
305 }
306
307 /**
308 * Render one or more navigations elements by name, automatically reveresed
309 * when UI is in RTL mode
310 */
311 private function renderNavigation( $elements ) {
312 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
313
314 // If only one element was given, wrap it in an array, allowing more
315 // flexible arguments
316 if ( !is_array( $elements ) ) {
317 $elements = array( $elements );
318 // If there's a series of elements, reverse them when in RTL mode
319 } else if ( wfUILang()->isRTL() ) {
320 $elements = array_reverse( $elements );
321 }
322 // Render elements
323 foreach ( $elements as $name => $element ) {
324 echo "\n<!-- {$name} -->\n";
325 switch ( $element ) {
326 case 'NAMESPACES':
327 ?>
328 <div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
329 <h5><?php $this->msg('namespaces') ?></h5>
330 <ul<?php $this->html('userlangattributes') ?>>
331 <?php foreach ($this->data['namespace_urls'] as $link ): ?>
332 <li <?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></span></li>
333 <?php endforeach; ?>
334 </ul>
335 </div>
336 <?php
337 break;
338 case 'VARIANTS':
339 ?>
340 <div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
341 <?php if ( $wgVectorShowVariantName ): ?>
342 <h4>
343 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
344 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?>
345 <?php echo htmlspecialchars( $link['text'] ) ?>
346 <?php endif; ?>
347 <?php endforeach; ?>
348 </h4>
349 <?php endif; ?>
350 <h5><span><?php $this->msg('variants') ?></span><a href="#"></a></h5>
351 <div class="menu">
352 <ul<?php $this->html('userlangattributes') ?>>
353 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
354 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
355 <?php endforeach; ?>
356 </ul>
357 </div>
358 </div>
359 <?php
360 break;
361 case 'VIEWS':
362 ?>
363 <div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
364 <h5><?php $this->msg('views') ?></h5>
365 <ul<?php $this->html('userlangattributes') ?>>
366 <?php foreach ( $this->data['view_urls'] as $link ): ?>
367 <li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo (array_key_exists('img',$link) ? '<img src="'.$link['img'].'" alt="'.$link['text'].'" />' : htmlspecialchars( $link['text'] ) ) ?></a></span></li>
368 <?php endforeach; ?>
369 </ul>
370 </div>
371 <?php
372 break;
373 case 'ACTIONS':
374 ?>
375 <div id="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
376 <h5><span><?php $this->msg('actions') ?></span><a href="#"></a></h5>
377 <div class="menu">
378 <ul<?php $this->html('userlangattributes') ?>>
379 <?php foreach ($this->data['action_urls'] as $link ): ?>
380 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
381 <?php endforeach; ?>
382 </ul>
383 </div>
384 </div>
385 <?php
386 break;
387 case 'PERSONAL':
388 ?>
389 <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
390 <h5><?php $this->msg('personaltools') ?></h5>
391 <ul<?php $this->html('userlangattributes') ?>>
392 <?php foreach($this->getPersonalTools() as $key => $item) { ?>
393 <?php echo $this->makeListItem($key, $item); ?>
394
395 <?php } ?>
396 </ul>
397 </div>
398 <?php
399 break;
400 case 'SEARCH':
401 ?>
402 <div id="p-search">
403 <h5<?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
404 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
405 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
406 <?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
407 <div id="simpleSearch">
408 <?php if ( $this->data['rtl'] ): ?>
409 <?php echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin->getSkinStylePath('images/search-rtl.png') )); ?>
410 <?php endif; ?>
411 <?php echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?>
412 <?php if ( !$this->data['rtl'] ): ?>
413 <?php echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin->getSkinStylePath('images/search-ltr.png') )); ?>
414 <?php endif; ?>
415 </div>
416 <?php else: ?>
417 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
418 <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?>
419 <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?>
420 <?php endif; ?>
421 </form>
422 </div>
423 <?php
424
425 break;
426 }
427 echo "\n<!-- /{$name} -->\n";
428 }
429 }
430 }