|
|
@@ -86,6 +86,12 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface
|
|
|
* @var int
|
|
|
*/
|
|
|
protected $_messageNum = 0;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Class to use when creating message parts
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $_partClass;
|
|
|
|
|
|
/**
|
|
|
* Public constructor
|
|
|
@@ -122,6 +128,10 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface
|
|
|
$this->_mail = $params['handler'];
|
|
|
$this->_messageNum = $params['id'];
|
|
|
}
|
|
|
+
|
|
|
+ if (isset($params['partclass'])) {
|
|
|
+ $this->setPartClass($params['partclass']);
|
|
|
+ }
|
|
|
|
|
|
if (isset($params['raw'])) {
|
|
|
Zend_Mime_Decode::splitMessage($params['raw'], $this->_headers, $this->_content);
|
|
|
@@ -140,6 +150,44 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set name pf class used to encapsulate message parts
|
|
|
+ * @param string $class
|
|
|
+ * @return Zend_Mail_Part
|
|
|
+ */
|
|
|
+ public function setPartClass($class)
|
|
|
+ {
|
|
|
+ if ( !class_exists($class) ) {
|
|
|
+ /**
|
|
|
+ * @see Zend_Mail_Exception
|
|
|
+ */
|
|
|
+ require_once 'Zend/Mail/Exception.php';
|
|
|
+ throw new Zend_Mail_Exception("Class '{$class}' does not exist");
|
|
|
+ }
|
|
|
+ if ( !is_subclass_of($class, 'Zend_Mail_Part_Interface') ) {
|
|
|
+ /**
|
|
|
+ * @see Zend_Mail_Exception
|
|
|
+ */
|
|
|
+ require_once 'Zend/Mail/Exception.php';
|
|
|
+ throw new Zend_Mail_Exception("Class '{$class}' must implement Zend_Mail_Part_Interface");
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->_partClass = $class;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieve the class name used to encapsulate message parts
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getPartClass()
|
|
|
+ {
|
|
|
+ if ( !$this->_partClass ) {
|
|
|
+ $this->_partClass = __CLASS__;
|
|
|
+ }
|
|
|
+ return $this->_partClass;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Check if part is a multipart message
|
|
|
@@ -223,9 +271,10 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface
|
|
|
if ($parts === null) {
|
|
|
return;
|
|
|
}
|
|
|
+ $partClass = $this->getPartClass();
|
|
|
$counter = 1;
|
|
|
foreach ($parts as $part) {
|
|
|
- $this->_parts[$counter++] = new self(array('headers' => $part['header'], 'content' => $part['body']));
|
|
|
+ $this->_parts[$counter++] = new $partClass(array('headers' => $part['header'], 'content' => $part['body']));
|
|
|
}
|
|
|
}
|
|
|
|