X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fskins%2FSkin.php;h=b8cd921b8d55394d1c45b978fb9748045552dd6b;hb=68527cf47935a0350d3f0a153bd06cbb98062ec8;hp=f3276e87ec6e98cf1429c3537e590751fc5f5050;hpb=c9f07af946fc143023a937ec6933ddca77ab1607;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index f3276e87ec..b8cd921b8d 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -166,24 +166,37 @@ abstract class Skin extends ContextSource { * It is recommended that skins wishing to override call parent::getDefaultModules() * and substitute out any modules they wish to change by using a key to look them up * - * For style modules, use setupSkinUserCss() instead. + * Any modules defined with the 'styles' key will be added as render blocking CSS via + * Output::addModuleStyles. Similarly, each key should refer to a list of modules * * @return array Array of modules with helper keys for easy overriding */ 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 = [ - // modules not specific to any specific skin or page + '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' => [], + ], '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', ], @@ -193,6 +206,8 @@ abstract class Skin extends ContextSource { '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 @@ -203,15 +218,24 @@ abstract class Skin extends ContextSource { // Preload jquery.tablesorter for mediawiki.page.ready if ( strpos( $out->getHTML(), 'sortable' ) !== false ) { $modules['content'][] = 'jquery.tablesorter'; + $modules['styles']['content'][] = 'jquery.tablesorter.styles'; } // Preload jquery.makeCollapsible for mediawiki.page.ready if ( strpos( $out->getHTML(), 'mw-collapsible' ) !== false ) { $modules['content'][] = 'jquery.makeCollapsible'; + $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'; + $modules['styles']['content'][] = 'mediawiki.toc.styles'; } // Add various resources if required @@ -232,6 +256,11 @@ abstract class Skin extends ContextSource { if ( $out->isArticle() && $user->getOption( 'editondblclick' ) ) { $modules['user'][] = 'mediawiki.action.view.dblClickEdit'; } + + if ( $out->isSyndicated() ) { + $modules['styles']['syndicate'][] = 'mediawiki.feedlink'; + } + return $modules; } @@ -403,14 +432,14 @@ abstract class Skin extends ContextSource { } /** - * 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