API: fix copyright symbol, coding style cleanup, more braces
[lhc/web/wiklou.git] / includes / SpecialPage.php
index ea891c8..80e2f7e 100644 (file)
@@ -2,31 +2,32 @@
 /**
  * SpecialPage: handling special pages and lists thereof.
  *
- * To add a special page in an extension, add to $wgSpecialPages either 
- * an object instance or an array containing the name and constructor 
- * parameters. The latter is preferred for performance reasons. 
+ * To add a special page in an extension, add to $wgSpecialPages either
+ * an object instance or an array containing the name and constructor
+ * parameters. The latter is preferred for performance reasons.
  *
- * The object instantiated must be either an instance of SpecialPage or a 
- * sub-class thereof. It must have an execute() method, which sends the HTML 
- * for the special page to $wgOut. The parent class has an execute() method 
- * which distributes the call to the historical global functions. Additionally, 
- * execute() also checks if the user has the necessary access privileges 
+ * The object instantiated must be either an instance of SpecialPage or a
+ * sub-class thereof. It must have an execute() method, which sends the HTML
+ * for the special page to $wgOut. The parent class has an execute() method
+ * which distributes the call to the historical global functions. Additionally,
+ * execute() also checks if the user has the necessary access privileges
  * and bails out if not.
  *
- * To add a core special page, use the similar static list in 
+ * To add a core special page, use the similar static list in
  * SpecialPage::$mList. To remove a core static special page at runtime, use
  * a SpecialPage_initList hook.
  *
- * @addtogroup SpecialPage
+ * @file
+ * @ingroup SpecialPage
+ * @defgroup SpecialPage SpecialPage
  */
 
 /**
  * Parent special page class, also static functions for handling the special
  * page list.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
-class SpecialPage
-{
+class SpecialPage {
        /**#@+
         * @access private
         */
@@ -68,89 +69,124 @@ class SpecialPage
         * Query parameters that can be passed through redirects
         */
        var $mAllowedRedirectParams = array();
