diff -r 5e7a0fedabdf -r 877f952ae2bd web/lib/Zend/Mail/Part.php --- a/web/lib/Zend/Mail/Part.php Thu Mar 21 17:31:31 2013 +0100 +++ b/web/lib/Zend/Mail/Part.php Thu Mar 21 19:50:53 2013 +0100 @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Part.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Part.php 24759 2012-05-05 02:58:55Z adamlundrigan $ */ @@ -34,7 +34,7 @@ /** * @category Zend * @package Zend_Mail - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface @@ -86,6 +86,12 @@ * @var int */ protected $_messageNum = 0; + + /** + * Class to use when creating message parts + * @var string + */ + protected $_partClass; /** * Public constructor @@ -122,6 +128,10 @@ $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 @@ } } } + + /** + * 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 @@ 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'])); } }