89 parent::__construct( $context, $linkRenderer );
90 $this->groupPermissionsLookup = $groupPermissionsLookup;
91 $this->hookRunner =
new HookRunner( $hookContainer );
92 $this->linkBatchFactory = $linkBatchFactory;
93 $this->namespaceInfo = $namespaceInfo;
94 $this->changeTagsStore = $changeTagsStore;
95 $this->rowCommentFormatter = $rowCommentFormatter;
96 $this->contentHandlerFactory = $contentHandlerFactory;
97 $this->tempUserConfig = $tempUserConfig;
103 $rcQuery = RecentChange::getQueryInfo();
106 $conds[
'rc_new'] = 1;
108 $username = $this->opts->getValue(
'username' );
109 $user = Title::makeTitleSafe(
NS_USER, $username );
111 $size = abs( intval( $this->opts->getValue(
'size' ) ) );
114 if ( $this->opts->getValue(
'size-mode' ) ===
'max' ) {
115 $conds[] = $db->expr(
'page_len',
'<=', $size );
117 $conds[] = $db->expr(
'page_len',
'>=', $size );
122 $conds[
'actor_name'] = $user->getText();
123 } elseif ( $this->opts->getValue(
'hideliu' ) ) {
125 $anonOnlyExpr = $this->
getDatabase()->expr(
'actor_user',
'=',
null );
126 if ( $this->tempUserConfig->isKnown() ) {
127 $anonOnlyExpr = $anonOnlyExpr->orExpr( $this->tempUserConfig->getMatchCondition(
128 $this->getDatabase(),
'actor_name', IExpression::LIKE
131 $conds[] = $anonOnlyExpr;
134 $conds = array_merge( $conds, $this->getNamespaceCond() );
136 # If this user cannot see patrolled edits or they are off, don't do dumb queries!
137 if ( $this->opts->getValue(
'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
138 $conds[
'rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
141 if ( $this->opts->getValue(
'hidebots' ) ) {
142 $conds[
'rc_bot'] = 0;
145 if ( $this->opts->getValue(
'hideredirs' ) ) {
146 $conds[
'page_is_redirect'] = 0;
150 $tables = array_merge( $rcQuery[
'tables'], [
'page' ] );
151 $fields = array_merge( $rcQuery[
'fields'], [
152 'length' =>
'page_len',
'rev_id' =>
'page_latest',
'page_namespace',
'page_title',
153 'page_content_model',
155 $join_conds = [
'page' => [
'JOIN',
'page_id=rc_cur_id' ] ] + $rcQuery[
'joins'];
157 $this->hookRunner->onSpecialNewpagesConditions(
158 $this, $this->opts, $conds, $tables, $fields, $join_conds );
165 'join_conds' => $join_conds
169 $this->changeTagsStore->modifyDisplayQuery(
175 $this->opts[
'tagfilter'],
176 $this->opts[
'tagInvert']
213 $title = Title::newFromRow( $row );
220 $attribs = [
'data-mw-revid' => $row->rc_this_oldid ];
223 $time = ChangesList::revDateLink( $revRecord, $this->
getUser(), $lang,
null,
'mw-newpages-time' );
227 $query = $title->
isRedirect() ? [
'redirect' =>
'no' ] : [];
229 $plink = Html::rawElement(
'bdi', [
'dir' => $lang->getDir() ], $linkRenderer->makeKnownLink(
232 [
'class' =>
'mw-newpages-pagename' ],
236 $linkArr[] = $linkRenderer->makeKnownLink(
238 $this->
msg(
'hist' )->text(),
239 [
'class' =>
'mw-newpages-history' ],
240 [
'action' =>
'history' ]
242 if ( $this->contentHandlerFactory->getContentHandler( $title->
getContentModel() )
243 ->supportsDirectEditing()
245 $linkArr[] = $linkRenderer->makeKnownLink(
247 $this->
msg(
'editlink' )->text(),
248 [
'class' =>
'mw-newpages-edit' ],
249 [
'action' =>
'edit' ]
252 $links = $this->
msg(
'parentheses' )->rawParams( $this->
getLanguage()
253 ->pipeList( $linkArr ) )->escaped();
255 $length = Html::rawElement(
257 [
'class' =>
'mw-newpages-length' ],
258 $this->
msg(
'brackets' )->rawParams(
259 $this->
msg(
'nbytes' )->numParams( $row->length )->escaped()
263 $ulink = Linker::revUserTools( $revRecord );
264 $rc = RecentChange::newFromRow( $row );
265 if ( ChangesList::userCan( $rc, RevisionRecord::DELETED_COMMENT, $this->
getAuthority() ) ) {
266 $comment = $this->formattedComments[$rc->mAttribs[
'rc_id']];
268 $comment =
'<span class="comment">' . $this->
msg(
'rev-deleted-comment' )->escaped() .
'</span>';
270 if ( ChangesList::isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
271 $deletedClass =
'history-deleted';
272 if ( ChangesList::isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
273 $deletedClass .=
' mw-history-suppressed';
275 $comment =
'<span class="' . $deletedClass .
' comment">' . $comment .
'</span>';
278 if ( $this->
getUser()->useNPPatrol() && !$row->rc_patrolled ) {
279 $classes[] =
'not-patrolled';
282 # Add a class for zero byte pages
283 if ( $row->length == 0 ) {
284 $classes[] =
'mw-newpages-zero-byte-page';
288 if ( isset( $row->ts_tags ) ) {
289 [ $tagDisplay, $newClasses ] = $this->tagsCache->getWithSetCallback(
290 $this->tagsCache->makeKey(
292 $this->getUser()->getName(),
295 fn () => ChangeTags::formatSummaryRow(
301 $classes = array_merge( $classes, $newClasses );
306 # Display the old title if the namespace/title has been changed
308 $oldTitle = Title::makeTitle( $row->rc_namespace, $row->rc_title );
310 if ( !$title->
equals( $oldTitle ) ) {
311 $oldTitleText = $oldTitle->getPrefixedText();
312 $oldTitleText = Html::rawElement(
314 [
'class' =>
'mw-newpages-oldtitle' ],
315 $this->
msg(
'rc-old-title' )->params( $oldTitleText )->escaped()
319 $ret =
"{$time} {$plink} {$links} {$length} {$ulink} {$comment} "
320 .
"{$tagDisplay} {$oldTitleText}";
323 $this->hookRunner->onNewPagesLineEnding(
324 $this, $ret, $row, $classes, $attribs );
325 $attribs = array_filter( $attribs,
326 [ Sanitizer::class,
'isReservedDataAttribute' ],
331 $attribs[
'class'] = $classes;
334 return Html::rawElement(
'li', $attribs, $ret ) .
"\n";
358 $linkBatch = $this->linkBatchFactory->newLinkBatch();
359 foreach ( $this->mResult as $row ) {
360 $linkBatch->addUser(
new UserIdentityValue( (
int)$row->rc_user, $row->rc_user_text ) );
361 $linkBatch->add( $row->page_namespace, $row->page_title );
363 $linkBatch->execute();
365 $this->formattedComments = $this->rowCommentFormatter->formatRows(
366 $this->mResult,
'rc_comment',
'page_namespace',
'page_title',
'rc_id',
true