Class MIME_Part

Description

The MIME_Part:: class provides a wrapper around MIME parts and methods for dealing with them.

$Horde: framework/MIME/MIME/Part.php,v 1.177.4.30 2010/07/07 23:27:51 slusarz Exp $

Copyright 1999-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /MIME/MIME/Part.php (line 54)


	
			
Direct descendents
Class Description
 class MIME_Message The MIME_Message:: class provides methods for creating and manipulating MIME email messages.
Variable Summary
 string $_boundary
 integer $_bytes
 array $_cids
 string $_contentid
 string $_contents
 string $_description
 string $_disposition
 boolean $_encode7bit
 string $_eol
 array $_flags
 array $_idmap
 string $_mimeid
 array $_parts
 string $_subtype
 string $_type
Method Summary
 MIME_Part MIME_Part ([string $mimetype = null], [string $contents = null], [string $charset = MIME_DEFAULT_CHARSET], [string $disposition = null], [string $encoding = null])
 void addCID ([array $cids = array()])
 void addPart (MIME_Part $mime_part, [string $index = null])
 void alterPart (string $id, MIME_Part $mime_part)
 void appendContents (string $contents, [string $encoding = null])
 void clearContents ()
 void clearContentTypeParameter (string $label, string $data)
 array contentTypeMap ()
 integer getBytes ()
 string getCharset ()
 array getCIDList ()
 string getContentID ()
 string getContents ()
 string getContentTypeParameter (string $label)
 string getCurrentEncoding ()
 string getDefaultType ()
 string getDescription ([boolean $decode = false], [boolean $default = false])
 string getDisposition ()
 string getDispositionParameter (string $label)
 string getEOL ()
 mixed getInformation (string $label)
 string getMIMEId ()
 string getName ([boolean $decode = false], [boolean $default = false])
 MIME_Part getPart (string $id)
 array getParts ()
 string getPrimaryType ()
 string getRelativeMIMEId (string $id)
 string getSize ()
 string getSubType ()
 string getType ([boolean $charset = false])
 string getUniqueID ()
 array header ([array $headers = array()])
 void removePart (string $id)
 string replaceEOL (string $text, [string $eol = null])
 void setBytes (integer $bytes)
 void setCharset (string $charset)
 void setContentID ([string $cid = null])
 void setContents (string $contents, [string $encoding = null])
 void setContentTypeParameter (string $label, string $data)
 void setDescription (string $description)
 void setDisposition (string $disposition)
 void setDispositionParameter (string $label, string $data)
 void setEOL (string $eol)
 void setInformation (string $label, mixed $data)
 void setMIMEId (string $mimeid)
 void setName (string $name)
 void setTransferEncoding (string $encoding)
 void setType (string $mimetype)
 boolean splitContents ()
 void strict7bit (boolean $use7bit)
 string toCanonicalString ([boolean $headers = true])
 string toString ([boolean $headers = true])
 string transferDecode ()
 string transferEncode ()
Variables
string $_boundary = null (line 188)

Unique MIME_Part boundary string.

integer $_bytes = 0 (line 195)

Default value for this Part's size.

array $_cids = array() (line 147)

The list of CIDs for this part.

string $_contentid = null (line 202)

The content-ID for this part.

string $_contents = '' (line 77)

The body of the part.

array $_contentTypeParameters = array() (line 126)

The content type parameters of this part.

string $_currentEncoding = null (line 91)

The current transfer encoding of the contents of this part.

string $_description = '' (line 105)

The description of this part.

string $_disposition = MIME_DEFAULT_DISPOSITION (line 112)

The disposition of this part (inline or attachment).

array $_dispositionParameters = array() (line 119)

The disposition parameters of this part.

boolean $_encode7bit = true (line 98)

Should the message be encoded via 7-bit?

string $_eol = MIME_PART_EOL (line 167)

The sequence to use as EOL for this part.

The default is currently to output the EOL sequence internally as just "\n" instead of the canonical "\r\n" required in RFC 822 & 2045. To be RFC complaint, the full <CR><LF> EOL combination should be used when sending a message. It is not crucial here since the PHP/PEAR mailing functions will handle the EOL details.

