MediaWiki REL1_33
ApiFormatFeedWrapper.php
Go to the documentation of this file.
1<?php
28
29 public function __construct( ApiMain $main ) {
30 parent::__construct( $main, 'feed' );
31 }
32
39 public static function setResult( $result, $feed, $feedItems ) {
40 // Store output in the Result data.
41 // This way we can check during execution if any error has occurred
42 // Disable size checking for this because we can't continue
43 // cleanly; size checking would cause more problems than it'd
44 // solve
45 $result->addValue( null, '_feed', $feed, ApiResult::NO_VALIDATE );
46 $result->addValue( null, '_feeditems', $feedItems, ApiResult::NO_VALIDATE );
47 }
48
54 public function getMimeType() {
55 return null;
56 }
57
63 public function canPrintErrors() {
64 return false;
65 }
66
73 public function initPrinter( $unused = false ) {
74 parent::initPrinter( $unused );
75
76 if ( $this->isDisabled() ) {
77 return;
78 }
79
80 $data = $this->getResult()->getResultData();
81 if ( isset( $data['_feed'] ) && isset( $data['_feeditems'] ) ) {
82 $data['_feed']->httpHeaders();
83 } else {
84 // Error has occurred, print something useful
85 ApiBase::dieDebug( __METHOD__, 'Invalid feed class/item' );
86 }
87 }
88
94 public function execute() {
95 $data = $this->getResult()->getResultData();
96 if ( isset( $data['_feed'] ) && isset( $data['_feeditems'] ) ) {
97 $feed = $data['_feed'];
98 $items = $data['_feeditems'];
99
100 // execute() needs to pass strings to $this->printText, not produce output itself.
101 ob_start();
102 $feed->outHeader();
103 foreach ( $items as & $item ) {
104 $feed->outItem( $item );
105 }
106 $feed->outFooter();
107 $this->printText( ob_get_clean() );
108 } else {
109 // Error has occurred, print something useful
110 ApiBase::dieDebug( __METHOD__, 'Invalid feed class/item' );
111 }
112 }
113}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition ApiBase.php:2188
getResult()
Get the result object.
Definition ApiBase.php:632
This is the abstract base class for API formatters.
printText( $text)
Append text to the output buffer.
isDisabled()
Whether the printer is disabled.
This printer is used to wrap an instance of the Feed class.
initPrinter( $unused=false)
This class expects the result data to be in a custom format set by self::setResult() $result['_feed']...
getMimeType()
Feed does its own headers.
execute()
This class expects the result data to be in a custom format set by self::setResult() $result['_feed']...
static setResult( $result, $feed, $feedItems)
Call this method to initialize output data.
canPrintErrors()
ChannelFeed doesn't give us a method to print errors in a friendly manner, so just punt errors to the...
This is the main API class, used for both external and internal processing.
Definition ApiMain.php:41
const NO_VALIDATE
For addValue(), setValue() and similar functions, do not validate data.
Definition ApiResult.php:66
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)