3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
25 class NewPagesPager
extends ReverseChronologicalPager
{
35 function __construct( $form, FormOptions
$opts ) {
36 parent
::__construct( $form->getContext() );
41 function getQueryInfo() {
45 $namespace = $this->opts
->getValue( 'namespace' );
46 $namespace = ( $namespace === 'all' ) ?
false : intval( $namespace );
48 $username = $this->opts
->getValue( 'username' );
49 $user = Title
::makeTitleSafe( NS_USER
, $username );
53 if ( $namespace !== false ) {
54 if ( $this->opts
->getValue( 'invert' ) ) {
55 $conds[] = 'rc_namespace != ' . $this->mDb
->addQuotes( $namespace );
57 $conds['rc_namespace'] = $namespace;
62 $conds['rc_user_text'] = $user->getText();
63 $rcIndexes = 'rc_user_text';
64 } elseif ( User
::groupHasPermission( '*', 'createpage' ) &&
65 $this->opts
->getValue( 'hideliu' )
67 # If anons cannot make new pages, don't "exclude logged in users"!
68 $conds['rc_user'] = 0;
71 # If this user cannot see patrolled edits or they are off, don't do dumb queries!
72 if ( $this->opts
->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
73 $conds['rc_patrolled'] = 0;
76 if ( $this->opts
->getValue( 'hidebots' ) ) {
80 if ( $this->opts
->getValue( 'hideredirs' ) ) {
81 $conds['page_is_redirect'] = 0;
84 // Allow changes to the New Pages query
85 $tables = [ 'recentchanges', 'page' ];
87 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text',
88 'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted',
89 'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid',
90 'page_namespace', 'page_title'
92 $join_conds = [ 'page' => [ 'INNER JOIN', 'page_id=rc_cur_id' ] ];
94 Hooks
::run( 'SpecialNewpagesConditions',
95 [ &$this, $this->opts
, &$conds, &$tables, &$fields, &$join_conds ] );
100 $options = [ 'USE INDEX' => [ 'recentchanges' => $rcIndexes ] ];
107 'options' => $options,
108 'join_conds' => $join_conds
111 // Modify query for tags
112 ChangeTags
::modifyDisplayQuery(
118 $this->opts
['tagfilter']
124 function getIndexField() {
125 return 'rc_timestamp';
128 function formatRow( $row ) {
129 return $this->mForm
->formatRow( $row );
132 function getStartBody() {
133 # Do a batch existence check on pages
134 $linkBatch = new LinkBatch();
135 foreach ( $this->mResult
as $row ) {
136 $linkBatch->add( NS_USER
, $row->rc_user_text
);
137 $linkBatch->add( NS_USER_TALK
, $row->rc_user_text
);
138 $linkBatch->add( $row->page_namespace
, $row->page_title
);
140 $linkBatch->execute();
145 function getEndBody() {