45 private $revisionStore;
51 private $linkRenderer;
54 private $linkBatchFactory;
57 private $hookContainer;
60 private $loadBalancer;
63 private $namespaceInfo;
66 private $actorMigration;
72 private $commentFormatter;
105 parent::__construct( $main, $action );
106 $this->revisionStore = $revisionStore;
107 $this->titleParser = $titleParser;
108 $this->linkRenderer = $linkRenderer;
109 $this->linkBatchFactory = $linkBatchFactory;
110 $this->hookContainer = $hookContainer;
111 $this->loadBalancer = $loadBalancer;
112 $this->namespaceInfo = $namespaceInfo;
113 $this->actorMigration = $actorMigration;
114 $this->userFactory = $userFactory;
115 $this->commentFormatter = $commentFormatter;
133 if ( !$config->get( MainConfigNames::Feed ) ) {
137 $feedClasses = $config->get( MainConfigNames::FeedClasses );
138 if ( !isset( $feedClasses[$params[
'feedformat']] ) ) {
142 if ( $params[
'showsizediff'] && $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
146 $msg = $this->
msg(
'Contributions' )->inContentLanguage()->text();
147 $feedTitle = $config->get( MainConfigNames::Sitename ) .
' - ' . $msg .
148 ' [' . $config->get( MainConfigNames::LanguageCode ) .
']';
150 $target = $params[
'user'];
151 if ( ExternalUserNames::isExternal( $target ) ) {
158 $feed =
new $feedClasses[$params[
'feedformat']] (
160 htmlspecialchars( $msg ),
165 $params[
'start'] =
'';
167 $params = ContribsPager::processDateFilter( $params );
169 $targetUser = $this->userFactory->newFromName( $target, UserRigorOptions::RIGOR_NONE );
174 'namespace' => $params[
'namespace'],
175 'start' => $params[
'start'],
176 'end' => $params[
'end'],
177 'tagFilter' => $params[
'tagfilter'],
178 'deletedOnly' => $params[
'deletedonly'],
179 'topOnly' => $params[
'toponly'],
180 'newOnly' => $params[
'newonly'],
181 'hideMinor' => $params[
'hideminor'],
182 'showSizeDiff' => $params[
'showsizediff'],
185 $this->linkBatchFactory,
186 $this->hookContainer,
188 $this->actorMigration,
189 $this->revisionStore,
190 $this->namespaceInfo,
192 $this->commentFormatter
195 $feedLimit = $this->
getConfig()->get( MainConfigNames::FeedLimit );
196 if ( $pager->getLimit() > $feedLimit ) {
197 $pager->setLimit( $feedLimit );
201 if ( $pager->getNumRows() > 0 ) {
203 $limit = $pager->getLimit();
204 foreach ( $pager->mResult as $row ) {
206 if ( ++$count > $limit ) {
210 if ( $item !==
null ) {
211 $feedItems[] = $item;
224 $hookResult = $this->hookRunner->onApiFeedContributions__feedItem(
227 if ( $feedItem instanceof
FeedItem ) {
230 } elseif ( !$hookResult ) {
235 $title = Title::makeTitle( (
int)$row->page_namespace, $row->page_title );
238 $date = $row->rev_timestamp;
239 $comments =
$title->getTalkPage()->getFullURL();
240 $revision = $this->revisionStore->newRevisionFromRow( $row, 0,
$title );
243 $title->getPrefixedText(),
244 $this->feedItemDesc( $revision ),
245 $title->getFullURL( [
'diff' => $revision->getId() ] ),
247 $this->feedItemAuthor( $revision ),
262 return $user ? $user->getName() :
'';
271 $msg = $this->
msg(
'colon-separator' )->inContentLanguage()->text();
280 $html = nl2br( htmlspecialchars(
$content->getText(), ENT_COMPAT ) );
291 return '<p>' . htmlspecialchars( $this->
feedItemAuthor( $revision ) ) . $msg .
292 htmlspecialchars( FeedItem::stripComment( $comment->text ??
'' ) ) .
293 "</p>\n<hr />\n<div>" . $html .
'</div>';
297 $feedFormatNames = array_keys( $this->
getConfig()->
get( MainConfigNames::FeedClasses ) );
301 ParamValidator::PARAM_DEFAULT =>
'rss',
302 ParamValidator::PARAM_TYPE => $feedFormatNames
305 ParamValidator::PARAM_TYPE =>
'user',
306 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'cidr',
'id',
'interwiki' ],
307 ParamValidator::PARAM_REQUIRED =>
true,
310 ParamValidator::PARAM_TYPE =>
'namespace'
313 ParamValidator::PARAM_TYPE =>
'integer'
316 ParamValidator::PARAM_TYPE =>
'integer'
319 ParamValidator::PARAM_ISMULTI =>
true,
321 ParamValidator::PARAM_DEFAULT =>
'',
323 'deletedonly' =>
false,
326 'hideminor' =>
false,
328 ParamValidator::PARAM_DEFAULT =>
false,
332 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
341 'action=feedcontributions&user=Example'
342 =>
'apihelp-feedcontributions-example-simple',
This is not intended to be a long-term part of MediaWiki; it will be deprecated and removed once acto...
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getMain()
Get the main module.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
__construct(ApiMain $main, $action, RevisionStore $revisionStore, TitleParser $titleParser, LinkRenderer $linkRenderer, LinkBatchFactory $linkBatchFactory, HookContainer $hookContainer, ILoadBalancer $loadBalancer, NamespaceInfo $namespaceInfo, ActorMigration $actorMigration, UserFactory $userFactory, CommentFormatter $commentFormatter)
feedItemDesc(RevisionRecord $revision)
feedItemAuthor(RevisionRecord $revision)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCustomPrinter()
This module uses a custom feed wrapper printer.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getExamplesMessages()
Returns usage examples for this module.
This is the main API class, used for both external and internal processing.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
A base class for outputting syndication feeds (e.g.
A class containing constants representing the names of configuration variables.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
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,...
Content object implementation for representing flat text.
A title parser service for MediaWiki.