48 private $revisionStore;
54 private $linkRenderer;
57 private $linkBatchFactory;
60 private $hookContainer;
63 private $loadBalancer;
66 private $namespaceInfo;
69 private $actorMigration;
75 private $commentFormatter;
108 parent::__construct( $main, $action );
109 $this->revisionStore = $revisionStore;
110 $this->titleParser = $titleParser;
111 $this->linkRenderer = $linkRenderer;
112 $this->linkBatchFactory = $linkBatchFactory;
113 $this->hookContainer = $hookContainer;
114 $this->loadBalancer = $loadBalancer;
115 $this->namespaceInfo = $namespaceInfo;
116 $this->actorMigration = $actorMigration;
117 $this->userFactory = $userFactory;
118 $this->commentFormatter = $commentFormatter;
136 if ( !$config->get( MainConfigNames::Feed ) ) {
140 $feedClasses = $config->get( MainConfigNames::FeedClasses );
141 if ( !isset( $feedClasses[$params[
'feedformat']] ) ) {
145 if ( $params[
'showsizediff'] && $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
149 $msg = $this->
msg(
'Contributions' )->inContentLanguage()->text();
150 $feedTitle = $config->get( MainConfigNames::Sitename ) .
' - ' . $msg .
151 ' [' . $config->get( MainConfigNames::LanguageCode ) .
']';
153 $target = $params[
'user'];
154 if ( ExternalUserNames::isExternal( $target ) ) {
161 $feed =
new $feedClasses[$params[
'feedformat']] (
163 htmlspecialchars( $msg ),
168 $params[
'start'] =
'';
170 $params = ContribsPager::processDateFilter( $params );
172 $targetUser = $this->userFactory->newFromName( $target, UserRigorOptions::RIGOR_NONE );
177 'namespace' => $params[
'namespace'],
178 'start' => $params[
'start'],
179 'end' => $params[
'end'],
180 'tagFilter' => $params[
'tagfilter'],
181 'deletedOnly' => $params[
'deletedonly'],
182 'topOnly' => $params[
'toponly'],
183 'newOnly' => $params[
'newonly'],
184 'hideMinor' => $params[
'hideminor'],
185 'showSizeDiff' => $params[
'showsizediff'],
188 $this->linkBatchFactory,
189 $this->hookContainer,
191 $this->actorMigration,
192 $this->revisionStore,
193 $this->namespaceInfo,
195 $this->commentFormatter
198 $feedLimit = $this->
getConfig()->get( MainConfigNames::FeedLimit );
199 if ( $pager->getLimit() > $feedLimit ) {
200 $pager->setLimit( $feedLimit );
204 if ( $pager->getNumRows() > 0 ) {
206 $limit = $pager->getLimit();
207 foreach ( $pager->mResult as $row ) {
209 if ( ++$count > $limit ) {
213 if ( $item !==
null ) {
214 $feedItems[] = $item;
227 $hookResult = $this->hookRunner->onApiFeedContributions__feedItem(
230 if ( $feedItem instanceof
FeedItem ) {
233 } elseif ( !$hookResult ) {
238 $title = Title::makeTitle( (
int)$row->page_namespace, $row->page_title );
241 $date = $row->rev_timestamp;
242 $comments =
$title->getTalkPage()->getFullURL();
243 $revision = $this->revisionStore->newRevisionFromRow( $row, 0,
$title );
246 $title->getPrefixedText(),
247 $this->feedItemDesc( $revision ),
248 $title->getFullURL( [
'diff' => $revision->getId() ] ),
250 $this->feedItemAuthor( $revision ),
265 return $user ? $user->getName() :
'';
274 $msg = $this->
msg(
'colon-separator' )->inContentLanguage()->text();
283 $html = nl2br( htmlspecialchars(
$content->getText(), ENT_COMPAT ) );
294 return '<p>' . htmlspecialchars( $this->
feedItemAuthor( $revision ) ) . $msg .
295 htmlspecialchars( FeedItem::stripComment( $comment->text ??
'' ) ) .
296 "</p>\n<hr />\n<div>" . $html .
'</div>';
300 $feedFormatNames = array_keys( $this->
getConfig()->
get( MainConfigNames::FeedClasses ) );
304 ParamValidator::PARAM_DEFAULT =>
'rss',
305 ParamValidator::PARAM_TYPE => $feedFormatNames
308 ParamValidator::PARAM_TYPE =>
'user',
309 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'cidr',
'id',
'interwiki' ],
310 ParamValidator::PARAM_REQUIRED =>
true,
313 ParamValidator::PARAM_TYPE =>
'namespace'
316 ParamValidator::PARAM_TYPE =>
'integer'
319 ParamValidator::PARAM_TYPE =>
'integer'
322 ParamValidator::PARAM_ISMULTI =>
true,
324 ParamValidator::PARAM_DEFAULT =>
'',
326 'deletedonly' =>
false,
329 'hideminor' =>
false,
331 ParamValidator::PARAM_DEFAULT =>
false,
335 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
344 'action=feedcontributions&user=Example'
345 =>
'apihelp-feedcontributions-example-simple',
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 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.