(bug 4974) Don't follow redirected talk page on "new messages" link
[lhc/web/wiklou.git] / includes / SpecialPage.php
index cea0c5e..f9a5ed9 100644 (file)
@@ -41,8 +41,13 @@ $wgSpecialPages = array(
        'Uncategorizedcategories'=> new SpecialPage( 'Uncategorizedcategories' ),
        'Unusedcategories'      => new SpecialPage( 'Unusedcategories' ),
        'Unusedimages'      => new SpecialPage( 'Unusedimages' ),
-       'Wantedpages'   => new SpecialPage( 'Wantedpages' ),
+       'Wantedpages'   => new IncludableSpecialPage( 'Wantedpages' ),
+       'Wantedcategories' => new SpecialPage( 'Wantedcategories' ),
        'Mostlinked'    => new SpecialPage( 'Mostlinked' ),
+       'Mostlinkedcategories' => new SpecialPage( 'Mostlinkedcategories' ),
+       'Mostcategories' => new SpecialPage( 'Mostcategories' ),
+       'Mostimages' => new SpecialPage( 'Mostimages' ),
+       'Mostrevisions' => new SpecialPage( 'Mostrevisions' ),
        'Shortpages'    => new SpecialPage( 'Shortpages' ),
        'Longpages'             => new SpecialPage( 'Longpages' ),
        'Newpages'              => new IncludableSpecialPage( 'Newpages' ),
@@ -65,22 +70,22 @@ $wgSpecialPages = array(
        'Allmessages'   => new SpecialPage( 'Allmessages' ),
        'Log'           => new SpecialPage( 'Log' ),
        'Blockip'               => new SpecialPage( 'Blockip', 'block' ),
-       'Undelete'              => new SpecialPage( 'Undelete' ),
+       'Undelete'              => new SpecialPage( 'Undelete', 'deletedhistory' ),
        "Import"                => new SpecialPage( "Import", 'import' ),
        'Lockdb'                => new SpecialPage( 'Lockdb', 'siteadmin' ),
        'Unlockdb'              => new SpecialPage( 'Unlockdb', 'siteadmin' ),
        'Userrights'    => new SpecialPage( 'Userrights', 'userrights' ),
+       'MIMEsearch'    => new SpecialPage( 'MIMEsearch' ),
+       'Unwatchedpages' => new SpecialPage( 'Unwatchedpages', 'unwatchedpages' ),
+       'Listredirects' => new SpecialPage( 'Listredirects' )
 );
 
-if ( $wgUseValidation )
-       $wgSpecialPages['Validate'] = new SpecialPage( 'Validate' );
-
 if( !$wgDisableCounters ) {
        $wgSpecialPages['Popularpages'] = new SpecialPage( 'Popularpages' );
 }
 
 if( !$wgDisableInternalSearch ) {
-       $wgSpecialPages['Search'] = new UnlistedSpecialPage( 'Search' );
+       $wgSpecialPages['Search'] = new SpecialPage( 'Search' );
 }
 
 if( $wgEmailAuthentication ) {
@@ -174,20 +179,17 @@ class SpecialPage
         */
        function getRedirect( $name ) {
                global $wgUser;
-               switch ( $name ) {
-                       case 'Mypage':
-                               return Title::makeTitle( NS_USER, $wgUser->getName() );
-                       case 'Mytalk':
-                               return Title::makeTitle( NS_USER_TALK, $wgUser->getName() );
-                       case 'Mycontributions':
-                               return Title::makeTitle( NS_SPECIAL, 'Contributions/' . $wgUser->getName() );
-                       case 'Listadmins':
-                               return Title::makeTitle( NS_SPECIAL, 'Listusers/sysop' ); # @bug 2832
-                       case 'Randompage':
-                               return Title::makeTitle( NS_SPECIAL, 'Random' );
-                       default:
-                               return NULL;
-               }
+
+               $redirects = array(
+                       'Mypage' => Title::makeTitle( NS_USER, $wgUser->getName() ),
+                       'Mytalk' => Title::makeTitle( NS_USER_TALK, $wgUser->getName() ),
+                       'Mycontributions' => Title::makeTitle( NS_SPECIAL, 'Contributions/' . $wgUser->getName() ),
+                       'Listadmins' => Title::makeTitle( NS_SPECIAL, 'Listusers/sysop' ), # @bug 2832
+                       'Randompage' => Title::makeTitle( NS_SPECIAL, 'Random' )
+               );
+               wfRunHooks( 'SpecialPageGetRedirect', array( &$redirects ) );
+
+               return isset( $redirects[$name] ) ? $redirects[$name] : null;
        }
 
        /**
@@ -250,8 +252,9 @@ class SpecialPage
                                        $retVal = $redir;
                                } else {
                                        $wgOut->setArticleRelated( false );
-                                       $wgOut->setRobotpolicy( "noindex,follow" );
-                                       $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
+                                       $wgOut->setRobotpolicy( 'noindex,follow' );
+                                       $wgOut->setStatusCode( 404 );
+                                       $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' );
                                        $retVal = false;
                                }
                        }
@@ -332,13 +335,28 @@ class SpecialPage
                }
        }
 
-       # Accessor functions, see the descriptions of the associated variables above
+       /**#@+
+         * Accessor
+         *
+         * @deprecated
+         */
        function getName() { return $this->mName; }
        function getRestriction() { return $this->mRestriction; }
-       function isListed() { return $this->mListed; }
        function getFile() { return $this->mFile; }
-       function including( $x = NULL ) { return wfSetVar( $this->mIncluding, $x ); }
+       function isListed() { return $this->mListed; }
+       /**#@-*/
+
+       /**#@+
+         * Accessor and mutator
+         */
+       function name( $x = NULL ) { return wfSetVar( $this->mName, $x ); }
+       function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions, $x ); }
+       function listed( $x = NULL) { return wfSetVar( $this->mListed, $x ); }
+       function func( $x = NULL) { return wfSetVar( $this->mFunction, $x ); }
+       function file( $x = NULL) { return wfSetVar( $this->mFile, $x ); }
        function includable( $x = NULL ) { return wfSetVar( $this->mIncludable, $x ); }
+       function including( $x = NULL ) { return wfSetVar( $this->mIncluding, $x ); }
+       /**#@-*/
 
        /**
         * Checks if the given user (identified by an object) can execute this
@@ -389,12 +407,28 @@ class SpecialPage
                        if(!function_exists($func) and $this->mFile) {
                                require_once( $this->mFile );
                        }
+                       if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
+                               $this->outputHeader();
+                       if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
+                               return;
                        $func( $par, $this );
+                       if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
+                               return;
                } else {
                        $this->displayRestrictionError();
                }
        }
 
+       function outputHeader() {
+               global $wgOut, $wgContLang;
+
+               $msg = $wgContLang->lc( $this->name() ) . '-summary';
+               $out = wfMsg( $msg );
+               if ( ! wfEmptyMsg( $msg, $out ) and  $out !== '' and ! $this->including() )
+                       $wgOut->addWikiText( $out );
+
+       }
+
        # Returns the name that goes in the <h1> in the special page itself, and also the name that
        # will be listed in Special:Specialpages
        #