Merge "Fix alpha transparency in XCF images"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 6075d8d..f8b1b3e 100644 (file)
@@ -885,10 +885,7 @@ class OutputPage extends ContextSource {
         * @return string
         */
        public function getPageTitleActionText() {
-               if ( isset( $this->mPageTitleActionText ) ) {
-                       return $this->mPageTitleActionText;
-               }
-               return '';
+               return $this->mPageTitleActionText;
        }
 
        /**
@@ -1608,7 +1605,7 @@ class OutputPage extends ContextSource {
                $oldTidy = $popts->setTidy( $tidy );
                $popts->setInterfaceMessage( (bool)$interface );
 
-               $parserOutput = $wgParser->parse(
+               $parserOutput = $wgParser->getFreshParser()->parse(
                        $text, $title, $popts,
                        $linestart, true, $this->mRevisionId
                );
@@ -1621,11 +1618,24 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add a ParserOutput object, but without Html
+        * Add a ParserOutput object, but without Html.
         *
+        * @deprecated since 1.24, use addParserOutputMetadata() instead.
         * @param ParserOutput $parserOutput
         */
        public function addParserOutputNoText( &$parserOutput ) {
+               $this->addParserOutputMetadata( $parserOutput );
+       }
+
+       /**
+        * Add all metadata associated with a ParserOutput object, but without the actual HTML. This
+        * includes categories, language links, ResourceLoader modules, effects of certain magic words,
+        * and so on.
+        *
+        * @since 1.24
+        * @param ParserOutput $parserOutput
+        */
+       public function addParserOutputMetadata( &$parserOutput ) {
                $this->mLanguageLinks += $parserOutput->getLanguageLinks();
                $this->addCategoryLinks( $parserOutput->getCategories() );
                $this->mNewSectionLink = $parserOutput->getNewSection();
@@ -1673,21 +1683,50 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add a ParserOutput object
+        * Add the HTML and enhancements for it (like ResourceLoader modules) associated with a
+        * ParserOutput object, without any other metadata.
+        *
+        * @since 1.24
+        * @param ParserOutput $parserOutput
+        */
+       public function addParserOutputContent( &$parserOutput ) {
+               $this->addParserOutputText( $parserOutput );
+
+               $this->addModules( $parserOutput->getModules() );
+               $this->addModuleScripts( $parserOutput->getModuleScripts() );
+               $this->addModuleStyles( $parserOutput->getModuleStyles() );
+               $this->addModuleMessages( $parserOutput->getModuleMessages() );
+
+               $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
+       }
+
+       /**
+        * Add the HTML associated with a ParserOutput object, without any metadata.
+        *
+        * @since 1.24
+        * @param ParserOutput $parserOutput
+        */
+       public function addParserOutputText( &$parserOutput ) {
+               $text = $parserOutput->getText();
+               wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
+               $this->addHTML( $text );
+       }
+
+       /**
+        * Add everything from a ParserOutput object.
         *
         * @param ParserOutput $parserOutput
         */
        function addParserOutput( &$parserOutput ) {
-               $this->addParserOutputNoText( $parserOutput );
+               $this->addParserOutputMetadata( $parserOutput );
                $parserOutput->setTOCEnabled( $this->mEnableTOC );
 
                // Touch section edit links only if not previously disabled
                if ( $parserOutput->getEditSectionTokens() ) {
                        $parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
                }
-               $text = $parserOutput->getText();
-               wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
-               $this->addHTML( $text );
+
+               $this->addParserOutputText( $parserOutput );
        }
 
        /**
@@ -1726,7 +1765,7 @@ class OutputPage extends ContextSource {
                        $oldLang = $popts->setTargetLanguage( $language );
                }
 
-               $parserOutput = $wgParser->parse(
+               $parserOutput = $wgParser->getFreshParser()->parse(
                        $text, $this->getTitle(), $popts,
                        $linestart, true, $this->mRevisionId
                );
@@ -1889,7 +1928,12 @@ class OutputPage extends ContextSource {
         *   /w/index.php?title=Main_page&variant=zh-cn should never be served.
         */
        function addAcceptLanguage() {
-               $lang = $this->getTitle()->getPageLanguage();
+               $title = $this->getTitle();
+               if ( !$title instanceof Title ) {
+                       return;
+               }
+
+               $lang = $title->getPageLanguage();
                if ( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) {
                        $variants = $lang->getVariants();
                        $aloption = array();