/** * Constructor * * @param \BLW\Type\IFile $File * File to attatch. * @param string $Name * [optional] File name (basename). * @param string $Type * [optional] File mime type. */ public function __construct(IFile $File, $Name = null, $Type = null) { // Open file if it is not readable if (!$File->isReadable()) { try { $File->openFile(); } catch (FileException $e) { throw new FileException($File->getPathname(), null, $e->getCode(), $e); } } // IContainer constructor parent::__construct(IPart::HEADER, 'string'); // Ensure $Name and $Type are set / not empty $Name = @substr($Name, 0) ?: $File->getBasename(); $Type = @substr($Type, 0) ?: $File->getMimetype(); // Host $Host = @$_SERVER['HTTP_HOST'] ?: @$_SERVER['SERVER_NAME'] ?: @$_SERVER['SERVER_ADDR'] ?: '0.0.0.0'; $Host = "http://{$Host}/"; // Attachment Headers parent::offsetSet('Content-Type', new ContentType($Type, array('name' => $Name))); parent::offsetSet('Content-Transfer-Encoding', new ContentTransferEncoding('base64')); parent::offsetSet('Content-Disposition', new ContentDisposition('inline', array('filename' => $Name))); parent::offsetSet('Content-ID', new ContentID()); parent::offsetSet('Content-Location', new ContentLocation(new GenericURI("/{$Name}"))); parent::offsetSet('Content-Base', new ContentBase(new GenericURI($Host))); // Attachment content parent::offsetSet('Content', $this->format($File->getContents(), self::CHUNKLEN) . $this->_CRLF); }
/** * Constructor * * @param string $Field * Label of field. * @param \BLW\Type\IFile $File * File to attatch. * @param string $Name * File name (basename). * @param string $Type * File mime type. */ public function __construct($Field, IFile $File, $Name = null, $Type = null) { // Is $Field not a string? if (!is_string($Field) && !is_callable(array($Field, '__toString'))) { throw new InvalidArgumentException(0); // Open file if it is not readable } elseif (!$File->isReadable()) { try { $File->openFile(); } catch (FileException $e) { throw new FileException($File->getPathname(), null, $e->getCode(), $e); } } // IContainer constructor parent::__construct(IPart::HEADER, 'string'); $Field = strval($Field); // Get $Name and $Type from file if not set $Type = $Type ?: $File->getMimetype(); $Name = $Name ?: $File->getBasename(); // File Headers parent::offsetSet('Content-Disposition', new ContentDisposition('form-data', array('name' => $Field, 'filename' => $Name))); parent::offsetSet('Content-Type', new ContentType($Type)); parent::offsetSet('Content-Transfer-Encoding', new ContentTransferEncoding('binary')); // File content parent::offsetSet('Content', $this->format($File->getContents(), self::CHUNKLEN) . $this->_CRLF); }
/** * Constructor * * @param \BLW\Model\MIME\Part\FormField[] $Fields * Form fields. */ public function __construct(array $Fields) { // IContainer constructor parent::__construct('string'); // Part content parent::offsetSet('Content', $this->format($Fields, self::CHUNKLEN) . $this->_CRLF); }
/** * Constructor * * @param string $Type * Content-Type. * @param string $Content * Content of part. * @param string $Charset * content carset. (Default utf-8) */ public function __construct($Type, $Content, $Charset = 'utf-8') { // Ensure content is a string if (!is_string($Content) && !is_callable(array($Content, '__toString'))) { throw new InvalidArgumentException(1); } // IContainer constructor parent::__construct(IPart::HEADER, 'string'); // Part Headers parent::offsetSet('Content-Type', new ContentType($Type, array('charset' => $Charset))); parent::offsetSet('Content-Transfer-Encoding', new ContentTransferEncoding('quoted-printable')); // Part content parent::offsetSet('Content', $this->format($Content, self::CHUNKLEN) . $this->_CRLF); }
/** * Constructor * * @param \BLW\Type\IFile $File * File to attatch. * @param string $Name * File name (basename). * @param string $Type * File mime type. */ public function __construct(IFile $File, $Name = null, $Type = null) { // Open file if it is not readable if (!$File->isReadable()) { try { $File->openFile(); } catch (FileException $e) { throw new FileException($File->getPathname(), null, $e->getCode(), $e); } } // IContainer constructor parent::__construct(IPart::HEADER, 'string'); // Ensure $Name and $Type are set / not empty $Name = @substr($Name, 0) ?: $File->getBasename(); $Type = @substr($Type, 0) ?: $File->getMimetype(); // Attachment Headers parent::offsetSet('Content-Type', new ContentType($Type, array('name' => $Name))); parent::offsetSet('Content-Transfer-Encoding', new ContentTransferEncoding('base64')); parent::offsetSet('Content-Disposition', new ContentDisposition('attachment', array('filename' => $Name))); // Attachment content parent::offsetSet('Content', $this->format($File->getContents(), self::CHUNKLEN) . $this->_CRLF); }
/** * Constructor * * @param \BLW\Model\MIME\MIMEVersion $Version * Version of * @param \BLW\Model\MIME\Section $Section * Main section of MIME body */ public function __construct(IHeader $Version, ISection $Section) { // IContainer constructor parent::__construct(self::HEADER, 'string'); // Set up properties $this->_Version = $Version; $this->_Section = $Section; }
/** * Constructor * * @param \BLW\Model\MIME\Section $Section * Main section of Mime body */ public function __construct(ISection $Section) { // IContainer constructor parent::__construct(IBody::HEADER, IBody::PART, 'string'); // Set up properties $this->_Sections = array($Section); }
/** * Constructor * * @param string $Type * [optional] Content type: * * <ul> * <li>multipart/mixed</li> * <li>multipart/alternative</li> * <li>multipart/related</li> * </ul> * * @param string $Boundary * [optional] MIME boundary */ public function __construct($Type = null, $Boundary = null) { // IContainer constructor parent::__construct('object', 'string'); $this->_Type = strval($Type) ?: $this->_Type; $this->_Boundary = strval($Boundary) ?: $this->buildBoundary(); }
/** * Constructor */ public function __construct() { // IContainer constructor parent::__construct(self::HEADER, 'string'); }
/** * Constructor */ public function __construct() { // IContainer constructor parent::__construct(IBody::HEADER, IBody::PART, 'string'); // Set up sections $this->_Sections = array(); }