* @file
*/
-if ( !defined( 'MEDIAWIKI' ) ) {
- require_once( 'ApiBase.php' );
-}
-
/**
- * API interface for page purging
+ * API module for sending out RSD information
* @ingroup API
*/
class ApiRsd extends ApiBase {
- public function __construct( $main, $action ) {
- parent::__construct( $main, $action );
- }
-
public function execute() {
$result = $this->getResult();
-
$result->addValue( null, 'version', '1.0' );
$result->addValue( null, 'xmlns', 'http://archipelago.phrasewise.com/rsd' );
- $service = array(
- 'engineName' => array(
- '*' => 'MediaWiki'
- ),
- 'engineLink' => array(
- '*' => 'http://www.mediawiki.org/'
- ),
- 'apis' => $this->formatRsdApiList()
- );
+ $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' );
$result->setIndexedTagName( $service['apis'], 'api' );
}
public function getDescription() {
- return 'Export an RSD schema';
+ return 'Export an RSD (Really Simple Discovery) schema';
}
- protected function getExamples() {
+ public function getExamples() {
return array(
'api.php?action=rsd'
);
$apis = array(
'MediaWiki' => array(
// The API link is required for all RSD API entries.
- 'apiLink' => wfExpandUrl( wfScript( 'api' ) ),
+ 'apiLink' => wfExpandUrl( wfScript( 'api' ), PROTO_CURRENT ),
// Docs link is optional, but recommended.
- 'docs' => 'http://mediawiki.org/wiki/API',
+ 'docs' => 'https://www.mediawiki.org/wiki/API',
// Some APIs may need a blog ID, but it may be left blank.
'blogID' => '',
'name' => $name,
'preferred' => wfBoolToStr( $name == 'MediaWiki' ),
'apiLink' => $info['apiLink'],
- 'blogID' => isset( $info['blogID'] ) ? $info['blogID'] : ''
+ 'blogID' => isset( $info['blogID'] ) ? $info['blogID'] : '',
);
+ $settings = array();
if ( isset( $info['docs'] ) ) {
- $data['settings']['docs'] = array(
- '*' => $info['docs'],
- );
+ ApiResult::setContent( $settings, $info['docs'], 'docs' );
}
if ( isset( $info['settings'] ) ) {
foreach ( $info['settings'] as $setting => $val ) {
} else {
$xmlVal = $val;
}
- $data['settings'][] = array(
- 'name' => $setting,
- '*' => $xmlVal,
- );
+ $setting = array( 'name' => $setting );
+ ApiResult::setContent( $setting, $xmlVal );
+ $settings[] = $setting;
}
}
- if ( isset( $data['settings'] ) ) {
- $data['settings']['_element'] = 'setting';
+ if ( count( $settings ) ) {
+ $this->getResult()->setIndexedTagName( $settings, 'setting' );
+ $data['settings'] = $settings;
}
$outputData[] = $data;
}
return $outputData;
}
- public function getVersion() {
- return __CLASS__ . ': $Id$';
- }
}
class ApiFormatXmlRsd extends ApiFormatXml {
parent::__construct( $main, $format );
$this->setRootElement( 'rsd' );
}
-
+
public function getMimeType() {
return 'application/rsd+xml';
}