* $wgAjaxSearch has been removed; use $wgEnableMWSuggest instead.
[lhc/web/wiklou.git] / includes / SpecialPage.php
index 9d40634..c7b0308 100644 (file)
  * 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
 {
@@ -88,7 +90,7 @@ class SpecialPage
                'Preferences'               => array( 'SpecialPage', 'Preferences' ),
                'Watchlist'                 => array( 'SpecialPage', 'Watchlist' ),
 
-               'Recentchanges'             => array( 'IncludableSpecialPage', 'Recentchanges' ),
+               'Recentchanges'             => 'SpecialRecentchanges',
                'Upload'                    => array( 'SpecialPage', 'Upload' ),
                'Imagelist'                 => array( 'SpecialPage', 'Imagelist' ),
                'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
@@ -114,7 +116,7 @@ class SpecialPage
                'Fewestrevisions'           => array( 'SpecialPage', 'Fewestrevisions' ),
                'Shortpages'                => array( 'SpecialPage', 'Shortpages' ),
                'Longpages'                 => array( 'SpecialPage', 'Longpages' ),
-               'Newpages'                  => array( 'IncludableSpecialPage', 'Newpages' ),
+               'Newpages'                  => 'SpecialNewpages',
                'Ancientpages'              => array( 'SpecialPage', 'Ancientpages' ),
                'Deadendpages'              => array( 'SpecialPage', 'Deadendpages' ),
                'Protectedpages'            => array( 'SpecialPage', 'Protectedpages' ),
@@ -126,7 +128,7 @@ class SpecialPage
                'Contributions'             => array( 'SpecialPage', 'Contributions' ),
                'Emailuser'                 => array( 'UnlistedSpecialPage', 'Emailuser' ),
                'Whatlinkshere'             => array( 'SpecialPage', 'Whatlinkshere' ),
-               'Recentchangeslinked'       => array( 'SpecialPage', 'Recentchangeslinked' ),
+               'Recentchangeslinked'       => 'SpecialRecentchangeslinked',
                'Movepage'                  => array( 'UnlistedSpecialPage', 'Movepage' ),
                'Blockme'                   => array( 'UnlistedSpecialPage', 'Blockme' ),
                'Resetpass'                 => array( 'UnlistedSpecialPage', 'Resetpass' ),
@@ -134,6 +136,7 @@ class SpecialPage
                'Categories'                => array( 'SpecialPage', 'Categories' ),
                'Export'                    => array( 'SpecialPage', 'Export' ),
                'Version'                   => array( 'SpecialPage', 'Version' ),
+               'Blankpage'                 => array( 'UnlistedSpecialPage', 'Blankpage' ),
                'Allmessages'               => array( 'SpecialPage', 'Allmessages' ),
                'Log'                       => array( 'SpecialPage', 'Log' ),
                'Blockip'                   => array( 'SpecialPage', 'Blockip', 'block' ),
@@ -162,97 +165,6 @@ class SpecialPage
 
        static public $mAliases;
        static public $mListInitialised = false;
-       /**
-        * List of special pages, followed by what subtitle they should go under
-        * at Special:SpecialPages
-        */
-       static public $mGroupsList = array(
-               'DoubleRedirects'           => 'maintenance',
-               'BrokenRedirects'           => 'maintenance',
-               'Lonelypages'               => 'maintenance',
-               'Uncategorizedpages'        => 'maintenance',
-               'Uncategorizedcategories'   => 'maintenance',
-               'Uncategorizedimages'       => 'maintenance',
-               'Uncategorizedtemplates'    => 'maintenance',
-               'Unusedcategories'          => 'maintenance',
-               'Unusedimages'              => 'maintenance',
-               'Protectedpages'            => 'maintenance',
-               'Protectedtitles'           => 'maintenance',
-               'Unusedtemplates'           => 'maintenance',
-               'Withoutinterwiki'          => 'maintenance',
-               'Longpages'                 => 'maintenance',
-
-               'Userlogin'                 => 'login',
-               'Userlogout'                => 'login',
-               'CreateAccount'             => 'login',
-
-               'Recentchanges'             => 'changes',
-               'Recentchangeslinked'       => 'changes',
-               'Watchlist'                 => 'changes',
-               'Newimages'                 => 'changes',
-               'Newpages'                  => 'changes',
-               'Log'                       => 'changes',
-
-               'Upload'                    => 'media',
-               'Imagelist'                 => 'media',
-               'MIMEsearch'                => 'media',
-               'FileDuplicateSearch'       => 'media',
-               'Filepath'                  => 'media',
-
-               'Listusers'                 => 'users',
-               'Listgrouprights'           => 'users',
-               'Ipblocklist'               => 'users',
-               'Contributions'             => 'users',
-               'Emailuser'                 => 'users',
-               'Listadmins'                => 'users',
-               'Listbots'                  => 'users',
-
-               'Wantedpages'               => 'needy',
-               'Wantedcategories'          => 'needy',
-               'Shortpages'                => 'needy',
-               'Ancientpages'              => 'needy',
-               'Deadendpages'              => 'needy',
-
-               'Mostlinked'                => 'highuse',
-               'Mostlinkedcategories'      => 'highuse',
-               'Mostlinkedtemplates'       => 'highuse',
-               'Mostcategories'            => 'highuse',
-               'Mostimages'                => 'highuse',
-               'Mostrevisions'             => 'highuse',
-
-               'Userrights'                => 'permissions',
-               'Blockip'                   => 'permissions',
-
-               'Statistics'                => 'other',
-               'Fewestrevisions'           => 'other',
-               'Randompage'                => 'other',
-               'Disambiguations'           => 'other',
-               'Specialpages'              => 'other',
-               'Blockme'                   => 'other',
-               'Movepage'                  => 'other',
-               'MergeHistory'              => 'other',
-               'Lockdb'                    => 'other',
-               'Unlockdb'                  => 'other',
-               'Version'                   => 'other',
-               'Whatlinkshere'             => 'other',
-               'Booksources'               => 'other',
-               'Revisiondelete'            => 'other',
-               'Export'                    => 'other',
-               'Categories'                => 'other',
-               'Undelete'                  => 'other',
-               'Import'                    => 'other',
-               'Unwatchedpages'            => 'other',
-               'Randomredirect'            => 'other',
-               'Allpages'                  => 'other',
-               'Allmessages'               => 'other',
-               'Prefixindex'               => 'other',
-               'Listredirects'             => 'other',
-               'Preferences'               => 'other',
-               'Resetpass'                 => 'other',
-               'Mypage'                    => 'other',
-               'Mytalk'                    => 'other',
-               'Mycontributions'           => 'other',
-       );
 
        /**#@-*/
 
@@ -352,10 +264,7 @@ class SpecialPage
         * 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 ) {
@@ -368,31 +277,37 @@ class SpecialPage
        /**
         * Add a page to a certain display group for Special:SpecialPages
         *
-        * @param mixed $page Must either be an array specifying a class name and
-        *                    constructor parameters, or an object.
+        * @param mixed $page (SpecialPage or string)
         * @param string $group
         * @static
         */
-       static function setGroup( &$page, $group ) {
-               if ( !self::$mListInitialised ) {
-                       self::initList();
-               }
-               self::$mGroupsList[$page->mName] = $group;
+       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 mixed $page Must either be an array specifying a class name and
-        *                    constructor parameters, or an object.
+        * @param SpecialPage $page
         * @static
         */
        static function getGroup( &$page ) {
-               if ( !self::$mListInitialised ) {
-                       self::initList();
-               }
-               $group = isset(self::$mGroupsList[$page->mName]) ?
-                       self::$mGroupsList[$page->mName] : 'other';
+               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;
        }
 
@@ -471,6 +386,32 @@ class SpecialPage
                }
        }
 
