/** * Add a MIME subpart. * * @param MIME_Part $mime_part Add a MIME_Part subpart to the current * MIME_Part. * @param string $index The index of the added MIME_Part. */ public function addPart($mime_part, $index = null) { /* Add the part to the parts list. */ if (is_null($index)) { end($this->_parts); $id = key($this->_parts) + 1; $ptr =& $this->_parts; } else { $ptr =& $this->_partFind($index, $this->_parts, true); if ($pos = strrpos($index, '.')) { $id = substr($index, $pos + 1); } else { $id = $index; } } /* Set the MIME ID if it has not already been set. */ if ($mime_part->getMIMEId() === null) { $mime_part->setMIMEId($id); } /* Store the part now. */ $ptr[$id] = $mime_part; /* Clear the ID -> Part mapping cache. */ $this->_idmap = array(); }