From 4ac963f70f080283b156caa90ddec8e52d3e21b7 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 23 May 2011 16:32:52 +0000 Subject: [PATCH] * 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() --- includes/Skin.php | 22 ++++++++++++---------- includes/SkinTemplate.php | 2 +- skins/CologneBlue.php | 10 +++++----- skins/MonoBook.php | 2 +- skins/Vector.php | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index 4cd89c2d06..cab34d272c 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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 { diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index cca86c178b..f639cb0994 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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, diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index b9745a52b7..c395e6a9db 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -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
" . htmlspecialchars( $h ) . "
"; } @@ -231,7 +231,7 @@ class CologneBlueTemplate extends LegacyTemplate { htmlspecialchars( $link['text'] ) . '' . $sep; } } - $barnumber = $barnumber + 1; + $barnumber++; } if ( $wgOut->isArticle() ) { diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 6acce0fe03..23d5417711 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -288,7 +288,7 @@ class MonoBookTemplate extends BaseTemplate { echo ' ' . Html::openElement( 'div', $portletAttribs ); ?> -
+
exists() ? $msg->text() : $bar ); ?>