94 parent::__construct( $context, $linkRenderer );
95 $this->groupPermissionsLookup = $groupPermissionsLookup;
96 $this->hookRunner =
new HookRunner( $hookContainer );
97 $this->linkBatchFactory = $linkBatchFactory;
98 $this->namespaceInfo = $namespaceInfo;
99 $this->changeTagsStore = $changeTagsStore;
100 $this->commentStore = $commentStore;
101 $this->commentFormatter = $commentFormatter;
102 $this->contentHandlerFactory = $contentHandlerFactory;
110 $conds[
'rc_new'] = 1;
112 $username = $this->opts->getValue(
'username' );
115 $size = abs( intval( $this->opts->getValue(
'size' ) ) );
117 if ( $this->opts->getValue(
'size-mode' ) ===
'max' ) {
118 $conds[] =
'page_len <= ' . $size;
120 $conds[] =
'page_len >= ' . $size;
125 $conds[
'actor_name'] = $user->getText();
126 } elseif ( $this->canAnonymousUsersCreatePages() && $this->opts->getValue(
'hideliu' ) ) {
127 # If anons cannot make new pages, don't "exclude logged in users"!
128 $conds[
'actor_user'] =
null;
131 $conds = array_merge( $conds, $this->getNamespaceCond() );
133 # If this user cannot see patrolled edits or they are off, don't do dumb queries!
134 if ( $this->opts->getValue(
'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
138 if ( $this->opts->getValue(
'hidebots' ) ) {
139 $conds[
'rc_bot'] = 0;
142 if ( $this->opts->getValue(
'hideredirs' ) ) {
143 $conds[
'page_is_redirect'] = 0;
147 $tables = array_merge( $rcQuery[
'tables'], [
'page' ] );
148 $fields = array_merge( $rcQuery[
'fields'], [
149 'length' =>
'page_len',
'rev_id' =>
'page_latest',
'page_namespace',
'page_title',
150 'page_content_model',
152 $join_conds = [
'page' => [
'JOIN',
'page_id=rc_cur_id' ] ] + $rcQuery[
'joins'];
154 $this->hookRunner->onSpecialNewpagesConditions(
155 $this, $this->opts, $conds, $tables, $fields, $join_conds );
162 'join_conds' => $join_conds
166 $this->changeTagsStore->modifyDisplayQuery(
172 $this->opts[
'tagfilter'],
173 $this->opts[
'tagInvert']
179 private function canAnonymousUsersCreatePages() {
180 return $this->groupPermissionsLookup->groupHasPermission(
'*',
'createpage' ) ||
181 $this->groupPermissionsLookup->groupHasPermission(
'*',
'createtalk' );
185 private function getNamespaceCond() {
186 $namespace = $this->opts->getValue(
'namespace' );
187 if ( $namespace ===
'all' || $namespace ===
'' ) {
191 $namespace = intval( $namespace );
197 $invert = $this->opts->getValue(
'invert' );
198 $associated = $this->opts->getValue(
'associated' );
200 $eq_op = $invert ?
'!=' :
'=';
201 $bool_op = $invert ?
'AND' :
'OR';
204 $selectedNS = $dbr->addQuotes( $namespace );
205 if ( !$associated ) {
206 return [
"rc_namespace $eq_op $selectedNS" ];
209 $associatedNS = $dbr->addQuotes(
210 $this->namespaceInfo->getAssociated( $namespace )
213 "rc_namespace $eq_op $selectedNS " .
215 " rc_namespace $eq_op $associatedNS"
220 return [ [
'rc_timestamp',
'rc_id' ] ];
231 $attribs = [
'data-mw-revid' => $row->rev_id ];
234 $dm = $lang->getDirMark();
236 $spanTime =
Html::element(
'span', [
'class' =>
'mw-newpages-time' ],
237 $lang->userTimeAndDate( $row->rc_timestamp, $this->getUser() )
240 $time = $linkRenderer->makeKnownLink(
244 [
'oldid' => $row->rc_this_oldid ]
247 $query = $title->
isRedirect() ? [
'redirect' =>
'no' ] : [];
249 $plink = $linkRenderer->makeKnownLink(
252 [
'class' =>
'mw-newpages-pagename' ],
256 $linkArr[] = $linkRenderer->makeKnownLink(
258 $this->
msg(
'hist' )->text(),
259 [
'class' =>
'mw-newpages-history' ],
260 [
'action' =>
'history' ]
262 if ( $this->contentHandlerFactory->getContentHandler( $title->
getContentModel() )
263 ->supportsDirectEditing()
265 $linkArr[] = $linkRenderer->makeKnownLink(
267 $this->
msg(
'editlink' )->text(),
268 [
'class' =>
'mw-newpages-edit' ],
269 [
'action' =>
'edit' ]
272 $links = $this->
msg(
'parentheses' )->rawParams( $this->
getLanguage()
273 ->pipeList( $linkArr ) )->escaped();
277 [
'class' =>
'mw-newpages-length' ],
278 $this->
msg(
'brackets' )->rawParams(
279 $this->
msg(
'nbytes' )->numParams( $row->length )->escaped()
284 $comment = $this->commentFormatter->formatRevision( $revRecord, $this->
getAuthority() );
286 if ( $this->
getUser()->useNPPatrol() && !$row->rc_patrolled ) {
287 $classes[] =
'not-patrolled';
290 # Add a class for zero byte pages
291 if ( $row->length == 0 ) {
292 $classes[] =
'mw-newpages-zero-byte-page';
296 if ( isset( $row->ts_tags ) ) {
302 $classes = array_merge( $classes, $newClasses );
307 # Display the old title if the namespace/title has been changed
311 if ( !$title->
equals( $oldTitle ) ) {
312 $oldTitleText = $oldTitle->getPrefixedText();
315 [
'class' =>
'mw-newpages-oldtitle' ],
316 $this->
msg(
'rc-old-title' )->params( $oldTitleText )->escaped()
320 $ret =
"{$time} {$dm}{$plink} {$links} {$dm}{$length} {$dm}{$ulink} {$comment} "
321 .
"{$tagDisplay} {$oldTitleText}";
324 $this->hookRunner->onNewPagesLineEnding(
325 $this, $ret, $row, $classes, $attribs );
326 $attribs = array_filter( $attribs,
327 [ Sanitizer::class,
'isReservedDataAttribute' ],
332 $attribs[
'class'] = $classes;
346 $this->commentStore->getComment(
'rc_comment', $result )
348 $revRecord->setVisibility( (
int)$result->rc_deleted );
351 (
int)$result->rc_user,
352 $result->rc_user_text
354 $revRecord->setUser( $user );
360 $linkBatch = $this->linkBatchFactory->newLinkBatch();
361 foreach ( $this->mResult as $row ) {
362 $linkBatch->add(
NS_USER, $row->rc_user_text );
364 $linkBatch->add( $row->page_namespace, $row->page_title );
366 $linkBatch->execute();
382 class_alias( NewPagesPager::class,
'NewPagesPager' );
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Marks HTML that shouldn't be escaped.
Utility class for creating new RC entries.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
Interface for objects which can provide a MediaWiki context on request.