* (bug 11562) Added a user_registration parameter/field to the list=allusers query.
* (bug 11588) Preserve document structure for empty dataset in backlinks query.
* Outputting list of all user preferences rather than having to request them by name
+* Add raw formatting support. Now several actions like expandtemplates support raw output with format=raw
=== Languages updated in 1.12 ===
'Services_JSON' => 'includes/api/ApiFormatJson_json.php',
'ApiFormatJson' => 'includes/api/ApiFormatJson.php',
'ApiFormatPhp' => 'includes/api/ApiFormatPhp.php',
+ 'ApiFormatRaw' => 'includes/api/ApiFormatBase.php',
'ApiFormatWddx' => 'includes/api/ApiFormatWddx.php',
'ApiFormatXml' => 'includes/api/ApiFormatXml.php',
'Spyc' => 'includes/api/ApiFormatYaml_spyc.php',
wfDebugDieBacktrace("Internal error in $method: $message");
}
+ private $mRawFormat = false;
+
+ /**
+ * Returns if module supports raw mode
+ */
+ public function supportRaw() {
+ return false;
+ }
+
+ /**
+ * Enables raw mode
+ */
+ public function setRaw() {
+ $this->mRawFormat = true;
+ }
+
+ /**
+ * Checks if raw mode is enabled
+ */
+ public function isRaw() {
+ return $this->mRawFormat;
+ }
+
/**
* Profiling: total module execution time
*/
}
}
+
// Return result
$result = $this->getResult();
+ if( $this->isRaw() ) {
+ ApiFormatRaw :: setRawData( $result, $retval );
+ }
$retval_array = array();
$result->setContent( $retval_array, $retval );
$result->addValue( null, $this->getModuleName(), $retval_array );
}
+ public function supportRaw() {
+ return true;
+ }
+
protected function getAllowedParams() {
return array (
'title' => array(
}
}
+
return __CLASS__ . ': $Id$';
}
}
+
+/**
+ * This printer is used to wrap raw printer
+ * @addtogroup API
+ */
+class ApiFormatRaw extends ApiFormatBase {
+
+ public function __construct($main, $format) {
+ parent :: __construct($main, $format);
+ }
+
+ public static function setRawData( $result, $raw_data ) {
+ $data = & $result->getData();
+ $data['_raw'] = $raw_data;
+ }
+
+ public function getMimeType() {
+ return 'text/plain';
+ }
+
+ public function execute() {
+ $data = $this->getResultData();
+ if( !isset( $data['_raw'] ) && !isset( $data['error'] ) ) {
+ ApiBase :: dieDebug( 'ApiFormatRaw', 'No raw data is set for this module' );
+ }
+ elseif( isset( $data['error'] ) ) {
+ header( '500 Internal error' );
+ echo "{$data['error']['code']}\n";
+ echo "{$data['error']['info']}\n";
+ return;
+ }
+ $this->printText( $data['_raw'] );
+ }
+
+ public function getNeedsRawData() {
+ return true;
+ }
+
+ protected function getDescription() {
+ return 'Output data in raw format. NOTE: not all actions support it' . parent :: getDescription();
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
+}
'xmlfm' => 'ApiFormatXml',
'yaml' => 'ApiFormatYaml',
'yamlfm' => 'ApiFormatYaml',
+ 'raw' => 'ApiFormatRaw',
'rawfm' => 'ApiFormatJson'
);
if (!$this->mInternalMode) {
+ //Check usage of raw printer
+ if( $params['format'] == 'raw' ) {
+ if( !$module->supportRaw() ) {
+ ApiBase :: dieUsage( 'This module doesn\'t support format=raw', 'rawnotsupported' );
+ return;
+ }
+ $module->setRaw();
+ }
+
// See if custom printer is used
$this->mPrinter = $module->getCustomPrinter();
if (is_null($this->mPrinter)) {
}
+
// Return result
$result = $this->getResult();
+ if( $this->isRaw() ) {
+ ApiFormatRaw :: setRawData( $result, $retval );
+ }
$retval_array = array();
$result->setContent( $retval_array, $retval );
$result->addValue( null, $this->getModuleName(), $retval_array );
}
+ public function supportRaw() {
+ return true;
+ }
+
protected function getAllowedParams() {
return array (
'title' => array(
}
}
+