diff --git a/Echo.i18n.php b/Echo.i18n.php
index 3a78620b6..5b6de5068 100644
--- a/Echo.i18n.php
+++ b/Echo.i18n.php
@@ -19,12 +19,16 @@ $messages['en'] = array(
'prefs-newmessageindicator' => 'New message indicator',
'echo-pref-send-me' => 'Send me:',
'echo-pref-send-to' => 'Send to:',
+ // Update this to 'Email format' when HTML email is ready for email digest
+ 'echo-pref-email-format' => 'Individual email format:',
'echo-pref-web' => 'Web',
'echo-pref-email' => 'Email',
'echo-pref-email-frequency-never' => 'Do not send me any email notifications',
'echo-pref-email-frequency-immediately' => 'Individual notifications as they come in',
'echo-pref-email-frequency-daily' => 'A daily summary of notifications',
'echo-pref-email-frequency-weekly' => 'A weekly summary of notifications',
+ 'echo-pref-email-format-html' => 'HTML',
+ 'echo-pref-email-format-plain-text' => 'Plain text',
'echo-pref-notify-show-link' => 'Show notifications in my toolbar',
'echo-pref-new-message-indicator' => 'Show talk page message indicator in my toolbar',
'echo-learn-more' => 'Learn more',
@@ -74,9 +78,9 @@ $messages['en'] = array(
'notification-link-text-view-changes' => 'View changes',
'notification-link-text-view-page' => 'View page',
'notification-link-text-view-edit' => 'View edit',
- 'notification-edit-talk-page2' => '[[User:$1|$1]] {{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-edit-talk-page2' => '[[User:$1|$1]] {{GENDER:$1|left}} a message on your [[User talk:$2#$3|talk page]].',
+ 'notification-edit-talk-page-flyout2' => '$1 {{GENDER:$1|left}} a message 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' => '$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]]',
@@ -91,61 +95,15 @@ $messages['en'] = array(
'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 $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-body3' => '$1
-
-$3
-
-View your talk page:
-<$2>
-
-View this change:
-<$4>
-
-$5',
- 'notification-edit-talk-page-email-batch-body2' => '$1 {{GENDER:$1|posted}} on your talk page',
- 'notification-page-linked-email-subject' => 'A page you started was linked on {{SITENAME}}',
- 'notification-page-linked-email-body' => '$1
-
-See all links to this page:
-
-{{canonicalurl:{{#special:WhatLinksHere/$2}}}}
-
-$3',
+ 'notification-edit-talk-page-email-subject2' => '$1 {{GENDER:$1|left}} you a message on {{SITENAME}}',
+ 'notification-edit-talk-page-email-batch-body2' => '$1 {{GENDER:$1|left}} a message on your talk page',
+ 'notification-page-linked-email-subject' => 'Your page was linked on {{SITENAME}}',
'notification-page-linked-email-batch-body' => '$2 was {{GENDER:$1|linked}} from $3',
- 'notification-reverted-email-subject2' => 'Your {{PLURAL:$3|edit on $2 was|edits on $2 were}} {{GENDER:$1|reverted}} by $1 on {{SITENAME}}',
- 'notification-reverted-email-body2' => 'Your {{PLURAL:$7|edit on $2 has been|edits on $2 have been}} {{GENDER:$1|reverted}} by $1.
-
-$5
-
-View more:
-
-<$3>
-
-$6',
- 'notification-reverted-email-batch-body2' => 'Your {{PLURAL:$3|edit on $2 was|edits on $2 were}} {{GENDER:$1|reverted}} by $1',
+ 'notification-reverted-email-subject2' => 'Your {{PLURAL:$3|edit was|edits were}} {{GENDER:$1|reverted}} on {{SITENAME}}',
+ 'notification-reverted-email-batch-body2' => 'Your {{PLURAL:$3|edit on $2 has been|edits on $2 have been}} {{GENDER:$1|reverted}} by $1',
'notification-mention-email-subject' => '$1 {{GENDER:$1|mentioned}} you on {{SITENAME}}',
- 'notification-mention-email-body' => '{{SITENAME}} user $1 {{GENDER:$1|mentioned}} you on $2.
-
-$3
-
-View mention:
-
-<$4>
-
-View changes:
-<$6>
-
-$5',
'notification-mention-email-batch-body' => '$1 {{GENDER:$1|mentioned}} you on $2',
'notification-user-rights-email-subject' => 'Your user rights have changed on {{SITENAME}}',
- 'notification-user-rights-email-body' => 'Your user rights were {{GENDER:$1|changed}} by $1. $2
-
-View more:
-
-{{canonicalurl:{{#special:ListGroupRights}}}}
-
-$3',
'notification-user-rights-email-batch-body' => 'Your user rights were {{GENDER:$1|changed}} by $1. $2',
'echo-notification-count' => '$1+',
// Email notification
@@ -159,6 +117,8 @@ $1',
To control which emails we send you, check your preferences:
{{canonicalurl:{{#special:Preferences}}#mw-prefsection-echo}}
+$1',
+ 'echo-email-footer-default-html' => 'To control which emails we send you, check your preferences
$1',
// Notifications overlay
'echo-overlay-link' => 'All notifications',
@@ -172,9 +132,9 @@ $1',
'echo-load-more-error' => 'An error occurred while fetching more results.',
// Bundle
- 'notification-edit-talk-page-bundle' => '$1 and $3 {{PLURAL:$4|other|others}} {{GENDER:$1|posted}} on your [[User talk:$2|talk page]].',
+ 'notification-edit-talk-page-bundle' => '$1 and $3 {{PLURAL:$4|other|others}} {{GENDER:$1|left}} a message on your [[User talk:$2|talk page]].',
'notification-page-linked-bundle' => '$2 was {{GENDER:$1|linked}} from $3 and $4 other {{PLURAL:$5|page|pages}}. [[Special:WhatLinksHere/$2|See all links to this page]]',
- 'notification-edit-user-talk-email-batch-bundle-body' => '$1 and $2 {{PLURAL:$3|other|others}} {{GENDER:$1|posted}} on your talk page',
+ 'notification-edit-user-talk-email-batch-bundle-body' => '$1 and $2 {{PLURAL:$3|other|others}} {{GENDER:$1|left}} a message on your talk page',
'notification-page-linked-email-batch-bundle-body' => '$2 was {{GENDER:$1|linked}} from $3 and $4 other {{PLURAL:$5|page|pages}}',
// Email batch
@@ -231,6 +191,7 @@ $messages['qqq'] = array(
* {{msg-mw|Echo-pref-email-frequency-daily}}
* {{msg-mw|Echo-pref-email-frequency-weekly}}',
'echo-pref-send-to' => 'Label for the address to send email notifications to.',
+ 'echo-pref-email-format' => 'Label for individual email notification format, the lable will be updated once HTML email is ready for email digest',
'echo-pref-web' => 'Label for list of notifications which are delivered on the web. In other words, on the wiki itself rather by email or another method. This should be kept very short.',
'echo-pref-email' => 'Label for list of notifications which are delivered via email. This should be kept very short.',
'echo-pref-email-frequency-never' => "Option for users who don't want to receive any email notifications
@@ -242,6 +203,8 @@ See also:
'echo-pref-email-frequency-immediately' => 'Option for users who want to receive email for each notification as it occurs',
'echo-pref-email-frequency-daily' => 'Option for users who want to receive a daily digest of email notifications',
'echo-pref-email-frequency-weekly' => 'Option for users who want to receive a weekly digest of email notifications',
+ 'echo-pref-email-format-html' => 'Option for users who want to receive HTML email notification',
+ 'echo-pref-email-format-plain-text' => 'Option for users who want to receive plain text email notification',
'echo-pref-notify-show-link' => "Label for a preference which enables the 'Notifications' link in the header and associated fly-out panel",
'echo-pref-new-message-indicator' => 'Label for a preference which enables the new talk page message alert',
'echo-learn-more' => 'Text for link to more information about a topic.
@@ -324,8 +287,7 @@ See also:
See also:
* {{msg-mw|Notification-page-linked-flyout}}
* {{msg-mw|Notification-page-linked-email-batch-body}}
-* {{msg-mw|Notification-page-linked-email-subject}}
-* {{msg-mw|Notification-page-linked-email-body}}',
+* {{msg-mw|Notification-page-linked-email-subject}}',
'notification-page-linked-flyout' => 'Flyout-specific format for displaying notifications of articles being linked
* $1 is the username of the person who linked the page, plain text. Can be used for GENDER.
* $2 is the page being linked
@@ -333,8 +295,7 @@ See also:
See also:
* {{msg-mw|Notification-page-linked}}
* {{msg-mw|Notification-page-linked-email-batch-body}}
-* {{msg-mw|Notification-page-linked-email-subject}}
-* {{msg-mw|Notification-page-linked-email-body}}',
+* {{msg-mw|Notification-page-linked-email-subject}}',
'notification-add-comment2' => 'Format for displaying notifications of a comment being added to an existing discussion. Parameters:
* $1 is the username of the person who edited, plain text. Can be used for GENDER.
* $2 is the section title of the discussion,
@@ -396,14 +357,9 @@ See also:
* $3 is a diff link to the ''revert'', possibly formatted.
* $4 is the number of edits that were reverted. NOTE: This will only be set to 1 or 2, with 2 actually meaning 'an unknown number greater than 0'.
{{Related|Notification-reverted}}",
- 'notification-edit-talk-page-email-subject2' => 'E-mail subject.',
- 'notification-edit-talk-page-email-body3' => "E-mail notification. Parameters:
-* $1 - the email intro, could be {{msg-mw|notification-edit-talk-page-email-batch-body2}} or {{msg-mw|notification-edit-user-talk-email-batch-bundle-body}}
-* <$2> - a link to the user's talk page
-* $3 - the edit summary
-* <$4> - a link to the 'diff view' of the changes that were made
-* $5 - the e-mail footer, {{msg-mw|echo-email-footer-default}}",
- 'notification-edit-talk-page-email-batch-body2' => 'E-mail notification for talk page edit
+ 'notification-edit-talk-page-email-subject2' => 'E-mail subject. Parameters:
+* $1 is a username which can be used for gender support',
+ 'notification-edit-talk-page-email-batch-body2' => 'E-mail notification for talk page edit. Parameters
* $1 is a username
See also:
@@ -414,17 +370,7 @@ See also:
See also:
* {{msg-mw|Notification-page-linked}}
* {{msg-mw|Notification-page-linked-flyout}}
-* {{msg-mw|Notification-page-linked-email-batch-body}}
-* {{msg-mw|Notification-page-linked-email-body}}',
- 'notification-page-linked-email-body' => 'E-mail notification. Parameters:
-* $1 is the email intro, could be {{msg-mw|notification-page-linked-email-batch-body}} or {{msg-mw|notification-page-linked-email-batch-bundle-body}}
-* $2 is the page being linked.
-* $3 is the e-mail footer, {{msg-mw|echo-email-footer-default}}.
-See also:
-* {{msg-mw|Notification-page-linked}}
-* {{msg-mw|Notification-page-linked-flyout}}
-* {{msg-mw|Notification-page-linked-email-batch-body}}
-* {{msg-mw|Notification-page-linked-email-subject}}',
+* {{msg-mw|Notification-page-linked-email-batch-body}}',
'notification-page-linked-email-batch-body' => 'E-mail notification for page being linked. Parameters:
* $1 is the username of the person who linked the page, plain text. Can be used for GENDER.
* $2 is the page being linked.
@@ -432,22 +378,12 @@ See also:
See also:
* {{msg-mw|Notification-page-linked}}
* {{msg-mw|Notification-page-linked-flyout}}
-* {{msg-mw|Notification-page-linked-email-subject}}
-* {{msg-mw|Notification-page-linked-email-body}}',
+* {{msg-mw|Notification-page-linked-email-subject}}',
'notification-reverted-email-subject2' => 'E-mail subject. Parameters:
* $1 is a username
* $2 is a page title
* $3 is the number of revert
{{Related|Notification-reverted}}',
- 'notification-reverted-email-body2' => "E-mail notification. Parameters:
-* $1 is the username
-* $2 is the page title
-* <$3> is the link to the change
-* $4 is the e-mail recipient's username
-* $5 is the edit summary
-* $6 is the email footer, {{msg-mw|echo-email-footer-default}}
-* $7 is the number of revert
-{{Related|Notification-reverted}}",
'notification-reverted-email-batch-body2' => 'E-mail notification for page revert. Parameters:
* $1 is a username
* $2 is a page title
@@ -459,21 +395,7 @@ See also:
See also:
* {{msg-mw|Notification-mention}}
* {{msg-mw|Notification-mention-flyout}}
-* {{msg-mw|Notification-mention-email-batch-body}}
-* {{msg-mw|Notification-mention-email-body}}',
- 'notification-mention-email-body' => 'E-mail notification. Parameters:
-* $1 is a username, plaintext. Can be used for gender support
-* $2 is talk page title
-* $3 is the edit summary
-* <$4> is the link to the talk page section title
-* $5 is the email footer
-* <$6> is a link to the diff view of the changes that were made
-
-See also:
-* {{msg-mw|Notification-mention}}
-* {{msg-mw|Notification-mention-flyout}}
-* {{msg-mw|Notification-mention-email-batch-body}}
-* {{msg-mw|Notification-mention-email-subject}}',
+* {{msg-mw|Notification-mention-email-batch-body}}',
'notification-mention-email-batch-body' => 'E-mail notification batch body. Parameters:
* $1 is a username, plaintext. Can be used for gender support
* $2 is talk page title
@@ -481,25 +403,13 @@ See also:
See also:
* {{msg-mw|Notification-mention}}
* {{msg-mw|Notification-mention-flyout}}
-* {{msg-mw|Notification-mention-email-body}}
* {{msg-mw|Notification-mention-email-subject}}',
'notification-user-rights-email-subject' => 'E-mail subject for user rights notification
See also:
* {{msg-mw|Notification-user-rights}}
* {{msg-mw|Notification-user-rights-flyout}}
-* {{msg-mw|Notification-user-rights-email-batch-body}}
-* {{msg-mw|Notification-user-rights-email-body}}',
- 'notification-user-rights-email-body' => 'E-mail notification. Parameters:
-* $1 - a user name, plaintext. Can be used for gender support
-* $2 - a semicolon separated list of {{msg-mw|notification-user-rights-add}}, {{msg-mw|notification-user-rights-remove}}
-* $3 - the email footer
-
-See also:
-* {{msg-mw|Notification-user-rights}}
-* {{msg-mw|Notification-user-rights-flyout}}
-* {{msg-mw|Notification-user-rights-email-batch-body}}
-* {{msg-mw|Notification-user-rights-email-subject}}',
+* {{msg-mw|Notification-user-rights-email-batch-body}}',
'notification-user-rights-email-batch-body' => 'Email notification batch body. Parameters:
* $1 is a user name, plaintext. Can be used for gender support
* $2 is a semicolon separated list of {{msg-mw|notification-user-rights-add}}, {{msg-mw|notification-user-rights-remove}}',
@@ -510,9 +420,12 @@ The new notification count next to notification link, for example: 99+
'echo-email-body-default' => 'Default message content for Echo e-mail notifications.
* $1 is a plain text description of the notification.',
'echo-email-batch-body-default' => 'Default message for Echo e-mail digest notifications',
- 'echo-email-footer-default' => 'Default footer content for Echo e-mail notifications. Parameters:
+ 'echo-email-footer-default' => 'Default footer content for Echo text e-mail notifications. Parameters:
* $1 is the address of the organization that sent the e-mail
* $2 is "-------..." ({{msg-mw|echo-email-batch-separator}})',
+ 'echo-email-footer-default-html' => 'Default footer content for Echo html e-mail notifications. Parameters:
+* $1 is the address of the organization that sent the e-mail
+* $2 is the url to the notification preference page',
'echo-overlay-link' => 'Link to "all notifications" at the bottom of the overlay.
{{Identical|All notifications}}',
'echo-overlay-title' => 'Title at the top of the notifications overlay. Should include bold tags.',
@@ -534,8 +447,7 @@ The new notification count next to notification link, for example: 99+
See also:
* {{msg-mw|Notification-edit-talk-page2}}
* {{msg-mw|Notification-edit-talk-page-email-batch-body2}}
-* {{msg-mw|Notification-edit-talk-page-email-subject2}}
-* {{msg-mw|Notification-edit-talk-page-email-body2}}',
+* {{msg-mw|Notification-edit-talk-page-email-subject2}}',
'notification-page-linked-bundle' => 'Bundled message for page-linked notification. Parameters:
* $1 - the username who performs the action, which can be used for gender support
* $2 - the page title
@@ -557,8 +469,7 @@ See also:
* {{msg-mw|Notification-edit-talk-page2}}
* {{msg-mw|Notification-edit-talk-page-flyout2}}
* {{msg-mw|Notification-edit-talk-page-email-batch-body2}}
-* {{msg-mw|Notification-edit-talk-page-email-subject2}}
-* {{msg-mw|Notification-edit-talk-page-email-body2}}',
+* {{msg-mw|Notification-edit-talk-page-email-subject2}}',
'notification-page-linked-email-batch-bundle-body' => 'Bundled message for page-linked email digest notification. Parameters:
* $1 - the username who performs the action, which can be used for gender support
* $2 - the link-to page title
@@ -570,8 +481,7 @@ See also:
* {{msg-mw|Notification-page-linked}}
* {{msg-mw|Notification-page-linked-flyout}}
* {{msg-mw|Notification-page-linked-email-batch-body}}
-* {{msg-mw|Notification-page-linked-email-subject}}
-* {{msg-mw|Notification-page-linked-email-body}}',
+* {{msg-mw|Notification-page-linked-email-subject}}',
'echo-email-batch-separator' => '{{optional}}
Email batch content separator',
'echo-email-batch-bullet' => '{{optional}}',
diff --git a/Echo.php b/Echo.php
index a16ddbcb7..66eb6b97f 100644
--- a/Echo.php
+++ b/Echo.php
@@ -61,6 +61,14 @@ $wgAutoloadClasses['EchoCommentFormatter'] = $dir . 'formatters/CommentFormatter
$wgAutoloadClasses['EchoUserRightsFormatter'] = $dir . 'formatters/UserRightsFormatter.php';
$wgAutoloadClasses['EchoPageLinkFormatter'] = $dir . 'formatters/PageLinkFormatter.php';
+// Email formatters
+$wgAutoloadClasses['EchoEmailFormatter'] = $dir . 'includes/EmailFormatter.php';
+$wgAutoloadClasses['EchoTextEmailFormatter'] = $dir . 'includes/EmailFormatter.php';
+$wgAutoloadClasses['EchoHTMLEmailFormatter'] = $dir . 'includes/EmailFormatter.php';
+$wgAutoloadClasses['EchoEmailMode'] = $dir . 'includes/EmailFormatter.php';
+$wgAutoloadClasses['EchoEmailSingle'] = $dir . 'includes/EmailFormatter.php';
+$wgAutoloadClasses['EchoEmailDigest'] = $dir . 'includes/EmailFormatter.php';
+
// Internal stuff
$wgAutoloadClasses['EchoNotifier'] = $dir . 'Notifier.php';
$wgAutoloadClasses['EchoNotificationController'] = $dir . 'controller/NotificationController.php';
@@ -124,8 +132,6 @@ $echoResourceTemplate = array(
'group' => 'ext.echo',
);
-$wgRecentEchoInstall = false; // default should be overridden with true until sure migration is complete
-
$wgResourceModules += array(
'ext.echo.base' => $echoResourceTemplate + array(
'styles' => 'base/ext.echo.base.css',
@@ -429,8 +435,7 @@ $wgEchoNotifications = array(
'flyout-message' => 'notification-edit-talk-page-flyout2',
'flyout-params' => array( 'agent', 'user', 'subject-anchor' ),
'email-subject-message' => 'notification-edit-talk-page-email-subject2',
- 'email-body-message' => 'notification-edit-talk-page-email-body3',
- 'email-body-params' => array( 'email-intro', 'titlelink', 'summary', 'difflink', 'email-footer' ),
+ 'email-subject-params' => array( 'agent' ),
'email-body-batch-message' => 'notification-edit-talk-page-email-batch-body2',
'email-body-batch-params' => array( 'agent' ),
'email-body-batch-bundle-message' => 'notification-edit-user-talk-email-batch-bundle-body',
@@ -449,8 +454,6 @@ $wgEchoNotifications = array(
'flyout-params' => array( 'agent', 'title', 'difflink', 'number' ),
'email-subject-message' => 'notification-reverted-email-subject2',
'email-subject-params' => array( 'agent', 'title', 'number' ),
- 'email-body-message' => 'notification-reverted-email-body2',
- 'email-body-params' => array( 'agent', 'title', 'difflink', 'user', 'summary', 'email-footer', 'number' ),
'email-body-batch-message' => 'notification-reverted-email-batch-body2',
'email-body-batch-params' => array( 'agent', 'title', 'number' ),
'icon' => 'revert',
@@ -470,8 +473,6 @@ $wgEchoNotifications = array(
'flyout-params' => array( 'agent', 'title', 'link-from-page' ),
'email-subject-message' => 'notification-page-linked-email-subject',
'email-subject-params' => array(),
- 'email-body-message' => 'notification-page-linked-email-body',
- 'email-body-params' => array( 'email-intro', 'title', 'email-footer', 'link-from-page' ),
'email-body-batch-message' => 'notification-page-linked-email-batch-body',
'email-body-batch-params' => array( 'agent', 'title', 'link-from-page' ),
'email-body-batch-bundle-message' => 'notification-page-linked-email-batch-bundle-body',
@@ -491,8 +492,6 @@ $wgEchoNotifications = array(
'flyout-params' => array( 'agent', 'subject-anchor', 'title' ),
'email-subject-message' => 'notification-mention-email-subject',
'email-subject-params' => array( 'agent' ),
- 'email-body-message' => 'notification-mention-email-body',
- 'email-body-params' => array( 'agent', 'title', 'summary', 'subject-link', 'email-footer', 'difflink' ),
'email-body-batch-message' => 'notification-mention-email-batch-body',
'email-body-batch-params' => array( 'agent', 'title' ),
'icon' => 'chat',
@@ -509,8 +508,6 @@ $wgEchoNotifications = array(
'flyout-params' => array( 'agent', 'user-rights-list' ),
'email-subject-message' => 'notification-user-rights-email-subject',
'email-subject-params' => array(),
- 'email-body-message' => 'notification-user-rights-email-body',
- 'email-body-params' => array( 'agent', 'user-rights-list', 'email-footer' ),
'email-body-batch-message' => 'notification-user-rights-email-batch-body',
'email-body-batch-params' => array( 'agent', 'user-rights-list' ),
'icon' => 'site',
@@ -526,6 +523,12 @@ $wgDefaultUserOptions['echo-show-alert'] = true;
// By default, send emails for each notification as they come in
$wgDefaultUserOptions['echo-email-frequency'] = EchoHooks::EMAIL_IMMEDIATELY;
+if ( $wgAllowHTMLEmail ) {
+ $wgDefaultUserOptions['echo-email-format'] = EchoHooks::EMAIL_FORMAT_HTML;
+} else {
+ $wgDefaultUserOptions['echo-email-format'] = EchoHooks::EMAIL_FORMAT_PLAIN_TEXT;
+}
+
// Set all of the events to notify by web but not email by default (won't affect events that don't email)
foreach ( $wgEchoNotificationCategories as $category => $categoryData ) {
$wgDefaultUserOptions["echo-subscriptions-email-{$category}"] = false;
diff --git a/Hooks.php b/Hooks.php
index a7c8be178..348170c24 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -5,6 +5,8 @@ class EchoHooks {
const EMAIL_IMMEDIATELY = 0; // Send email notificaitons immediately as they come in
const EMAIL_DAILY_DIGEST = 1; // Send daily email digests
const EMAIL_WEEKLY_DIGEST = 7; // Send weekly email digests
+ const EMAIL_FORMAT_HTML = 'html';
+ const EMAIL_FORMAT_PLAIN_TEXT = 'plain-text';
/**
* Initialize Echo extension with necessary data, this function is invoked
@@ -247,7 +249,7 @@ class EchoHooks {
public static function getPreferences( $user, &$preferences ) {
global $wgEchoDefaultNotificationTypes, $wgAuth, $wgEchoEnableEmailBatch,
$wgEchoNotifiers, $wgEchoNotificationCategories, $wgEchoNotifications,
- $wgEchoHelpPage, $wgEchoNewMsgAlert;
+ $wgEchoHelpPage, $wgEchoNewMsgAlert, $wgAllowHTMLEmail;
// Don't show echo preference page if echo is disabled for this user
if ( self::isEchoDisabled( $user ) ) {
@@ -302,6 +304,20 @@ class EchoHooks {
'section' => 'echo/emailsettings'
);
+ // Only show this option if html email is allowed, otherwise it is always plain text format
+ if ( $wgAllowHTMLEmail ) {
+ // Email format
+ $preferences['echo-email-format'] = array(
+ 'type' => 'select',
+ 'label-message' => 'echo-pref-email-format',
+ 'section' => 'echo/emailsettings',
+ 'options' => array (
+ wfMessage( 'echo-pref-email-format-html' )->plain() => self::EMAIL_FORMAT_HTML,
+ wfMessage( 'echo-pref-email-format-plain-text' )->plain() => self::EMAIL_FORMAT_PLAIN_TEXT
+ )
+ );
+ }
+
// Sort notification categories by priority
$categoriesAndPriorities = array();
foreach ( $wgEchoNotificationCategories as $category => $categoryData ) {
diff --git a/formatters/BasicFormatter.php b/formatters/BasicFormatter.php
index 800d8c037..e2b3eabb5 100644
--- a/formatters/BasicFormatter.php
+++ b/formatters/BasicFormatter.php
@@ -7,15 +7,6 @@
*/
class EchoBasicFormatter extends EchoNotificationFormatter {
- /**
- * Required parameters
- * @param array
- */
- protected $requiredParameters = array(
- 'title-message',
- 'title-params'
- );
-
/**
* Notification title data for archive page
* @param array
@@ -33,11 +24,6 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
*/
protected $bundleTitle;
- /**
- * @Todo Check if this varaible can be removed
- */
- protected $content;
-
/**
* Notification email data
* @param array
@@ -50,6 +36,15 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
*/
protected $icon;
+ /**
+ * Required parameters
+ * @param array
+ */
+ protected $requiredParameters = array (
+ 'title-message',
+ 'title-params'
+ );
+
/**
* Data for constructing bundle message, data in this array
* should be used in function processParams()
@@ -92,10 +87,6 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
'message' => $params['email-subject-message'],
'params' => $params['email-subject-params']
),
- 'body' => array(
- 'message' => $params['email-body-message'],
- 'params' => $params['email-body-params']
- ),
'batch-body' => array(
'message' => $params['email-body-batch-message'],
'params' => $params['email-body-batch-params']
@@ -124,8 +115,6 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
'payload' => array(),
'email-subject-message' => 'echo-email-subject-default',
'email-subject-params' => array(),
- 'email-body-message' => 'echo-email-body-default',
- 'email-body-params' => array( 'text-notification' ),
'email-body-batch-message' => 'echo-email-batch-body-default',
'email-body-batch-params' => array(),
'email-body-batch-bundle-message' => '',
@@ -261,25 +250,48 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
}
/**
+ * Create text version and/or html version for email notification
+ *
* @param $event EchoEvent
* @param $user User
- * @param $type
+ * @param $type string
* @return array
*/
protected function formatEmail( $event, $user, $type ) {
- $subject = $this->formatFragment( $this->email['subject'], $event, $user )->text();
-
- $body = preg_replace( "/\n{3,}/", "\n\n", $this->formatFragment( $this->email['body'], $event, $user )->text() );
-
if ( $this->bundleData['use-bundle'] && $this->email['batch-bundle-body'] ) {
- $bodyKey = $this->email['batch-bundle-body'];
+ $key = $this->email['batch-bundle-body'];
} else {
- $bodyKey = $this->email['batch-body'];
+ $key = $this->email['batch-body'];
}
- $batchBody = preg_replace( "/\n{3,}/", "\n\n", $this->formatFragment( $bodyKey, $event, $user )->text() );
+ // Echo single email
+ $emailSingle = new EchoEmailSingle( $this, $event, $user );
- return array( 'subject' => $subject, 'body' => $body, 'batch-body' => $batchBody );
+ $textEmailFormatter = new EchoTextEmailFormatter( $emailSingle );
+ $content = array(
+ // Single email subject, there is no need to to escape it for either html
+ // or text email since it's always treated as plain text by mail client
+ 'subject' => $this->formatFragment( $this->email['subject'], $event, $user )->text(),
+ // Single email text body
+ 'body' => $textEmailFormatter->formatEmail(),
+ // Email digest text body
+ 'batch-body' => $this->formatFragment( $key, $event, $user )->text()
+ );
+
+ $format = MWEchoNotifUser::newFromUser( $user )->getEmailFormat();
+ if ( $format == EchoHooks::EMAIL_FORMAT_HTML ) {
+ $htmlEmailFormatter = new EchoHTMLEmailFormatter( $emailSingle );
+ $outputFormat = $this->outputFormat;
+ $this->setOutputFormat( 'htmlemail' );
+ // Add single email html body if user prefers html format
+ $content['body'] = array (
+ 'text' => $content['body'],
+ 'html' => $htmlEmailFormatter->formatEmail()
+ );
+ $this->setOutputFormat( $outputFormat );
+ }
+
+ return $content;
}
/**
@@ -290,7 +302,7 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
* @param $user User to format the notification for.
* @return string
*/
- protected function formatFragment( $details, $event, $user ) {
+ public function formatFragment( $details, $event, $user ) {
$message = wfMessage( $details['message'] )
->inLanguage( $user->getOption( 'language' ) );
@@ -387,7 +399,6 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
return Xml::tags( 'div', array( 'class' => 'mw-echo-notification-footer' ), $footer ) . "\n";
}
-
/**
* Generate links based on output format and passed properties
* $event EchoEvent
@@ -414,10 +425,10 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
}
$title->setFragment( "#$fragment" );
- if ( $this->outputFormat === 'html' || $this->outputFormat === 'flyout' ) {
- $class = array();
- if ( isset( $props['class'] ) ) {
- $class['class'] = $props['class'];
+ if ( in_array( $this->outputFormat, array( 'html', 'flyout', 'htmlemail' ) ) ) {
+ $attribs = array();
+ if ( isset( $props['attribs'] ) ) {
+ $attribs = (array)$props['attribs'];
}
if ( isset( $props['linkText'] ) ) {
@@ -426,27 +437,40 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
$linkText = htmlspecialchars( $title->getPrefixedText() );
}
- $message->rawParams( Linker::link( $title, $linkText, $class, $param ) );
- } elseif ( $this->outputFormat === 'email' ) {
- // plain text email in some mail client is messing with
- // ending punctuation in links, it is better to encode them
- $url = $title->getCanonicalURL( $param );
- // $url should contain all ascii characters now, it's safe to use substr()
- $lastChar = substr( $url, -1 );
- if ( $lastChar && !ctype_alnum( $lastChar ) ) {
- $lastChar = str_replace(
- array( '.', '-', '(', ';', '!', ':', ',' ),
- array( '%2E', '%2D', '%28', '%3B', '%21', '%3A', '%2C' ),
- $lastChar
- );
- $url = substr( $url, 0, -1 ) . $lastChar;
+ $options = array();
+ if ( $this->outputFormat === 'htmlemail' ) {
+ $options = array( 'https' );
}
- $message->params( $url );
+
+ $message->rawParams( Linker::link( $title, $linkText, $attribs, $param, $options ) );
+ } elseif ( $this->outputFormat === 'email' ) {
+ $url = $title->getFullURL( $param, false, PROTO_HTTPS );
+ $message->params( $this->sanitizeEmailLink( $url ) );
} else {
$message->params( $title->getFullURL( $param ) );
}
}
+ /**
+ * Plain text email in some mail client is misinterpreting the ending
+ * punctuation, this function would encode the last character
+ * @param $url string
+ * @param string
+ */
+ public function sanitizeEmailLink( $url ) {
+ // $url should contain all ascii characters now, it's safe to use substr()
+ $lastChar = substr( $url, -1 );
+ if ( $lastChar && !ctype_alnum( $lastChar ) ) {
+ $lastChar = str_replace(
+ array( '.', '-', '(', ';', '!', ':', ',' ),
+ array( '%2E', '%2D', '%28', '%3B', '%21', '%3A', '%2C' ),
+ $lastChar
+ );
+ $url = substr( $url, 0, -1 ) . $lastChar;
+ }
+ return $url;
+ }
+
/**
* Get raw bundle data for an event so it can be manipulated
* @param $event EchoEvent
@@ -551,11 +575,12 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
* 'border: 1px solid green; text-decoration: none;' (optional)
* @return String URL for link, or HTML for anchor tag, or empty string
*/
- protected function getLink( $event, $user, $rank = 'primary', $local = true, $urlOnly = false, $style = '' ) {
+ public function getLink( $event, $user, $rank = 'primary', $local = true, $urlOnly = false, $style = '' ) {
$destination = $event->getLinkDestination( $rank );
if ( !$destination ) {
return '';
}
+
// Get link parameters based on the destination
list( $target, $query ) = $this->getLinkParams( $event, $user, $destination );
if ( !$target ) {
@@ -565,7 +590,7 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
if ( $local ) {
return $target->getLinkURL( $query );
} else {
- return $target->getCanonicalURL( $query );
+ return $target->getFullURL( $query, false, PROTO_HTTPS );
}
} else {
$message = wfMessage( $event->getLinkMessage( $rank ) )->text();
@@ -576,7 +601,7 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
$options = array();
// If local is false, return an absolute url using HTTP protocol
if ( !$local ) {
- $options[] = 'http';
+ $options[] = 'https';
}
return Linker::link( $target, $message, $attribs, $query, $options );
}
@@ -630,23 +655,44 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
return array( $target, $query );
}
+ /**
+ * Get the style for standard links in html email
+ * @return string
+ */
+ public function getHTMLLinkStyle() {
+ return 'text-decoration: none; color: #3A68B0;';
+ }
+
/**
* Helper function for processParams()
*
* @param $event EchoEvent
- * @param $param
+ * @param $param string
* @param $message Message
* @param $user User
* @throws MWException
*/
protected function processParam( $event, $param, $message, $user ) {
if ( $param === 'agent' ) {
- if ( !$event->getAgent() ) {
+ $agent = $event->getAgent();
+ if ( !$agent ) {
$message->params( wfMessage( 'echo-no-agent' )->text() );
} elseif ( !$event->userCan( Revision::DELETED_USER, $user ) ) {
$message->params( wfMessage( 'rev-deleted-user' )->text() );
} else {
- $message->params( $event->getAgent()->getName() );
+ if ( $this->outputFormat === 'htmlemail' ) {
+ $message->rawParams(
+ Linker::link(
+ $agent->getUserPage(),
+ $agent->getName(),
+ array( 'style' => $this->getHTMLLinkStyle() ),
+ array(),
+ array( 'https' )
+ )
+ );
+ } else {
+ $message->params( $agent->getName() );
+ }
}
// example: {7} others, {99+} others
} elseif ( $param === 'agent-other-display') {
@@ -671,7 +717,14 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
if ( !$event->getTitle() ) {
$message->params( wfMessage( 'echo-no-title' )->text() );
} else {
- $message->params( $this->formatTitle( $event->getTitle() ) );
+ if ( $this->outputFormat === 'htmlemail' ) {
+ $props = array (
+ 'attribs' => array( 'style' => $this->getHTMLLinkStyle() )
+ );
+ $this->setTitleLink( $event, $message, $props );
+ } else {
+ $message->params( $this->formatTitle( $event->getTitle() ) );
+ }
}
} elseif ( $param === 'titlelink' ) {
$this->setTitleLink( $event, $message );
@@ -683,29 +736,20 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
$this->setOutputFormat( $oldOutputFormat );
$message->params( $textNotification );
- } elseif ( $param === 'email-intro' ) {
- if ( $this->bundleData['use-bundle'] && isset( $this->email['batch-bundle-body']['message'] ) ) {
- $detail = array(
- 'message' => $this->email['batch-bundle-body']['message'],
- 'params' => $this->email['batch-bundle-body']['params']
- );
- } else {
- $detail = array(
- 'message' => $this->email['batch-body']['message'],
- 'params' => $this->email['batch-body']['params']
- );
- }
- $message->params( $this->formatFragment( $detail, $event, $user )->text() );
- } elseif ( $param === 'email-footer' ) {
- global $wgEchoEmailFooterAddress;
- $message->params(
- wfMessage( 'echo-email-footer-default' )
- ->inLanguage( $user->getOption( 'language' ) )
- ->params( $wgEchoEmailFooterAddress, wfMessage( 'echo-email-batch-separator' )->text() )
- ->text()
- );
} else {
throw new MWException( "Unrecognised parameter $param" );
}
}
+
+ /**
+ * Getter method
+ * @param $key string
+ * @return mixed
+ */
+ public function getValue( $key ) {
+ if ( !property_exists( $this, $key ) ) {
+ throw new MWException( "Call to non-existing property $key in " . get_class( $this ) );
+ }
+ return $this->$key;
+ }
}
diff --git a/formatters/CommentFormatter.php b/formatters/CommentFormatter.php
index 8e7f3337d..423b2b23b 100644
--- a/formatters/CommentFormatter.php
+++ b/formatters/CommentFormatter.php
@@ -8,10 +8,6 @@ class EchoCommentFormatter extends EchoEditFormatter {
$this->title['message-yours'] = $params['title-message-yours'];
}
- if ( isset( $params['content-message-yours'] ) ) {
- $this->content['message-yours'] = $params['content-message-yours'];
- }
-
if ( isset( $params['email-subject-message-yours'] ) ) {
$this->email['subject']['message-yours'] = $params['email-subject-message-yours'];
}
@@ -27,7 +23,7 @@ class EchoCommentFormatter extends EchoEditFormatter {
* @param $user User
* @return Message
*/
- protected function formatFragment( $details, $event, $user ) {
+ public function formatFragment( $details, $event, $user ) {
$userTalkPage = $user->getUserPage()->getTalkPage();
$title = $event->getTitle();
@@ -47,7 +43,6 @@ class EchoCommentFormatter extends EchoEditFormatter {
* @param User $user
*/
protected function processParam( $event, $param, $message, $user ) {
- $extra = $event->getExtra();
if ( $param === 'content-page' ) {
if ( $event->getTitle() ) {
$message->params( $event->getTitle()->getSubjectPage()->getPrefixedText() );
diff --git a/formatters/EditFormatter.php b/formatters/EditFormatter.php
index 3577f8fd9..240ec7373 100644
--- a/formatters/EditFormatter.php
+++ b/formatters/EditFormatter.php
@@ -18,7 +18,7 @@ class EchoEditFormatter extends EchoBasicFormatter {
return;
}
$props = array(
- 'class' => 'mw-echo-diff',
+ 'attribs' => array( 'class' => 'mw-echo-diff' ),
'linkText' => wfMessage( 'parentheses', wfMessage( 'showdiff' )->text() )->escaped(),
'param' => array(
'oldid' => $revid,
diff --git a/formatters/NotificationFormatter.php b/formatters/NotificationFormatter.php
index 775eb492a..e68f5ef5c 100644
--- a/formatters/NotificationFormatter.php
+++ b/formatters/NotificationFormatter.php
@@ -12,7 +12,7 @@ abstract class EchoNotificationFormatter {
* List of valid output format
* @var array
*/
- protected $validOutputFormats = array( 'text', 'flyout', 'html', 'email' );
+ protected $validOutputFormats = array( 'text', 'flyout', 'html', 'email', 'htmlemail' );
/**
* Current output format, default is 'text'
@@ -121,7 +121,7 @@ abstract class EchoNotificationFormatter {
* @param User $user The user to format the notification for.
* @return String The revision comment (or empty string)
*/
- protected function formatRevisionComment( $event, $user ) {
+ public function formatRevisionComment( $event, $user ) {
$revision = $event->getRevision();
if ( $revision === null ) {
return '';
@@ -143,6 +143,7 @@ abstract class EchoNotificationFormatter {
$comment = Xml::tags( 'div', array( 'class' => 'mw-echo-edit-summary' ), $comment );
}
}
+
return $comment;
}
}
diff --git a/includes/EmailFormatter.php b/includes/EmailFormatter.php
new file mode 100644
index 000000000..e5f0bab53
--- /dev/null
+++ b/includes/EmailFormatter.php
@@ -0,0 +1,415 @@
+emailMode = $emailMode;
+ }
+
+ /**
+ * Abstract method for formatting email
+ * @return string
+ */
+ abstract public function formatEmail();
+}
+
+/**
+ * Formatter class for formatting text email notification
+ */
+class EchoTextEmailFormatter extends EchoEmailFormatter {
+
+ /**
+ * @param $emailMode EchoEmailMode
+ */
+ public function __construct( EchoEmailMode $emailMode ) {
+ parent::__construct( $emailMode );
+ }
+
+ /**
+ * Formatting text email notification
+ * @return string
+ */
+ public function formatEmail() {
+ $template = $this->emailMode->getTextTemplate();
+
+ foreach ( $this->emailMode->getComponent() as $val ) {
+ $func = 'build' . ucfirst( $val );
+ $template = str_replace( "%%$val%%", $this->emailMode->$func( 'text' ), $template );
+ }
+
+ // Remove redundant newline characters
+ return $this->removeExtraNewLine( $template );
+ }
+
+ /**
+ * Remove extra newline from a text content
+ * @param $text string
+ * @return string
+ */
+ protected function removeExtraNewLine( $text ) {
+ return preg_replace( "/\n{3,}/", "\n\n", $text );
+ }
+
+}
+
+/**
+ * Formatter class for formatting HTML email notification
+ */
+class EchoHTMLEmailFormatter extends EchoEmailFormatter {
+
+ /**
+ * @param $emailMode EchoEmailMode
+ */
+ public function __construct( EchoEmailMode $emailMode ) {
+ parent::__construct( $emailMode );
+ }
+
+ /**
+ * Formatting HTML email notification
+ * @return string
+ */
+ public function formatEmail() {
+ $template = $this->emailMode->getHTMLTemplate();
+
+ foreach ( $this->emailMode->getComponent() as $val ) {
+ $func = 'build' . ucfirst( $val );
+ $template = str_replace( "%%$val%%", $this->emailMode->$func( 'html' ), $template );
+ }
+
+ return $template;
+ }
+}
+
+/**
+ * Abstract entity that represents an email delivery mode
+ */
+abstract class EchoEmailMode {
+
+ /**
+ * Email components
+ * @var array
+ */
+ protected $component;
+
+ /**
+ * @var User
+ */
+ protected $user;
+
+ /**
+ * @param $user User
+ * @param $component array
+ */
+ public function __construct( User $user, array $component ) {
+ $this->user = $user;
+ // All email delivery mode share the same footer
+ $this->component = array_merge( $component, array( 'footer' ) );
+ }
+
+ /**
+ * Get text email template
+ * @return string
+ */
+ abstract public function getTextTemplate();
+
+ /**
+ * Get html email template
+ * @return string
+ */
+ abstract public function getHTMLTemplate();
+
+ /**
+ * Get the footer component
+ * @param $format string 'text'/'html'
+ * @return string
+ */
+ public function buildFooter( $format ) {
+ global $wgEchoEmailFooterAddress;
+
+ if ( $format === 'text' ) {
+ return wfMessage( 'echo-email-footer-default' )
+ ->params(
+ $wgEchoEmailFooterAddress,
+ wfMessage( 'echo-email-batch-separator' )->text()
+ )
+ ->text();
+ } else {
+ $title = SpecialPage::getTitleFor( 'Preferences' );
+ $title->setFragment( "#mw-prefsection-echo" );
+ return wfMessage( 'echo-email-footer-default-html' )
+ ->params( $wgEchoEmailFooterAddress )
+ ->rawParams( $title->getFullURL( '', false, PROTO_HTTPS ) )
+ ->text();
+ }
+ }
+
+ /**
+ * Getter method for email template component
+ * @return array
+ */
+ public function getComponent() {
+ return $this->component;
+ }
+
+ /**
+ * The style for primary link
+ * @return string
+ */
+ protected function getPrimaryLinkCSS() {
+ return 'cursor:pointer; text-align:center;
+ text-decoration:none; padding:.45em 1.2em .45em;
+ color:#D9EEF7; background:#3366BB;
+ font-family: arial;font-size: 13px;';
+ }
+
+ /**
+ * The style for secondary link
+ * @return string
+ */
+ protected function getSecondaryLinkCSS() {
+ return 'text-decoration: none;font-size: 10px;font-family: arial;
+ color: #808184';
+ }
+}
+
+/**
+ * Entity that represents a single email delivery mode
+ */
+class EchoEmailSingle extends EchoEmailMode {
+
+ /**
+ * @var EchoBasicFormatter
+ */
+ protected $notifFormatter;
+
+ /**
+ * @var EchoEvent
+ */
+ protected $event;
+
+ /**
+ * @param $notifFormatter EchoBasicFormatter
+ * @param $event EchoEvent
+ * @param $user User
+ */
+ public function __construct( EchoBasicFormatter $notifFormatter, EchoEvent $event, User $user ) {
+ parent::__construct( $user, array ( 'emailIcon', 'intro', 'summary', 'action' ) );
+ $this->notifFormatter = $notifFormatter;
+ $this->event = $event;
+ }
+
+ /**
+ * Build the intro component
+ * @param $format string 'text'/'html'
+ * @return string
+ */
+ public function buildIntro( $format ) {
+ $bundle = $this->notifFormatter->getValue( 'bundleData' );
+ $email = $this->notifFormatter->getValue( 'email' );
+
+ if ( $bundle['use-bundle'] && $email['batch-bundle-body']['message'] ) {
+ $detail = $email['batch-bundle-body'];
+ } else {
+ $detail = $email['batch-body'];
+ }
+
+ $message = $this->notifFormatter->formatFragment(
+ $detail,
+ $this->event,
+ $this->user
+ );
+
+ if ( $format === 'text' ) {
+ return $message->text();
+ } else {
+ return $message->parse();
+ }
+ }
+
+ /**
+ * Build the summary component
+ * @param $format string 'text'/'html'
+ * @return string
+ */
+ public function buildSummary( $format ) {
+ return $this->notifFormatter->formatRevisionComment(
+ $this->event,
+ $this->user
+ );
+ }
+
+ /**
+ * Build the action component
+ * @param $format string 'text'/'html'
+ * @return string
+ */
+ public function buildAction( $format ) {
+ $link = array();
+ $ranks = array( 'primary', 'secondary' );
+
+ foreach ( $ranks as $rank ) {
+ $message = $this->event->getLinkMessage( $rank );
+
+ // Valid call to action should have link text
+ if ( !$message ) {
+ continue;
+ }
+
+ // Plain text email
+ if ( $format === 'text' ) {
+ $url = $this->notifFormatter->getLink( $this->event, $this->user, $rank, false, true );
+
+ $link[] = wfMessage( $message )->text()
+ . wfMessage( 'colon-separator' )->text()
+ . '<'
+ . $this->notifFormatter->sanitizeEmailLink( $url )
+ . '>';
+ // HTML email
+ } else {
+ if ( $rank === 'primary' ) {
+ $style = $this->getPrimaryLinkCSS();
+ } else {
+ $style = $this->getSecondaryLinkCSS();
+ }
+
+ $link[] = $this->notifFormatter->getLink( $this->event, $this->user, $rank, false, false, $style );
+ }
+ }
+
+ // Add some spacing between the two action links
+ $spacing = ( $format === 'text' ) ? "\n\n" : " ";
+ return implode( $spacing, $link );
+ }
+
+ /**
+ * Build the email icon component
+ * @param $format string 'text'/'html'
+ * @return string
+ */
+ public function buildEmailIcon( $format ) {
+ global $wgEchoNotificationIcons, $wgExtensionAssetsPath;
+
+ $iconInfo = $wgEchoNotificationIcons[$this->notifFormatter->getValue( 'icon' )];
+ if ( isset( $iconInfo['url'] ) && $iconInfo['url'] ) {
+ $iconUrl = $iconInfo['url'];
+ } else {
+ if ( !isset( $iconInfo['path'] ) || !$iconInfo['path'] ) {
+ $iconInfo = $wgEchoNotificationIcons['placeholder'];
+ }
+ $iconUrl = "$wgExtensionAssetsPath/{$iconInfo['path']}";
+ }
+
+ return wfExpandUrl( $iconUrl );
+ }
+
+ /**
+ * Get template for text email
+ * @return string
+ */
+ public function getTextTemplate() {
+ return <<< EOF
+%%intro%%
+
+%%summary%%
+
+%%action%%
+
+%%footer%%
+EOF;
+ }
+
+ /**
+ * Get template for html email
+ * @return string
+ */
+ public function getHTMLTemplate() {
+ return <<< EOF
+
+
|
+