MediaWiki  REL1_22
ApiFormatRaw.php
Go to the documentation of this file.
00001 <?php
00031 class ApiFormatRaw extends ApiFormatBase {
00032 
00038     public function __construct( $main, $errorFallback ) {
00039         parent::__construct( $main, 'raw' );
00040         $this->mErrorFallback = $errorFallback;
00041     }
00042 
00043     public function getMimeType() {
00044         $data = $this->getResultData();
00045 
00046         if ( isset( $data['error'] ) ) {
00047             return $this->mErrorFallback->getMimeType();
00048         }
00049 
00050         if ( !isset( $data['mime'] ) ) {
00051             ApiBase::dieDebug( __METHOD__, 'No MIME type set for raw formatter' );
00052         }
00053 
00054         return $data['mime'];
00055     }
00056 
00057     public function execute() {
00058         $data = $this->getResultData();
00059         if ( isset( $data['error'] ) ) {
00060             $this->mErrorFallback->execute();
00061             return;
00062         }
00063 
00064         if ( !isset( $data['text'] ) ) {
00065             ApiBase::dieDebug( __METHOD__, 'No text given for raw formatter' );
00066         }
00067         $this->printText( $data['text'] );
00068     }
00069 }