/user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php
https://gitlab.com/3dplex/3d-plex-main-site · PHP · 179 lines · 70 code · 16 blank · 93 comment · 3 complexity · 37137ef7f554b26a94a8fd14a986057d MD5 · raw file
- <?php
- /*
- * This file is part of SwiftMailer.
- * (c) 2004-2009 Chris Corbyn
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- /**
- * An attachment, in a multipart message.
- *
- <<<<<<< HEAD
- * @package Swift
- * @subpackage Mime
- * @author Chris Corbyn
- =======
- * @author Chris Corbyn
- >>>>>>> update grav cms
- */
- class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
- {
- /** Recognized MIME types */
- private $_mimeTypes = array();
- /**
- * Create a new Attachment with $headers, $encoder and $cache.
- *
- * @param Swift_Mime_HeaderSet $headers
- * @param Swift_Mime_ContentEncoder $encoder
- * @param Swift_KeyCache $cache
- * @param Swift_Mime_Grammar $grammar
- * @param array $mimeTypes optional
- */
- public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $mimeTypes = array())
- {
- parent::__construct($headers, $encoder, $cache, $grammar);
- $this->setDisposition('attachment');
- $this->setContentType('application/octet-stream');
- $this->_mimeTypes = $mimeTypes;
- }
- /**
- * Get the nesting level used for this attachment.
- *
- * Always returns {@link LEVEL_MIXED}.
- *
- <<<<<<< HEAD
- * @return integer
- =======
- * @return int
- >>>>>>> update grav cms
- */
- public function getNestingLevel()
- {
- return self::LEVEL_MIXED;
- }
- /**
- * Get the Content-Disposition of this attachment.
- *
- * By default attachments have a disposition of "attachment".
- *
- * @return string
- */
- public function getDisposition()
- {
- return $this->_getHeaderFieldModel('Content-Disposition');
- }
- /**
- * Set the Content-Disposition of this attachment.
- *
- * @param string $disposition
- *
- * @return Swift_Mime_Attachment
- */
- public function setDisposition($disposition)
- {
- if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) {
- <<<<<<< HEAD
- $this->getHeaders()->addParameterizedHeader(
- 'Content-Disposition', $disposition
- );
- =======
- $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition);
- >>>>>>> update grav cms
- }
- return $this;
- }
- /**
- * Get the filename of this attachment when downloaded.
- *
- * @return string
- */
- public function getFilename()
- {
- return $this->_getHeaderParameter('Content-Disposition', 'filename');
- }
- /**
- * Set the filename of this attachment.
- *
- * @param string $filename
- *
- * @return Swift_Mime_Attachment
- */
- public function setFilename($filename)
- {
- $this->_setHeaderParameter('Content-Disposition', 'filename', $filename);
- $this->_setHeaderParameter('Content-Type', 'name', $filename);
- return $this;
- }
- /**
- * Get the file size of this attachment.
- *
- <<<<<<< HEAD
- * @return integer
- =======
- * @return int
- >>>>>>> update grav cms
- */
- public function getSize()
- {
- return $this->_getHeaderParameter('Content-Disposition', 'size');
- }
- /**
- * Set the file size of this attachment.
- *
- <<<<<<< HEAD
- * @param integer $size
- =======
- * @param int $size
- >>>>>>> update grav cms
- *
- * @return Swift_Mime_Attachment
- */
- public function setSize($size)
- {
- $this->_setHeaderParameter('Content-Disposition', 'size', $size);
- return $this;
- }
- /**
- * Set the file that this attachment is for.
- *
- * @param Swift_FileStream $file
- * @param string $contentType optional
- *
- * @return Swift_Mime_Attachment
- */
- public function setFile(Swift_FileStream $file, $contentType = null)
- {
- $this->setFilename(basename($file->getPath()));
- $this->setBody($file, $contentType);
- if (!isset($contentType)) {
- <<<<<<< HEAD
- $extension = strtolower(substr(
- $file->getPath(), strrpos($file->getPath(), '.') + 1
- ));
- =======
- $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1));
- >>>>>>> update grav cms
- if (array_key_exists($extension, $this->_mimeTypes)) {
- $this->setContentType($this->_mimeTypes[$extension]);
- }
- }
- return $this;
- }
- }