array $_flags = array() (line 174)

Internal class flags.

array $_idmap = array() (line 181)

Part -> ID mapping cache.

array $_information = array() (line 140)

Information/Statistics on the subpart.

string $_mimeid = null (line 154)

The MIME ID of this part.

array $_parts = array() (line 133)

The subparts of this part.

string $_subtype = 'octet-stream' (line 70)

The subtype (ex.: plain) of this part.

Per RFC 2045, the default is 'octet-stream'.

string $_transferEncoding = MIME_DEFAULT_ENCODING (line 84)

The desired transfer encoding of this part.

string $_type = 'application' (line 62)

The type (ex.: text) of this part.

Per RFC 2045, the default is 'application'.

Methods
Constructor MIME_Part (line 213)

MIME_Part constructor.

MIME_Part MIME_Part ([string $mimetype = null], [string $contents = null], [string $charset = MIME_DEFAULT_CHARSET], [string $disposition = null], [string $encoding = null])
  • string $mimetype: The content type of the part.
  • string $contents: The body of the part.
  • string $charset: The character set of the part.
  • string $disposition: The content disposition of the part.
  • string $encoding: The content encoding of the contents.
addCID (line 1358)

Add to the list of CIDs for this part.

void addCID ([array $cids = array()])
  • array $cids: A list of MIME IDs of the part. Key - MIME ID Value - CID for the part
addPart (line 574)

Add a MIME subpart.

void addPart (MIME_Part $mime_part, [string $index = null])
  • MIME_Part $mime_part: Add a MIME_Part subpart to the current MIME_Part.
  • string $index: The index of the added MIME_Part.
alterPart (line 674)

Alter a current MIME subpart.

void alterPart (string $id, MIME_Part $mime_part)
  • string $id: The MIME Part ID to alter.
  • MIME_Part $mime_part: The MIME Part to store.
appendContents (line 319)

Add to the body contents of this part.

void appendContents (string $contents, [string $encoding = null])
  • string $contents: The contents to append to the current part body.
  • string $encoding: The current encoding of the contents. If not specified, will try to auto determine the encoding.
clearContents (line 327)

Clears the body contents of this part.

void clearContents ()
clearContentTypeParameter (line 815)

Clears a content type parameter from this part.

void clearContentTypeParameter (string $label, string $data)
  • string $label: The disposition parameter label.
  • string $data: The disposition parameter data.
contentTypeMap (line 1438)

Returns a mapping of all MIME IDs to their content-types.

  • return: KEY: MIME ID, VALUE: Content type
array contentTypeMap ()
getAllContentTypeParameters (line 839)

Get all parameters from the Content-Type header.

  • return: An array of all the parameters Returns the empty array if no parameters set.
array getAllContentTypeParameters ()
getAllDispositionParameters (line 793)

Get all parameters from the Content-Disposition header.

  • return: An array of all the parameters Returns the empty array if no parameters set.
array getAllDispositionParameters ()
getBytes (line 1295)

Determine the size of a MIME_Part and its child members.

  • return: Size of the MIME_Part, in bytes.
integer getBytes ()
getCanonicalContents (line 350)

Returns the contents in strict RFC 822 & 2045 output - namely, all newlines end with the canonical <CR><LF> sequence.

  • return: The entire MIME part.
string getCanonicalContents ()
getCharset (line 505)

Get the character set to use for of this part. Returns a charset for all types (not just 'text/*') since we use this charset to determine how to encode text in MIME headers.

  • return: The character set of this part. Returns null if there is no character set.
string getCharset ()
getCIDList (line 1368)

Returns the list of CIDs for this part.

  • return: The list of CIDs for this part.
array getCIDList ()
getContentID (line 1393)

Returns the Content-ID for this part.

  • return: The Content-ID for this part.
string getContentID ()
getContents (line 339)

Return the body of the part.

  • return: The raw body of the part.
string getContents ()
getContentTypeParameter (line 828)

Get a content type parameter from this part.

  • return: The data requested. Returns false if $label is not set.
string getContentTypeParameter (string $label)
  • string $label: The content type parameter label.
getCurrentEncoding (line 1090)

Retrieves the current encoding of the contents in the object.

  • return: The current encoding.
string getCurrentEncoding ()
getDefaultType (line 449)

If the subtype of a MIME part is unrecognized by an application, the default type should be used instead (See RFC 2046). This method returns the default subtype for a particular primary MIME Type.

  • return: The default mimetype of this part (ex.: text/plain).
string getDefaultType ()
getDescription (line 531)

Get the description of this part.

  • return: The description of this part.
string getDescription ([boolean $decode = false], [boolean $default = false])
  • boolean $decode: MIME decode description?
  • boolean $default: If the name parameter doesn't exist, should we use the default name from the description parameter?
getDisposition (line 255)

Get the content-disposition of this part.

  • return: The part's content-disposition.
string getDisposition ()
getDispositionParameter (line 782)

Get a disposition parameter from this part.

  • return: The data requested. Returns false if $label is not set.
string getDispositionParameter (string $label)
  • string $label: The disposition parameter label.
getEOL (line 859)

Get the string to use for EOLs.

  • return: The string to use for EOLs.
string getEOL ()
getInformation (line 758)

Retrieve information about the MIME_Part.

  • return: The information requested. Returns false if $label is not set.
mixed getInformation (string $label)
  • string $label: The information label.
getMIMEId (line 1413)

Returns the MIME ID of this part.

  • return: The MIME ID.
string getMIMEId ()
getName (line 282)

Get the name of this part.

  • return: The name of the part.
string getName ([boolean $decode = false], [boolean $default = false])
  • boolean $decode: MIME decode description?
  • boolean $default: If the name parameter doesn't exist, should we use the default name from the description parameter?
getPart (line 620)

Retrieve a specific MIME part.

  • return: The MIME_Part requested, or false if the part doesn't exist.
MIME_Part getPart (string $id)
  • string $id: The MIME_Part ID string.

Redefined in descendants as:
getParts (line 607)

Get a list of all MIME subparts.

  • return: An array of the MIME_Part subparts.
array getParts ()

Redefined in descendants as:
getPrimaryType (line 472)

Get the primary type of this part.

  • return: The primary MIME type of this part.
string getPrimaryType ()
getRelativeMIMEId (line 1427)

Returns the relative MIME ID of this part.

e.g., if the base part has MIME ID of 2, and you want the first subpart of the base part, the relative MIME ID is 2.1.

  • return: The relative MIME ID.
string getRelativeMIMEId (string $id)
  • string $id: The relative part ID.
getSize (line 1341)

Output the size of this MIME_Part in KB.

  • return: Size of the MIME_Part, in string format.
string getSize ()
getSubType (line 482)

Get the subtype of this part.

  • return: The MIME subtype of this part.
string getSubType ()
getTransferEncoding (line 1031)

Get the transfer encoding for the part based on the user requested transfer encoding and the current contents of the part.

  • return: The transfer-encoding of this part.
string getTransferEncoding ()
getType (line 429)

Get the full MIME Content-Type of this part.

  • return: The mimetype of this part (ex.: text/plain; charset=us-ascii).
