88 parent::__construct( $main, $action );
89 $this->revisionStore = $revisionStore;
90 $this->titleParser = $titleParser;
91 $this->linkRenderer = $linkRenderer;
92 $this->linkBatchFactory = $linkBatchFactory;
93 $this->hookContainer = $hookContainer;
94 $this->dbProvider = $dbProvider;
95 $this->namespaceInfo = $namespaceInfo;
96 $this->userFactory = $userFactory;
97 $this->commentFormatter = $commentFormatter;
115 if ( !$config->get( MainConfigNames::Feed ) ) {
119 $feedClasses = $config->get( MainConfigNames::FeedClasses );
120 if ( !isset( $feedClasses[$params[
'feedformat']] ) ) {
124 if ( $params[
'showsizediff'] && $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
128 $msg = $this->
msg(
'Contributions' )->inContentLanguage()->text();
129 $feedTitle = $config->get( MainConfigNames::Sitename ) .
' - ' . $msg .
130 ' [' . $config->get( MainConfigNames::LanguageCode ) .
']';
132 $target = $params[
'user'];
133 if ( ExternalUserNames::isExternal( $target ) ) {
135 $feedUrl = SpecialPage::getTitleFor(
'Contributions' )->getFullURL( [
'target' => $target ] );
137 $feedUrl = SpecialPage::getTitleFor(
'Contributions', $target )->getFullURL();
140 $feed =
new $feedClasses[$params[
'feedformat']] (
142 htmlspecialchars( $msg ),
147 $params[
'start'] =
'';
149 $params = ContribsPager::processDateFilter( $params );
151 $targetUser = $this->userFactory->newFromName( $target, UserRigorOptions::RIGOR_NONE );
156 'namespace' => $params[
'namespace'],
157 'start' => $params[
'start'],
158 'end' => $params[
'end'],
159 'tagFilter' => $params[
'tagfilter'],
160 'deletedOnly' => $params[
'deletedonly'],
161 'topOnly' => $params[
'toponly'],
162 'newOnly' => $params[
'newonly'],
163 'hideMinor' => $params[
'hideminor'],
164 'showSizeDiff' => $params[
'showsizediff'],
167 $this->linkBatchFactory,
168 $this->hookContainer,
170 $this->revisionStore,
171 $this->namespaceInfo,
173 $this->commentFormatter
176 $feedLimit = $this->
getConfig()->get( MainConfigNames::FeedLimit );
177 if ( $pager->getLimit() > $feedLimit ) {
178 $pager->setLimit( $feedLimit );
182 if ( $pager->getNumRows() > 0 ) {
184 $limit = $pager->getLimit();
185 foreach ( $pager->mResult as $row ) {
187 if ( ++$count > $limit ) {
191 if ( $item !==
null ) {
192 $feedItems[] = $item;
205 $hookResult = $this->hookRunner->onApiFeedContributions__feedItem(
208 if ( $feedItem instanceof
FeedItem ) {
211 } elseif ( !$hookResult ) {
216 $title = Title::makeTitle( (
int)$row->page_namespace, $row->page_title );
218 if ( $title && $this->
getAuthority()->authorizeRead(
'read', $title ) ) {
219 $date = $row->rev_timestamp;
220 $comments = $title->getTalkPage()->getFullURL();
221 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, $title );
224 $title->getPrefixedText(),
225 $this->feedItemDesc( $revision ),
226 $title->getFullURL( [
'diff' => $revision->getId() ] ),
228 $this->feedItemAuthor( $revision ),
243 return $user ? $user->getName() :
'';
252 $msg = $this->
msg(
'colon-separator' )->inContentLanguage()->text();
261 $html = nl2br( htmlspecialchars(
$content->getText(), ENT_COMPAT ) );
272 return '<p>' . htmlspecialchars( $this->
feedItemAuthor( $revision ) ) . $msg .
273 htmlspecialchars( FeedItem::stripComment( $comment->text ??
'' ) ) .
274 "</p>\n<hr />\n<div>" . $html .
'</div>';
278 $feedFormatNames = array_keys( $this->
getConfig()->
get( MainConfigNames::FeedClasses ) );
282 ParamValidator::PARAM_DEFAULT =>
'rss',
283 ParamValidator::PARAM_TYPE => $feedFormatNames
286 ParamValidator::PARAM_TYPE =>
'user',
287 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'cidr',
'id',
'interwiki' ],
288 ParamValidator::PARAM_REQUIRED =>
true,
291 ParamValidator::PARAM_TYPE =>
'namespace'
294 ParamValidator::PARAM_TYPE =>
'integer'
297 ParamValidator::PARAM_TYPE =>
'integer'
300 ParamValidator::PARAM_ISMULTI =>
true,
302 ParamValidator::PARAM_DEFAULT =>
'',
304 'deletedonly' =>
false,
307 'hideminor' =>
false,
309 ParamValidator::PARAM_DEFAULT =>
false,
313 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
322 'action=feedcontributions&user=Example'
323 =>
'apihelp-feedcontributions-example-simple',
328 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Feedcontributions';
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, IConnectionProvider $dbProvider, NamespaceInfo $namespaceInfo, 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...
getHelpUrls()
Return links to more detailed help pages about the module.
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.
Parent class for all special pages.
Content object implementation for representing flat text.