Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: 
  3: /*
  4:  * This file is part of SwiftMailer.
  5:  * (c) 2004-2009 Chris Corbyn
  6:  *
  7:  * For the full copyright and license information, please view the LICENSE
  8:  * file that was distributed with this source code.
  9:  */
 10: 
 11: /**
 12:  * A MIME part, in a multipart message.
 13:  *
 14:  * @package Swift
 15:  * @subpackage Mime
 16:  * @author Chris Corbyn
 17:  */
 18: class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
 19: {
 20:     /** The format parameter last specified by the user */
 21:     protected $_userFormat;
 22: 
 23:     /** The charset last specified by the user */
 24:     protected $_userCharset;
 25: 
 26:     /** The delsp parameter last specified by the user */
 27:     protected $_userDelSp;
 28: 
 29:     /** The nesting level of this MimePart */
 30:     private $_nestingLevel = self::LEVEL_ALTERNATIVE;
 31: 
 32:     /**
 33:      * Create a new MimePart with $headers, $encoder and $cache.
 34:      *
 35:      * @param Swift_Mime_HeaderSet      $headers
 36:      * @param Swift_Mime_ContentEncoder $encoder
 37:      * @param Swift_KeyCache            $cache
 38:      * @param Swift_Mime_Grammar        $grammar
 39:      * @param string                    $charset
 40:      */
 41:     public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $charset = null)
 42:     {
 43:         parent::__construct($headers, $encoder, $cache, $grammar);
 44:         $this->setContentType('text/plain');
 45:         if (!is_null($charset)) {
 46:             $this->setCharset($charset);
 47:         }
 48:     }
 49: 
 50:     /**
 51:      * Set the body of this entity, either as a string, or as an instance of
 52:      * {@link Swift_OutputByteStream}.
 53:      *
 54:      * @param mixed  $body
 55:      * @param string $contentType optional
 56:      * @param string $charset     optional
 57:      * @param Swift_Mime_MimePart
 58:      */
 59:     public function setBody($body, $contentType = null, $charset = null)
 60:     {
 61:         if (isset($charset)) {
 62:             $this->setCharset($charset);
 63:         }
 64:         $body = $this->_convertString($body);
 65: 
 66:         parent::setBody($body, $contentType);
 67: 
 68:         return $this;
 69:     }
 70: 
 71:     /**
 72:      * Get the character set of this entity.
 73:      *
 74:      * @return string
 75:      */
 76:     public function getCharset()
 77:     {
 78:         return $this->_getHeaderParameter('Content-Type', 'charset');
 79:     }
 80: 
 81:     /**
 82:      * Set the character set of this entity.
 83:      *
 84:      * @param string $charset
 85:      * @param Swift_Mime_MimePart
 86:      */
 87:     public function setCharset($charset)
 88:     {
 89:         $this->_setHeaderParameter('Content-Type', 'charset', $charset);
 90:         if ($charset !== $this->_userCharset) {
 91:             $this->_clearCache();
 92:         }
 93:         $this->_userCharset = $charset;
 94:         parent::charsetChanged($charset);
 95: 
 96:         return $this;
 97:     }
 98: 
 99:     /**
100:      * Get the format of this entity (i.e. flowed or fixed).
101:      *
102:      * @return string
103:      */
104:     public function getFormat()
105:     {
106:         return $this->_getHeaderParameter('Content-Type', 'format');
107:     }
108: 
109:     /**
110:      * Set the format of this entity (flowed or fixed).
111:      *
112:      * @param string $format
113:      * @param Swift_Mime_MimePart
114:      */
115:     public function setFormat($format)
116:     {
117:         $this->_setHeaderParameter('Content-Type', 'format', $format);
118:         $this->_userFormat = $format;
119: 
120:         return $this;
121:     }
122: 
123:     /**
124:      * Test if delsp is being used for this entity.
125:      *
126:      * @return boolean
127:      */
128:     public function getDelSp()
129:     {
130:         return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes')
131:             ? true
132:             : false;
133:     }
134: 
135:     /**
136:      * Turn delsp on or off for this entity.
137:      *
138:      * @param boolean $delsp
139:      * @param Swift_Mime_MimePart
140:      */
141:     public function setDelSp($delsp = true)
142:     {
143:         $this->_setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null);
144:         $this->_userDelSp = $delsp;
145: 
146:         return $this;
147:     }
148: 
149:     /**
150:      * Get the nesting level of this entity.
151:      *
152:      * @return int
153:      * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED
154:      */
155:     public function getNestingLevel()
156:     {
157:         return $this->_nestingLevel;
158:     }
159: 
160:     /**
161:      * Receive notification that the charset has changed on this document, or a
162:      * parent document.
163:      *
164:      * @param string $charset
165:      */
166:     public function charsetChanged($charset)
167:     {
168:         $this->setCharset($charset);
169:     }
170: 
171:     // -- Protected methods
172: 
173:     /** Fix the content-type and encoding of this entity */
174:     protected function _fixHeaders()
175:     {
176:         parent::_fixHeaders();
177:         if (count($this->getChildren())) {
178:             $this->_setHeaderParameter('Content-Type', 'charset', null);
179:             $this->_setHeaderParameter('Content-Type', 'format', null);
180:             $this->_setHeaderParameter('Content-Type', 'delsp', null);
181:         } else {
182:             $this->setCharset($this->_userCharset);
183:             $this->setFormat($this->_userFormat);
184:             $this->setDelSp($this->_userDelSp);
185:         }
186:     }
187: 
188:     /** Set the nesting level of this entity */
189:     protected function _setNestingLevel($level)
190:     {
191:         $this->_nestingLevel = $level;
192:     }
193: 
194:     /** Encode charset when charset is not utf-8 */
195:     protected function _convertString($string)
196:     {
197:         $charset = strtolower($this->getCharset());
198:         if (!in_array($charset, array('utf-8', 'iso-8859-1', ""))) {
199:             // mb_convert_encoding must be the first one to check, since iconv cannot convert some words.
200:             if (function_exists('mb_convert_encoding')) {
201:                 $string = mb_convert_encoding($string, $charset, 'utf-8');
202:             } elseif (function_exists('iconv')) {
203:                 $string = iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string);
204:             } else {
205:                     throw new Swift_SwiftException('No suitable convert encoding function (use UTF-8 as your harset or install the mbstring or iconv extension).');
206:             }
207: 
208:             return $string;
209:         }
210: 
211:         return $string;
212:     }
213: }
214: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen