User:Mainframe98/Snippets
MediaWiki PHP Code snippets for reuse.
Notification
editShown on Special:Preferences, see the class for that special page.
$out->addModuleStyles( 'mediawiki.notification.convertmessagebox.styles' );
$out->addHTML(
Html::rawElement(
'div',
[
'class' => 'mw-preferences-messagebox mw-notify-success successbox',
'id' => 'mw-preferences-success',
'data-mw-autohide' => 'false',
],
html::element( 'p', [], $this->msg( 'savedprefs' )->text() )
)
);
Getting the OOUI Theme of a skin
edit // This is a somewhat convoluted way. Ideally there should be a $skin->getOOUITheme() or similar
$skinName = $this->getOutput()->getSkin()->getSkinName();
$themes = \ResourceLoaderOOUIModule::getSkinThemeMap();
$theme = isset( $themes[$skinName] ) ? $themes[$skinName] : $themes['default'];