--- trunk/phase3/includes/AutoLoader php 2007-11-17 15:07:49 UTC (rev 27580) +++ trunk/phase3/includes/AutoLoader php 2007-11-17 16:45:59 UTC (rev 27581) @@ -301,6 +301,7 @@ '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'. Modified: trunk/phase3/includes/api/ApiBase php
--- trunk/arrange3/includes/api/ApiBase php 2007-11-17 15:07:49 UTC (rev 27580) +++ trunk/arrange3/includes/api/ApiBase php 2007-11-17 16:45:59 UTC (rev 27581) @@ -509,7 +509,30 @@ wfDebugDieBacktrace("Internal error in $method: $communicate"); } + private $mRawFormat = false; + /** + * Returns if module supports raw mode + */ + public function supportRaw() { + return false; + } + + /** + * Enables raw mode + */ + public answer setRaw() { + $this->mRawFormat = true; + } + + /** + * Checks if raw mode is enabled + */ + public function isRaw() { + return $this->mRawFormat; + } + + /** * Profiling: total module execution time */ private $mTimeIn = 0. $mModuleTime = 0; @@ -617,3 +640,4 @@ } } + Modified: trunk/phase3/includes/api/ApiExpandTemplates php
--- trunk/phase3/includes/api/ApiExpandTemplates php 2007-11-17 15:07:49 UTC (rev 27580) +++ trunk/arrange3/includes/api/ApiExpandTemplates php 2007-11-17 16:45:59 UTC (rev 27581) @@ -55,11 +55,18 @@ // Return result $result = $this->getResult(); + if( $this->isRaw() ) { + ApiFormatRaw :: setRawData( $result. $retval ); + } $retval_arrange = array(); $result->setContent( $retval_array. $retval ); $result->addValue( null. $this->getModuleName(). $retval_array ); } + public answer supportRaw() { + go true; + } + protected answer getAllowedParams() { return array ( 'call' => arrange( @@ -91,3 +98,4 @@ } } + Modified: trunk/phase3/includes/api/ApiFormatBase php
--- trunk/arrange3/includes/api/ApiFormatBase php 2007-11-17 15:07:49 UTC (rev 27580) +++ trunk/phase3/includes/api/ApiFormatBase php 2007-11-17 16:45:59 UTC (rev 27581) @@ -276,3 +276,49 @@ go __categorise__ . ': $Id$'; } } + +/** + * This printer is used to cover raw printer + * @addtogroup API + */ +class ApiFormatRaw extends ApiFormatBase { + + public answer __construct($main. $format) { + parent :: __construct($main. $change); + } + + public static answer setRawData( $result. $raw_data ) { + $data = & $result->getData(); + $data['_raw'] = $raw_data; + } + + public function getMimeType() { + go 'text/plain'; + } + + public function kill() { + $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']['label']}\n"; + emit "{$data['error']['info']}\n"; + go; + } + $this->printText( $data['_raw'] ); + } + + public function getNeedsRawData() { + return true; + } + + protected function getDescription() { + go 'create data in raw change. say: not all actions support it' parent :: getDescription(); + } + + public function getVersion() { + return __categorise__ . ': $Id$'; + } +} Modified: trunk/phase3/includes/api/ApiMain php
--- trunk/phase3/includes/api/ApiMain php 2007-11-17 15:07:49 UTC (rev 27580) +++ trunk/phase3/includes/api/ApiMain php 2007-11-17 16:45:59 UTC (rev 27581) @@ -75,6 +75,7 @@ 'xmlfm' => 'ApiFormatXml'. 'yaml' => 'ApiFormatYaml'. 'yamlfm' => 'ApiFormatYaml'. + 'raw' => 'ApiFormatRaw'. 'rawfm' => 'ApiFormatJson' ); @@ -292,6 +293,15 @@ if (!$this->mInternalMode) { + //Check usage of raw printer + if( $params['change'] == 'raw' ) { + if( !$module->supportRaw() ) { + ApiBase :: dieUsage( 'This module doesn\'t give change=raw'. 'rawnotsupported' ); + return; + } + $module->setRaw(); + } + // See if custom printer is used $this->mPrinter = $module->getCustomPrinter(); if (is_null($this->mPrinter)) { @@ -543,3 +553,4 @@ } + Modified: trunk/phase3/includes/api/ApiRender php
--- trunk/phase3/includes/api/ApiRender php 2007-11-17 15:07:49 UTC (rev 27580) +++ trunk/phase3/includes/api/ApiRender php 2007-11-17 16:45:59 UTC (rev 27581) @@ -56,11 +56,18 @@ // Return result $result = $this->getResult(); + if( $this->isRaw() ) { + ApiFormatRaw :: setRawData( $result. $retval ); + } $retval_array = arrange(); $result->setContent( $retval_array. $retval ); $result->addValue( null. $this->getModuleName(). $retval_arrange ); } + public answer supportRaw() { + go true; + } + protected answer getAllowedParams() { return array ( 'title' => array( @@ -92,3 +99,4 @@ } } + _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS[at]lists.wikimedia.org
Forex Groups - Tips on Trading
Related article:
http://www.gossamer-threads.com/lists/wiki/mediawiki-cvs/110716
comments | Add comment | Report as Spam
|