Merge "(bug 37755) Set robot meta tags for 'view source' pages"
[lhc/web/wiklou.git] / includes / OutputPage.php
index f0fd067..7649b23 100644 (file)
@@ -611,7 +611,7 @@ class OutputPage extends ContextSource {
 
        /**
         * checkLastModified tells the client to use the client-cached page if
-        * possible. If sucessful, the OutputPage is disabled so that
+        * possible. If successful, the OutputPage is disabled so that
         * any future call to OutputPage->output() have no effect.
         *
         * Side effect: sets mLastModified for Last-Modified header
@@ -1469,7 +1469,7 @@ class OutputPage extends ContextSource {
         * @param $interface Boolean: whether it is an interface message
         *                                                              (for example disables conversion)
         */
-       public function addWikiTextTitle( $text, &$title, $linestart, $tidy = false, $interface = false ) {
+       public function addWikiTextTitle( $text, Title $title, $linestart, $tidy = false, $interface = false ) {
                global $wgParser;
 
                wfProfileIn( __METHOD__ );
@@ -1570,9 +1570,10 @@ class OutputPage extends ContextSource {
         * @param $interface Boolean: use interface language ($wgLang instead of
         *                   $wgContLang) while parsing language sensitive magic
         *                   words like GRAMMAR and PLURAL. This also disables
-        *                                       LanguageConverter.
+        *                   LanguageConverter.
         * @param $language  Language object: target language object, will override
         *                   $interface
+        * @throws MWException
         * @return String: HTML
         */
        public function parse( $text, $linestart = true, $interface = false, $language = null ) {
@@ -1768,14 +1769,12 @@ class OutputPage extends ContextSource {
                                } else {
                                        $aloption[] = 'string-contains=' . $variant;
 
-                                       // IE and some other browsers use another form of language code
-                                       // in their Accept-Language header, like "zh-CN" or "zh-TW".
+                                       // IE and some other browsers use BCP 47 standards in
+                                       // their Accept-Language header, like "zh-CN" or "zh-Hant".
                                        // We should handle these too.
-                                       $ievariant = explode( '-', $variant );
-                                       if ( count( $ievariant ) == 2 ) {
-                                               $ievariant[1] = strtoupper( $ievariant[1] );
-                                               $ievariant = implode( '-', $ievariant );
-                                               $aloption[] = 'string-contains=' . $ievariant;
+                                       $variantBCP47 = wfBCP47( $variant );
+                                       if ( $variantBCP47 !== $variant ) {
+                                               $aloption[] = 'string-contains=' . $variantBCP47;
                                        }
                                }
                        }
@@ -2155,6 +2154,7 @@ class OutputPage extends ContextSource {
         * Display an error page noting that a given permission bit is required.
         * @deprecated since 1.18, just throw the exception directly
         * @param $permission String: key required
+        * @throws PermissionsError
         */
        public function permissionRequired( $permission ) {
                throw new PermissionsError( $permission );
@@ -2225,6 +2225,7 @@ class OutputPage extends ContextSource {
         * @param $protected Boolean: is this a permissions error?
         * @param $reasons   Array: list of reasons for this error, as returned by Title::getUserPermissionsErrors().
         * @param $action    String: action that was denied or null if unknown
+        * @throws ReadOnlyError
         */
        public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
                $this->setRobotPolicy( 'noindex,nofollow' );
@@ -2459,7 +2460,7 @@ $templates
         */
        private function addDefaultModules() {
                global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
-                       $wgAjaxWatch;
+                       $wgAjaxWatch, $wgResponsiveImages;
 
                // Add base resources
                $this->addModules( array(
@@ -2500,6 +2501,11 @@ $templates
                if ( $this->isArticle() && $this->getUser()->getOption( 'editondblclick' ) ) {
                        $this->addModules( 'mediawiki.action.view.dblClickEdit' );
                }
+
+               // Support for high-density display images
+               if ( $wgResponsiveImages ) {
+                       $this->addModules( 'mediawiki.hidpi' );
+               }
        }
 
        /**
@@ -2912,7 +2918,7 @@ $templates
         * @return array
         */
        public function getJSVars() {
-               global $wgUseAjax, $wgContLang;
+               global $wgContLang;
 
                $latestRevID = 0;
                $pageID = 0;
@@ -2974,7 +2980,7 @@ $templates
                );
                if ( $wgContLang->hasVariants() ) {
                        $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
-               }
+               }
                foreach ( $title->getRestrictionTypes() as $type ) {
                        $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
                }
@@ -3565,7 +3571,6 @@ $templates
                $msgSpecs = array_values( $msgSpecs );
                $s = $wrap;
                foreach ( $msgSpecs as $n => $spec ) {
-                       $options = array();
                        if ( is_array( $spec ) ) {
                                $args = $spec;
                                $name = array_shift( $args );