Go to the documentation of this file.
52 $feedClasses = $config->get(
'FeedClasses' );
57 if ( !$config->get(
'Feed' ) ) {
61 if ( !isset( $feedClasses[$params[
'feedformat']] ) ) {
66 $endTime =
wfTimestamp( TS_MW, time() - (
int)$params[
'hours'] * 60 * 60 );
72 'siprop' =>
'general',
73 'list' =>
'watchlist',
74 'wlprop' =>
'title|user|comment|timestamp|ids|loginfo',
77 'wllimit' => min( 50, $this->
getConfig()->
get(
'FeedLimit' ) )
80 if ( $params[
'wlowner'] !==
null ) {
81 $fauxReqArr[
'wlowner'] = $params[
'wlowner'];
83 if ( $params[
'wltoken'] !==
null ) {
84 $fauxReqArr[
'wltoken'] = $params[
'wltoken'];
86 if ( $params[
'wlexcludeuser'] !==
null ) {
87 $fauxReqArr[
'wlexcludeuser'] = $params[
'wlexcludeuser'];
89 if ( $params[
'wlshow'] !==
null ) {
90 $fauxReqArr[
'wlshow'] = $params[
'wlshow'];
92 if ( $params[
'wltype'] !==
null ) {
93 $fauxReqArr[
'wltype'] = $params[
'wltype'];
98 if ( $params[
'linktosections'] ) {
99 $this->linkToSections =
true;
103 if ( $params[
'allrev'] ) {
104 $fauxReqArr[
'wlallrev'] =
'';
109 $module =
new ApiMain( $fauxReq );
112 $data = $module->getResult()->getResultData( [
'query',
'watchlist' ] );
114 foreach ( (array)$data as $key => $info ) {
120 $feedItems[] = $feedItem;
124 $msg =
wfMessage(
'watchlist' )->inContentLanguage()->text();
126 $feedTitle = $this->
getConfig()->get(
'Sitename' ) .
' - ' . $msg .
127 ' [' . $this->
getConfig()->get(
'LanguageCode' ) .
']';
130 $feed =
new $feedClasses[$params[
'feedformat']] (
132 htmlspecialchars( $msg ),
137 }
catch ( Exception $e ) {
139 $this->
getMain()->setCacheMaxAge( 0 );
142 $feedTitle = $this->
getConfig()->get(
'Sitename' ) .
' - Error - ' .
143 wfMessage(
'watchlist' )->inContentLanguage()->text() .
144 ' [' . $this->
getConfig()->get(
'LanguageCode' ) .
']';
147 $feedFormat = $params[
'feedformat'] ??
'rss';
148 $msg =
wfMessage(
'watchlist' )->inContentLanguage()->escaped();
149 $feed =
new $feedClasses[$feedFormat] ( $feedTitle, $msg, $feedUrl );
152 foreach ( $e->getStatusValue()->getErrors() as $error ) {
156 $errorTitle = $this->
msg(
'api-feed-error-title', $msg->getApiCode() );
157 $errorText = $msg->text();
158 $feedItems[] =
new FeedItem( $errorTitle, $errorText,
'',
'',
'' );
162 $errorCode =
'internal_api_error';
163 $errorTitle = $this->
msg(
'api-feed-error-title', $errorCode );
164 $errorText = $e->getMessage();
165 $feedItems[] =
new FeedItem( $errorTitle, $errorText,
'',
'',
'' );
177 if ( !isset( $info[
'title'] ) ) {
182 $titleStr = $info[
'title'];
188 if ( isset( $info[
'pageid'] ) ) {
190 $curidParam = [
'curid' => $info[
'pageid'] ];
196 if ( isset( $info[
'revid'] ) ) {
197 if ( $info[
'revid'] === 0 && isset( $info[
'logid'] ) ) {
199 $titleUrl = $logTitle->getFullURL( [
'logid' => $info[
'logid'] ] );
201 $titleUrl =
$title->getFullURL( [
'diff' => $info[
'revid'] ] );
204 $titleUrl =
$title->getFullURL( $curidParam );
206 $comment = $info[
'comment'] ??
null;
212 if ( $this->linkToSections && $comment !==
null &&
213 preg_match(
'!(.*)/\*\s*(.*?)\s*\*/(.*)!', $comment,
$matches )
215 $titleUrl .= MediaWikiServices::getInstance()->getParser()
216 ->guessSectionNameFromWikiText(
$matches[ 2 ] );
219 $timestamp = $info[
'timestamp'];
221 if ( isset( $info[
'user'] ) ) {
222 $user = $info[
'user'];
223 $completeText =
"$comment ($user)";
226 $completeText = (string)$comment;
229 return new FeedItem( $titleStr, $completeText, $titleUrl, $timestamp, $user );
233 if ( $this->watchlistModule ===
null ) {
234 $this->watchlistModule = $this->
getMain()->getModuleManager()->getModule(
'query' )
235 ->getModuleManager()->getModule(
'watchlist' );
242 $feedFormatNames = array_keys( $this->
getConfig()->
get(
'FeedClasses' ) );
254 'linktosections' =>
false,
258 'allrev' =>
'allrev',
259 'owner' =>
'wlowner',
260 'token' =>
'wltoken',
263 'excludeuser' =>
'wlexcludeuser',
267 foreach ( $copyParams as $from => $to ) {
268 $p = $wlparams[$from];
269 if ( !is_array( $p ) ) {
287 foreach ( $copyParams as $from => $to ) {
297 'action=feedwatchlist'
298 =>
'apihelp-feedwatchlist-example-default',
299 'action=feedwatchlist&allrev=&hours=6'
300 =>
'apihelp-feedwatchlist-example-all6hrs',
305 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlist_feed';
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams( $flags=0)
This is the main API class, used for both external and internal processing.
WebRequest clone which takes values from a provided array.
This action allows users to get their watchlist items in RSS/Atom formats.
A base class for outputting syndication feeds (e.g.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Exception used to abort API execution with an error.
getCustomPrinter()
This module uses a custom feed wrapper printer.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getHelpUrls()
Return links to more detailed help pages about the module.
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
execute()
Make a nested call to the API to request watchlist items in the last $hours.
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
static isMetadataKey( $key)
Test whether a key should be considered metadata.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getMain()
Get the main module.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
static newFromID( $id, $flags=0)
Create a new Title from an article ID.