Gilles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/214741

Change subject: Make ResourceLoaderWikiModule support custom position
......................................................................

Make ResourceLoaderWikiModule support custom position

Bug: T97410
Change-Id: Ib1180c5b2126f4ba8ac5b54578fcce18a3f35d85
---
M includes/resourceloader/ResourceLoaderWikiModule.php
1 file changed, 20 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/41/214741/1

diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php 
b/includes/resourceloader/ResourceLoaderWikiModule.php
index 4d207f6..74ad774 100644
--- a/includes/resourceloader/ResourceLoaderWikiModule.php
+++ b/includes/resourceloader/ResourceLoaderWikiModule.php
@@ -30,6 +30,8 @@
  * Title::isCssJsSubpage.
  */
 class ResourceLoaderWikiModule extends ResourceLoaderModule {
+       /** @var string Position on the page to load this module at */
+       protected $position = 'bottom';
 
        // Origin defaults to users with sitewide authority
        protected $origin = self::ORIGIN_USER_SITEWIDE;
@@ -50,14 +52,21 @@
         * @param array $options For back-compat, this can be omitted in favour 
of overwriting getPages.
         */
        public function __construct( array $options = null ) {
-               if ( isset( $options['styles'] ) ) {
-                       $this->styles = $options['styles'];
+               if ( is_null( $options ) ) {
+                       return;
                }
-               if ( isset( $options['scripts'] ) ) {
-                       $this->scripts = $options['scripts'];
-               }
-               if ( isset( $options['group'] ) ) {
-                       $this->group = $options['group'];
+
+               foreach ( $options as $member => $option ) {
+                       switch ( $member ) {
+                               case 'position':
+                                       $this->isPositionDefined = true;
+                                       // Don't break since we need the member 
set as well
+                               case 'styles':
+                               case 'scripts':
+                               case 'group':
+                                       $this->{$member} = $option;
+                                       break;
+                       }
                }
        }
 
@@ -305,4 +314,8 @@
                }
                return $this->titleInfo[$hash];
        }
+
+       public function getPosition() {
+               return $this->position;
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/214741
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1180c5b2126f4ba8ac5b54578fcce18a3f35d85
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.26wmf8
Gerrit-Owner: Gilles <gdu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to