$result->addValue( null, 'version', '1.0' );
$result->addValue( null, 'xmlns', 'http://archipelago.phrasewise.com/rsd' );
- $service = array( 'apis' => $this->formatRsdApiList() );
- ApiResult::setContent( $service, 'MediaWiki', 'engineName' );
- ApiResult::setContent( $service, 'https://www.mediawiki.org/', 'engineLink' );
- ApiResult::setContent( $service, Title::newMainPage()->getCanonicalURL(), 'homePageLink' );
+ $service = [
+ 'apis' => $this->formatRsdApiList(),
+ 'engineName' => 'MediaWiki',
+ 'engineLink' => 'https://www.mediawiki.org/',
+ 'homePageLink' => Title::newMainPage()->getCanonicalURL(),
+ ];
- $result->setIndexedTagName( $service['apis'], 'api' );
+ ApiResult::setSubelementsList( $service, [ 'engineName', 'engineLink', 'homePageLink' ] );
+ ApiResult::setIndexedTagName( $service['apis'], 'api' );
$result->addValue( null, 'service', $service );
}
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=rsd'
=> 'apihelp-rsd-example-simple',
- );
+ ];
}
public function isReadMode() {
* 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.
* @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 ),
'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;
}
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();
+ ];
+ $settings = [];
if ( isset( $info['docs'] ) ) {
- ApiResult::setContent( $settings, $info['docs'], 'docs' );
+ $settings['docs'] = $info['docs'];
+ ApiResult::setSubelementsList( $settings, 'docs' );
}
if ( isset( $info['settings'] ) ) {
foreach ( $info['settings'] as $setting => $val ) {
} else {
$xmlVal = $val;
}
- $setting = array( 'name' => $setting );
- ApiResult::setContent( $setting, $xmlVal );
+ $setting = [ 'name' => $setting ];
+ ApiResult::setContentValue( $setting, 'value', $xmlVal );
$settings[] = $setting;
}
}
if ( count( $settings ) ) {
- $this->getResult()->setIndexedTagName( $settings, 'setting' );
+ ApiResult::setIndexedTagName( $settings, 'setting' );
$data['settings'] = $settings;
}
$outputData[] = $data;
public function getMimeType() {
return 'application/rsd+xml';
}
+
+ public static function recXmlPrint( $name, $value, $indent, $attributes = [] ) {
+ unset( $attributes['_idx'] );
+ return parent::recXmlPrint( $name, $value, $indent, $attributes );
+ }
}