VitaliyFilippov has uploaded a new change for review.

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

Change subject: Send HTML page change notification emails
......................................................................

Send HTML page change notification emails

Bug: T15303
Change-Id: I88100a5e0795f40482a1e78f9c1774c75e2a2c9a
---
M includes/mail/EmailNotification.php
M languages/i18n/en.json
M languages/i18n/ru.json
3 files changed, 42 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/249155/1

diff --git a/includes/mail/EmailNotification.php 
b/includes/mail/EmailNotification.php
index 044bb53..29a19be 100644
--- a/includes/mail/EmailNotification.php
+++ b/includes/mail/EmailNotification.php
@@ -336,7 +336,7 @@
                # named variables when composing your notification emails while
                # simply editing the Meta pages
 
-               $keys = array();
+               $keys = $keysHtml = array();
                $postTransformKeys = array();
                $pageTitleUrl = $this->title->getCanonicalURL();
                $pageTitle = $this->title->getPrefixedText();
@@ -346,6 +346,9 @@
                        $keys['$NEWPAGE'] = "\n\n" . wfMessage( 
'enotif_lastdiff',
                                        $this->title->getCanonicalURL( array( 
'diff' => 'next', 'oldid' => $this->oldid ) ) )
                                        ->inContentLanguage()->text();
+                       $keysHtml['$NEWPAGE'] = wfMessage( 
'enotif_lastdiff_html',
+                                       $this->title->getCanonicalURL( array( 
'diff' => 'next', 'oldid' => $this->oldid ) ) )
+                                       ->inContentLanguage()->plain();
 
                        if ( !$wgEnotifImpersonal ) {
                                // For personal mail, also show a link to the 
diff of all changes
@@ -353,6 +356,9 @@
                                $keys['$NEWPAGE'] .= "\n\n" . wfMessage( 
'enotif_lastvisited',
                                                $this->title->getCanonicalURL( 
array( 'diff' => '0', 'oldid' => $this->oldid ) ) )
                                                ->inContentLanguage()->text();
+                               $keysHtml['$NEWPAGE'] .= wfMessage( 
'enotif_lastvisited_html',
+                                               $this->title->getCanonicalURL( 
array( 'diff' => '0', 'oldid' => $this->oldid ) ) )
+                                               ->inContentLanguage()->plain();
                        }
                        $keys['$OLDID'] = $this->oldid;
                        // Deprecated since MediaWiki 1.21, not used by 
default. Kept for backwards-compatibility.
@@ -390,7 +396,7 @@
                );
 
                # Replace this after transforming the message, bug 35019
-               $postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - 
' : $this->summary;
+               $postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? 
wfMessage( 'enotif_empty_summary' )->text() : $this->summary;
 
                // Now build message's subject and body
 
@@ -406,11 +412,25 @@
                $keys['$PAGEINTRO'] = wfMessage( 'enotif_body_intro_' . 
$this->pageStatus )
                        ->inContentLanguage()->params( $pageTitle, 
$keys['$PAGEEDITOR'], $pageTitleUrl )
                        ->text();
+               $keysHtml['$PAGEINTRO'] = wfMessage( 'enotif_body_intro_' . 
$this->pageStatus )
+                       ->inContentLanguage()->params( htmlspecialchars( 
$pageTitle ), htmlspecialchars( $keys['$PAGEEDITOR'] ),
+                               '<a 
href="'.$pageTitleUrl.'">'.htmlspecialchars( urldecode( 
$this->title->getCanonicalUrl() ) ).'</a>' )
+                       ->plain();
 
                $body = wfMessage( 'enotif_body' 
)->inContentLanguage()->plain();
                $body = strtr( $body, $keys );
                $body = MessageCache::singleton()->transform( $body, false, 
null, $this->title );
                $this->body = wordwrap( strtr( $body, $postTransformKeys ), 72 
);
+
+               foreach ( $keys as $k => $v ) {
+                       if ( !isset( $keysHtml[$k] ) ) {
+                               $keysHtml[$k] = htmlspecialchars( $v );
+                       }
+               }
+               $bodyHtml = wfMessage( 'enotif_body_html' 
)->inContentLanguage()->plain();
+               $bodyHtml = strtr( $bodyHtml, $keysHtml );
+               $bodyHtml = MessageCache::singleton()->transform( $bodyHtml, 
false, null, $this->title );
+               $this->bodyHtml = strtr( $bodyHtml, $postTransformKeys );
 
                # Reveal the page editor's address as REPLY-TO address only if
                # the user has not opted-out and the option is enabled at the
