46 LinkBatchFactory $linkBatchFactory,
61 parent::__construct( $context, $linkRenderer );
62 $this->commentStore = $commentStore;
63 $this->linkBatchFactory = $linkBatchFactory;
64 $this->rowCommentFormatter = $rowCommentFormatter;
65 $this->type = $type ??
'edit';
66 $this->level = $level;
67 $this->
namespace = $namespace;
68 $this->sizetype = $sizetype;
69 $this->size = $size ?? 0;
70 $this->indefonly = $indefonly;
71 $this->cascadeonly = $cascadeonly;
72 $this->noredirect = $noredirect;
77 # Do a link batch query
78 $lb = $this->linkBatchFactory->newLinkBatch();
79 $rowsWithComments = [];
81 foreach ( $result as $row ) {
82 $lb->add( $row->page_namespace, $row->page_title );
84 if ( $row->actor_name !==
null ) {
87 if ( $row->log_timestamp !==
null ) {
88 $rowsWithComments[] = $row;
95 $this->formattedComments = $this->rowCommentFormatter->formatRows(
136 case 'log_timestamp':
138 if ( $value ===
null ) {
139 $formatted = Html::rawElement(
141 [
'class' =>
'mw-protectedpages-unknown' ],
142 $this->
msg(
'protectedpages-unknown-timestamp' )->escaped()
145 $formatted = htmlspecialchars( $this->
getLanguage()->userTimeAndDate(
151 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
155 [
'class' =>
'mw-invalidtitle' ],
156 Linker::getInvalidTitleDescription(
158 $row->page_namespace,
163 $formatted = $linkRenderer->makeLink( $title );
165 $formatted = Html::rawElement(
'bdi', [
168 if ( $row->page_len !==
null ) {
169 $formatted .=
' ' . Html::rawElement(
171 [
'class' =>
'mw-protectedpages-length' ],
172 Linker::formatRevisionSize( $row->page_len )
178 $formatted = htmlspecialchars( $this->
getLanguage()->formatExpiry(
179 $value,
true,
'infinity', $this->
getUser() ) );
180 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
181 if ( $title && $this->
getAuthority()->isAllowed(
'protect' ) ) {
182 $changeProtection = $linkRenderer->makeKnownLink(
184 $this->
msg(
'protect_change' )->text(),
186 [
'action' =>
'unprotect' ]
188 $formatted .=
' ' . Html::rawElement(
190 [
'class' =>
'mw-protectedpages-actions' ],
191 $this->
msg(
'parentheses' )->rawParams( $changeProtection )->escaped()
198 if ( $row->log_timestamp ===
null ) {
199 $formatted = Html::rawElement(
201 [
'class' =>
'mw-protectedpages-unknown' ],
202 $this->
msg(
'protectedpages-unknown-performer' )->escaped()
205 $username = $row->actor_name;
206 if ( LogEventsList::userCanBitfield(
208 LogPage::DELETED_USER,
209 $this->getAuthority()
211 $formatted = Linker::userLink( (
int)$value, $username )
212 . Linker::userToolLinks( (
int)$value, $username );
214 $formatted = $this->
msg(
'rev-deleted-user' )->escaped();
216 if ( LogEventsList::isDeleted( $row, LogPage::DELETED_USER ) ) {
217 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
225 $params[] = $this->
msg(
'restriction-level-' . $row->pr_level )->escaped();
226 if ( $row->pr_cascade ) {
227 $params[] = $this->
msg(
'protect-summary-cascade' )->escaped();
229 $formatted = $this->
getLanguage()->commaList( $params );
234 if ( $row->log_timestamp ===
null ) {
235 $formatted = Html::rawElement(
237 [
'class' =>
'mw-protectedpages-unknown' ],
238 $this->
msg(
'protectedpages-unknown-reason' )->escaped()
241 if ( LogEventsList::userCanBitfield(
243 LogPage::DELETED_COMMENT,
244 $this->getAuthority()
246 $formatted = $this->formattedComments[$row->pr_id];
248 $formatted = $this->
msg(
'rev-deleted-comment' )->escaped();
250 if ( LogEventsList::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
251 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
257 throw new UnexpectedValueException(
"Unknown field '$field'" );