98 parent::__construct( $context, $linkRenderer );
99 $this->commentStore = $commentStore;
100 $this->linkBatchFactory = $linkBatchFactory;
101 $this->rowCommentFormatter = $rowCommentFormatter;
102 $this->type = $type ?:
'edit';
103 $this->level = $level;
104 $this->
namespace = $namespace;
105 $this->sizetype = $sizetype;
106 $this->size = intval( $size );
107 $this->indefonly = (bool)$indefonly;
108 $this->cascadeonly = (bool)$cascadeonly;
109 $this->noredirect = (bool)$noredirect;
113 # Do a link batch query
114 $lb = $this->linkBatchFactory->newLinkBatch();
115 $rowsWithComments = [];
117 foreach ( $result as $row ) {
118 $lb->add( $row->page_namespace, $row->page_title );
120 if ( $row->actor_name !==
null ) {
121 $lb->add(
NS_USER, $row->actor_name );
124 if ( $row->log_timestamp !==
null ) {
125 $rowsWithComments[] = $row;
132 $this->formattedComments = $this->rowCommentFormatter->formatRows(
172 case 'log_timestamp':
174 if ( $value ===
null ) {
175 $formatted = Html::rawElement(
177 [
'class' =>
'mw-protectedpages-unknown' ],
178 $this->
msg(
'protectedpages-unknown-timestamp' )->escaped()
181 $formatted = htmlspecialchars( $this->
getLanguage()->userTimeAndDate(
187 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
191 [
'class' =>
'mw-invalidtitle' ],
192 Linker::getInvalidTitleDescription(
194 $row->page_namespace,
199 $formatted = $linkRenderer->makeLink( $title );
201 $formatted = Html::rawElement(
'bdi', [
204 if ( $row->page_len !==
null ) {
205 $formatted .=
' ' . Html::rawElement(
207 [
'class' =>
'mw-protectedpages-length' ],
208 Linker::formatRevisionSize( $row->page_len )
214 $formatted = htmlspecialchars( $this->
getLanguage()->formatExpiry(
215 $value,
true,
'infinity', $this->
getUser() ) );
216 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
217 if ( $title && $this->
getAuthority()->isAllowed(
'protect' ) ) {
218 $changeProtection = $linkRenderer->makeKnownLink(
220 $this->
msg(
'protect_change' )->text(),
222 [
'action' =>
'unprotect' ]
224 $formatted .=
' ' . Html::rawElement(
226 [
'class' =>
'mw-protectedpages-actions' ],
227 $this->
msg(
'parentheses' )->rawParams( $changeProtection )->escaped()
234 if ( $row->log_timestamp ===
null ) {
235 $formatted = Html::rawElement(
237 [
'class' =>
'mw-protectedpages-unknown' ],
238 $this->
msg(
'protectedpages-unknown-performer' )->escaped()
241 $username = $row->actor_name;
242 if ( LogEventsList::userCanBitfield(
244 LogPage::DELETED_USER,
245 $this->getAuthority()
247 $formatted = Linker::userLink( (
int)$value, $username )
248 . Linker::userToolLinks( (
int)$value, $username );
250 $formatted = $this->
msg(
'rev-deleted-user' )->escaped();
252 if ( LogEventsList::isDeleted( $row, LogPage::DELETED_USER ) ) {
253 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
261 $params[] = $this->
msg(
'restriction-level-' . $row->pr_level )->escaped();
262 if ( $row->pr_cascade ) {
263 $params[] = $this->
msg(
'protect-summary-cascade' )->escaped();
270 if ( $row->log_timestamp ===
null ) {
271 $formatted = Html::rawElement(
273 [
'class' =>
'mw-protectedpages-unknown' ],
274 $this->
msg(
'protectedpages-unknown-reason' )->escaped()
277 if ( LogEventsList::userCanBitfield(
279 LogPage::DELETED_COMMENT,
280 $this->getAuthority()
282 $formatted = $this->formattedComments[$row->pr_id];
284 $formatted = $this->
msg(
'rev-deleted-comment' )->escaped();
286 if ( LogEventsList::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
287 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
293 throw new UnexpectedValueException(
"Unknown field '$field'" );