MIME -> Mime, other camelcasing in functions, autoload what we can, other tweaks
authorChuck Hagenbuch <chuck@horde.org>
Sun, 9 Nov 2008 04:45:57 +0000 (23:45 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 9 Nov 2008 04:45:57 +0000 (23:45 -0500)
framework/Mime/lib/Horde/Mime.php
framework/Mime/lib/Horde/Mime/Address.php
framework/Mime/lib/Horde/Mime/Headers.php
framework/Mime/lib/Horde/Mime/Magic.php
framework/Mime/lib/Horde/Mime/Mail.php
framework/Mime/lib/Horde/Mime/Mdn.php
framework/Mime/lib/Horde/Mime/Message.php
framework/Mime/lib/Horde/Mime/Part.php
framework/Mime/lib/Horde/Mime/Viewer.php

index 9569c78..46195ef 100644 (file)
@@ -1,6 +1,6 @@
 <?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/)
@@ -10,9 +10,9 @@
  *
  * @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.
@@ -190,7 +190,7 @@ class Horde_MIME
                 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;
             }
@@ -209,9 +209,9 @@ class Horde_MIME
                     }
                     $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']) . ' ';
             }
         }
 
@@ -301,14 +301,14 @@ class Horde_MIME
     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);
     }
 
     /**
@@ -425,9 +425,9 @@ class Horde_MIME
      *
      * @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'] . '>';
     }
 
     /**
@@ -436,8 +436,9 @@ class Horde_MIME
      *
      * @return string  A random string.
      */
-    static public function generateRandomID()
+    static public function generateRandomId()
     {
         return base_convert(dechex(strtr(microtime(), array('0.' => '', ' ' => ''))) . uniqid(), 16, 36);
     }
+
 }
index 1ca31fd..fe9a983 100644 (file)
@@ -1,6 +1,6 @@
 <?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/)
@@ -10,9 +10,9 @@
  *
  * @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.
@@ -150,7 +150,7 @@ class Horde_MIME_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.
@@ -256,7 +256,7 @@ class Horde_MIME_Address
 
             /* 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']);
index 164f7de..b8df2c8 100644 (file)
@@ -1,6 +1,6 @@
 <?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/)
@@ -9,9 +9,9 @@
  * 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.
@@ -66,12 +66,12 @@ class Horde_MIME_Headers
             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];
@@ -172,8 +172,7 @@ class Horde_MIME_Headers
      */
     public function addMessageIdHeader()
     {
-        require_once dirname(__FILE__) . '/../MIME.php';
-        $this->addHeader('Message-ID', Horde_MIME::generateMessageID());
+        $this->addHeader('Message-ID', Horde_Mime::generateMessageId());
     }
 
     /**
@@ -185,13 +184,11 @@ class Horde_MIME_Headers
      */
     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());
     }
 
     /**
@@ -246,13 +243,11 @@ class Horde_MIME_Headers
         $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);
             }
         }
 
@@ -442,7 +437,7 @@ class Horde_MIME_Headers
         $val = $this->getValue($field);
         return is_null($val)
             ? array()
-            : Horde_MIME_Address::parseAddressList($val);
+            : Horde_Mime_Address::parseAddressList($val);
     }
 
     /**
@@ -506,17 +501,17 @@ class Horde_MIME_Headers
     }
 
     /**
-     * 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) {
index ef93b45..0b6b633 100644 (file)
@@ -3,7 +3,7 @@
 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/)
@@ -13,9 +13,9 @@ require_once 'Horde/Util.php';
  *
  * @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.
@@ -61,7 +61,7 @@ class Horde_MIME_Magic
      *
      * @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';
@@ -94,7 +94,7 @@ class Horde_MIME_Magic
      *
      * @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 = '';
@@ -106,7 +106,7 @@ class Horde_MIME_Magic
                 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'
@@ -123,7 +123,7 @@ class Horde_MIME_Magic
      *
      * @return string  The file extension of the MIME type.
      */
-    static public function MIMEToExt($type)
+    static public function mimeToExt($type)
     {
         if (empty($type)) {
             return false;
index 289fc9a..3482056 100644 (file)
@@ -1,13 +1,9 @@
 <?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/)
@@ -16,28 +12,28 @@ require_once 'Mail.php';
  * 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;
 
@@ -88,7 +84,7 @@ class Horde_MIME_Mail
             $_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);
