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:  * Creates MIME headers.
 13:  * @package Swift
 14:  * @subpackage Mime
 15:  * @author Chris Corbyn
 16:  */
 17: class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
 18: {
 19:     /** The HeaderEncoder used by these headers */
 20:     private $_encoder;
 21: 
 22:     /** The Encoder used by parameters */
 23:     private $_paramEncoder;
 24: 
 25:     /** The Grammar */
 26:     private $_grammar;
 27: 
 28:     /** The charset of created Headers */
 29:     private $_charset;
 30: 
 31:     /**
 32:      * Creates a new SimpleHeaderFactory using $encoder and $paramEncoder.
 33:      * @param Swift_Mime_HeaderEncoder $encoder
 34:      * @param Swift_Encoder            $paramEncoder
 35:      * @param Swift_Mime_Grammar       $grammar
 36:      * @param string                   $charset
 37:      */
 38:     public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, Swift_Mime_Grammar $grammar, $charset = null)
 39:     {
 40:         $this->_encoder = $encoder;
 41:         $this->_paramEncoder = $paramEncoder;
 42:         $this->_grammar = $grammar;
 43:         $this->_charset = $charset;
 44:     }
 45: 
 46:     /**
 47:      * Create a new Mailbox Header with a list of $addresses.
 48:      * @param  string            $name
 49:      * @param  array|string      $addresses
 50:      * @return Swift_Mime_Header
 51:      */
 52:     public function createMailboxHeader($name, $addresses = null)
 53:     {
 54:         $header = new Swift_Mime_Headers_MailboxHeader($name, $this->_encoder, $this->_grammar);
 55:         if (isset($addresses)) {
 56:             $header->setFieldBodyModel($addresses);
 57:         }
 58:         $this->_setHeaderCharset($header);
 59: 
 60:         return $header;
 61:     }
 62: 
 63:     /**
 64:      * Create a new Date header using $timestamp (UNIX time).
 65:      * @param  string            $name
 66:      * @param  int               $timestamp
 67:      * @return Swift_Mime_Header
 68:      */
 69:     public function createDateHeader($name, $timestamp = null)
 70:     {
 71:         $header = new Swift_Mime_Headers_DateHeader($name, $this->_grammar);
 72:         if (isset($timestamp)) {
 73:             $header->setFieldBodyModel($timestamp);
 74:         }
 75:         $this->_setHeaderCharset($header);
 76: 
 77:         return $header;
 78:     }
 79: 
 80:     /**
 81:      * Create a new basic text header with $name and $value.
 82:      * @param  string            $name
 83:      * @param  string            $value
 84:      * @return Swift_Mime_Header
 85:      */
 86:     public function createTextHeader($name, $value = null)
 87:     {
 88:         $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->_encoder, $this->_grammar);
 89:         if (isset($value)) {
 90:             $header->setFieldBodyModel($value);
 91:         }
 92:         $this->_setHeaderCharset($header);
 93: 
 94:         return $header;
 95:     }
 96: 
 97:     /**
 98:      * Create a new ParameterizedHeader with $name, $value and $params.
 99:      * @param  string                         $name
100:      * @param  string                         $value
101:      * @param  array                          $params
102:      * @return Swift_Mime_ParameterizedHeader
103:      */
104:     public function createParameterizedHeader($name, $value = null,
105:         $params = array())
106:     {
107:         $header = new Swift_Mime_Headers_ParameterizedHeader($name,
108:             $this->_encoder, (strtolower($name) == 'content-disposition')
109:                 ? $this->_paramEncoder
110:                 : null,
111:                 $this->_grammar
112:             );
113:         if (isset($value)) {
114:             $header->setFieldBodyModel($value);
115:         }
116:         foreach ($params as $k => $v) {
117:             $header->setParameter($k, $v);
118:         }
119:         $this->_setHeaderCharset($header);
120: 
121:         return $header;
122:     }
123: 
124:     /**
125:      * Create a new ID header for Message-ID or Content-ID.
126:      * @param  string            $name
127:      * @param  string|array      $ids
128:      * @return Swift_Mime_Header
129:      */
130:     public function createIdHeader($name, $ids = null)
131:     {
132:         $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->_grammar);
133:         if (isset($ids)) {
134:             $header->setFieldBodyModel($ids);
135:         }
136:         $this->_setHeaderCharset($header);
137: 
138:         return $header;
139:     }
140: 
141:     /**
142:      * Create a new Path header with an address (path) in it.
143:      * @param  string            $name
144:      * @param  string            $path
145:      * @return Swift_Mime_Header
146:      */
147:     public function createPathHeader($name, $path = null)
148:     {
149:         $header = new Swift_Mime_Headers_PathHeader($name, $this->_grammar);
150:         if (isset($path)) {
151:             $header->setFieldBodyModel($path);
152:         }
153:         $this->_setHeaderCharset($header);
154: 
155:         return $header;
156:     }
157: 
158:     /**
159:      * Notify this observer that the entity's charset has changed.
160:      * @param string $charset
161:      */
162:     public function charsetChanged($charset)
163:     {
164:         $this->_charset = $charset;
165:         $this->_encoder->charsetChanged($charset);
166:         $this->_paramEncoder->charsetChanged($charset);
167:     }
168: 
169:     // -- Private methods
170: 
171:     /** Apply the charset to the Header */
172:     private function _setHeaderCharset(Swift_Mime_Header $header)
173:     {
174:         if (isset($this->_charset)) {
175:             $header->setCharset($this->_charset);
176:         }
177:     }
178: }
179: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen