mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
67f926707e
* echo-email-plain-footer * echo-email-html-footer-preference-link-text * echo-email-html-footer-with-link Bug: T145439 Change-Id: I2d55a617910efa11effef1a469e6d845eebc5591
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
class EchoPlainTextEmailFormatter extends EchoEventFormatter {
|
|
protected function formatModel( EchoEventPresentationModel $model ) {
|
|
|
|
$subject = EchoDiscussionParser::htmlToText( $model->getSubjectMessage()->parse() );
|
|
|
|
$text = EchoDiscussionParser::htmlToText( $model->getHeaderMessage()->parse() );
|
|
|
|
$text .= "\n\n";
|
|
|
|
$bodyMsg = $model->getBodyMessage();
|
|
if ( $bodyMsg ) {
|
|
$text .= EchoDiscussionParser::htmlToText( $bodyMsg->parse() );
|
|
}
|
|
|
|
$primaryLink = $model->getPrimaryLinkWithMarkAsRead();
|
|
|
|
$primaryUrl = wfExpandUrl( $primaryLink['url'], PROTO_CANONICAL );
|
|
$colon = $this->msg( 'colon-separator' )->text();
|
|
$text .= "\n\n{$primaryLink['label']}$colon <$primaryUrl>";
|
|
|
|
foreach ( array_filter( $model->getSecondaryLinks() ) as $secondaryLink ) {
|
|
$url = wfExpandUrl( $secondaryLink['url'], PROTO_CANONICAL );
|
|
$text .= "\n\n{$secondaryLink['label']}$colon <$url>";
|
|
}
|
|
|
|
// Footer
|
|
$text .= "\n\n{$this->getFooter()}";
|
|
|
|
return [
|
|
'body' => $text,
|
|
'subject' => $subject,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getFooter() {
|
|
global $wgEchoEmailFooterAddress;
|
|
|
|
$footerMsg = $this->msg( 'echo-email-plain-footer', $this->user )->text();
|
|
$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;
|
|
}
|
|
}
|