mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Fixes to the toolbar link for notifications per Vibha
New badge behavior - Show badge even if zero notifications Enable long and short links - i.e. 'Notification (X)' or just '(X)' Depends on core change https://gerrit.wikimedia.org/r/#/c/38258/ Change-Id: Idc2288a4ddd0bf788ccdadb96d4744d223edaf0a
This commit is contained in:
parent
d2d59c1d47
commit
704147d1d2
4
Echo.php
4
Echo.php
|
@ -163,6 +163,10 @@ $wgEchoDisableStandardEmail = true;
|
||||||
// Whether to turn on email batch function
|
// Whether to turn on email batch function
|
||||||
$wgEchoEnableEmailBatch = true;
|
$wgEchoEnableEmailBatch = true;
|
||||||
|
|
||||||
|
// Show a 'Notifications' link with badge in the user toolbar at the top of the page.
|
||||||
|
// Otherwise, only show a badge next to the username.
|
||||||
|
$wgEchoShowFullNotificationsLink = false;
|
||||||
|
|
||||||
// The organization address, the value should be defined in LocalSettings.php
|
// The organization address, the value should be defined in LocalSettings.php
|
||||||
$wgEchoEmailFooterAddress = '';
|
$wgEchoEmailFooterAddress = '';
|
||||||
|
|
||||||
|
|
22
Hooks.php
22
Hooks.php
|
@ -220,26 +220,30 @@ class EchoHooks {
|
||||||
* @return bool true in all cases
|
* @return bool true in all cases
|
||||||
*/
|
*/
|
||||||
static function onPersonalUrls( &$personal_urls, &$title ) {
|
static function onPersonalUrls( &$personal_urls, &$title ) {
|
||||||
global $wgUser;
|
global $wgUser, $wgEchoShowFullNotificationsLink;
|
||||||
// Add a "My notifications" item to personal URLs
|
|
||||||
if ( $wgUser->isAnon() || !$wgUser->getOption( 'echo-notify-link' ) ) {
|
if ( $wgUser->isAnon() || !$wgUser->getOption( 'echo-notify-link' ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$notificationCount = EchoNotificationController::getNotificationCount( $wgUser );
|
$notificationCount = EchoNotificationController::getNotificationCount( $wgUser );
|
||||||
|
if ( $wgEchoShowFullNotificationsLink ) {
|
||||||
$msg = wfMessage( $notificationCount == 0 ? 'echo-link' : 'echo-link-new' );
|
// Add a "Notifications" item to personal URLs
|
||||||
|
$msg = wfMessage( $notificationCount == 0 ? 'echo-link' : 'echo-link-new' );
|
||||||
|
$text = $msg->params( EchoNotificationController::formatNotificationCount( $notificationCount ) )->text();
|
||||||
|
} else {
|
||||||
|
// Just add a number
|
||||||
|
$text = wfMessage( 'parentheses', $notificationCount )->plain();
|
||||||
|
}
|
||||||
$url = SpecialPage::getTitleFor( 'Notifications' )->getLocalURL();
|
$url = SpecialPage::getTitleFor( 'Notifications' )->getLocalURL();
|
||||||
|
|
||||||
$notificationsLink = array(
|
$notificationsLink = array(
|
||||||
'href' => $url,
|
'href' => $url,
|
||||||
'text' => $msg->params( EchoNotificationController::formatNotificationCount( $notificationCount ) )->text(),
|
'text' => $text,
|
||||||
'active' => $notificationCount > 0,
|
'active' => ( $url == $title->getLocalUrl() ),
|
||||||
);
|
);
|
||||||
|
|
||||||
$insertUrls = array( 'notifications' => $notificationsLink );
|
$insertUrls = array( 'notifications' => $notificationsLink );
|
||||||
$personal_urls = wfArrayInsertAfter( $personal_urls, $insertUrls, 'watchlist' );
|
$personal_urls = wfArrayInsertAfter( $personal_urls, $insertUrls, 'userpage' );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +265,7 @@ class EchoHooks {
|
||||||
* @return bool true in all cases
|
* @return bool true in all cases
|
||||||
*/
|
*/
|
||||||
public static function makeGlobalVariablesScript( &$vars, OutputPage $outputPage ) {
|
public static function makeGlobalVariablesScript( &$vars, OutputPage $outputPage ) {
|
||||||
|
global $wgEchoShowFullNotificationsLink;
|
||||||
$user = $outputPage->getUser();
|
$user = $outputPage->getUser();
|
||||||
|
|
||||||
// Provide info for the Overlay
|
// Provide info for the Overlay
|
||||||
|
@ -268,6 +273,7 @@ class EchoHooks {
|
||||||
$timestamp = new MWTimestamp( wfTimestampNow() );
|
$timestamp = new MWTimestamp( wfTimestampNow() );
|
||||||
if ( ! $user->isAnon() ) {
|
if ( ! $user->isAnon() ) {
|
||||||
$vars['wgEchoOverlayConfiguration'] = array(
|
$vars['wgEchoOverlayConfiguration'] = array(
|
||||||
|
'notifications-link-full' => $wgEchoShowFullNotificationsLink,
|
||||||
'timestamp' => $timestamp->getTimestamp( TS_UNIX ),
|
'timestamp' => $timestamp->getTimestamp( TS_UNIX ),
|
||||||
'notification-count' => EchoNotificationController::getFormattedNotificationCount( $user ),
|
'notification-count' => EchoNotificationController::getFormattedNotificationCount( $user ),
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,9 +12,16 @@
|
||||||
newCount = Number( newCount );
|
newCount = Number( newCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
$( '#pt-notifications a' )
|
if ( mw.echo.overlay.configuration['notifications-link-full'] ) {
|
||||||
.text( mw.msg( 'echo-link' ) )
|
$( '#pt-notifications a' )
|
||||||
.badge( newCount, true );
|
.text( mw.msg( 'echo-link' ) )
|
||||||
|
.badge( newCount, true, true );
|
||||||
|
} else {
|
||||||
|
$( '#pt-notifications a' )
|
||||||
|
.text( '' )
|
||||||
|
.badge( newCount, true, true );
|
||||||
|
$( '#pt-notifications .mw-badge' ).css( 'margin-left', '-5px' );
|
||||||
|
}
|
||||||
|
|
||||||
mw.echo.overlay.notification_count = newCount;
|
mw.echo.overlay.notification_count = newCount;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue