From 232aa1924c8c0f10d87b210b46c9f061af5c844c Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sun, 17 Oct 2010 13:29:57 +0000 Subject: added files --- .../lib/classes/Swift/Mime/Attachment.php | 143 +++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 h-source/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php (limited to 'h-source/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php') diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/h-source/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php new file mode 100644 index 0000000..25ef68b --- /dev/null +++ b/h-source/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -0,0 +1,143 @@ +setDisposition('attachment'); + $this->setContentType('application/octet-stream'); + $this->_mimeTypes = $mimeTypes; + } + + /** + * Get the nesting level used for this attachment. + * Always returns {@link LEVEL_MIXED}. + * @return int + */ + 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 + */ + public function setDisposition($disposition) + { + if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) + { + $this->getHeaders()->addParameterizedHeader( + 'Content-Disposition', $disposition + ); + } + 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 + */ + 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. + * @return int + */ + public function getSize() + { + return $this->_getHeaderParameter('Content-Disposition', 'size'); + } + + /** + * Set the file size of this attachment. + * @param int $size + */ + 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 + */ + public function setFile(Swift_FileStream $file, $contentType = null) + { + $this->setFilename(basename($file->getPath())); + $this->setBody($file, $contentType); + if (!isset($contentType)) + { + $extension = strtolower(substr( + $file->getPath(), strrpos($file->getPath(), '.') + 1 + )); + + if (array_key_exists($extension, $this->_mimeTypes)) + { + $this->setContentType($this->_mimeTypes[$extension]); + } + } + return $this; + } + +} -- cgit v1.2.3