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
|
|
|
public $mForm, $mConds; |
|
|
|
|
28
|
|
|
|
29
|
|
|
function __construct( $form, $conds = [], $type, $level, $namespace, |
30
|
|
|
$sizetype = '', $size = 0 |
31
|
|
|
) { |
32
|
|
|
$this->mForm = $form; |
33
|
|
|
$this->mConds = $conds; |
34
|
|
|
$this->level = $level; |
|
|
|
|
35
|
|
|
$this->namespace = $namespace; |
|
|
|
|
36
|
|
|
$this->size = intval( $size ); |
|
|
|
|
37
|
|
|
parent::__construct( $form->getContext() ); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function getStartBody() { |
41
|
|
|
# Do a link batch query |
42
|
|
|
$this->mResult->seek( 0 ); |
43
|
|
|
$lb = new LinkBatch; |
44
|
|
|
|
45
|
|
|
foreach ( $this->mResult as $row ) { |
46
|
|
|
$lb->add( $row->pt_namespace, $row->pt_title ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$lb->execute(); |
50
|
|
|
|
51
|
|
|
return ''; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return Title |
56
|
|
|
*/ |
57
|
|
|
function getTitle() { |
58
|
|
|
return $this->mForm->getTitle(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function formatRow( $row ) { |
62
|
|
|
return $this->mForm->formatRow( $row ); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
|
|
function getQueryInfo() { |
69
|
|
|
$conds = $this->mConds; |
70
|
|
|
$conds[] = 'pt_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) . |
71
|
|
|
' OR pt_expiry IS NULL'; |
72
|
|
|
if ( $this->level ) { |
73
|
|
|
$conds['pt_create_perm'] = $this->level; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
View Code Duplication |
if ( !is_null( $this->namespace ) ) { |
77
|
|
|
$conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return [ |
81
|
|
|
'tables' => 'protected_titles', |
82
|
|
|
'fields' => [ 'pt_namespace', 'pt_title', 'pt_create_perm', |
83
|
|
|
'pt_expiry', 'pt_timestamp' ], |
84
|
|
|
'conds' => $conds |
85
|
|
|
]; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
function getIndexField() { |
89
|
|
|
return 'pt_timestamp'; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.