* (bug 26484) add a lltitles param to prop=langlinks
[lhc/web/wiklou.git] / includes / SpecialPage.php
index e43a855..4a2af8a 100644 (file)
@@ -84,39 +84,39 @@ class SpecialPage {
         */
        static public $mList = array(
                # Maintenance Reports
-               'BrokenRedirects'           => array( 'SpecialPage', 'BrokenRedirects' ),
-               'Deadendpages'              => array( 'SpecialPage', 'Deadendpages' ),
-               'DoubleRedirects'           => array( 'SpecialPage', 'DoubleRedirects' ),
-               'Longpages'                 => array( 'SpecialPage', 'Longpages' ),
-               'Ancientpages'              => array( 'SpecialPage', 'Ancientpages' ),
-               'Lonelypages'               => array( 'SpecialPage', 'Lonelypages' ),
-               'Fewestrevisions'           => array( 'SpecialPage', 'Fewestrevisions' ),
-               'Withoutinterwiki'          => array( 'SpecialPage', 'Withoutinterwiki' ),
+               'BrokenRedirects'           => 'BrokenRedirectsPage',
+               'Deadendpages'              => 'DeadendpagesPage',
+               'DoubleRedirects'           => 'DoubleRedirectsPage',
+               'Longpages'                 => 'LongpagesPage',
+               'Ancientpages'              => 'AncientpagesPage',
+               'Lonelypages'               => 'LonelypagesPage',
+               'Fewestrevisions'           => 'FewestrevisionsPage',
+               'Withoutinterwiki'          => 'WithoutinterwikiPage',
                'Protectedpages'            => 'SpecialProtectedpages',
                'Protectedtitles'           => 'SpecialProtectedtitles',
-               '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' ),
-               'Unusedtemplates'           => array( 'SpecialPage', 'Unusedtemplates' ),
-               'Unwatchedpages'            => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
-               'Wantedcategories'          => array( 'SpecialPage', 'Wantedcategories' ),
-               'Wantedfiles'               => array( 'SpecialPage', 'Wantedfiles' ),
-               'Wantedpages'               => array( 'IncludableSpecialPage', 'Wantedpages' ),
-               'Wantedtemplates'           => array( 'SpecialPage', 'Wantedtemplates' ),
+               'Shortpages'                => 'ShortpagesPage',
+               'Uncategorizedcategories'   => 'UncategorizedcategoriesPage',
+               'Uncategorizedimages'       => 'UncategorizedimagesPage',
+               'Uncategorizedpages'        => 'UncategorizedpagesPage',
+               'Uncategorizedtemplates'    => 'UncategorizedtemplatesPage',
+               'Unusedcategories'          => 'UnusedcategoriesPage',
+               'Unusedimages'              => 'UnusedimagesPage',
+               'Unusedtemplates'           => 'UnusedtemplatesPage',
+               'Unwatchedpages'            => 'UnwatchedpagesPage',
+               'Wantedcategories'          => 'WantedcategoriesPage',
+               'Wantedfiles'               => 'WantedfilesPage',
+               'Wantedpages'               => 'WantedpagesPage',
+               'Wantedtemplates'           => 'WantedtemplatesPage',
 
                # List of pages
                'Allpages'                  => 'SpecialAllpages',
                'Prefixindex'               => 'SpecialPrefixindex',
                'Categories'                => 'SpecialCategories',
-               'Disambiguations'           => array( 'SpecialPage', 'Disambiguations' ),
-               'Listredirects'             => array( 'SpecialPage', 'Listredirects' ),
+               'Disambiguations'           => 'DisambiguationsPage',
+               'Listredirects'             => 'ListredirectsPage',
 
                # Login/create account
-               'Userlogin'                 => array( 'SpecialPage', 'Userlogin' ),
+               'Userlogin'                 => 'LoginForm',
                'CreateAccount'             => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
 
                # Users and rights
@@ -133,7 +133,7 @@ class SpecialPage {
                'Listbots'                  => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
                'Activeusers'               => 'SpecialActiveUsers',
                'Userrights'                => 'UserrightsPage',
-               'DisableAccount'            => 'SpecialDisableAccount',
+               'DisableAccount'            => 'SpecialDisableAccount',
 
                # Recent changes and logs
                'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
@@ -147,10 +147,10 @@ class SpecialPage {
                # Media reports and uploads
                'Listfiles'                 => array( 'SpecialPage', 'Listfiles' ),
                'Filepath'                  => 'SpecialFilepath',
-               'MIMEsearch'                => array( 'SpecialPage', 'MIMEsearch' ),
-               'FileDuplicateSearch'       => array( 'SpecialPage', 'FileDuplicateSearch' ),
+               'MIMEsearch'                => 'MIMEsearchPage',
+               'FileDuplicateSearch'       => 'FileDuplicateSearchPage',
                'Upload'                    => 'SpecialUpload',
-               'UploadStash'        => 'SpecialUploadStash',
+               'UploadStash'               => 'SpecialUploadStash',
 
                # Wiki data and tools
                'Statistics'                => 'SpecialStatistics',
@@ -160,23 +160,23 @@ class SpecialPage {
                'Unlockdb'                  => 'SpecialUnlockdb',
 
                # Redirecting special pages
-               'LinkSearch'                => array( 'SpecialPage', 'LinkSearch' ),
+               'LinkSearch'                => 'LinkSearchPage',
                'Randompage'                => 'Randompage',
                'Randomredirect'            => 'SpecialRandomredirect',
 
                # 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' ),
+               'Mostlinkedcategories'      => 'MostlinkedCategoriesPage',
+               'Mostimages'                => 'MostimagesPage',
+               'Mostlinked'                => 'MostlinkedPage',
+               'Mostlinkedtemplates'       => 'MostlinkedTemplatesPage',
+               'Mostcategories'            => 'MostcategoriesPage',
+               'Mostrevisions'             => 'MostrevisionsPage',
 
                # Page tools
                'ComparePages'              => 'SpecialComparePages',
                'Export'                    => 'SpecialExport',
                'Import'                    => 'SpecialImport',
-               'Undelete'                  => 'UndeleteForm',
+               'Undelete'                  => 'SpecialUndelete',
                'Whatlinkshere'             => 'SpecialWhatlinkshere',
                'MergeHistory'              => 'SpecialMergeHistory',
 
@@ -191,7 +191,8 @@ class SpecialPage {
                'Mycontributions'           => 'SpecialMycontributions',
                'Mypage'                    => 'SpecialMypage',
                'Mytalk'                    => 'SpecialMytalk',
-               'Myuploads'                     => 'SpecialMyuploads',
+               'Myuploads'                 => 'SpecialMyuploads',
+               'PermanentLink'             => 'SpecialPermanentLink',
                'Revisiondelete'            => 'SpecialRevisionDelete',
                'RevisionMove'              => 'SpecialRevisionMove',
                'Specialpages'              => 'SpecialSpecialpages',
@@ -220,11 +221,11 @@ class SpecialPage {
                self::$mListInitialised = true;
 
                if( !$wgDisableCounters ) {
-                       self::$mList['Popularpages'] = array( 'SpecialPage', 'Popularpages' );
+                       self::$mList['Popularpages'] = 'PopularpagesPage';
                }
 
                if( !$wgDisableInternalSearch ) {
-                       self::$mList['Search'] = array( 'SpecialPage', 'Search' );
+                       self::$mList['Search'] = 'SpecialSearch';
                }
 
                if( $wgEmailAuthentication ) {
@@ -406,7 +407,7 @@ class SpecialPage {
                                self::$mList[$name] = new $className;
                        } elseif ( is_array( $rec ) ) {
                                $className = array_shift( $rec );
-                               self::$mList[$name] = wfCreateObject( $className, $rec );
+                               self::$mList[$name] = MWFunction::newObj( $className, $rec );
                        }
                        return self::$mList[$name];
                } else {
@@ -541,12 +542,18 @@ class SpecialPage {
                # Check for redirect
                if ( !$including ) {
                        $redirect = $page->getRedirect( $par );
-                       if ( $redirect ) {
-                               $query = $page->getRedirectQuery();
+                       $query = $page->getRedirectQuery();
+                       if ( $redirect instanceof Title ) {
                                $url = $redirect->getFullUrl( $query );
                                $wgOut->redirect( $url );
                                wfProfileOut( __METHOD__ );
                                return $redirect;
+                       } elseif( $redirect === true ) {
+                               global $wgScript;
+                               $url = $wgScript . '?' . wfArrayToCGI( $query );
+                               $wgOut->redirect( $url );
+                               wfProfileOut( __METHOD__ );
+                               return $redirect;
                        }
                }
 
@@ -702,7 +709,16 @@ class SpecialPage {
         * @param $file String: file which is included by execute(). It is also constructed from $name by default
         * @param $includable Boolean: whether the page can be included in normal pages
         */
-       function __construct( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
+       public function __construct( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
+               $this->init( $name, $restriction, $listed, $function, $file, $includable );
+       }
+
+       /**
+        * Do the real work for the constructor, mainly so __call() can intercept
+        * calls to SpecialPage()
+        * @see __construct() for param docs
+        */
+       private function init( $name, $restriction, $listed, $function, $file, $includable ) {
                $this->mName = $name;
                $this->mRestriction = $restriction;
                $this->mListed = $listed;
@@ -719,6 +735,32 @@ class SpecialPage {
                }
        }
 
+       /**
+        * Use PHP's magic __call handler to get calls to the old PHP4 constructor
+        * because PHP E_STRICT yells at you for having __construct() and SpecialPage()
+        *
+        * @param $fName String Name of called method
+        * @param $a Array Arguments to the method
+        * @deprecated Call isn't deprecated, but SpecialPage::SpecialPage() is
+        */
+       public function __call( $fName, $a ) {
+               // Sometimes $fName is SpecialPage, sometimes it's specialpage. <3 PHP
+               if( strtolower( $fName ) == 'specialpage' ) {
+                       // Debug messages now, warnings in 1.19 or 1.20?
+                       wfDebug( "Deprecated SpecialPage::SpecialPage() called, use __construct();\n" );
+                       $name = isset( $a[0] ) ? $a[0] : '';
+                       $restriction = isset( $a[1] ) ? $a[1] : '';
+                       $listed = isset( $a[2] ) ? $a[2] : true;
+                       $function = isset( $a[3] ) ? $a[3] : false;
+                       $file = isset( $a[4] ) ? $a[4] : 'default';
+                       $includable = isset( $a[5] ) ? $a[5] : false;
+                       $this->init( $name, $restriction, $listed, $function, $file, $includable );
+               } else {
+                       $className = get_class( $this );
+                       throw new MWException( "Call to undefined method $className::$fName" );
+               }
+       }
+
        /**#@+
          * Accessor
          *
@@ -894,16 +936,20 @@ class SpecialPage {
        function getRedirectQuery() {
                global $wgRequest;
                $params = array();
+
                foreach( $this->mAllowedRedirectParams as $arg ) {
-                       if( ( $val = $wgRequest->getVal( $arg, null ) ) !== null )
-                               $params[] = $arg . '=' . $val;
+                       if( $wgRequest->getVal( $arg, null ) !== null ){
+                               $params[$arg] = $wgRequest->getVal( $arg );
+                       }
                }
-               
+
                foreach( $this->mAddedRedirectParams as $arg => $val ) {
-                       $params[] = $arg . '=' . $val;
+                       $params[$arg] = $val;
                }
-               
-               return count( $params ) ? implode( '&', $params ) : false;
+
+               return count( $params )
+                       ? $params
+                       : false;
        }
 }
 
@@ -953,7 +999,8 @@ class SpecialRedirectToSpecial extends UnlistedSpecialPage {
        }
 }
 
-/** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
+/**
+ * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
  * are used to get user independant links pointing to the user page, talk
  * page and list of contributions.
  * This can let us cache a single copy of any generated content for all
@@ -1027,9 +1074,25 @@ class SpecialMyuploads extends UnlistedSpecialPage {
                parent::__construct( 'Myuploads' );
                $this->mAllowedRedirectParams = array( 'limit' );
        }
-       
+
        function getRedirect( $subpage ) {
                global $wgUser;
                return SpecialPage::getTitleFor( 'Listfiles', $wgUser->getName() );
        }
-}
\ No newline at end of file
+}
+
+/**
+ * Redirect from Special:PermanentLink/### to index.php?oldid=###
+ */
+class SpecialPermanentLink extends UnlistedSpecialPage {
+       function __construct() {
+               parent::__construct( 'PermanentLink' );
+               $this->mAllowedRedirectParams = array();
+       }
+
+       function getRedirect( $subpage ) {
+               $subpage = intval( $subpage );
+               $this->mAddedRedirectParams['oldid'] = $subpage;
+               return true;
+       }
+}