From 9a8ed786271484118187c7bdb56f421e553f14ee Mon Sep 17 00:00:00 2001 From: Gilles Dubuc Date: Fri, 29 May 2015 22:00:17 +0200 Subject: [PATCH] Make ResourceLoaderWikiModule support custom position Bug: T97410 Change-Id: Ib1180c5b2126f4ba8ac5b54578fcce18a3f35d85 --- .../ResourceLoaderWikiModule.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index 4d207f6373..74ad774884 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 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { * @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 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { } return $this->titleInfo[$hash]; } + + public function getPosition() { + return $this->position; + } } -- 2.20.1