50 $feedClasses = $config->get(
'FeedClasses' );
55 if ( !$config->get(
'Feed' ) ) {
59 if ( !isset( $feedClasses[
$params[
'feedformat']] ) ) {
70 'siprop' =>
'general',
71 'list' =>
'watchlist',
72 'wlprop' =>
'title|user|comment|timestamp|ids',
75 'wllimit' => min( 50, $this->
getConfig()->
get(
'FeedLimit' ) )
78 if ( $params[
'wlowner'] !==
null ) {
79 $fauxReqArr[
'wlowner'] =
$params[
'wlowner'];
81 if (
$params[
'wltoken'] !==
null ) {
82 $fauxReqArr[
'wltoken'] =
$params[
'wltoken'];
84 if (
$params[
'wlexcludeuser'] !==
null ) {
85 $fauxReqArr[
'wlexcludeuser'] =
$params[
'wlexcludeuser'];
87 if (
$params[
'wlshow'] !==
null ) {
88 $fauxReqArr[
'wlshow'] =
$params[
'wlshow'];
90 if (
$params[
'wltype'] !==
null ) {
91 $fauxReqArr[
'wltype'] =
$params[
'wltype'];
96 if (
$params[
'linktosections'] ) {
97 $this->linkToSections =
true;
102 $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' ) .
']';
128 $feedUrl = SpecialPage::getTitleFor(
'Watchlist' )->getFullURL();
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' ) .
']';
145 $feedUrl = SpecialPage::getTitleFor(
'Watchlist' )->getFullURL();
147 $feedFormat = isset(
$params[
'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 ) {
155 $errorTitle = $this->
msg(
'api-feed-error-title', $msg->getApiCode() );
156 $errorText = $msg->text();
157 $feedItems[] =
new FeedItem( $errorTitle, $errorText,
'',
'',
'' );
161 $errorCode =
$e->getCodeString();
164 $errorCode =
'internal_api_error';
166 $errorTitle = $this->
msg(
'api-feed-error-title', $errorCode );
167 $errorText =
$e->getMessage();
168 $feedItems[] =
new FeedItem( $errorTitle, $errorText,
'',
'',
'' );
180 if ( !isset( $info[
'title'] ) ) {
185 $titleStr = $info[
'title'];
186 $title = Title::newFromText( $titleStr );
188 if ( !$title || $title->isExternal() ) {
191 if ( isset( $info[
'pageid'] ) ) {
192 $title = Title::newFromID( $info[
'pageid'] );
193 $curidParam = [
'curid' => $info[
'pageid'] ];
195 if ( !$title || $title->isExternal() ) {
199 if ( isset( $info[
'revid'] ) ) {
200 $titleUrl = $title->getFullURL( [
'diff' => $info[
'revid'] ] );
202 $titleUrl = $title->getFullURL( $curidParam );
204 $comment = isset( $info[
'comment'] ) ? $info[
'comment'] :
null;
210 if ( $this->linkToSections && $comment !==
null &&
211 preg_match(
'!(.*)/\*\s*(.*?)\s*\*/(.*)!', $comment,
$matches )
217 $timestamp = $info[
'timestamp'];
219 if ( isset( $info[
'user'] ) ) {
220 $user = $info[
'user'];
221 $completeText =
"$comment ($user)";
224 $completeText = (
string)$comment;
227 return new FeedItem( $titleStr, $completeText, $titleUrl, $timestamp, $user );
231 if ( $this->watchlistModule ===
null ) {
232 $this->watchlistModule = $this->
getMain()->getModuleManager()->getModule(
'query' )
233 ->getModuleManager()->getModule(
'watchlist' );
240 $feedFormatNames = array_keys( $this->
getConfig()->
get(
'FeedClasses' ) );
252 'linktosections' =>
false,
256 'allrev' =>
'allrev',
257 'owner' =>
'wlowner',
258 'token' =>
'wltoken',
261 'excludeuser' =>
'wlexcludeuser',
265 foreach ( $copyParams as $from => $to ) {
266 $p = $wlparams[$from];
267 if ( !is_array( $p ) ) {
285 foreach ( $copyParams as $from => $to ) {
295 'action=feedwatchlist'
296 =>
'apihelp-feedwatchlist-example-default',
297 'action=feedwatchlist&allrev=&hours=6'
298 =>
'apihelp-feedwatchlist-example-all6hrs',
303 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlist_feed';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
getMain()
Get the main module.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
getResult()
Get the result object.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
This action allows users to get their watchlist items in RSS/Atom formats.
getAllowedParams( $flags=0)
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
getCustomPrinter()
This module uses a custom feed wrapper printer.
execute()
Make a nested call to the API to request watchlist items in the last $hours.
This is the main API class, used for both external and internal processing.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
static isMetadataKey( $key)
Test whether a key should be considered metadata.
Exception used to abort API execution with an error.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
WebRequest clone which takes values from a provided array.
A base class for basic support for outputting syndication feeds in RSS and other formats.
This exception will be thrown when dieUsage is called to stop module execution.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
returning false will NOT prevent logging $e