Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/201266
Change subject: ResourceLoaderImageModule: Inherit from ResourceLoaderFileModule
......................................................................
ResourceLoaderImageModule: Inherit from ResourceLoaderFileModule
Bug: T94731
Change-Id: I38848acd488d4bd22d94a1d34862aac65cf0b93a
---
M includes/resourceloader/ResourceLoaderImageModule.php
1 file changed, 17 insertions(+), 41 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/66/201266/1
diff --git a/includes/resourceloader/ResourceLoaderImageModule.php
b/includes/resourceloader/ResourceLoaderImageModule.php
index bf6a7dd..a4203a9 100644
--- a/includes/resourceloader/ResourceLoaderImageModule.php
+++ b/includes/resourceloader/ResourceLoaderImageModule.php
@@ -26,32 +26,23 @@
*
* @since 1.25
*/
-class ResourceLoaderImageModule extends ResourceLoaderModule {
+class ResourceLoaderImageModule extends ResourceLoaderFileModule {
/**
- * Local base path, see __construct()
- * @var string
+ * Change the default from `array( 'desktop' )`.
+ * @var array
*/
- protected $localBasePath = '';
-
- protected $origin = self::ORIGIN_CORE_SITEWIDE;
+ protected $targets = array( 'desktop', 'mobile' );
protected $images = array();
protected $variants = array();
protected $prefix = null;
protected $selectorWithoutVariant = '.{prefix}-{name}';
protected $selectorWithVariant = '.{prefix}-{name}-{variant}';
- protected $targets = array( 'desktop', 'mobile' );
/**
- * Constructs a new module from an options array.
- *
- * @param array $options List of options; if not given or empty, an
empty module will be
- * constructed
- * @param string $localBasePath Base path to prepend to all local paths
in $options. Defaults
- * to $IP
- *
- * Below is a description for the $options array:
+ * Below is a description for the $options array, in addition to the
options provided by
+ * ResourceLoaderFileModule:
* @par Construction options:
* @code
* array(
@@ -87,8 +78,12 @@
* @endcode
* @throws InvalidArgumentException
*/
- public function __construct( $options = array(), $localBasePath = null
) {
- $this->localBasePath = self::extractLocalBasePath( $options,
$localBasePath );
+ public function __construct(
+ $options = array(),
+ $localBasePath = null,
+ $remoteBasePath = null
+ ) {
+ parent::__construct( $options, $localBasePath, $remoteBasePath
);
// Accepted combinations:
// * prefix
@@ -232,6 +227,8 @@
* @return array
*/
public function getStyles( ResourceLoaderContext $context ) {
+ $styles = parent::getStyles( $context );
+
// Build CSS rules
$rules = array();
$script = $context->getResourceLoader()->getLoadScript(
$this->getSource() );
@@ -271,8 +268,9 @@
}
}
- $style = implode( "\n", $rules );
- return array( 'all' => $style );
+ $styles['all'] = isset( $styles['all'] ) ?
(array)$styles['all'] : array();
+ $styles['all'][] = implode( "\n", $rules );
+ return $styles;
}
/**
@@ -301,27 +299,5 @@
*/
public function supportsURLLoading() {
return false;
- }
-
- /**
- * Extract a local base path from module definition information.
- *
- * @param array $options Module definition
- * @param string $localBasePath Path to use if not provided in module
definition. Defaults
- * to $IP
- * @return string Local base path
- */
- public static function extractLocalBasePath( $options, $localBasePath =
null ) {
- global $IP;
-
- if ( $localBasePath === null ) {
- $localBasePath = $IP;
- }
-
- if ( array_key_exists( 'localBasePath', $options ) ) {
- $localBasePath = (string)$options['localBasePath'];
- }
-
- return $localBasePath;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/201266
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I38848acd488d4bd22d94a1d34862aac65cf0b93a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits