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 if ( isset($nav['actions'][$mode]) ) {
86 $nav['views'][$mode] = $nav['actions'][$mode];
87 $nav['views'][$mode]['class'] = rtrim('icon ' . $nav['views'][$mode]['class'], ' ');
88 $nav['views'][$mode]['primary'] = true;
89 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">
150 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
153 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
155 <?php
if ( $this->data
['undelete'] ): ?
>
157 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
160 <?php
if($this->data
['newtalk'] ): ?
>
162 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
165 <?php
if ( $this->data
['showjumplinks'] ): ?
>
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
>
174 <?php
$this->html( 'bodytext' ) ?
>
176 <?php
if ( $this->data
['catlinks'] ): ?
>
178 <?php
$this->html( 'catlinks' ); ?
>
181 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
182 <!-- dataAfterContent
-->
183 <?php
$this->html( 'dataAfterContent' ); ?
>
184 <!-- /dataAfterContent
-->
186 <div
class="visualClear"></div
>
188 <!-- /bodyContent
-->
192 <div id
="mw-head" class="noprint">
193 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
194 <div id
="left-navigation">
195 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
197 <div id
="right-navigation">
198 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
203 <div id
="mw-panel" class="noprint">
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
>
207 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
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
>
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 ); ?
>
232 <div style
="clear:both"></div
>
235 <?php
$this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?
>
237 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
239 <?php
$this->html( 'reporttime' ) ?
>
240 <?php
if ( $this->data
['debug'] ): ?
>
241 <!-- Debug output
: <?php
$this->text( 'debug' ); ?
> -->
249 * Render a series of portals
251 private function renderPortals( $portals ) {
252 // Force the rendering of the following portals
253 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
254 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
255 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
257 foreach ( $portals as $name => $content ) {
258 echo "\n<!-- {$name} -->\n";
263 $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
266 if ( $this->data
['language_urls'] ) {
267 $this->renderPortal("lang", $this->data
['language_urls'], "otherlanguages");
271 $this->renderPortal($name, $content);
274 echo "\n<!-- /{$name} -->\n";
278 private function renderPortal($name, $content, $msg=null, $hook=null) {
279 if ( !isset($msg) ) {
283 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo $this->skin
->tooltip( 'p-' . $name ) ?
>>
284 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $msg ); if ( wfEmptyMsg( $msg, $out ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?
></h5
>
287 if ( is_array( $content ) ): ?
>
290 foreach( $content as $key => $val ): ?
>
291 <?php
echo $this->makeListItem($key, $val); ?
>
295 if ( isset($hook) ) {
296 wfRunHooks( $hook, array( &$this ) );
302 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
311 * Render one or more navigations elements by name, automatically reveresed
312 * when UI is in RTL mode
314 private function renderNavigation( $elements ) {
315 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
317 // If only one element was given, wrap it in an array, allowing more
318 // flexible arguments
319 if ( !is_array( $elements ) ) {
320 $elements = array( $elements );
321 // If there's a series of elements, reverse them when in RTL mode
322 } else if ( wfUILang()->isRTL() ) {
323 $elements = array_reverse( $elements );
326 foreach ( $elements as $name => $element ) {
327 echo "\n<!-- {$name} -->\n";
328 switch ( $element ) {
331 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
332 <h5
><?php
$this->msg('namespaces') ?
></h5
>
333 <ul
<?php
$this->html('userlangattributes') ?
>>
334 <?php
foreach ($this->data
['namespace_urls'] as $link ): ?
>
335 <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
>
343 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
344 <?php
if ( $wgVectorShowVariantName ): ?
>
346 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
347 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
348 <?php
echo htmlspecialchars( $link['text'] ) ?
>
353 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"></a
></h5
>
355 <ul
<?php
$this->html('userlangattributes') ?
>>
356 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
357 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
366 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
367 <h5
><?php
$this->msg('views') ?
></h5
>
368 <ul
<?php
$this->html('userlangattributes') ?
>>
369 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
370 <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
>
378 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
379 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"></a
></h5
>
381 <ul
<?php
$this->html('userlangattributes') ?
>>
382 <?php
foreach ($this->data
['action_urls'] as $link ): ?
>
383 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
392 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
393 <h5
><?php
$this->msg('personaltools') ?
></h5
>
394 <ul
<?php
$this->html('userlangattributes') ?
>>
395 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
396 <?php
echo $this->makeListItem($key, $item); ?
>
406 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
407 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
408 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
409 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
410 <div id
="simpleSearch">
411 <?php
if ( $this->data
['rtl'] ): ?
>
412 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-rtl.png') )); ?
>
414 <?php
echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?
>
415 <?php
if ( !$this->data
['rtl'] ): ?
>
416 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-ltr.png') )); ?
>
420 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
421 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?
>
422 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?
>
430 echo "\n<!-- /{$name} -->\n";