MediaWiki REL1_33
NewPagesPager.php
Go to the documentation of this file.
1<?php
26
30 protected $opts;
31
35 protected $mForm;
36
41 public function __construct( $form, FormOptions $opts ) {
42 parent::__construct( $form->getContext() );
43 $this->mForm = $form;
44 $this->opts = $opts;
45 }
46
47 function getQueryInfo() {
48 $rcQuery = RecentChange::getQueryInfo();
49
50 $conds = [];
51 $conds['rc_new'] = 1;
52
53 $namespace = $this->opts->getValue( 'namespace' );
54 $namespace = ( $namespace === 'all' ) ? false : intval( $namespace );
55
56 $username = $this->opts->getValue( 'username' );
57 $user = Title::makeTitleSafe( NS_USER, $username );
58
59 $size = abs( intval( $this->opts->getValue( 'size' ) ) );
60 if ( $size > 0 ) {
61 if ( $this->opts->getValue( 'size-mode' ) === 'max' ) {
62 $conds[] = 'page_len <= ' . $size;
63 } else {
64 $conds[] = 'page_len >= ' . $size;
65 }
66 }
67
68 if ( $namespace !== false ) {
69 if ( $this->opts->getValue( 'invert' ) ) {
70 $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace );
71 } else {
72 $conds['rc_namespace'] = $namespace;
73 }
74 }
75
76 if ( $user ) {
77 $conds[] = ActorMigration::newMigration()->getWhere(
78 $this->mDb, 'rc_user', User::newFromName( $user->getText(), false ), false
79 )['conds'];
80 } elseif ( User::groupHasPermission( '*', 'createpage' ) &&
81 $this->opts->getValue( 'hideliu' )
82 ) {
83 # If anons cannot make new pages, don't "exclude logged in users"!
84 $conds[] = ActorMigration::newMigration()->isAnon( $rcQuery['fields']['rc_user'] );
85 }
86
87 # If this user cannot see patrolled edits or they are off, don't do dumb queries!
88 if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
89 $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
90 }
91
92 if ( $this->opts->getValue( 'hidebots' ) ) {
93 $conds['rc_bot'] = 0;
94 }
95
96 if ( $this->opts->getValue( 'hideredirs' ) ) {
97 $conds['page_is_redirect'] = 0;
98 }
99
100 // Allow changes to the New Pages query
101 $tables = array_merge( $rcQuery['tables'], [ 'page' ] );
102 $fields = array_merge( $rcQuery['fields'], [
103 'length' => 'page_len', 'rev_id' => 'page_latest', 'page_namespace', 'page_title'
104 ] );
105 $join_conds = [ 'page' => [ 'JOIN', 'page_id=rc_cur_id' ] ] + $rcQuery['joins'];
106
107 // Avoid PHP 7.1 warning from passing $this by reference
108 $pager = $this;
109 Hooks::run( 'SpecialNewpagesConditions',
110 [ &$pager, $this->opts, &$conds, &$tables, &$fields, &$join_conds ] );
111
112 $info = [
113 'tables' => $tables,
114 'fields' => $fields,
115 'conds' => $conds,
116 'options' => [],
117 'join_conds' => $join_conds
118 ];
119
120 // Modify query for tags
122 $info['tables'],
123 $info['fields'],
124 $info['conds'],
125 $info['join_conds'],
126 $info['options'],
127 $this->opts['tagfilter']
128 );
129
130 return $info;
131 }
132
133 function getIndexField() {
134 return 'rc_timestamp';
135 }
136
137 function formatRow( $row ) {
138 return $this->mForm->formatRow( $row );
139 }
140
141 protected function getStartBody() {
142 # Do a batch existence check on pages
143 $linkBatch = new LinkBatch();
144 foreach ( $this->mResult as $row ) {
145 $linkBatch->add( NS_USER, $row->rc_user_text );
146 $linkBatch->add( NS_USER_TALK, $row->rc_user_text );
147 $linkBatch->add( $row->page_namespace, $row->page_title );
148 }
149 $linkBatch->execute();
150
151 return '<ul>';
152 }
153
154 protected function getEndBody() {
155 return '</ul>';
156 }
157}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Helper class to keep track of options when mixing links and form elements.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:34
formatRow( $row)
Abstract formatting function.
SpecialNewpages $mForm
FormOptions $opts
__construct( $form, FormOptions $opts)
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
getIndexField()
This function should be overridden to return the name of the index fi- eld.
getEndBody()
Hook into getBody() for the end of the list.
Efficient paging for SQL queries.
A special page that list newly created pages.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:585
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
Definition User.php:5062
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition hooks.txt:996
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:782
const NS_USER_TALK
Definition Defines.php:76