From 5700f36de116a4522f579627e2a75f303942d7fd Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 2 Apr 2010 08:00:40 +0000 Subject: [PATCH] * (bug 22867) "View source" tab is now only displayed if there's source text * Removed comment which is no longer true since the new localisation cache --- RELEASE-NOTES | 1 + includes/SkinTemplate.php | 2 +- includes/Title.php | 22 ++++++++++++++++++++-- skins/Vector.php | 4 ++-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0dedf556d4..f55062117c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -72,6 +72,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN logged in (anonpreviewwarning). * (bug 22935) image/x-ms-bmp mime type added for BMP files * (bug 23024) Special:ListFiles now escapes file names correctly +* (bug 22867) "View source" tab is now only displayed if there's source text === API changes in 1.17 === * (bug 22738) Allow filtering by action type on query=logevent diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 7d4588155d..619dd5c974 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -719,7 +719,7 @@ class SkinTemplate extends Skin { ); } } - } elseif ( $this->mTitle->isKnown() ) { + } elseif ( $this->mTitle->hasSourceText() ) { $content_actions['viewsource'] = array( 'class' => ($action == 'edit') ? 'selected' : false, 'text' => wfMsg( 'viewsource' ), diff --git a/includes/Title.php b/includes/Title.php index d3bd6ec63a..3feba538cb 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3644,8 +3644,6 @@ class Title { // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes // the full l10n of that language to be loaded. That takes much memory and // isn't needed. So we strip the language part away. - // Also, extension messages which are not loaded, are shown as red, because - // we don't call MessageCache::loadAllMessages. list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 ); return wfMsgWeirdKey( $basename ); // known system message default: @@ -3665,6 +3663,26 @@ class Title { return $this->exists() || $this->isAlwaysKnown(); } + /** + * Does this page have source text? + * + * @return Boolean + */ + public function hasSourceText() { + if ( $this->exists() ) + return true; + + if ( $this->mNamespace == NS_MEDIAWIKI ) { + // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes + // the full l10n of that language to be loaded. That takes much memory and + // isn't needed. So we strip the language part away. + list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 ); + return wfMsgWeirdKey( $basename ); // known system message + } + + return false; + } + /** * Is this in a namespace that allows actual pages? * diff --git a/skins/Vector.php b/skins/Vector.php index 57f37dddd4..6d3d0ad14b 100644 --- a/skins/Vector.php +++ b/skins/Vector.php @@ -169,8 +169,8 @@ class SkinVector extends SkinTemplate { ); } } - // Checks if the page is known (some kind of viewable content) - } elseif ( $this->mTitle->isKnown() ) { + // Checks if the page has some kind of viewable content + } elseif ( $this->mTitle->hasSourceText() ) { // Adds view source view link $links['views']['viewsource'] = array( 'class' => ( $action == 'edit' ) ? 'selected' : false, -- 2.20.1