84 if ( $this->linkRenderer !==
null ) {
87 return MediaWikiServices::getInstance()->getLinkRenderer();
107 public function showOptions( $types = [], $user =
'', $page =
'', $pattern =
false, $year = 0,
108 $month = 0, $day = 0, $filter =
null, $tagFilter =
'', $action =
null
111 $types = ( $types ===
'' ) ? [] : (array)$types;
113 $formDescriptor = [];
126 is_array( $extraInputsDescriptor ) &&
127 !empty( $extraInputsDescriptor )
129 $formDescriptor[
'extra' ] = $extraInputsDescriptor;
131 is_string( $extraInputsDescriptor ) &&
132 $extraInputsDescriptor !==
''
135 $extraInputsString = $extraInputsDescriptor;
136 wfDeprecated(
'$input in LogEventsListGetExtraInputs hook',
'1.32' );
140 if ( !$this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
145 $formDescriptor[
'date'] = [
147 'label-message' =>
'date',
148 'default' => $year && $month && $day ? sprintf(
"%04d-%02d-%02d", $year, $month, $day ) :
'',
152 $formDescriptor[
'tagfilter'] = [
153 'type' =>
'tagfilter',
154 'name' =>
'tagfilter',
155 'label-message' =>
'tag-filter',
166 $this->allowedActions !==
null &&
167 count( $this->allowedActions ) > 0
176 ->setSubmitTextMsg(
'logeventslist-submit' )
178 ->setWrapperLegendMsg(
'log' );
181 if ( isset( $extraInputsString ) ) {
189 $htmlForm->prepareForm()->displayForm(
false );
199 foreach ( $filter as
$type => $val ) {
200 $optionsMsg[
"logeventslist-{$type}-log"] =
$type;
202 if ( $val ===
false ) {
207 'class' => HTMLMultiSelectField::class,
208 'label-message' =>
'logeventslist-more-filters',
210 'options-messages' => $optionsMsg,
211 'default' => $default,
220 $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] :
'';
226 $restriction = $page->getRestriction();
227 if ( $this->
getAuthority()->isAllowed( $restriction ) ) {
228 $typesByName[
$type] = $page->getName()->text();
233 asort( $typesByName );
236 $public = $typesByName[
''];
237 unset( $typesByName[
''] );
238 $typesByName = [
'' => $public ] + $typesByName;
241 'class' => HTMLSelectField::class,
243 'options' => array_flip( $typesByName ),
244 'default' => $queryType,
254 'class' => HTMLUserTextField::class,
255 'label-message' =>
'specialloguserlabel',
267 'class' => HTMLTitleTextField::class,
268 'label-message' =>
'speciallogtitlelabel',
281 'label-message' =>
'log-title-wildcard',
291 if ( count( $types ) == 1 ) {
292 if ( $types[0] ==
'suppress' ) {
295 'label-message' =>
'revdelete-offender',
296 'name' =>
'offender',
302 $formDescriptor = [];
303 $this->hookRunner->onLogEventsListGetExtraInputs( $types[0], $this, $input, $formDescriptor );
305 return empty( $formDescriptor ) ? $input : $formDescriptor;
320 $actionOptions[
'log-action-filter-all' ] =
'';
322 foreach ( $this->allowedActions as $value ) {
323 $msgKey =
'log-action-filter-' . $types[0] .
'-' . $value;
324 $actionOptions[ $msgKey ] = $value;
328 'class' => HTMLSelectField::class,
330 'options-messages' => $actionOptions,
331 'default' => $action,
332 'label' => $this->
msg(
'log-action-filter-' . $types[0] )->text(),
343 $this->allowedActions = $actions;
350 return "<ul class='mw-logevent-loglines'>\n";
367 $formatter->setContext( $this->
getContext() );
369 $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
372 $entry->getTimestamp(),
380 [
'logid' => $entry->getId() ]
383 $action = $formatter->getActionText();
385 if ( $this->flags & self::NO_ACTION_LINK ) {
388 $revert = $formatter->getActionLinks();
389 if ( $revert !=
'' ) {
390 $revert =
'<span class="mw-logevent-actionlink">' . $revert .
'</span>';
394 $comment = $formatter->getComment();
405 $classes = array_merge(
406 [
'mw-logline-' . $entry->getType() ],
410 'data-mw-logid' => $entry->getId(),
411 'data-mw-logaction' => $entry->getFullType(),
413 $ret =
"$del $timeLink $action $comment $revert $tagDisplay";
416 $this->hookRunner->onLogEventsListLineEnding( $this, $ret, $entry, $classes, $attribs );
417 $attribs = array_filter( $attribs,
418 [ Sanitizer::class,
'isReservedDataAttribute' ],
421 $attribs[
'class'] = $classes;
432 if ( $this->flags == self::NO_ACTION_LINK ) {
437 if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
441 [
'name' =>
'ids[' . $row->log_id .
']' ]
446 if ( $row->log_type ==
'suppress' ) {
453 if ( $authority->isAllowed(
'deletedhistory' ) ) {
454 $canHide = $authority->isAllowed(
'deletelogentry' );
455 $canViewSuppressedOnly = $authority->isAllowed(
'viewsuppressed' ) &&
456 !$authority->isAllowed(
'suppressrevision' );
458 $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
459 if ( $row->log_deleted || $canHide ) {
461 if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
464 $del =
Xml::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
469 [
'name' =>
'ids[' . $row->log_id .
']' ]
480 'ids' => $row->log_id,
485 $canHide && !$canViewThisSuppressedEntry
502 $match = is_array(
$type ) ?
503 in_array( $row->log_type,
$type ) : $row->log_type ==
$type;
505 $match = is_array( $action ) ?
506 in_array( $row->log_action, $action ) : $row->log_action == $action;
536 if ( $bitfield & $field ) {
538 return $performer->
isAllowedAny(
'suppressrevision',
'viewsuppressed' );
540 return $performer->
isAllowed(
'deletedhistory' );
555 $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::LogRestrictions );
569 return ( $row->log_deleted & $field ) == $field;
598 &$out, $types = [], $page =
'', $user =
'', $param = []
600 $defaultParameters = [
603 'showIfEmpty' =>
true,
607 'useRequestParams' =>
false,
608 'useMaster' =>
false,
609 'extraUrlParams' =>
false,
611 # The + operator appends elements of remaining keys from the right
612 # handed array to the left handed, whereas duplicated keys are NOT overwritten.
613 $param += $defaultParameters;
614 # Convert $param array to individual variables
615 $lim = $param[
'lim'];
616 $conds = $param[
'conds'];
617 $showIfEmpty = $param[
'showIfEmpty'];
618 $msgKey = $param[
'msgKey'];
619 $wrap = $param[
'wrap'];
621 $extraUrlParams = $param[
'extraUrlParams'];
623 $useRequestParams = $param[
'useRequestParams'];
625 if ( !is_array( $msgKey ) ) {
626 $msgKey = [ $msgKey ];
635 $services = MediaWikiServices::getInstance();
639 # Insert list of top 50 (or top $lim) items
654 $services->getLinkBatchFactory(),
655 $services->getDBLoadBalancer(),
656 $services->getActorNormalization()
658 if ( !$useRequestParams ) {
659 # Reset vars that may have been taken from the request
661 $pager->mDefaultLimit = 50;
662 $pager->mOffset =
"";
663 $pager->mIsBackwards =
false;
666 if ( $param[
'useMaster'] ) {
670 if ( isset( $param[
'offset'] ) ) { # Tell pager to ignore
WebRequest offset
671 $pager->setOffset( $param[
'offset'] );
676 $pager->mLimit = $lim;
679 $logBody = $pager->getBody();
680 $numRows = $pager->getNumRows();
690 $s .= $msg->parseAsBlock();
692 $s .= $loglist->beginLogEventsList() .
694 $loglist->endLogEventsList();
697 } elseif ( $showIfEmpty ) {
703 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
704 $pageName = $titleFormatter->getPrefixedDBkey( $page );
705 } elseif ( $page !=
'' ) {
711 if ( $numRows > $pager->mLimit ) { # Show
"Full log" link
714 $urlParam[
'page'] = $pageName;
718 $urlParam[
'user'] = $user;
721 if ( !is_array( $types ) ) { # Make it an array,
if it isn
't
725 # If there is exactly one log type, we can link to Special:Log?type=foo
726 if ( count( $types ) == 1 ) {
727 $urlParam['type
'] = $types[0];
730 // @phan-suppress-next-line PhanSuspiciousValueComparison
731 if ( $extraUrlParams !== false ) {
732 $urlParam = array_merge( $urlParam, $extraUrlParams );
735 $s .= $linkRenderer->makeKnownLink(
736 SpecialPage::getTitleFor( 'Log
' ),
737 $context->msg( 'log-fulllog
' )->text(),
743 if ( $logBody && $msgKey[0] ) {
744 // TODO: The condition above is weird. Should this be done in any other cases?
745 // Or is it always true in practice?
747 // Mark as interface language (T60685)
748 $dir = $context->getLanguage()->getDir();
749 $lang = $context->getLanguage()->getHtmlCode();
750 $s = Html::rawElement( 'div
', [
751 'class' => "mw-content-$dir",
756 // Wrap in warning box
757 $s = Html::warningBox(
759 'mw-warning-with-logexcerpt
'
763 // @phan-suppress-next-line PhanSuspiciousValueComparison
764 if ( $wrap != '' ) { // Wrap message in html
765 $s = str_replace( '$1
', $s, $wrap );
768 /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
769 if (
Hooks::runner()->onLogEventsListShowLogExtract(
$s, $types, $pageName, $user, $param ) ) {
791 $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::LogRestrictions );
793 if ( $audience !=
'public' && $performer ===
null ) {
794 throw new InvalidArgumentException(
795 'A User object must be given when checking for a user audience.'
803 foreach ( $logRestrictions as $logType => $right ) {
804 if ( $audience ==
'public' || !$performer->isAllowed( $right )
806 $hiddenLogs[] = $logType;
809 if ( count( $hiddenLogs ) == 1 ) {
810 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
811 } elseif ( $hiddenLogs ) {
812 return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) .
')';
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
static newFromRow( $row)
Constructs new LogEntry from database result row.
An IContextSource implementation which will inherit context from another source but allow individual ...
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
LinkRenderer null $linkRenderer
const NO_EXTRA_USER_LINKS
getTitlePatternDesc( $pattern)
static typeAction( $row, $type, $action)
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
showOptions( $types=[], $user='', $page='', $pattern=false, $year=0, $month=0, $day=0, $filter=null, $tagFilter='', $action=null)
Show options for the log list.
static getExcludeClause( $db, $audience='public', Authority $performer=null)
SQL clause to skip forbidden log types for this user.
static userCan( $row, $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
static userCanBitfield( $bitfield, $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
getExtraInputsDesc( $types)
__construct( $context, $linkRenderer=null, $flags=0)
setAllowedActions( $actions)
Sets the action types allowed for log filtering To one action type may correspond several log_actions...
getTypeMenuDesc( $queryTypes)
getTitleInputDesc( $page)
getActionSelectorDesc( $types, $action)
Drop down menu for selection of actions that can be used to filter the log.
static userCanViewLogType( $type, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
static isDeleted( $row, $field)
Class to simplify the use of log pages.
static validTypes()
Get the list of valid log types.
A class containing constants representing the names of configuration variables.
This is one of the Core classes and should be read at least once by any new developers.
static getMain()
Get the RequestContext object associated with the main request.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
msg( $key,... $params)
This is the method for getting translated interface messages.
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s