Make use of Title::isSpecialPage() in various places
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 2 Nov 2011 20:55:08 +0000 (20:55 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 2 Nov 2011 20:55:08 +0000 (20:55 +0000)
12 files changed:
includes/Linker.php
includes/LogPage.php
includes/Skin.php
includes/SkinLegacy.php
includes/SkinTemplate.php
includes/Title.php
includes/Wiki.php
includes/WikiPage.php
includes/api/ApiQuery.php
includes/parser/Parser.php
includes/search/SearchEngine.php
includes/specials/SpecialRevisiondelete.php

index 4c16a9a..ff9af75 100644 (file)
@@ -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;
index 995c609..1fe0c6b 100644 (file)
@@ -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
index 9d57429..96566d7 100644 (file)
@@ -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() );
index 53273fb..855098e 100644 (file)
@@ -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 '';
                }
 
index b72b85b..bccdff5 100644 (file)
@@ -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();
index 04503c8..3ea7a86 100644 (file)
@@ -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() ) {
index 9743478..ddc7f20 100644 (file)
@@ -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 );
index c9d38ec..936e287 100644 (file)
@@ -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.
index edeb9c8..09f6c5d 100644 (file)
@@ -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 &&
index f95a216..660f720 100644 (file)
@@ -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'] )
                                {
index 40b992d..260c248 100644 (file)
@@ -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;
                        }
 
index 4f8edda..0cfc4bb 100644 (file)
@@ -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,