68 LinkBatchFactory $linkBatchFactory,
76 parent::__construct( $context, $linkRenderer );
77 $this->groupPermissionsLookup = $groupPermissionsLookup;
78 $this->hookRunner =
new HookRunner( $hookContainer );
79 $this->linkBatchFactory = $linkBatchFactory;
80 $this->namespaceInfo = $namespaceInfo;
81 $this->changeTagsStore = $changeTagsStore;
82 $this->rowCommentFormatter = $rowCommentFormatter;
83 $this->contentHandlerFactory = $contentHandlerFactory;
84 $this->tempUserConfig = $tempUserConfig;
92 $conds[
'rc_source'] = RecentChange::SRC_NEW;
94 $username = $this->opts->getValue(
'username' );
95 $user = Title::makeTitleSafe(
NS_USER, $username );
97 $size = abs( intval( $this->opts->getValue(
'size' ) ) );
100 if ( $this->opts->getValue(
'size-mode' ) ===
'max' ) {
101 $conds[] = $db->expr(
'page_len',
'<=', $size );
103 $conds[] = $db->expr(
'page_len',
'>=', $size );
108 $conds[
'actor_name'] = $user->getText();
110 } elseif ( $this->opts->getValue(
'hideliu' ) ) {
112 $anonOnlyExpr = $this->
getDatabase()->expr(
'actor_user',
'=',
null );
113 if ( $this->tempUserConfig->isKnown() ) {
114 $anonOnlyExpr = $anonOnlyExpr->orExpr( $this->tempUserConfig->getMatchCondition(
115 $this->getDatabase(),
'actor_name', IExpression::LIKE
118 $conds[] = $anonOnlyExpr;
121 $joinFlags = RecentChange::STRAIGHT_JOIN_ACTOR;
124 $conds = array_merge( $conds, $this->getNamespaceCond() );
126 # If this user cannot see patrolled edits or they are off, don't do dumb queries!
127 if ( $this->opts->getValue(
'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
128 $conds[
'rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
131 if ( $this->opts->getValue(
'hidebots' ) ) {
132 $conds[
'rc_bot'] = 0;
135 if ( $this->opts->getValue(
'hideredirs' ) ) {
136 $conds[
'page_is_redirect'] = 0;
140 $rcQuery = RecentChange::getQueryInfo( $joinFlags );
141 $tables = array_merge( $rcQuery[
'tables'], [
'page' ] );
142 $fields = array_merge( $rcQuery[
'fields'], [
143 'length' =>
'page_len',
'rev_id' =>
'page_latest',
'page_namespace',
'page_title',
144 'page_content_model',
146 $join_conds = [
'page' => [
'JOIN',
'page_id=rc_cur_id' ] ] + $rcQuery[
'joins'];
148 $this->hookRunner->onSpecialNewpagesConditions(
149 $this, $this->opts, $conds, $tables, $fields, $join_conds );
156 'join_conds' => $join_conds
160 $this->changeTagsStore->modifyDisplayQuery(
166 $this->opts[
'tagfilter'],
167 $this->opts[
'tagInvert']
205 $title = Title::newFromRow( $row );
209 $revRecord = $this->revisionFromRcResult( $row, $title );
212 $attribs = [
'data-mw-revid' => $row->rc_this_oldid ];
214 $lang = $this->getLanguage();
215 $time = ChangesList::revDateLink( $revRecord, $this->getUser(), $lang,
null,
'mw-newpages-time' );
217 $linkRenderer = $this->getLinkRenderer();
219 $query = $title->
isRedirect() ? [
'redirect' =>
'no' ] : [];
221 $plink = Html::rawElement(
'bdi', [
'dir' => $lang->getDir() ], $linkRenderer->makeKnownLink(
224 [
'class' =>
'mw-newpages-pagename' ],
228 $linkArr[] = $linkRenderer->makeKnownLink(
230 $this->msg(
'hist' )->text(),
231 [
'class' =>
'mw-newpages-history' ],
232 [
'action' =>
'history' ]
234 if ( $this->contentHandlerFactory->getContentHandler( $title->
getContentModel() )
235 ->supportsDirectEditing()
237 $linkArr[] = $linkRenderer->makeKnownLink(
239 $this->msg(
'editlink' )->text(),
240 [
'class' =>
'mw-newpages-edit' ],
241 [
'action' =>
'edit' ]
244 $links = $this->msg(
'parentheses' )->rawParams( $this->getLanguage()
245 ->pipeList( $linkArr ) )->escaped();
247 $length = Html::rawElement(
249 [
'class' =>
'mw-newpages-length' ],
250 $this->msg(
'brackets' )->rawParams(
251 $this->msg(
'nbytes' )->numParams( $row->length )->escaped()
255 $ulink = Linker::revUserTools( $revRecord );
256 $rc = RecentChange::newFromRow( $row );
257 if ( ChangesList::userCan( $rc, RevisionRecord::DELETED_COMMENT, $this->getAuthority() ) ) {
258 $comment = $this->formattedComments[$rc->mAttribs[
'rc_id']];
260 $comment =
'<span class="comment">' . $this->msg(
'rev-deleted-comment' )->escaped() .
'</span>';
262 if ( ChangesList::isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
263 $deletedClass =
'history-deleted';
264 if ( ChangesList::isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
265 $deletedClass .=
' mw-history-suppressed';
267 $comment =
'<span class="' . $deletedClass .
' comment">' . $comment .
'</span>';
270 if ( $this->getUser()->useNPPatrol() && !$row->rc_patrolled ) {
271 $classes[] =
'not-patrolled';
274 # Add a class for zero byte pages
275 if ( $row->length == 0 ) {
276 $classes[] =
'mw-newpages-zero-byte-page';
280 if ( isset( $row->ts_tags ) ) {
281 [ $tagDisplay, $newClasses ] = $this->tagsCache->getWithSetCallback(
282 $this->tagsCache->makeKey(
284 $this->getUser()->getName(),
287 fn () => ChangeTags::formatSummaryRow(
293 $classes = array_merge( $classes, $newClasses );
298 # Display the old title if the namespace/title has been changed
302 if ( !$title->
equals( $oldTitle ) ) {
303 $oldTitleText = $oldTitle->getPrefixedText();
304 $oldTitleText = Html::rawElement(
306 [
'class' =>
'mw-newpages-oldtitle' ],
307 $this->msg(
'rc-old-title' )->params( $oldTitleText )->escaped()
311 $ret =
"{$time} {$plink} {$links} {$length} {$ulink} {$comment} "
312 .
"{$tagDisplay} {$oldTitleText}";
315 $this->hookRunner->onNewPagesLineEnding(
316 $this, $ret, $row, $classes, $attribs );
317 $attribs = array_filter( $attribs,
318 Sanitizer::isReservedDataAttribute( ... ),
323 $attribs[
'class'] = $classes;
326 return Html::rawElement(
'li', $attribs, $ret ) .
"\n";