35 private $commentStore;
38 private $linkBatchFactory;
44 private $rowCommentFormatter;
47 private $formattedComments = [];
87 parent::__construct( $context, $linkRenderer );
88 $this->commentStore = $commentStore;
89 $this->linkBatchFactory = $linkBatchFactory;
90 $this->rowCommentFormatter = $rowCommentFormatter;
91 $this->userCache = $userCache;
92 $this->mConds = $conds;
93 $this->type = $type ?:
'edit';
95 $this->
namespace = $namespace;
97 $this->size = intval(
$size );
104 # Do a link batch query
105 $lb = $this->linkBatchFactory->newLinkBatch();
108 foreach ( $result as $row ) {
109 $lb->add( $row->page_namespace, $row->page_title );
110 if ( $row->actor_user !==
null ) {
111 $userids[] = $row->actor_user;
116 if ( count( $userids ) ) {
117 $this->userCache->doQuery( $userids, [], __METHOD__ );
118 foreach ( $userids as $userid ) {
119 $name = $this->userCache->getProp( $userid,
'name' );
120 if ( $name !==
false ) {
130 $this->formattedComments = $this->rowCommentFormatter->formatRows( $result,
'log_comment' );
134 static $headers =
null;
136 if ( $headers == [] ) {
138 'log_timestamp' =>
'protectedpages-timestamp',
139 'pr_page' =>
'protectedpages-page',
140 'pr_expiry' =>
'protectedpages-expiry',
141 'actor_user' =>
'protectedpages-performer',
142 'pr_params' =>
'protectedpages-params',
143 'log_comment' =>
'protectedpages-reason',
145 foreach ( $headers as $key => $val ) {
146 $headers[$key] = $this->
msg( $val )->text();
165 case 'log_timestamp':
167 if ( $value ===
null ) {
170 [
'class' =>
'mw-protectedpages-unknown' ],
171 $this->
msg(
'protectedpages-unknown-timestamp' )->escaped()
174 $formatted = htmlspecialchars( $this->
getLanguage()->userTimeAndDate(
184 [
'class' =>
'mw-invalidtitle' ],
185 Linker::getInvalidTitleDescription(
187 $row->page_namespace,
192 $formatted = $linkRenderer->makeLink(
$title );
194 if ( $row->page_len !==
null ) {
198 [
'class' =>
'mw-protectedpages-length' ],
199 Linker::formatRevisionSize( $row->page_len )
205 $formatted = htmlspecialchars( $this->
getLanguage()->formatExpiry(
206 $value,
true,
'infinity', $this->
getUser() ) );
209 $changeProtection = $linkRenderer->makeKnownLink(
211 $this->
msg(
'protect_change' )->text(),
213 [
'action' =>
'unprotect' ]
217 [
'class' =>
'mw-protectedpages-actions' ],
218 $this->
msg(
'parentheses' )->rawParams( $changeProtection )->escaped()
225 if ( $row->log_timestamp ===
null ) {
228 [
'class' =>
'mw-protectedpages-unknown' ],
229 $this->
msg(
'protectedpages-unknown-performer' )->escaped()
232 $username = $row->actor_name;
236 $this->getAuthority()
238 $formatted = Linker::userLink( (
int)$value, $username )
239 . Linker::userToolLinks( (
int)$value, $username );
241 $formatted = $this->
msg(
'rev-deleted-user' )->escaped();
244 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
252 $params[] = $this->
msg(
'restriction-level-' . $row->pr_level )->escaped();
253 if ( $row->pr_cascade ) {
254 $params[] = $this->
msg(
'protect-summary-cascade' )->escaped();
256 $formatted = $this->
getLanguage()->commaList( $params );
261 if ( $row->log_timestamp ===
null ) {
264 [
'class' =>
'mw-protectedpages-unknown' ],
265 $this->
msg(
'protectedpages-unknown-reason' )->escaped()
271 $this->getAuthority()
275 $formatted = $this->
msg(
'rev-deleted-comment' )->escaped();
278 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
293 $conds[] =
'pr_expiry > ' .
$dbr->addQuotes(
$dbr->timestamp() ) .
294 ' OR pr_expiry IS NULL';
295 $conds[] =
'page_id=pr_page';
296 $conds[] =
'pr_type=' .
$dbr->addQuotes( $this->type );
298 if ( $this->sizetype ==
'min' ) {
300 } elseif ( $this->sizetype ==
'max' ) {
304 if ( $this->indefonly ) {
305 $infinity =
$dbr->addQuotes(
$dbr->getInfinity() );
306 $conds[] =
"pr_expiry = $infinity OR pr_expiry IS NULL";
308 if ( $this->cascadeonly ) {
309 $conds[] =
'pr_cascade = 1';
311 if ( $this->noredirect ) {
312 $conds[] =
'page_is_redirect = 0';
315 if ( $this->level ) {
316 $conds[] =
'pr_level=' .
$dbr->addQuotes( $this->level );
318 if ( $this->
namespace !==
null ) {
319 $conds[] =
'page_namespace=' .
$dbr->addQuotes( $this->
namespace );
322 $commentQuery = $this->commentStore->getJoin(
'log_comment' );
326 'page',
'page_restrictions',
'log_search',
327 'logparen' => [
'logging',
'actor' ] + $commentQuery[
'tables'],
342 ] + $commentQuery[
'fields'],
347 'ls_field' =>
'pr_id',
'ls_value = ' .
$dbr->buildStringCast(
'pr_id' )
360 ] + $commentQuery[
'joins']
365 return parent::getTableClass() .
' mw-protectedpages';
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static userCanBitfield( $bitfield, $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
static isDeleted( $row, $field)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Interface for objects which can provide a MediaWiki context on request.