88 parent::__construct(
'Newpages' );
89 $this->linkBatchFactory = $linkBatchFactory;
90 $this->contentHandlerFactory = $contentHandlerFactory;
91 $this->groupPermissionsLookup = $groupPermissionsLookup;
92 $this->revisionLookup = $revisionLookup;
93 $this->namespaceInfo = $namespaceInfo;
94 $this->userOptionsLookup = $userOptionsLookup;
95 $this->rowCommentFormatter = $rowCommentFormatter;
96 $this->changeTagsStore = $changeTagsStore;
108 $this->userOptionsLookup->getBoolOption( $this->getUser(),
'newpageshidepatrolled' )
114 $this->userOptionsLookup->getIntOption( $this->getUser(),
'rclimit' )
127 $this->customFilters = [];
128 $this->
getHookRunner()->onSpecialNewPagesFilters( $this, $this->customFilters );
130 foreach ( $this->customFilters as $key => $params ) {
131 $opts->
add( $key, $params[
'default'] );
146 $bits = preg_split(
'/\s*,\s*/', trim( $par ) );
147 foreach ( $bits as $bit ) {
149 if ( $bit ===
'shownav' ) {
150 $this->showNavigation =
true;
151 } elseif ( $bit ===
'hideliu' ) {
152 $this->opts->setValue(
'hideliu',
true );
153 } elseif ( $bit ===
'hidepatrolled' ) {
154 $this->opts->setValue(
'hidepatrolled',
true );
155 } elseif ( $bit ===
'hidebots' ) {
156 $this->opts->setValue(
'hidebots',
true );
157 } elseif ( $bit ===
'showredirs' ) {
158 $this->opts->setValue(
'hideredirs',
false );
159 } elseif ( is_numeric( $bit ) ) {
160 $this->opts->setValue(
'limit', intval( $bit ) );
161 } elseif ( preg_match(
'/^limit=(\d+)$/', $bit, $m ) ) {
162 $this->opts->setValue(
'limit', intval( $m[1] ) );
163 } elseif ( preg_match(
'/^offset=([^=]+)$/', $bit, $m ) ) {
165 $this->opts->setValue(
'offset', intval( $m[1] ) );
166 } elseif ( preg_match(
'/^username=(.*)$/', $bit, $m ) ) {
167 $this->opts->setValue(
'username', $m[1] );
168 } elseif ( preg_match(
'/^namespace=(.*)$/', $bit, $m ) ) {
170 if ( $ns !==
false ) {
171 $this->opts->setValue(
'namespace', $ns );
176 if ( $ns !==
false ) {
177 $this->opts->setValue(
'namespace', $ns );
194 $this->showNavigation = !$this->
including();
195 $this->
setup( $par );
203 $feedType = $this->opts->getValue(
'feed' );
205 $this->
feed( $feedType );
210 $allValues = $this->opts->getAllValues();
211 unset( $allValues[
'feed'] );
215 $pager = $this->getNewPagesPager();
216 $pager->mLimit = $this->opts->getValue(
'limit' );
217 $pager->mOffset = $this->opts->getValue(
'offset' );
219 if ( $pager->getNumRows() ) {
221 if ( $this->showNavigation ) {
222 $navigation = $pager->getNavigationBar();
224 $out->addHTML( $navigation . $pager->getBody() . $navigation );
226 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
228 $out->addWikiMsg(
'specialpage-empty' );
234 $showhide = [ $this->
msg(
'show' )->escaped(), $this->
msg(
'hide' )->escaped() ];
238 'hideliu' =>
'newpages-showhide-registered',
239 'hidepatrolled' =>
'newpages-showhide-patrolled',
240 'hidebots' =>
'newpages-showhide-bots',
241 'hideredirs' =>
'newpages-showhide-redirect'
243 foreach ( $this->customFilters as $key => $params ) {
244 $filters[$key] = $params[
'msg'];
248 if ( !$this->canAnonymousUsersCreatePages() ) {
249 unset( $filters[
'hideliu'] );
251 if ( !$this->
getUser()->useNPPatrol() ) {
252 unset( $filters[
'hidepatrolled'] );
256 $changed = $this->opts->getChangedValues();
257 unset( $changed[
'offset'] );
263 foreach ( $changed as $key => $value ) {
264 if ( array_key_exists( $key, $filters ) ) {
265 $changed[$key] = $changed[$key] ?
'1' :
'0';
271 foreach ( $filters as $key => $msg ) {
272 $onoff = 1 - $this->opts->getValue( $key );
273 $link = $linkRenderer->makeLink(
277 [ $key => $onoff ] + $changed
279 $links[$key] = $this->
msg( $msg )->rawParams( $link )->escaped();
289 $this->opts->consumeValue(
'offset' );
290 $namespace = $this->opts->consumeValue(
'namespace' );
291 $username = $this->opts->consumeValue(
'username' );
292 $tagFilterVal = $this->opts->consumeValue(
'tagfilter' );
293 $tagInvertVal = $this->opts->consumeValue(
'tagInvert' );
294 $nsinvert = $this->opts->consumeValue(
'invert' );
295 $nsassociated = $this->opts->consumeValue(
'associated' );
297 $size = $this->opts->consumeValue(
'size' );
298 $max = $this->opts->consumeValue(
'size-mode' ) ===
'max';
301 $ut = Title::makeTitleSafe(
NS_USER, $username );
302 $userText = $ut ? $ut->getText() :
'';
306 'type' =>
'namespaceselect',
307 'name' =>
'namespace',
308 'label-message' =>
'namespace',
309 'default' => $namespace,
314 'label-message' =>
'invert',
315 'default' => $nsinvert,
316 'tooltip' =>
'invert',
320 'name' =>
'associated',
321 'label-message' =>
'namespace_association',
322 'default' => $nsassociated,
323 'tooltip' =>
'namespace_association',
326 'type' =>
'tagfilter',
327 'name' =>
'tagfilter',
328 'label-message' =>
'tag-filter',
329 'default' => $tagFilterVal,
333 'name' =>
'tagInvert',
334 'label-message' =>
'invert',
335 'hide-if' => [
'===',
'tagFilter',
'' ],
336 'default' => $tagInvertVal,
340 'name' =>
'username',
341 'label-message' =>
'newpages-username',
342 'default' => $userText,
343 'id' =>
'mw-np-username',
347 'type' =>
'sizefilter',
349 'default' => ( $max ? -1 : 1 ) * $size,
353 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
356 foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
357 $htmlForm->addHiddenField( $key, $value );
362 ->setFormIdentifier(
'newpagesform' )
370 ->setSubmitTextMsg(
'newpages-submit' )
371 ->setWrapperLegendMsg(
'newpages' )
372 ->addFooterHtml( Html::rawElement(
378 $out->addModuleStyles(
'mediawiki.special' );
381 private function getNewPagesPager() {
385 $this->groupPermissionsLookup,
387 $this->linkBatchFactory,
388 $this->namespaceInfo,
389 $this->changeTagsStore,
390 $this->rowCommentFormatter,
391 $this->contentHandlerFactory,
401 protected function feed( $type ) {
403 $this->
getOutput()->addWikiMsg(
'feed-unavailable' );
409 if ( !isset( $feedClasses[$type] ) ) {
410 $this->
getOutput()->addWikiMsg(
'feed-invalid' );
415 $feed =
new $feedClasses[$type](
417 $this->
msg(
'tagline' )->text(),
421 $pager = $this->getNewPagesPager();
422 $limit = $this->opts->getValue(
'limit' );
426 if ( $pager->getNumRows() > 0 ) {
427 foreach ( $pager->mResult as $row ) {
428 $feed->outItem( $this->
feedItem( $row ) );
439 return "$sitename - $desc [$code]";
443 $title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title );
445 $date = $row->rc_timestamp;
446 $comments = $title->getTalkPage()->getFullURL();
449 $title->getPrefixedText(),
450 $this->feedItemDesc( $row ),
451 $title->getFullURL(),
453 $this->feedItemAuthor( $row ),
462 return $row->rc_user_text ??
'';
466 $revisionRecord = $this->revisionLookup->getRevisionById( $row->rev_id );
467 if ( !$revisionRecord ) {
471 $content = $revisionRecord->getContent( SlotRecord::MAIN );
477 $revUser = $revisionRecord->getUser();
478 $revUserText = $revUser ? $revUser->getName() :
'';
479 $revComment = $revisionRecord->getComment();
480 $revCommentText = $revComment ? $revComment->text :
'';
481 return '<p>' . htmlspecialchars( $revUserText ) .
482 $this->
msg(
'colon-separator' )->inContentLanguage()->escaped() .
483 htmlspecialchars( FeedItem::stripComment( $revCommentText ) ) .
484 "</p>\n<hr />\n<div>" .
485 nl2br( htmlspecialchars(
$content->serialize() ) ) .
"</div>";
488 private function canAnonymousUsersCreatePages() {
489 return $this->groupPermissionsLookup->groupHasPermission(
'*',
'createpage' ) ||
490 $this->groupPermissionsLookup->groupHasPermission(
'*',
'createtalk' );
506class_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....
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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
A special page that list 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.