Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderUserModule.php
index 1b6d1de..d584165 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Resource loader module for user customizations.
+ * ResourceLoader module for user customizations.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  */
 class ResourceLoaderUserModule extends ResourceLoaderWikiModule {
 
-       /* Protected Members */
-
        protected $origin = self::ORIGIN_USER_INDIVIDUAL;
 
-       /* Protected Methods */
-
        /**
+        * Get list of pages used by this module
+        *
         * @param ResourceLoaderContext $context
-        * @return array
+        * @return array List of pages
         */
        protected function getPages( ResourceLoaderContext $context ) {
-               $username = $context->getUser();
-
-               if ( $username === null ) {
-                       return array();
-               }
-
                $allowUserJs = $this->getConfig()->get( 'AllowUserJs' );
                $allowUserCss = $this->getConfig()->get( 'AllowUserCss' );
-
                if ( !$allowUserJs && !$allowUserCss ) {
-                       return array();
+                       return [];
                }
 
-               // Get the normalized title of the user's user page
-               $userpageTitle = Title::makeTitleSafe( NS_USER, $username );
-
-               if ( !$userpageTitle instanceof Title ) {
-                       return array();
+               $user = $context->getUserObj();
+               if ( !$user || $user->isAnon() ) {
+                       return [];
                }
 
-               $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works
+               // Needed so $excludepages works
+               $userPage = $user->getUserPage()->getPrefixedDBkey();
 
-               $pages = array();
+               $pages = [];
                if ( $allowUserJs ) {
-                       $pages["$userpage/common.js"] = array( 'type' => 'script' );
-                       $pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' );
+                       $pages["$userPage/common.js"] = [ 'type' => 'script' ];
+                       $pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ];
                }
                if ( $allowUserCss ) {
-                       $pages["$userpage/common.css"] = array( 'type' => 'style' );
-                       $pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' );
+                       $pages["$userPage/common.css"] = [ 'type' => 'style' ];
+                       $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
                }
 
                // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
@@ -82,9 +72,9 @@ class ResourceLoaderUserModule extends ResourceLoaderWikiModule {
                return $pages;
        }
 
-       /* Methods */
-
        /**
+        * Get group name
+        *
         * @return string
         */
        public function getGroup() {