-
+       /**
+        * List of special pages, followed by parameters.
+        * If the only parameter is a string, that is the page name.
+        * Otherwise, it is an array. The format is one of:
+        ** array( 'SpecialPage', name, right )
+        ** array( 'IncludableSpecialPage', name, right, listed? )
+        ** array( 'UnlistedSpecialPage', name, right )
+        ** array( 'SpecialRedirectToSpecial', name, page to redirect to, special page param, ... )
+        */
        static public $mList = array(
-               'DoubleRedirects'           => array( 'SpecialPage', 'DoubleRedirects' ),
+               # Maintenance Reports
                'BrokenRedirects'           => array( 'SpecialPage', 'BrokenRedirects' ),
-               'Disambiguations'           => array( 'SpecialPage', 'Disambiguations' ),
-
-               'Userlogin'                 => array( 'SpecialPage', 'Userlogin' ),
-               'Userlogout'                => array( 'UnlistedSpecialPage', 'Userlogout' ),
-               'CreateAccount'             => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
-               'Preferences'               => array( 'SpecialPage', 'Preferences' ),
-               'Watchlist'                 => array( 'SpecialPage', 'Watchlist' ),
-
-               'Recentchanges'             => array( 'IncludableSpecialPage', 'Recentchanges' ),
-               'Upload'                    => array( 'SpecialPage', 'Upload' ),
-               'Imagelist'                 => array( 'SpecialPage', 'Imagelist' ),
-               'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
-               'Listusers'                 => array( 'SpecialPage', 'Listusers' ),
-               'Listgrouprights'           => 'SpecialListGroupRights',
-               'Statistics'                => array( 'SpecialPage', 'Statistics' ),
-               'Randompage'                => 'Randompage',
+               'Deadendpages'              => array( 'SpecialPage', 'Deadendpages' ),
+               'DoubleRedirects'           => array( 'SpecialPage', 'DoubleRedirects' ),
+               'Longpages'                 => array( 'SpecialPage', 'Longpages' ),
+               'Ancientpages'              => array( 'SpecialPage', 'Ancientpages' ),
                'Lonelypages'               => array( 'SpecialPage', 'Lonelypages' ),
-               'Uncategorizedpages'        => array( 'SpecialPage', 'Uncategorizedpages' ),
+               'Fewestrevisions'           => array( 'SpecialPage', 'Fewestrevisions' ),
+               'Withoutinterwiki'          => array( 'SpecialPage', 'Withoutinterwiki' ),
+               'Protectedpages'            => array( 'SpecialPage', 'Protectedpages' ),
+               'Protectedtitles'           => array( 'SpecialPage', 'Protectedtitles' ),
+               'Shortpages'                => array( 'SpecialPage', 'Shortpages' ),
                'Uncategorizedcategories'   => array( 'SpecialPage', 'Uncategorizedcategories' ),
                'Uncategorizedimages'       => array( 'SpecialPage', 'Uncategorizedimages' ),
+               'Uncategorizedpages'        => array( 'SpecialPage', 'Uncategorizedpages' ),
                'Uncategorizedtemplates'    => array( 'SpecialPage', 'Uncategorizedtemplates' ),
                'Unusedcategories'          => array( 'SpecialPage', 'Unusedcategories' ),
                'Unusedimages'              => array( 'SpecialPage', 'Unusedimages' ),
-               'Wantedpages'               => array( 'IncludableSpecialPage', 'Wantedpages' ),
+               'Unusedtemplates'           => array( 'SpecialPage', 'Unusedtemplates' ),
+               'Unwatchedpages'            => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
                'Wantedcategories'          => array( 'SpecialPage', 'Wantedcategories' ),
-               'Mostlinked'                => array( 'SpecialPage', 'Mostlinked' ),
-               'Mostlinkedcategories'      => array( 'SpecialPage', 'Mostlinkedcategories' ),
-               'Mostlinkedtemplates'       => array( 'SpecialPage', 'Mostlinkedtemplates' ),
-               'Mostcategories'            => array( 'SpecialPage', 'Mostcategories' ),
-               'Mostimages'                => array( 'SpecialPage', 'Mostimages' ),
-               'Mostrevisions'             => array( 'SpecialPage', 'Mostrevisions' ),
-               'Fewestrevisions'           => array( 'SpecialPage', 'Fewestrevisions' ),
-               'Shortpages'                => array( 'SpecialPage', 'Shortpages' ),
-               'Longpages'                 => array( 'SpecialPage', 'Longpages' ),
-               'Newpages'                  => array( 'IncludableSpecialPage', 'Newpages' ),
-               'Ancientpages'              => array( 'SpecialPage', 'Ancientpages' ),
-               'Deadendpages'              => array( 'SpecialPage', 'Deadendpages' ),
-               'Protectedpages'            => array( 'SpecialPage', 'Protectedpages' ),
-               'Protectedtitles'           => array( 'SpecialPage', 'Protectedtitles' ),
-               'Allpages'                  => array( 'IncludableSpecialPage', 'Allpages' ),
-               'Prefixindex'               => array( 'IncludableSpecialPage', 'Prefixindex' ) ,
-               'Ipblocklist'               => array( 'SpecialPage', 'Ipblocklist' ),
-               'Specialpages'              => array( 'UnlistedSpecialPage', 'Specialpages' ),
-               'Contributions'             => array( 'SpecialPage', 'Contributions' ),
-               'Emailuser'                 => array( 'UnlistedSpecialPage', 'Emailuser' ),
-               'Whatlinkshere'             => array( 'SpecialPage', 'Whatlinkshere' ),
-               'Recentchangeslinked'       => array( 'UnlistedSpecialPage', 'Recentchangeslinked' ),
-               'Movepage'                  => array( 'UnlistedSpecialPage', 'Movepage' ),
-               'Blockme'                   => array( 'UnlistedSpecialPage', 'Blockme' ),
-               'Resetpass'                 => array( 'UnlistedSpecialPage', 'Resetpass' ),
-               'Booksources'               => 'SpecialBookSources',
+               'Wantedfiles'               => array( 'SpecialPage', 'Wantedfiles' ),
+               'Wantedpages'               => array( 'IncludableSpecialPage', 'Wantedpages' ),
+               'Wantedtemplates'           => array( 'SpecialPage', 'Wantedtemplates' ),
+
+               # List of pages
+               'Allpages'                  => 'SpecialAllpages',
+               'Prefixindex'               => 'SpecialPrefixindex',
                'Categories'                => array( 'SpecialPage', 'Categories' ),
-               'Export'                    => array( 'SpecialPage', 'Export' ),
-               'Version'                   => array( 'SpecialPage', 'Version' ),
-               'Allmessages'               => array( 'SpecialPage', 'Allmessages' ),
-               'Log'                       => array( 'SpecialPage', 'Log' ),
+               'Disambiguations'           => array( 'SpecialPage', 'Disambiguations' ),
+               'Listredirects'             => array( 'SpecialPage', 'Listredirects' ),
+
+               # Login/create account
+               'Userlogin'                 => array( 'SpecialPage', 'Userlogin' ),
+               'CreateAccount'             => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
+
+               # Users and rights
                'Blockip'                   => array( 'SpecialPage', 'Blockip', 'block' ),
-               'Undelete'                  => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
-               'Import'                    => array( 'SpecialPage', 'Import', 'import' ),
-               'Lockdb'                    => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
-               'Unlockdb'                  => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
+               'Ipblocklist'               => array( 'SpecialPage', 'Ipblocklist' ),
+               'Resetpass'                 => 'SpecialResetpass',
+               'DeletedContributions'      => 'DeletedContributionsPage',
+               'Preferences'               => 'SpecialPreferences',
+               'Contributions'             => 'SpecialContributions',
+               'Listgrouprights'           => 'SpecialListGroupRights',
+               'Listusers'                 => array( 'SpecialPage', 'Listusers' ),
+               'Activeusers'               => 'SpecialActiveUsers',
                'Userrights'                => 'UserrightsPage',
+
+               # Recent changes and logs
+               'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
+               'Log'                       => array( 'SpecialPage', 'Log' ),
+               'Watchlist'                 => array( 'SpecialPage', 'Watchlist' ),
+               'Newpages'                  => 'SpecialNewpages',
+               'Recentchanges'             => 'SpecialRecentchanges',
+               'Recentchangeslinked'       => 'SpecialRecentchangeslinked',
+               'Tags'                      => 'SpecialTags',
+
+               # Media reports and uploads
+               'Listfiles'                 => array( 'SpecialPage', 'Listfiles' ),
+               'Filepath'                  => array( 'SpecialPage', 'Filepath' ),
                'MIMEsearch'                => array( 'SpecialPage', 'MIMEsearch' ),
                'FileDuplicateSearch'       => array( 'SpecialPage', 'FileDuplicateSearch' ),
-               'Unwatchedpages'            => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
-               'Listredirects'             => array( 'SpecialPage', 'Listredirects' ),
-               'Revisiondelete'            => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
-               'Unusedtemplates'           => array( 'SpecialPage', 'Unusedtemplates' ),
+               'Upload'                    => 'SpecialUpload',
+
+               # Wiki data and tools
+               'Statistics'                => 'SpecialStatistics',
+               'Allmessages'               => 'SpecialAllmessages',
+               'Version'                   => 'SpecialVersion',
+               'Lockdb'                    => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
+               'Unlockdb'                  => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
+
+               # Redirecting special pages
+               'LinkSearch'                => array( 'SpecialPage', 'LinkSearch' ),
+               'Randompage'                => 'Randompage',
                'Randomredirect'            => 'SpecialRandomredirect',
-               'Withoutinterwiki'          => array( 'SpecialPage', 'Withoutinterwiki' ),
-               'Filepath'                  => array( 'SpecialPage', 'Filepath' ),
 
-               'Mypage'                    => array( 'SpecialMypage' ),
-               'Mytalk'                    => array( 'SpecialMytalk' ),
-               'Mycontributions'           => array( 'SpecialMycontributions' ),
-               'Listadmins'                => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
+               # High use pages
+               'Mostlinkedcategories'      => array( 'SpecialPage', 'Mostlinkedcategories' ),
+               'Mostimages'                => array( 'SpecialPage', 'Mostimages' ),
+               'Mostlinked'                => array( 'SpecialPage', 'Mostlinked' ),
+               'Mostlinkedtemplates'       => array( 'SpecialPage', 'Mostlinkedtemplates' ),
+               'Mostcategories'            => array( 'SpecialPage', 'Mostcategories' ),
+               'Mostrevisions'             => array( 'SpecialPage', 'Mostrevisions' ),
+
+               # Page tools
+               'Export'                    => 'SpecialExport',
+               'Import'                    => 'SpecialImport',
+               'Undelete'                  => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
+               'Whatlinkshere'             => 'SpecialWhatlinkshere',
                'MergeHistory'              => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
+
+               # Other
+               'Booksources'               => 'SpecialBookSources',
+
+               # Unlisted / redirects
+               'Blankpage'                 => 'SpecialBlankpage',
+               'Blockme'                   => array( 'UnlistedSpecialPage', 'Blockme' ),
+               'Emailuser'                 => array( 'UnlistedSpecialPage', 'Emailuser' ),
+               'Listadmins'                => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
                'Listbots'                  => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
-               );
+               'Movepage'                  => array( 'UnlistedSpecialPage', 'Movepage' ),
+               'Mycontributions'           => array( 'SpecialMycontributions' ),
+               'Mypage'                    => array( 'SpecialMypage' ),
+               'Mytalk'                    => array( 'SpecialMytalk' ),
+               'Revisiondelete'            => 'SpecialRevisionDelete',
+               'Specialpages'              => array( 'UnlistedSpecialPage', 'Specialpages' ),
+               'Userlogout'                => array( 'UnlistedSpecialPage', 'Userlogout' ),
+       );
 
        static public $mAliases;
        static public $mListInitialised = false;
@@ -169,7 +205,7 @@ class SpecialPage
                        return;
                }
                wfProfileIn( __METHOD__ );
-               
+
                # Better to set this now, to avoid infinite recursion in carelessly written hooks
                self::$mListInitialised = true;
 
@@ -233,7 +269,7 @@ class SpecialPage
        }
 
        /**
-        * Given a special page name with a possible subpage, return an array 
+        * Given a special page name with a possible subpage, return an array
         * where the first element is the special page name and the second is the
         * subpage.
         */
@@ -241,7 +277,7 @@ class SpecialPage
                $bits = explode( '/', $alias, 2 );
                $name = self::resolveAlias( $bits[0] );
                if( !isset( $bits[1] ) ) { // bug 2087
-                       $par = NULL;
+                       $par = null;
                } else {
                        $par = $bits[1];
                }
@@ -249,14 +285,11 @@ class SpecialPage
        }
 
        /**
-        * Add a page to the list of valid special pages. This used to be the preferred 
-        * method for adding special pages in extensions. It's now suggested that you add 
+        * Add a page to the list of valid special pages. This used to be the preferred
+        * method for adding special pages in extensions. It's now suggested that you add
         * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
         *
-        * @param mixed $page Must either be an array specifying a class name and 
-        *                    constructor parameters, or an object. The object,
-        *                    when constructed, must have an execute() method which
-        *                    sends HTML to $wgOut.
+        * @param SpecialPage $page
         * @static
         */
        static function addPage( &$page ) {
@@ -266,11 +299,48 @@ class SpecialPage
                self::$mList[$page->mName] = $page;
        }
 