string getType ([boolean $charset = false])
  • boolean $charset: Append character set information to the end of the content type if this is a text/* part.
getUniqueID (line 1285)

Return the unique MIME_Part boundary string generated for this object.

This may not be the boundary string used when building the message since a user defined 'boundary' Content-Type parameter will override this value.

  • return: The unique boundary string.
string getUniqueID ()
header (line 871)

Add the appropriate MIME headers for this part to an existing array.

  • return: The headers, with the MIME headers added.
array header ([array $headers = array()])
  • array $headers: An array of any other headers for the part.

Redefined in descendants as:
removePart (line 660)

Remove a MIME_Part subpart.

void removePart (string $id)
  • string $id: The MIME Part to delete.
replaceEOL (line 1269)

Replace newlines in this part's contents with those specified by either the given newline sequence or the part's current EOL setting.

  • return: The text with the newlines replaced by the desired newline sequence.
string replaceEOL (string $text, [string $eol = null])
  • string $text: The text to replace.
  • string $eol: The EOL sequence to use. If not present, uses the part's current EOL setting.
setBytes (line 1331)

Explicitly set the size (in bytes) of this part. This value will only 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 MIME_Part object from IMAP header information without loading the data of the part).

void setBytes (integer $bytes)
  • integer $bytes: The size of this part in bytes.
setCharset (line 492)

Set the character set of this part.

void setCharset (string $charset)
  • string $charset: The character set of this part.
setContentID (line 1380)

Sets the Content-ID header for this part.

void setContentID ([string $cid = null])
  • string $cid: Use this CID (if not already set). Else, generate a random CID.
setContents (line 303)

Set the body contents of this part.

void setContents (string $contents, [string $encoding = null])
  • string $contents: The part body.
  • string $encoding: The current encoding of the contents.
setContentTypeParameter (line 804)

Add a content type parameter to this part.

void setContentTypeParameter (string $label, string $data)
  • string $label: The disposition parameter label.
  • string $data: The disposition parameter data.
setDescription (line 516)

Set the description of this part.

void setDescription (string $description)
  • string $description: The description of this part.
setDisposition (line 241)

Set the content-disposition of this part.

void setDisposition (string $disposition)
  • string $disposition: The content-disposition to set (inline or attachment).
setDispositionParameter (line 769)

Add a disposition parameter to this part.

void setDispositionParameter (string $label, string $data)
  • string $label: The disposition parameter label.
  • string $data: The disposition parameter data.
setEOL (line 849)

Sets a new string to use for EOLs.

void setEOL (string $eol)
  • string $eol: The string to use for EOLs.
setInformation (line 745)

Add information about the MIME_Part.

void setInformation (string $label, mixed $data)
  • string $label: The information label.
  • mixed $data: The information to store.
setMIMEId (line 1403)

Alter the MIME ID of this part.

void setMIMEId (string $mimeid)
  • string $mimeid: The MIME ID.
setName (line 267)

Set the name of this part.

TODO: MIME encode here instead of in header() - add a charset parameter.

void setName (string $name)
  • string $name: The name to set.
setTransferEncoding (line 554)

Set the transfer encoding to use for this part.

void setTransferEncoding (string $encoding)
  • string $encoding: The transfer encoding to use.
setType (line 390)

Set the mimetype of this part.

void setType (string $mimetype)
  • string $mimetype: The mimetype to set (ex.: text/plain).
splitContents (line 1209)

Split the contents of the current Part into its respective subparts, if it is multipart MIME encoding. Unlike the imap_*() functions, this will preserve all MIME header information.

The boundary content-type parameter must be set for this function to work correctly.

  • return: True if the contents were successfully split. False if any error occurred.
boolean splitContents ()
strict7bit (line 1020)

Should we make sure the message is encoded via 7-bit (e.g. to adhere to mail delivery standards such as RFC 2821)?

void strict7bit (boolean $use7bit)
  • boolean $use7bit: Use 7-bit encoding?
toCanonicalString (line 1008)

Returns the encoded part in strict RFC 822 & 2045 output - namely, all newlines end with the canonical <CR><LF> sequence.

  • return: The entire MIME part.
string toCanonicalString ([boolean $headers = true])
  • boolean $headers: Include the MIME headers?
toString (line 950)

Return the entire part in MIME format. Includes headers on request.

  • return: The MIME string.
string toString ([boolean $headers = true])
  • boolean $headers: Include the MIME headers?

Redefined in descendants as:
transferDecode (line 1145)

Decodes the contents of the part to either a 7bit or 8bit encoding.

  • return: The decoded text. Returns the empty string if there is no text to decode.
string transferDecode ()
transferDecodeContents (line 370)

Transfer decode the contents and set them as the new contents.

void transferDecodeContents ()
transferEncode (line 1100)

Encodes the contents with the part's transfer encoding.

  • return: The encoded text.
string transferEncode ()
transferEncodeContents (line 359)

Transfer encode the contents (to the transfer encoding identified via getTransferEncoding()) and set as the part's new contents.

void transferEncodeContents ()

Documentation generated on Sun, 30 Jan 2011 05:20:16 +0000 by phpDocumentor 1.4.3