MediaWiki  master
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 
59  public function __construct(
60  $form,
61  $conds,
62  $type,
63  $level,
64  $namespace,
65  $sizetype = '',
66  $size = 0,
68  ) {
69  $this->mForm = $form;
70  $this->mConds = $conds;
71  $this->level = $level;
72  $this->namespace = $namespace;
73  parent::__construct( $form->getContext() );
74  $this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
75  }
76 
77  protected function getStartBody() {
78  # Do a link batch query
79  $this->mResult->seek( 0 );
80  $lb = $this->linkBatchFactory->newLinkBatch();
81 
82  foreach ( $this->mResult as $row ) {
83  $lb->add( $row->pt_namespace, $row->pt_title );
84  }
85 
86  $lb->execute();
87 
88  return '';
89  }
90 
94  public function getTitle() {
95  return $this->mForm->getPageTitle();
96  }
97 
98  public function formatRow( $row ) {
99  return $this->mForm->formatRow( $row );
100  }
101 
105  public function getQueryInfo() {
106  $conds = $this->mConds;
107  $conds[] = 'pt_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) .
108  ' OR pt_expiry IS NULL';
109  if ( $this->level ) {
110  $conds['pt_create_perm'] = $this->level;
111  }
112 
113  if ( $this->namespace !== null ) {
114  $conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace );
115  }
116 
117  return [
118  'tables' => 'protected_titles',
119  'fields' => [ 'pt_namespace', 'pt_title', 'pt_create_perm',
120  'pt_expiry', 'pt_timestamp' ],
121  'conds' => $conds
122  ];
123  }
124 
125  public function getIndexField() {
126  return 'pt_timestamp';
127  }
128 }
ProtectedTitlesPager\$linkBatchFactory
LinkBatchFactory $linkBatchFactory
Definition: ProtectedTitlesPager.php:47
ProtectedTitlesPager\getTitle
getTitle()
Definition: ProtectedTitlesPager.php:94
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:157
AlphabeticPager
IndexPager with an alphabetic list and a formatted navigation bar Stable to extend.
Definition: AlphabeticPager.php:29
SpecialProtectedtitles
A special page that list protected titles from creation.
Definition: SpecialProtectedtitles.php:31
ProtectedTitlesPager\getIndexField
getIndexField()
Returns the name of the index field.
Definition: ProtectedTitlesPager.php:125
ProtectedTitlesPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: ProtectedTitlesPager.php:77
ProtectedTitlesPager\getQueryInfo
getQueryInfo()
Definition: ProtectedTitlesPager.php:105
ProtectedTitlesPager\formatRow
formatRow( $row)
Returns an HTML string representing the result row $row.
Definition: ProtectedTitlesPager.php:98
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:38
ProtectedTitlesPager\$namespace
int null $namespace
Definition: ProtectedTitlesPager.php:44
ProtectedTitlesPager
Definition: ProtectedTitlesPager.php:28
ProtectedTitlesPager\$level
string null $level
Definition: ProtectedTitlesPager.php:41
ProtectedTitlesPager\$mConds
array $mConds
Definition: ProtectedTitlesPager.php:38
ProtectedTitlesPager\__construct
__construct( $form, $conds, $type, $level, $namespace, $sizetype='', $size=0, LinkBatchFactory $linkBatchFactory=null)
Definition: ProtectedTitlesPager.php:59
ProtectedTitlesPager\$mForm
SpecialProtectedtitles $mForm
Definition: ProtectedTitlesPager.php:33
$type
$type
Definition: testCompression.php:52