Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/68817
Change subject: New primary and secondary links
......................................................................
New primary and secondary links
Change-Id: I94aed697e87126ed8ad6d1d416c99bafaa53ac53
---
M Echo.i18n.php
M Echo.php
M controller/NotificationController.php
M formatters/BasicFormatter.php
M modules/overlay/ext.echo.overlay.js
5 files changed, 85 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/17/68817/1
diff --git a/Echo.i18n.php b/Echo.i18n.php
index 31ef5fc..4feb3d5 100644
--- a/Echo.i18n.php
+++ b/Echo.i18n.php
@@ -69,23 +69,25 @@
// Notification
'echo-quotation-marks' => '"$1"',
+ 'notification-view-message' => 'View message',
+ 'notification-view-changes' => 'View changes',
'notification-edit-talk-page2' => '[[User:$1|$1]] {{GENDER:$1|posted}}
on your [[User talk:$2#$3|talk page]].',
- 'notification-edit-talk-page-flyout2' => '<b>$1</b>
{{GENDER:$1|posted}} on your [[User talk:$2#$3|talk page]].',
+ 'notification-edit-talk-page-flyout2' => '$1 {{GENDER:$1|posted}} on
your [[User talk:$2#$3|talk page]].',
'notification-page-linked' => '[[:$2]] was {{GENDER:$1|linked}} from
[[:$3]]: [[Special:WhatLinksHere/$2|See all links to this page]]',
- 'notification-page-linked-flyout' => '<b>$2</b> was
{{GENDER:$1|linked}} from [[:$3]].',
+ 'notification-page-linked-flyout' => '$2 was {{GENDER:$1|linked}} from
[[:$3]].',
'notification-add-comment2' => '[[User:$1|$1]] {{GENDER:$1|commented}}
on "[[$3|$2]]" on the "$4" talk page',
'notification-add-talkpage-topic2' => '[[User:$1|$1]]
{{GENDER:$1|posted}} a new topic "$2" on [[$3]]',
'notification-add-talkpage-topic-yours2' => '[[User:$1|$1]]
{{GENDER:$1|sent}} you a message: "[[$3#$2|$2]]"',
'notification-add-comment-yours2' => '[[User:$1|$1]]
{{GENDER:$1|commented}} on "[[$3#$2|$2]]" on your talk page',
'notification-mention' => '[[User:$1|$1]] {{GENDER:$1|mentioned}} you
on [[$3#$2|$3]].',
- 'notification-mention-flyout' => '<b>$1</b> {{GENDER:$1|mentioned}} you
on [[$3#$2|$3]].',
+ 'notification-mention-flyout' => '$1 {{GENDER:$1|mentioned}} you on
[[$3#$2|$3]].',
'notification-user-rights' => 'Your user rights
[[Special:Log/rights/$1|were {{GENDER:$1|changed}}]] by [[User:$1|$1]]. $2.
[[Special:ListGroupRights|Learn more]]',
- 'notification-user-rights-flyout' => 'Your user rights were
{{GENDER:$1|changed}} by <b>$1</b>. $2. [[Special:ListGroupRights|Learn more]]',
+ 'notification-user-rights-flyout' => 'Your user rights were
{{GENDER:$1|changed}} by $1. $2. [[Special:ListGroupRights|Learn more]]',
'notification-user-rights-add' => 'You are now a member of
{{PLURAL:$2|this group|these groups}}: $1',
'notification-user-rights-remove' => 'You are no longer a member of
{{PLURAL:$2|this group|these groups}}: $1',
'notification-new-user' => "Welcome to {{SITENAME}}, $1! We're glad
you're here.",
'notification-reverted2' => 'Your {{PLURAL:$4|edit on [[:$2]] has|edits
on [[:$2]] have}} been {{GENDER:$1|reverted}} by [[User:$1|$1]] $3',
- 'notification-reverted-flyout2' => 'Your {{PLURAL:$4|edit on <b>$2</b>
has|edits on <b>$2</b> have}} been {{GENDER:$1|reverted}} by <b>$1</b> $3',
+ 'notification-reverted-flyout2' => 'Your {{PLURAL:$4|edit on $2
has|edits on $2 have}} been {{GENDER:$1|reverted}} by $1 $3',
'notification-edit-talk-page-email-subject2' => 'You have a new
talkpage message on {{SITENAME}}',
'notification-edit-talk-page-email-body2' => '$1
@@ -347,7 +349,7 @@
* $3 - the page title of the discussion",
'notification-mention-flyout' => "Flyout-specific format for displaying
notifications of a comment including a link to another user's user page.
Parameters:
-* <b>$1</b> - the username of the person who mentioned you, plain text. Can be
used for GENDER.
+* $1 - the username of the person who mentioned you, plain text. Can be used
for GENDER.
* $2 - the section title of the discussion
* $3 - the page title of the discussion",
'notification-user-rights' => 'Format for displaying notifications of a
user right change in notification page. Parameters:
diff --git a/Echo.php b/Echo.php
index d7e8501..ec1e833 100755
--- a/Echo.php
+++ b/Echo.php
@@ -419,6 +419,8 @@
'icon' => 'site',
),
'edit-user-talk' => array(
+ 'primary-link' => array( 'message' =>
'notification-view-message', 'destination' => 'subject-anchor' ),
+ 'secondary-link' => array( 'message' =>
'notification-view-changes', 'destination' => 'agent' ),
'category' => 'edit-user-talk',
'group' => 'interactive',
'bundle' => array( 'web' => true, 'email' => false ),
diff --git a/controller/NotificationController.php
b/controller/NotificationController.php
index 586ca15..2c67c40 100644
--- a/controller/NotificationController.php
+++ b/controller/NotificationController.php
@@ -1,5 +1,8 @@
<?php
-
+/**
+ * This class represents the controller for notifications and includes
functions
+ * for dealing with notification types and categories.
+ */
class EchoNotificationController {
static protected $blacklist;
static protected $userWhitelist;
@@ -107,6 +110,36 @@
}
/**
+ * Get the message key of the primary or secondary link for a
notification type.
+ *
+ * @param $notificationType string A notification type defined in
$wgEchoNotifications
+ * @param $rank String 'primary' or 'secondary'
+ * @return String i18n message key
+ */
+ public static function getLinkMessage( $notificationType, $rank ) {
+ global $wgEchoNotifications;
+ if ( isset(
$wgEchoNotifications[$notificationType][$rank.'-link']['message'] ) ) {
+ return
$wgEchoNotifications[$notificationType][$rank.'-link']['message'];
+ }
+ return '';
+ }
+
+ /**
+ * Get the link destination of the primary or secondary link for a
notification type.
+ *
+ * @param $notificationType string A notification type defined in
$wgEchoNotifications
+ * @param $rank String 'primary' or 'secondary'
+ * @return String The link destination, e.g. 'agent'
+ */
+ public static function getLinkDestination( $notificationType, $rank ) {
+ global $wgEchoNotifications;
+ if ( isset(
$wgEchoNotifications[$notificationType][$rank.'-link']['destination'] ) ) {
+ return
$wgEchoNotifications[$notificationType][$rank.'-link']['destination'];
+ }
+ return '';
+ }
+
+ /**
* Format the notification count with Language::formatNum(). In
addition, for large count,
* return abbreviated version, e.g. 99+
* @param $count int
diff --git a/formatters/BasicFormatter.php b/formatters/BasicFormatter.php
index b5cd76f..a89a70b 100644
--- a/formatters/BasicFormatter.php
+++ b/formatters/BasicFormatter.php
@@ -213,6 +213,22 @@
// like the close box won't inherit the greyed out opacity
(which can't be reset).
$output = Xml::tags( 'div', array( 'class' => 'mw-echo-state'
), $output ) . "\n";
+ // If a primary link definition exists for this notification
type, wrap
+ // the notification in an anchor tag linking to the primary
link.
+ if ( $this->outputFormat === 'flyout' ) {
+ $linkUrl = $this->getLinkUrl( $event, 'primary' );
+ if ( $linkUrl ) {
+ $output = Xml::tags(
+ 'a',
+ array(
+ 'class' =>
'mw-echo-notification-link',
+ 'href' => $linkUrl
+ ),
+ $output
+ ) . "\n";
+ }
+ }
+
return $output;
}
@@ -502,6 +518,30 @@
}
/**
+ * Get the URL for the primary or secondary link for an event
+ *
+ * @param EchoEvent $event
+ * @param String $rank 'primary' or 'secondary' (default is 'primary')
+ * @param boolean $local True to return a local URL, false to return a
full
+ * URL (for email for example) (default is true)
+ * @return String URL for the link
+ */
+ protected function getLinkUrl( $event, $rank = 'primary', $local = true
) {
+ $destination = EchoNotificationController::getLinkDestination(
$event->getType(), $rank );
+ switch ( $destination ) {
+ case 'agent':
+ if ( $local ) {
+ return
$event->getAgent()->getUserPage()->getLocalURL();
+ } else {
+ return
$event->getAgent()->getUserPage()->getFullURL();
+ }
+ break;
+ default:
+ return '';
+ }
+ }
+
+ /**
* Helper function for processParams()
*
* @param $event EchoEvent
diff --git a/modules/overlay/ext.echo.overlay.js
b/modules/overlay/ext.echo.overlay.js
index 2bcce4e..74a26bf 100644
--- a/modules/overlay/ext.echo.overlay.js
+++ b/modules/overlay/ext.echo.overlay.js
@@ -204,7 +204,7 @@
} );
}
} ).fail( function () {
- window.location.href = $( '#pt-notifications a'
).attr( 'href' );
+ //window.location.href = $( '#pt-notifications
a' ).attr( 'href' );
} );
}
};
--
To view, visit https://gerrit.wikimedia.org/r/68817
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I94aed697e87126ed8ad6d1d416c99bafaa53ac53
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits