X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=e78cd7bd124d0cdf32085134dc9d29ed0462e1a4;hb=383460afa3b78e46a6711da73ba7258652a10a7f;hp=6c49696a2b1829903d420a7557692213a6c1a5ad;hpb=97db167a0ae539d7bb9c9d4ca51b2aaaf78f1853;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6c49696a2b..e78cd7bd12 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -29,9 +29,9 @@ use Wikimedia\WrappedString; use Wikimedia\WrappedStringList; /** - * This class should be covered by a general architecture document which does - * not exist as of January 2011. This is one of the Core classes and should - * be read at least once by any new developers. + * This is one of the Core classes and should + * be read at least once by any new developers. Also documented at + * https://www.mediawiki.org/wiki/Manual:Architectural_modules/OutputPage * * This class is used to prepare the final rendering. A skin is then * applied to the output parameters (links, javascript, html, categories ...). @@ -459,13 +459,6 @@ class OutputPage extends ContextSource { * @param string|null $unused Previously used to change the cache-busting query parameter */ public function addScriptFile( $file, $unused = null ) { - if ( substr( $file, 0, 1 ) !== '/' && !preg_match( '#^[a-z]*://#i', $file ) ) { - // This is not an absolute path, protocol-relative url, or full scheme url, - // presumed to be an old call intended to include a file from /w/skins/common, - // which doesn't exist anymore as of MediaWiki 1.24 per T71277. Ignore. - wfDeprecated( __METHOD__, '1.24' ); - return; - } $this->addScript( Html::linkedScript( $file, $this->getCSPNonce() ) ); } @@ -2278,7 +2271,7 @@ class OutputPage extends ContextSource { } /** - * T23672: Add Accept-Language to Vary and Key headers if there's no 'variant' parameter in GET. + * T23672: Add Accept-Language to Vary header if there's no 'variant' parameter in GET. * * For example: * /w/index.php?title=Main_page will vary based on Accept-Language; but @@ -3019,6 +3012,7 @@ class OutputPage extends ContextSource { * @return string The doctype, opening "", and head element. */ public function headElement( Skin $sk, $includeStyle = true ) { + $config = $this->getConfig(); $userdir = $this->getLanguage()->getDir(); $sitedir = MediaWikiServices::getInstance()->getContentLanguage()->getDir(); @@ -3033,7 +3027,7 @@ class OutputPage extends ContextSource { $this->setHTMLTitle( $this->msg( 'pagetitle', $this->getPageTitle() )->inContentLanguage() ); } - if ( !Html::isXmlMimeType( $this->getConfig()->get( 'MimeType' ) ) ) { + if ( !Html::isXmlMimeType( $config->get( 'MimeType' ) ) ) { // Add // This should be before since it defines the charset used by // text including the text inside <title>. @@ -3051,18 +3045,15 @@ class OutputPage extends ContextSource { $pieces = array_merge( $pieces, array_values( $this->getHeadLinksArray() ) ); $pieces = array_merge( $pieces, array_values( $this->mHeadItems ) ); + // This library is intended to run on older browsers that MediaWiki no longer + // supports as Grade A. For these Grade C browsers, we provide an experience + // using only HTML and CSS. Where standards-compliant browsers are able to style + // unknown HTML elements without issue, old IE ignores these styles. + // The html5shiv library fixes that. // Use an IE conditional comment to serve the script only to old IE + $shivUrl = $config->get( 'ResourceBasePath' ) . '/resources/lib/html5shiv/html5shiv.js'; $pieces[] = '<!--[if lt IE 9]>' . - ResourceLoaderClientHtml::makeLoad( - new ResourceLoaderContext( - $this->getResourceLoader(), - new FauxRequest( [] ) - ), - [ 'html5shiv' ], - ResourceLoaderModule::TYPE_SCRIPTS, - [ 'raw' => '1', 'sync' => '1' ], - $this->getCSPNonce() - ) . + Html::linkedScript( $shivUrl, $this->getCSPNonce() ) . '<![endif]-->'; $pieces[] = Html::closeElement( 'head' ); @@ -3719,43 +3710,54 @@ class OutputPage extends ContextSource { */ protected function buildExemptModules() { $chunks = []; - // Things that go after the ResourceLoaderDynamicStyles marker - $append = []; - // We want site, private and user styles to override dynamically added styles from - // general modules, but we want dynamically added styles to override statically added - // style modules. So the order has to be: - // - page style modules (formatted by ResourceLoaderClientHtml::getHeadHtml()) - // - dynamically loaded styles (added by mw.loader before ResourceLoaderDynamicStyles) - // - ResourceLoaderDynamicStyles marker - // - site/private/user styles + // Requirements: + // - Within modules provided by the software (core, skin, extensions), + // styles from skin stylesheets should be overridden by styles + // from modules dynamically loaded with JavaScript. + // - Styles from site-specific, private, and user modules should override + // both of the above. + // + // The effective order for stylesheets must thus be: + // 1. Page style modules, formatted server-side by ResourceLoaderClientHtml. + // 2. Dynamically-loaded styles, inserted client-side by mw.loader. + // 3. Styles that are site-specific, private or from the user, formatted + // server-side by this function. + // + // The 'ResourceLoaderDynamicStyles' marker helps JavaScript know where + // point #2 is. // Add legacy styles added through addStyle()/addInlineStyle() here $chunks[] = implode( '', $this->buildCssLinksArray() ) . $this->mInlineStyles; - $chunks[] = Html::element( - 'meta', - [ 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ] - ); - + // Things that go after the ResourceLoaderDynamicStyles marker + $append = []; $separateReq = [ 'site.styles', 'user.styles' ]; foreach ( $this->rlExemptStyleModules as $group => $moduleNames ) { - // Combinable modules - $chunks[] = $this->makeResourceLoaderLink( - array_diff( $moduleNames, $separateReq ), - ResourceLoaderModule::TYPE_STYLES - ); - - foreach ( array_intersect( $moduleNames, $separateReq ) as $name ) { - // These require their own dedicated request in order to support "@import" - // syntax, which is incompatible with concatenation. (T147667, T37562) - $chunks[] = $this->makeResourceLoaderLink( $name, + if ( $moduleNames ) { + $append[] = $this->makeResourceLoaderLink( + array_diff( $moduleNames, $separateReq ), ResourceLoaderModule::TYPE_STYLES ); + + foreach ( array_intersect( $moduleNames, $separateReq ) as $name ) { + // These require their own dedicated request in order to support "@import" + // syntax, which is incompatible with concatenation. (T147667, T37562) + $append[] = $this->makeResourceLoaderLink( $name, + ResourceLoaderModule::TYPE_STYLES + ); + } } } + if ( $append ) { + $chunks[] = Html::element( + 'meta', + [ 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ] + ); + $chunks = array_merge( $chunks, $append ); + } - return self::combineWrappedStrings( array_merge( $chunks, $append ) ); + return self::combineWrappedStrings( $chunks ); } /** @@ -3992,13 +3994,6 @@ class OutputPage extends ContextSource { if ( is_array( $spec ) ) { $args = $spec; $name = array_shift( $args ); - if ( isset( $args['options'] ) ) { - unset( $args['options'] ); - wfDeprecated( - 'Adding "options" to ' . __METHOD__ . ' is no longer supported', - '1.20' - ); - } } else { $args = []; $name = $spec; @@ -4047,7 +4042,6 @@ class OutputPage extends ContextSource { $this->addModuleStyles( [ 'oojs-ui-core.styles', 'oojs-ui.styles.indicators', - 'oojs-ui.styles.textures', 'mediawiki.widgets.styles', 'oojs-ui-core.icons', ] );