/**
* Constructor.
*
* @param Horde_Mime_Part $mime_part A MIME part object. Must be of
* type multipart/related.
*/
public function __construct(Horde_Mime_Part $mime_part)
{
if ($mime_part->getType() != 'multipart/related') {
throw new InvalidArgumentException('MIME part must be of type multipart/related');
}
$ids = array_keys($mime_part->contentTypeMap());
$related_id = $mime_part->getMimeId();
$id = null;
/* Build a list of parts -> CIDs. */
foreach ($ids as $val) {
if (strcmp($related_id, $val) !== 0 && ($cid = $mime_part->getPart($val)->getContentId())) {
$this->_cids[$val] = $cid;
}
}
/* Look at the 'start' parameter to determine which part to start
* with. If no 'start' parameter, use the first part (RFC 2387
* [3.1]). */
$start = $mime_part->getContentTypeParameter('start');
if (!empty($start)) {
$id = $this->cidSearch($start);
}
if (empty($id)) {
reset($ids);
$id = next($ids);
}
$this->_start = $id;
}