getSubjectMessage()->parse();
$intro = $model->getHeaderMessage()->parse();
$bodyMsg = $model->getBodyMessage();
$summary = $bodyMsg ? $bodyMsg->parse() : '';
$actions = array();
$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(
EchoNotificationFormatter::getIconUrl( $model->getIconType(), $this->language->getDir() ),
PROTO_CANONICAL
);
$body = $this->renderBody(
$this->language,
$iconUrl,
$summary,
implode( " ", $actions ),
$intro,
$this->getFooter()
);
return array(
'body' => $body,
'subject' => $subject,
);
}
private function renderBody( Language $lang, $emailIcon, $summary, $action, $intro, $footer ) {
$alignStart = $lang->alignStart();
$langCode = $lang->getCode();
$langDir = $lang->getDir();
$iconImgSrc = Sanitizer::encodeAttribute( $emailIcon );
return <<< EOF
|
|
|
|
|
|
{$intro} |
|
|
|
|
|
|
|
|
{$footer}
|
|
|
|
EOF;
}
/**
* @return string
*/
public function getFooter() {
global $wgEchoEmailFooterAddress;
$preferenceLink = $this->renderLink(
array(
'label' => $this->msg( 'echo-email-html-footer-preference-link-text' )->text(),
'url' => SpecialPage::getTitleFor( 'Preferences', false, 'mw-prefsection-echo' )->getFullURL( '', false, PROTO_CANONICAL ),
),
'text-decoration: none; color: #3868B0;'
);
$footer = $this->msg( 'echo-email-html-footer-with-link' )
->rawParams( $preferenceLink )
->parse();
if ( $wgEchoEmailFooterAddress ) {
$footer .= '
' . $wgEchoEmailFooterAddress;
}
return $footer;
}
private function renderLink( $link, $style ) {
return Html::element(
'a',
array(
'href' => wfExpandUrl( $link['url'], PROTO_CANONICAL ),
'style' => $style,
),
$link['label']
);
}
}