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';
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,
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' );
324 'deleted' => $result->rc_deleted,
325 'user_text' => $result->rc_user_text,
326 'user' => $result->rc_user,
327 'actor' => $result->rc_actor,
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
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]";
500 $date = $row->rc_timestamp;
501 $comments =
$title->getTalkPage()->getFullURL();
504 $title->getPrefixedText(),
517 return $row->rc_user_text ??
'';
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>";