93 parent::__construct(
'Newpages' );
94 $this->linkBatchFactory = $linkBatchFactory;
95 $this->contentHandlerFactory = $contentHandlerFactory;
96 $this->groupPermissionsLookup = $groupPermissionsLookup;
97 $this->revisionLookup = $revisionLookup;
98 $this->namespaceInfo = $namespaceInfo;
99 $this->userOptionsLookup = $userOptionsLookup;
100 $this->rowCommentFormatter = $rowCommentFormatter;
101 $this->changeTagsStore = $changeTagsStore;
102 $this->tempUserConfig = $tempUserConfig;
114 $this->userOptionsLookup->getBoolOption( $this->getUser(),
'newpageshidepatrolled' )
120 $this->userOptionsLookup->getIntOption( $this->getUser(),
'rclimit' )
133 $this->customFilters = [];
134 $this->
getHookRunner()->onSpecialNewPagesFilters( $this, $this->customFilters );
136 foreach ( $this->customFilters as $key =>
$params ) {
148 if ( !$this->canAnonymousUsersCreatePages() ) {
159 $bits = preg_split(
'/\s*,\s*/', trim( $par ) );
160 foreach ( $bits as $bit ) {
162 if ( $bit ===
'shownav' ) {
163 $this->showNavigation =
true;
164 } elseif ( $bit ===
'hideliu' ) {
165 $this->opts->setValue(
'hideliu',
true );
166 } elseif ( $bit ===
'hidepatrolled' ) {
167 $this->opts->setValue(
'hidepatrolled',
true );
168 } elseif ( $bit ===
'hidebots' ) {
169 $this->opts->setValue(
'hidebots',
true );
170 } elseif ( $bit ===
'showredirs' ) {
171 $this->opts->setValue(
'hideredirs',
false );
172 } elseif ( is_numeric( $bit ) ) {
173 $this->opts->setValue(
'limit', intval( $bit ) );
174 } elseif ( preg_match(
'/^limit=(\d+)$/', $bit, $m ) ) {
175 $this->opts->setValue(
'limit', intval( $m[1] ) );
176 } elseif ( preg_match(
'/^offset=([^=]+)$/', $bit, $m ) ) {
178 $this->opts->setValue(
'offset', intval( $m[1] ) );
179 } elseif ( preg_match(
'/^username=(.*)$/', $bit, $m ) ) {
180 $this->opts->setValue(
'username', $m[1] );
181 } elseif ( preg_match(
'/^namespace=(.*)$/', $bit, $m ) ) {
183 if ( $ns !==
false ) {
184 $this->opts->setValue(
'namespace', $ns );
189 if ( $ns !==
false ) {
190 $this->opts->setValue(
'namespace', $ns );
207 $this->showNavigation = !$this->
including();
208 $this->
setup( $par );
216 $feedType = $this->opts->getValue(
'feed' );
218 $this->
feed( $feedType );
223 $allValues = $this->opts->getAllValues();
224 unset( $allValues[
'feed'] );
228 $pager = $this->getNewPagesPager();
229 $pager->mLimit = $this->opts->getValue(
'limit' );
230 $pager->mOffset = $this->opts->getValue(
'offset' );
232 if ( $pager->getNumRows() ) {
234 if ( $this->showNavigation ) {
235 $navigation = $pager->getNavigationBar();
237 $out->addHTML( $navigation . $pager->getBody() . $navigation );
239 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
241 $out->addWikiMsg(
'specialpage-empty' );
247 $showhide = [ $this->
msg(
'show' )->escaped(), $this->
msg(
'hide' )->escaped() ];
251 'hideliu' =>
'newpages-showhide-registered',
252 'hidepatrolled' =>
'newpages-showhide-patrolled',
253 'hidebots' =>
'newpages-showhide-bots',
254 'hideredirs' =>
'newpages-showhide-redirect'
256 foreach ( $this->customFilters as $key =>
$params ) {
257 $filters[$key] =
$params[
'msg'];
261 if ( !$this->canAnonymousUsersCreatePages() ) {
262 unset( $filters[
'hideliu'] );
264 if ( !$this->
getUser()->useNPPatrol() ) {
265 unset( $filters[
'hidepatrolled'] );
269 $changed = $this->opts->getChangedValues();
270 unset( $changed[
'offset'] );
276 foreach ( $changed as $key => $value ) {
277 if ( array_key_exists( $key, $filters ) ) {
278 $changed[$key] = $changed[$key] ?
'1' :
'0';
284 foreach ( $filters as $key => $msg ) {
285 $onoff = 1 - $this->opts->getValue( $key );
286 $link = $linkRenderer->makeLink(
290 [ $key => $onoff ] + $changed
292 $links[$key] = $this->
msg( $msg )->rawParams( $link )->escaped();
302 $this->opts->consumeValue(
'offset' );
303 $namespace = $this->opts->consumeValue(
'namespace' );
304 $username = $this->opts->consumeValue(
'username' );
305 $tagFilterVal = $this->opts->consumeValue(
'tagfilter' );
306 $tagInvertVal = $this->opts->consumeValue(
'tagInvert' );
307 $nsinvert = $this->opts->consumeValue(
'invert' );
308 $nsassociated = $this->opts->consumeValue(
'associated' );
310 $size = $this->opts->consumeValue(
'size' );
311 $max = $this->opts->consumeValue(
'size-mode' ) ===
'max';
314 $ut = Title::makeTitleSafe(
NS_USER, $username );
315 $userText = $ut ? $ut->getText() :
'';
319 'type' =>
'namespaceselect',
320 'name' =>
'namespace',
321 'label-message' =>
'namespace',
322 'default' => $namespace,
327 'label-message' =>
'invert',
328 'default' => $nsinvert,
329 'tooltip' =>
'invert',
333 'name' =>
'associated',
334 'label-message' =>
'namespace_association',
335 'default' => $nsassociated,
336 'tooltip' =>
'namespace_association',
339 'type' =>
'tagfilter',
340 'name' =>
'tagfilter',
341 'label-message' =>
'tag-filter',
342 'default' => $tagFilterVal,
346 'name' =>
'tagInvert',
347 'label-message' =>
'invert',
348 'hide-if' => [
'===',
'tagFilter',
'' ],
349 'default' => $tagInvertVal,
353 'name' =>
'username',
354 'label-message' =>
'newpages-username',
355 'default' => $userText,
356 'id' =>
'mw-np-username',
360 'type' =>
'sizefilter',
362 'default' => ( $max ? -1 : 1 ) * $size,
366 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
369 foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
370 $htmlForm->addHiddenField( $key, $value );
375 ->setFormIdentifier(
'newpagesform' )
383 ->setSubmitTextMsg(
'newpages-submit' )
384 ->setWrapperLegendMsg(
'newpages' )
385 ->addFooterHtml( Html::rawElement(
391 $out->addModuleStyles(
'mediawiki.special' );
394 private function getNewPagesPager() {
398 $this->groupPermissionsLookup,
400 $this->linkBatchFactory,
401 $this->namespaceInfo,
402 $this->changeTagsStore,
403 $this->rowCommentFormatter,
404 $this->contentHandlerFactory,
405 $this->tempUserConfig,
415 protected function feed( $type ) {
417 $this->
getOutput()->addWikiMsg(
'feed-unavailable' );
423 if ( !isset( $feedClasses[$type] ) ) {
424 $this->
getOutput()->addWikiMsg(
'feed-invalid' );
429 $feed =
new $feedClasses[$type](
431 $this->
msg(
'tagline' )->text(),
435 $pager = $this->getNewPagesPager();
436 $limit = $this->opts->getValue(
'limit' );
440 if ( $pager->getNumRows() > 0 ) {
441 foreach ( $pager->mResult as $row ) {
442 $feed->outItem( $this->
feedItem( $row ) );
453 return "$sitename - $desc [$code]";
457 $title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title );
459 $date = $row->rc_timestamp;
460 $comments = $title->getTalkPage()->getFullURL();
463 $title->getPrefixedText(),
464 $this->feedItemDesc( $row ),
465 $title->getFullURL(),
467 $this->feedItemAuthor( $row ),
476 return $row->rc_user_text ??
'';
480 $revisionRecord = $this->revisionLookup->getRevisionById( $row->rev_id );
481 if ( !$revisionRecord ) {
485 $content = $revisionRecord->getContent( SlotRecord::MAIN );
486 if ( $content ===
null ) {
491 $revUser = $revisionRecord->getUser();
492 $revUserText = $revUser ? $revUser->getName() :
'';
493 $revComment = $revisionRecord->getComment();
494 $revCommentText = $revComment ? $revComment->text :
'';
495 return '<p>' . htmlspecialchars( $revUserText ) .
496 $this->
msg(
'colon-separator' )->inContentLanguage()->escaped() .
497 htmlspecialchars( FeedItem::stripComment( $revCommentText ) ) .
498 "</p>\n<hr />\n<div>" .
499 nl2br( htmlspecialchars( $content->serialize() ) ) .
"</div>";
506 private function canAnonymousUsersCreatePages(): bool {
508 $anonGroups = [
'*' ];
509 if ( $this->tempUserConfig->isKnown() ) {
510 $anonGroups[] =
'temp';
513 foreach ( $anonGroups as $group ) {
514 $anonUsersCanCreatePages = $this->groupPermissionsLookup->groupHasPermission( $group,
'createpage' ) ||
515 $this->groupPermissionsLookup->groupHasPermission( $group,
'createtalk' );
516 if ( $anonUsersCanCreatePages ) {
536class_alias( SpecialNewPages::class,
'SpecialNewpages' );
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
array $params
The job parameters.
Marks HTML that shouldn't be escaped.
A class containing constants representing the names of configuration variables.
const FeedClasses
Name constant for the FeedClasses setting, for use with Config::get()
const Feed
Name constant for the Feed setting, for use with Config::get()
const Sitename
Name constant for the Sitename setting, for use with Config::get()
const LanguageCode
Name constant for the LanguageCode setting, for use with Config::get()
const FeedLimit
Name constant for the FeedLimit setting, for use with Config::get()
Shortcut to construct an includable special page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
getUser()
Shortcut to get the User executing this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getConfig()
Shortcut to get main config object.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
including( $x=null)
Whether the special page is being evaluated via transclusion.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
List of newly created pages.
feed( $type)
Output a subscription feed listing recent edits to this page.
__construct(LinkBatchFactory $linkBatchFactory, IContentHandlerFactory $contentHandlerFactory, GroupPermissionsLookup $groupPermissionsLookup, RevisionLookup $revisionLookup, NamespaceInfo $namespaceInfo, UserOptionsLookup $userOptionsLookup, RowCommentFormatter $rowCommentFormatter, ChangeTagsStore $changeTagsStore, TempUserConfig $tempUserConfig)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Show a form for filtering namespace and username.