37 private $commentStore;
40 private $linkBatchFactory;
46 private $rowCommentFormatter;
49 private $formattedComments = [];
89 parent::__construct( $context, $linkRenderer );
90 $this->commentStore = $commentStore;
91 $this->linkBatchFactory = $linkBatchFactory;
92 $this->rowCommentFormatter = $rowCommentFormatter;
93 $this->userCache = $userCache;
94 $this->mConds = $conds;
95 $this->type = $type ?:
'edit';
97 $this->
namespace = $namespace;
99 $this->size = intval(
$size );
106 # Do a link batch query
107 $lb = $this->linkBatchFactory->newLinkBatch();
110 foreach ( $result as $row ) {
111 $lb->add( $row->page_namespace, $row->page_title );
112 if ( $row->actor_user !==
null ) {
113 $userids[] = $row->actor_user;
118 if ( count( $userids ) ) {
119 $this->userCache->doQuery( $userids, [], __METHOD__ );
120 foreach ( $userids as $userid ) {
121 $name = $this->userCache->getProp( $userid,
'name' );
122 if ( $name !==
false ) {
132 $this->formattedComments = $this->rowCommentFormatter->formatRows( $result,
'log_comment' );
136 static $headers =
null;
138 if ( $headers == [] ) {
140 'log_timestamp' =>
'protectedpages-timestamp',
141 'pr_page' =>
'protectedpages-page',
142 'pr_expiry' =>
'protectedpages-expiry',
143 'actor_user' =>
'protectedpages-performer',
144 'pr_params' =>
'protectedpages-params',
145 'log_comment' =>
'protectedpages-reason',
147 foreach ( $headers as $key => $val ) {
148 $headers[$key] = $this->
msg( $val )->text();
167 case 'log_timestamp':
169 if ( $value ===
null ) {
170 $formatted = Html::rawElement(
172 [
'class' =>
'mw-protectedpages-unknown' ],
173 $this->
msg(
'protectedpages-unknown-timestamp' )->escaped()
176 $formatted = htmlspecialchars( $this->
getLanguage()->userTimeAndDate(
182 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
184 $formatted = Html::element(
186 [
'class' =>
'mw-invalidtitle' ],
187 Linker::getInvalidTitleDescription(
189 $row->page_namespace,
194 $formatted = $linkRenderer->makeLink(
$title );
196 if ( $row->page_len !==
null ) {
198 ' ' . Html::rawElement(
200 [
'class' =>
'mw-protectedpages-length' ],
201 Linker::formatRevisionSize( $row->page_len )
207 $formatted = htmlspecialchars( $this->
getLanguage()->formatExpiry(
208 $value,
true,
'infinity', $this->
getUser() ) );
209 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
211 $changeProtection = $linkRenderer->makeKnownLink(
213 $this->
msg(
'protect_change' )->text(),
215 [
'action' =>
'unprotect' ]
217 $formatted .=
' ' . Html::rawElement(
219 [
'class' =>
'mw-protectedpages-actions' ],
220 $this->
msg(
'parentheses' )->rawParams( $changeProtection )->escaped()
227 if ( $row->log_timestamp ===
null ) {
228 $formatted = Html::rawElement(
230 [
'class' =>
'mw-protectedpages-unknown' ],
231 $this->
msg(
'protectedpages-unknown-performer' )->escaped()
234 $username = $row->actor_name;
238 $this->getAuthority()
240 $formatted = Linker::userLink( (
int)$value, $username )
241 . Linker::userToolLinks( (
int)$value, $username );
243 $formatted = $this->
msg(
'rev-deleted-user' )->escaped();
246 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
254 $params[] = $this->
msg(
'restriction-level-' . $row->pr_level )->escaped();
255 if ( $row->pr_cascade ) {
256 $params[] = $this->
msg(
'protect-summary-cascade' )->escaped();
258 $formatted = $this->
getLanguage()->commaList( $params );
263 if ( $row->log_timestamp ===
null ) {
264 $formatted = Html::rawElement(
266 [
'class' =>
'mw-protectedpages-unknown' ],
267 $this->
msg(
'protectedpages-unknown-reason' )->escaped()
273 $this->getAuthority()
277 $formatted = $this->
msg(
'rev-deleted-comment' )->escaped();
280 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
295 $conds[] =
'pr_expiry > ' .
$dbr->addQuotes(
$dbr->timestamp() ) .
296 ' OR pr_expiry IS NULL';
297 $conds[] =
'page_id=pr_page';
298 $conds[] =
'pr_type=' .
$dbr->addQuotes( $this->type );
300 if ( $this->sizetype ==
'min' ) {
302 } elseif ( $this->sizetype ==
'max' ) {
306 if ( $this->indefonly ) {
307 $infinity =
$dbr->addQuotes(
$dbr->getInfinity() );
308 $conds[] =
"pr_expiry = $infinity OR pr_expiry IS NULL";
310 if ( $this->cascadeonly ) {
311 $conds[] =
'pr_cascade = 1';
313 if ( $this->noredirect ) {
314 $conds[] =
'page_is_redirect = 0';
317 if ( $this->level ) {
318 $conds[] =
'pr_level=' .
$dbr->addQuotes( $this->level );
320 if ( $this->
namespace !==
null ) {
321 $conds[] =
'page_namespace=' .
$dbr->addQuotes( $this->
namespace );
324 $commentQuery = $this->commentStore->getJoin(
'log_comment' );
328 'page',
'page_restrictions',
'log_search',
329 'logparen' => [
'logging',
'actor' ] + $commentQuery[
'tables'],
344 ] + $commentQuery[
'fields'],
349 'ls_field' =>
'pr_id',
'ls_value = ' .
$dbr->buildStringCast(
'pr_id' )
362 ] + $commentQuery[
'joins']
367 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 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)
Interface for objects which can provide a MediaWiki context on request.