| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\AbuseFilter; |
| 4 |
|
| 5 |
use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
| 6 |
use MediaWiki\Message\Message; |
| 7 |
|
| 8 |
class ThrottleFilterPresentationModel extends EchoEventPresentationModel { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public function getIconType() { |
| 14 |
return 'placeholder'; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
|
| 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 |
|
| 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 |
|
| 50 |
|
| 51 |
public function getSubjectMessage() { |
| 52 |
return $this->msg( 'notification-subject-throttle-filter' ) |
| 53 |
->params( $this->getViewingUserForGender() ); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 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 |
} |