88 if ( $this->linkRenderer !==
null ) {
91 return MediaWikiServices::getInstance()->getLinkRenderer();
111 public function showOptions( $types = [], $user =
'', $page =
'', $pattern =
false, $year = 0,
112 $month = 0, $day = 0, $filter =
null, $tagFilter =
'', $action =
null
115 $types = ( $types ===
'' ) ? [] : (array)$types;
117 $formDescriptor = [];
130 is_array( $extraInputsDescriptor ) &&
131 !empty( $extraInputsDescriptor )
133 $formDescriptor[
'extra' ] = $extraInputsDescriptor;
135 is_string( $extraInputsDescriptor ) &&
136 $extraInputsDescriptor !==
''
139 $extraInputsString = $extraInputsDescriptor;
140 wfDeprecated(
'$input in LogEventsListGetExtraInputs hook',
'1.32' );
144 if ( !$this->
getConfig()->
get(
'MiserMode' ) ) {
149 $formDescriptor[
'date'] = [
151 'label-message' =>
'date',
152 'default' => $year && $month && $day ? sprintf(
"%04d-%02d-%02d", $year, $month, $day ) :
'',
156 $formDescriptor[
'tagfilter'] = [
157 'type' =>
'tagfilter',
158 'name' =>
'tagfilter',
159 'label-raw' => $this->
msg(
'tag-filter' )->parse(),
170 $this->allowedActions !==
null &&
171 count( $this->allowedActions ) > 0
180 ->setSubmitText( $this->
msg(
'logeventslist-submit' )->text() )
182 ->setWrapperLegendMsg(
'log' );
185 if ( isset( $extraInputsString ) ) {
193 $htmlForm->prepareForm()->displayForm(
false );
203 foreach ( $filter as
$type => $val ) {
204 $optionsMsg[
"logeventslist-{$type}-log"] =
$type;
206 if ( $val ===
false ) {
211 'class' => HTMLMultiSelectField::class,
212 'label-message' =>
'logeventslist-more-filters',
214 'options-messages' => $optionsMsg,
215 'default' => $default,
224 $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] :
'';
230 $restriction = $page->getRestriction();
231 if ( $this->
getAuthority()->isAllowed( $restriction ) ) {
232 $typesByName[
$type] = $page->getName()->text();
237 asort( $typesByName );
240 $public = $typesByName[
''];
241 unset( $typesByName[
''] );
242 $typesByName = [
'' => $public ] + $typesByName;
245 'class' => HTMLSelectField::class,
247 'options' => array_flip( $typesByName ),
248 'default' => $queryType,
258 'class' => HTMLUserTextField::class,
259 'label-message' =>
'specialloguserlabel',
271 'class' => HTMLTitleTextField::class,
272 'label-message' =>
'speciallogtitlelabel',
285 'label-message' =>
'log-title-wildcard',
295 if ( count( $types ) == 1 ) {
296 if ( $types[0] ==
'suppress' ) {
299 'label-message' =>
'revdelete-offender',
300 'name' =>
'offender',
306 $formDescriptor = [];
307 $this->hookRunner->onLogEventsListGetExtraInputs( $types[0], $this, $input, $formDescriptor );
309 return empty( $formDescriptor ) ? $input : $formDescriptor;
324 $actionOptions[
'log-action-filter-all' ] =
'';
326 foreach ( $this->allowedActions as $value ) {
327 $msgKey =
'log-action-filter-' . $types[0] .
'-' . $value;
328 $actionOptions[ $msgKey ] = $value;
332 'class' => HTMLSelectField::class,
334 'options-messages' => $actionOptions,
335 'default' => $action,
336 'label' => $this->
msg(
'log-action-filter-' . $types[0] )->text(),
347 $this->allowedActions = $actions;
371 $formatter->setContext( $this->
getContext() );
373 $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
376 $entry->getTimestamp(),
384 [
'logid' => $entry->getId() ]
387 $action = $formatter->getActionText();
389 if ( $this->flags & self::NO_ACTION_LINK ) {
392 $revert = $formatter->getActionLinks();
393 if ( $revert !=
'' ) {
394 $revert =
'<span class="mw-logevent-actionlink">' . $revert .
'</span>';
398 $comment = $formatter->getComment();
409 $classes = array_merge(
410 [
'mw-logline-' . $entry->getType() ],
414 'data-mw-logid' => $entry->getId(),
415 'data-mw-logaction' => $entry->getFullType(),
417 $ret =
"$del $timeLink $action $comment $revert $tagDisplay";
420 $this->hookRunner->onLogEventsListLineEnding( $this, $ret, $entry, $classes, $attribs );
421 $attribs = array_filter( $attribs,
422 [ Sanitizer::class,
'isReservedDataAttribute' ],
425 $attribs[
'class'] = $classes;
436 if ( $this->flags == self::NO_ACTION_LINK ) {
443 if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
447 [
'name' =>
'ids[' . $row->log_id .
']' ]
452 if ( $row->log_type ==
'suppress' ) {
458 if ( $this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
459 $canHide = $this->
getAuthority()->isAllowed(
'deletelogentry' );
460 $canViewSuppressedOnly = $this->
getAuthority()->isAllowed(
'viewsuppressed' ) &&
461 !$this->
getAuthority()->isAllowed(
'suppressrevision' );
463 $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
464 if ( $row->log_deleted || $canHide ) {
466 if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
469 $del =
Xml::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
474 [
'name' =>
'ids[' . $row->log_id .
']' ]
485 'ids' => $row->log_id,
490 $canHide && !$canViewThisSuppressedEntry
507 $match = is_array(
$type ) ?
508 in_array( $row->log_type,
$type ) : $row->log_type ==
$type;
510 $match = is_array( $action ) ?
511 in_array( $row->log_action, $action ) : $row->log_action == $action;
541 if ( $bitfield & $field ) {
543 return $performer->
isAllowedAny(
'suppressrevision',
'viewsuppressed' );
545 return $performer->
isAllowed(
'deletedhistory' );
560 $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get(
'LogRestrictions' );
574 return ( $row->log_deleted & $field ) == $field;
603 &$out, $types = [], $page =
'', $user =
'', $param = []
605 $defaultParameters = [
608 'showIfEmpty' =>
true,
612 'useRequestParams' =>
false,
613 'useMaster' =>
false,
614 'extraUrlParams' =>
false,
616 # The + operator appends elements of remaining keys from the right
617 # handed array to the left handed, whereas duplicated keys are NOT overwritten.
618 $param += $defaultParameters;
619 # Convert $param array to individual variables
620 $lim = $param[
'lim'];
621 $conds = $param[
'conds'];
622 $showIfEmpty = $param[
'showIfEmpty'];
623 $msgKey = $param[
'msgKey'];
624 $wrap = $param[
'wrap'];
626 $extraUrlParams = $param[
'extraUrlParams'];
628 $useRequestParams = $param[
'useRequestParams'];
630 if ( !is_array( $msgKey ) ) {
631 $msgKey = [ $msgKey ];
640 $services = MediaWikiServices::getInstance();
644 # Insert list of top 50 (or top $lim) items
659 $services->getLinkBatchFactory(),
660 $services->getDBLoadBalancer(),
661 $services->getActorMigration()
663 if ( !$useRequestParams ) {
664 # Reset vars that may have been taken from the request
666 $pager->mDefaultLimit = 50;
667 $pager->mOffset =
"";
668 $pager->mIsBackwards =
false;
671 if ( $param[
'useMaster'] ) {
674 if ( isset( $param[
'offset'] ) ) { # Tell pager to ignore
WebRequest offset
675 $pager->setOffset( $param[
'offset'] );
680 $pager->mLimit = $lim;
683 $logBody = $pager->getBody();
684 $numRows = $pager->getNumRows();
694 'class' =>
"warningbox mw-warning-with-logexcerpt mw-content-$dir",
700 if ( count( $msgKey ) == 1 ) {
704 array_shift(
$args );
708 $s .= $loglist->beginLogEventsList() .
710 $loglist->endLogEventsList();
713 } elseif ( $showIfEmpty ) {
718 if ( $numRows > $pager->mLimit ) { # Show
"Full log" link
720 if ( $page instanceof
Title ) {
721 $urlParam[
'page'] = $page->getPrefixedDBkey();
722 } elseif ( $page !=
'' ) {
723 $urlParam[
'page'] = $page;
727 $urlParam[
'user'] = $user;
730 if ( !is_array( $types ) ) { # Make it an array,
if it isn
't
734 # If there is exactly one log type, we can link to Special:Log?type=foo
735 if ( count( $types ) == 1 ) {
736 $urlParam['type
'] = $types[0];
739 // @phan-suppress-next-line PhanSuspiciousValueComparison
740 if ( $extraUrlParams !== false ) {
741 $urlParam = array_merge( $urlParam, $extraUrlParams );
744 $s .= $linkRenderer->makeKnownLink(
745 SpecialPage::getTitleFor( 'Log
' ),
746 $context->msg( 'log-fulllog
' )->text(),
752 if ( $logBody && $msgKey[0] ) {
756 // @phan-suppress-next-line PhanSuspiciousValueComparison
757 if ( $wrap != '' ) { // Wrap message in html
758 $s = str_replace( '$1
', $s, $wrap );
761 /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
762 if (
Hooks::runner()->onLogEventsListShowLogExtract(
$s, $types, $page, $user, $param ) ) {
786 if ( $audience !=
'public' && $performer ===
null ) {
787 throw new InvalidArgumentException(
788 'A User object must be given when checking for a user audience.'
797 if ( $audience ==
'public' || !$performer->isAllowed( $right )
799 $hiddenLogs[] = $logType;
802 if ( count( $hiddenLogs ) == 1 ) {
803 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
804 } elseif ( $hiddenLogs ) {
805 return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) .
')';