API: Change acprop description to allow for future expansion
[lhc/web/wiklou.git] / includes / SpecialPage.php
index 9125f37..c9380ba 100644 (file)
  * @addtogroup SpecialPage
  */
 
-/**
- * @access private
- */
-
 /**
  * Parent special page class, also static functions for handling the special
  * page list.
@@ -80,6 +76,7 @@ class SpecialPage
 
                'Userlogin'                 => array( 'SpecialPage', 'Userlogin' ),
                'Userlogout'                => array( 'UnlistedSpecialPage', 'Userlogout' ),
+               'CreateAccount'             => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
                'Preferences'               => array( 'SpecialPage', 'Preferences' ),
                'Watchlist'                 => array( 'SpecialPage', 'Watchlist' ),
 
@@ -89,7 +86,7 @@ class SpecialPage
                'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
                'Listusers'                 => array( 'SpecialPage', 'Listusers' ),
                'Statistics'                => array( 'SpecialPage', 'Statistics' ),
-               'Randompage'                => array( 'SpecialPage', 'Randompage' ),
+               'Randompage'                => 'Randompage',
                'Lonelypages'               => array( 'SpecialPage', 'Lonelypages' ),
                'Uncategorizedpages'        => array( 'SpecialPage', 'Uncategorizedpages' ),
                'Uncategorizedcategories'   => array( 'SpecialPage', 'Uncategorizedcategories' ),
@@ -112,6 +109,7 @@ class SpecialPage
                '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' ),
@@ -131,23 +129,27 @@ class SpecialPage
                'Log'                       => array( 'SpecialPage', 'Log' ),
                'Blockip'                   => array( 'SpecialPage', 'Blockip', 'block' ),
                'Undelete'                  => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
-               'Import'                    => array( 'SpecialPage', "Import", 'import' ),
+               'Import'                    => array( 'SpecialPage', 'Import', 'import' ),
                'Lockdb'                    => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
                'Unlockdb'                  => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
-               'Userrights'                => array( 'SpecialPage', 'Userrights', 'userrights' ),
+               'Userrights'                => 'UserrightsPage',
                'MIMEsearch'                => array( 'SpecialPage', 'MIMEsearch' ),
+               'FileDuplicateSearch'       => array( 'SpecialPage', 'FileDuplicateSearch' ),
                'Unwatchedpages'            => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
                'Listredirects'             => array( 'SpecialPage', 'Listredirects' ),
-               'Revisiondelete'            => array( 'SpecialPage', 'Revisiondelete', 'deleterevision' ),
+               'Revisiondelete'            => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
                'Unusedtemplates'           => array( 'SpecialPage', 'Unusedtemplates' ),
-               'Randomredirect'            => array( 'SpecialPage', 'Randomredirect' ),
+               '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' ),
-       );
+               'MergeHistory'              => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
+               'Listbots'                  => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
+               );
 
        static public $mAliases;
        static public $mListInitialised = false;
@@ -349,7 +351,7 @@ class SpecialPage
 
                foreach ( self::$mList as $name => $rec ) {
                        $page = self::getPage( $name );
-                       if ( $page->isListed() && $page->getRestriction() == '' ) {
+                       if ( $page->isListed() && !$page->isRestricted() ) {
                                $pages[$name] = $page;
                        }
                }
@@ -370,11 +372,12 @@ class SpecialPage
 
                foreach ( self::$mList as $name => $rec ) {
                        $page = self::getPage( $name );
-                       if ( $page->isListed() ) {
-                               $restriction = $page->getRestriction();
-                               if ( $restriction != '' && $wgUser->isAllowed( $restriction ) ) {
-                                       $pages[$name] = $page;
-                               }
+                       if (
+                               $page->isListed()
+                               and $page->isRestricted()
+                               and $page->userCanExecute( $wgUser )
+                       ) {
+                               $pages[$name] = $page;
                        }
                }
                return $pages;
@@ -404,7 +407,6 @@ class SpecialPage
                        $par = $bits[1];
                }
                $page = SpecialPage::getPageByAlias( $name );
-
                # Nonexistent?
                if ( !$page ) {
                        if ( !$including ) {
@@ -486,6 +488,11 @@ class SpecialPage
 
        /**
         * Get the local name for a specified canonical name
+        *
+        * @param $name
+        * @param mixed $subpage Boolean false, or string
+        *
+        * @return string
         */
        static function getLocalNameFor( $name, $subpage = false ) {
                global $wgContLang;
@@ -602,11 +609,26 @@ class SpecialPage
                return $this->mLocalName;
        }
 
+       /**
+        * Can be overridden by subclasses with more complicated permissions
+        * schemes.
+        *
+        * @return bool Should the page be displayed with the restricted-access
+        *   pages?
+        */
+       public function isRestricted() {
+               return $this->mRestriction != '';
+       }
+
        /**
         * Checks if the given user (identified by an object) can execute this
-        * special page (as defined by $mRestriction)
+        * special page (as defined by $mRestriction).  Can be overridden by sub-
+        * classes with more complicated permissions schemes.
+        *
+        * @param User $user The user to check
+        * @return bool Does the user have permission to view the page?
         */
-       function userCanExecute( &$user ) {
+       public function userCanExecute( $user ) {
                return $user->isAllowed( $this->mRestriction );
        }
 
@@ -642,7 +664,7 @@ class SpecialPage
                if ( $this->userCanExecute( $wgUser ) ) {
                        $func = $this->mFunction;
                        // only load file if the function does not exist
-                       if(!function_exists($func) and $this->mFile) {
+                       if(!is_callable($func) and $this->mFile) {
                                require_once( $this->mFile );
                        }
                        # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage. 
@@ -650,7 +672,7 @@ class SpecialPage
                                $this->outputHeader();
                        if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
                                return;
-                       $func( $par, $this );
+                       call_user_func( $func, $par, $this );
                        if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
                                return;
                } else {
@@ -662,9 +684,10 @@ class SpecialPage
                global $wgOut, $wgContLang;
 
                $msg = $wgContLang->lc( $this->name() ) . '-summary';
-               $out = wfMsg( $msg );
-               if ( ! wfEmptyMsg( $msg, $out ) and  $out !== '' and ! $this->including() )
+               $out = wfMsgNoTrans( $msg );
+               if ( ! wfEmptyMsg( $msg, $out ) and  $out !== '' and ! $this->including() ) {
                        $wgOut->addWikiText( $out );
+               }
 
        }
 
@@ -776,7 +799,7 @@ class SpecialRedirectToSpecial extends UnlistedSpecialPage {
 class SpecialMypage extends UnlistedSpecialPage {
        function __construct() {
                parent::__construct( 'Mypage' );
-               $this->mAllowedRedirectParams = array( 'action' );
+               $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro', 'section' );
        }
 
        function getRedirect( $subpage ) {
@@ -796,7 +819,7 @@ class SpecialMypage extends UnlistedSpecialPage {
 class SpecialMytalk extends UnlistedSpecialPage {
        function __construct() {
                parent::__construct( 'Mytalk' );
-               $this->mAllowedRedirectParams = array( 'action' );
+               $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro', 'section' );
        }
 
        function getRedirect( $subpage ) {
@@ -823,5 +846,3 @@ class SpecialMycontributions extends UnlistedSpecialPage {
                return SpecialPage::getTitleFor( 'Contributions', $wgUser->getName() );
        }
 }
-
-