mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Get bundled notifications count
Utility functions to get the count of bundled notifications for display and plural purposes. Change-Id: I74d5ad244dec337a94e59c2118c33e474cd76797
This commit is contained in:
parent
f4d42418ab
commit
259effc235
|
@ -109,6 +109,46 @@ abstract class EchoEventPresentationModel {
|
|||
return $this->bundledEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Whether there is other notifications bundled with this one.
|
||||
*/
|
||||
final protected function isBundled() {
|
||||
return $this->getBundleCount() > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $includeCurrent
|
||||
* @return int Number of bundled events, potentially capped to $cap
|
||||
*/
|
||||
final protected function getBundleCount( $includeCurrent = true ) {
|
||||
$count = count( $this->getBundledEvents() );
|
||||
if ( $includeCurrent ) {
|
||||
$count++;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the count of notifications bundled together.
|
||||
* @param bool $includeCurrent
|
||||
* @return array ['number for display', 'number for PLURAL']
|
||||
*/
|
||||
final protected function getNotificationCountForOutput( $includeCurrent = true ) {
|
||||
global $wgEchoMaxNotificationCount;
|
||||
$count = $this->getBundleCount( $includeCurrent );
|
||||
if ( $count > $wgEchoMaxNotificationCount ) {
|
||||
return array(
|
||||
$this->msg( 'echo-notification-count' )->numParams( $wgEchoMaxNotificationCount )->text(),
|
||||
$wgEchoMaxNotificationCount
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
$this->language->formatNum( $count ),
|
||||
$count
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The symbolic icon name as defined in $wgEchoNotificationIcons
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue