resourceloader: Remove comment about XmlJsCode wrapper
[lhc/web/wiklou.git] / includes / specials / pagers / ProtectedTitlesPager.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Pager
20 */
21
22 /**
23 * @ingroup Pager
24 */
25 class ProtectedTitlesPager extends AlphabeticPager {
26
27 /**
28 * @var SpecialProtectedtitles
29 */
30 public $mForm;
31
32 /**
33 * @var array
34 */
35 public $mConds;
36
37 /**
38 * @param SpecialProtectedtitles $form
39 * @param array $conds
40 * @param string|null $type
41 * @param string|null $level
42 * @param int|null $namespace
43 * @param string|null $sizetype
44 * @param int|null $size
45 */
46 public function __construct( $form, $conds, $type, $level, $namespace,
47 $sizetype = '', $size = 0
48 ) {
49 $this->mForm = $form;
50 $this->mConds = $conds;
51 $this->level = $level;
52 $this->namespace = $namespace;
53 $this->size = intval( $size );
54 parent::__construct( $form->getContext() );
55 }
56
57 protected function getStartBody() {
58 # Do a link batch query
59 $this->mResult->seek( 0 );
60 $lb = new LinkBatch;
61
62 foreach ( $this->mResult as $row ) {
63 $lb->add( $row->pt_namespace, $row->pt_title );
64 }
65
66 $lb->execute();
67
68 return '';
69 }
70
71 /**
72 * @return Title
73 */
74 function getTitle() {
75 return $this->mForm->getPageTitle();
76 }
77
78 function formatRow( $row ) {
79 return $this->mForm->formatRow( $row );
80 }
81
82 /**
83 * @return array
84 */
85 function getQueryInfo() {
86 $conds = $this->mConds;
87 $conds[] = 'pt_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) .
88 ' OR pt_expiry IS NULL';
89 if ( $this->level ) {
90 $conds['pt_create_perm'] = $this->level;
91 }
92
93 if ( !is_null( $this->namespace ) ) {
94 $conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace );
95 }
96
97 return [
98 'tables' => 'protected_titles',
99 'fields' => [ 'pt_namespace', 'pt_title', 'pt_create_perm',
100 'pt_expiry', 'pt_timestamp' ],
101 'conds' => $conds
102 ];
103 }
104
105 function getIndexField() {
106 return 'pt_timestamp';
107 }
108 }