Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 21 additions & 26 deletions src/HooksHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use MediaWiki\Hook\ParserFirstCallInitHook;
use MediaWiki\Hook\SetupAfterCacheHook;
use MediaWiki\MediaWikiServices;
use \Parser;
use Parser;
// TODO switch to then when dropping support for mw < 1.40
// use MediaWiki\Parser\Parser;
use SMW\Utils\File;
Expand Down Expand Up @@ -83,8 +83,7 @@ public function __construct(
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ScribuntoExternalLibraries
*/
public static function onScribuntoExternalLibraries( $engine, array &$extraLibraries ): bool
{
public static function onScribuntoExternalLibraries( $engine, array &$extraLibraries ): bool {
if ( $engine == 'lua' ) {
$extraLibraries['mw.bootstrap'] = LuaLibrary::class;
}
Expand All @@ -101,12 +100,11 @@ public static function onScribuntoExternalLibraries( $engine, array &$extraLibra
*
* @codeCoverageIgnore trivial
*
* @param array $modeArray
* @param array &$modeArray
* @return bool
*/

public function onGalleryGetModes( &$modeArray ): bool
{
public function onGalleryGetModes( &$modeArray ): bool {
if (
$this->getConfig()->has( 'BootstrapComponentsEnableCarouselGalleryMode' )
&& $this->getConfig()->get( 'BootstrapComponentsEnableCarouselGalleryMode' )
Expand All @@ -125,24 +123,23 @@ public function onGalleryGetModes( &$modeArray ): bool
*
* @codeCoverageIgnore trivial
*
* @param $linker, always null (was \DummyLinker $linker)
* @param \Title $title
* @param File|\LocalFile $file
* @param array $frameParams
* @param array $handlerParams
* @param bool|string $time
* @param null|string $res
* @param $linker always null (was \DummyLinker $linker)
* @param \Title &$title
* @param File|\LocalFile &$file
* @param array &$frameParams
* @param array &$handlerParams
* @param bool|string &$time
* @param null|string &$res
* @param Parser $parser
* @param string $query
* @param null|int $widthOption
* @param string &$query
* @param null|int &$widthOption
* @throws \MWException
*/
public function onImageBeforeProduceHTML(
$linker, &$title, &$file, &$frameParams, &$handlerParams, &$time, &$res, $parser, &$query, &$widthOption
): bool {
if ( $this->getConfig()->has( 'BootstrapComponentsModalReplaceImageTag' ) &&
$this->getConfig()->get( 'BootstrapComponentsModalReplaceImageTag' ) )
{
$this->getConfig()->get( 'BootstrapComponentsModalReplaceImageTag' ) ) {
$imageModal = new ImageModal( $linker, $title, $file,
$this->getNestingController(), $this->getBootstrapComponentsService()
);
Expand All @@ -167,7 +164,7 @@ public function onImageBeforeProduceHTML(
* @codeCoverageIgnore trivial
*
* @param Parser $parser
* @param string $text
* @param string &$text
* @param StripState $stripState
* @return bool
*/
Expand All @@ -179,7 +176,6 @@ public function onInternalParseBeforeLinks( $parser, &$text, $stripState ): bool
return true;
}


/**
* Hook: OutputPageParserOutput
*
Expand Down Expand Up @@ -212,24 +208,23 @@ public function onOutputPageParserOutput( $outputPage, $parserOutput ): void {
* @codeCoverageIgnore trivial
*
* @param Parser $parser
* @param string $text
* @param string &$text
* @param StripState $stripState
* @return bool
*/
public function onParserAfterParse( $parser, &$text, $stripState ): bool {

// once, this was only loaded, when a component was paced on the page. now, we load it always
// to keep the layout of all the wiki pages consistent.
$parser->getOutput()->addModuleStyles( ['ext.bootstrapComponents.bootstrap.fix'] );
$parser->getOutput()->addModuleStyles( ['ext.bootstrap.styles'] );
$parser->getOutput()->addModules( ['ext.bootstrap.scripts'] );
$parser->getOutput()->addModuleStyles( [ 'ext.bootstrapComponents.bootstrap.fix' ] );
$parser->getOutput()->addModuleStyles( [ 'ext.bootstrap.styles' ] );
$parser->getOutput()->addModules( [ 'ext.bootstrap.scripts' ] );
$skin = $this->getBootstrapComponentsService()->getNameOfActiveSkin();
foreach ( $this->getBootstrapComponentsService()->getActiveComponents() as $activeComponent ) {
if ( !$this->getComponentLibrary()->isRegistered( $activeComponent ) ) {
continue;
}
foreach ( $this->getComponentLibrary()->getModulesFor( $activeComponent ) as $module ) {
$parser->getOutput()->addModuleStyles( $module, $skin );
$parser->getOutput()->addModuleStyles( [ $module ] );
}
}
return true;
Expand Down Expand Up @@ -287,7 +282,7 @@ protected function getComponentLibrary(): ComponentLibrary {
*/
protected function getConfig(): Config {
if ( !isset( $this->config ) ) {
$this->config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig('BootstrapComponents');
$this->config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'BootstrapComponents' );
}
return $this->config;
}
Expand Down
Loading