mixed) */ private $properties = array(); /** * The counter is unique between all multipart types and is used to generate * unique boundary strings. * * @var int */ private static $counter = 0; /** * Constructs a new ezcMailMultipart with the parts $parts. * * Subclasses typically accept an arbitrary number of parts in the * constructor and pass them along using func_get_args(). * * $parts should be of the format array(array(ezcMailPart)|ezcMailPart) * * Subclasses must call this method in the constructor. * @param array */ public function __construct( array $parts ) { parent::__construct(); $this->boundary = $this->generateBoundary(); $this->setHeader( "Content-Type", 'multipart/' . $this->multipartType() . '; ' . 'boundary="' . $this->boundary . '"' ); foreach ( $parts as $part ) { if ( $part instanceof ezcMailPart ) { $this->parts[] = $part; } elseif( is_array( $part ) ) // add each and everyone of the parts in the array { foreach ( $part as $array_part ) { if ( $array_part instanceof ezcMailPart ) { $this->parts[] = $array_part;; } } } } } /** * Sets the property $name to $value. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @param string $name * @param mixed $value * @return void */ public function __set( $name, $value ) { switch ( $name ) { case 'boundary': $this->properties['boundary'] = $value; $this->setHeader( 'Content-Type', 'multipart/' . $this->multipartType() . '; ' . 'boundary="' . $this->boundary . '"' ); break; default: return parent::__set( $name, $value ); break; } } /** * Returns the property $name. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @param string $name * @return mixed */ public function __get( $name ) { switch ( $name ) { case 'boundary': return $this->properties['boundary']; break; default: return parent::__get( $name ); break; } } /** * Returns the generated body for all multipart types. * * @return string */ public function generateBody() { $data = ezcMailMultipart::$noMimeMessage . ezcMailTools::lineBreak(); foreach ( $this->parts as $part ) { $data .= ezcMailTools::lineBreak() . '--' . $this->boundary . ezcMailTools::lineBreak(); $data .= $part->generate(); } $data .= ezcMailTools::lineBreak() . '--' . $this->boundary . '--'; return $data; } /** * Returns the type of multipart. * * @return string */ abstract public function multipartType(); /** * Returns a unique boundary string. * * @return string */ protected static function generateBoundary() { return date( "YmdGHjs" ) . ':' . getmypid() . ':' . self::$counter++; } } ?>