4 * Created on Feb 2, 2009
6 * API for MediaWiki 1.8+
8 * Copyright (C) 2009 Roan Kattouw <Firstname>.<Lastname>@home.nl
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 if ( !defined( 'MEDIAWIKI' ) ) {
27 // Eclipse helper - will be ignored in production
28 require_once ( 'ApiFormatBase.php' );
32 * Formatter that spits out anything you like with any desired MIME type
35 class ApiFormatRaw extends ApiFormatBase {
39 * @param $main ApiMain object
40 * @param $errorFallback Formatter object to fall back on for errors
42 public function __construct( $main, $errorFallback ) {
43 parent :: __construct( $main, 'raw' );
44 $this->mErrorFallback = $errorFallback;
47 public function getMimeType() {
48 $data = $this->getResultData();
50 if ( isset( $data['error'] ) )
51 return $this->mErrorFallback->getMimeType();
53 if ( !isset( $data['mime'] ) )
54 ApiBase::dieDebug( __METHOD__, "No MIME type set for raw formatter" );
59 public function execute() {
60 $data = $this->getResultData();
61 if ( isset( $data['error'] ) )
63 $this->mErrorFallback->execute();
67 if ( !isset( $data['text'] ) )
68 ApiBase::dieDebug( __METHOD__, "No text given for raw formatter" );
69 $this->printText( $data['text'] );
72 public function getVersion() {
73 return __CLASS__ . ': $Id: ApiFormatRaw.php 61437 2010-01-23 22:26:40Z reedy $';