| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\OATHAuth\Notifications; |
| 4 |
|
| 5 |
use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
| 6 |
use MediaWiki\Extension\OATHAuth\Key\TOTPKey; |
| 7 |
use MediaWiki\SpecialPage\SpecialPage; |
| 8 |
use MediaWiki\Title\Title; |
| 9 |
|
| 10 |
class RecoveryCodeCountPresentationModel extends EchoEventPresentationModel { |
| 11 |
|
| 12 |
|
| 13 |
public function getIconType() { |
| 14 |
return 'site'; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
public function getPrimaryLink() { |
| 19 |
return [ |
| 20 |
'url' => SpecialPage::getTitleFor( 'OATHManage' )->getLocalURL(), |
| 21 |
'label' => $this->msg( 'oathauth-notifications-recoverycodesleft-primary' )->text() |
| 22 |
]; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
public function getSecondaryLinks() { |
| 27 |
$link = $this->msg( 'oathauth-notifications-recoverycodesleft-helplink' )->inContentLanguage(); |
| 28 |
$title = Title::newFromText( $link->plain() ); |
| 29 |
if ( !$title ) { |
| 30 |
|
| 31 |
return []; |
| 32 |
} |
| 33 |
return [ [ |
| 34 |
'url' => $title->getLocalURL(), |
| 35 |
'label' => $this->msg( 'oathauth-notifications-recoverycodesleft-help' )->text(), |
| 36 |
'icon' => 'help', |
| 37 |
] ]; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
public function getBodyMessage() { |
| 42 |
$msg = $this->getMessageWithAgent( 'notification-body-oathauth-recoverycodesleft' ); |
| 43 |
$msg->params( $this->event->getExtraParam( 'codeCount', 0 ) ); |
| 44 |
$msg->params( $this->event->getExtraParam( 'generatedCount', TOTPKey::RECOVERY_CODES_COUNT ) ); |
| 45 |
return $msg; |
| 46 |
} |
| 47 |
|
| 48 |
} |