| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Extension\OATHAuth\Notifications; |
| 22 |
|
| 23 |
use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
| 24 |
use MediaWiki\SpecialPage\SpecialPage; |
| 25 |
use MediaWiki\Title\Title; |
| 26 |
|
| 27 |
class DisablePresentationModel extends EchoEventPresentationModel { |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
public function getIconType() { |
| 33 |
return 'site'; |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
protected function getHeaderMessageKey() { |
| 38 |
return $this->event->getExtraParam( 'activeDevices', 0 ) === 0 |
| 39 |
? 'notification-header-oathauth-disable' |
| 40 |
: 'notification-header-oathauth-remove-device'; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public function getPrimaryLink() { |
| 47 |
return [ |
| 48 |
'url' => SpecialPage::getTitleFor( 'OATHManage' )->getLocalURL(), |
| 49 |
'label' => $this->msg( 'oathauth-notifications-disable-primary' )->text() |
| 50 |
]; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public function getSecondaryLinks() { |
| 57 |
$link = $this->msg( 'oathauth-notifications-disable-helplink' )->inContentLanguage(); |
| 58 |
$title = Title::newFromText( $link->plain() ); |
| 59 |
if ( !$title ) { |
| 60 |
|
| 61 |
return []; |
| 62 |
} |
| 63 |
return [ [ |
| 64 |
'url' => $title->getLocalURL(), |
| 65 |
'label' => $this->msg( 'oathauth-notifications-disable-help' )->text(), |
| 66 |
'icon' => 'help', |
| 67 |
] ]; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public function getBodyMessage() { |
| 74 |
$helpMessageKey = $this->event->getExtraParam( 'self', true ) |
| 75 |
? 'notification-body-oathauth-disable' |
| 76 |
: 'notification-body-oathauth-disable-other'; |
| 77 |
$message = $this->getMessageWithAgent( $helpMessageKey ); |
| 78 |
|
| 79 |
if ( $this->event->getExtraParam( 'activeDevices', 0 ) >= 1 ) { |
| 80 |
$remainingMessage = $this->getMessageWithAgent( 'notification-body-oathauth-disable-remaining' ); |
| 81 |
$remainingMessage->params( $this->event->getExtraParam( 'activeDevices', 0 ) ); |
| 82 |
|
| 83 |
$message = $this->msg( 'rawmessage' )->rawParams( |
| 84 |
$message->escaped() |
| 85 |
. $this->msg( 'word-separator' )->escaped() |
| 86 |
. $remainingMessage->escaped() |
| 87 |
); |
| 88 |
} |
| 89 |
|
| 90 |
return $message; |
| 91 |
} |
| 92 |
} |