MediaWiki  1.28.0
NewPagesPager.php
Go to the documentation of this file.
1 <?php
26 
27  // Stored opts
28  protected $opts;
29 
33  protected $mForm;
34 
35  function __construct( $form, FormOptions $opts ) {
36  parent::__construct( $form->getContext() );
37  $this->mForm = $form;
38  $this->opts = $opts;
39  }
40 
41  function getQueryInfo() {
42  $conds = [];
43  $conds['rc_new'] = 1;
44 
45  $namespace = $this->opts->getValue( 'namespace' );
46  $namespace = ( $namespace === 'all' ) ? false : intval( $namespace );
47 
48  $username = $this->opts->getValue( 'username' );
50 
51  $rcIndexes = [];
52 
53  if ( $namespace !== false ) {
54  if ( $this->opts->getValue( 'invert' ) ) {
55  $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace );
56  } else {
57  $conds['rc_namespace'] = $namespace;
58  }
59  }
60 
61  if ( $user ) {
62  $conds['rc_user_text'] = $user->getText();
63  $rcIndexes = 'rc_user_text';
64  } elseif ( User::groupHasPermission( '*', 'createpage' ) &&
65  $this->opts->getValue( 'hideliu' )
66  ) {
67  # If anons cannot make new pages, don't "exclude logged in users"!
68  $conds['rc_user'] = 0;
69  }
70 
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;
74  }
75 
76  if ( $this->opts->getValue( 'hidebots' ) ) {
77  $conds['rc_bot'] = 0;
78  }
79 
80  if ( $this->opts->getValue( 'hideredirs' ) ) {
81  $conds['page_is_redirect'] = 0;
82  }
83 
84  // Allow changes to the New Pages query
85  $tables = [ 'recentchanges', 'page' ];
86  $fields = [
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'
91  ];
92  $join_conds = [ 'page' => [ 'INNER JOIN', 'page_id=rc_cur_id' ] ];
93 
94  Hooks::run( 'SpecialNewpagesConditions',
95  [ &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ] );
96 
97  $options = [];
98 
99  if ( $rcIndexes ) {
100  $options = [ 'USE INDEX' => [ 'recentchanges' => $rcIndexes ] ];
101  }
102 
103  $info = [
104  'tables' => $tables,
105  'fields' => $fields,
106  'conds' => $conds,
107  'options' => $options,
108  'join_conds' => $join_conds
109  ];
110 
111  // Modify query for tags
113  $info['tables'],
114  $info['fields'],
115  $info['conds'],
116  $info['join_conds'],
117  $info['options'],
118  $this->opts['tagfilter']
119  );
120 
121  return $info;
122  }
123 
124  function getIndexField() {
125  return 'rc_timestamp';
126  }
127 
128  function formatRow( $row ) {
129  return $this->mForm->formatRow( $row );
130  }
131 
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 );
139  }
140  $linkBatch->execute();
141 
142  return '<ul>';
143  }
144 
145  function getEndBody() {
146  return '</ul>';
147  }
148 }
HtmlForm $mForm
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
IndexPager with a formatted navigation bar.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:1007
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:32
static groupHasPermission($group, $role)
Check, if the given group has the given permission.
Definition: User.php:4625
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1046
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:535
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition: hooks.txt:242
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
Definition: ChangeTags.php:629
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:802
const NS_USER_TALK
Definition: Defines.php:59
getUser()
Get the User object.
__construct($form, FormOptions $opts)