getSubjectMessage()->parse();
$intro = $model->getHeaderMessage()->parse();
$bodyMsg = $model->getBodyMessage();
$summary = $bodyMsg ? $bodyMsg->parse() : '';
$actions = [];
$primaryLink = $model->getPrimaryLinkWithMarkAsRead();
if ( $primaryLink ) {
$actions[] = $this->renderLink( $primaryLink, self::PRIMARY_LINK_STYLE );
}
foreach ( array_filter( $model->getSecondaryLinks() ) as $secondaryLink ) {
$actions[] = $this->renderLink( $secondaryLink, self::SECONDARY_LINK_STYLE );
}
$iconUrl = wfExpandUrl(
EchoIcon::getRasterizedUrl( $model->getIconType(), $this->language->getCode() ),
PROTO_CANONICAL
);
$body = $this->renderBody(
$this->language,
$iconUrl,
$summary,
implode( " ", $actions ),
$intro,
$this->getFooter()
);
return [
'body' => $body,
'subject' => $subject,
];
}
private function renderBody( Language $lang, $emailIcon, $summary, $action, $intro, $footer ) {
$alignStart = $lang->alignStart();
$langCode = $lang->getHtmlCode();
$langDir = $lang->getDir();
$iconImgSrc = Sanitizer::encodeAttribute( $emailIcon );
global $wgCanonicalServer;
return <<< EOF
|
|
|
|
|
|
{$intro} |
|
|
|
|
|
|
|
|
{$footer}
|
|
|
|
EOF;
}
/**
* @return string
*/
public function getFooter() {
global $wgEchoEmailFooterAddress;
$preferenceLink = $this->renderLink(
[
'label' => $this->msg( 'echo-email-html-footer-preference-link-text', $this->user )->text(),
'url' => SpecialPage::getTitleFor( 'Preferences', false, 'mw-prefsection-echo' )->getFullURL( '', false, PROTO_CANONICAL ),
],
'text-decoration: none; color: #36C;'
);
$footer = $this->msg( 'echo-email-html-footer-with-link' )
->rawParams( $preferenceLink )
->params( $this->user )
->parse();
if ( $wgEchoEmailFooterAddress ) {
$footer .= '
' . $wgEchoEmailFooterAddress;
}
return $footer;
}
private function renderLink( $link, $style ) {
return Html::element(
'a',
[
'href' => wfExpandUrl( $link['url'], PROTO_CANONICAL ),
'style' => $style,
],
$link['label']
);
}
}