MediaWiki REL1_39
ProtectedTitlesPager.php
Go to the documentation of this file.
1<?php
24
29
33 public $mForm;
34
38 public $mConds;
39
41 private $level;
42
44 private $namespace;
45
47 private $linkBatchFactory;
48
60 public function __construct(
62 LinkBatchFactory $linkBatchFactory,
63 ILoadBalancer $loadBalancer,
64 $conds,
65 $type,
66 $level,
67 $namespace,
68 $sizetype,
69 $size
70 ) {
71 // Set database before parent constructor to avoid setting it there with wfGetDB
72 $this->mDb = $loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
73 $this->mForm = $form;
74 $this->mConds = $conds;
75 $this->level = $level;
76 $this->namespace = $namespace;
77 parent::__construct( $form->getContext() );
78 $this->linkBatchFactory = $linkBatchFactory;
79 }
80
81 protected function getStartBody() {
82 # Do a link batch query
83 $this->mResult->seek( 0 );
84 $lb = $this->linkBatchFactory->newLinkBatch();
85
86 foreach ( $this->mResult as $row ) {
87 $lb->add( $row->pt_namespace, $row->pt_title );
88 }
89
90 $lb->execute();
91
92 return '';
93 }
94
98 public function getTitle() {
99 return $this->mForm->getPageTitle();
100 }
101
102 public function formatRow( $row ) {
103 return $this->mForm->formatRow( $row );
104 }
105
109 public function getQueryInfo() {
110 $dbr = $this->getDatabase();
111 $conds = $this->mConds;
112 $conds[] = 'pt_expiry > ' . $dbr->addQuotes( $this->mDb->timestamp() ) .
113 ' OR pt_expiry IS NULL';
114 if ( $this->level ) {
115 $conds['pt_create_perm'] = $this->level;
116 }
117
118 if ( $this->namespace !== null ) {
119 $conds[] = 'pt_namespace=' . $dbr->addQuotes( $this->namespace );
120 }
121
122 return [
123 'tables' => 'protected_titles',
124 'fields' => [ 'pt_namespace', 'pt_title', 'pt_create_perm',
125 'pt_expiry', 'pt_timestamp' ],
126 'conds' => $conds
127 ];
128 }
129
130 public function getIndexField() {
131 return 'pt_timestamp';
132 }
133}
IndexPager with an alphabetic list and a formatted navigation bar.
getDatabase()
Get the Database object in use.
__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.
Create and track the database connections and transactions for a given database cluster.
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)