Merge "Introduce ContentGetParserOutput hook"
[lhc/web/wiklou.git] / includes / specialpage / SpecialPageFactory.php
index 54d9793..dd22769 100644 (file)
@@ -79,6 +79,7 @@ class SpecialPageFactory {
                'Categories' => 'SpecialCategories',
                'Listredirects' => 'ListredirectsPage',
                'PagesWithProp' => 'SpecialPagesWithProp',
+               'TrackingCategories' => 'SpecialTrackingCategories',
 
                // Login/create account
                'Userlogin' => 'LoginForm',
@@ -231,7 +232,7 @@ class SpecialPageFactory {
         * aliases; the first in the array is the canonical alias.  All registered special
         * pages are guaranteed to have a property entry, and for that property array to
         * contain at least one entry (English fallbacks will be added if necessary).
-        * @return Object
+        * @return object
         */
        static function getAliasList() {
                if ( !is_object( self::$aliases ) ) {
@@ -344,7 +345,8 @@ class SpecialPageFactory {
                                return new $className;
                        } elseif ( is_array( $rec ) ) {
                                // @deprecated, officially since 1.18, unofficially since forever
-                               wfDebug( "Array syntax for \$wgSpecialPages is deprecated, define a subclass of SpecialPage instead." );
+                               wfDebug( "Array syntax for \$wgSpecialPages is deprecated, " .
+                                       "define a subclass of SpecialPage instead." );
                                $className = array_shift( $rec );
                                self::getList()->$realName = MWFunction::newObj( $className, $rec );
                        }
@@ -359,7 +361,7 @@ class SpecialPageFactory {
         * Return categorised listable special pages which are available
         * for the current user, and everyone.
         *
-        * @param $user User object to check permissions, $wgUser will be used if
+        * @param User $user User object to check permissions, $wgUser will be used if
         *   if not provided
         * @return array ( string => Specialpage )
         */
@@ -405,17 +407,21 @@ class SpecialPageFactory {
         * Return categorised listable special pages which are available
         * for the current user, but not for everyone
         *
+        * @param User|null $user User object to use or null for $wgUser
         * @return array ( string => Specialpage )
         */
-       public static function getRestrictedPages() {
-               global $wgUser;
+       public static function getRestrictedPages( User $user = null ) {
                $pages = array();
+               if ( $user === null ) {
+                       global $wgUser;
+                       $user = $wgUser;
+               }
                foreach ( self::getList() as $name => $rec ) {
                        $page = self::getPage( $name );
                        if (
                                $page->isListed()
                                && $page->isRestricted()
-                               && $page->userCanExecute( $wgUser )
+                               && $page->userCanExecute( $user )
                        ) {
                                $pages[$name] = $page;
                        }