本文整理汇总了PHP中Horde_Mime::encodeParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime::encodeParam方法的具体用法?PHP Horde_Mime::encodeParam怎么用?PHP Horde_Mime::encodeParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime
的用法示例。
在下文中一共展示了Horde_Mime::encodeParam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toArray
/**
* Returns the internal header array in array format.
*
* @param array $opts Optional parameters:
* - canonical: (boolean) Use canonical (RFC 822/2045) line endings?
* DEFAULT: Uses $this->_eol
* - charset: (string) Encodes the headers using this charset. If empty,
* encodes using internal charset (UTF-8).
* DEFAULT: No encoding.
* - defserver: (string) The default domain to append to mailboxes.
* DEFAULT: No default name.
* - nowrap: (integer) Don't wrap the headers.
* DEFAULT: Headers are wrapped.
*
* @return array The headers in array format.
*/
public function toArray(array $opts = array())
{
$address_keys = $this->addressFields();
$charset = array_key_exists('charset', $opts) ? empty($opts['charset']) ? 'UTF-8' : $opts['charset'] : null;
$eol = empty($opts['canonical']) ? $this->_eol : "\r\n";
$mime = $this->mimeParamFields();
$ret = array();
foreach ($this->_headers as $header => $ob) {
$val = is_array($ob['v']) ? $ob['v'] : array($ob['v']);
foreach (array_keys($val) as $key) {
if (in_array($header, $address_keys)) {
/* Address encoded headers. */
$rfc822 = new Horde_Mail_Rfc822();
$text = $rfc822->parseAddressList($val[$key], array('default_domain' => empty($opts['defserver']) ? null : $opts['defserver']))->writeAddress(array('encode' => $charset, 'idn' => true));
} elseif (in_array($header, $mime) && !empty($ob['p'])) {
/* MIME encoded headers (RFC 2231). */
$text = $val[$key];
foreach ($ob['p'] as $name => $param) {
foreach (Horde_Mime::encodeParam($name, $param, array('charset' => $charset, 'escape' => true)) as $name2 => $param2) {
$text .= '; ' . $name2 . '=' . $param2;
}
}
} else {
$text = is_null($charset) ? $val[$key] : Horde_Mime::encode($val[$key], $charset);
}
if (empty($opts['nowrap'])) {
/* Remove any existing linebreaks and wrap the line. */
$header_text = $ob['h'] . ': ';
$text = ltrim(substr(wordwrap($header_text . strtr(trim($text), array("\r" => '', "\n" => '')), 76, $eol . ' '), strlen($header_text)));
}
$val[$key] = $text;
}
$ret[$ob['h']] = count($val) == 1 ? reset($val) : $val;
}
return $ret;
}
示例2: testBug12127
public function testBug12127()
{
Horde_Mime::$brokenRFC2231 = true;
$this->assertEquals(array('foo' => 'test'), Horde_Mime::encodeParam('foo', 'test', array('charset' => 'UTF-16LE')));
$this->assertEquals(array('foo*' => "utf-16le''%01%01", 'foo' => '"=?utf-16le?b?AQE=?="'), Horde_Mime::encodeParam('foo', 'ā', array('charset' => 'UTF-16LE')));
}