+       /**
+        * Add a page to a certain display group for Special:SpecialPages
+        *
+        * @param mixed $page (SpecialPage or string)
+        * @param string $group
+        * @static
+        */
+       static function setGroup( $page, $group ) {
+               global $wgSpecialPageGroups;
+               $name = is_object($page) ? $page->mName : $page;
+               $wgSpecialPageGroups[$name] = $group;
+       }
+
+       /**
+        * Add a page to a certain display group for Special:SpecialPages
+        *
+        * @param SpecialPage $page
+        * @static
+        */
+       static function getGroup( &$page ) {
+               global $wgSpecialPageGroups;
+               static $specialPageGroupsCache = array();
+               if( isset($specialPageGroupsCache[$page->mName]) ) {
+                       return $specialPageGroupsCache[$page->mName];
+               }
+               $group = wfMsg('specialpages-specialpagegroup-'.strtolower($page->mName));
+               if( $group == ''
+                || wfEmptyMsg('specialpages-specialpagegroup-'.strtolower($page->mName), $group ) ) {
+                       $group = isset($wgSpecialPageGroups[$page->mName])
+                               ? $wgSpecialPageGroups[$page->mName]
+                               : '-';
+               }
+               if( $group == '-' ) $group = 'other';
+               $specialPageGroupsCache[$page->mName] = $group;
+               return $group;
+       }
+
        /**
         * Remove a special page from the list
-        * Formerly used to disable expensive or dangerous special pages. The 
+        * Formerly used to disable expensive or dangerous special pages. The
         * preferred method is now to add a SpecialPage_initList hook.
-        * 
+        *
         * @static
         */
        static function removePage( $name ) {
@@ -324,7 +394,7 @@ class SpecialPage
                        }
                        return self::$mList[$name];
                } else {
-                       return NULL;
+                       return null;
                }
        }
 
