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:  * An attachment, in a multipart message.
 13:  * @package Swift
 14:  * @subpackage Mime
 15:  * @author Chris Corbyn
 16:  */
 17: class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
 18: {
 19:     /** Recognized MIME types */
 20:     private $_mimeTypes = array();
 21: 
 22:     /**
 23:      * Create a new Attachment with $headers, $encoder and $cache.
 24:      * @param Swift_Mime_HeaderSet      $headers
 25:      * @param Swift_Mime_ContentEncoder $encoder
 26:      * @param Swift_KeyCache            $cache
 27:      * @param Swift_Mime_Grammar        $grammar
 28:      * @param array                     $mimeTypes optional
 29:      */
 30:     public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $mimeTypes = array())
 31:     {
 32:         parent::__construct($headers, $encoder, $cache, $grammar);
 33:         $this->setDisposition('attachment');
 34:         $this->setContentType('application/octet-stream');
 35:         $this->_mimeTypes = $mimeTypes;
 36:     }
 37: 
 38:     /**
 39:      * Get the nesting level used for this attachment.
 40:      * Always returns {@link LEVEL_MIXED}.
 41:      * @return int
 42:      */
 43:     public function getNestingLevel()
 44:     {
 45:         return self::LEVEL_MIXED;
 46:     }
 47: 
 48:     /**
 49:      * Get the Content-Disposition of this attachment.
 50:      * By default attachments have a disposition of "attachment".
 51:      * @return string
 52:      */
 53:     public function getDisposition()
 54:     {
 55:         return $this->_getHeaderFieldModel('Content-Disposition');
 56:     }
 57: 
 58:     /**
 59:      * Set the Content-Disposition of this attachment.
 60:      * @param  string                $disposition
 61:      * @return Swift_Mime_Attachment
 62:      */
 63:     public function setDisposition($disposition)
 64:     {
 65:         if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) {
 66:             $this->getHeaders()->addParameterizedHeader(
 67:                 'Content-Disposition', $disposition
 68:                 );
 69:         }
 70: 
 71:         return $this;
 72:     }
 73: 
 74:     /**
 75:      * Get the filename of this attachment when downloaded.
 76:      * @return string
 77:      */
 78:     public function getFilename()
 79:     {
 80:         return $this->_getHeaderParameter('Content-Disposition', 'filename');
 81:     }
 82: 
 83:     /**
 84:      * Set the filename of this attachment.
 85:      * @param  string                $filename
 86:      * @return Swift_Mime_Attachment
 87:      */
 88:     public function setFilename($filename)
 89:     {
 90:         $this->_setHeaderParameter('Content-Disposition', 'filename', $filename);
 91:         $this->_setHeaderParameter('Content-Type', 'name', $filename);
 92: 
 93:         return $this;
 94:     }
 95: 
 96:     /**
 97:      * Get the file size of this attachment.
 98:      * @return int
 99:      */
100:     public function getSize()
101:     {
102:         return $this->_getHeaderParameter('Content-Disposition', 'size');
103:     }
104: 
105:     /**
106:      * Set the file size of this attachment.
107:      * @param  int                   $size
108:      * @return Swift_Mime_Attachment
109:      */
110:     public function setSize($size)
111:     {
112:         $this->_setHeaderParameter('Content-Disposition', 'size', $size);
113: 
114:         return $this;
115:     }
116: 
117:     /**
118:      * Set the file that this attachment is for.
119:      * @param  Swift_FileStream      $file
120:      * @param  string                $contentType optional
121:      * @return Swift_Mime_Attachment
122:      */
123:     public function setFile(Swift_FileStream $file, $contentType = null)
124:     {
125:         $this->setFilename(basename($file->getPath()));
126:         $this->setBody($file, $contentType);
127:         if (!isset($contentType)) {
128:             $extension = strtolower(substr(
129:                 $file->getPath(), strrpos($file->getPath(), '.') + 1
130:                 ));
131: 
132:             if (array_key_exists($extension, $this->_mimeTypes)) {
133:                 $this->setContentType($this->_mimeTypes[$extension]);
134:             }
135:         }
136: 
137:         return $this;
138:     }
139: }
140: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen