From f5b47d2565f065ffe856dff4a0b84d789949ce6b Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Sat, 2 Feb 2019 21:16:15 +0100 Subject: [PATCH] Twigify EMail-template --- lib/SimpleSAML/XHTML/EMail.php | 30 +++++------------------------- templates/errorreport_mail.twig | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 templates/errorreport_mail.twig diff --git a/lib/SimpleSAML/XHTML/EMail.php b/lib/SimpleSAML/XHTML/EMail.php index a9e239029..fc5441ef4 100644 --- a/lib/SimpleSAML/XHTML/EMail.php +++ b/lib/SimpleSAML/XHTML/EMail.php @@ -5,7 +5,7 @@ namespace SimpleSAML\XHTML; /** * A minimalistic Emailer class. Creates and sends HTML emails. * - * @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> + * @author Andreas Ă…kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ @@ -48,30 +48,10 @@ class EMail */ private function getHTML($body) { - return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - <title>SimpleSAMLphp Email report</title> - <style type="text/css"> -pre, div.box { - margin: .4em 2em .4em 1em; - padding: 4px; - -} -pre { - background: #eee; - border: 1px solid #aaa; -} - </style> -</head> -<body> -<div class="container" style="background: #fafafa; border: 1px solid #eee; margin: 2em; padding: .6em;"> -'.$body.' -</div> -</body> -</html>'; + $config = \SimpleSAML\Configuration::getInstance(); + $t = new \SimpleSAML\XHTML\Template($config, 'errorreport_mail.twig'); + $twig = $t->getTwig(); + return $twig->render('errorreport_mail.twig', ['body' => $body]); } diff --git a/templates/errorreport_mail.twig b/templates/errorreport_mail.twig new file mode 100644 index 000000000..e549912e2 --- /dev/null +++ b/templates/errorreport_mail.twig @@ -0,0 +1,30 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <title>SimpleSAMLphp Email report</title> + <style type="text/css"> +pre, div.box { + margin: .4em 2em .4em 1em; + padding: 4px; + +} +pre { + background: #eee; + border: 1px solid #aaa; +} +div.container { + background: #fafafa; + border: 1px solid #eee; + margin: 2em; + padding: .6em; +} + </style> +</head> +<body> +<div class="container"> +{{ body }} +</div> +</body> +</html> -- GitLab