85 parent::__construct( $main, $action );
86 $this->revisionStore = $revisionStore;
87 $this->linkRenderer = $linkRenderer;
88 $this->linkBatchFactory = $linkBatchFactory;
89 $this->hookContainer = $hookContainer;
90 $this->dbProvider = $dbProvider;
91 $this->namespaceInfo = $namespaceInfo;
92 $this->userFactory = $userFactory;
93 $this->commentFormatter = $commentFormatter;
111 if ( !$config->get( MainConfigNames::Feed ) ) {
115 $feedClasses = $config->get( MainConfigNames::FeedClasses );
116 if ( !isset( $feedClasses[
$params[
'feedformat']] ) ) {
120 if ( $params[
'showsizediff'] && $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
124 $msg = $this->
msg(
'Contributions' )->inContentLanguage()->text();
125 $feedTitle = $config->get( MainConfigNames::Sitename ) .
' - ' . $msg .
126 ' [' . $config->get( MainConfigNames::LanguageCode ) .
']';
129 if ( ExternalUserNames::isExternal( $target ) ) {
131 $feedUrl = SpecialPage::getTitleFor(
'Contributions' )->getFullURL( [
'target' => $target ] );
133 $feedUrl = SpecialPage::getTitleFor(
'Contributions', $target )->getFullURL();
136 $feed =
new $feedClasses[
$params[
'feedformat']] (
138 htmlspecialchars( $msg ),
147 $targetUser = $this->userFactory->newFromName( $target, UserRigorOptions::RIGOR_NONE );
152 'namespace' =>
$params[
'namespace'],
155 'tagFilter' =>
$params[
'tagfilter'],
156 'deletedOnly' =>
$params[
'deletedonly'],
157 'topOnly' =>
$params[
'toponly'],
158 'newOnly' =>
$params[
'newonly'],
159 'hideMinor' =>
$params[
'hideminor'],
160 'showSizeDiff' =>
$params[
'showsizediff'],
163 $this->linkBatchFactory,
164 $this->hookContainer,
166 $this->revisionStore,
167 $this->namespaceInfo,
169 $this->commentFormatter
172 $feedLimit = $this->
getConfig()->get( MainConfigNames::FeedLimit );
173 if ( $pager->getLimit() > $feedLimit ) {
174 $pager->setLimit( $feedLimit );
178 if ( $pager->getNumRows() > 0 ) {
180 $limit = $pager->getLimit();
181 foreach ( $pager->mResult as $row ) {
183 if ( ++$count > $limit ) {
187 if ( $item !==
null ) {
188 $feedItems[] = $item;
201 $hookResult = $this->hookRunner->onApiFeedContributions__feedItem(
204 if ( $feedItem instanceof
FeedItem ) {
207 } elseif ( !$hookResult ) {
212 $title = Title::makeTitle( (
int)$row->page_namespace, $row->page_title );
214 if ( $title && $this->
getAuthority()->authorizeRead(
'read', $title ) ) {
215 $date = $row->rev_timestamp;
216 $comments = $title->getTalkPage()->getFullURL();
217 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, $title );
220 $title->getPrefixedText(),
221 $this->feedItemDesc( $revision ),
222 $title->getFullURL( [
'diff' => $revision->getId() ] ),
224 $this->feedItemAuthor( $revision ),
239 return $user ? $user->getName() :
'';
248 $msg = $this->
msg(
'colon-separator' )->inContentLanguage()->text();
250 $content = $revision->
getContent( SlotRecord::MAIN );
257 $html = nl2br( htmlspecialchars( $content->getText(), ENT_COMPAT ) );
268 return '<p>' . htmlspecialchars( $this->
feedItemAuthor( $revision ) ) . $msg .
269 htmlspecialchars( FeedItem::stripComment( $comment->text ??
'' ) ) .
270 "</p>\n<hr />\n<div>" . $html .
'</div>';
274 $feedFormatNames = array_keys( $this->
getConfig()->
get( MainConfigNames::FeedClasses ) );
278 ParamValidator::PARAM_DEFAULT =>
'rss',
279 ParamValidator::PARAM_TYPE => $feedFormatNames
282 ParamValidator::PARAM_TYPE =>
'user',
283 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'cidr',
'id',
'interwiki' ],
284 ParamValidator::PARAM_REQUIRED =>
true,
287 ParamValidator::PARAM_TYPE =>
'namespace'
290 ParamValidator::PARAM_TYPE =>
'integer'
293 ParamValidator::PARAM_TYPE =>
'integer'
296 ParamValidator::PARAM_ISMULTI =>
true,
298 ParamValidator::PARAM_DEFAULT =>
'',
300 'deletedonly' =>
false,
303 'hideminor' =>
false,
305 ParamValidator::PARAM_DEFAULT =>
false,
309 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
318 'action=feedcontributions&user=Example'
319 =>
'apihelp-feedcontributions-example-simple',
324 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Feedcontributions';
array $params
The job parameters.
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.
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.
__construct(ApiMain $main, $action, RevisionStore $revisionStore, LinkRenderer $linkRenderer, LinkBatchFactory $linkBatchFactory, HookContainer $hookContainer, IConnectionProvider $dbProvider, NamespaceInfo $namespaceInfo, UserFactory $userFactory, CommentFormatter $commentFormatter)
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.
Content object implementation for representing flat text.
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.