84 parent::__construct( $main, $action );
85 $this->revisionStore = $revisionStore;
86 $this->linkRenderer = $linkRenderer;
87 $this->linkBatchFactory = $linkBatchFactory;
88 $this->hookContainer = $hookContainer;
89 $this->dbProvider = $dbProvider;
90 $this->namespaceInfo = $namespaceInfo;
91 $this->userFactory = $userFactory;
92 $this->commentFormatter = $commentFormatter;
110 if ( !$config->get( MainConfigNames::Feed ) ) {
114 $feedClasses = $config->get( MainConfigNames::FeedClasses );
115 if ( !isset( $feedClasses[
$params[
'feedformat']] ) ) {
119 if ( $params[
'showsizediff'] && $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
123 $msg = $this->
msg(
'Contributions' )->inContentLanguage()->text();
124 $feedTitle = $config->get( MainConfigNames::Sitename ) .
' - ' . $msg .
125 ' [' . $config->get( MainConfigNames::LanguageCode ) .
']';
128 if ( ExternalUserNames::isExternal( $target ) ) {
130 $feedUrl = SpecialPage::getTitleFor(
'Contributions' )->getFullURL( [
'target' => $target ] );
132 $feedUrl = SpecialPage::getTitleFor(
'Contributions', $target )->getFullURL();
135 $feed =
new $feedClasses[
$params[
'feedformat']] (
137 htmlspecialchars( $msg ),
146 $targetUser = $this->userFactory->newFromName( $target, UserRigorOptions::RIGOR_NONE );
151 'namespace' =>
$params[
'namespace'],
154 'tagFilter' =>
$params[
'tagfilter'],
155 'deletedOnly' =>
$params[
'deletedonly'],
156 'topOnly' =>
$params[
'toponly'],
157 'newOnly' =>
$params[
'newonly'],
158 'hideMinor' =>
$params[
'hideminor'],
159 'showSizeDiff' =>
$params[
'showsizediff'],
162 $this->linkBatchFactory,
163 $this->hookContainer,
165 $this->revisionStore,
166 $this->namespaceInfo,
168 $this->commentFormatter
171 $feedLimit = $this->
getConfig()->get( MainConfigNames::FeedLimit );
172 if ( $pager->getLimit() > $feedLimit ) {
173 $pager->setLimit( $feedLimit );
177 if ( $pager->getNumRows() > 0 ) {
179 $limit = $pager->getLimit();
180 foreach ( $pager->mResult as $row ) {
182 if ( ++$count > $limit ) {
186 if ( $item !==
null ) {
187 $feedItems[] = $item;
200 $hookResult = $this->hookRunner->onApiFeedContributions__feedItem(
203 if ( $feedItem instanceof
FeedItem ) {
206 } elseif ( !$hookResult ) {
211 $title = Title::makeTitle( (
int)$row->page_namespace, $row->page_title );
213 if ( $title && $this->
getAuthority()->authorizeRead(
'read', $title ) ) {
214 $date = $row->rev_timestamp;
215 $comments = $title->getTalkPage()->getFullURL();
216 $revision = $this->revisionStore->newRevisionFromRow( $row, 0, $title );
219 $title->getPrefixedText(),
220 $this->feedItemDesc( $revision ),
221 $title->getFullURL( [
'diff' => $revision->getId() ] ),
223 $this->feedItemAuthor( $revision ),
238 return $user ? $user->getName() :
'';
247 $msg = $this->
msg(
'colon-separator' )->inContentLanguage()->text();
249 $content = $revision->
getContent( SlotRecord::MAIN );
256 $html = nl2br( htmlspecialchars( $content->getText(), ENT_COMPAT ) );
267 return '<p>' . htmlspecialchars( $this->
feedItemAuthor( $revision ) ) . $msg .
268 htmlspecialchars( FeedItem::stripComment( $comment->text ??
'' ) ) .
269 "</p>\n<hr />\n<div>" . $html .
'</div>';
273 $feedFormatNames = array_keys( $this->
getConfig()->
get( MainConfigNames::FeedClasses ) );
277 ParamValidator::PARAM_DEFAULT =>
'rss',
278 ParamValidator::PARAM_TYPE => $feedFormatNames
281 ParamValidator::PARAM_TYPE =>
'user',
282 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'cidr',
'id',
'interwiki' ],
283 ParamValidator::PARAM_REQUIRED =>
true,
286 ParamValidator::PARAM_TYPE =>
'namespace'
289 ParamValidator::PARAM_TYPE =>
'integer'
292 ParamValidator::PARAM_TYPE =>
'integer'
295 ParamValidator::PARAM_ISMULTI =>
true,
297 ParamValidator::PARAM_DEFAULT =>
'',
299 'deletedonly' =>
false,
302 'hideminor' =>
false,
304 ParamValidator::PARAM_DEFAULT =>
false,
308 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
317 'action=feedcontributions&user=Example'
318 =>
'apihelp-feedcontributions-example-simple',
323 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.
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.