Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/249885

Change subject: [WIP] Add plain text email formatter
......................................................................

[WIP] Add plain text email formatter

TODO:
* Actually hook it up to the formatting system
* qqq
* Document that link text messages need to be plain text

Change-Id: I4eceaf521315adab7429a8a73ffca70ebcddab86
---
M i18n/en.json
A includes/formatters/EchoPlainTextEmailFormatter.php
2 files changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/85/249885/1

diff --git a/i18n/en.json b/i18n/en.json
index ff0230f..f49b30b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -99,6 +99,7 @@
        "echo-email-body-default": "You have a new notification at 
{{SITENAME}}:\n\n$1",
        "echo-email-batch-body-default": "You have a new notification.",
        "echo-email-footer-default": "$2\n\nTo control which emails we send 
you, check your 
preferences:\n{{canonicalurl:{{#special:Preferences}}#mw-prefsection-echo}}\n\n$1",
+       "echo-email-plain-footer": "To control which emails we send you, check 
your preferences:",
        "echo-email-footer-default-html": "To control which emails we send you, 
<a href=\"$2\" style=\"text-decoration:none; color: #3868B0;\">check your 
preferences</a>.<br />\n$1",
        "echo-notification-alert": "{{PLURAL:$1|Alert ($1)|Alerts 
($1)|100=Alerts (99+)}}",
        "echo-notification-message": "{{PLURAL:$1|Message ($1)|Messages 
($1)|100=Messages (99+)}}",
diff --git a/includes/formatters/EchoPlainTextEmailFormatter.php 
b/includes/formatters/EchoPlainTextEmailFormatter.php
new file mode 100644
index 0000000..d18ff72
--- /dev/null
+++ b/includes/formatters/EchoPlainTextEmailFormatter.php
@@ -0,0 +1,33 @@
+<?php
+
+class EchoPlainTextEmailFormatter extends EchoEventFormatter {
+       protected function formatModel( EchoEventPresentationModel $model ) {
+               global $wgEchoEmailFooterAddress;
+
+               $text = strip_tags( $model->getHeaderMessage()->parse() );
+
+               // @todo body text
+
+               list( $primaryUrl, $primaryText ) = $model->getPrimaryLink();
+
+               $primaryUrl = wfExpandUrl( $primaryUrl, PROTO_CANONICAL );
+               $colon = wfMessage( 'colon-separator' )->inLanguage( 
$this->language )->escaped();
+               $text .= "\n\n$primaryText$colon <$primaryUrl>";
+
+               foreach ( $model->getSecondaryLinks() as $secondaryLink => 
$secondaryText ) {
+                       $text .= "\n\n$secondaryText$colon <$secondaryLink>";
+               }
+
+               // Footer
+               $footerMsg = wfMessage( 'echo-email-plain-footer' 
)->inLanguage( $this->language )->escaped();
+               $prefsUrl = SpecialPage::getTitleFor( 'Preferences', false, 
'mw-prefsection-echo' )
+                       ->getFullURL( '', false, PROTO_CANONICAL );
+               $text .= "\n\n--$footerMsg\n$prefsUrl";
+
+               if ( strlen( $wgEchoEmailFooterAddress ) ) {
+                       $text .= "\n\n$wgEchoEmailFooterAddress";
+               }
+
+               return $text;
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/249885
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4eceaf521315adab7429a8a73ffca70ebcddab86
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to