3 * Vector - Branch of MonoBook which has many usability improvements and
4 * somewhat cleaner code.
11 if( !defined( 'MEDIAWIKI' ) ) {
16 * SkinTemplate class for Vector skin
19 class SkinVector
extends SkinTemplate
{
22 var $skinname = 'vector', $stylename = 'vector',
23 $template = 'VectorTemplate', $useHeadElement = true;
26 * Initializes output page and sets up skin-specific parameters
27 * @param $out OutputPage object to initialize
29 public function initPage( OutputPage
$out ) {
30 global $wgLocalStylePath;
32 parent
::initPage( $out );
34 // Append CSS which includes IE only behavior fixes for hover support -
35 // this is better than including this in a CSS fille since it doesn't
36 // wait for the CSS file to load before fetching the HTC file.
38 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
39 htmlspecialchars( $wgLocalStylePath ) .
40 "/{$this->stylename}/csshover.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 Cached skin object
71 * Outputs the entire contents of the XHTML page
73 public function execute() {
74 global $wgRequest, $wgLang, $wgVectorUseIconWatch;
76 $this->skin
= $this->data
['skin'];
77 $action = $wgRequest->getText( 'action' );
79 // Build additional attributes for navigation urls
80 //$nav = $this->skin->buildNavigationUrls();
81 $nav = $this->data
['content_navigation'];
83 if ( $wgVectorUseIconWatch ) {
84 $mode = $this->skin
->mTitle
->userIsWatching() ?
'unwatch' : 'watch';
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]);
91 foreach ( $nav as $section => $links ) {
92 foreach ( $links as $key => $link ) {
93 if ( $section == "views" && !(isset($link["primary"]) && $link["primary"]) ) {
94 $link['class'] = rtrim('collapsible ' . $link['class'], ' ');
97 $xmlID = isset($link["id"]) ?
$link["id"] : 'ca-' . $xmlID;
98 $nav[$section][$key]['attributes'] =
99 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
100 if ( $link['class'] ) {
101 $nav[$section][$key]['attributes'] .=
102 ' class="' . htmlspecialchars( $link['class'] ) . '"';
103 unset( $nav[$section][$key]['class'] );
105 if ( isset($link['tooltiponly']) && $link['tooltiponly'] ) {
106 $nav[$section][$key]['key'] =
107 $this->skin
->tooltip( $xmlID );
109 $nav[$section][$key]['key'] =
110 $this->skin
->tooltipAndAccesskey( $xmlID );
114 $this->data
['namespace_urls'] = $nav['namespaces'];
115 $this->data
['view_urls'] = $nav['views'];
116 $this->data
['action_urls'] = $nav['actions'];
117 $this->data
['variant_urls'] = $nav['variants'];
119 // Reverse horizontally rendered navigation elements
120 if ( $wgLang->isRTL() ) {
121 $this->data
['view_urls'] =
122 array_reverse( $this->data
['view_urls'] );
123 $this->data
['namespace_urls'] =
124 array_reverse( $this->data
['namespace_urls'] );
125 $this->data
['personal_urls'] =
126 array_reverse( $this->data
['personal_urls'] );
129 $this->html( 'headelement' );
131 <div id
="mw-page-base" class="noprint"></div
>
132 <div id
="mw-head-base" class="noprint"></div
>
134 <div id
="content"<?php
$this->html('specialpageattributes') ?
>>
136 <div id
="mw-js-message" style
="display:none;"<?php
$this->html('userlangattributes') ?
>></div
>
137 <?php
if ( $this->data
['sitenotice'] ): ?
>
139 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
142 <!-- firstHeading
-->
143 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
144 <!-- /firstHeading
-->
146 <div id
="bodyContent">
148 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
151 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
153 <?php
if ( $this->data
['undelete'] ): ?
>
155 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
158 <?php
if($this->data
['newtalk'] ): ?
>
160 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
163 <?php
if ( $this->data
['showjumplinks'] ): ?
>
165 <div id
="jump-to-nav">
166 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
167 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
172 <?php
$this->html( 'bodytext' ) ?
>
174 <?php
if ( $this->data
['catlinks'] ): ?
>
176 <?php
$this->html( 'catlinks' ); ?
>
179 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
180 <!-- dataAfterContent
-->
181 <?php
$this->html( 'dataAfterContent' ); ?
>
182 <!-- /dataAfterContent
-->
184 <div
class="visualClear"></div
>
186 <!-- /bodyContent
-->
190 <div id
="mw-head" class="noprint">
191 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
192 <div id
="left-navigation">
193 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
195 <div id
="right-navigation">
196 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
201 <div id
="mw-panel" class="noprint">
203 <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
>
205 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
209 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
210 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
211 <ul id
="footer-<?php echo $category ?>">
212 <?php
foreach( $links as $link ): ?
>
213 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
217 <?php
$footericons = $this->getFooterIcons("icononly");
218 if ( count( $footericons ) > 0 ): ?
>
219 <ul id
="footer-icons" class="noprint">
220 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
221 <li id
="footer-<?php echo htmlspecialchars($blockName); ?>ico">
222 <?php
foreach ( $footerIcons as $icon ): ?
>
223 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
230 <div style
="clear:both"></div
>
233 <?php
$this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?
>
235 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
237 <?php
$this->html( 'reporttime' ) ?
>
238 <?php
if ( $this->data
['debug'] ): ?
>
239 <!-- Debug output
: <?php
$this->text( 'debug' ); ?
> -->
247 * Render a series of portals
249 private function renderPortals( $portals ) {
250 // Force the rendering of the following portals
251 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
252 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
253 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
255 foreach ( $portals as $name => $content ) {
256 echo "\n<!-- {$name} -->\n";
261 $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
264 if ( $this->data
['language_urls'] ) {
265 $this->renderPortal("lang", $this->data
['language_urls'], "otherlanguages");
269 $this->renderPortal($name, $content);
272 echo "\n<!-- /{$name} -->\n";
276 private function renderPortal($name, $content, $msg=null, $hook=null) {
277 if ( !isset($msg) ) {
281 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo $this->skin
->tooltip( 'p-' . $name ) ?
>>
282 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $msg ); if ( wfEmptyMsg( $msg, $out ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?
></h5
>
285 if ( is_array( $content ) ): ?
>
288 foreach( $content as $key => $val ): ?
>
289 <?php
echo $this->makeListItem($key, $val); ?
>
293 if ( isset($hook) ) {
294 wfRunHooks( $hook, array( &$this ) );
300 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
309 * Render one or more navigations elements by name, automatically reveresed
310 * when UI is in RTL mode
312 private function renderNavigation( $elements ) {
313 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
315 // If only one element was given, wrap it in an array, allowing more
316 // flexible arguments
317 if ( !is_array( $elements ) ) {
318 $elements = array( $elements );
319 // If there's a series of elements, reverse them when in RTL mode
320 } else if ( wfUILang()->isRTL() ) {
321 $elements = array_reverse( $elements );
324 foreach ( $elements as $name => $element ) {
325 echo "\n<!-- {$name} -->\n";
326 switch ( $element ) {
329 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
330 <h5
><?php
$this->msg('namespaces') ?
></h5
>
331 <ul
<?php
$this->html('userlangattributes') ?
>>
332 <?php
foreach ($this->data
['namespace_urls'] as $link ): ?
>
333 <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
>
341 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
342 <?php
if ( $wgVectorShowVariantName ): ?
>
344 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
345 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
346 <?php
echo htmlspecialchars( $link['text'] ) ?
>
351 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"></a
></h5
>
353 <ul
<?php
$this->html('userlangattributes') ?
>>
354 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
355 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
364 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
365 <h5
><?php
$this->msg('views') ?
></h5
>
366 <ul
<?php
$this->html('userlangattributes') ?
>>
367 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
368 <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
>
376 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
377 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"></a
></h5
>
379 <ul
<?php
$this->html('userlangattributes') ?
>>
380 <?php
foreach ($this->data
['action_urls'] as $link ): ?
>
381 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
390 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
391 <h5
><?php
$this->msg('personaltools') ?
></h5
>
392 <ul
<?php
$this->html('userlangattributes') ?
>>
393 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
394 <?php
echo $this->makeListItem($key, $item); ?
>
404 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
405 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
406 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
407 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
408 <div id
="simpleSearch">
409 <?php
if ( $this->data
['rtl'] ): ?
>
410 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-rtl.png') )); ?
>
412 <?php
echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?
>
413 <?php
if ( !$this->data
['rtl'] ): ?
>
414 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-ltr.png') )); ?
>
418 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
419 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?
>
420 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?
>
428 echo "\n<!-- /{$name} -->\n";