X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=b63e658ddddd8da9e1d1e6f0a5d18683aaced755;hb=5755a74aa63fef10a6cf785f34176681e139499f;hp=65800dd49cb6259e23c4f4a070d6724623371340;hpb=8e7150b5497bc2308da99ca07f4d3c0c89ec8e21;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 65800dd49c..b63e658ddd 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1296,7 +1296,6 @@ class OutputPage extends ContextSource { * Return whether user JavaScript is allowed for this page * @deprecated since 1.18 Load modules with ResourceLoader, and origin and * trustworthiness is identified and enforced automagically. - * Will be removed in 1.20. * @return Boolean */ public function isUserJsAllowed() { @@ -2050,7 +2049,7 @@ class OutputPage extends ContextSource { } if ( $this->mArticleBodyOnly ) { - $this->out( $this->mBodytext ); + echo $this->mBodytext; } else { $this->addDefaultModules(); @@ -2076,11 +2075,13 @@ class OutputPage extends ContextSource { } /** - * Actually output something with print(). + * Actually output something with print. * * @param string $ins the string to output + * @deprecated since 1.20 Use echo yourself. */ public function out( $ins ) { + wfDeprecated( __METHOD__, '1.22' ); print $ins; } @@ -2475,7 +2476,7 @@ $templates * @return String: The doctype, opening "", and head element. */ public function headElement( Skin $sk, $includeStyle = true ) { - global $wgContLang; + global $wgContLang, $wgMimeType; $userdir = $this->getLanguage()->getDir(); $sitedir = $wgContLang->getDir(); @@ -2496,10 +2497,22 @@ $templates $ret .= "$openHead\n"; } + if ( !Html::isXmlMimeType( $wgMimeType ) ) { + // Add + // This should be before since it defines the charset used by + // text including the text inside <title>. + // The spec recommends defining XHTML5's charset using the XML declaration + // instead of meta. + // Our XML declaration is output by Html::htmlHeader. + // http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-meta-http-equiv-content-type + // http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#charset + $ret .= Html::element( 'meta', array( 'charset' => 'UTF-8' ) ); + } + $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n"; $ret .= implode( "\n", array( - $this->getHeadLinks( null, true ), + $this->getHeadLinks(), $this->buildCssLinks(), $this->getHeadScripts(), $this->getHeadItems() @@ -2510,20 +2523,29 @@ $templates $ret .= "$closeHead\n"; } - $bodyAttrs = array(); + $bodyClasses = array(); + $bodyClasses[] = 'mediawiki'; # Classes for LTR/RTL directionality support - $bodyAttrs['class'] = "mediawiki $userdir sitedir-$sitedir"; + $bodyClasses[] = $userdir; + $bodyClasses[] = "sitedir-$sitedir"; if ( $this->getLanguage()->capitalizeAllNouns() ) { # A <body> class is probably not the best way to do this . . . - $bodyAttrs['class'] .= ' capitalize-all-nouns'; + $bodyClasses[] = 'capitalize-all-nouns'; } - $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() ); - $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $sk->getSkinName() ); - $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); - $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need + $bodyClasses[] = $sk->getPageClasses( $this->getTitle() ); + $bodyClasses[] = 'skin-' . Sanitizer::escapeClass( $sk->getSkinName() ); + $bodyClasses[] = 'action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); + + $bodyAttrs = array(); + // While the implode() is not strictly needed, it's used for backwards compatibility + // (this used to be built as a string and hooks likely still expect that). + $bodyAttrs['class'] = implode( ' ', $bodyClasses ); + + // Allow skins and extensions to add body attributes they need + $sk->addToBodyAttributes( $this, $bodyAttrs ); wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) ); $ret .= Html::openElement( 'body', $bodyAttrs ) . "\n"; @@ -2954,11 +2976,18 @@ $templates */ function getBottomScripts() { global $wgResourceLoaderExperimentalAsyncLoading; + + // Optimise jQuery ready event cross-browser. + // This also enforces $.isReady to be true at </body> which fixes the + // mw.loader bug in Firefox with using document.write between </body> + // and the DOMContentReady event (bug 47457). + $html = Html::inlineScript( 'window.jQuery && jQuery.ready();' ); + if ( !$wgResourceLoaderExperimentalAsyncLoading ) { - return $this->getScriptsForBottomQueue( false ); - } else { - return ''; + $html .= $this->getScriptsForBottomQueue( false ); } + + return $html; } /** @@ -3046,6 +3075,7 @@ $templates 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', 'wgPageContentLanguage' => $lang->getCode(), + 'wgPageContentModel' => $title->getContentModel(), 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgDefaultDateFormat' => $lang->getDefaultDateFormat(), @@ -3058,6 +3088,10 @@ $templates $vars['wgUserEditCount'] = $user->getEditCount(); $userReg = wfTimestampOrNull( TS_UNIX, $user->getRegistration() ); $vars['wgUserRegistration'] = $userReg !== null ? ( $userReg * 1000 ) : null; + // Get the revision ID of the oldest new message on the user's talk + // page. This can be used for constructing new message alerts on + // the client side. + $vars['wgUserNewMsgRevisionId'] = $user->getNewMessageRevisionId(); } if ( $wgContLang->hasVariants() ) { $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); @@ -3107,13 +3141,11 @@ $templates } /** - * @param bool $addContentType Whether "<meta>" specifying content type should be returned - * * @return array in format "link name or number => 'link html'". */ - public function getHeadLinksArray( $addContentType = false ) { + public function getHeadLinksArray() { global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, - $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, + $wgSitename, $wgVersion, $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgRightsPage, $wgRightsUrl; @@ -3122,23 +3154,6 @@ $templates $canonicalUrl = $this->mCanonicalUrl; - if ( $addContentType ) { - if ( $wgHtml5 ) { - # More succinct than <meta http-equiv=Content-Type>, has the - # same effect - $tags['meta-charset'] = Html::element( 'meta', array( 'charset' => 'UTF-8' ) ); - } else { - $tags['meta-content-type'] = Html::element( 'meta', array( - 'http-equiv' => 'Content-Type', - 'content' => "$wgMimeType; charset=UTF-8" - ) ); - $tags['meta-content-style-type'] = Html::element( 'meta', array( // bug 15835 - 'http-equiv' => 'Content-Style-Type', - 'content' => 'text/css' - ) ); - } - } - $tags['meta-generator'] = Html::element( 'meta', array( 'name' => 'generator', 'content' => "MediaWiki $wgVersion", @@ -3356,13 +3371,10 @@ $templates } /** - * @param $unused - * @param bool $addContentType Whether "<meta>" specifying content type should be returned - * * @return string HTML tag links to be put in the header. */ - public function getHeadLinks( $unused = null, $addContentType = false ) { - return implode( "\n", $this->getHeadLinksArray( $addContentType ) ); + public function getHeadLinks() { + return implode( "\n", $this->getHeadLinksArray() ); } /**