本文整理汇总了PHP中Horde_Mime_Part::replaceEOL方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::replaceEOL方法的具体用法?PHP Horde_Mime_Part::replaceEOL怎么用?PHP Horde_Mime_Part::replaceEOL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Part
的用法示例。
在下文中一共展示了Horde_Mime_Part::replaceEOL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: htmlspecialchars
$textpart->setType('text/plain');
$textpart->setCharset('UTF-8');
$textpart->setContents(_("You have been sent an Ecard. To view the Ecard, you must be able to view text/html messages in your mail reader. If you are viewing this message, then most likely your mail reader does not support viewing text/html messages."));
/* Create the multipart/related part. */
$related = new Horde_Mime_Part();
$related->setType('multipart/related');
/* Create the HTML part. */
$htmlpart = new Horde_Mime_Part();
$htmlpart->setType('text/html');
$htmlpart->setCharset('UTF-8');
/* The image part */
$imgpart = new Horde_Mime_Part();
$imgpart->setType($image->getType('screen'));
$imgpart->setContents($image->raw('screen'));
$img_tag = '<img src="cid:' . $imgpart->setContentID() . '" /><p />';
$comments = $htmlpart->replaceEOL(Horde_Util::getFormData('ecard_comments'));
if (!Horde_Util::getFormData('rtemode')) {
$comments = '<pre>' . htmlspecialchars($comments, ENT_COMPAT, 'UTF-8') . '</pre>';
}
$htmlpart->setContents('<html>' . $img_tag . $comments . '</html>');
$related->setContentTypeParameter('start', $htmlpart->setContentID());
$related->addPart($htmlpart);
$related->addPart($imgpart);
/* Create the multipart/alternative part. */
$alternative = new Horde_Mime_Part();
$alternative->setType('multipart/alternative');
$alternative->addPart($textpart);
$alternative->addPart($related);
/* Add them to the mail message */
$alt = new Horde_Mime_Mail(array('Subject' => _("Ecard - ") . Horde_Util::getFormData('image_desc'), 'To' => $to, 'From' => $from));
$alt->setBasePart($alternative);
示例2: getRawPartText
/**
* Attempts to obtain the raw text of a MIME part.
*
* @param mixed $text The full text of the MIME message. The text is
* assumed to be MIME data (no MIME-Version checking
* is performed). It can be either a stream or a
* string.
* @param string $type Either 'header' or 'body'.
* @param string $id The MIME ID.
*
* @return string The raw text.
* @throws Horde_Mime_Exception
*/
public static function getRawPartText($text, $type, $id)
{
/* Mini-hack to get a blank Horde_Mime part so we can call
* replaceEOL(). From an API perspective, getRawPartText() should be
* static since it is not working on MIME part data. */
$part = new Horde_Mime_Part();
$rawtext = $part->replaceEOL($text, self::RFC_EOL);
/* We need to carry around the trailing "\n" because this is needed
* to correctly find the boundary string. */
$hdr_pos = self::_findHeader($rawtext, self::RFC_EOL);
$curr_pos = $hdr_pos + 3;
if ($id == 0) {
switch ($type) {
case 'body':
return substr($rawtext, $curr_pos + 1);
case 'header':
return trim(substr($rawtext, 0, $hdr_pos));
}
}
$hdr_ob = Horde_Mime_Headers::parseHeaders(trim(substr($rawtext, 0, $hdr_pos)));
/* If this is a message/rfc822, pass the body into the next loop.
* Don't decrement the ID here. */
if (($ct = $hdr_ob['Content-Type']) && $ct == 'message/rfc822') {
return self::getRawPartText(substr($rawtext, $curr_pos + 1), $type, $id);
}
$base_pos = strpos($id, '.');
$orig_id = $id;
if ($base_pos !== false) {
$id = substr($id, $base_pos + 1);
$base_pos = substr($orig_id, 0, $base_pos);
} else {
$base_pos = $id;
$id = 0;
}
if ($ct && !isset($ct->params['boundary'])) {
if ($orig_id == '1') {
return substr($rawtext, $curr_pos + 1);
}
throw new Horde_Mime_Exception('Could not find MIME part.');
}
$b_find = self::_findBoundary($rawtext, $curr_pos, $ct->params['boundary'], $base_pos);
if (!isset($b_find[$base_pos])) {
throw new Horde_Mime_Exception('Could not find MIME part.');
}
return self::getRawPartText(substr($rawtext, $b_find[$base_pos]['start'], $b_find[$base_pos]['length'] - 1), $type, $id);
}