MediaWiki
REL1_41
ProtectedTitlesPager.php
Go to the documentation of this file.
1
<?php
22
namespace
MediaWiki\Pager
;
23
24
use
IContextSource
;
25
use
MediaWiki\Cache\LinkBatchFactory
;
26
use
MediaWiki\Html\Html
;
27
use
MediaWiki\Linker\Linker
;
28
use
MediaWiki\Linker\LinkRenderer
;
29
use
MediaWiki\Title\Title
;
30
use
Wikimedia\Rdbms\IConnectionProvider
;
31
35
class
ProtectedTitlesPager
extends
AlphabeticPager
{
36
40
public
$mConds
;
41
43
private
$level;
44
46
private
$namespace;
47
48
private
LinkBatchFactory
$linkBatchFactory;
49
62
public
function
__construct
(
63
IContextSource
$context,
64
LinkRenderer
$linkRenderer,
65
LinkBatchFactory
$linkBatchFactory,
66
IConnectionProvider
$dbProvider,
67
$conds,
68
$type,
69
$level,
70
$namespace,
71
$sizetype,
72
$size
73
) {
74
// Set database before parent constructor to avoid setting it there with wfGetDB
75
$this->mDb = $dbProvider->
getReplicaDatabase
();
76
$this->mConds = $conds;
77
$this->level = $level;
78
$this->
namespace
= $namespace;
79
parent::__construct( $context, $linkRenderer );
80
$this->linkBatchFactory = $linkBatchFactory;
81
}
82
83
protected
function
doBatchLookups
() {
84
$this->mResult->seek( 0 );
85
$lb = $this->linkBatchFactory->newLinkBatch();
86
87
foreach
( $this->mResult as $row ) {
88
$lb->add( $row->pt_namespace, $row->pt_title );
89
}
90
91
$lb->execute();
92
}
93
94
public
function
formatRow
( $row ) {
95
$title = Title::makeTitleSafe( $row->pt_namespace, $row->pt_title );
96
if
( !$title ) {
97
return
Html::rawElement(
98
'li'
,
99
[],
100
Html::element(
101
'span'
,
102
[
'class'
=>
'mw-invalidtitle'
],
103
Linker::getInvalidTitleDescription(
104
$this->
getContext
(),
105
$row->pt_namespace,
106
$row->pt_title
107
)
108
)
109
) .
"\n"
;
110
}
111
112
$link = $this->
getLinkRenderer
()->makeLink( $title );
113
// Messages: restriction-level-sysop, restriction-level-autoconfirmed
114
$description = $this->
msg
(
'restriction-level-'
. $row->pt_create_perm )->escaped();
115
$lang = $this->
getLanguage
();
116
$expiry = strlen( $row->pt_expiry ) ?
117
$lang->formatExpiry( $row->pt_expiry, TS_MW ) :
118
'infinity'
;
119
120
if
( $expiry !==
'infinity'
) {
121
$user = $this->
getUser
();
122
$description .= $this->
msg
(
'comma-separator'
)->escaped() . $this->
msg
(
123
'protect-expiring-local'
,
124
$lang->userTimeAndDate( $expiry, $user ),
125
$lang->userDate( $expiry, $user ),
126
$lang->userTime( $expiry, $user )
127
)->escaped();
128
}
129
130
return
'<li>'
. $lang->specialList( $link, $description ) .
"</li>\n"
;
131
}
132
136
public
function
getQueryInfo
() {
137
$dbr = $this->
getDatabase
();
138
$conds =
$this->mConds
;
139
$conds[] =
'pt_expiry > '
. $dbr->addQuotes( $this->mDb->timestamp() ) .
140
' OR pt_expiry IS NULL'
;
141
if
( $this->level ) {
142
$conds[
'pt_create_perm'
] = $this->level;
143
}
144
145
if
( $this->
namespace
!==
null
) {
146
$conds[] =
'pt_namespace='
. $dbr->addQuotes( $this->
namespace
);
147
}
148
149
return
[
150
'tables'
=>
'protected_titles'
,
151
'fields'
=> [
'pt_namespace'
,
'pt_title'
,
'pt_create_perm'
,
152
'pt_expiry'
,
'pt_timestamp'
],
153
'conds'
=> $conds
154
];
155
}
156
157
public
function
getIndexField
() {
158
return
[ [
'pt_timestamp'
,
'pt_namespace'
,
'pt_title'
] ];
159
}
160
}
161
166
class_alias( ProtectedTitlesPager::class,
'ProtectedTitlesPager'
);
ContextSource\getUser
getUser()
Definition
ContextSource.php:152
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition
ContextSource.php:202
ContextSource\getLanguage
getLanguage()
Definition
ContextSource.php:169
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition
ContextSource.php:52
MediaWiki\Cache\LinkBatchFactory
Definition
LinkBatchFactory.php:41
MediaWiki\Html\Html
This class is a collection of static functions that serve two purposes:
Definition
Html.php:57
MediaWiki\Linker\LinkRenderer
Class that generates HTML for internal links.
Definition
LinkRenderer.php:45
MediaWiki\Linker\Linker
Some internal bits split of from Skin.php.
Definition
Linker.php:65
MediaWiki\Pager\AlphabeticPager
IndexPager with an alphabetic list and a formatted navigation bar.
Definition
AlphabeticPager.php:29
MediaWiki\Pager\IndexPager\getDatabase
getDatabase()
Get the Database object in use.
Definition
IndexPager.php:256
MediaWiki\Pager\IndexPager\getLinkRenderer
getLinkRenderer()
Definition
IndexPager.php:961
MediaWiki\Pager\ProtectedTitlesPager
Definition
ProtectedTitlesPager.php:35
MediaWiki\Pager\ProtectedTitlesPager\getQueryInfo
getQueryInfo()
Definition
ProtectedTitlesPager.php:136
MediaWiki\Pager\ProtectedTitlesPager\__construct
__construct(IContextSource $context, LinkRenderer $linkRenderer, LinkBatchFactory $linkBatchFactory, IConnectionProvider $dbProvider, $conds, $type, $level, $namespace, $sizetype, $size)
Definition
ProtectedTitlesPager.php:62
MediaWiki\Pager\ProtectedTitlesPager\doBatchLookups
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
Definition
ProtectedTitlesPager.php:83
MediaWiki\Pager\ProtectedTitlesPager\$mConds
array $mConds
Definition
ProtectedTitlesPager.php:40
MediaWiki\Pager\ProtectedTitlesPager\getIndexField
getIndexField()
Returns the name of the index field.
Definition
ProtectedTitlesPager.php:157
MediaWiki\Pager\ProtectedTitlesPager\formatRow
formatRow( $row)
Returns an HTML string representing the result row $row.
Definition
ProtectedTitlesPager.php:94
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:76
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition
IContextSource.php:64
Wikimedia\Rdbms\IConnectionProvider
Provide primary and replica IDatabase connections.
Definition
IConnectionProvider.php:35
Wikimedia\Rdbms\IConnectionProvider\getReplicaDatabase
getReplicaDatabase( $domain=false, $group=null)
Get connection to a replica database.
MediaWiki\Pager
Definition
HistoryPager.php:24
includes
specials
pagers
ProtectedTitlesPager.php
Generated on Wed Nov 27 2024 07:25:07 for MediaWiki by
1.10.0