MediaWiki
REL1_30
ApiFormatFeedWrapper.php
Go to the documentation of this file.
1
<?php
31
class
ApiFormatFeedWrapper
extends
ApiFormatBase
{
32
33
public
function
__construct
(
ApiMain
$main ) {
34
parent::__construct( $main,
'feed'
);
35
}
36
43
public
static
function
setResult
( $result, $feed, $feedItems ) {
44
// Store output in the Result data.
45
// This way we can check during execution if any error has occurred
46
// Disable size checking for this because we can't continue
47
// cleanly; size checking would cause more problems than it'd
48
// solve
49
$result->addValue(
null
,
'_feed'
, $feed,
ApiResult::NO_VALIDATE
);
50
$result->addValue(
null
,
'_feeditems'
, $feedItems,
ApiResult::NO_VALIDATE
);
51
}
52
58
public
function
getMimeType
() {
59
return
null
;
60
}
61
67
public
function
canPrintErrors
() {
68
return
false
;
69
}
70
77
public
function
initPrinter
( $unused =
false
) {
78
parent::initPrinter( $unused );
79
80
if
( $this->
isDisabled
() ) {
81
return
;
82
}
83
84
$data = $this->
getResult
()->getResultData();
85
if
( isset( $data[
'_feed'
] ) && isset( $data[
'_feeditems'
] ) ) {
86
$data[
'_feed'
]->httpHeaders();
87
}
else
{
88
// Error has occurred, print something useful
89
ApiBase::dieDebug
( __METHOD__,
'Invalid feed class/item'
);
90
}
91
}
92
98
public
function
execute
() {
99
$data = $this->
getResult
()->getResultData();
100
if
( isset( $data[
'_feed'
] ) && isset( $data[
'_feeditems'
] ) ) {
101
$feed = $data[
'_feed'
];
102
$items = $data[
'_feeditems'
];
103
104
// execute() needs to pass strings to $this->printText, not produce output itself.
105
ob_start();
106
$feed->outHeader();
107
foreach
( $items as & $item ) {
108
$feed->outItem( $item );
109
}
110
$feed->outFooter();
111
$this->
printText
( ob_get_clean() );
112
}
else
{
113
// Error has occurred, print something useful
114
ApiBase::dieDebug
( __METHOD__,
'Invalid feed class/item'
);
115
}
116
}
117
}
ApiBase\dieDebug
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition
ApiBase.php:2038
ApiBase\getResult
getResult()
Get the result object.
Definition
ApiBase.php:632
ApiFormatBase
This is the abstract base class for API formatters.
Definition
ApiFormatBase.php:32
ApiFormatBase\printText
printText( $text)
Append text to the output buffer.
Definition
ApiFormatBase.php:336
ApiFormatBase\isDisabled
isDisabled()
Whether the printer is disabled.
Definition
ApiFormatBase.php:127
ApiFormatFeedWrapper
This printer is used to wrap an instance of the Feed class.
Definition
ApiFormatFeedWrapper.php:31
ApiFormatFeedWrapper\initPrinter
initPrinter( $unused=false)
This class expects the result data to be in a custom format set by self::setResult() $result['_feed']...
Definition
ApiFormatFeedWrapper.php:77
ApiFormatFeedWrapper\__construct
__construct(ApiMain $main)
Definition
ApiFormatFeedWrapper.php:33
ApiFormatFeedWrapper\getMimeType
getMimeType()
Feed does its own headers.
Definition
ApiFormatFeedWrapper.php:58
ApiFormatFeedWrapper\execute
execute()
This class expects the result data to be in a custom format set by self::setResult() $result['_feed']...
Definition
ApiFormatFeedWrapper.php:98
ApiFormatFeedWrapper\setResult
static setResult( $result, $feed, $feedItems)
Call this method to initialize output data.
Definition
ApiFormatFeedWrapper.php:43
ApiFormatFeedWrapper\canPrintErrors
canPrintErrors()
ChannelFeed doesn't give us a method to print errors in a friendly manner, so just punt errors to the...
Definition
ApiFormatFeedWrapper.php:67
ApiMain
This is the main API class, used for both external and internal processing.
Definition
ApiMain.php:45
ApiResult\NO_VALIDATE
const NO_VALIDATE
For addValue(), setValue() and similar functions, do not validate data.
Definition
ApiResult.php:64
includes
api
ApiFormatFeedWrapper.php
Generated on Mon Nov 25 2024 15:42:03 for MediaWiki by
1.10.0