r51448 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51447‎ | r51448 | r51449 >
Date:03:14, 4 June 2009
Author:rememberthedot
Status:ok
Tags:
Comment:
Moved language attribute generation to SkinTemplate.php as requested by Tim Starling, see r49350
Modified paths:
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/skins/MonoBook.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/Vector.php
@@ -540,7 +540,7 @@
541541 <div id="personal">
542542 <div class="buffer">
543543 <h5><?php $this->msg('personaltools') ?></h5>
544 - <ul <?php echo $this->langAttributes() ?>>
 544+ <ul <?php $this->html('userlangattributes') ?>>
545545 <?php foreach($this->data['personal_urls'] as $key => $item): ?>
546546 <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>
547547 <?php endforeach; ?>
@@ -553,7 +553,7 @@
554554 <!-- namespaces -->
555555 <div id="namespaces">
556556 <h5><?php $this->msg('namespaces') ?></h5>
557 - <ul <?php echo $this->langAttributes() ?>>
 557+ <ul <?php $this->html('userlangattributes') ?>>
558558 <?php foreach ($this->data['namespace_urls'] as $key => $link ): ?>
559559 <li <?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
560560 <?php endforeach; ?>
@@ -565,7 +565,7 @@
566566 <div id="variants">
567567 <h5><div class="icon"><span><?php $this->msg('variants') ?></span></div></h5>
568568 <div class="menu">
569 - <ul <?php echo $this->langAttributes() ?>>
 569+ <ul <?php $this->html('userlangattributes') ?>>
570570 <?php foreach ($this->data['variant_urls'] as $key => $link ): ?>
571571 <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>
572572 <?php endforeach; ?>
@@ -580,7 +580,7 @@
581581 <?php if ( count( $this->data['view_urls'] ) > 0 ): ?>
582582 <div id="views">
583583 <h5><?php $this->msg('views') ?></h5>
584 - <ul <?php echo $this->langAttributes() ?>>
 584+ <ul <?php $this->html('userlangattributes') ?>>
585585 <?php foreach ($this->data['view_urls'] as $key => $link ): ?>
586586 <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>
587587 <?php endforeach; ?>
@@ -593,7 +593,7 @@
594594 <div id="actions">
595595 <h5><div class="icon"><span><?php $this->msg('actions') ?></span></div></h5>
596596 <div class="menu">
597 - <ul <?php echo $this->langAttributes() ?>>
 597+ <ul <?php $this->html('userlangattributes') ?>>
598598 <?php foreach ($this->data['action_urls'] as $key => $link ): ?>
599599 <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>
600600 <?php endforeach; ?>
@@ -605,7 +605,7 @@
606606 <!-- search -->
607607 <div id="search">
608608 <div class="buffer">
609 - <h5 <?php echo $this->langAttributes() ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
 609+ <h5 <?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
610610 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
611611 <div>
612612 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
@@ -710,7 +710,7 @@
711711 private function toolBox() {
712712 ?>
713713 <div class="portal" id="p-tb">
714 - <h5 <?php echo $this->langAttributes() ?>><?php $this->msg( 'toolbox' ) ?></h5>
 714+ <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg( 'toolbox' ) ?></h5>
715715 <div class="body">
716716 <ul>
717717 <?php if( $this->data['notspecialpage'] ): ?>
@@ -757,7 +757,7 @@
758758 if( $this->data['language_urls'] ) {
759759 ?>
760760 <div class="portal" id="p-lang">
761 - <h5 <?php echo $this->langAttributes() ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
 761+ <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
762762 <div class="body">
763763 <ul>
764764 <?php foreach ( $this->data['language_urls'] as $langlink ): ?>
@@ -778,7 +778,7 @@
779779 private function customBox( $bar, $content ) {
780780 ?>
781781 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip( 'p-' . $bar ) ?>>
782 - <h5 <?php echo $this->langAttributes() ?>><?php $out = wfMsg( $bar ); if ( wfEmptyMsg( $bar, $out ) ) echo htmlspecialchars( $bar ); else echo htmlspecialchars( $out ); ?></h5>
 782+ <h5 <?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $bar ); if ( wfEmptyMsg( $bar, $out ) ) echo htmlspecialchars( $bar ); else echo htmlspecialchars( $out ); ?></h5>
783783 <div class="body">
784784 <?php if ( is_array( $content ) ): ?>
785785 <ul>
@@ -793,12 +793,4 @@
794794 </div>
795795 <?php
796796 }
797 -
798 - /**
799 - * Build attributes describing user language
800 - * @return HTML and XML Language attributes
801 - */
802 - private function langAttributes() {
803 - return 'lang="' . $this->data['userlang'] . '" xml:lang="' . $this->data['userlang'] . '"';
804 - }
805797 }
Index: trunk/phase3/skins/MonoBook.php
@@ -135,7 +135,7 @@
136136 <div id="p-cactions" class="portlet">
137137 <h5><?php $this->msg('views') ?></h5>
138138 <div class="pBody">
139 - <ul <?php echo $this->langAttributes() ?>>
 139+ <ul <?php $this->html('userlangattributes') ?>>
140140 <?php foreach($this->data['content_actions'] as $key => $tab) {
141141 echo '
142142 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
@@ -163,7 +163,7 @@
164164 <div class="portlet" id="p-personal">
165165 <h5><?php $this->msg('personaltools') ?></h5>
166166 <div class="pBody">
167 - <ul <?php echo $this->langAttributes() ?>>
 167+ <ul <?php $this->html('userlangattributes') ?>>
168168 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
169169 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
170170 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
@@ -252,7 +252,7 @@
253253 global $wgUseTwoButtonsSearchForm;
254254 ?>
255255 <div id="p-search" class="portlet">
256 - <h5 <?php echo $this->langAttributes() ?>><label for="searchInput"><?php $this->msg('search') ?></label></h5>
 256+ <h5 <?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg('search') ?></label></h5>
257257 <div id="searchBody" class="pBody">
258258 <form action="<?php $this->text('wgScript') ?>" id="searchform"><div>
259259 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
@@ -274,7 +274,7 @@
275275 function toolbox() {
276276 ?>
277277 <div class="portlet" id="p-tb">
278 - <h5 <?php echo $this->langAttributes() ?>><?php $this->msg('toolbox') ?></h5>
 278+ <h5 <?php $this->html('userlangattributes')?>><?php $this->msg('toolbox') ?></h5>
279279 <div class="pBody">
280280 <ul>
281281 <?php
@@ -335,7 +335,7 @@
336336 if( $this->data['language_urls'] ) {
337337 ?>
338338 <div id="p-lang" class="portlet">
339 - <h5 <?php echo $this->langAttributes() ?>><?php $this->msg('otherlanguages') ?></h5>
 339+ <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
340340 <div class="pBody">
341341 <ul>
342342 <?php foreach($this->data['language_urls'] as $langlink) { ?>
@@ -353,7 +353,7 @@
354354 function customBox( $bar, $cont ) {
355355 ?>
356356 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
357 - <h5 <?php echo $this->langAttributes() ?>><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
 357+ <h5 <?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
358358 <div class='pBody'>
359359 <?php if ( is_array( $cont ) ) { ?>
360360 <ul>
@@ -372,11 +372,6 @@
373373 </div>
374374 <?php
375375 }
376 -
377 - private function langAttributes() {
378 - $languageCode = $this->data['userlang'];
379 - return 'lang="' . $languageCode . '" xml:lang="' . $languageCode . '"';
380 - }
381376 } // end of class
382377
383378
Index: trunk/phase3/includes/SkinTemplate.php
@@ -276,6 +276,7 @@
277277 $tpl->setRef( 'userpage', $this->userpage );
278278 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
279279 $tpl->set( 'userlang', $wgLang->getCode() );
 280+ $tpl->set( 'userlangattributes', 'lang="' . $wgLang->getCode() . '" xml:lang="' . $wgLang->getCode() . '"' );
280281 $tpl->set( 'pagecss', $this->setupPageCss() );
281282 $tpl->setRef( 'usercss', $this->usercss );
282283 $tpl->setRef( 'userjs', $this->userjs );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49350Follow-up to r49331, reduce redundancy in language attribute generation in Mo...rememberthedot19:06, 9 April 2009

Status & tagging log