File: ThrottleFilterPresentationModel.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (65 lines) | stat: -rw-r--r-- 1,904 bytes parent folder | download | duplicates (2)
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
61
62
63
64
65
<?php

namespace MediaWiki\Extension\AbuseFilter;

use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel;
use MediaWiki\Message\Message;

class ThrottleFilterPresentationModel extends EchoEventPresentationModel {

	/**
	 * @inheritDoc
	 */
	public function getIconType() {
		return 'placeholder';
	}

	/**
	 * @inheritDoc
	 */
	public function getHeaderMessage() {
		$text = $this->event->getTitle()->getText();
		[ , $filter ] = explode( '/', $text, 2 );
		$disabledActions = $this->event->getExtraParam( 'throttled-actions' );
		if ( $disabledActions === null ) {
			// BC for when we didn't include the actions here.
			return $this->msg( 'notification-header-throttle-filter' )
				->params( $this->getViewingUserForGender() )
				->numParams( $filter );
		}
		if ( $disabledActions ) {
			$specsFormatter = AbuseFilterServices::getSpecsFormatter();
			$specsFormatter->setMessageLocalizer( $this );
			$disabledActionsLocalized = [];
			foreach ( $disabledActions as $action ) {
				$disabledActionsLocalized[] = $specsFormatter->getActionMessage( $action )->text();
			}
			return $this->msg( 'notification-header-throttle-filter-actions' )
				->params( $this->getViewingUserForGender() )
				->numParams( $filter )
				->params( Message::listParam( $disabledActionsLocalized ) )
				->params( count( $disabledActionsLocalized ) );
		}
		return $this->msg( 'notification-header-throttle-filter-no-actions' )
			->params( $this->getViewingUserForGender() )
			->numParams( $filter );
	}

	/**
	 * @inheritDoc
	 */
	public function getSubjectMessage() {
		return $this->msg( 'notification-subject-throttle-filter' )
			->params( $this->getViewingUserForGender() );
	}

	/**
	 * @inheritDoc
	 */
	public function getPrimaryLink() {
		return [
			'url' => $this->event->getTitle()->getFullURL(),
			'label' => $this->msg( 'notification-link-text-show-filter' )->text()
		];
	}
}