本文整理汇总了PHP中Horde_Mime_Part::setLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::setLanguage方法的具体用法?PHP Horde_Mime_Part::setLanguage怎么用?PHP Horde_Mime_Part::setLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Part
的用法示例。
在下文中一共展示了Horde_Mime_Part::setLanguage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _parseBodystructure
/**
* Recursively parse BODYSTRUCTURE data from a FETCH return (see
* RFC 3501 [7.4.2]).
*
* @param Horde_Imap_Client_Tokenize $data Data returned from the server.
*
* @return Horde_Mime_Part Mime part object.
*/
protected function _parseBodystructure(Horde_Imap_Client_Tokenize $data)
{
$ob = new Horde_Mime_Part();
// If index 0 is an array, this is a multipart part.
if (($entry = $data->next()) === true) {
do {
$ob->addPart($this->_parseBodystructure($data));
} while (($entry = $data->next()) === true);
// The subpart type.
$ob->setType('multipart/' . $entry);
// After the subtype is further extension information. This
// information MAY appear for BODYSTRUCTURE requests.
// This is parameter information.
if (($tmp = $data->next()) === false) {
return $ob;
} elseif ($tmp === true) {
foreach ($this->_parseStructureParams($data, 'content-type') as $key => $val) {
$ob->setContentTypeParameter($key, $val);
}
}
} else {
$ob->setType($entry . '/' . $data->next());
if ($data->next() === true) {
foreach ($this->_parseStructureParams($data, 'content-type') as $key => $val) {
$ob->setContentTypeParameter($key, $val);
}
}
if (!is_null($tmp = $data->next())) {
$ob->setContentId($tmp);
}
if (!is_null($tmp = $data->next())) {
$ob->setDescription(Horde_Mime::decode($tmp));
}
if (!is_null($tmp = $data->next())) {
$ob->setTransferEncoding($tmp);
}
$ob->setBytes($data->next());
// If the type is 'message/rfc822' or 'text/*', several extra
// fields are included
switch ($ob->getPrimaryType()) {
case 'message':
if ($ob->getSubType() == 'rfc822') {
if ($data->next() === true) {
// Ignore: envelope
$data->flushIterator(false);
}
if ($data->next() === true) {
$ob->addPart($this->_parseBodystructure($data));
}
$data->next();
// Ignore: lines
}
break;
case 'text':
$data->next();
// Ignore: lines
break;
}
// After the subtype is further extension information. This
// information MAY appear for BODYSTRUCTURE requests.
// Ignore: MD5
if ($data->next() === false) {
return $ob;
}
}
// This is disposition information
if (($tmp = $data->next()) === false) {
return $ob;
} elseif ($tmp === true) {
$ob->setDisposition($data->next());
if ($data->next() === true) {
foreach ($this->_parseStructureParams($data, 'content-disposition') as $key => $val) {
$ob->setDispositionParameter($key, $val);
}
}
$data->next();
}
// This is language information. It is either a single value or a list
// of values.
if (($tmp = $data->next()) === false) {
return $ob;
} elseif (!is_null($tmp)) {
$ob->setLanguage($tmp === true ? $data->flushIterator() : $tmp);
}
// Ignore location (RFC 2557) and consume closing paren.
$data->flushIterator(false);
return $ob;
}
示例2: _parseStructure
/**
* Recursively parse BODYSTRUCTURE data from a FETCH return (see
* RFC 3501 [7.4.2]).
*
* @param array $data The tokenized information from the server.
*
* @return array The array of bodystructure information.
*/
protected function _parseStructure($data)
{
$ob = new Horde_Mime_Part();
// If index 0 is an array, this is a multipart part.
if (is_array($data[0])) {
// Keep going through array values until we find a non-array.
for ($i = 0, $cnt = count($data); $i < $cnt; ++$i) {
if (!is_array($data[$i])) {
break;
}
$ob->addPart($this->_parseStructure($data[$i]));
}
// The first string entry after an array entry gives us the
// subpart type.
$ob->setType('multipart/' . $data[$i]);
// After the subtype is further extension information. This
// information MAY not appear for BODYSTRUCTURE requests.
// This is parameter information.
if (isset($data[++$i]) && is_array($data[$i])) {
foreach ($this->_parseStructureParams($data[$i], 'content-type') as $key => $val) {
$ob->setContentTypeParameter($key, $val);
}
}
// This is disposition information.
if (isset($data[++$i]) && is_array($data[$i])) {
$ob->setDisposition($data[$i][0]);
foreach ($this->_parseStructureParams($data[$i][1], 'content-disposition') as $key => $val) {
$ob->setDispositionParameter($key, $val);
}
}
// This is language information. It is either a single value or
// a list of values.
if (isset($data[++$i])) {
$ob->setLanguage($data[$i]);
}
// Ignore: location (RFC 2557)
// There can be further information returned in the future, but
// for now we are done.
} else {
$ob->setType($data[0] . '/' . $data[1]);
foreach ($this->_parseStructureParams($data[2], 'content-type') as $key => $val) {
$ob->setContentTypeParameter($key, $val);
}
if ($data[3] !== null) {
$ob->setContentId($data[3]);
}
if ($data[4] !== null) {
$ob->setDescription(Horde_Mime::decode($data[4]));
}
if ($data[5] !== null) {
$ob->setTransferEncoding($data[5]);
}
if ($data[6] !== null) {
$ob->setBytes($data[6]);
}
// If the type is 'message/rfc822' or 'text/*', several extra
// fields are included
switch ($ob->getPrimaryType()) {
case 'message':
if ($ob->getSubType() == 'rfc822') {
// Ignore: envelope
$ob->addPart($this->_parseStructure($data[8]));
// Ignore: lines
$i = 10;
} else {
$i = 7;
}
break;
case 'text':
// Ignore: lines
$i = 8;
break;
default:
$i = 7;
break;
}
// After the subtype is further extension information. This
// information MAY appear for BODYSTRUCTURE requests.
// Ignore: MD5
// This is disposition information
if (isset($data[++$i]) && is_array($data[$i])) {
$ob->setDisposition($data[$i][0]);
foreach ($this->_parseStructureParams($data[$i][1], 'content-disposition') as $key => $val) {
$ob->setDispositionParameter($key, $val);
}
}
// This is language information. It is either a single value or
// a list of values.
if (isset($data[++$i])) {
$ob->setLanguage($data[$i]);
}
// Ignore: location (RFC 2557)
//.........这里部分代码省略.........
示例3: _parseBodystructure
/**
* Recursively parse BODYSTRUCTURE data from a FETCH return (see
* RFC 3501 [7.4.2]).
*
* @param Horde_Imap_Client_Tokenize $data Data returned from the server.
*
* @return array The array of bodystructure information.
*/
protected function _parseBodystructure(Horde_Imap_Client_Tokenize $data)
{
$ob = new Horde_Mime_Part();
// If index 0 is an array, this is a multipart part.
if (is_object($entry = $data->rewind())) {
// Keep going through array values until we find a non-array.
do {
$ob->addPart($this->_parseBodystructure($entry));
} while (is_object($entry = $data->next()));
// The first string entry after an array entry gives us the
// subpart type.
$ob->setType('multipart/' . $entry);
// After the subtype is further extension information. This
// information MAY not appear for BODYSTRUCTURE requests.
// This is parameter information.
if (is_object($tmp = $data->next())) {
foreach ($this->_parseStructureParams($tmp, 'content-type') as $key => $val) {
$ob->setContentTypeParameter($key, $val);
}
}
} else {
$ob->setType($entry . '/' . $data->next());
if (is_object($tmp = $data->next())) {
foreach ($this->_parseStructureParams($tmp, 'content-type') as $key => $val) {
$ob->setContentTypeParameter($key, $val);
}
}
if (!is_null($tmp = $data->next())) {
$ob->setContentId($tmp);
}
if (!is_null($tmp = $data->next())) {
$ob->setDescription(Horde_Mime::decode($tmp));
}
if (!is_null($tmp = $data->next())) {
$ob->setTransferEncoding($tmp);
}
$ob->setBytes($data->next());
// If the type is 'message/rfc822' or 'text/*', several extra
// fields are included
switch ($ob->getPrimaryType()) {
case 'message':
if ($ob->getSubType() == 'rfc822') {
$data->next();
// Ignore: envelope
$ob->addPart($this->_parseBodystructure($data->next()));
$data->next();
// Ignore: lines
}
break;
case 'text':
$data->next();
// Ignore: lines
break;
}
// After the subtype is further extension information. This
// information MAY appear for BODYSTRUCTURE requests.
$data->next();
// Ignore: MD5
}
// This is disposition information
if (is_object($tmp = $data->next())) {
$ob->setDisposition($tmp->rewind());
foreach ($this->_parseStructureParams($tmp->next(), 'content-disposition') as $key => $val) {
$ob->setDispositionParameter($key, $val);
}
}
// This is language information. It is either a single value or a list
// of values.
if (($tmp = $data->next()) !== false) {
$ob->setLanguage($tmp);
}
$data->next();
// Ignore: location (RFC 2557)
return $ob;
}
示例4: testNullCharactersNotAllowedInMimeHeaderData
public function testNullCharactersNotAllowedInMimeHeaderData()
{
$part = new Horde_Mime_Part();
$part->setType("text/plain");
$this->assertEquals('text/plain', $part->getType());
$part->setDisposition("inline");
$this->assertEquals('inline', $part->getDisposition());
$part->setDispositionParameter('size', '123' . "" . '456');
$this->assertEquals(123456, $part->getDispositionParameter('size'));
$part->setDispositionParameter('foo', "foobar");
$this->assertEquals('foobar', $part->getDispositionParameter('foo'));
$part->setCharset("utf-8");
$this->assertEquals('utf-8', $part->getCharset());
$part->setName("foobar");
$this->assertEquals('foobar', $part->getName());
$this->assertEquals('foobar', $part->getDispositionParameter('filename'));
$this->assertEquals('foobar', $part->getContentTypeParameter('name'));
$part->setLanguage("en");
$this->assertEquals(array('en'), $part->getLanguage());
$part->setLanguage(array("en", "de"));
$this->assertEquals(array('en', 'de'), $part->getLanguage());
$part->setDuration('123' . "" . '456');
$this->assertEquals(123456, $part->getDuration());
$part->setBytes('123' . "" . '456');
$this->assertEquals(123456, $part->getBytes());
$part->setDescription("foobar");
$this->assertEquals('foobar', $part->getDescription());
$part->setContentTypeParameter('foo', "foobar");
$this->assertEquals('foobar', $part->getContentTypeParameter('foo'));
$part->setContentId("foobar");
$this->assertEquals('foobar', $part->getContentId());
}
示例5: _saveToSentMail
/**
* Save message to sent-mail mailbox, if configured to do so.
*
* @param Horde_Mime_Headers $headers Headers object.
* @param Horde_Mime_Part $save_msg Message data to save.
* @param Horde_Mail_Rfc822_List $recips Recipient list.
* @param array $opts See buildAndSendMessage()
*/
protected function _saveToSentMail(Horde_Mime_Headers $headers, Horde_Mime_Part $save_msg, Horde_Mail_Rfc822_List $recips, $opts)
{
global $injector, $language, $notification, $prefs;
if (empty($opts['sent_mail']) || $prefs->isLocked('save_sent_mail') && !$prefs->getValue('save_sent_mail') || !$prefs->isLocked('save_sent_mail') && empty($opts['save_sent'])) {
return;
}
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
/* If message contains EAI addresses, we need to verify that the IMAP
* server can handle this data in order to save. */
foreach ($recips as $val) {
if ($val->eai) {
if ($imp_imap->client_ob->capability->query('UTF8', 'ACCEPT')) {
break;
}
$notification->push(sprintf(_("Message sent successfully, but not saved to %s."), $sent_mail->display));
return;
}
}
/* Strip attachments if requested. */
if (!empty($opts['strip_attachments'])) {
$save_msg->buildMimeIds();
/* Don't strip any part if this is a text message with both
* plaintext and HTML representation. */
if ($save_msg->getType() != 'multipart/alternative') {
for ($i = 2;; ++$i) {
if (!($oldPart = $save_msg[$i])) {
break;
}
$replace_part = new Horde_Mime_Part();
$replace_part->setType('text/plain');
$replace_part->setCharset($this->charset);
$replace_part->setLanguage($language);
$replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]');
$save_msg[$i] = $replace_part;
}
}
}
/* Generate the message string. */
$fcc = $save_msg->toString(array('defserver' => $imp_imap->config->maildomain, 'headers' => $headers, 'stream' => true));
/* Make sure sent mailbox is created. */
$sent_mail = IMP_Mailbox::get($opts['sent_mail']);
$sent_mail->create();
$flags = array(Horde_Imap_Client::FLAG_SEEN, Horde_Imap_Client::FLAG_MDNSENT);
try {
$imp_imap->append($sent_mail, array(array('data' => $fcc, 'flags' => $flags)));
} catch (IMP_Imap_Exception $e) {
$notification->push(sprintf(_("Message sent successfully, but not saved to %s."), $sent_mail->display));
}
}
示例6: buildAndSendMessage
//.........这里部分代码省略.........
if ($e->log()) {
$msg_id = new Horde_Mail_Rfc822_Identification($headers->getValue('message-id'));
$sentmail->log($senttype, reset($msg_id->ids), $val['recipients'], false);
}
throw new IMP_Compose_Exception(sprintf(_("There was an error sending your message: %s"), $e->getMessage()));
}
}
$recipients = strval($recip['list']);
if ($this->_replytype) {
/* Log the reply. */
if ($indices = $this->getMetadata('indices')) {
switch ($this->_replytype) {
case self::FORWARD:
case self::FORWARD_ATTACH:
case self::FORWARD_BODY:
case self::FORWARD_BOTH:
$log = new IMP_Maillog_Log_Forward($recipients);
break;
case self::REPLY:
case self::REPLY_SENDER:
$log = new IMP_Maillog_Log_Reply();
break;
case IMP_Compose::REPLY_ALL:
$log = new IMP_Maillog_Log_Replyall();
break;
case IMP_Compose::REPLY_LIST:
$log = new IMP_Maillog_Log_Replylist();
break;
}
$log_msgs = array();
foreach ($indices as $val) {
foreach ($val->uids as $val2) {
$log_msgs[] = new IMP_Maillog_Message(new IMP_Indices($val->mbox, $val2));
}
}
$injector->getInstance('IMP_Maillog')->log($log_msgs, $log);
}
$imp_message = $injector->getInstance('IMP_Message');
$reply_uid = new IMP_Indices($this);
switch ($this->replyType(true)) {
case self::FORWARD:
/* Set the Forwarded flag, if possible, in the mailbox.
* See RFC 5550 [5.9] */
$imp_message->flag(array('add' => array(Horde_Imap_Client::FLAG_FORWARDED)), $reply_uid);
break;
case self::REPLY:
/* Make sure to set the IMAP reply flag and unset any
* 'flagged' flag. */
$imp_message->flag(array('add' => array(Horde_Imap_Client::FLAG_ANSWERED), 'remove' => array(Horde_Imap_Client::FLAG_FLAGGED)), $reply_uid);
break;
}
}
Horde::log(sprintf("Message sent to %s from %s (%s)", $recipients, $registry->getAuth(), $session->get('horde', 'auth/remoteAddr')), 'INFO');
/* Should we save this message in the sent mail mailbox? */
if (!empty($opts['sent_mail']) && (!$prefs->isLocked('save_sent_mail') && !empty($opts['save_sent']) || $prefs->isLocked('save_sent_mail') && $prefs->getValue('save_sent_mail'))) {
/* Keep Bcc: headers on saved messages. */
if (count($header['bcc'])) {
$headers->addHeader('Bcc', $header['bcc']);
}
/* Strip attachments if requested. */
if (!empty($opts['strip_attachments'])) {
$save_msg->buildMimeIds();
/* Don't strip any part if this is a text message with both
* plaintext and HTML representation. */
if ($save_msg->getType() != 'multipart/alternative') {
for ($i = 2;; ++$i) {
if (!($oldPart = $save_msg->getPart($i))) {
break;
}
$replace_part = new Horde_Mime_Part();
$replace_part->setType('text/plain');
$replace_part->setCharset($this->charset);
$replace_part->setLanguage($GLOBALS['language']);
$replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]');
$save_msg->alterPart($i, $replace_part);
}
}
}
/* Generate the message string. */
$fcc = $save_msg->toString(array('defserver' => $imp_imap->config->maildomain, 'headers' => $headers, 'stream' => true));
/* Make sure sent mailbox is created. */
$sent_mail = IMP_Mailbox::get($opts['sent_mail']);
$sent_mail->create();
$flags = array(Horde_Imap_Client::FLAG_SEEN, Horde_Imap_Client::FLAG_MDNSENT);
try {
$imp_imap->append($sent_mail, array(array('data' => $fcc, 'flags' => $flags)));
} catch (IMP_Imap_Exception $e) {
$notification->push(sprintf(_("Message sent successfully, but not saved to %s."), $sent_mail->display));
}
}
/* Delete the attachment data. */
$this->deleteAllAttachments();
/* Save recipients to address book? */
$this->_saveRecipients($recip['list']);
/* Call post-sent hook. */
try {
$injector->getInstance('Horde_Core_Hooks')->callHook('post_sent', 'imp', array($save_msg['msg'], $headers));
} catch (Horde_Exception_HookNotSet $e) {
}
}