configuration in LocalSettings.php.
* HTMLForm::setSubmitProgressive() is deprecated. No need to call it. Submit
button is already marked as progressive.
+* Skin::setupSkinUserCss() is deprecated. Adding of modules to load
+ has been centralised to Skin::getDefaultModules(), which is now capable
+ of queueing style modules as well.
=== Other changes in 1.32 ===
* …
global $wgStyleDirectory;
$moduleNames = [
- // See SkinTemplate::setupSkinUserCss
+ // Based on Skin::getDefaultModules
'mediawiki.legacy.shared',
- // See Vector::setupSkinUserCss
+ // Based on Vector::setupSkinUserCss
'mediawiki.skinning.interface',
];
public function getDefaultModules() {
$out = $this->getOutput();
$config = $this->getConfig();
- $user = $out->getUser();
+ $user = $this->getUser();
+
+ // Modules declared in the $modules literal are loaded
+ // for ALL users, on ALL pages, in ALL skins.
+ // Keep this list as small as possible!
$modules = [
- // Styles key sets render blocking styles
- // Unlike other keys in this definition it is an associative array
- // where each key is the group name and points to a list of modules
'styles' => [
+ // The 'styles' key sets render-blocking style modules
+ // Unlike other keys in $modules, this is an associative array
+ // where each key is its own group pointing to a list of modules
+ 'core' => [
+ 'mediawiki.legacy.shared',
+ 'mediawiki.legacy.commonPrint',
+ ],
'content' => [],
+ 'syndicate' => [],
],
- // modules not specific to any specific skin or page
'core' => [
- // Enforce various default modules for all pages and all skins
- // Keep this list as small as possible
'site',
'mediawiki.page.startup',
'mediawiki.user',
],
- // modules that enhance the page content in some way
+ // modules that enhance the content in some way
'content' => [
'mediawiki.page.ready',
],
'watch' => [],
// modules which relate to the current users preferences
'user' => [],
+ // modules relating to RSS/Atom Feeds
+ 'syndicate' => [],
];
// Support for high-density display images if enabled
$modules['styles']['content'][] = 'jquery.makeCollapsible.styles';
}
+ // Deprecated since 1.26: Unconditional loading of mediawiki.ui.button
+ // on every page is deprecated. Express a dependency instead.
+ if ( strpos( $out->getHTML(), 'mw-ui-button' ) !== false ) {
+ $modules['styles']['content'][] = 'mediawiki.ui.button';
+ }
+
if ( $out->isTOCEnabled() ) {
$modules['content'][] = 'mediawiki.toc';
}
if ( $out->isArticle() && $user->getOption( 'editondblclick' ) ) {
$modules['user'][] = 'mediawiki.action.view.dblClickEdit';
}
+
+ if ( $out->isSyndicated() ) {
+ $modules['styles']['syndicate'][] = 'mediawiki.feedlink';
+ }
+
return $modules;
}
}
/**
- * Add skin specific stylesheets
- * Calling this method with an $out of anything but the same OutputPage
- * inside ->getOutput() is deprecated. The $out arg is kept
- * for compatibility purposes with skins.
- * @param OutputPage $out
- * @todo delete
+ * Hook point for adding style modules to OutputPage.
+ *
+ * @deprecated since 1.32 Use getDefaultModules() instead.
+ * @param OutputPage $out Legacy parameter, identical to $this->getOutput()
*/
- abstract function setupSkinUserCss( OutputPage $out );
+ public function setupSkinUserCss( OutputPage $out ) {
+ // Stub.
+ }
/**
* TODO: document
public $username;
public $userpageUrlDetails;
- /**
- * Add specific styles for this skin
- *
- * @param OutputPage $out
- */
- public function setupSkinUserCss( OutputPage $out ) {
- $moduleStyles = [
- 'mediawiki.legacy.shared',
- 'mediawiki.legacy.commonPrint',
- ];
- if ( $out->isSyndicated() ) {
- $moduleStyles[] = 'mediawiki.feedlink';
- }
-
- // Deprecated since 1.26: Unconditional loading of mediawiki.ui.button
- // on every page is deprecated. Express a dependency instead.
- if ( strpos( $out->getHTML(), 'mw-ui-button' ) !== false ) {
- $moduleStyles[] = 'mediawiki.ui.button';
- }
-
- $out->addModuleStyles( $moduleStyles );
- }
-
/**
* Create the template engine object; we feed it a bunch of data
* and eventually it spits out some HTML. Should have interface
$mock->expects( $this->once() )
->method( 'isSyndicated' )
->will( $this->returnValue( $isSyndicated ) );
- $mock->expects( $this->once() )
+ $mock->expects( $this->any() )
->method( 'getHTML' )
->will( $this->returnValue( $html ) );
return $mock;
}
- public function provideSetupSkinUserCss() {
+ public function provideGetDefaultModules() {
$defaultStyles = [
'mediawiki.legacy.shared',
'mediawiki.legacy.commonPrint',
$feedStyle = 'mediawiki.feedlink';
return [
[
- $this->getMockOutputPage( false, '' ),
+ false,
+ '',
$defaultStyles
],
[
- $this->getMockOutputPage( true, '' ),
+ true,
+ '',
array_merge( $defaultStyles, [ $feedStyle ] )
],
[
- $this->getMockOutputPage( false, 'FOO mw-ui-button BAR' ),
+ false,
+ 'FOO mw-ui-button BAR',
array_merge( $defaultStyles, [ $buttonStyle ] )
],
[
- $this->getMockOutputPage( true, 'FOO mw-ui-button BAR' ),
- array_merge( $defaultStyles, [ $feedStyle, $buttonStyle ] )
+ true,
+ 'FOO mw-ui-button BAR',
+ array_merge( $defaultStyles, [ $buttonStyle, $feedStyle ] )
],
];
}
/**
- * @param PHPUnit_Framework_MockObject_MockObject|OutputPage $outputPageMock
- * @param string[] $expectedModuleStyles
- *
- * @covers SkinTemplate::setupSkinUserCss
- * @dataProvider provideSetupSkinUserCss
+ * @covers Skin::getDefaultModules
+ * @dataProvider provideGetDefaultModules
*/
- public function testSetupSkinUserCss( $outputPageMock, $expectedModuleStyles ) {
- $outputPageMock->expects( $this->once() )
- ->method( 'addModuleStyles' )
- ->with( $expectedModuleStyles );
+ public function testgetDefaultModules( $isSyndicated, $html, $expectedModuleStyles ) {
+ $skin = new SkinTemplate();
- $skinTemplate = new SkinTemplate();
- $skinTemplate->setupSkinUserCss( $outputPageMock );
+ $context = new DerivativeContext( $skin->getContext() );
+ $context->setOutput( $this->getMockOutputPage( $isSyndicated, $html ) );
+ $skin->setContext( $context );
+
+ $modules = $skin->getDefaultModules();
+
+ $actualStylesModule = call_user_func_array( 'array_merge', $modules['styles'] );
+ $this->assertArraySubset(
+ $expectedModuleStyles,
+ $actualStylesModule,
+ 'style modules'
+ );
}
}