mixed) */ protected $properties = array(); /** * Constructs a new attachment with $fileName. * * @param string $fileName */ public function __construct( $fileName ) { parent::__construct(); // initialize properties that may be touched automatically // this is to avoid notices $this->properties['contentType'] = null; $this->properties['mimeType'] = null; $this->properties['dispositionType'] = null; $this->properties['contentId'] = null; $this->fileName = $fileName; $this->setHeader( 'Content-Transfer-Encoding', 'base64' ); $this->dispositionType = self::DISPLAY_ATTACHMENT; } /** * Sets the property $name to $value. * * @throws ezcBasePropertyNotFoundException * if the property does not exist. * @param string $name * @param mixed $value * @ignore */ public function __set( $name, $value ) { switch ( $name ) { case 'fileName': $this->properties['fileName'] = $value; $this->setHeaderContentType(); $this->setHeaderContentDisposition(); break; case 'mimeType': $this->properties['mimeType'] = $value; $this->setHeaderContentType(); break; case 'contentType': $this->properties['contentType'] = $value; $this->setHeaderContentType(); break; case 'dispositionType': $this->properties['dispositionType'] = $value; $this->setHeaderContentDisposition(); break; case 'contentId': $this->properties['contentId'] = $value; $this->setHeader( 'Content-ID', '<' . $value . '>' ); break; default: return parent::__set( $name, $value ); break; } } /** * Returns the value of property $value. * * @throws ezcBasePropertyNotFoundException * if the property does not exist. * @param string $name * @return mixed * @ignore */ public function __get( $name ) { switch ( $name ) { case 'fileName': case 'mimeType': case 'contentType': case 'dispositionType': case 'contentId': return $this->properties[$name]; break; default: return parent::__get( $name ); break; } } /** * Returns true if the property $name is set, otherwise false. * * @param string $name * @return bool * @ignore */ public function __isset( $name ) { switch ( $name ) { case 'fileName': case 'mimeType': case 'contentType': case 'dispositionType': case 'contentId': return isset( $this->properties[$name] ); default: return parent::__isset( $name ); } } /** * Sets the Content-Type header. * * Based on the contentType, mimeType and fileName. */ private function setHeaderContentType() { $this->setHeader( 'Content-Type', $this->contentType . '/' . $this->mimeType . '; ' . 'name="' . basename( $this->fileName ) . '"' ); } /** * Sets the Content-Disposition header. * * Based on the properties $dispositionType and $fileName. */ private function setHeaderContentDisposition() { if ( $this->contentDisposition == null ) { $this->contentDisposition = new ezcMailContentDispositionHeader(); } $this->contentDisposition->disposition = $this->dispositionType; $this->contentDisposition->fileName = basename( $this->fileName ); // $this->setHeader( 'Content-Disposition', // $this->dispositionType .'; ' . 'filename="' . basename( $this->fileName ) . '"' ); } } ?>