<?php
/**
- * Context for resource loader modules.
+ * Context for ResourceLoader modules.
*
* 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
* @author Roan Kattouw
*/
+use MediaWiki\Logger\LoggerFactory;
+
/**
* Object passed around to modules which contains information about the state
* of a specific loader request
$this->resourceLoader = $resourceLoader;
$this->request = $request;
- // Interpret request
// List of modules
$modules = $request->getVal( 'modules' );
$this->modules = $modules ? self::expandModuleNames( $modules ) : array();
+
// Various parameters
- $this->skin = $request->getVal( 'skin' );
$this->user = $request->getVal( 'user' );
$this->debug = $request->getFuzzyBool(
- 'debug', $resourceLoader->getConfig()->get( 'ResourceLoaderDebug' )
+ 'debug',
+ $resourceLoader->getConfig()->get( 'ResourceLoaderDebug' )
);
- $this->only = $request->getVal( 'only' );
- $this->version = $request->getVal( 'version' );
+ $this->only = $request->getVal( 'only', null );
+ $this->version = $request->getVal( 'version', null );
$this->raw = $request->getFuzzyBool( 'raw' );
+
// Image requests
$this->image = $request->getVal( 'image' );
$this->variant = $request->getVal( 'variant' );
$this->format = $request->getVal( 'format' );
+ $this->skin = $request->getVal( 'skin' );
$skinnames = Skin::getSkinNames();
// If no skin is specified, or we don't recognize the skin, use the default skin
if ( !$this->skin || !isset( $skinnames[$this->skin] ) ) {
*/
public static function newDummyContext() {
return new self( new ResourceLoader(
- ConfigFactory::getDefaultInstance()->makeConfig( 'main' )
+ ConfigFactory::getDefaultInstance()->makeConfig( 'main' ),
+ LoggerFactory::getInstance( 'resourceloader' )
), new FauxRequest( array() ) );
}
public function getLanguage() {
if ( $this->language === null ) {
// Must be a valid language code after this point (bug 62849)
- $this->language = RequestContext::sanitizeLangCode( $this->request->getVal( 'lang' ) );
+ $this->language = RequestContext::sanitizeLangCode( $this->getRequest()->getVal( 'lang' ) );
}
return $this->language;
}
*/
public function getDirection() {
if ( $this->direction === null ) {
- $this->direction = $this->request->getVal( 'dir' );
+ $this->direction = $this->getRequest()->getVal( 'dir' );
if ( !$this->direction ) {
// Determine directionality based on user language (bug 6100)
$this->direction = Language::factory( $this->getLanguage() )->getDir();
}
/**
- * @return string|null
+ * @return string
*/
public function getSkin() {
return $this->skin;
}
/**
+ * @see ResourceLoaderModule::getVersionHash
+ * @see OutputPage::makeResourceLoaderLink
* @return string|null
*/
public function getVersion() {
return $this->imageObj;
}
- $image = $module->getImage( $this->image );
+ $image = $module->getImage( $this->image, $this );
if ( !$image ) {
return $this->imageObj;
}
* @return bool
*/
public function shouldIncludeScripts() {
- return is_null( $this->getOnly() ) || $this->getOnly() === 'scripts';
+ return $this->getOnly() === null || $this->getOnly() === 'scripts';
}
/**
* @return bool
*/
public function shouldIncludeStyles() {
- return is_null( $this->getOnly() ) || $this->getOnly() === 'styles';
+ return $this->getOnly() === null || $this->getOnly() === 'styles';
}
/**
* @return bool
*/
public function shouldIncludeMessages() {
- return is_null( $this->getOnly() );
+ return $this->getOnly() === null;
}
/**