File_IMC
[ class tree: File_IMC ] [ index: File_IMC ] [ all elements ]

Class: File_IMC_Parse

Source Location: /File_IMC-0.5.0/File/IMC/Parse.php

Class Overview


Common parser for IMC files (vCard, vCalendar, iCalendar)


Author(s):

Version:

  • Release: 0.5.0

Variables

Methods


Child classes:

File_IMC_Parse_Vcard
This class is a parser for vCards.
File_IMC_Parse_Vcalendar
Parser for vCalendars.

Inherited Variables

Inherited Methods


Class Details

[line 63]
Common parser for IMC files (vCard, vCalendar, iCalendar)

This class provides the methods to parse a file into an array. By extending the class, you are able to define functions to handle specific elements that need special decoding. For an example, see File_IMC_Parse_vCard.



[ Top ]


Class Variables

$count =  -1

[line 75]

Keeps track of the current line being parsed

Starts at -1 so that the first line parsed is 0, since _parseBlock() advances the counter by 1 at the beginning

  • See: self::_parseBlock()
  • Access: protected

Type:   int


[ Top ]

$data =

[line 80]


Type:   array


[ Top ]



Method Detail

fromFile   [line 98]

array fromFile( string $filename, [string $charset = 'UTF-8'])

Reads a file for parsing, then sends it to $this->fromText() and returns the results.
  • Return: An array of information extracted from the file.
  • See: self::_fromArray()
  • See: self::fromText()
  • Throws: File_IMC_Exception If the file is not readable.
  • Throws: File_IMC_Exception If the file does not exist.
  • Access: public

Parameters:

string   $filename   —  The name of the file to read
string   $charset   —  what charset the text should be. Default = UTF-8

[ Top ]

fromText   [line 123]

array fromText( string $text, [string $charset = 'UTF-8'])

Prepares a block of text for parsing, then sends it through and returns the results from $this->_fromArray().
  • Return: An array of information extracted from the source text.
  • See: self::_fromArray()
  • Access: public

Parameters:

string   $text   —  A block of text to read for information.
string   $charset   —  what charset the text should be. Default = UTF-8

[ Top ]

getVersion   [line 82]

void getVersion( )

  • Abstract:

Overridden in child classes as:

File_IMC_Parse_Vcard::getVersion()
Return version.
File_IMC_Parse_Vcalendar::getVersion()
Return the version.

[ Top ]

_charset_conv   [line 675]

array _charset_conv( array $params, string $text, [string $charset = 'UTF-8'])

Convert text to the specified charaster set
  • Access: protected

Parameters:

array   $params   —  A parameter array from a vCard line.
string   $text   —  A right-part (after-the-colon part) from a line.
string   $charset   —  The charset to convert to

[ Top ]

_convertLineEndings   [line 158]

void _convertLineEndings( string $text)

Converts line endings in text.

Takes any text block and converts all line endings to UNIX standard. DOS line endings are \r\n, Mac are \r, and UNIX is \n. As a side-effect, all double-newlines (\n\n) are converted to a single-newline.

NOTE: Acts on the text block in-place; does not return a value.

  • Access: protected

Parameters:

string   $text   —  The string on which to convert line endings.

[ Top ]

_decode   [line 643]

array _decode( array $params, string $text, [string $prop = null])

Looks at a line's parameters; if ENCODING parameter is set and is QUOTED-PRINTABLE then decode the text in-place.

This method is overwritten in Parse/Vcard.php


Overridden in child classes as:

File_IMC_Parse_Vcard::_decode()
Looks at a line's parameters; if ENCODING parameter is set -> decode the text in-place.

Parameters:

array   $params   —  A parameter array from a vCard line.
string   $text   —  A right-part (after-the-colon part) from a line.
string   $prop   —  The property name.. passed so may have special-cases

[ Top ]

_fromArray   [line 358]

array _fromArray( array $source, [string $charset = 'UTF-8'])

Parses an array of source lines and returns an array of vCards.

Each element of the array is itself an array expressing the types, parameters, and values of each part of the vCard. Processes both 2.1 and 3.0 vCard sources.

  • Return: An array of of vCard information extracted from the source array.
  • Todo: fix missing colon = skip line
  • Access: protected

Parameters:

array   $source   —  An array of lines to be read for vCard information.
string   $charset   —  what charset the text should be. Default = UTF-8

[ Top ]

_getGroup   [line 466]

string _getGroup( array $text)

