r88646 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88645‎ | r88646 | r88647 >
Date:16:32, 23 May 2011
Author:ialex
Status:ok
Tags:
Comment:
* Simplify message existence checks by using wfMessage() instead of wfMsg() with wfEmptyMsg()
* Fixed one check in Skin::addToSidebarPlain() that used user language for existence and content language for message's content
* Changed SkinTemplate::buildContentNavigationUrls() to use Title::getDefaultMessageText() instead of wfEmptyMsg()
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/skins/CologneBlue.php (modified) (history)
  • /trunk/phase3/skins/MonoBook.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/CologneBlue.php
@@ -216,12 +216,12 @@
217217
218218 $barnumber = 1;
219219 foreach ( $bar as $heading => $browseLinks ) {
220 - $heading_text = wfMsg ( $heading );
221220 if ( $barnumber > 1 ) {
222 - if ( wfEmptyMsg( $heading, $heading_text ) ) {
 221+ $headingMsg = wfMessage( $heading );
 222+ if ( $headingMsg->exists() ) {
 223+ $h = $headingMsg->text();
 224+ } else {
223225 $h = $heading;
224 - } else {
225 - $h = $heading_text;
226226 }
227227 $s .= "\n<h6>" . htmlspecialchars( $h ) . "</h6>";
228228 }
@@ -231,7 +231,7 @@
232232 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
233233 }
234234 }
235 - $barnumber = $barnumber + 1;
 235+ $barnumber++;
236236 }
237237
238238 if ( $wgOut->isArticle() ) {
Index: trunk/phase3/skins/Vector.php
@@ -298,7 +298,7 @@
299299 }
300300 ?>
301301 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo Linker::tooltip( 'p-' . $name ) ?>>
302 - <h5<?php $this->html( 'userlangattributes' ) ?>><?php $out = wfMsg( $msg ); if ( wfEmptyMsg( $msg ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?></h5>
 302+ <h5<?php $this->html( 'userlangattributes' ) ?>><?php $msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $msg ); ?></h5>
303303 <div class="body">
304304 <?php
305305 if ( is_array( $content ) ): ?>
Index: trunk/phase3/skins/MonoBook.php
@@ -288,7 +288,7 @@
289289 echo ' ' . Html::openElement( 'div', $portletAttribs );
290290 ?>
291291
292 - <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
 292+ <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
293293 <div class='pBody'>
294294 <?php if ( is_array( $cont ) ) { ?>
295295 <ul>
Index: trunk/phase3/includes/SkinTemplate.php
@@ -905,7 +905,7 @@
906906 ( $action == 'edit' || $action == 'submit' ) &&
907907 ( $section != 'new' )
908908 );
909 - $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $title->getText() ) ) ?
 909+ $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ?
910910 "edit" : "create";
911911 $content_navigation['views']['edit'] = array(
912912 'class' => ( $selected ? 'selected' : '' ) . $isTalkClass,
Index: trunk/phase3/includes/Skin.php
@@ -1253,22 +1253,24 @@
12541254 if ( strpos( $line, '|' ) !== false ) { // sanity check
12551255 $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
12561256 $line = array_map( 'trim', explode( '|', $line, 2 ) );
1257 - $link = wfMsgForContent( $line[0] );
12581257
1259 - if ( $link == '-' ) {
1260 - continue;
 1258+ $msgLink = wfMessage( $line[0] )->inContentLanguage();
 1259+ if ( $msgLink->exists() ) {
 1260+ $link = $msgLink->text();
 1261+ if ( $link == '-' ) {
 1262+ continue;
 1263+ }
 1264+ } else {
 1265+ $link = $line[0];
12611266 }
12621267
1263 - $text = wfMsgExt( $line[1], 'parsemag' );
1264 -
1265 - if ( wfEmptyMsg( $line[1] ) ) {
 1268+ $msgText = wfMessage( $line[1] );
 1269+ if ( $msgText->exists() ) {
 1270+ $text = $msgText->text();
 1271+ } else {
12661272 $text = $line[1];
12671273 }
12681274
1269 - if ( wfEmptyMsg( $line[0] ) ) {
1270 - $link = $line[0];
1271 - }
1272 -
12731275 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
12741276 $href = $link;
12751277 } else {

Status & tagging log