resourceloader: Introduce hooks in ResourceLoaderSiteModule

This will allow extensions/skins to alter the wiki pages that editors
can use to control styles

Bug: T237050
Change-Id: I329415b787136fcf9422a9deebfcd34f83b40f12
This commit is contained in:
jdlrobson 2019-10-31 12:51:16 -07:00 committed by Krinkle
parent 7b49e17eff
commit 5b044bb928
4 changed files with 16 additions and 3 deletions

View file

@ -76,6 +76,8 @@ For notes on 1.34.x and older releases, see HISTORY.
getRobotPolicy() returns the entire policy as a string in the form
<index policy>,<follow policy> while getIndexPolicy() and getFollowPolicy()
return their respective policies as a string.
* The ResourceLoaderSiteModulePages and ResourceLoaderSiteStylesModulePages
hooks were added to allow changing which wiki pages these modules contain.
* …
=== External library changes in 1.35 ===

View file

@ -3049,6 +3049,14 @@ $type: 'normal' or 'history' for old/diff views
message must be in HTML format, not wikitext!
&$link: overridable HTML link to be passed into the message as $1
'ResourceLoaderSiteModulePages': Modify list of pages for a given skin
$skin: string of the current skin key
&$pages: array of pages and their types.
'ResourceLoaderSiteStylesModulePages': Modify list of pages for a given skin
$skin: string of the current skin key
&$pages: array of pages and their types.
'SkinEditSectionLinks': Modify the section edit links
$skin: Skin object rendering the UI
$title: Title object for the title being linked to (may not be the same as

View file

@ -37,8 +37,10 @@ class ResourceLoaderSiteModule extends ResourceLoaderWikiModule {
protected function getPages( ResourceLoaderContext $context ) {
$pages = [];
if ( $this->getConfig()->get( 'UseSiteJs' ) ) {
$skin = $context->getSkin();
$pages['MediaWiki:Common.js'] = [ 'type' => 'script' ];
$pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.js'] = [ 'type' => 'script' ];
$pages['MediaWiki:' . ucfirst( $skin ) . '.js'] = [ 'type' => 'script' ];
Hooks::run( 'ResourceLoaderSiteModulePages', [ $skin, &$pages ] );
}
return $pages;
}

View file

@ -37,10 +37,11 @@ class ResourceLoaderSiteStylesModule extends ResourceLoaderWikiModule {
protected function getPages( ResourceLoaderContext $context ) {
$pages = [];
if ( $this->getConfig()->get( 'UseSiteCss' ) ) {
$skin = $context->getSkin();
$pages['MediaWiki:Common.css'] = [ 'type' => 'style' ];
$pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.css'] = [ 'type' => 'style' ];
$pages['MediaWiki:' . ucfirst( $skin ) . '.css'] = [ 'type' => 'style' ];
$pages['MediaWiki:Print.css'] = [ 'type' => 'style', 'media' => 'print' ];
Hooks::run( 'ResourceLoaderSiteStylesModulePages', [ $skin, &$pages ] );
}
return $pages;
}