/** * @return void */ private function reParseParameters() { $aDataToReParse = $this->CloneAsArray(); $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8; $this->clear(); $aPreParams = array(); foreach ($aDataToReParse as $oParam) { $aMatch = array(); $sParamName = $oParam->Name(); if (preg_match('/([^\\*]+)\\*([\\d]{1,2})\\*/', $sParamName, $aMatch) && isset($aMatch[1], $aMatch[2]) && 0 < strlen($aMatch[1]) && is_numeric($aMatch[2])) { if (!isset($aPreParams[$aMatch[1]])) { $aPreParams[$aMatch[1]] = array(); } $sValue = $oParam->Value(); $aValueParts = explode('\'\'', $sValue, 2); if (is_array($aValueParts) && 2 === count($aValueParts) && 0 < strlen($aValueParts[1])) { $sCharset = $aValueParts[0]; $sValue = $aValueParts[1]; } $aPreParams[$aMatch[1]][(int) $aMatch[2]] = $sValue; } else { if (preg_match('/([^\\*]+)\\*/', $sParamName, $aMatch) && isset($aMatch[1])) { if (!isset($aPreParams[$aMatch[1]])) { $aPreParams[$aMatch[1]] = array(); } $sValue = $oParam->Value(); $aValueParts = explode('\'\'', $sValue, 2); if (is_array($aValueParts) && 2 === count($aValueParts) && 0 < strlen($aValueParts[1])) { $sCharset = $aValueParts[0]; $sValue = $aValueParts[1]; } $aPreParams[$aMatch[1]][0] = $sValue; } else { $this->Add($oParam); } } } foreach ($aPreParams as $sName => $aValues) { ksort($aValues); $sResult = implode(array_values($aValues)); $sResult = urldecode($sResult); if (0 < strlen($sCharset)) { $sResult = \MailSo\Base\Utils::ConvertEncoding($sResult, $sCharset, \MailSo\Base\Enumerations\Charset::UTF_8); } $this->Add(Parameter::NewInstance($sName, $sResult)); } }
/** * @param \MailSo\Mime\Part $oIncPart * * @return \MailSo\Mime\Part */ private function createNewMessageMixedBody($oIncPart) { $oResultPart = null; $aAttachments = $this->oAttachmentCollection->UnlinkedAttachments(); if (0 < count($aAttachments)) { $oResultPart = Part::NewInstance(); $oResultPart->Headers->AddByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, \MailSo\Mime\Enumerations\MimeType::MULTIPART_MIXED . '; ' . ParameterCollection::NewInstance()->Add(Parameter::NewInstance(\MailSo\Mime\Enumerations\Parameter::BOUNDARY, $this->generateNewBoundary()))->ToString()); $oResultPart->SubParts->Add($oIncPart); foreach ($aAttachments as $oAttachment) { $oResultPart->SubParts->Add($this->createNewMessageAttachmentBody($oAttachment)); } } else { $oResultPart = $oIncPart; } return $oResultPart; }