87 parent::__construct(
'Newpages' );
88 $this->linkBatchFactory = $linkBatchFactory;
89 $this->contentHandlerFactory = $contentHandlerFactory;
90 $this->groupPermissionsLookup = $groupPermissionsLookup;
91 $this->revisionLookup = $revisionLookup;
92 $this->namespaceInfo = $namespaceInfo;
93 $this->userOptionsLookup = $userOptionsLookup;
94 $this->rowCommentFormatter = $rowCommentFormatter;
95 $this->changeTagsStore = $changeTagsStore;
107 $this->userOptionsLookup->getBoolOption( $this->getUser(),
'newpageshidepatrolled' )
113 $this->userOptionsLookup->getIntOption( $this->getUser(),
'rclimit' )
126 $this->customFilters = [];
127 $this->
getHookRunner()->onSpecialNewPagesFilters( $this, $this->customFilters );
129 foreach ( $this->customFilters as $key =>
$params ) {
145 $bits = preg_split(
'/\s*,\s*/', trim( $par ) );
146 foreach ( $bits as $bit ) {
148 if ( $bit ===
'shownav' ) {
149 $this->showNavigation =
true;
150 } elseif ( $bit ===
'hideliu' ) {
151 $this->opts->setValue(
'hideliu',
true );
152 } elseif ( $bit ===
'hidepatrolled' ) {
153 $this->opts->setValue(
'hidepatrolled',
true );
154 } elseif ( $bit ===
'hidebots' ) {
155 $this->opts->setValue(
'hidebots',
true );
156 } elseif ( $bit ===
'showredirs' ) {
157 $this->opts->setValue(
'hideredirs',
false );
158 } elseif ( is_numeric( $bit ) ) {
159 $this->opts->setValue(
'limit', intval( $bit ) );
160 } elseif ( preg_match(
'/^limit=(\d+)$/', $bit, $m ) ) {
161 $this->opts->setValue(
'limit', intval( $m[1] ) );
162 } elseif ( preg_match(
'/^offset=([^=]+)$/', $bit, $m ) ) {
164 $this->opts->setValue(
'offset', intval( $m[1] ) );
165 } elseif ( preg_match(
'/^username=(.*)$/', $bit, $m ) ) {
166 $this->opts->setValue(
'username', $m[1] );
167 } elseif ( preg_match(
'/^namespace=(.*)$/', $bit, $m ) ) {
169 if ( $ns !==
false ) {
170 $this->opts->setValue(
'namespace', $ns );
175 if ( $ns !==
false ) {
176 $this->opts->setValue(
'namespace', $ns );
193 $this->showNavigation = !$this->
including();
194 $this->
setup( $par );
202 $feedType = $this->opts->getValue(
'feed' );
204 $this->
feed( $feedType );
209 $allValues = $this->opts->getAllValues();
210 unset( $allValues[
'feed'] );
214 $pager = $this->getNewPagesPager();
215 $pager->mLimit = $this->opts->getValue(
'limit' );
216 $pager->mOffset = $this->opts->getValue(
'offset' );
218 if ( $pager->getNumRows() ) {
220 if ( $this->showNavigation ) {
221 $navigation = $pager->getNavigationBar();
223 $out->addHTML( $navigation . $pager->getBody() . $navigation );
225 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
227 $out->addWikiMsg(
'specialpage-empty' );
233 $showhide = [ $this->
msg(
'show' )->escaped(), $this->
msg(
'hide' )->escaped() ];
237 'hideliu' =>
'newpages-showhide-registered',
238 'hidepatrolled' =>
'newpages-showhide-patrolled',
239 'hidebots' =>
'newpages-showhide-bots',
240 'hideredirs' =>
'newpages-showhide-redirect'
242 foreach ( $this->customFilters as $key =>
$params ) {
243 $filters[$key] =
$params[
'msg'];
247 if ( !$this->canAnonymousUsersCreatePages() ) {
248 unset( $filters[
'hideliu'] );
250 if ( !$this->
getUser()->useNPPatrol() ) {
251 unset( $filters[
'hidepatrolled'] );
255 $changed = $this->opts->getChangedValues();
256 unset( $changed[
'offset'] );
262 foreach ( $changed as $key => $value ) {
263 if ( array_key_exists( $key, $filters ) ) {
264 $changed[$key] = $changed[$key] ?
'1' :
'0';
270 foreach ( $filters as $key => $msg ) {
271 $onoff = 1 - $this->opts->getValue( $key );
272 $link = $linkRenderer->makeLink(
276 [ $key => $onoff ] + $changed
278 $links[$key] = $this->
msg( $msg )->rawParams( $link )->escaped();
288 $this->opts->consumeValue(
'offset' );
289 $namespace = $this->opts->consumeValue(
'namespace' );
290 $username = $this->opts->consumeValue(
'username' );
291 $tagFilterVal = $this->opts->consumeValue(
'tagfilter' );
292 $tagInvertVal = $this->opts->consumeValue(
'tagInvert' );
293 $nsinvert = $this->opts->consumeValue(
'invert' );
294 $nsassociated = $this->opts->consumeValue(
'associated' );
296 $size = $this->opts->consumeValue(
'size' );
297 $max = $this->opts->consumeValue(
'size-mode' ) ===
'max';
300 $ut = Title::makeTitleSafe(
NS_USER, $username );
301 $userText = $ut ? $ut->getText() :
'';
305 'type' =>
'namespaceselect',
306 'name' =>
'namespace',
307 'label-message' =>
'namespace',
308 'default' => $namespace,
313 'label-message' =>
'invert',
314 'default' => $nsinvert,
315 'tooltip' =>
'invert',
319 'name' =>
'associated',
320 'label-message' =>
'namespace_association',
321 'default' => $nsassociated,
322 'tooltip' =>
'namespace_association',
325 'type' =>
'tagfilter',
326 'name' =>
'tagfilter',
327 'label-message' =>
'tag-filter',
328 'default' => $tagFilterVal,
332 'name' =>
'tagInvert',
333 'label-message' =>
'invert',
334 'hide-if' => [
'===',
'tagFilter',
'' ],
335 'default' => $tagInvertVal,
339 'name' =>
'username',
340 'label-message' =>
'newpages-username',
341 'default' => $userText,
342 'id' =>
'mw-np-username',
346 'type' =>
'sizefilter',
348 'default' => ( $max ? -1 : 1 ) * $size,
352 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
355 foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
356 $htmlForm->addHiddenField( $key, $value );
361 ->setFormIdentifier(
'newpagesform' )
369 ->setSubmitTextMsg(
'newpages-submit' )
370 ->setWrapperLegendMsg(
'newpages' )
371 ->addFooterHtml( Html::rawElement(
377 $out->addModuleStyles(
'mediawiki.special' );
380 private function getNewPagesPager() {
384 $this->groupPermissionsLookup,
386 $this->linkBatchFactory,
387 $this->namespaceInfo,
388 $this->changeTagsStore,
389 $this->rowCommentFormatter,
390 $this->contentHandlerFactory,
400 protected function feed( $type ) {
402 $this->
getOutput()->addWikiMsg(
'feed-unavailable' );
408 if ( !isset( $feedClasses[$type] ) ) {
409 $this->
getOutput()->addWikiMsg(
'feed-invalid' );
414 $feed =
new $feedClasses[$type](
416 $this->
msg(
'tagline' )->text(),
420 $pager = $this->getNewPagesPager();
421 $limit = $this->opts->getValue(
'limit' );
425 if ( $pager->getNumRows() > 0 ) {
426 foreach ( $pager->mResult as $row ) {
427 $feed->outItem( $this->
feedItem( $row ) );
438 return "$sitename - $desc [$code]";
442 $title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title );
444 $date = $row->rc_timestamp;
445 $comments = $title->getTalkPage()->getFullURL();
448 $title->getPrefixedText(),
449 $this->feedItemDesc( $row ),
450 $title->getFullURL(),
452 $this->feedItemAuthor( $row ),
461 return $row->rc_user_text ??
'';
465 $revisionRecord = $this->revisionLookup->getRevisionById( $row->rev_id );
466 if ( !$revisionRecord ) {
470 $content = $revisionRecord->getContent( SlotRecord::MAIN );
471 if ( $content ===
null ) {
476 $revUser = $revisionRecord->getUser();
477 $revUserText = $revUser ? $revUser->getName() :
'';
478 $revComment = $revisionRecord->getComment();
479 $revCommentText = $revComment ? $revComment->text :
'';
480 return '<p>' . htmlspecialchars( $revUserText ) .
481 $this->
msg(
'colon-separator' )->inContentLanguage()->escaped() .
482 htmlspecialchars( FeedItem::stripComment( $revCommentText ) ) .
483 "</p>\n<hr />\n<div>" .
484 nl2br( htmlspecialchars( $content->serialize() ) ) .
"</div>";
487 private function canAnonymousUsersCreatePages() {
488 return $this->groupPermissionsLookup->groupHasPermission(
'*',
'createpage' ) ||
489 $this->groupPermissionsLookup->groupHasPermission(
'*',
'createtalk' );
505class_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)
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.