Takes a line and extracts the Group for the line (a group is identified as a prefix-with-dot to the Type-Definition; e.g., Group.ADR or Group.ORG).
  • Return: The group for the line.
  • See: self::_getTypeDef()
  • See: self::_splitBySemi()
  • Access: protected

Parameters:

array   $text   —  Array containing left side (before colon) split by semi-colon from a line.

[ Top ]

_getParamName   [line 586]

string _getParamName( string $value)

Returns the parameter name for parameters given without names.

The vCard 2.1 specification allows parameter values without a name. The parameter name is then determined from the unique parameter value.

Shamelessly lifted from Frank Hellwig <frank@hellwig.org> and his vCard PHP project <http://vcardphp.sourceforge.net>.

  • Return: The proper parameter name (TYPE, ENCODING, or VALUE).
  • Access: protected

Parameters:

string   $value   —  The first element in a parameter name-value pair.

[ Top ]

_getParams   [line 511]

array _getParams( array $text)

Finds the Type-Definition parameters for a line.
  • Return: An array of parameters.
  • See: self::_splitBySemi()
  • Access: protected

Parameters:

array   $text   —  Array containing left side (before colon) split by semi-colon from a line.

[ Top ]

_getTypeDef   [line 490]

string _getTypeDef( array $text)

Takes a line and extracts the Type-Definition for the line (not including the Group portion; e.g., in Group.ADR, only ADR is returned).
  • Return: The type definition for the line.
  • See: self::_getGroup()
  • See: self::_splitBySemi()
  • Access: protected

Parameters:

array   $text   —  Array containing left side (before colon) split by semi-colon from a line.

[ Top ]

_parseBlock   [line 376]

array _parseBlock( array $source, [string $charset = 'UTF-8'])

Goes through the IMC file, recursively processing BEGIN-END blocks

Handles nested blocks, such as vEvents (BEGIN:VEVENT) and vTodos (BEGIN:VTODO) inside vCalendars (BEGIN:VCALENDAR).

  • Access: protected

Parameters:

string   $charset   — 
array   $source   —  Array of lines in the IMC file

[ Top ]

_splitByColon   [line 314]

array _splitByColon( string $text, [bool $recurse = false])

Splits the line into types/parameters and values.
  • Return: The first element contains types and parameters (before the colon). The second element contains the line's value (after the colon).
  • Todo: A parameter w/ 1 quote will break everything. Try to come up with a good way to fix this.
  • Access: protected

Parameters:

string   $text   —  The string to split into an array.
bool   $recurse   —  If true, recursively parse the entire text for all occurrences of the delimiter; if false, only parse for the first occurrence. Defaults to false (this is different from self::_splitByCommon() and self::_splitBySemi()).

[ Top ]

_splitByComma   [line 291]

string|array _splitByComma( string $text, [bool $recurse = true])

Splits a string into an array at commas.
  • Return: An array of values, or a single string.
  • See: self::_splitByDelim()
  • Access: protected

Parameters:

string   $text   —  The string to split into an array.
bool   $recurse   —  If true, recursively parse the entire text for all occurrences of the delimiter; if false, only parse for the first occurrence. Defaults to true.

[ Top ]

_splitByDelim   [line 182]

string|array _splitByDelim( string $text, string $delim, [bool $recurse = true])

Splits a string into an array. Honors backslash-escaped delimiters, (i.e., splits at ';' not '\;') and double-quotes (will not break inside double-quotes ("")).
  • Return: An array of values, or a single string.
  • Access: public

Parameters:

string   $text   —  The string to split into an array.
string   $delim   —  Character to split string at.
bool   $recurse   —  If true, recursively parse the entire text for all occurrences of the delimiter; if false, only parse for the first occurrence. Defaults to true.

[ Top ]

_splitBySemi   [line 273]

string|array _splitBySemi( string $text, [bool $recurse = true], bool $convertSingle)

Splits a string into an array at semicolons.
  • Return: An array of values, or a single string.
  • See: self::_splitByDelim()
  • Access: protected

Parameters:

string   $text   —  The string to split into an array.
bool   $convertSingle   —  If splitting the string results in a single array element, return a string instead of a one-element array.
bool   $recurse   —  If true, recursively parse the entire text for all occurrences of the delimiter; if false, only parse for the first occurrence. Defaults to true.

[ Top ]

_unescape   [line 331]

mixed _unescape( string|array $text)

Used to make string human-readable after being a vCard value.

Converts... \; => ; \, => , literal \n => newline

  • Access: protected

Parameters:

string|array   $text   —  The text to unescape.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:49:38 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.