Start managing output and input context from special pages themselves instead of...
[lhc/web/wiklou.git] / includes / SpecialPage.php
index f4d3895..5da2ef7 100644 (file)
@@ -144,7 +144,7 @@ class SpecialPage {
                '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',
@@ -153,7 +153,7 @@ class SpecialPage {
                'EditWatchlist'             => 'SpecialEditWatchlist',
 
                # Recent changes and logs
-               'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
+               'Newimages'                 => 'SpecialNewFiles',
                'Log'                       => 'SpecialLog',
                'Watchlist'                 => 'SpecialWatchlist',
                'Newpages'                  => 'SpecialNewpages',
@@ -162,7 +162,7 @@ class SpecialPage {
                'Tags'                      => 'SpecialTags',
 
                # Media reports and uploads
-               'Listfiles'                 => array( 'SpecialPage', 'Listfiles' ),
+               'Listfiles'                 => 'SpecialListFiles',
                'Filepath'                  => 'SpecialFilepath',
                'MIMEsearch'                => 'MIMEsearchPage',
                'FileDuplicateSearch'       => 'FileDuplicateSearchPage',
@@ -619,12 +619,13 @@ class SpecialPage {
         * @return String: HTML fragment
         */
        static function capturePath( &$title ) {
-               global $wgOut, $wgTitle;
+               global $wgOut, $wgTitle, $wgUser;
 
                $oldTitle = $wgTitle;
                $oldOut = $wgOut;
                $wgOut = new OutputPage;
                $wgOut->setTitle( $title );
+               $wgOut->setUser( $wgUser ); # for now, there may be a better idea in the future
 
                $ret = SpecialPage::executePath( $title, true );
                if ( $ret === true ) {
@@ -995,6 +996,53 @@ class SpecialPage {
                $this->mOutput = $output;
                $this->mFullTitle = $output->getTitle();
        }
+
+       /**
+        * Get the WebRequest being used for this instance
+        *
+        * @return WebRequest
+        */
+       public function getRequest() {
+               if ( !isset($this->mRequest) ) {
+                       wfDebug( __METHOD__ . " called and \$mRequest is null. Return \$wgRequest for sanity\n" );
+                       global $wgRequest;
+                       return $wgRequest;
+               }
+               return $this->mRequest;
+       }
+
+       /**
+        * Get the OutputPage being used for this instance
+        *
+        * @return OutputPage
+        */
+       public function getOutput() {
+               if ( !isset($this->mOutput) ) {
+                       wfDebug( __METHOD__ . " called and \$mOutput is null. Return \$wgOut for sanity\n" );
+                       global $wgOut;
+                       return $wgOut;
+               }
+               return $this->mOutput;
+       }
+
+       /**
+        * Shortcut to get the skin being used for this instance
+        *
+        * @return User
+        */
+       public function getUser() {
+               return $this->getOutput()->getUser();
+       }
+
+       /**
+        * Shortcut to get the skin being used for this instance
+        *
+        * @return Skin
+        */
+       public function getSkin() {
+               return $this->getOutput()->getSkin();
+       }
+
        /**
         * Wrapper around wfMessage that sets the current context. Currently this
         * is only the title.