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, $wgRequest;
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.
37 $min = $wgRequest->getFuzzyBool( 'debug' ) ?
'' : '.min';
38 $out->addHeadItem( 'csshover',
39 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
40 htmlspecialchars( $wgLocalStylePath ) .
41 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
46 * Load skin and user CSS files in the correct order
48 * @param $out OutputPage object
50 function setupSkinUserCss( OutputPage
$out ){
51 parent
::setupSkinUserCss( $out );
52 $out->addModuleStyles( 'skins.vector' );
57 * QuickTemplate class for Vector skin
60 class VectorTemplate
extends BaseTemplate
{
65 * @var Cached skin object
72 * Outputs the entire contents of the XHTML page
74 public function execute() {
75 global $wgRequest, $wgLang, $wgVectorUseIconWatch;
77 $this->skin
= $this->data
['skin'];
78 $action = $wgRequest->getText( 'action' );
80 // Build additional attributes for navigation urls
81 //$nav = $this->skin->buildNavigationUrls();
82 $nav = $this->data
['content_navigation'];
84 if ( $wgVectorUseIconWatch ) {
85 $mode = $this->skin
->mTitle
->userIsWatching() ?
'unwatch' : 'watch';
86 if ( isset($nav['actions'][$mode]) ) {
87 $nav['views'][$mode] = $nav['actions'][$mode];
88 $nav['views'][$mode]['class'] = rtrim('icon ' . $nav['views'][$mode]['class'], ' ');
89 $nav['views'][$mode]['primary'] = true;
90 unset($nav['actions'][$mode]);
94 foreach ( $nav as $section => $links ) {
95 foreach ( $links as $key => $link ) {
96 if ( $section == "views" && !(isset($link["primary"]) && $link["primary"]) ) {
97 $link['class'] = rtrim('collapsible ' . $link['class'], ' ');
100 $xmlID = isset($link["id"]) ?
$link["id"] : 'ca-' . $xmlID;
101 $nav[$section][$key]['attributes'] =
102 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
103 if ( $link['class'] ) {
104 $nav[$section][$key]['attributes'] .=
105 ' class="' . htmlspecialchars( $link['class'] ) . '"';
106 unset( $nav[$section][$key]['class'] );
108 if ( isset($link['tooltiponly']) && $link['tooltiponly'] ) {
109 $nav[$section][$key]['key'] =
110 $this->skin
->tooltip( $xmlID );
112 $nav[$section][$key]['key'] =
113 $this->skin
->tooltipAndAccesskey( $xmlID );
117 $this->data
['namespace_urls'] = $nav['namespaces'];
118 $this->data
['view_urls'] = $nav['views'];
119 $this->data
['action_urls'] = $nav['actions'];
120 $this->data
['variant_urls'] = $nav['variants'];
122 // Reverse horizontally rendered navigation elements
123 if ( $wgLang->isRTL() ) {
124 $this->data
['view_urls'] =
125 array_reverse( $this->data
['view_urls'] );
126 $this->data
['namespace_urls'] =
127 array_reverse( $this->data
['namespace_urls'] );
128 $this->data
['personal_urls'] =
129 array_reverse( $this->data
['personal_urls'] );
132 $this->html( 'headelement' );
134 <div id
="mw-page-base" class="noprint"></div
>
135 <div id
="mw-head-base" class="noprint"></div
>
137 <div id
="content"<?php
$this->html('specialpageattributes') ?
>>
139 <div id
="mw-js-message" style
="display:none;"<?php
$this->html('userlangattributes') ?
>></div
>
140 <?php
if ( $this->data
['sitenotice'] ): ?
>
142 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
145 <!-- firstHeading
-->
146 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
147 <!-- /firstHeading
-->
149 <div id
="bodyContent">
151 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
154 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
156 <?php
if ( $this->data
['undelete'] ): ?
>
158 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
161 <?php
if($this->data
['newtalk'] ): ?
>
163 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
166 <?php
if ( $this->data
['showjumplinks'] ): ?
>
168 <div id
="jump-to-nav">
169 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
170 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
175 <?php
$this->html( 'bodytext' ) ?
>
177 <?php
if ( $this->data
['catlinks'] ): ?
>
179 <?php
$this->html( 'catlinks' ); ?
>
182 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
183 <!-- dataAfterContent
-->
184 <?php
$this->html( 'dataAfterContent' ); ?
>
185 <!-- /dataAfterContent
-->
187 <div
class="visualClear"></div
>
189 <!-- /bodyContent
-->
193 <div id
="mw-head" class="noprint">
194 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
195 <div id
="left-navigation">
196 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
198 <div id
="right-navigation">
199 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
204 <div id
="mw-panel" class="noprint">
206 <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
>
208 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
212 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
213 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
214 <ul id
="footer-<?php echo $category ?>">
215 <?php
foreach( $links as $link ): ?
>
216 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
220 <?php
$footericons = $this->getFooterIcons("icononly");
221 if ( count( $footericons ) > 0 ): ?
>
222 <ul id
="footer-icons" class="noprint">
223 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
224 <li id
="footer-<?php echo htmlspecialchars($blockName); ?>ico">
225 <?php
foreach ( $footerIcons as $icon ): ?
>
226 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
233 <div style
="clear:both"></div
>
237 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
239 <?php
$this->printTrail(); ?
>
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";