Topple the last bastion of global-function-based special pages. Also fix HTMLCheckFi...
[lhc/web/wiklou.git] / includes / SpecialPage.php
index e985f2b..89a015b 100644 (file)
@@ -73,6 +73,22 @@ class SpecialPage {
         * Query parameteres added by redirects
         */
        var $mAddedRedirectParams = array();
+       /**
+        * Current request
+        * @var WebRequest 
+        */
+       protected $mRequest;
+       /**
+        * Current output page
+        * @var OutputPage
+        */
+       protected $mOutput;
+       /**
+        * Full title including $par
+        * @var Title
+        */
+       protected $mFullTitle;
+               
        /**
         * List of special pages, followed by parameters.
         * If the only parameter is a string, that is the page name.
@@ -120,32 +136,33 @@ class SpecialPage {
                'CreateAccount'             => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
 
                # Users and rights
-               'Blockip'                   => 'IPBlockForm',
-               'Ipblocklist'               => 'IPUnblockForm',
-               'Unblock'                   => array( 'SpecialRedirectToSpecial', 'Unblock', 'Ipblocklist', false, array( 'uselang', 'ip', 'id' ), array( 'action' => 'unblock' ) ),
+               'Block'                     => 'SpecialBlock',
+               'Unblock'                   => 'SpecialUnblock',
+               'BlockList'                 => 'SpecialBlockList',
                'Resetpass'                 => 'SpecialResetpass',
                'DeletedContributions'      => 'DeletedContributionsPage',
                'Preferences'               => 'SpecialPreferences',
                'Contributions'             => 'SpecialContributions',
                'Listgrouprights'           => 'SpecialListGroupRights',
-               'Listusers'                 => array( 'SpecialPage', 'Listusers' ),
+               'Listusers'                 => 'SpecialListusers',
                'Listadmins'                => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
                'Listbots'                  => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
                'Activeusers'               => 'SpecialActiveUsers',
                'Userrights'                => 'UserrightsPage',
                'DisableAccount'            => 'SpecialDisableAccount',
+               'EditWatchlist'             => 'SpecialEditWatchlist',
 
                # Recent changes and logs
-               'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
+               'Newimages'                 => 'SpecialNewFiles',
                'Log'                       => 'SpecialLog',
-               'Watchlist'                 => array( 'SpecialPage', 'Watchlist' ),
+               'Watchlist'                 => 'SpecialWatchlist',
                'Newpages'                  => 'SpecialNewpages',
                'Recentchanges'             => 'SpecialRecentchanges',
                'Recentchangeslinked'       => 'SpecialRecentchangeslinked',
                'Tags'                      => 'SpecialTags',
 
                # Media reports and uploads
-               'Listfiles'                 => array( 'SpecialPage', 'Listfiles' ),
+               'Listfiles'                 => 'SpecialListFiles',
                'Filepath'                  => 'SpecialFilepath',
                'MIMEsearch'                => 'MIMEsearchPage',
                'FileDuplicateSearch'       => 'FileDuplicateSearchPage',
@@ -539,6 +556,9 @@ class SpecialPage {
                        wfProfileOut( __METHOD__ );
                        return false;
                }
+               
+               # Page exists, set the context
+               $page->setContext( $wgRequest, $wgOut );
 
                # Check for redirect
                if ( !$including ) {
@@ -633,7 +653,7 @@ class SpecialPage {
                        $found = false;
                        foreach ( $aliases as $n => $values ) {
                                if ( strcasecmp( $name, $n ) === 0 ) {
-                                       wfWarn( "Found alias defined for $n when searching for" .
+                                       wfWarn( "Found alias defined for $n when searching for " .
                                                "special page aliases for $name. Case mismatch?" );
                                        $name = $values[0];
                                        $found = true;
@@ -641,7 +661,7 @@ class SpecialPage {
                                }
                        }
                        if ( !$found ) {
-                               wfWarn( "Did not find alias for special page '$name'. " . 
+                               wfWarn( "Did not find alias for special page '$name'. " .
                                        "Perhaps no aliases are defined for it?" );
                        }
                }
@@ -800,6 +820,18 @@ class SpecialPage {
                return $this->mLocalName;
        }
 
+       /**
+        * Is this page expensive (for some definition of expensive)?
+        * Expensive pages are disabled or cached in miser mode.  Originally used
+        * (and still overridden) by QueryPage and subclasses, moved here so that
+        * Special:SpecialPages can safely call it for all special pages.
+        *
+        * @return Boolean
+        */
+       public function isExpensive() {
+               return false;
+       }
+
        /**
         * Can be overridden by subclasses with more complicated permissions
         * schemes.
@@ -951,6 +983,27 @@ class SpecialPage {
                        ? $params
                        : false;
        }
+       
+       /**
+        * Sets the context this SpecialPage is executed in
+        * 
+        * @param $request WebRequest
+        * @param $output OutputPage
+        */
+       protected function setContext( $request, $output ) {
+               $this->mRequest = $request;
+               $this->mOutput = $output;
+               $this->mFullTitle = $output->getTitle();
+       }
+       /**
+        * Wrapper around wfMessage that sets the current context. Currently this
+        * is only the title.
+        * 
+        * @see wfMessage
+        */
+       public function msg( /* $args */ ) {
+               return call_user_func_array( 'wfMessage', func_get_args() )->title( $this->mFullTitle );
+       }
 }
 
 /**