+       /**
+        * 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
@@ -497,17 +438,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;
                        }
@@ -543,7 +484,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' );
                        }
@@ -702,7 +643,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;
                }
@@ -818,7 +759,7 @@ class SpecialPage
                $msg = $wgContLang->lc( $this->name() ) . '-summary';
                $out = wfMsgNoTrans( $msg );
                if ( ! wfEmptyMsg( $msg, $out ) and  $out !== '' and ! $this->including() ) {
-                       $wgOut->addWikiText( $out );
+                       $wgOut->addWikiMsg( $msg );
                }
 
        }
@@ -874,7 +815,7 @@ class SpecialPage
 
 /**
  * Shortcut to construct a special page which is unlisted by default
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class UnlistedSpecialPage extends SpecialPage
 {
@@ -885,7 +826,7 @@ class UnlistedSpecialPage extends SpecialPage
 
 /**
  * Shortcut to construct an includable special  page
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class IncludableSpecialPage extends SpecialPage
 {
@@ -896,7 +837,7 @@ class IncludableSpecialPage extends SpecialPage
 
 /**
  * Shortcut to construct a special page alias.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class SpecialRedirectToSpecial extends UnlistedSpecialPage {
        var $redirName, $redirSubpage;
@@ -926,7 +867,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() {
@@ -946,7 +887,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() {
@@ -966,7 +907,7 @@ 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() {