41 parent::__construct(
'Newpages' );
47 protected function setup( $par ) {
51 $opts->
add(
'hidepatrolled', $this->
getUser()->getBoolOption(
'newpageshidepatrolled' ) );
65 $this->customFilters = [];
66 Hooks::run(
'SpecialNewPagesFilters', [ $this, &$this->customFilters ] );
67 foreach ( $this->customFilters as $key => $params ) {
68 $opts->
add( $key, $params[
'default'] );
83 $bits = preg_split(
'/\s*,\s*/', trim( $par ) );
84 foreach ( $bits as $bit ) {
85 if ( $bit ===
'shownav' ) {
86 $this->showNavigation =
true;
88 if ( $bit ===
'hideliu' ) {
89 $this->opts->setValue(
'hideliu',
true );
91 if ( $bit ===
'hidepatrolled' ) {
92 $this->opts->setValue(
'hidepatrolled',
true );
94 if ( $bit ===
'hidebots' ) {
95 $this->opts->setValue(
'hidebots',
true );
97 if ( $bit ===
'showredirs' ) {
98 $this->opts->setValue(
'hideredirs',
false );
100 if ( is_numeric( $bit ) ) {
101 $this->opts->setValue(
'limit', intval( $bit ) );
105 if ( preg_match(
'/^limit=(\d+)$/', $bit, $m ) ) {
106 $this->opts->setValue(
'limit', intval( $m[1] ) );
109 if ( preg_match(
'/^offset=([^=]+)$/', $bit, $m ) ) {
110 $this->opts->setValue(
'offset', intval( $m[1] ) );
112 if ( preg_match(
'/^username=(.*)$/', $bit, $m ) ) {
113 $this->opts->setValue(
'username', $m[1] );
115 if ( preg_match(
'/^namespace=(.*)$/', $bit, $m ) ) {
117 if ( $ns !==
false ) {
118 $this->opts->setValue(
'namespace', $ns );
135 $this->showNavigation = !$this->
including();
136 $this->
setup( $par );
144 $feedType = $this->opts->getValue(
'feed' );
146 $this->
feed( $feedType );
151 $allValues = $this->opts->getAllValues();
152 unset( $allValues[
'feed'] );
157 $pager->mLimit = $this->opts->getValue(
'limit' );
158 $pager->mOffset = $this->opts->getValue(
'offset' );
160 if ( $pager->getNumRows() ) {
162 if ( $this->showNavigation ) {
163 $navigation = $pager->getNavigationBar();
165 $out->addHTML( $navigation . $pager->getBody() . $navigation );
167 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
169 $out->addWikiMsg(
'specialpage-empty' );
175 $showhide = [ $this->
msg(
'show' )->escaped(), $this->
msg(
'hide' )->escaped() ];
179 'hideliu' =>
'rcshowhideliu',
180 'hidepatrolled' =>
'rcshowhidepatr',
181 'hidebots' =>
'rcshowhidebots',
182 'hideredirs' =>
'whatlinkshere-hideredirs'
184 foreach ( $this->customFilters as $key => $params ) {
185 $filters[$key] = $params[
'msg'];
190 ->groupHasPermission(
'*',
'createpage' )
192 unset( $filters[
'hideliu'] );
194 if ( !$this->
getUser()->useNPPatrol() ) {
195 unset( $filters[
'hidepatrolled'] );
199 $changed = $this->opts->getChangedValues();
200 unset( $changed[
'offset'] );
206 foreach ( $changed as $key => $value ) {
207 if ( array_key_exists( $key, $filters ) ) {
208 $changed[$key] = $changed[$key] ?
'1' :
'0';
214 foreach ( $filters as $key => $msg ) {
215 $onoff = 1 - $this->opts->getValue( $key );
220 [ $key => $onoff ] + $changed
222 $links[$key] = $this->
msg( $msg )->rawParams( $link )->escaped();
232 $this->opts->consumeValue(
'offset' );
233 $namespace = $this->opts->consumeValue(
'namespace' );
234 $username = $this->opts->consumeValue(
'username' );
235 $tagFilterVal = $this->opts->consumeValue(
'tagfilter' );
236 $nsinvert = $this->opts->consumeValue(
'invert' );
237 $nsassociated = $this->opts->consumeValue(
'associated' );
239 $size = $this->opts->consumeValue(
'size' );
240 $max = $this->opts->consumeValue(
'size-mode' ) ===
'max';
243 $ut = Title::makeTitleSafe(
NS_USER, $username );
244 $userText = $ut ? $ut->getText() :
'';
248 'type' =>
'namespaceselect',
249 'name' =>
'namespace',
250 'label-message' =>
'namespace',
251 'default' => $namespace,
256 'label-message' =>
'invert',
257 'default' => $nsinvert,
258 'tooltip' =>
'invert',
262 'name' =>
'associated',
263 'label-message' =>
'namespace_association',
264 'default' => $nsassociated,
265 'tooltip' =>
'namespace_association',
268 'type' =>
'tagfilter',
269 'name' =>
'tagfilter',
270 'label-raw' => $this->
msg(
'tag-filter' )->parse(),
271 'default' => $tagFilterVal,
275 'name' =>
'username',
276 'label-message' =>
'newpages-username',
277 'default' => $userText,
278 'id' =>
'mw-np-username',
282 'type' =>
'sizefilter',
284 'default' => -$max * $size,
288 $htmlForm = HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() );
291 foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
292 $htmlForm->addHiddenField( $key, $value );
297 ->setFormIdentifier(
'newpagesform' )
305 ->setSubmitText( $this->
msg(
'newpages-submit' )->text() )
306 ->setWrapperLegend( $this->
msg(
'newpages' )->text() )
307 ->addFooterText( Html::rawElement(
313 $out->addModuleStyles(
'mediawiki.special' );
323 'comment' => CommentStore::getStore()->getComment(
'rc_comment', $result )->text,
324 'deleted' => $result->rc_deleted,
325 'user_text' => $result->rc_user_text,
326 'user' => $result->rc_user,
327 'actor' => $result->rc_actor,
339 $title = Title::newFromRow( $result );
346 $attribs = [
'data-mw-revid' => $result->rev_id ];
349 $dm =
$lang->getDirMark();
351 $spanTime = Html::element(
'span', [
'class' =>
'mw-newpages-time' ],
352 $lang->userTimeAndDate( $result->rc_timestamp, $this->getUser() )
359 [
'oldid' => $result->rc_this_oldid ]
362 $query =
$title->isRedirect() ? [
'redirect' =>
'no' ] : [];
367 [
'class' =>
'mw-newpages-pagename' ],
372 $this->
msg(
'hist' )->text(),
374 [
'action' =>
'history' ]
376 $hist = Html::rawElement(
'span', [
'class' =>
'mw-newpages-history' ],
377 $this->
msg(
'parentheses' )->rawParams( $histLink )->escaped() );
379 $length = Html::rawElement(
381 [
'class' =>
'mw-newpages-length' ],
382 $this->
msg(
'brackets' )->rawParams(
383 $this->
msg(
'nbytes' )->numParams( $result->length )->escaped()
391 $classes[] =
'not-patrolled';
394 # Add a class for zero byte pages
395 if ( $result->length == 0 ) {
396 $classes[] =
'mw-newpages-zero-byte-page';
400 if ( isset( $result->ts_tags ) ) {
406 $classes = array_merge( $classes, $newClasses );
411 # Display the old title if the namespace/title has been changed
413 $oldTitle = Title::makeTitle( $result->rc_namespace, $result->rc_title );
415 if ( !
$title->equals( $oldTitle ) ) {
416 $oldTitleText = $oldTitle->getPrefixedText();
417 $oldTitleText = Html::rawElement(
419 [
'class' =>
'mw-newpages-oldtitle' ],
420 $this->
msg(
'rc-old-title' )->params( $oldTitleText )->escaped()
424 $ret =
"{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} "
425 .
"{$tagDisplay} {$oldTitleText}";
428 Hooks::run(
'NewPagesLineEnding', [ $this, &$ret, $result, &$classes, &$attribs ] );
429 $attribs = array_filter( $attribs,
430 [ Sanitizer::class,
'isReservedDataAttribute' ],
434 if ( count( $classes ) ) {
435 $attribs[
'class'] = implode(
' ', $classes );
438 return Html::rawElement(
'li', $attribs, $ret ) .
"\n";
448 return ( $this->
getUser()->useNPPatrol() && !$result->rc_patrolled );
457 if ( !$this->
getConfig()->
get(
'Feed' ) ) {
458 $this->
getOutput()->addWikiMsg(
'feed-unavailable' );
463 $feedClasses = $this->
getConfig()->get(
'FeedClasses' );
464 if ( !isset( $feedClasses[
$type] ) ) {
465 $this->
getOutput()->addWikiMsg(
'feed-invalid' );
470 $feed =
new $feedClasses[
$type](
472 $this->
msg(
'tagline' )->text(),
477 $limit = $this->opts->getValue(
'limit' );
478 $pager->mLimit = min( $limit, $this->
getConfig()->
get(
'FeedLimit' ) );
481 if ( $pager->getNumRows() > 0 ) {
482 foreach ( $pager->mResult as $row ) {
483 $feed->outItem( $this->
feedItem( $row ) );
491 $code = $this->
getConfig()->get(
'LanguageCode' );
492 $sitename = $this->
getConfig()->get(
'Sitename' );
494 return "$sitename - $desc [$code]";
498 $title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title );
500 $date = $row->rc_timestamp;
501 $comments =
$title->getTalkPage()->getFullURL();
504 $title->getPrefixedText(),
505 $this->feedItemDesc( $row ),
508 $this->feedItemAuthor( $row ),
517 return $row->rc_user_text ??
'';
521 $revision = Revision::newFromId( $row->rev_id );
532 return '<p>' . htmlspecialchars( $revision->getUserText() ) .
533 $this->
msg(
'colon-separator' )->inContentLanguage()->escaped() .
535 "</p>\n<hr />\n<div>" .
536 nl2br( htmlspecialchars(
$content->serialize() ) ) .
"</div>";
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
A base class for outputting syndication feeds (e.g.
static stripComment( $text)
Quickie hack... strip out wikilinks to more legible form from the comment.
Marks HTML that shouldn't be escaped.
Shortcut to construct an includable special page.
static revComment(Revision $rev, $local=false, $isPublic=false, $useParentheses=true)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
static revUserTools( $rev, $isPublic=false, $useParentheses=true)
Generate a user tool link cluster if the current user is allowed to view it.
A special page that list newly created pages.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
patrollable( $result)
Should a specific result row provide "patrollable" links?
feed( $type)
Output a subscription feed listing recent edits to this page.
execute( $par)
Show a form for filtering namespace and username.
formatRow( $result)
Format a row, providing the timestamp, links to the page/history, size, user links,...
revisionFromRcResult(stdClass $result, Title $title)
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
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...
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
including( $x=null)
Whether the special page is being evaluated via transclusion.
MediaWiki Linker LinkRenderer null $linkRenderer
Represents a title within MediaWiki.
if(!isset( $args[0])) $lang