2012-04-14 10:10:35 +00:00
|
|
|
<?php
|
2017-10-19 07:40:22 +00:00
|
|
|
|
2012-04-14 10:10:35 +00:00
|
|
|
/**
|
|
|
|
* This class formats abuse log notifications.
|
2016-12-21 14:56:32 +00:00
|
|
|
*
|
|
|
|
* Uses logentry-abusefilter-hit
|
2012-04-14 10:10:35 +00:00
|
|
|
*/
|
|
|
|
class AbuseLogHitFormatter extends LogFormatter {
|
|
|
|
|
2012-06-21 13:31:09 +00:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2012-04-14 10:10:35 +00:00
|
|
|
protected function getMessageParameters() {
|
|
|
|
$entry = $this->entry->getParameters();
|
2020-08-25 19:13:03 +00:00
|
|
|
$linkRenderer = $this->getLinkRenderer();
|
2012-04-14 10:10:35 +00:00
|
|
|
$params = parent::getMessageParameters();
|
|
|
|
|
|
|
|
$filter_title = SpecialPage::getTitleFor( 'AbuseFilter', $entry['filter'] );
|
2018-07-04 15:04:05 +00:00
|
|
|
$filter_caption = $this->msg( 'abusefilter-log-detailedentry-local' )
|
|
|
|
->params( $entry['filter'] )
|
|
|
|
->text();
|
2012-04-14 10:10:35 +00:00
|
|
|
$log_title = SpecialPage::getTitleFor( 'AbuseLog', $entry['log'] );
|
2018-07-04 15:04:05 +00:00
|
|
|
$log_caption = $this->msg( 'abusefilter-log-detailslink' )->text();
|
2012-04-14 10:10:35 +00:00
|
|
|
|
|
|
|
$params[4] = $entry['action'];
|
|
|
|
|
|
|
|
if ( $this->plaintext ) {
|
|
|
|
$params[3] = '[[' . $filter_title->getPrefixedText() . '|' . $filter_caption . ']]';
|
|
|
|
$params[8] = '[[' . $log_title->getPrefixedText() . '|' . $log_caption . ']]';
|
|
|
|
} else {
|
2016-12-04 15:13:16 +00:00
|
|
|
$params[3] = Message::rawParam( $linkRenderer->makeLink(
|
2012-04-14 10:10:35 +00:00
|
|
|
$filter_title,
|
2016-12-04 15:13:16 +00:00
|
|
|
$filter_caption
|
2012-04-14 10:10:35 +00:00
|
|
|
) );
|
2016-12-04 15:13:16 +00:00
|
|
|
$params[8] = Message::rawParam( $linkRenderer->makeLink(
|
2012-04-14 10:10:35 +00:00
|
|
|
$log_title,
|
2016-12-04 15:13:16 +00:00
|
|
|
$log_caption
|
2012-04-14 10:10:35 +00:00
|
|
|
) );
|
|
|
|
}
|
|
|
|
|
2020-06-02 08:13:17 +00:00
|
|
|
$actions_takenRaw = $entry['actions'];
|
|
|
|
if ( !strlen( trim( $actions_takenRaw ) ) ) {
|
2012-04-14 10:10:35 +00:00
|
|
|
$actions_taken = $this->msg( 'abusefilter-log-noactions' );
|
|
|
|
} else {
|
2020-06-02 08:13:17 +00:00
|
|
|
$actions = explode( ',', $actions_takenRaw );
|
2017-06-15 14:23:34 +00:00
|
|
|
$displayActions = [];
|
2012-04-14 10:10:35 +00:00
|
|
|
|
|
|
|
foreach ( $actions as $action ) {
|
2020-08-25 19:33:37 +00:00
|
|
|
$displayActions[] = AbuseFilter::getActionDisplay( $action, $this->context );
|
2012-04-14 10:10:35 +00:00
|
|
|
}
|
|
|
|
$actions_taken = $this->context->getLanguage()->commaList( $displayActions );
|
|
|
|
}
|
2020-06-02 08:13:17 +00:00
|
|
|
$params[5] = Message::rawParam( $actions_taken );
|
2012-04-14 10:10:35 +00:00
|
|
|
|
|
|
|
// Bad things happen if the numbers are not in correct order
|
2015-09-28 18:03:35 +00:00
|
|
|
ksort( $params );
|
|
|
|
|
2012-04-14 10:10:35 +00:00
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
}
|