Moved language attribute generation to SkinTemplate.php as requested by Tim Starling...
authorRemember the dot <rememberthedot@users.mediawiki.org>
Thu, 4 Jun 2009 03:14:27 +0000 (03:14 +0000)
committerRemember the dot <rememberthedot@users.mediawiki.org>
Thu, 4 Jun 2009 03:14:27 +0000 (03:14 +0000)
includes/SkinTemplate.php
skins/MonoBook.php
skins/Vector.php

index 02721cf..a08d2fb 100644 (file)
@@ -276,6 +276,7 @@ class SkinTemplate extends Skin {
                $tpl->setRef( 'userpage', $this->userpage );
                $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
                $tpl->set( 'userlang', $wgLang->getCode() );
+               $tpl->set( 'userlangattributes', 'lang="' . $wgLang->getCode() . '" xml:lang="' . $wgLang->getCode() . '"' );
                $tpl->set( 'pagecss', $this->setupPageCss() );
                $tpl->setRef( 'usercss', $this->usercss );
                $tpl->setRef( 'userjs', $this->userjs );
index f92cbf4..8d82f73 100644 (file)
@@ -135,7 +135,7 @@ class MonoBookTemplate extends QuickTemplate {
        <div id="p-cactions" class="portlet">
                <h5><?php $this->msg('views') ?></h5>
                <div class="pBody">
-                       <ul <?php echo $this->langAttributes() ?>>
+                       <ul <?php $this->html('userlangattributes') ?>>
        <?php           foreach($this->data['content_actions'] as $key => $tab) {
                                        echo '
                                 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
@@ -163,7 +163,7 @@ class MonoBookTemplate extends QuickTemplate {
        <div class="portlet" id="p-personal">
                <h5><?php $this->msg('personaltools') ?></h5>
                <div class="pBody">
-                       <ul <?php echo $this->langAttributes() ?>>
+                       <ul <?php $this->html('userlangattributes') ?>>
 <?php                  foreach($this->data['personal_urls'] as $key => $item) { ?>
                                <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
                                        if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
@@ -252,7 +252,7 @@ class MonoBookTemplate extends QuickTemplate {
                global $wgUseTwoButtonsSearchForm;
 ?>
        <div id="p-search" class="portlet">
-               <h5 <?php echo $this->langAttributes() ?>><label for="searchInput"><?php $this->msg('search') ?></label></h5>
+               <h5 <?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg('search') ?></label></h5>
                <div id="searchBody" class="pBody">
                        <form action="<?php $this->text('wgScript') ?>" id="searchform"><div>
                                <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
@@ -274,7 +274,7 @@ class MonoBookTemplate extends QuickTemplate {
        function toolbox() {
 ?>
        <div class="portlet" id="p-tb">
-               <h5 <?php echo $this->langAttributes() ?>><?php $this->msg('toolbox') ?></h5>
+               <h5 <?php $this->html('userlangattributes')?>><?php $this->msg('toolbox') ?></h5>
                <div class="pBody">
                        <ul>
 <?php
@@ -335,7 +335,7 @@ class MonoBookTemplate extends QuickTemplate {
                if( $this->data['language_urls'] ) {
 ?>
        <div id="p-lang" class="portlet">
-               <h5 <?php echo $this->langAttributes() ?>><?php $this->msg('otherlanguages') ?></h5>
+               <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
                <div class="pBody">
                        <ul>
 <?php          foreach($this->data['language_urls'] as $langlink) { ?>
@@ -353,7 +353,7 @@ class MonoBookTemplate extends QuickTemplate {
        function customBox( $bar, $cont ) {
 ?>
        <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
-               <h5 <?php echo $this->langAttributes() ?>><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
+               <h5 <?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
                <div class='pBody'>
 <?php   if ( is_array( $cont ) ) { ?>
                        <ul>
@@ -372,11 +372,6 @@ class MonoBookTemplate extends QuickTemplate {
        </div>
 <?php
        }
-
-       private function langAttributes() {
-               $languageCode = $this->data['userlang'];
-               return 'lang="' . $languageCode . '" xml:lang="' . $languageCode . '"';
-       }
 } // end of class
 
 
index 4f5358a..a98e4ab 100644 (file)
@@ -540,7 +540,7 @@ class VectorTemplate extends QuickTemplate {
                                                <div id="personal">
                                                        <div class="buffer">
                                                                <h5><?php $this->msg('personaltools') ?></h5>
-                                                               <ul <?php echo $this->langAttributes() ?>>
+                                                               <ul <?php $this->html('userlangattributes') ?>>
                                                                        <?php foreach($this->data['personal_urls'] as $key => $item): ?>
                                                                                <li <?= $item['attributes'] ?>><a href="<?php echo htmlspecialchars($item['href']) ?>"<?php echo $item['key'] ?><?php if(!empty($item['class'])): ?> class="<?php echo htmlspecialchars($item['class']) ?>"<?php endif; ?>><?php echo htmlspecialchars($item['text']) ?></a></li>
                                                                        <?php endforeach; ?>
@@ -553,7 +553,7 @@ class VectorTemplate extends QuickTemplate {
                                                <!-- namespaces -->
                                                <div id="namespaces">
                                                        <h5><?php $this->msg('namespaces') ?></h5>
-                                                       <ul <?php echo $this->langAttributes() ?>>
+                                                       <ul <?php $this->html('userlangattributes') ?>>
                                                                <?php foreach ($this->data['namespace_urls'] as $key => $link ): ?>
                                                                        <li <?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
                                                                <?php endforeach; ?>
@@ -565,7 +565,7 @@ class VectorTemplate extends QuickTemplate {
                                                <div id="variants">
                                                        <h5><div class="icon"><span><?php $this->msg('variants') ?></span></div></h5>
                                                        <div class="menu">
-                                                               <ul <?php echo $this->langAttributes() ?>>
+                                                               <ul <?php $this->html('userlangattributes') ?>>
                                                                        <?php foreach ($this->data['variant_urls'] as $key => $link ): ?>
                                                                                <li<?php echo $link['attributes'] ?><?php if(!empty($link['class'])): ?> class="<?php echo htmlspecialchars($link['class']) ?>"<?php endif; ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
                                                                        <?php endforeach; ?>
@@ -580,7 +580,7 @@ class VectorTemplate extends QuickTemplate {
                                                <?php if ( count( $this->data['view_urls'] ) > 0 ): ?>
                                                <div id="views">
                                                        <h5><?php $this->msg('views') ?></h5>
-                                                       <ul <?php echo $this->langAttributes() ?>>
+                                                       <ul <?php $this->html('userlangattributes') ?>>
                                                                <?php foreach ($this->data['view_urls'] as $key => $link ): ?>
                                                                        <li<?php echo $link['attributes'] ?><?php if(!empty($link['class'])): ?> class="<?php echo htmlspecialchars($link['class']) ?>"<?php endif; ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
                                                                <?php endforeach; ?>
@@ -593,7 +593,7 @@ class VectorTemplate extends QuickTemplate {
                                                <div id="actions">
                                                        <h5><div class="icon"><span><?php $this->msg('actions') ?></span></div></h5>
                                                        <div class="menu">
-                                                               <ul <?php echo $this->langAttributes() ?>>
+                                                               <ul <?php $this->html('userlangattributes') ?>>
                                                                        <?php foreach ($this->data['action_urls'] as $key => $link ): ?>
                                                                                <li<?php echo $link['attributes'] ?><?php if(!empty($link['class'])): ?> class="<?php echo htmlspecialchars($link['class']) ?>"<?php endif; ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
                                                                        <?php endforeach; ?>
@@ -605,7 +605,7 @@ class VectorTemplate extends QuickTemplate {
                                                <!-- search -->
                                                <div id="search">
                                                        <div class="buffer">
-                                                               <h5 <?php echo $this->langAttributes() ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
+                                                               <h5 <?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
                                                                <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
                                                                        <div>
                                                                                <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
@@ -710,7 +710,7 @@ class VectorTemplate extends QuickTemplate {
        private function toolBox() {
 ?>
        <div class="portal" id="p-tb">
-               <h5 <?php echo $this->langAttributes() ?>><?php $this->msg( 'toolbox' ) ?></h5>
+               <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg( 'toolbox' ) ?></h5>
                <div class="body">
                        <ul>
                        <?php if( $this->data['notspecialpage'] ): ?>
@@ -757,7 +757,7 @@ class VectorTemplate extends QuickTemplate {
                if( $this->data['language_urls'] ) {
 ?>
 <div class="portal" id="p-lang">
-       <h5 <?php echo $this->langAttributes() ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
+       <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
        <div class="body">
                <ul>
                <?php foreach ( $this->data['language_urls'] as $langlink ): ?>
@@ -778,7 +778,7 @@ class VectorTemplate extends QuickTemplate {
        private function customBox( $bar, $content ) {
 ?>
 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip( 'p-' . $bar ) ?>>
-       <h5 <?php echo $this->langAttributes() ?>><?php $out = wfMsg( $bar ); if ( wfEmptyMsg( $bar, $out ) ) echo htmlspecialchars( $bar ); else echo htmlspecialchars( $out ); ?></h5>
+       <h5 <?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $bar ); if ( wfEmptyMsg( $bar, $out ) ) echo htmlspecialchars( $bar ); else echo htmlspecialchars( $out ); ?></h5>
        <div class="body">
                <?php if ( is_array( $content ) ): ?>
                <ul>
@@ -793,12 +793,4 @@ class VectorTemplate extends QuickTemplate {
 </div>
 <?php
        }
-
-       /**
-        * Build attributes describing user language
-        * @return HTML and XML Language attributes
-        */
-       private function langAttributes() {
-               return 'lang="' . $this->data['userlang'] . '" xml:lang="' . $this->data['userlang'] . '"';
-       }
 }