Fix a couple of Generic.Files.OneObjectStructurePerFile.MultipleFound in api
[lhc/web/wiklou.git] / includes / api / ApiRsd.php
index d466112..00ab77b 100644 (file)
@@ -3,8 +3,6 @@
 /**
  * API for MediaWiki 1.17+
  *
- * Created on October 26, 2010
- *
  * Copyright © 2010 Bryan Tong Minh and Brion Vibber
  *
  * This program is free software; you can redistribute it and/or modify
@@ -37,14 +35,14 @@ class ApiRsd extends ApiBase {
                $result->addValue( null, 'version', '1.0' );
                $result->addValue( null, 'xmlns', 'http://archipelago.phrasewise.com/rsd' );
 
-               $service = array(
+               $service = [
                        'apis' => $this->formatRsdApiList(),
                        'engineName' => 'MediaWiki',
                        'engineLink' => 'https://www.mediawiki.org/',
                        'homePageLink' => Title::newMainPage()->getCanonicalURL(),
-               );
+               ];
 
-               ApiResult::setSubelementsList( $service, array( 'engineName', 'engineLink', 'homePageLink' ) );
+               ApiResult::setSubelementsList( $service, [ 'engineName', 'engineLink', 'homePageLink' ] );
                ApiResult::setIndexedTagName( $service['apis'], 'api' );
 
                $result->addValue( null, 'service', $service );
@@ -55,10 +53,10 @@ class ApiRsd extends ApiBase {
        }
 
        protected function getExamplesMessages() {
-               return array(
+               return [
                        'action=rsd'
                                => 'apihelp-rsd-example-simple',
-               );
+               ];
        }
 
        public function isReadMode() {
@@ -75,7 +73,7 @@ class ApiRsd extends ApiBase {
         * compatible APIs, by hooking 'ApiRsdServiceApis' and adding more
         * elements to the array.
         *
-        * See http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html for
+        * See https://cyber.harvard.edu/blogs/gems/tech/rsd.html for
         * the base RSD spec, and check WordPress and StatusNet sites for
         * in-production examples listing several blogging and micrblogging
         * APIs.
@@ -83,26 +81,26 @@ class ApiRsd extends ApiBase {
         * @return array
         */
        protected function getRsdApiList() {
-               $apis = array(
-                       'MediaWiki' => array(
+               $apis = [
+                       'MediaWiki' => [
                                // The API link is required for all RSD API entries.
                                'apiLink' => wfExpandUrl( wfScript( 'api' ), PROTO_CURRENT ),
 
                                // Docs link is optional, but recommended.
-                               'docs' => 'https://www.mediawiki.org/wiki/API',
+                               'docs' => 'https://www.mediawiki.org/wiki/Special:MyLanguage/API',
 
                                // Some APIs may need a blog ID, but it may be left blank.
                                'blogID' => '',
 
                                // Additional settings are optional.
-                               'settings' => array(
+                               'settings' => [
                                        // Change this to true in the future as an aid to
                                        // machine discovery of OAuth for API access.
                                        'OAuth' => false,
-                               )
-                       ),
-               );
-               Hooks::run( 'ApiRsdServiceApis', array( &$apis ) );
+                               ]
+                       ],
+               ];
+               Hooks::run( 'ApiRsdServiceApis', [ &$apis ] );
 
                return $apis;
        }
@@ -116,15 +114,15 @@ class ApiRsd extends ApiBase {
        protected function formatRsdApiList() {
                $apis = $this->getRsdApiList();
 
-               $outputData = array();
+               $outputData = [];
                foreach ( $apis as $name => $info ) {
-                       $data = array(
+                       $data = [
                                'name' => $name,
                                'preferred' => wfBoolToStr( $name == 'MediaWiki' ),
                                'apiLink' => $info['apiLink'],
-                               'blogID' => isset( $info['blogID'] ) ? $info['blogID'] : '',
-                       );
-                       $settings = array();
+                               'blogID' => $info['blogID'] ?? '',
+                       ];
+                       $settings = [];
                        if ( isset( $info['docs'] ) ) {
                                $settings['docs'] = $info['docs'];
                                ApiResult::setSubelementsList( $settings, 'docs' );
@@ -136,7 +134,7 @@ class ApiRsd extends ApiBase {
                                        } else {
                                                $xmlVal = $val;
                                        }
-                                       $setting = array( 'name' => $setting );
+                                       $setting = [ 'name' => $setting ];
                                        ApiResult::setContentValue( $setting, 'value', $xmlVal );
                                        $settings[] = $setting;
                                }
@@ -151,19 +149,3 @@ class ApiRsd extends ApiBase {
                return $outputData;
        }
 }
-
-class ApiFormatXmlRsd extends ApiFormatXml {
-       public function __construct( ApiMain $main, $format ) {
-               parent::__construct( $main, $format );
-               $this->setRootElement( 'rsd' );
-       }
-
-       public function getMimeType() {
-               return 'application/rsd+xml';
-       }
-
-       public static function recXmlPrint( $name, $value, $indent, $attributes = array() ) {
-               unset( $attributes['_idx'] );
-               return parent::recXmlPrint( $name, $value, $indent, $attributes );
-       }
-}