2015-10-29 21:14:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EchoPlainTextEmailFormatter extends EchoEventFormatter {
|
|
|
|
protected function formatModel( EchoEventPresentationModel $model ) {
|
2017-07-07 23:55:51 +00:00
|
|
|
$subject = Sanitizer::stripAllTags( $model->getSubjectMessage()->parse() );
|
2015-10-29 21:14:35 +00:00
|
|
|
|
2017-07-07 23:55:51 +00:00
|
|
|
$text = Sanitizer::stripAllTags( $model->getHeaderMessage()->parse() );
|
2015-10-29 21:14:35 +00:00
|
|
|
|
|
|
|
$text .= "\n\n";
|
|
|
|
|
|
|
|
$bodyMsg = $model->getBodyMessage();
|
|
|
|
if ( $bodyMsg ) {
|
2017-07-07 23:55:51 +00:00
|
|
|
$text .= Sanitizer::stripAllTags( $bodyMsg->parse() );
|
2015-10-29 21:14:35 +00:00
|
|
|
}
|
|
|
|
|
2016-06-09 22:15:22 +00:00
|
|
|
$primaryLink = $model->getPrimaryLinkWithMarkAsRead();
|
2015-10-29 21:14:35 +00:00
|
|
|
|
|
|
|
$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()}";
|
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
return [
|
2015-10-29 21:14:35 +00:00
|
|
|
'body' => $text,
|
|
|
|
'subject' => $subject,
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2015-10-29 21:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getFooter() {
|
|
|
|
global $wgEchoEmailFooterAddress;
|
|
|
|
|
2016-12-28 16:43:40 +00:00
|
|
|
$footerMsg = $this->msg( 'echo-email-plain-footer', $this->user )->text();
|
2015-10-29 21:14:35 +00:00
|
|
|
$prefsUrl = SpecialPage::getTitleFor( 'Preferences', false, 'mw-prefsection-echo' )
|
|
|
|
->getFullURL( '', false, PROTO_CANONICAL );
|
|
|
|
$text = "--\n\n$footerMsg\n$prefsUrl";
|
|
|
|
|
2019-02-19 08:54:56 +00:00
|
|
|
if ( $wgEchoEmailFooterAddress !== '' ) {
|
2015-10-29 21:14:35 +00:00
|
|
|
$text .= "\n\n$wgEchoEmailFooterAddress";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
}
|