MediaWiki  master
ProtectedTitlesPager.php
Go to the documentation of this file.
1 <?php
25 
30 
34  public $mForm;
35 
39  public $mConds;
40 
42  private $level;
43 
45  private $namespace;
46 
48  private $linkBatchFactory;
49 
61  public function __construct(
63  LinkBatchFactory $linkBatchFactory,
64  ILoadBalancer $loadBalancer,
65  $conds,
66  $type,
67  $level,
68  $namespace,
69  $sizetype,
70  $size
71  ) {
72  // Set database before parent constructor to avoid setting it there with wfGetDB
73  $this->mDb = $loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
74  $this->mForm = $form;
75  $this->mConds = $conds;
76  $this->level = $level;
77  $this->namespace = $namespace;
78  parent::__construct( $form->getContext() );
79  $this->linkBatchFactory = $linkBatchFactory;
80  }
81 
82  protected function getStartBody() {
83  # Do a link batch query
84  $this->mResult->seek( 0 );
85  $lb = $this->linkBatchFactory->newLinkBatch();
86 
87  foreach ( $this->mResult as $row ) {
88  $lb->add( $row->pt_namespace, $row->pt_title );
89  }
90 
91  $lb->execute();
92 
93  return '';
94  }
95 
99  public function getTitle() {
100  return $this->mForm->getPageTitle();
101  }
102 
103  public function formatRow( $row ) {
104  return $this->mForm->formatRow( $row );
105  }
106 
110  public function getQueryInfo() {
111  $dbr = $this->getDatabase();
112  $conds = $this->mConds;
113  $conds[] = 'pt_expiry > ' . $dbr->addQuotes( $this->mDb->timestamp() ) .
114  ' OR pt_expiry IS NULL';
115  if ( $this->level ) {
116  $conds['pt_create_perm'] = $this->level;
117  }
118 
119  if ( $this->namespace !== null ) {
120  $conds[] = 'pt_namespace=' . $dbr->addQuotes( $this->namespace );
121  }
122 
123  return [
124  'tables' => 'protected_titles',
125  'fields' => [ 'pt_namespace', 'pt_title', 'pt_create_perm',
126  'pt_expiry', 'pt_timestamp' ],
127  'conds' => $conds
128  ];
129  }
130 
131  public function getIndexField() {
132  return [ [ 'pt_timestamp', 'pt_namespace', 'pt_title' ] ];
133  }
134 }
IndexPager with an alphabetic list and a formatted navigation bar.
getDatabase()
Get the Database object in use.
Definition: IndexPager.php:250
Represents a title within MediaWiki.
Definition: Title.php:82
__construct(SpecialProtectedtitles $form, LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, $conds, $type, $level, $namespace, $sizetype, $size)
formatRow( $row)
Returns an HTML string representing the result row $row.
SpecialProtectedtitles $mForm
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
getIndexField()
Returns the name of the index field.
getContext()
Gets the context this SpecialPage is executed in.
A special page that list protected titles from creation.
This class is a delegate to ILBFactory for a given database cluster.
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
const DB_REPLICA
Definition: defines.php:26