From 6c4360c9510b4890c548006e610a8c281dde5120 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 2 Nov 2011 20:55:08 +0000 Subject: [PATCH] Make use of Title::isSpecialPage() in various places --- includes/Linker.php | 4 ++-- includes/LogPage.php | 2 +- includes/Skin.php | 4 ++-- includes/SkinLegacy.php | 4 ++-- includes/SkinTemplate.php | 10 +++++----- includes/Title.php | 12 ++++++------ includes/Wiki.php | 4 ++-- includes/WikiPage.php | 2 +- includes/api/ApiQuery.php | 2 +- includes/parser/Parser.php | 2 +- includes/search/SearchEngine.php | 2 +- includes/specials/SpecialRevisiondelete.php | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 4c16a9ad15..ff9af75d4f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -250,7 +250,7 @@ class Linker { # there's already an action specified, or unless 'edit' makes no sense # (i.e., for a nonexistent special page). if ( in_array( 'broken', $options ) && empty( $query['action'] ) - && $target->getNamespace() != NS_SPECIAL ) { + && !$target->isSpecialPage() ) { $query['action'] = 'edit'; $query['redlink'] = '1'; } @@ -389,7 +389,7 @@ class Linker { * @return Title */ static function normaliseSpecialPage( Title $title ) { - if ( $title->getNamespace() == NS_SPECIAL ) { + if ( $title->isSpecialPage() ) { list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); if ( !$name ) { return $title; diff --git a/includes/LogPage.php b/includes/LogPage.php index 995c609177..1fe0c6b344 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -391,7 +391,7 @@ class LogPage { $params[1] = $lang->timeanddate( $params[1] ); break; default: - if( $title->getNamespace() == NS_SPECIAL ) { + if( $title->isSpecialPage() ) { list( $name, $par ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); # Use the language name for log titles, rather than Log/X diff --git a/includes/Skin.php b/includes/Skin.php index 9d57429746..96566d7889 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -183,7 +183,7 @@ abstract class Skin extends ContextSource { $titles = array( $user->getUserPage(), $user->getTalkPage() ); // Other tab link - if ( $this->getTitle()->getNamespace() == NS_SPECIAL ) { + if ( $this->getTitle()->isSpecialPage() ) { // nothing } elseif ( $this->getTitle()->isTalkPage() ) { $titles[] = $this->getTitle()->getSubjectPage(); @@ -329,7 +329,7 @@ abstract class Skin extends ContextSource { function getPageClasses( $title ) { $numeric = 'ns-' . $title->getNamespace(); - if ( $title->getNamespace() == NS_SPECIAL ) { + if ( $title->isSpecialPage() ) { $type = 'ns-special'; // bug 23315: provide a class based on the canonical special page name without subpages list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); diff --git a/includes/SkinLegacy.php b/includes/SkinLegacy.php index 53273fb5b7..855098e8b3 100644 --- a/includes/SkinLegacy.php +++ b/includes/SkinLegacy.php @@ -238,7 +238,7 @@ class LegacyTemplate extends BaseTemplate { $variants = $lang->getVariants(); if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 - && $title->getNamespace() != NS_SPECIAL ) { + && !$title->isSpecialPage() ) { foreach ( $variants as $code ) { $varname = $lang->getVariantname( $code ); @@ -770,7 +770,7 @@ class LegacyTemplate extends BaseTemplate { global $wgOut; $title = $this->getSkin()->getTitle(); - if ( $title->getNamespace() == NS_SPECIAL ) { + if ( $title->isSpecialPage() ) { return ''; } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index b72b85bb54..bccdff5f1e 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -275,9 +275,9 @@ class SkinTemplate extends Skin { $tpl->set( 'printable', $out->isPrintable() ); $tpl->set( 'handheld', $request->getBool( 'handheld' ) ); $tpl->setRef( 'loggedin', $this->loggedin ); - $tpl->set( 'notspecialpage', $this->getTitle()->getNamespace() != NS_SPECIAL ); + $tpl->set( 'notspecialpage', !$this->getTitle()->isSpecialPage() ); /* XXX currently unused, might get useful later - $tpl->set( 'editable', ( $this->getTitle()->getNamespace() != NS_SPECIAL ) ); + $tpl->set( 'editable', ( !$this->getTitle()->isSpecialPage() ) ); $tpl->set( 'exists', $this->getTitle()->getArticleID() != 0 ); $tpl->set( 'watch', $this->getTitle()->userIsWatching() ? 'unwatch' : 'watch' ); $tpl->set( 'protect', count( $this->getTitle()->isProtected() ) ? 'unprotect' : 'protect' ); @@ -589,7 +589,7 @@ class SkinTemplate extends Skin { # thickens, because $wgTitle is altered for special pages, so doesn't # contain the original alias-with-subpage. $origTitle = Title::newFromText( $request->getText( 'title' ) ); - if( $origTitle instanceof Title && $origTitle->getNamespace() == NS_SPECIAL ) { + if( $origTitle instanceof Title && $origTitle->isSpecialPage() ) { list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() ); $active = $spName == 'Contributions' && ( ( $spPar && $spPar == $this->username ) @@ -814,7 +814,7 @@ class SkinTemplate extends Skin { wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) ); // Checks if page is some kind of content - if( $title->getNamespace() != NS_SPECIAL ) { + if( !$title->isSpecialPage() ) { // Gets page objects for the related namespaces $subjectPage = $title->getSubjectPage(); $talkPage = $title->getTalkPage(); @@ -1009,7 +1009,7 @@ class SkinTemplate extends Skin { array( &$this, &$content_navigation ) ); } - if ( !$wgDisableLangConversion && $title->getNamespace() != NS_SPECIAL ) { + if ( !$wgDisableLangConversion && !$title->isSpecialPage() ) { $pageLang = $title->getPageLanguage(); // Gets list of language variants $variants = $pageLang->getVariants(); diff --git a/includes/Title.php b/includes/Title.php index 04503c88a7..3ea7a8614c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1112,7 +1112,7 @@ class Title { $restrictionTypes = $this->getRestrictionTypes(); # Special pages have inherent protection - if( $this->getNamespace() == NS_SPECIAL ) { + if( $this->isSpecialPage() ) { return true; } @@ -1863,7 +1863,7 @@ class Title { } # If it's a special page, ditch the subpage bit and check again - if ( $this->getNamespace() == NS_SPECIAL ) { + if ( $this->isSpecialPage() ) { $name = $this->getDBkey(); list( $name, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $name ); if ( $name === false ) { @@ -4152,7 +4152,7 @@ class Title { * @return boolean */ public function isSpecial( $name ) { - if ( $this->getNamespace() == NS_SPECIAL ) { + if ( $this->isSpecialPage() ) { list( $thisName, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $this->getDBkey() ); if ( $name == $thisName ) { return true; @@ -4168,7 +4168,7 @@ class Title { * @return Title */ public function fixSpecialName() { - if ( $this->getNamespace() == NS_SPECIAL ) { + if ( $this->isSpecialPage() ) { list( $canonicalName, $par ) = SpecialPageFactory::resolveAlias( $this->mDbkeyform ); if ( $canonicalName ) { $localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par ); @@ -4279,7 +4279,7 @@ class Title { * @return array applicable restriction types */ public function getRestrictionTypes() { - if ( $this->getNamespace() == NS_SPECIAL ) { + if ( $this->isSpecialPage() ) { return array(); } @@ -4356,7 +4356,7 @@ class Title { */ public function getPageLanguage() { global $wgLang; - if ( $this->getNamespace() == NS_SPECIAL ) { + if ( $this->isSpecialPage() ) { // special pages are in the user language return $wgLang; } elseif ( $this->isCssOrJsPage() ) { diff --git a/includes/Wiki.php b/includes/Wiki.php index 9743478219..ddc7f20e8e 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -92,7 +92,7 @@ class MediaWiki { } } // For non-special titles, check for implicit titles - if ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) { + if ( is_null( $ret ) || !$ret->isSpecialPage() ) { // We can have urls with just ?diff=,?oldid= or even just ?diff= $oldid = $request->getInt( 'oldid' ); $oldid = $oldid ? $oldid : $request->getInt( 'diff' ); @@ -190,7 +190,7 @@ class MediaWiki { && !count( $request->getValueNames( array( 'action', 'title' ) ) ) && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) ) { - if ( $title->getNamespace() == NS_SPECIAL ) { + if ( $title->isSpecialPage() ) { list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); if ( $name ) { $title = SpecialPage::getTitleFor( $name, $subpage ); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index c9d38ec30d..936e287e21 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -205,7 +205,7 @@ class WikiPage extends Page { return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ); } } else { - if ( $rt->getNamespace() == NS_SPECIAL ) { + if ( $rt->isSpecialPage() ) { // Gotta handle redirects to special pages differently: // Fill the HTTP response "Location" header and ignore // the rest of the page we're on. diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index edeb9c877e..09f6c5d538 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -443,7 +443,7 @@ class ApiQuery extends ApiBase { $vals = array(); ApiQueryBase::addTitleInfo( $vals, $title ); $vals['special'] = ''; - if ( $title->getNamespace() == NS_SPECIAL && + if ( $title->isSpecialPage() && !SpecialPageFactory::exists( $title->getDbKey() ) ) { $vals['missing'] = ''; } elseif ( $title->getNamespace() == NS_MEDIA && diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index f95a216b8c..660f72030f 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3220,7 +3220,7 @@ class Parser { wfProfileIn( $titleProfileIn ); // template in wfProfileIn( __METHOD__ . '-loadtpl' ); if ( !$title->isExternal() ) { - if ( $title->getNamespace() == NS_SPECIAL + if ( $title->isSpecialPage() && $this->mOptions->getAllowSpecialInclusion() && $this->ot['html'] ) { diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 40b992de41..260c2486e1 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -171,7 +171,7 @@ class SearchEngine { return null; } - if ( $title->getNamespace() == NS_SPECIAL || $title->isExternal() || $title->exists() ) { + if ( $title->isSpecialPage() || $title->isExternal() || $title->exists() ) { return $title; } diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 4f8eddad2e..0cfc4bbfaf 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -228,7 +228,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { array(), array( 'page' => $this->targetObj->getPrefixedText() ) ); - if ( $this->targetObj->getNamespace() != NS_SPECIAL ) { + if ( !$this->targetObj->isSpecialPage() ) { # Give a link to the page history $links[] = Linker::linkKnown( $this->targetObj, -- 2.20.1