c67d3c231cddafb7040399446d74d830011af1d8
3 * Vector - Modern version of MonoBook with fresh look and many usability
11 if( !defined( 'MEDIAWIKI' ) ) {
16 * SkinTemplate class for Vector skin
19 class SkinVector
extends SkinTemplate
{
21 var $skinname = 'vector', $stylename = 'vector',
22 $template = 'VectorTemplate', $useHeadElement = true;
25 * Initializes output page and sets up skin-specific parameters
26 * @param $out OutputPage object to initialize
28 public function initPage( OutputPage
$out ) {
29 global $wgLocalStylePath, $wgRequest;
31 parent
::initPage( $out );
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]-->"
45 * Load skin and user CSS files in the correct order
47 * @param $out OutputPage object
49 function setupSkinUserCss( OutputPage
$out ){
50 parent
::setupSkinUserCss( $out );
51 $out->addModuleStyles( 'skins.vector' );
56 * QuickTemplate class for Vector skin
59 class VectorTemplate
extends BaseTemplate
{
64 * @var Skin Cached skin object
71 * Outputs the entire contents of the (X)HTML page
73 public function execute() {
74 global $wgLang, $wgVectorUseIconWatch;
76 $this->skin
= $this->data
['skin'];
78 // Build additional attributes for navigation urls
79 //$nav = $this->skin->buildNavigationUrls();
80 $nav = $this->data
['content_navigation'];
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]);
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'], ' ');
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'] );
107 if ( isset($link['tooltiponly']) && $link['tooltiponly'] ) {
108 $nav[$section][$key]['key'] =
109 $this->skin
->tooltip( $xmlID );
111 $nav[$section][$key]['key'] =
112 $this->skin
->tooltipAndAccesskey( $xmlID );
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'];
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'] );
131 $this->html( 'headelement' );
133 <div id
="mw-page-base" class="noprint"></div
>
134 <div id
="mw-head-base" class="noprint"></div
>
136 <div id
="content"<?php
$this->html('specialpageattributes') ?
>>
138 <div id
="mw-js-message" style
="display:none;"<?php
$this->html('userlangattributes') ?
>></div
>
139 <?php
if ( $this->data
['sitenotice'] ): ?
>
141 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
144 <!-- firstHeading
-->
145 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
146 <!-- /firstHeading
-->
148 <div id
="bodyContent">
149 <?php
if ( $this->data
['isarticle'] ): ?
>
151 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
155 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
157 <?php
if ( $this->data
['undelete'] ): ?
>
159 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
162 <?php
if($this->data
['newtalk'] ): ?
>
164 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
167 <?php
if ( $this->data
['showjumplinks'] ): ?
>
169 <div id
="jump-to-nav">
170 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
171 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
176 <?php
$this->html( 'bodytext' ) ?
>
178 <?php
if ( $this->data
['catlinks'] ): ?
>
180 <?php
$this->html( 'catlinks' ); ?
>
183 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
184 <!-- dataAfterContent
-->
185 <?php
$this->html( 'dataAfterContent' ); ?
>
186 <!-- /dataAfterContent
-->
188 <div
class="visualClear"></div
>
190 <!-- /bodyContent
-->
194 <div id
="mw-head" class="noprint">
195 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
196 <div id
="left-navigation">
197 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
199 <div id
="right-navigation">
200 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
205 <div id
="mw-panel" class="noprint">
207 <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
>
209 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
213 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
214 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
215 <ul id
="footer-<?php echo $category ?>">
216 <?php
foreach( $links as $link ): ?
>
217 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
221 <?php
$footericons = $this->getFooterIcons("icononly");
222 if ( count( $footericons ) > 0 ): ?
>
223 <ul id
="footer-icons" class="noprint">
224 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
225 <li id
="footer-<?php echo htmlspecialchars($blockName); ?>ico">
226 <?php
foreach ( $footerIcons as $icon ): ?
>
227 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
234 <div style
="clear:both"></div
>
238 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
240 <?php
$this->printTrail(); ?
>
248 * Render a series of portals
250 private function renderPortals( $portals ) {
251 // Force the rendering of the following portals
252 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
253 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
254 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
256 foreach ( $portals as $name => $content ) {
257 echo "\n<!-- {$name} -->\n";
262 $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
265 if ( $this->data
['language_urls'] ) {
266 $this->renderPortal("lang", $this->data
['language_urls'], "otherlanguages");
270 $this->renderPortal($name, $content);
273 echo "\n<!-- /{$name} -->\n";
277 private function renderPortal($name, $content, $msg=null, $hook=null) {
278 if ( !isset($msg) ) {
282 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo $this->skin
->tooltip( 'p-' . $name ) ?
>>
283 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $msg ); if ( wfEmptyMsg( $msg ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?
></h5
>
286 if ( is_array( $content ) ): ?
>
289 foreach( $content as $key => $val ): ?
>
290 <?php
echo $this->makeListItem($key, $val); ?
>
294 if ( isset($hook) ) {
295 wfRunHooks( $hook, array( &$this ) );
301 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
310 * Render one or more navigations elements by name, automatically reveresed
311 * when UI is in RTL mode
313 private function renderNavigation( $elements ) {
314 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
316 // If only one element was given, wrap it in an array, allowing more
317 // flexible arguments
318 if ( !is_array( $elements ) ) {
319 $elements = array( $elements );
320 // If there's a series of elements, reverse them when in RTL mode
321 } else if ( wfUILang()->isRTL() ) {
322 $elements = array_reverse( $elements );
325 foreach ( $elements as $name => $element ) {
326 echo "\n<!-- {$name} -->\n";
327 switch ( $element ) {
330 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
331 <h5
><?php
$this->msg('namespaces') ?
></h5
>
332 <ul
<?php
$this->html('userlangattributes') ?
>>
333 <?php
foreach ($this->data
['namespace_urls'] as $link ): ?
>
334 <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
>
342 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
343 <?php
if ( $wgVectorShowVariantName ): ?
>
345 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
346 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
347 <?php
echo htmlspecialchars( $link['text'] ) ?
>
352 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"></a
></h5
>
354 <ul
<?php
$this->html('userlangattributes') ?
>>
355 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
356 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
365 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
366 <h5
><?php
$this->msg('views') ?
></h5
>
367 <ul
<?php
$this->html('userlangattributes') ?
>>
368 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
369 <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
>
377 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
378 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"></a
></h5
>
380 <ul
<?php
$this->html('userlangattributes') ?
>>
381 <?php
foreach ($this->data
['action_urls'] as $link ): ?
>
382 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
391 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
392 <h5
><?php
$this->msg('personaltools') ?
></h5
>
393 <ul
<?php
$this->html('userlangattributes') ?
>>
394 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
395 <?php
echo $this->makeListItem($key, $item); ?
>
405 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
406 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
407 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
408 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
409 <div id
="simpleSearch">
410 <?php
if ( $this->data
['rtl'] ): ?
>
411 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-rtl.png') )); ?
>
413 <?php
echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?
>
414 <?php
if ( !$this->data
['rtl'] ): ?
>
415 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-ltr.png') )); ?
>
419 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
420 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?
>
421 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?
>
429 echo "\n<!-- /{$name} -->\n";