@@ -337,10 +407,36 @@ class SpecialPage
                if ( $realName ) {
                        return self::getPage( $realName );
                } else {
-                       return NULL;
+                       return null;
                }
        }
 
+       /**
+        * Return categorised listable special pages which are available
+        * for the current user, and everyone.
+        * @static
+        */
+       static function getUsablePages() {
+               global $wgUser;
+               if ( !self::$mListInitialised ) {
+                       self::initList();
+               }
+               $pages = array();
+
+               foreach ( self::$mList as $name => $rec ) {
+                       $page = self::getPage( $name );
+                       if ( $page->isListed()
+                               && (
+                                       !$page->isRestricted()
+                                       || $page->userCanExecute( $wgUser )
+                               )
+                       ) {
+                               $pages[$name] = $page;
+                       }
+               }
+               return $pages;
+       }
+
        /**
         * Return categorised listable special pages for all users
         * @static
@@ -367,17 +463,17 @@ class SpecialPage
         */
        static function getRestrictedPages() {
                global $wgUser;
-               if ( !self::$mListInitialised ) {
+               if( !self::$mListInitialised ) {
                        self::initList();
                }
                $pages = array();
 
-               foreach ( self::$mList as $name => $rec ) {
+               foreach( self::$mList as $name => $rec ) {
                        $page = self::getPage( $name );
-                       if (
+                       if(
                                $page->isListed()
-                               and $page->isRestricted()
-                               and $page->userCanExecute( $wgUser )
+                               && $page->isRestricted()
+                               && $page->userCanExecute( $wgUser )
                        ) {
                                $pages[$name] = $page;
                        }
@@ -404,7 +500,7 @@ class SpecialPage
                $bits = explode( '/', $title->getDBkey(), 2 );
                $name = $bits[0];
                if( !isset( $bits[1] ) ) { // bug 2087
-                       $par = NULL;
+                       $par = null;
                } else {
                        $par = $bits[1];
                }
@@ -413,7 +509,7 @@ class SpecialPage
                if ( !$page ) {
                        if ( !$including ) {
                                $wgOut->setArticleRelated( false );
-                               $wgOut->setRobotpolicy( 'noindex,nofollow' );
+                               $wgOut->setRobotPolicy( 'noindex,nofollow' );
                                $wgOut->setStatusCode( 404 );
                                $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
                        }
@@ -434,9 +530,9 @@ class SpecialPage
                }
 
                # Redirect to canonical alias for GET commands
-               # Not for POST, we'd lose the post data, so it's best to just distribute 
-               # the request. Such POST requests are possible for old extensions that 
-               # generate self-links without being aware that their default name has 
+               # Not for POST, we'd lose the post data, so it's best to just distribute
+               # the request. Such POST requests are possible for old extensions that
+               # generate self-links without being aware that their default name has
                # changed.
                if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
                        $query = $_GET;
@@ -478,6 +574,7 @@ class SpecialPage
                $oldTitle = $wgTitle;
                $oldOut = $wgOut;
                $wgOut = new OutputPage;
+               $wgOut->setTitle( $title );
 
                $ret = SpecialPage::executePath( $title, true );
                if ( $ret === true ) {
@@ -501,11 +598,25 @@ class SpecialPage
                $aliases = $wgContLang->getSpecialPageAliases();
                if ( isset( $aliases[$name][0] ) ) {
                        $name = $aliases[$name][0];
+               } else {
+                       // Try harder in case someone misspelled the correct casing
+                       $found = false;
+                       foreach ( $aliases as $n => $values ) {
+                               if ( strcasecmp( $name, $n ) === 0 ) {
+                                       wfWarn( "Found alias defined for $n when searching for special page aliases
+for $name. Case mismatch?" );
+                                       $name = $values[0];
+                                       $found = true;
+                                       break;
+                               }
+                       }
+                       if ( !$found ) wfWarn( "Did not find alias for special page '$name'.
+Perhaps no page aliases are defined for it?" );
                }
                if ( $subpage !== false && !is_null( $subpage ) ) {
                        $name = "$name/$subpage";
                }
-               return $name;
+               return $wgContLang->ucfirst( $name );
        }
 
        /**
@@ -572,7 +683,7 @@ class SpecialPage
                        $this->mFunction = $function;
                }
                if ( $file === 'default' ) {
-                       $this->mFile = dirname(__FILE__) . "/Special{$name}.php";
+                       $this->mFile = dirname(__FILE__) . "/specials/Special$name.php";
                } else {
                        $this->mFile = $file;
                }
@@ -592,13 +703,18 @@ class SpecialPage
        /**#@+
          * 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 ); }
+       function name( $x = null ) { return wfSetVar( $this->mName, $x ); }
+       function restrictions( $x = null) {
+               # Use the one below this
+               wfDeprecated( __METHOD__ );
+               return wfSetVar( $this->mRestriction, $x );
+       }
+       function restriction( $x = null) { return wfSetVar( $this->mRestriction, $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 ); }
        /**#@-*/
 
        /**
@@ -619,7 +735,9 @@ class SpecialPage
         *   pages?
         */
        public function isRestricted() {
-               return $this->mRestriction != '';
+               global $wgGroupPermissions;
+               // DWIM: If all anons can do something, then it is not restricted
+               return $this->mRestriction != '' && empty($wgGroupPermissions['*'][$this->mRestriction]);
        }
 
        /**
@@ -656,7 +774,7 @@ class SpecialPage
         * Default execute method
         * Checks user permissions, calls the function given in mFunction
         *
-        * This may be overridden by subclasses. 
+        * This may be overridden by subclasses.
         */
        function execute( $par ) {
                global $wgUser;
@@ -669,26 +787,32 @@ class SpecialPage
                        if(!is_callable($func) and $this->mFile) {
                                require_once( $this->mFile );
                        }
-                       # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage. 
-                       if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
-                               $this->outputHeader();
-                       if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
-                               return;
+                       $this->outputHeader();
                        call_user_func( $func, $par, $this );
-                       if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
-                               return;
                } else {
                        $this->displayRestrictionError();
                }
        }
 
-       function outputHeader() {
+       /**
+        * Outputs a summary message on top of special pages
+        * Per default the message key is the canonical name of the special page
+        * May be overriden, i.e. by extensions to stick with the naming conventions
+        * for message keys: 'extensionname-xxx'
+        *
+        * @param string message key of the summary
+        */
+       function outputHeader( $summaryMessageKey = '' ) {
                global $wgOut, $wgContLang;
 
-               $msg = $wgContLang->lc( $this->name() ) . '-summary';
+               if( $summaryMessageKey == '' ) {
+                       $msg = $wgContLang->lc( $this->name() ) . '-summary';
+               } else {
+                       $msg = $summaryMessageKey;
+               }
                $out = wfMsgNoTrans( $msg );
                if ( ! wfEmptyMsg( $msg, $out ) and  $out !== '' and ! $this->including() ) {
-                       $wgOut->addWikiText( $out );
+                       $wgOut->wrapWikiMsg( "<div class='mw-specialpage-summary'>\n$1</div>", $msg );
                }
 
        }
@@ -705,7 +829,7 @@ class SpecialPage
        /**
         * Get a self-referential title object
         */
-       function getTitle( $subpage = false) {
+       function getTitle( $subpage = false ) {
                return self::getTitleFor( $this->mName, $subpage );
        }
 
@@ -717,7 +841,7 @@ class SpecialPage
        }
 
        /**
-        * If the special page is a redirect, then get the Title object it redirects to. 
+        * If the special page is a redirect, then get the Title object it redirects to.
         * False otherwise.
         */
        function getRedirect( $subpage ) {
@@ -734,17 +858,17 @@ class SpecialPage
                global $wgRequest;
                $params = array();
                foreach( $this->mAllowedRedirectParams as $arg ) {
-                       if( $val = $wgRequest->getVal( $arg, false ) )
+                       if( ( $val = $wgRequest->getVal( $arg, null ) ) !== null )
                                $params[] = $arg . '=' . $val;
                }
-               
+
                return count( $params ) ? implode( '&', $params ) : false;
        }
 }
 
 /**
  * Shortcut to construct a special page which is unlisted by default
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class UnlistedSpecialPage extends SpecialPage
 {
@@ -755,7 +879,7 @@ class UnlistedSpecialPage extends SpecialPage
 
 /**
  * Shortcut to construct an includable special  page
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class IncludableSpecialPage extends SpecialPage
 {
@@ -766,7 +890,7 @@ class IncludableSpecialPage extends SpecialPage
 
 /**
  * Shortcut to construct a special page alias.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class SpecialRedirectToSpecial extends UnlistedSpecialPage {
        var $redirName, $redirSubpage;
@@ -796,7 +920,7 @@ class SpecialRedirectToSpecial extends UnlistedSpecialPage {
 
 /**
  * Shortcut to construct a special page pointing to current user user's page.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class SpecialMypage extends UnlistedSpecialPage {
        function __construct() {
@@ -816,7 +940,7 @@ class SpecialMypage extends UnlistedSpecialPage {
 
 /**
  * Shortcut to construct a special page pointing to current user talk page.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class SpecialMytalk extends UnlistedSpecialPage {
        function __construct() {
@@ -836,11 +960,13 @@ class SpecialMytalk extends UnlistedSpecialPage {
 
 /**
  * Shortcut to construct a special page pointing to current user contributions.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class SpecialMycontributions extends UnlistedSpecialPage {
        function __construct() {
                parent::__construct(  'Mycontributions' );
+               $this->mAllowedRedirectParams = array( 'limit', 'namespace', 'tagfilter',
+                       'offset', 'dir', 'year', 'month', 'feed' );
        }
 
        function getRedirect( $subpage ) {