本文整理汇总了PHP中ezcMailTools::replaceContentIdRefs方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailTools::replaceContentIdRefs方法的具体用法?PHP ezcMailTools::replaceContentIdRefs怎么用?PHP ezcMailTools::replaceContentIdRefs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcMailTools
的用法示例。
在下文中一共展示了ezcMailTools::replaceContentIdRefs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testResolveCids
public function testResolveCids()
{
$parser = new ezcMailParser();
$set = new ezcMailFileSet(array(dirname(__FILE__) . '/parser/data/various/test-html-inline-images'));
$mail = $parser->parseMail($set);
$relatedParts = $mail[0]->body->getParts();
$alternativeParts = $relatedParts[0]->getParts();
$html = $alternativeParts[1]->getMainPart();
$convertArray = array('consoletools-table.png@1421450' => 'foo', 'consoletools-table.png@1421452' => 'bar');
$htmlBody = ezcMailTools::replaceContentIdRefs($html->text, $convertArray);
$expected = <<<EOFE
<html>
Here is the HTML version of your mail
with an image: <img src='foo'/>
with an image: <img src='cid:consoletools-table.png@1421451'/>
</html>
EOFE;
self::assertSame($expected, $htmlBody);
}
示例2: tempnam
$newFile = tempnam($this->dir, 'mail');
copy($mailPart->fileName, $newFile);
// save location and setup ID array
$this->cids[$mailPart->contentId] = $this->webDir . '/' . basename($newFile);
}
// if we find a text part and if the sub-type is HTML (no plain text)
// we store that in the classes' htmlText property.
if ($mailPart instanceof ezcMailText) {
if ($mailPart->subType == 'html') {
$this->htmlText = $mailPart->text;
}
}
}
}
// create the collector class and set the filesystem path, and the webserver's
// path to find the attached files (images) in.
$collector = new collector();
$collector->dir = "/home/httpd/html/test/ezc";
$collector->webDir = '/test/ezc';
// We use the saveMailPart() method of the $collector object function as a
// callback in walkParts().
$context = new ezcMailPartWalkContext(array($collector, 'saveMailPart'));
// only call the callback for file and text parts.
$context->filter = array('ezcMailFile', 'ezcMailText');
// use walkParts() to iterate over all parts in the first parsed e-mail
// message.
$mail[0]->walkParts($context, $mail[0]);
// display the html text with the content IDs replaced with references to the
// file in the webroot.
echo ezcMailTools::replaceContentIdRefs($collector->htmlText, $collector->cids);