* Simplify message existence checks by using wfMessage() instead of wfMsg() with...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 23 May 2011 16:32:52 +0000 (16:32 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 23 May 2011 16:32:52 +0000 (16:32 +0000)
* 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()

includes/Skin.php
includes/SkinTemplate.php
skins/CologneBlue.php
skins/MonoBook.php
skins/Vector.php

index 4cd89c2..cab34d2 100644 (file)
@@ -1253,22 +1253,24 @@ abstract class Skin {
                                if ( strpos( $line, '|' ) !== false ) { // sanity check
                                        $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
                                        $line = array_map( 'trim', explode( '|', $line, 2 ) );
-                                       $link = wfMsgForContent( $line[0] );
 
-                                       if ( $link == '-' ) {
-                                               continue;
+                                       $msgLink = wfMessage( $line[0] )->inContentLanguage();
+                                       if ( $msgLink->exists() ) {
+                                               $link = $msgLink->text();
+                                               if ( $link == '-' ) {
+                                                       continue;
+                                               }
+                                       } else {
+                                               $link = $line[0];
                                        }
 
-                                       $text = wfMsgExt( $line[1], 'parsemag' );
-
-                                       if ( wfEmptyMsg( $line[1] ) ) {
+                                       $msgText = wfMessage( $line[1] );
+                                       if ( $msgText->exists() ) {
+                                               $text = $msgText->text();
+                                       } else {
                                                $text = $line[1];
                                        }
 
-                                       if ( wfEmptyMsg( $line[0] ) ) {
-                                               $link = $line[0];
-                                       }
-
                                        if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
                                                $href = $link;
                                        } else {
index cca86c1..f639cb0 100644 (file)
@@ -905,7 +905,7 @@ class SkinTemplate extends Skin {
                                        ( $action == 'edit' || $action == 'submit' ) &&
                                        ( $section != 'new' )
                                );
-                               $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $title->getText() ) ) ?
+                               $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ?
                                        "edit" : "create";
                                $content_navigation['views']['edit'] = array(
                                        'class' => ( $selected ? 'selected' : '' ) . $isTalkClass,
index b9745a5..c395e6a 100644 (file)
@@ -216,12 +216,12 @@ class CologneBlueTemplate extends LegacyTemplate {
 
                $barnumber = 1;
                foreach ( $bar as $heading => $browseLinks ) {
-                       $heading_text = wfMsg ( $heading );
                        if ( $barnumber > 1 ) {
-                               if ( wfEmptyMsg( $heading, $heading_text ) ) {
-                                       $h = $heading;
+                               $headingMsg = wfMessage( $heading );
+                               if ( $headingMsg->exists() ) {
+                                       $h = $headingMsg->text();
                                } else {
-                                       $h = $heading_text;
+                                       $h = $heading;
                                }
                                $s .= "\n<h6>" . htmlspecialchars( $h ) . "</h6>";
                        }
@@ -231,7 +231,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                                                htmlspecialchars( $link['text'] ) . '</a>' . $sep;
                                }
                        }
-                       $barnumber = $barnumber + 1;
+                       $barnumber++;
                }
 
                if ( $wgOut->isArticle() ) {
index 6acce0f..23d5417 100644 (file)
@@ -288,7 +288,7 @@ class MonoBookTemplate extends BaseTemplate {
                echo '  ' . Html::openElement( 'div', $portletAttribs );
 ?>
 
-               <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
+               <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
                <div class='pBody'>
 <?php   if ( is_array( $cont ) ) { ?>
                        <ul>
index 189c1ab..357c48d 100644 (file)
@@ -298,7 +298,7 @@ class VectorTemplate extends BaseTemplate {
                }
                ?>
 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo Linker::tooltip( 'p-' . $name ) ?>>
-       <h5<?php $this->html( 'userlangattributes' ) ?>><?php $out = wfMsg( $msg ); if ( wfEmptyMsg( $msg ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?></h5>
+       <h5<?php $this->html( 'userlangattributes' ) ?>><?php $msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $msg ); ?></h5>
        <div class="body">
 <?php
                if ( is_array( $content ) ): ?>