<?php
/**
- * The MIME:: class provides methods for dealing with various MIME (see, e.g.,
+ * The Horde_Mime:: class provides methods for dealing with various MIME (see, e.g.,
* RFC 2045) standards.
*
* Copyright 1999-2008 The Horde Project (http://www.horde.org/)
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Michael Slusarz <slusarz@curecanti.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME
+class Horde_Mime
{
/**
* Determines if a string contains 8-bit (non US-ASCII) characters.
return $addresses;
}
- $addresses = Horde_MIME_Address::parseAddressList($addresses, array('defserver' => $defserver, 'nestgroups' => true));
+ $addresses = Horde_Mime_Address::parseAddressList($addresses, array('defserver' => $defserver, 'nestgroups' => true));
if (is_a($addresses, 'PEAR_Error')) {
return $addresses;
}
}
$personal = self::encode($addr['personal'], $charset);
}
- $text .= Horde_MIME_Address::writeAddress($addr['mailbox'], $addr['host'], $personal) . ', ';
+ $text .= Horde_Mime_Address::writeAddress($addr['mailbox'], $addr['host'], $personal) . ', ';
} else {
- $text .= Horde_MIME_Address::writeGroupAddress($addr['groupname'], $addr['addresses']) . ' ';
+ $text .= Horde_Mime_Address::writeGroupAddress($addr['groupname'], $addr['addresses']) . ' ';
}
}
static public function decodeAddrString($string, $to_charset = null)
{
$addr_list = array();
- foreach (Horde_MIME_Address::parseAddressList($string) as $ob) {
+ foreach (Horde_Mime_Address::parseAddressList($string) as $ob) {
$ob['personal'] = isset($ob['personal'])
? self::decode($ob['personal'], $to_charset)
: '';
$addr_list[] = $ob;
}
- return Horde_MIME_Address::addrArray2String($addr_list);
+ return Horde_Mime_Address::addrArray2String($addr_list);
}
/**
*
* @param string A message ID string.
*/
- static public function generateMessageID()
+ static public function generateMessageId()
{
- return '<' . date('YmdHis') . '.' . self::generateRandomID() . '@' . $_SERVER['SERVER_NAME'] . '>';
+ return '<' . date('YmdHis') . '.' . self::generateRandomId() . '@' . $_SERVER['SERVER_NAME'] . '>';
}
/**
*
* @return string A random string.
*/
- static public function generateRandomID()
+ static public function generateRandomId()
{
return base_convert(dechex(strtr(microtime(), array('0.' => '', ' ' => ''))) . uniqid(), 16, 36);
}
+
}
<?php
/**
- * The Horde_MIME_Address:: class provides methods for dealing with email
+ * The Horde_Mime_Address:: class provides methods for dealing with email
* address standards (RFC 822/2822/5322).
*
* Copyright 2008 The Horde Project (http://www.horde.org/)
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_Address
+class Horde_Mime_Address
{
/**
* Builds an RFC compliant email address.
{
/* If the personal name is set, decode it. */
$ob['personal'] = isset($ob['personal'])
- ? Horde_MIME::decode($ob['personal'])
+ ? Horde_Mime::decode($ob['personal'])
: '';
/* If both the mailbox and the host are empty, return an empty string.
/* Ensure we're working with initialized values. */
if (!empty($ob['personal'])) {
- $ob['personal'] = stripslashes(trim(Horde_MIME::decode($ob['personal']), '"'));
+ $ob['personal'] = stripslashes(trim(Horde_Mime::decode($ob['personal']), '"'));
}
$inner = self::writeAddress($ob['mailbox'], $ob['host']);
<?php
/**
- * The Horde_MIME_Headers:: class contains generic functions related to
+ * The Horde_Mime_Headers:: class contains generic functions related to
* handling the headers of mail messages.
*
* Copyright 2002-2008 The Horde Project (http://www.horde.org/)
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_Headers
+class Horde_Mime_Headers
{
/**
* The internal headers array.
foreach (array_keys($val) as $key) {
if (!empty($address_keys)) {
if (in_array($header, $address_keys)) {
- $text = Horde_MIME::encodeAddress($val[$key], $charset, empty($options['defserver']) ? null : $options['defserver']);
+ $text = Horde_Mime::encodeAddress($val[$key], $charset, empty($options['defserver']) ? null : $options['defserver']);
if (is_a($text, 'PEAR_Error')) {
$text = $val[$key];
}
} else {
- $text = Horde_MIME::encode($val[$key], $options['charset']);
+ $text = Horde_Mime::encode($val[$key], $options['charset']);
}
} else {
$text = $val[$key];
*/
public function addMessageIdHeader()
{
- require_once dirname(__FILE__) . '/../MIME.php';
- $this->addHeader('Message-ID', Horde_MIME::generateMessageID());
+ $this->addHeader('Message-ID', Horde_Mime::generateMessageId());
}
/**
*/
public function addResentHeaders($from, $to)
{
- require_once dirname(__FILE__) . '/../MIME.php';
-
/* We don't set Resent-Sender, Resent-Cc, or Resent-Bcc. */
$this->addHeader('Resent-Date', date('r'));
$this->addHeader('Resent-From', $from);
$this->addHeader('Resent-To', $to);
- $this->addHeader('Resent-Message-ID', Horde_MIME::generateMessageID());
+ $this->addHeader('Resent-Message-ID', Horde_Mime::generateMessageId());
}
/**
$ptr = &$this->_headers[$lcHeader];
if ($decode) {
- require_once dirname(__FILE__) . '/../MIME.php';
-
// Fields defined in RFC 2822 that contain address information
if (in_array($lcHeader, $this->addressFields())) {
- $value = Horde_MIME::decodeAddrString($value);
+ $value = Horde_Mime::decodeAddrString($value);
} else {
- $value = Horde_MIME::decode($value);
+ $value = Horde_Mime::decode($value);
}
}
$val = $this->getValue($field);
return is_null($val)
? array()
- : Horde_MIME_Address::parseAddressList($val);
+ : Horde_Mime_Address::parseAddressList($val);
}
/**
}
/**
- * Builds a Horde_MIME_Headers object from header text.
+ * Builds a Horde_Mime_Headers object from header text.
* This function can be called statically:
- * $headers = Horde_MIME_Headers::parseHeaders().
+ * $headers = Horde_Mime_Headers::parseHeaders().
*
* @param string $text A text string containing the headers.
*
- * @return Horde_MIME_Headers A new Horde_MIME_Headers object.
+ * @return Horde_Mime_Headers A new Horde_Mime_Headers object.
*/
static public function parseHeaders($text)
{
- $headers = new Horde_MIME_Headers();
+ $headers = new Horde_Mime_Headers();
$currheader = $currtext = null;
foreach (explode("\n", $text) as $val) {
require_once 'Horde/Util.php';
/**
- * The Horde_MIME_Magic:: class provides an interface to determine a MIME type
+ * The Horde_Mime_Magic:: class provides an interface to determine a MIME type
* for various content, if it provided with different levels of information.
*
* Copyright 1999-2008 The Horde Project (http://www.horde.org/)
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_Magic
+class Horde_Mime_Magic
{
/**
* Returns a copy of the MIME extension map.
*
* @return string The MIME type of the file extension.
*/
- static public function extToMIME($ext)
+ static public function extToMime($ext)
{
if (empty($ext)) {
return 'application/octet-stream';
*
* @return string The MIME type of the filename.
*/
- static public function filenameToMIME($filename, $unknown = true)
+ static public function filenameToMime($filename, $unknown = true)
{
$pos = strlen($filename) + 1;
$type = '';
break;
}
}
- $type = self::extToMIME(substr($filename, $pos));
+ $type = self::extToMime(substr($filename, $pos));
return (empty($type) || (!$unknown && (strpos($type, 'x-extension') !== false)))
? 'application/octet-stream'
*
* @return string The file extension of the MIME type.
*/
- static public function MIMEToExt($type)
+ static public function mimeToExt($type)
{
if (empty($type)) {
return false;
<?php
require_once 'Horde/String.php';
-require_once dirname(__FILE__) . '/../MIME.php';
-require_once dirname(__FILE__) . '/Headers.php';
-require_once dirname(__FILE__) . '/Message.php';
-require_once 'Mail.php';
/**
- * The Horde_MIME_Mail:: class wraps around the various MIME library classes
+ * The Horde_Mime_Mail:: class wraps around the various MIME library classes
* to provide a simple interface for creating and sending MIME messages.
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Jan Schneider <jan@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_Mail
+class Horde_Mime_Mail
{
/**
* The message headers.
*
- * @var Horde_MIME_Headers
+ * @var Horde_Mime_Headers
*/
protected $_headers;
/**
* The main body part.
*
- * @var Horde_MIME_Part
+ * @var Horde_Mime_Part
*/
protected $_body;
/**
* The main HTML body part.
*
- * @var Horde_MIME_Part
+ * @var Horde_Mime_Part
*/
protected $_htmlBody;
$_SERVER['SERVER_NAME'] = php_uname('n');
}
- $this->_headers = new Horde_MIME_Headers();
+ $this->_headers = new Horde_Mime_Headers();
if ($subject) {
$this->addHeader('Subject', $subject, $charset);
* the message's charset will be used when building the message. */
if (!empty($charset)) {
if (in_array($lc_header, $this->_headers->addressFields())) {
- $value = Horde_MIME::encodeAddress($value, $charset);
+ $value = Horde_Mime::encodeAddress($value, $charset);
} else {
- $value = Horde_MIME::encode($value, $charset);
+ $value = Horde_Mime::encode($value, $charset);
}
}
if ($wrap) {
$body = String::wrap($body, $wrap === true ? 76 : $wrap, "\n");
}
- $this->_body = new Horde_MIME_Part('text/plain', $body, $charset);
+ $this->_body = new Horde_Mime_Part('text/plain', $body, $charset);
}
/**
public function setHTMLBody($body, $charset = 'iso-8859-1',
$alternative = true)
{
- $this->_htmlBody = new Horde_MIME_Part('text/html', $body, $charset);
+ $this->_htmlBody = new Horde_Mime_Part('text/html', $body, $charset);
if ($alternative) {
require_once 'Horde/Text/Filter.php';
$body = Text_Filter::filter($body, 'html2text', array('wrap' => false));
- $this->_body = new Horde_MIME_Part('text/plain', $body, $charset);
+ $this->_body = new Horde_Mime_Part('text/plain', $body, $charset);
}
}
public function addPart($mime_type, $content, $charset = 'us-ascii',
$disposition = null)
{
- $part = new Horde_MIME_Part($mime_type, $content, $charset, $disposition);
+ $part = new Horde_Mime_Part($mime_type, $content, $charset, $disposition);
$part->transferEncodeContents();
$this->_parts[] = $part;
return count($this->_parts) - 1;
/**
* Adds a MIME message part.
*
- * @param Horde_MIME_Part $part A Horde_MIME_Part object.
+ * @param Horde_Mime_Part $part A Horde_Mime_Part object.
*
* @return integer The part number.
*/
- public function addMIMEPart($part)
+ public function addMimePart($part)
{
$part->transferEncodeContents();
$this->_parts[] = $part;
}
if (empty($type)) {
require_once dirname(__FILE__) . '/Magic.php';
- $type = Horde_MIME_Magic::filenameToMIME($file, false);
+ $type = Horde_Mime_Magic::filenameToMime($file, false);
}
- $part = new Horde_MIME_Part($type, file_get_contents($file), $charset, 'attachment');
+ $part = new Horde_Mime_Part($type, file_get_contents($file), $charset, 'attachment');
$part->setName($name);
$part->transferEncodeContents();
$this->_parts[] = $part;
protected function _buildRecipients($recipients)
{
if (is_string($recipients)) {
- $recipients = Horde_MIME::explode($recipients, ',');
+ $recipients = Horde_Mime::explode($recipients, ',');
}
$recipients = array_filter(array_map('trim', $recipients));
$addrlist = array();
foreach ($recipients as $email) {
if (!empty($email)) {
- $unique = Horde_MIME::bareAddress($email);
+ $unique = Horde_Mime::bareAddress($email);
if ($unique) {
$addrlist[$unique] = $email;
} else {
}
}
- foreach (Horde_MIME::bareAddress(implode(', ', $addrlist), null, true) as $val) {
- if (Horde_MIME::is8bit($val)) {
+ foreach (Horde_Mime::bareAddress(implode(', ', $addrlist), null, true) as $val) {
+ if (Horde_Mime::is8bit($val)) {
return PEAR::raiseError(sprintf(_("Invalid character in e-mail address: %s."), $val));
}
}
}
/* Build mime message. */
- $mime = new Horde_MIME_Message();
+ $mime = new Horde_Mime_Message();
if (!empty($this->_body) && !empty($this->_htmlBody)) {
- $basepart = new Horde_MIME_Part('multipart/alternative');
+ $basepart = new Horde_Mime_Part('multipart/alternative');
$this->_body->setDescription(_("Plaintext Version of Message"));
$basepart->addPart($this->_body);
$this->_htmlBody->setDescription(_("HTML Version of Message"));
<?php
/**
- * The Horde_MIME_MDN:: class implements Message Disposition Notifications as
+ * The Horde_Mime_Mdn:: class implements Message Disposition Notifications as
* described by RFC 3798.
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_MDN
+class Horde_Mime_Mdn
{
/**
- * The Horde_MIME_Headers object.
+ * The Horde_Mime_Headers object.
*
- * @var Horde_MIME_Headers
+ * @var Horde_Mime_Headers
*/
protected $_headers;
/**
* Constructor.
*
- * @param Horde_MIME_Headers $mime_headers A Horde_MIME_Headers object.
+ * @param Horde_Mime_Headers $mime_headers A Horde_Mime_Headers object.
*/
function __construct($headers = null)
{
* @return string The address to send the MDN to. Returns null if no
* MDN is requested.
*/
- public function getMDNReturnAddr()
+ public function getMdnReturnAddr()
{
/* RFC 3798 [2.1] requires the Disposition-Notificaion-To header
* for an MDN to be created. */
/* RFC 3798 [2.1]: Explicit confirmation is needed if there is more
* than one distinct address in the Disposition-Notification-To
* header. */
- $addr_arr = Horde_MIME_Address::parseAddressList($this->getMDNReturnAddr());
+ $addr_arr = Horde_Mime_Address::parseAddressList($this->getMdnReturnAddr());
if (count($addr_arr) > 1) {
return true;
}
* from the address in the Return-Path header." This comparison is
* case-sensitive for the mailbox part and case-insensitive for the
* host part. */
- $ret_arr = Horde_MIME_Address::parseAddressList($return_path);
+ $ret_arr = Horde_Mime_Address::parseAddressList($return_path);
return ($addr_arr[0]['mailbox'] == $ret_arr[0]['mailbox']) &&
(String::lower($addr_arr[0]['host']) == String::lower($ret_arr[0]['host']));
}
$identity = &Identity::singleton();
$from_addr = $identity->getDefaultFromAddress();
- $to = $this->getMDNReturnAddr();
+ $to = $this->getMdnReturnAddr();
$ua = $this->_headers->getAgentHeader();
$orig_recip = $this->_headers->getValue('Original-Recipient');
}
/* Set up the mail headers. */
- $msg_headers = new Horde_MIME_Headers();
+ $msg_headers = new Horde_Mime_Headers();
$msg_headers->addMessageIdHeader();
$msg_headers->addAgentHeader($ua);
$msg_headers->addHeader('Date', date('r'));
$msg_headers->addHeader('From', $from_addr);
- $msg_headers->addHeader('To', $this->getMDNReturnAddr());
+ $msg_headers->addHeader('To', $this->getMdnReturnAddr());
$msg_headers->addHeader('Subject', _("Disposition Notification"));
/* MDNs are a subtype of 'multipart/report'. */
- $msg = new Horde_MIME_Message();
+ $msg = new Horde_Mime_Message();
$msg->setType('multipart/report');
$msg->setContentTypeParameter('report-type', 'disposition-notification');
$charset = NLS::getCharset();
/* The first part is a human readable message. */
- $part_one = new Horde_MIME_Part('text/plain');
+ $part_one = new Horde_Mime_Part('text/plain');
$part_one->setCharset($charset);
if ($type == 'displayed') {
$contents = sprintf(_("The message sent on %s to %s with subject \"%s\" has been displayed.\n\nThis is no guarantee that the message has been read or understood."), $this->_headers->getValue('Date'), $this->_headers->getValue('To'), $this->_headers->getValue('Subject'));
$msg->addPart($part_one);
/* The second part is a machine-parseable description. */
- $part_two = new Horde_MIME_Part('message/disposition-notification');
+ $part_two = new Horde_Mime_Part('message/disposition-notification');
$part_two->setContents('Reporting-UA: ' . $GLOBALS['conf']['server']['name'] . '; ' . $ua . "\n");
if (!empty($orig_recip)) {
$part_two->appendContents('Original-Recipient: rfc822;' . $orig_recip . "\n");
/* The third part is the text of the original message. RFC 3798 [3]
* allows us to return only a portion of the entire message - this
* is left up to the user. */
- $part_three = new Horde_MIME_Part('message/rfc822');
+ $part_three = new Horde_Mime_Part('message/rfc822');
$part_three->setContents($this->_headers->toString());
if (!empty($this->_msgtext)) {
$part_three->appendContents($part_three->getEOL() . $this->_msgtext);
}
/**
- * Add a MDN (read receipt) request headers to the Horde_MIME_Headers::
+ * Add a MDN (read receipt) request headers to the Horde_Mime_Headers::
* object.
*
- * @param Horde_MIME_Headers &$ob The object to add the headers to.
+ * @param Horde_Mime_Headers $ob The object to add the headers to.
* @param string $to The address the receipt should be
* mailed to.
*/
- public function addMDNRequestHeaders(&$ob, $to)
+ public function addMdnRequestHeaders($ob, $to)
{
/* This is the RFC 3798 way of requesting a receipt. */
$ob->addHeader('Disposition-Notification-To', $to);
}
+
}
<?php
-
-require_once dirname(__FILE__) . '/Part.php';
-
/**
- * The Horde_MIME_Message:: class provides methods for creating and
+ * The Horde_Mime_Message:: class provides methods for creating and
* manipulating MIME email messages.
*
- * $Horde: framework/MIME/MIME/Message.php,v 1.107 2008/10/17 05:41:59 slusarz Exp $
- *
* Copyright 1999-2008 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_Message extends Horde_MIME_Part
+class Horde_Mime_Message extends Horde_Mime_Part
{
/**
- * Create a Horde_MIME_Message object from a Horde_MIME_Part object.
+ * Create a Horde_Mime_Message object from a Horde_Mime_Part object.
* This function can be called statically via:
- * $mime_message = Horde_MIME_Message::convertMIMEPart();
+ * $mime_message = Horde_Mime_Message::convertMimePart();
*
* @todo Is this needed?
*
- * @param Horde_MIME_Part $mime_part The Horde_MIME_Part object.
+ * @param Horde_Mime_Part $mime_part The Horde_Mime_Part object.
*
- * @return Horde_MIME_Message The new Horde_MIME_Message object.
+ * @return Horde_Mime_Message The new Horde_Mime_Message object.
*/
- static public function convertMIMEPart($mime_part)
+ static public function convertMimePart($mime_part)
{
- if (!$mime_part->getMIMEId()) {
- $mime_part->setMIMEId(1);
+ if (!$mime_part->getMimeId()) {
+ $mime_part->setMimeId(1);
}
- $mime_message = new Horde_MIME_Message();
+ $mime_message = new Horde_Mime_Message();
$mime_message->addPart($mime_part);
return $mime_message;
* Sends this message.
*
* @param string $email The address list to send to.
- * @param Horde_MIME_Headers $headers The Horde_MIME_Headers object
+ * @param Horde_Mime_Headers $headers The Horde_Mime_Headers object
* holding this message's headers.
* @param string $driver The Mail:: driver to use.
* @param array $params Any parameters necessary for the
/* Add MIME Headers if they don't already exist. */
if (!$headers->getValue('MIME-Version')) {
- $headers = $this->addMIMEHeaders($headers);
+ $headers = $this->addMimeHeaders($headers);
}
$headerArray = $headers->toArray($this->getCharset());
$msg .= "\n";
}
- $result = $mailer->send(Horde_MIME::encodeAddress($email), $headerArray, $msg);
+ $result = $mailer->send(Horde_Mime::encodeAddress($email), $headerArray, $msg);
if (is_a($result, 'PEAR_Error') && ($driver == 'sendmail')) {
- $error = Horde_MIME_Mail::sendmailError($result->getCode());
+ $error = Horde_Mime_Mail::sendmailError($result->getCode());
if (is_null($error)) {
$error = $result;
$userinfo = null;
}
/**
- * Parse an array of MIME structure information into a Horde_MIME_Message
+ * Parse an array of MIME structure information into a Horde_Mime_Message
* object.
* This function can be called statically via:
- * $mime_message = Horde_MIME_Message::parseStructure();
+ * $mime_message = Horde_Mime_Message::parseStructure();
*
* @param array $structure An array of structure information in the
* following format:
* 'md5' - [OPTIONAL] (string) The part's MD5 value.
* </pre>
*
- * @return object A Horde_MIME_Message object.
+ * @return object A Horde_Mime_Message object.
*/
static public function parseStructure($structure)
{
$ob = self::_parseStructure($structure, true);
- $ob->buildMIMEIds();
+ $ob->buildMimeIds();
return $ob;
}
/**
* Parse a subpart of a MIME message into a
- * Horde_MIME_Message/Horde_MIME_Part object.
+ * Horde_Mime_Message/Horde_Mime_Part object.
*
* @param array $data Structure information in the format described
* in parseStructure().
* @param boolean $rfc822 Force the part to be treated as a
* message/rfc822 part.
*
- * @return mixed Returns either a Horde_MIME_Message or a Horde_MIME_Part
+ * @return mixed Returns either a Horde_Mime_Message or a Horde_Mime_Part
* object, depending on the part's MIME type.
*/
static protected function _parseStructure($data, $rfc822 = false)
$type = $data['type'] . '/' . $data['subtype'];
if ($rfc822 || ($type == 'message/rfc822')) {
- $ob = new Horde_MIME_Message();
+ $ob = new Horde_Mime_Message();
} else {
- $ob = new Horde_MIME_Part();
+ $ob = new Horde_Mime_Part();
}
$ob->setType($type);
}
if (isset($data['id'])) {
- $ob->setContentID($data['id']);
+ $ob->setContentId($data['id']);
}
if (!empty($data['parameters'])) {
}
/**
- * Attempts to build a Horde_MIME_Message object from message text.
+ * Attempts to build a Horde_Mime_Message object from message text.
* This function can be called statically via:
- * $mime_message = Horde_MIME_Message::parseMessage();
+ * $mime_message = Horde_Mime_Message::parseMessage();
*
* @param string $text The text of the MIME message.
*
- * @return Horde_MIME_Message A Horde_MIME_Message object, or false on
+ * @return Horde_Mime_Message A Horde_Mime_Message object, or false on
* error.
*/
static public function parseMessage($text)
);
require_once 'Mail/mimeDecode.php';
- $mimeDecode = new Mail_mimeDecode($text, Horde_MIME_Part::EOL);
+ $mimeDecode = new Mail_mimeDecode($text, Horde_Mime_Part::EOL);
if (!($ob = $mimeDecode->decode($decode_args))) {
return false;
}
return $part;
}
+
}
require_once dirname(__FILE__) . '/../MIME.php';
/**
- * The Horde_MIME_Part:: class provides a wrapper around MIME parts and
+ * The Horde_Mime_Part:: class provides a wrapper around MIME parts and
* methods for dealing with them.
*
* Copyright 1999-2008 The Horde Project (http://www.horde.org/)
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_Part
+class Horde_Mime_Part
{
/* The character(s) used internally for EOLs. */
const EOL = "\n";
protected $_flags = array();
/**
- * Unique Horde_MIME_Part boundary string.
+ * Unique Horde_Mime_Part boundary string.
*
* @var string
*/
*/
public function setDispositionParameter($label, $data)
{
- $this->_dispParams[$label] = Horde_MIME::decode($data);
+ $this->_dispParams[$label] = Horde_Mime::decode($data);
}
/**
*/
public function setDescription($description)
{
- $this->_description = Horde_MIME::decode($description);
+ $this->_description = Horde_Mime::decode($description);
}
/**
/**
* Add a MIME subpart.
*
- * @param Horde_MIME_Part $mime_part Add a subpart to the current object.
+ * @param Horde_Mime_Part $mime_part Add a subpart to the current object.
*/
public function addPart($mime_part)
{
/**
* Get a list of all MIME subparts.
*
- * @return array An array of the Horde_MIME_Part subparts.
+ * @return array An array of the Horde_Mime_Part subparts.
*/
public function getParts()
{
*
* @param string $id The MIME ID.
*
- * @return Horde_MIME_Part A pointer to the part requested, or null if
+ * @return Horde_Mime_Part A pointer to the part requested, or null if
* the part doesn't exist.
*/
public function &getPart($id)
{
- $this_id = $this->getMIMEId();
+ $this_id = $this->getMimeId();
if ($id == $this_id) {
return $this;
}
if ($this->_reindex) {
- $this->buildMIMEIds(is_null($this_id) ? '1' : $this_id);
+ $this->buildMimeIds(is_null($this_id) ? '1' : $this_id);
}
return $this->_partFind($id, $this->_parts);
* Alter a current MIME subpart.
*
* @param string $id The MIME part ID to alter.
- * @param Horde_MIME_Part $mime_part The MIME part to store.
+ * @param Horde_Mime_Part $mime_part The MIME part to store.
*/
public function alterPart($id, $mime_part)
{
* Function used to find a specific MIME part by ID.
*
* @param string $id The MIME ID.
- * @param array &$parts A list of Horde_MIME_Part objects.
+ * @param array &$parts A list of Horde_Mime_Part objects.
*/
protected function &_partFind($id, &$parts)
{
}
/**
- * Returns a Horde_MIME_Header object containing all MIME headers needed
+ * Returns a Horde_Mime_Header object containing all MIME headers needed
* for the part.
*
- * @param Horde_MIME_Headers $headers The Horde_MIME_Headers object to
+ * @param Horde_Mime_Headers $headers The Horde_Mime_Headers object to
* add the MIME headers to. If not
* specified, adds the headers to a
* new object.
*
- * @return Horde_MIME_Headers A Horde_MIME_Headers object.
+ * @return Horde_Mime_Headers A Horde_Mime_Headers object.
*/
- public function addMIMEHeaders($headers = null)
+ public function addMimeHeaders($headers = null)
{
if (is_null($headers)) {
- $headers = new Horde_MIME_Headers();
+ $headers = new Horde_Mime_Headers();
}
foreach ($this->getHeaderArray() as $key => $val) {
$ctype = $this->getType(true);
/* Manually encode Content-Type and Disposition parameters in here,
- * rather than in Horde_MIME_Headers, since it is easier to do when
+ * rather than in Horde_Mime_Headers, since it is easier to do when
* the paramters are broken down. Encoding in the headers object will
* ignore these headers Since they will already be in 7bit. */
foreach ($this->getAllContentTypeParameters() as $key => $value) {
continue;
}
- $encode_2231 = Horde_MIME::encodeParamString($key, $value, $charset);
+ $encode_2231 = Horde_Mime::encodeParamString($key, $value, $charset);
/* Try to work around non RFC 2231-compliant MUAs by sending both
* a RFC 2047-like parameter name and then the correct RFC 2231
* parameter. See:
* http://lists.horde.org/archives/dev/Week-of-Mon-20040426/014240.html */
if (!empty($GLOBALS['conf']['mailformat']['brokenrfc2231']) &&
(strpos($encode_2231, '*=') !== false)) {
- $ctype .= '; ' . $key . '="' . Horde_MIME::encode($value, $charset) . '"';
+ $ctype .= '; ' . $key . '="' . Horde_Mime::encode($value, $charset) . '"';
}
$ctype .= '; ' . $encode_2231;
}
/* Add any disposition parameter information, if available. */
if (!empty($name)) {
- $encode_2231 = Horde_MIME::encodeParamString('filename', $name, $charset);
+ $encode_2231 = Horde_Mime::encodeParamString('filename', $name, $charset);
/* Same broken RFC 2231 workaround as above. */
if (!empty($GLOBALS['conf']['mailformat']['brokenrfc2231']) &&
(strpos($encode_2231, '*=') !== false)) {
- $disp .= '; filename="' . Horde_MIME::encode($name, $charset) . '"';
+ $disp .= '; filename="' . Horde_Mime::encode($name, $charset) . '"';
}
$disp .= '; ' . $encode_2231;
}
$text = '';
if ($headers) {
- $hdr_ob = $this->addMIMEHeaders();
+ $hdr_ob = $this->addMimeHeaders();
$hdr_ob->setEOL($eol);
$text = $hdr_ob->toString(array('charset' => $this->getCharset()));
}
break;
case 'text':
- if (Horde_MIME::is8bit($this->_contents)) {
+ if (Horde_Mime::is8bit($this->_contents)) {
$encoding = ($this->_encode7bit) ? 'quoted-printable' : '8bit';
} elseif (preg_match("/(?:\n|^)[^\n]{999,}(?:\n|$)/", $this->_contents)) {
/* If the text is longer than 998 characters between
break;
default:
- if (Horde_MIME::is8bit($this->_contents)) {
+ if (Horde_Mime::is8bit($this->_contents)) {
$encoding = ($this->_encode7bit) ? 'base64' : '8bit';
}
break;
/* Quoted-Printable Encoding: See RFC 2045, section 6.7 */
case 'quoted-printable':
- $output = Horde_MIME::quotedPrintableEncode($this->_contents, $eol);
+ $output = Horde_Mime::quotedPrintableEncode($this->_contents, $eol);
if (($eollength = String::length($eol)) &&
(substr($output, $eollength * -1) == $eol)) {
return substr($output, 0, $eollength * -1);
case 'quoted-printable':
$message = preg_replace("/=\r?\n/", '', $this->_contents);
$message = quoted_printable_decode($this->replaceEOL($message));
- $this->_flags['lastTransferDecode'] = (Horde_MIME::is8bit($message)) ? '8bit' : '7bit';
+ $this->_flags['lastTransferDecode'] = (Horde_Mime::is8bit($message)) ? '8bit' : '7bit';
return $message;
/* Support for uuencoded encoding - although not required by RFCs,
* be returned (via getBytes()) if there are no contents currently set.
* This function is useful for setting the size of the part when the
* contents of the part are not fully loaded (i.e. creating a
- * Horde_MIME_Part object from IMAP header information without loading the
+ * Horde_Mime_Part object from IMAP header information without loading the
* data of the part).
*
* @param integer $bytes The size of this part in bytes.
* Key - MIME ID
* Value - CID for the part
*/
- public function addCID($cids = array())
+ public function addCid($cids = array())
{
$this->_cids += $cids;
asort($this->_cids, SORT_STRING);
* @param string $cid Use this CID (if not already set). Else, generate
* a random CID.
*/
- public function setContentID($cid = null)
+ public function setContentId($cid = null)
{
if (is_null($this->_contentid)) {
- $this->_contentid = (is_null($cid)) ? (Horde_MIME::generateRandomID() . '@' . $_SERVER['SERVER_NAME']) : $cid;
+ $this->_contentid = (is_null($cid)) ? (Horde_Mime::generateRandomId() . '@' . $_SERVER['SERVER_NAME']) : $cid;
}
return $this->_contentid;
}
*
* @return string The Content-ID for this part.
*/
- public function getContentID()
+ public function getContentId()
{
return $this->_contentid;
}
*
* @param string $mimeid The MIME ID.
*/
- public function setMIMEId($mimeid)
+ public function setMimeId($mimeid)
{
$this->_mimeid = $mimeid;
}
*
* @return string The MIME ID.
*/
- public function getMIMEId()
+ public function getMimeId()
{
return $this->_mimeid;
}
*
* @param string $id The ID of this part.
*/
- public function buildMIMEIds($id = null)
+ public function buildMimeIds($id = null)
{
if (is_null($id)) {
if (empty($this->_parts)) {
- $this->setMIMEId('1');
+ $this->setMimeId('1');
} else {
- $this->setMIMEId('0');
+ $this->setMimeId('0');
$i = 1;
foreach (array_keys($this->_parts) as $val) {
- $this->_parts[$val]->buildMIMEIds($i++);
+ $this->_parts[$val]->buildMimeIds($i++);
}
}
} else {
- $this->setMIMEId($id . (($this->getType() == 'message/rfc822') ? '.0' : ''));
+ $this->setMimeId($id . (($this->getType() == 'message/rfc822') ? '.0' : ''));
if (!empty($this->_parts)) {
$i = 1;
foreach (array_keys($this->_parts) as $val) {
- $this->_parts[$val]->buildMIMEIds($id . '.' . $i++);
+ $this->_parts[$val]->buildMimeIds($id . '.' . $i++);
}
}
}
protected function _generateBoundary()
{
if (is_null($this->_boundary)) {
- $this->_boundary = '=_' . Horde_MIME::generateRandomID();
+ $this->_boundary = '=_' . Horde_Mime::generateRandomId();
}
return $this->_boundary;
}
*/
public function contentTypeMap($sort = true)
{
- $map = array($this->getMIMEId() => $this->getType());
+ $map = array($this->getMimeId() => $this->getType());
foreach ($this->_parts as $val) {
$map += $val->contentTypeMap(false);
}
return $map;
}
+
}
<?php
/**
- * The Horde_MIME_Viewer:: class provides an abstracted interface to render
+ * The Horde_Mime_Viewer:: class provides an abstracted interface to render
* MIME data into various formats. It depends on both a set of
- * Horde_MIME_Viewer_* drivers which handle the actual rendering, and a
+ * Horde_Mime_Viewer_* drivers which handle the actual rendering, and a
* configuration file to map MIME types to drivers.
*
* Copyright 1999-2008 The Horde Project (http://www.horde.org/)
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_MIME
+ * @package Horde_Mime
*/
-class Horde_MIME_Viewer
+class Horde_Mime_Viewer
{
/**
* The config array. This array is shared between all instances of
- * Horde_MIME_Viewer.
+ * Horde_Mime_Viewer.
*
* @var array
*/
static protected $_drivercache = array();
/**
- * Attempts to return a concrete Horde_MIME_Viewer_* object based on the
+ * Attempts to return a concrete Horde_Mime_Viewer_* object based on the
* MIME type.
*
* @param string $mime_type The MIME type.
*
- * @return Horde_MIME_Viewer The Horde_MIME_Viewer object, or false on
+ * @return Horde_Mime_Viewer The Horde_Mime_Viewer object, or false on
* error.
*/
static final public function factory($mime_type)
self::$_drivercache[$sig] = array(
'app' => $app,
- 'class' => (($app == 'horde') ? '' : $app . '_') . 'Horde_MIME_Viewer_' . $driver,
+ 'class' => (($app == 'horde') ? '' : $app . '_') . 'Horde_Mime_Viewer_' . $driver,
'driver' => $driver,
'exact' => $exact,
);
{
$file = ($app == 'horde')
? dirname(__FILE__) . '/Viewer/' . $driver . '.php'
- : $GLOBALS['registry']->applications[$app]['fileroot'] . '/lib/MIME/Viewer/' . $driver . '.php';
+ : $GLOBALS['registry']->applications[$app]['fileroot'] . '/lib/Mime/Viewer/' . $driver . '.php';
require_once dirname(__FILE__) . '/Viewer/Driver.php';