@@ -487,15 +507,19 @@
                # $PAGEEDITDATE is the time and date of the page change
                # expressed in terms of individual local time of the 
notification
                # recipient, i.e. watching user
-               $body = str_replace(
-                       array( '$WATCHINGUSERNAME',
-                               '$PAGEEDITDATE',
-                               '$PAGEEDITTIME' ),
-                       array( $wgEnotifUseRealName && 
$watchingUser->getRealName() !== ''
+               $repl = array(
+                       '$WATCHINGUSERNAME' => $wgEnotifUseRealName && 
$watchingUser->getRealName() !== ''
                                ? $watchingUser->getRealName() : 
$watchingUser->getName(),
-                               $wgContLang->userDate( $this->timestamp, 
$watchingUser ),
-                               $wgContLang->userTime( $this->timestamp, 
$watchingUser ) ),
-                       $this->body );
+                       '$PAGEEDITDATE' => $wgContLang->userDate( 
$this->timestamp, $watchingUser ),
+                       '$PAGEEDITTIME' => $wgContLang->userTime( 
$this->timestamp, $watchingUser ),
+               );
+               $body = strtr( $this->body, $repl );
+               $repl['$WATCHINGUSERNAME'] = htmlspecialchars( 
$repl['$WATCHINGUSERNAME'] );
+               $bodyHtml = strtr( $this->bodyHtml, $repl );
+               $body = array(
+                       'text' => $body,
+                       'html' => $bodyHtml,
+               );
 
                $headers = array();
                if ( $source === self::WATCHLIST ) {
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index c97b08e..110c694 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1942,8 +1942,12 @@
        "enotif_body_intro_changed": "The {{SITENAME}} page $1 has been 
{{GENDER:$2|changed}} on $PAGEEDITDATE by $2, see $3 for the current revision.",
        "enotif_lastvisited": "See $1 for all changes since your last visit.",
        "enotif_lastdiff": "See $1 to view this change.",
+       "enotif_lastvisited_html": ", <a href='$1'>Show all changes since your 
last visit.</a>",
+       "enotif_lastdiff_html": "<a href='$1'>Show this change</a>",
+       "enotif_empty_summary": "empty summary",
        "enotif_anon_editor": "anonymous user $1",
        "enotif_body": "Dear $WATCHINGUSERNAME,\n\n$PAGEINTRO 
$NEWPAGE\n\nEditor's summary: $PAGESUMMARY $PAGEMINOREDIT\n\nContact the 
editor:\nmail: $PAGEEDITOR_EMAIL\nwiki: $PAGEEDITOR_WIKI\n\nThere will be no 
other notifications in case of further activity unless you visit this page 
while logged in. You could also reset the notification flags for all your 
watched pages on your watchlist.\n\nYour friendly {{SITENAME}} notification 
system\n\n--\nTo change your email notification settings, 
visit\n{{canonicalurl:{{#special:Preferences}}}}\n\nTo change your watchlist 
settings, visit\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nTo delete the 
page from your watchlist, visit\n$UNWATCHURL\n\nFeedback and further 
assistance:\n$HELPPAGE",
+       "enotif_body_html": "<p>Dear 
<b>$WATCHINGUSERNAME</b>,</p>\n<p>$PAGEINTRO</p>\n$NEWPAGE\n<p>Editor's 
summary: <b>$PAGESUMMARY $PAGEMINOREDIT</b><br>Contact the editor: <a 
href='$PAGEEDITOR_EMAIL'>mail</a>, <a 
href='$PAGEEDITOR_WIKI'>wiki</a>.</p>\n<p>There will be no other notifications 
in case of further activity unless you visit this page while logged in. You 
could also reset the notification flags for all your watched pages on your 
watchlist.</p>\n<p style='font-size: 12px'><i>\n-- \n<br><b>Your friendly 
{{SITENAME}} notification system</b>\n<br>To change your email notification 
settings, visit <a 
href='{{canonicalurl:{{#special:Preferences}}}}'>Special:Preferences</a>\n<br>To
 change your watchlist settings, visit <a 
href='{{canonicalurl:{{#special:EditWatchlist}}}}'>Special:EditWatchlist</a>\n<br><a
 href='$UNWATCHURL'>Delete this page from your watchlist</a>\n<br><a 
href='$HELPPAGE'>Feedback and further assistance</a>\n</i></p>",
        "created": "created",
        "changed": "changed",
        "deletepage": "Delete page",
diff --git a/languages/i18n/ru.json b/languages/i18n/ru.json
index d8c2cb1..204be4e 100644
--- a/languages/i18n/ru.json
+++ b/languages/i18n/ru.json
@@ -1894,8 +1894,12 @@
        "enotif_body_intro_changed": "$PAGEEDITDATE 
{{gender:$2|участником|участницей}} $2 была изменена страница проекта 
«{{SITENAME}}» с именем «$1», см. текущую версию по ссылке: $3",
        "enotif_lastvisited": "См. $1 для просмотра всех изменений, 
произошедших с вашего последнего посещения.",
        "enotif_lastdiff": "См. $1 для ознакомления с изменением.",
+       "enotif_lastvisited_html": ", <a href='$1'>Просмотреть все изменения, 
произошедшие с вашего последнего посещения</a>",
+       "enotif_lastdiff_html": "<a href='$1'>Просмотреть данное изменение</a>",
+       "enotif_empty_summary": "нет описания",
        "enotif_anon_editor": "анонимный участник $1",
        "enotif_body": "Здравствуйте, $WATCHINGUSERNAME!\n\n$PAGEINTRO 
$NEWPAGE\n\nКраткое описание изменения: $PAGESUMMARY 
$PAGEMINOREDIT\n\nОбратиться к изменившему:\nэл. почта: 
$PAGEEDITOR_EMAIL\nвики: $PAGEEDITOR_WIKI\n\nЕсли вы не зайдёте на эту страницу 
под своей учётной записью, в случае её дальнейших изменений уведомлений больше 
не будет. Вы можете также отключить опцию уведомления для всех страниц в вашем 
списке наблюдения.\n\nСистема оповещения 
{{grammar:genitive|{{SITENAME}}}}\n\n--\nИзменение настройки 
уведомлений\n{{canonicalurl:{{#special:Preferences}}}}\n\nИзменение настройки 
вашего списка 
наблюдения\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nУдалить страницы из 
вашего списка наблюдения\n$UNWATCHURL\n\nОбратная связь и помощь\n$HELPPAGE",
+       "enotif_body_html": "<p>Здравствуйте, 
<b>$WATCHINGUSERNAME</b>!</p>\n<p>$PAGEINTRO</p>\n$NEWPAGE\n<p>Краткое описание 
изменения: <b>$PAGESUMMARY $PAGEMINOREDIT</b><br>\nОбратиться к изменившему: <a 
href='$PAGEEDITOR_EMAIL'>эл. почта</a>, <a 
href='$PAGEEDITOR_WIKI'>вики</a></p>\n<p>Если вы не зайдёте на эту страницу под 
своей учётной записью, в случае её дальнейших изменений уведомлений больше не 
будет. Вы можете также отключить опцию уведомления для всех страниц в вашем 
списке наблюдения.</p>\n<p style='font-size: 12px'><i>\n-- \n<br>Система 
оповещения {{grammar:genitive|{{SITENAME}}}}\n<br><a 
href='{{canonicalurl:{{#special:Preferences}}}}'>Изменение настройки 
уведомлений</a>\n<br><a 
href='{{canonicalurl:{{#special:EditWatchlist}}}}'>Изменение настройки вашего 
списка наблюдения</a>\n<br><a href='$UNWATCHURL'>Удалить данную страницу из 
вашего списка наблюдения</a>\n<br><a href='$HELPPAGE'>Обратная связь и 
помощь</a>\n</i></p>",
        "created": "создана",
        "changed": "изменена",
        "deletepage": "Удалить страницу",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I88100a5e0795f40482a1e78f9c1774c75e2a2c9a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: VitaliyFilippov <vita...@yourcmc.ru>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to