Follow up r64936. Even better, provide the bug number and imagemagick doc page.
[lhc/web/wiklou.git] / includes / OutputPage.php
index 702a9f5..802740e 100644 (file)
@@ -364,6 +364,16 @@ class OutputPage {
                return true;
        }
 
+       /**
+        * Override the last modified timestamp
+        *
+        * @param $timestamp String: new timestamp, in a format readable by
+        *        wfTimestamp()
+        */
+       public function setLastModified( $timestamp ) {
+               $this->mLastModified = wfTimestamp( TS_RFC2822, $timestamp );
+       }
+
 
        /**
         * Set the robot policy for the page: <http://www.robotstxt.org/meta.html>
@@ -435,7 +445,8 @@ class OutputPage {
        }
 
        /**
-        * "HTML title" means the contents of <title>. It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file.
+        * "HTML title" means the contents of <title>.
+        * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file.
         */
        public function setHTMLTitle( $name ) {
                $this->mHTMLtitle = $name;
@@ -1085,11 +1096,6 @@ class OutputPage {
                                $this->mTemplateIds[$ns] = $dbks;
                        }
                }
-               // Page title
-               $title = $parserOutput->getTitleText();
-               if ( $title != '' ) {
-                       $this->setPageTitle( $title );
-               }
 
                // Hooks registered in the object
                global $wgParserOutputHooks;
@@ -1320,8 +1326,6 @@ class OutputPage {
         * For example:
         *   /w/index.php?title=Main_page should always be served; but
         *   /w/index.php?title=Main_page&variant=zh-cn should never be served.
-        *
-        * patched by Liangent and Philip
         */
        function addAcceptLanguage() {
                global $wgRequest, $wgContLang;
@@ -1903,7 +1907,7 @@ class OutputPage {
                        // Wiki is read only
                        $this->setPageTitle( wfMsg( 'readonly' ) );
                        $reason = wfReadOnlyReason();
-                       $this->wrapWikiMsg( '<div class="mw-readonly-error">\n$1</div>', array( 'readonlytext', $reason ) );
+                       $this->wrapWikiMsg( "<div class='mw-readonly-error'>\n$1</div>", array( 'readonlytext', $reason ) );
                }
 
                // Show source, if supplied
@@ -2075,7 +2079,6 @@ class OutputPage {
                global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5, $wgWellFormedXml;
                global $wgUser, $wgRequest, $wgLang;
 
-               $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" );
                if ( $sk->commonPrintStylesheet() ) {
                        $this->addStyle( 'common/wikiprintable.css', 'print' );
                }
@@ -2088,11 +2091,12 @@ class OutputPage {
                }
 
                if ( $this->getHTMLTitle() == '' ) {
-                       $this->setHTMLTitle(  wfMsg( 'pagetitle', $this->getPageTitle() ));
+                       $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
                }
 
                $dir = $wgContLang->getDir();
 
+               $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir );
                if ( $wgHtml5 ) {
                        if ( $wgWellFormedXml ) {
                                # Unknown elements and attributes are okay in XML, but unknown
@@ -2107,34 +2111,50 @@ class OutputPage {
                                # Much saner.
                                $ret .= "<!doctype html>\n";
                        }
-                       $ret .= "<html lang=\"$wgContLanguageCode\" dir=\"$dir\"";
-                       if ( $wgHtml5Version ) $ret .= " version=\"$wgHtml5Version\"";
-                       $ret .= ">\n";
+                       if ( $wgHtml5Version ) {
+                               $htmlAttribs['version'] = $wgHtml5Version;
+                       }
                } else {
                        $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
-                       $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
-                       foreach($wgXhtmlNamespaces as $tag => $ns) {
-                               $ret .= "xmlns:{$tag}=\"{$ns}\" ";
+                       $htmlAttribs['xmlns'] = $wgXhtmlDefaultNamespace;
+                       foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
+                               $htmlAttribs["xmlns:$tag"] = $ns;
                        }
-                       $ret .= "lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
+                       $this->addMeta( 'http:Content-Type', "$wgMimeType; charset=$wgOutputEncoding" );
                }
+               $ret .= Html::openElement( 'html', $htmlAttribs ) . "\n";
 
-               $ret .= "<head>\n";
+               $openHead = Html::openElement( 'head' );
+               if ( $openHead ) {
+                       # Don't bother with the newline if $head == ''
+                       $ret .= "$openHead\n";
+               }
                $ret .= "<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
+
+               if ( $wgHtml5 ) {
+                       # More succinct than <meta http-equiv=Content-Type>, has the
+                       # same effect
+                       $ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n";
+               }
+
                $ret .= implode( "\n", array(
                        $this->getHeadLinks(),
                        $this->buildCssLinks(),
                        $this->getHeadScripts( $sk ),
                        $this->getHeadItems(),
-               ));
-               if( $sk->usercss ){
+               ) );
+               if ( $sk->usercss ) {
                        $ret .= Html::inlineStyle( $sk->usercss );
                }
 
-               if ($wgUseTrackbacks && $this->isArticleRelated())
+               if ( $wgUseTrackbacks && $this->isArticleRelated() ) {
                        $ret .= $this->getTitle()->trackbackRDF();
+               }
 
-               $ret .= "</head>\n";
+               $closeHead = Html::closeElement( 'head' );
+               if ( $closeHead ) {
+                       $ret .= "$closeHead\n";
+               }
 
                $bodyAttrs = array();