X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplmailer.php;h=317dd64f05749e93ccf3561b8c0926ef123bdc5a;hb=b49f3f403fa8bb518c709c4091946c5d7f2aad6b;hp=9468fa31735ee0ca16847f4bcfe88541707d116c;hpb=c77fed7490e11faf397966d51f49f8e328ffd370;p=platal.git diff --git a/classes/plmailer.php b/classes/plmailer.php index 9468fa3..317dd64 100644 --- a/classes/plmailer.php +++ b/classes/plmailer.php @@ -28,11 +28,10 @@ class PlMail extends Smarty private $tpl; private $mailer = null; - function __construct(&$mailer, $tpl) + function __construct($tpl) { global $globals; $this->tpl = $tpl; - $this->mailer =& $mailer; $this->caching = false; $this->compile_check = true; @@ -50,11 +49,20 @@ class PlMail extends Smarty $this->register_function('add_header', Array($this, 'addHeader')); } + public static function &get(&$mailer, $tpl) + { + static $plmail; + if (!isset($plmail) || $plmail->tpl != $tpl) { + $plmail = new PlMail($tpl); + } + $plmail->mailer =& $mailer; + return $plmail; + } + public function run($html) { $this->assign('html_version', $html); $text = $this->fetch($this->tpl); - fix_encoding($text); return $text; } @@ -140,13 +148,13 @@ class PlMailer extends Mail_Mime { private $page = null; private $charset; - function __construct($tpl = null, $charset = "ISO-8859-15") + function __construct($tpl = null, $charset = "UTF-8") { $this->charset = $charset; $this->Mail_Mime("\n"); - $this->mail = @Mail::factory('sendmail', Array('sendmail_args' => '-oi')); + $this->mail = Mail::factory('sendmail', Array('sendmail_args' => '-oi')); if (!is_null($tpl)) { - $this->page = new PlMail($this, $tpl); + $this->page =& PlMail::get($this, $tpl); } } @@ -155,7 +163,7 @@ class PlMailer extends Mail_Mime { */ private function correct_emails($email) { - return preg_replace('!(^|, *)([^<"]+?) *(<[^>]*>)!', '\1"\2" \3', $email); + return preg_replace('!(^|, *)([^<"]+?) *(<[^>]*>)!u', '\1"\2" \3', $email); } public function addTo($email) @@ -292,4 +300,5 @@ class PlMailer extends Mail_Mime { } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>