MediaWiki REL1_37
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
48
60 public function __construct(
61 $form,
62 $conds,
63 $type,
64 $level,
66 $sizetype,
67 $size,
69 ILoadBalancer $loadBalancer
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.
LinkBatchFactory $linkBatchFactory
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.
__construct( $form, $conds, $type, $level, $namespace, $sizetype, $size, LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer)
getIndexField()
Returns the name of the index field.
A special page that list protected titles from creation.
Database cluster connection, tracking, load balancing, and transaction manager interface.
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a live database handle reference for a server index.