MediaWiki
REL1_24
|
00001 <?php 00031 class ApiFormatFeedWrapper extends ApiFormatBase { 00032 00033 public function __construct( ApiMain $main ) { 00034 parent::__construct( $main, 'feed' ); 00035 } 00036 00043 public static function setResult( $result, $feed, $feedItems ) { 00044 // Store output in the Result data. 00045 // This way we can check during execution if any error has occurred 00046 // Disable size checking for this because we can't continue 00047 // cleanly; size checking would cause more problems than it'd 00048 // solve 00049 $result->addValue( null, '_feed', $feed, ApiResult::NO_SIZE_CHECK ); 00050 $result->addValue( null, '_feeditems', $feedItems, ApiResult::NO_SIZE_CHECK ); 00051 } 00052 00058 public function getMimeType() { 00059 return null; 00060 } 00061 00067 public function getNeedsRawData() { 00068 return true; 00069 } 00070 00076 public function canPrintErrors() { 00077 return false; 00078 } 00079 00085 public function execute() { 00086 $data = $this->getResultData(); 00087 if ( isset( $data['_feed'] ) && isset( $data['_feeditems'] ) ) { 00088 $feed = $data['_feed']; 00089 $items = $data['_feeditems']; 00090 00091 $feed->outHeader(); 00092 foreach ( $items as & $item ) { 00093 $feed->outItem( $item ); 00094 } 00095 $feed->outFooter(); 00096 } else { 00097 // Error has occurred, print something useful 00098 ApiBase::dieDebug( __METHOD__, 'Invalid feed class/item' ); 00099 } 00100 } 00101 }