Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 28
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
ThrottleFilterPresentationModel
0.00% covered (danger)
0.00%
0 / 28
0.00% covered (danger)
0.00%
0 / 4
56
0.00% covered (danger)
0.00%
0 / 1
 getIconType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHeaderMessage
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 1
20
 getSubjectMessage
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getPrimaryLink
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\AbuseFilter;
4
5use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel;
6use MediaWiki\Message\Message;
7
8class ThrottleFilterPresentationModel extends EchoEventPresentationModel {
9
10    /**
11     * @inheritDoc
12     */
13    public function getIconType() {
14        return 'placeholder';
15    }
16
17    /**
18     * @inheritDoc
19     */
20    public function getHeaderMessage() {
21        $text = $this->event->getTitle()->getText();
22        [ , $filter ] = explode( '/', $text, 2 );
23        $disabledActions = $this->event->getExtraParam( 'throttled-actions' );
24        if ( $disabledActions === null ) {
25            // BC for when we didn't include the actions here.
26            return $this->msg( 'notification-header-throttle-filter' )
27                ->params( $this->getViewingUserForGender() )
28                ->numParams( $filter );
29        }
30        if ( $disabledActions ) {
31            $specsFormatter = AbuseFilterServices::getSpecsFormatter();
32            $specsFormatter->setMessageLocalizer( $this );
33            $disabledActionsLocalized = [];
34            foreach ( $disabledActions as $action ) {
35                $disabledActionsLocalized[] = $specsFormatter->getActionMessage( $action )->text();
36            }
37            return $this->msg( 'notification-header-throttle-filter-actions' )
38                ->params( $this->getViewingUserForGender() )
39                ->numParams( $filter )
40                ->params( Message::listParam( $disabledActionsLocalized ) )
41                ->params( count( $disabledActionsLocalized ) );
42        }
43        return $this->msg( 'notification-header-throttle-filter-no-actions' )
44            ->params( $this->getViewingUserForGender() )
45            ->numParams( $filter );
46    }
47
48    /**
49     * @inheritDoc
50     */
51    public function getSubjectMessage() {
52        return $this->msg( 'notification-subject-throttle-filter' )
53            ->params( $this->getViewingUserForGender() );
54    }
55
56    /**
57     * @inheritDoc
58     */
59    public function getPrimaryLink() {
60        return [
61            'url' => $this->event->getTitle()->getFullURL(),
62            'label' => $this->msg( 'notification-link-text-show-filter' )->text()
63        ];
64    }
65}