* of a specific loader request.
*/
class ResourceLoaderContext implements MessageLocalizer {
+ const DEFAULT_LANG = 'qqx';
+ const DEFAULT_SKIN = 'fallback';
+
protected $resourceLoader;
protected $request;
protected $logger;
$this->skin = $request->getRawVal( '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] ) ) {
- $this->skin = $this->getConfig()->get( 'DefaultSkin' );
+ // The 'skin' parameter is required. (Not yet enforced.)
+ // For requests without a known skin specified,
+ // use MediaWiki's 'fallback' skin for skin-specific decisions.
+ $this->skin = self::DEFAULT_SKIN;
}
}
}
/**
+ * @deprecated since 1.34 Use ResourceLoaderModule::getConfig instead
+ * inside module methods. Use ResourceLoader::getConfig elsewhere.
* @return Config
*/
public function getConfig() {
}
/**
+ * @deprecated since 1.34 Use ResourceLoaderModule::getLogger instead
+ * inside module methods. Use ResourceLoader::getLogger elsewhere.
* @since 1.27
* @return \Psr\Log\LoggerInterface
*/
$lang = $this->getRequest()->getRawVal( 'lang', '' );
// Stricter version of RequestContext::sanitizeLangCode()
if ( !Language::isValidBuiltInCode( $lang ) ) {
- $lang = $this->getConfig()->get( 'LanguageCode' );
+ // The 'lang' parameter is required. (Not yet enforced.)
+ // If omitted, localise with the dummy language code.
+ $lang = self::DEFAULT_LANG;
}
$this->language = $lang;
}
*/
public function getDirection() {
if ( $this->direction === null ) {
- $this->direction = $this->getRequest()->getRawVal( 'dir' );
- if ( !$this->direction ) {
+ $direction = $this->getRequest()->getRawVal( 'dir' );
+ if ( $direction === 'ltr' || $direction === 'rtl' ) {
+ $this->direction = $direction;
+ } else {
// Determine directionality based on user language (T8100)
$this->direction = Language::factory( $this->getLanguage() )->getDir();
}
}
return $this->hash;
}
+
+ /**
+ * Get the request base parameters, omitting any defaults.
+ *
+ * @internal For internal use by ResourceLoaderStartUpModule only
+ * @return array
+ */
+ public function getReqBase() {
+ $reqBase = [];
+ if ( $this->getLanguage() !== self::DEFAULT_LANG ) {
+ $reqBase['lang'] = $this->getLanguage();
+ }
+ if ( $this->getSkin() !== self::DEFAULT_SKIN ) {
+ $reqBase['skin'] = $this->getSkin();
+ }
+ if ( $this->getDebug() ) {
+ $reqBase['debug'] = 'true';
+ }
+ return $reqBase;
+ }
}