Go to the documentation of this file.
52 $feedClasses = $config->get(
'FeedClasses' );
58 if ( !$config->get(
'Feed' ) ) {
62 if ( !isset( $feedClasses[$params[
'feedformat']] ) ) {
67 $endTime =
wfTimestamp( TS_MW, time() - (
int)$params[
'hours'] * 60 * 60 );
73 'siprop' =>
'general',
74 'list' =>
'watchlist',
75 'wlprop' =>
'title|user|comment|timestamp|ids|loginfo',
78 'wllimit' => min( 50, $this->
getConfig()->
get(
'FeedLimit' ) )
81 if ( $params[
'wlowner'] !==
null ) {
82 $fauxReqArr[
'wlowner'] = $params[
'wlowner'];
84 if ( $params[
'wltoken'] !==
null ) {
85 $fauxReqArr[
'wltoken'] = $params[
'wltoken'];
87 if ( $params[
'wlexcludeuser'] !==
null ) {
88 $fauxReqArr[
'wlexcludeuser'] = $params[
'wlexcludeuser'];
90 if ( $params[
'wlshow'] !==
null ) {
91 $fauxReqArr[
'wlshow'] = $params[
'wlshow'];
93 if ( $params[
'wltype'] !==
null ) {
94 $fauxReqArr[
'wltype'] = $params[
'wltype'];
99 if ( $params[
'linktosections'] ) {
100 $this->linkToSections =
true;
104 if ( $params[
'allrev'] ) {
105 $fauxReqArr[
'wlallrev'] =
'';
110 $module =
new ApiMain( $fauxReq );
113 $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',
268 foreach ( $copyParams as $from => $to ) {
269 $p = $wlparams[$from];
270 if ( !is_array( $p ) ) {
288 foreach ( $copyParams as $from => $to ) {
298 'action=feedwatchlist'
299 =>
'apihelp-feedwatchlist-example-default',
300 'action=feedwatchlist&allrev=&hours=6'
301 =>
'apihelp-feedwatchlist-example-all6hrs',
306 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.
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.
execute()
Make a nested call to the API to request watchlist items in the last $hours.
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.
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.