Implement page status indicators
[lhc/web/wiklou.git] / includes / api / ApiParse.php
index d09470b..c2ec8d4 100644 (file)
@@ -79,16 +79,6 @@ class ApiParse extends ApiBase {
                // TODO: Does this still need $wgTitle?
                global $wgParser, $wgTitle;
 
-               // Currently unnecessary, code to act as a safeguard against any change
-               // in current behavior of uselang
-               $oldLang = null;
-               if ( isset( $params['uselang'] )
-                       && $params['uselang'] != $this->getContext()->getLanguage()->getCode()
-               ) {
-                       $oldLang = $this->getContext()->getLanguage(); // Backup language
-                       $this->getContext()->setLanguage( Language::factory( $params['uselang'] ) );
-               }
-
                $redirValues = null;
 
                // Return result
@@ -347,6 +337,14 @@ class ApiParse extends ApiBase {
                        $result_array['modulemessages'] = array_values( array_unique( $p_result->getModuleMessages() ) );
                }
 
+               if ( isset( $prop['indicators'] ) ) {
+                       foreach ( $p_result->getIndicators() as $name => $content ) {
+                               $indicator = array( 'name' => $name );
+                               ApiResult::setContent( $indicator, $content );
+                               $result_array['indicators'][] = $indicator;
+                       }
+               }
+
                if ( isset( $prop['iwlinks'] ) ) {
                        $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
                }
@@ -401,6 +399,7 @@ class ApiParse extends ApiBase {
                        'sections' => 's',
                        'headitems' => 'hi',
                        'modules' => 'm',
+                       'indicators' => 'ind',
                        'modulescripts' => 'm',
                        'modulestyles' => 'm',
                        'modulemessages' => 'm',
@@ -409,10 +408,6 @@ class ApiParse extends ApiBase {
                );
                $this->setIndexedTagNames( $result_array, $result_mapping );
                $result->addValue( null, $this->getModuleName(), $result_array );
-
-               if ( !is_null( $oldLang ) ) {
-                       $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
-               }
        }
 
        /**
@@ -473,6 +468,7 @@ class ApiParse extends ApiBase {
        /**
         * @param Content $content
         * @param string $what Identifies the content in error messages, e.g. page title.
+        * @return Content|bool
         */
        private function getSectionContent( Content $content, $what ) {
                // Not cached (save or load)
@@ -498,7 +494,7 @@ class ApiParse extends ApiBase {
                        $entry['lang'] = $bits[0];
                        if ( $title ) {
                                $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
-                               // localised language name in user language (maybe set by uselang=)
+                               // localised language name in 'uselang' language
                                $entry['langname'] = Language::fetchLanguageName(
                                        $title->getInterwiki(),
                                        $this->getLanguage()->getCode()
@@ -693,6 +689,7 @@ class ApiParse extends ApiBase {
                                        'headitems',
                                        'headhtml',
                                        'modules',
+                                       'indicators',
                                        'iwlinks',
                                        'wikitext',
                                        'properties',
@@ -703,7 +700,6 @@ class ApiParse extends ApiBase {
                        'pst' => false,
                        'onlypst' => false,
                        'effectivelanglinks' => false,
-                       'uselang' => null,
                        'section' => null,
                        'disablepp' => false,
                        'disableeditsection' => false,
@@ -749,6 +745,7 @@ class ApiParse extends ApiBase {
                                ' 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',
+                               ' indicators     - Gives the HTML of page status indicators 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',
@@ -770,7 +767,6 @@ class ApiParse extends ApiBase {
                                'Returns the same wikitext, after a PST has been applied.',
                                "Only valid when used with {$p}text",
                        ),
-                       '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',