Merge "Pass context to ChangeTags::tagDescription"
[lhc/web/wiklou.git] / includes / specials / SpecialNewpages.php
old mode 100644 (file)
new mode 100755 (executable)
index ab29d13..be8ad8f
@@ -54,6 +54,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                $opts->add( 'feed', '' );
                $opts->add( 'tagfilter', '' );
                $opts->add( 'invert', false );
+               $opts->add( 'size-mode', 'max' );
+               $opts->add( 'size', 0 );
 
                $this->customFilters = [];
                Hooks::run( 'SpecialNewPagesFilters', [ $this, &$this->customFilters ] );
@@ -188,9 +190,13 @@ class SpecialNewpages extends IncludableSpecialPage {
                unset( $changed['offset'] ); // Reset offset if query type changes
 
                $self = $this->getPageTitle();
+               $linkRenderer = $this->getLinkRenderer();
                foreach ( $filters as $key => $msg ) {
                        $onoff = 1 - $this->opts->getValue( $key );
-                       $link = Linker::link( $self, $showhide[$onoff], [],
+                       $link = $linkRenderer->makeLink(
+                               $self,
+                               new HtmlArmor( $showhide[$onoff] ),
+                               [],
                                [ $key => $onoff ] + $changed
                        );
                        $links[$key] = $this->msg( $msg )->rawParams( $link )->escaped();
@@ -210,6 +216,9 @@ class SpecialNewpages extends IncludableSpecialPage {
                $tagFilterVal = $this->opts->consumeValue( 'tagfilter' );
                $nsinvert = $this->opts->consumeValue( 'invert' );
 
+               $size = $this->opts->consumeValue( 'size' );
+               $max = $this->opts->consumeValue( 'size-mode' ) === 'max';
+
                // Check username input validity
                $ut = Title::makeTitleSafe( NS_USER, $username );
                $userText = $ut ? $ut->getText() : '';
@@ -250,6 +259,11 @@ class SpecialNewpages extends IncludableSpecialPage {
                                'size' => 30,
                                'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
                        ],
+                       'size' => [
+                               'type' => 'sizefilter',
+                               'name' => 'size',
+                               'default' => -$max * $size,
+                       ],
                ];
 
                $htmlForm = new HTMLForm( $form, $this->getContext() );
@@ -307,28 +321,25 @@ class SpecialNewpages extends IncludableSpecialPage {
                $spanTime = Html::element( 'span', [ 'class' => 'mw-newpages-time' ],
                        $lang->userTimeAndDate( $result->rc_timestamp, $this->getUser() )
                );
-               $time = Linker::linkKnown(
+               $linkRenderer = $this->getLinkRenderer();
+               $time = $linkRenderer->makeKnownLink(
                        $title,
-                       $spanTime,
+                       new HtmlArmor( $spanTime ),
                        [],
-                       [ 'oldid' => $result->rc_this_oldid ],
-                       []
+                       [ 'oldid' => $result->rc_this_oldid ]
                );
 
                $query = $title->isRedirect() ? [ 'redirect' => 'no' ] : [];
 
-               // Linker::linkKnown() uses 'known' and 'noclasses' options.
-               // This breaks the colouration for stubs.
-               $plink = Linker::link(
+               $plink = $linkRenderer->makeKnownLink(
                        $title,
                        null,
                        [ 'class' => 'mw-newpages-pagename' ],
-                       $query,
-                       [ 'known' ]
+                       $query
                );
-               $histLink = Linker::linkKnown(
+               $histLink = $linkRenderer->makeKnownLink(
                        $title,
-                       $this->msg( 'hist' )->escaped(),
+                       $this->msg( 'hist' )->text(),
                        [],
                        [ 'action' => 'history' ]
                );
@@ -375,7 +386,11 @@ class SpecialNewpages extends IncludableSpecialPage {
 
                if ( !$title->equals( $oldTitle ) ) {
                        $oldTitleText = $oldTitle->getPrefixedText();
-                       $oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped();
+                       $oldTitleText = Html::rawElement(
+                               'span',
+                               [ 'class' => 'mw-newpages-oldtitle' ],
+                               $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped()
+                       );
                }
 
                return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} "
@@ -478,131 +493,8 @@ class SpecialNewpages extends IncludableSpecialPage {
        protected function getGroupName() {
                return 'changes';
        }
-}
-
-/**
- * @ingroup SpecialPage Pager
- */
-class NewPagesPager extends ReverseChronologicalPager {
-       // Stored opts
-       protected $opts;
-
-       /**
-        * @var HtmlForm
-        */
-       protected $mForm;
-
-       function __construct( $form, FormOptions $opts ) {
-               parent::__construct( $form->getContext() );
-               $this->mForm = $form;
-               $this->opts = $opts;
-       }
-
-       function getQueryInfo() {
-               $conds = [];
-               $conds['rc_new'] = 1;
-
-               $namespace = $this->opts->getValue( 'namespace' );
-               $namespace = ( $namespace === 'all' ) ? false : intval( $namespace );
-
-               $username = $this->opts->getValue( 'username' );
-               $user = Title::makeTitleSafe( NS_USER, $username );
-
-               $rcIndexes = [];
-
-               if ( $namespace !== false ) {
-                       if ( $this->opts->getValue( 'invert' ) ) {
-                               $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace );
-                       } else {
-                               $conds['rc_namespace'] = $namespace;
-                       }
-               }
-
-               if ( $user ) {
-                       $conds['rc_user_text'] = $user->getText();
-                       $rcIndexes = 'rc_user_text';
-               } elseif ( User::groupHasPermission( '*', 'createpage' ) &&
-                       $this->opts->getValue( 'hideliu' )
-               ) {
-                       # If anons cannot make new pages, don't "exclude logged in users"!
-                       $conds['rc_user'] = 0;
-               }
-
-               # If this user cannot see patrolled edits or they are off, don't do dumb queries!
-               if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
-                       $conds['rc_patrolled'] = 0;
-               }
-
-               if ( $this->opts->getValue( 'hidebots' ) ) {
-                       $conds['rc_bot'] = 0;
-               }
-
-               if ( $this->opts->getValue( 'hideredirs' ) ) {
-                       $conds['page_is_redirect'] = 0;
-               }
-
-               // Allow changes to the New Pages query
-               $tables = [ 'recentchanges', 'page' ];
-               $fields = [
-                       'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text',
-                       'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted',
-                       'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid',
-                       'page_namespace', 'page_title'
-               ];
-               $join_conds = [ 'page' => [ 'INNER JOIN', 'page_id=rc_cur_id' ] ];
-
-               Hooks::run( 'SpecialNewpagesConditions',
-                       [ &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ] );
-
-               $options = [];
-
-               if ( $rcIndexes ) {
-                       $options = [ 'USE INDEX' => [ 'recentchanges' => $rcIndexes ] ];
-               }
-
-               $info = [
-                       'tables' => $tables,
-                       'fields' => $fields,
-                       'conds' => $conds,
-                       'options' => $options,
-                       'join_conds' => $join_conds
-               ];
-
-               // Modify query for tags
-               ChangeTags::modifyDisplayQuery(
-                       $info['tables'],
-                       $info['fields'],
-                       $info['conds'],
-                       $info['join_conds'],
-                       $info['options'],
-                       $this->opts['tagfilter']
-               );
-
-               return $info;
-       }
-
-       function getIndexField() {
-               return 'rc_timestamp';
-       }
-
-       function formatRow( $row ) {
-               return $this->mForm->formatRow( $row );
-       }
-
-       function getStartBody() {
-               # Do a batch existence check on pages
-               $linkBatch = new LinkBatch();
-               foreach ( $this->mResult as $row ) {
-                       $linkBatch->add( NS_USER, $row->rc_user_text );
-                       $linkBatch->add( NS_USER_TALK, $row->rc_user_text );
-                       $linkBatch->add( $row->page_namespace, $row->page_title );
-               }
-               $linkBatch->execute();
-
-               return '<ul>';
-       }
 
-       function getEndBody() {
-               return '</ul>';
+       protected function getCacheTTL() {
+               return 60 * 5;
        }
 }