mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-01 02:46:46 +00:00
2c7136ecb7
Bug: T121661 Change-Id: I8386429a36182dbc44b45990506a42cbeef115ad
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Formatter for 'user-rights' notifications
|
|
*/
|
|
class EchoUserRightsPresentationModel extends EchoEventPresentationModel {
|
|
|
|
public function getIconType() {
|
|
return 'user-rights';
|
|
}
|
|
|
|
public function getHeaderMessage() {
|
|
list( $formattedName, $genderName ) = $this->getAgentForOutput();
|
|
$add = $this->getLocalizedGroupNames( $this->event->getExtraParam( 'add', array() ) );
|
|
$remove = $this->getLocalizedGroupNames( $this->event->getExtraParam( 'remove', array() ) );
|
|
if ( $add && !$remove ) {
|
|
$msg = $this->msg( 'notification-header-user-rights-add-only' );
|
|
$msg->params( $genderName );
|
|
$msg->params( $this->language->listToText( $add ) );
|
|
$msg->params( count( $add ) );
|
|
return $msg;
|
|
} elseif ( !$add && $remove ) {
|
|
$msg = $this->msg( 'notification-header-user-rights-remove-only' );
|
|
$msg->params( $genderName );
|
|
$msg->params( $this->language->listToText( $remove ) );
|
|
$msg->params( count( $remove ) );
|
|
return $msg;
|
|
} else {
|
|
$msg = $this->msg( 'notification-header-user-rights-add-and-remove' );
|
|
$msg->params( $genderName );
|
|
$msg->params( $this->language->listToText( $add ) );
|
|
$msg->params( count( $add ) );
|
|
$msg->params( $this->language->listToText( $remove ) );
|
|
$msg->params( count( $remove ) );
|
|
return $msg;
|
|
}
|
|
}
|
|
|
|
private function getLocalizedGroupNames( $names ) {
|
|
return array_map( function( $name ) {
|
|
$msg = $this->msg( 'group-' . $name );
|
|
return $msg->isBlank() ? $name : $msg->text();
|
|
}, $names );
|
|
}
|
|
|
|
public function getPrimaryLink() {
|
|
return array(
|
|
'url' => SpecialPage::getTitleFor( 'Listgrouprights' )->getLocalURL(),
|
|
'label' => $this->msg( 'echo-learn-more' )->text()
|
|
);
|
|
}
|
|
|
|
public function getSecondaryLinks() {
|
|
return array( $this->getAgentLink() );
|
|
}
|
|
}
|