Remove use of OutputPage::addParserOutputNoText()
[lhc/web/wiklou.git] / includes / api / ApiParse.php
index 97f0009..9dc4d03 100644 (file)
@@ -325,7 +325,7 @@ class ApiParse extends ApiBase {
                if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
                        $context = $this->getContext();
                        $context->setTitle( $titleObj );
-                       $context->getOutput()->addParserOutputNoText( $p_result );
+                       $context->getOutput()->addParserOutputMetadata( $p_result );
 
                        if ( isset( $prop['headitems'] ) ) {
                                $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
@@ -346,6 +346,13 @@ class ApiParse extends ApiBase {
                        }
                }
 
+               if ( isset( $prop['modules'] ) ) {
+                       $result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
+                       $result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
+                       $result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
+                       $result_array['modulemessages'] = array_values( array_unique( $p_result->getModuleMessages() ) );
+               }
+
                if ( isset( $prop['iwlinks'] ) ) {
                        $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
                }
@@ -363,7 +370,8 @@ class ApiParse extends ApiBase {
                }
 
                if ( isset( $prop['limitreportdata'] ) ) {
-                       $result_array['limitreportdata'] = $this->formatLimitReportData( $p_result->getLimitReportData() );
+                       $result_array['limitreportdata'] =
+                               $this->formatLimitReportData( $p_result->getLimitReportData() );
                }
                if ( isset( $prop['limitreporthtml'] ) ) {
                        $limitreportHtml = EditPage::getPreviewLimitReport( $p_result );
@@ -398,6 +406,10 @@ class ApiParse extends ApiBase {
                        'iwlinks' => 'iw',
                        'sections' => 's',
                        'headitems' => 'hi',
+                       'modules' => 'm',
+                       'modulescripts' => 'm',
+                       'modulestyles' => 'm',
+                       'modulemessages' => 'm',
                        'properties' => 'pp',
                        'limitreportdata' => 'lr',
                );
@@ -424,6 +436,7 @@ class ApiParse extends ApiBase {
                $popts->enableLimitReport( !$params['disablepp'] );
                $popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
                $popts->setIsSectionPreview( $params['sectionpreview'] );
+               $popts->setEditSection( !$params['disableeditsection'] );
 
                wfProfileOut( __METHOD__ );
 
@@ -488,7 +501,11 @@ class ApiParse extends ApiBase {
                        if ( $title ) {
                                $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
                                // localised language name in user language (maybe set by uselang=)
-                               $entry['langname'] = Language::fetchLanguageName( $title->getInterwiki(), $this->getLanguage()->getCode() );
+                               $entry['langname'] = Language::fetchLanguageName(
+                                       $title->getInterwiki(),
+                                       $this->getLanguage()->getCode()
+                               );
+
                                // native language name
                                $entry['autonym'] = Language::fetchLanguageName( $title->getInterwiki() );
                        }
@@ -558,9 +575,9 @@ class ApiParse extends ApiBase {
                        'and will be removed in MediaWiki 1.24. Use "prop=langlinks" ' .
                        'to generate your own HTML.' );
 
-               global $wgContLang, $wgHideInterlanguageLinks;
+               global $wgContLang;
 
-               if ( $wgHideInterlanguageLinks || count( $languages ) == 0 ) {
+               if ( $this->getConfig()->get( 'HideInterlanguageLinks' ) || count( $languages ) == 0 ) {
                        return '';
                }
 
@@ -718,6 +735,7 @@ class ApiParse extends ApiBase {
                                        'displaytitle',
                                        'headitems',
                                        'headhtml',
+                                       'modules',
                                        'iwlinks',
                                        'wikitext',
                                        'properties',
@@ -731,6 +749,7 @@ class ApiParse extends ApiBase {
                        'uselang' => null,
                        'section' => null,
                        'disablepp' => false,
+                       'disableeditsection' => false,
                        'generatexml' => false,
                        'preview' => false,
                        'sectionpreview' => false,
@@ -774,6 +793,7 @@ class ApiParse extends ApiBase {
                                ' displaytitle   - Adds the title of the parsed wikitext',
                                ' headitems      - Gives items to put in the <head> of the page',
                                ' headhtml       - Gives parsed <head> of the page',
+                               ' modules        - Gives the ResourceLoader modules used on the page',
                                ' iwlinks        - Gives interwiki links in the parsed wikitext',
                                ' wikitext       - Gives the original wikitext that was parsed',
                                ' properties     - Gives various properties defined in the parsed wikitext',
@@ -798,6 +818,7 @@ class ApiParse extends ApiBase {
                        'uselang' => 'Which language to parse the request in',
                        'section' => 'Only retrieve the content of this section number',
                        'disablepp' => 'Disable the PP Report from the parser output',
+                       'disableeditsection' => 'Disable edit section links from the parser output',
                        'generatexml' => "Generate XML parse tree (requires contentmodel=$wikitext)",
                        'preview' => 'Parse in preview mode',
                        'sectionpreview' => 'Parse in section preview mode (enables preview mode too)',