Installer is no longer hardcoded to xhtml doctype
[lhc/web/wiklou.git] / includes / OutputPage.php
index 33753c0..a135166 100644 (file)
@@ -9,7 +9,7 @@ class OutputPage {
        var $mMetatags = array(), $mKeywords = array(), $mLinktags = array();
        var $mExtStyles = array();
        var $mPagetitle = '', $mBodytext = '', $mDebugtext = '';
-       var $mHTMLtitle = '', $mHTMLtitleFromPagetitle = true, $mIsarticle = true, $mPrintable = false;
+       var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false;
        var $mSubtitle = '', $mRedirect = '', $mStatusCode;
        var $mLastModified = '', $mETag = false;
        var $mCategoryLinks = array(), $mCategories = array(), $mLanguageLinks = array();
@@ -447,17 +447,9 @@ 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.
-        * If $name is from page title, it can only override names which are also from page title,
-        * but if it is not from page title, it can override all other names.
         */
-       public function setHTMLTitle( $name, $frompagetitle = false ) {
-               if ( $frompagetitle && $this->mHTMLtitleFromPagetitle ) {
-                       $this->mHTMLtitle = $name;
-               }
-               elseif ( $this->mHTMLtitleFromPagetitle ) {
-                       $this->mHTMLtitle = $name;
-                       $this->mHTMLtitleFromPagetitle = false;
-               }
+       public function setHTMLTitle( $name ) {
+               $this->mHTMLtitle = $name;
        }
 
        /**
@@ -487,7 +479,7 @@ class OutputPage {
                }
 
                # change "<i>foo&amp;bar</i>" to "foo&bar"
-               $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ), true );
+               $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) );
        }
 
        /**
@@ -1104,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;
@@ -1488,7 +1475,7 @@ class OutputPage {
                global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
                global $wgUseAjax, $wgAjaxWatch;
                global $wgEnableMWSuggest, $wgUniversalEditButton;
-               global $wgArticle;
+               global $wgArticle, $wgJQueryOnEveryPage;
 
                if( $this->mDoNothing ){
                        return;
@@ -1531,6 +1518,7 @@ class OutputPage {
                        wfRunHooks( 'AjaxAddScript', array( &$this ) );
 
                        if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
+                               $this->includeJQuery();
                                $this->addScriptFile( 'ajaxwatch.js' );
                        }
 
@@ -1562,6 +1550,10 @@ class OutputPage {
                                ) );
                        }
                }
+               
+               if ( $wgJQueryOnEveryPage ) {
+                       $this->includeJQuery();
+               }
 
                # Buffer output; final headers may depend on later processing
                ob_start();
@@ -2087,9 +2079,8 @@ class OutputPage {
         * @return String: The doctype, opening <html>, and head element.
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
-               global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
-               global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
-               global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5, $wgWellFormedXml;
+               global $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
+               global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5;
                global $wgUser, $wgRequest, $wgLang;
 
                if ( $sk->commonPrintStylesheet() ) {
@@ -2097,58 +2088,29 @@ class OutputPage {
                }
                $sk->setupUserCss( $this );
 
-               $ret = '';
-
-               if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
-                       $ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
-               }
+               $dir = $wgContLang->getDir();
+               $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir );
+               $ret = Html::htmlHeader( $htmlAttribs );
 
                if ( $this->getHTMLTitle() == '' ) {
                        $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
-                               # named entities are well-formedness errors and will break XML
-                               # parsers.  Thus we need a doctype that gives us appropriate
-                               # entity definitions.  The HTML5 spec permits four legacy
-                               # doctypes as obsolete but conforming, so let's pick one of
-                               # those, although it makes our pages look like XHTML1 Strict.
-                               # Isn't compatibility great?
-                               $ret .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
-                       } else {
-                               # Much saner.
-                               $ret .= "<!doctype html>\n";
-                       }
-                       if ( $wgHtml5Version ) {
-                               $htmlAttribs['version'] = $wgHtml5Version;
-                       }
+                       # More succinct than <meta http-equiv=Content-Type>, has the
+                       # same effect
+                       $ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n";
                } else {
-                       $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
-                       $htmlAttribs['xmlns'] = $wgXhtmlDefaultNamespace;
-                       foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
-                               $htmlAttribs["xmlns:$tag"] = $ns;
-                       }
                        $this->addMeta( 'http:Content-Type', "$wgMimeType; charset=$wgOutputEncoding" );
                }
-               $ret .= Html::openElement( 'html', $htmlAttribs ) . "\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";
+               $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\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(),
@@ -2622,12 +2584,13 @@ class OutputPage {
         * @since 1.16
         */
        public function includeJQuery( $modules = array() ) {
-               global $wgStylePath, $wgStyleVersion;
+               global $wgStylePath, $wgStyleVersion, $wgJQueryVersion, $wgJQueryMinified;
 
                $supportedModules = array( /** TODO: add things here */ );
                $unsupported = array_diff( $modules, $supportedModules );
 
-               $url = "$wgStylePath/common/jquery.min.js?$wgStyleVersion";
+               $min = $wgJQueryMinified ? '.min' : '';
+               $url = "$wgStylePath/common/jquery-$wgJQueryVersion$min.js?$wgStyleVersion";
                if ( !$this->mJQueryDone ) {
                        $this->mJQueryDone = true;
                        $this->mScripts = Html::linkedScript( $url ) . "\n" . $this->mScripts;