@@ -141,9 +137,9 @@ class Horde_MIME_Mail
          * 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);
             }
         }
 
@@ -195,7 +191,7 @@ class Horde_MIME_Mail
         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);
     }
 
     /**
@@ -211,11 +207,11 @@ class Horde_MIME_Mail
     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);
         }
     }
 
@@ -232,7 +228,7 @@ class Horde_MIME_Mail
     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;
@@ -241,11 +237,11 @@ class Horde_MIME_Mail
     /**
      * 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;
@@ -271,10 +267,10 @@ class Horde_MIME_Mail
         }
         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;
@@ -346,14 +342,14 @@ class Horde_MIME_Mail
     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 {
@@ -362,8 +358,8 @@ class Horde_MIME_Mail
             }
         }
 
-        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));
             }
         }
@@ -413,9 +409,9 @@ class Horde_MIME_Mail
         }
 
         /* 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"));
index d567c88..b2acc85 100644 (file)
@@ -1,6 +1,6 @@
 <?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/)
@@ -9,14 +9,14 @@
  * 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;
 
@@ -30,7 +30,7 @@ class Horde_MIME_MDN
     /**
      * 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)
     {
@@ -43,7 +43,7 @@ class Horde_MIME_MDN
      * @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. */
@@ -74,7 +74,7 @@ class Horde_MIME_MDN
         /* 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;
         }
@@ -84,7 +84,7 @@ class Horde_MIME_MDN
          * 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']));
     }
@@ -141,7 +141,7 @@ class Horde_MIME_MDN
         $identity = &Identity::singleton();
         $from_addr = $identity->getDefaultFromAddress();
 
-        $to = $this->getMDNReturnAddr();
+        $to = $this->getMdnReturnAddr();
         $ua = $this->_headers->getAgentHeader();
 
         $orig_recip = $this->_headers->getValue('Original-Recipient');
@@ -163,23 +163,23 @@ class Horde_MIME_MDN
         }
 
         /* 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'));
@@ -194,7 +194,7 @@ class Horde_MIME_MDN
         $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");
@@ -212,7 +212,7 @@ class Horde_MIME_MDN
         /* 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);
@@ -223,16 +223,17 @@ class Horde_MIME_MDN
     }
 
     /**
-     * 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);
     }
+
 }
index 6844080..a07e1eb 100644 (file)
@@ -1,13 +1,8 @@
 <?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
@@ -15,28 +10,28 @@ require_once dirname(__FILE__) . '/Part.php';
  *
  * @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;
@@ -46,7 +41,7 @@ class Horde_MIME_Message extends Horde_MIME_Part
      * 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
@@ -66,7 +61,7 @@ class Horde_MIME_Message extends Horde_MIME_Part
 
         /* 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());
 
@@ -100,10 +95,10 @@ class Horde_MIME_Message extends Horde_MIME_Part
             $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;
@@ -128,10 +123,10 @@ class Horde_MIME_Message extends Horde_MIME_Part
     }
 
     /**
-     * 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:
@@ -177,25 +172,25 @@ class Horde_MIME_Message extends Horde_MIME_Part
      * '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)
@@ -203,9 +198,9 @@ class Horde_MIME_Message extends Horde_MIME_Part
         $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);
@@ -228,7 +223,7 @@ class Horde_MIME_Message extends Horde_MIME_Part
         }
 
         if (isset($data['id'])) {
-            $ob->setContentID($data['id']);
+            $ob->setContentId($data['id']);
         }
 
         if (!empty($data['parameters'])) {
@@ -270,13 +265,13 @@ class Horde_MIME_Message extends Horde_MIME_Part
     }
 
     /**
-     * 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)
@@ -289,7 +284,7 @@ class Horde_MIME_Message extends Horde_MIME_Part
         );
 
         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;
         }
@@ -381,4 +376,5 @@ class Horde_MIME_Message extends Horde_MIME_Part
 
         return $part;
     }
+
 }
index 6af6251..be72bb2 100644 (file)
@@ -4,7 +4,7 @@ require_once 'Horde/String.php';
 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/)
@@ -14,9 +14,9 @@ require_once dirname(__FILE__) . '/../MIME.php';
  *
  * @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";
@@ -148,7 +148,7 @@ class Horde_MIME_Part
     protected $_flags = array();
 
     /**
-     * Unique Horde_MIME_Part boundary string.
+     * Unique Horde_Mime_Part boundary string.
      *
      * @var string
      */
@@ -213,7 +213,7 @@ class Horde_MIME_Part
      */
     public function setDispositionParameter($label, $data)
     {
-        $this->_dispParams[$label] = Horde_MIME::decode($data);
+        $this->_dispParams[$label] = Horde_Mime::decode($data);
     }
 
     /**
@@ -505,7 +505,7 @@ class Horde_MIME_Part
      */
     public function setDescription($description)
     {
-        $this->_description = Horde_MIME::decode($description);
+        $this->_description = Horde_Mime::decode($description);
     }
 
     /**
@@ -552,7 +552,7 @@ class Horde_MIME_Part
     /**
      * 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)
     {
@@ -563,7 +563,7 @@ class Horde_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()
     {
@@ -575,18 +575,18 @@ class Horde_MIME_Part
      *
      * @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);
@@ -609,7 +609,7 @@ class Horde_MIME_Part
      * 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)
     {
@@ -623,7 +623,7 @@ class Horde_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)
     {
@@ -707,20 +707,20 @@ class Horde_MIME_Part
     }
 
     /**
-     * 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) {
@@ -747,7 +747,7 @@ class Horde_MIME_Part
         $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) {
@@ -757,14 +757,14 @@ class Horde_MIME_Part
                 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;
         }
@@ -797,11 +797,11 @@ class Horde_MIME_Part
 
             /* 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;
             }
@@ -834,7 +834,7 @@ class Horde_MIME_Part
         $text = '';
 
         if ($headers) {
-            $hdr_ob = $this->addMIMEHeaders();
+            $hdr_ob = $this->addMimeHeaders();
             $hdr_ob->setEOL($eol);
             $text = $hdr_ob->toString(array('charset' => $this->getCharset()));
         }
@@ -922,7 +922,7 @@ class Horde_MIME_Part
             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
@@ -934,7 +934,7 @@ class Horde_MIME_Part
             break;
 
         default:
-            if (Horde_MIME::is8bit($this->_contents)) {
+            if (Horde_Mime::is8bit($this->_contents)) {
                 $encoding = ($this->_encode7bit) ? 'base64' : '8bit';
             }
             break;
@@ -995,7 +995,7 @@ class Horde_MIME_Part
 
         /* 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);
@@ -1031,7 +1031,7 @@ class Horde_MIME_Part
         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,
@@ -1164,7 +1164,7 @@ class Horde_MIME_Part
      * 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.
@@ -1197,7 +1197,7 @@ class Horde_MIME_Part
      *                     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);
@@ -1219,10 +1219,10 @@ class Horde_MIME_Part
      * @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;
     }
@@ -1232,7 +1232,7 @@ class Horde_MIME_Part
      *
      * @return string  The Content-ID for this part.
      */
-    public function getContentID()
+    public function getContentId()
     {
         return $this->_contentid;
     }
@@ -1242,7 +1242,7 @@ class Horde_MIME_Part
      *
      * @param string $mimeid  The MIME ID.
      */
-    public function setMIMEId($mimeid)
+    public function setMimeId($mimeid)
     {
         $this->_mimeid = $mimeid;
     }
@@ -1252,7 +1252,7 @@ class Horde_MIME_Part
      *
      * @return string  The MIME ID.
      */
-    public function getMIMEId()
+    public function getMimeId()
     {
         return $this->_mimeid;
     }
@@ -1262,25 +1262,25 @@ class Horde_MIME_Part
      *
      * @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++);
                 }
             }
         }
@@ -1296,7 +1296,7 @@ class Horde_MIME_Part
     protected function _generateBoundary()
     {
         if (is_null($this->_boundary)) {
-            $this->_boundary = '=_' . Horde_MIME::generateRandomID();
+            $this->_boundary = '=_' . Horde_Mime::generateRandomId();
         }
         return $this->_boundary;
     }
@@ -1310,7 +1310,7 @@ class Horde_MIME_Part
      */
     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);
         }
@@ -1321,4 +1321,5 @@ class Horde_MIME_Part
 
         return $map;
     }
+
 }
index cfc47fc..4772d90 100644 (file)
@@ -1,8 +1,8 @@
 <?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
      */
@@ -32,12 +32,12 @@ class Horde_MIME_Viewer
     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)
@@ -158,7 +158,7 @@ class Horde_MIME_Viewer
 
         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,
         );
@@ -179,7 +179,7 @@ class Horde_MIME_Viewer
     {
         $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';