summaryrefslogtreecommitdiff
blob: 5bdb7878e72383d56b13b00437a53a94ff825e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

/**
 * This class formats abuse log notifications.
 *
 * Uses logentry-abusefilter-hit
 */
class AbuseLogHitFormatter extends LogFormatter {

	/**
	 * @return array
	 */
	protected function getMessageParameters() {
		$entry = $this->entry->getParameters();
		$linkRenderer = $this->getLinkRenderer();
		$params = parent::getMessageParameters();

		$filter_title = SpecialPage::getTitleFor( 'AbuseFilter', $entry['filter'] );
		$filter_caption = $this->msg( 'abusefilter-log-detailedentry-local' )
			->params( $entry['filter'] )
			->text();
		$log_title = SpecialPage::getTitleFor( 'AbuseLog', $entry['log'] );
		$log_caption = $this->msg( 'abusefilter-log-detailslink' )->text();

		$params[4] = $entry['action'];

		if ( $this->plaintext ) {
			$params[3] = '[[' . $filter_title->getPrefixedText() . '|' . $filter_caption . ']]';
			$params[8] = '[[' . $log_title->getPrefixedText() . '|' . $log_caption . ']]';
		} else {
			$params[3] = Message::rawParam( $linkRenderer->makeLink(
				$filter_title,
				$filter_caption
			) );
			$params[8] = Message::rawParam( $linkRenderer->makeLink(
				$log_title,
				$log_caption
			) );
		}

		$actions_takenRaw = $entry['actions'];
		if ( !strlen( trim( $actions_takenRaw ) ) ) {
			$actions_taken = $this->msg( 'abusefilter-log-noactions' );
		} else {
			$actions = explode( ',', $actions_takenRaw );
			$displayActions = [];

			foreach ( $actions as $action ) {
				$displayActions[] = AbuseFilter::getActionDisplay( $action, $this->context );
			}
			$actions_taken = $this->context->getLanguage()->commaList( $displayActions );
		}
		$params[5] = Message::rawParam( $actions_taken );

		// Bad things happen if the numbers are not in correct order
		ksort( $params );

		return $params;
	}
}