r1608 - in trunk: doc main/Flow main/Utils

From: <aelAT@ATshadanakar.org>
Date: Mon, 8 May 2006 16:38:45 +0400 (MSD)

Author: ael
Date: 2006-05-08 16:38:45 +0400 (Mon, 08 May 2006)
New Revision: 1608

Modified:
   trunk/doc/ChangeLog
   trunk/main/Flow/SimplePhpView.class.php
   trunk/main/Utils/Mail.class.php
Log:
main/Utils/Mail.class.php: encoding interface simplified
main/Flow/SimplePhpView.class.php: toString function added

Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog 2006-05-07 15:50:18 UTC (rev 1607)
+++ trunk/doc/ChangeLog 2006-05-08 12:38:45 UTC (rev 1608)
@@ -1,5 +1,11 @@
 # $Id$
 
+2006-05-08 Anton E. Lebedevich
+
+ * main/Utils/Mail.class.php: encoding interface simplified
+
+ * main/Flow/SimplePhpView.class.php: toString function added
+
 2006-05-05 Sergey S. Sergeev
 
         * main/Containers/StorableContainer.class.php: bugfixed call to undefined

Modified: trunk/main/Flow/SimplePhpView.class.php
===================================================================
--- trunk/main/Flow/SimplePhpView.class.php 2006-05-07 15:50:18 UTC (rev 1607)
+++ trunk/main/Flow/SimplePhpView.class.php 2006-05-08 12:38:45 UTC (rev 1608)
@@ -35,5 +35,12 @@
                         
                         require $this->templatePath;
                 }
+
+ public function toString($model = null)
+ {
+ ob_start();
+ $this->render($model);
+ return ob_get_clean();
+ }
         }
 ?>
\ No newline at end of file

Modified: trunk/main/Utils/Mail.class.php
===================================================================
--- trunk/main/Utils/Mail.class.php 2006-05-07 15:50:18 UTC (rev 1607)
+++ trunk/main/Utils/Mail.class.php 2006-05-08 12:38:45 UTC (rev 1608)
@@ -19,8 +19,7 @@
                 private $text = null;
                 private $subject = null;
                 private $from = null;
- private $siteEncoding = null;
- private $mailEncoding = null;
+ private $encoding = null;
                 
                 public static function create()
                 {
@@ -31,38 +30,52 @@
                 {
                         if (empty($this->to))
                                 throw new WrongArgumentException("mail to: is not specified");
+
+ $siteEncoding = mb_get_info('internal_encoding');
+
+ if (! $this->encoding
+ || $this->encoding == $siteEncoding
+ ) {
+ $encoding = $siteEncoding;
+ $to = $this->to;
+ $from = $this->from;
+ $subject =
+ "=?".$encoding."?B?"
+ .base64_encode($this->subject)
+ ."?=";
+ $body = $this->text;
+
+ } else {
+ $encoding = $this->encoding;
+ $to = mb_convert_encoding($this->to, $encoding);
+ $from = mb_convert_encoding($this->from, $encoding);
+
+ $subject =
+ "=?".$encoding."?B?"
+ .base64_encode(
+ iconv(
+ $siteEncoding,
+ $encoding.'//TRANSLIT',
+ $this->subject
+ )
+ )."?=";
+
+ $body = iconv(
+ $siteEncoding,
+ $encoding.'//TRANSLIT',
+ $this->text
+ );
+ }
 
- $this->to = mb_convert_encoding($this->to, $this->mailEncoding);
- $this->from = mb_convert_encoding($this->from, $this->mailEncoding);
-
- $to = $this->to;
-
- $subject =
- "=?".$this->mailEncoding."?B?"
- .base64_encode(
- iconv(
- $this->siteEncoding,
- $this->mailEncoding
- .'//TRANSLIT',
- $this->subject
- )
- )."?=";
-
                         $headers = '';
                         if (!empty($this->from)) {
                                 $headers .= "From: ".$this->from."\n";
                                 $headers .= "Return-Path: ".$this->from."\n";
                         }
                         $headers .= "MIME-Version: 1.0\n";
- $headers .= "Content-type: text/html; charset=".$this->mailEncoding."\n";
+ $headers .= "Content-type: text/html; charset=".$encoding."\n";
                         $headers .= "Content-Transfer-Encoding: 8bit\n";
                         $headers .= "Date: ".date('r')."\n";
-
- $body = iconv(
- $this->siteEncoding,
- $this->mailEncoding.'//TRANSLIT',
- $this->text
- );
 
                         if (!mail($to, $subject, $body, $headers))
                                 throw new MailNotSentException();
@@ -92,16 +105,10 @@
                         return $this;
                 }
                 
- public function setSiteEncoding($siteEncoding)
+ public function setEncoding($encoding)
                 {
- $this->siteEncoding = $siteEncoding;
+ $this->encoding = $encoding;
                         return $this;
                 }
-
- public function setMailEncoding($mailEncoding)
- {
- $this->mailEncoding = $mailEncoding;
- return $this;
- }
         }
 ?>
\ No newline at end of file
Received on Mon May 08 2006 - 16:38:45 MSD

This archive was generated by hypermail 2.2.0 : Sat Oct 27 2007 - 20:04:27 MSD