//dP $result = $this->raiseError("vCard 3.0 [$comp] [$iter]: The only allowed ENCODING parameters are 8BIT and B.");
} else {
$result = true;
}
break;
case 'VALUE':
if ($text != 'BINARY' &&
$text != 'PHONE-NUMBER' &&
$text != 'TEXT' &&
$text != 'URI' &&
$text != 'UTC-OFFSET' &&
$text != 'VCARD') {
//dP $result = $this->raiseError("vCard 3.0 [$comp] [$iter]: The only allowed VALUE parameters are BINARY, PHONE-NUMBER, TEXT, URI, UTC-OFFSET, and VCARD.");
} else {
$result = true;
}
break;
default:
//dP $result = $this->raiseError("vCard 3.0 [$comp] [$iter]: Unknown or invalid parameter name ($name).");
break;
}
} else {
//dP $result = $this->raiseError("[$comp] [$iter] Unknown vCard version number or other error.");
}
return $result;
}
/**
*
* Gets back the parameter string for a given component.
*
* @access public
*
* @param string $comp The component to get parameters for (ADR, TEL,
* etc).
*
* @param int $iter The vCard component iteration to get the param
* list for. E.g., if you have more than one ADR component, 0 refers
* to the first ADR, 1 to the second ADR, and so on.
*
* @return string
*
*/
function getParam($comp, $iter = 0)
{
$comp = strtoupper($comp);
$text = '';
if (is_array($this->param[$comp][$iter])) {
// loop through the array of parameters for
// the component
foreach ($this->param[$comp][$iter] as $param_name => $param_val) {
// if there were previous parameter names, separate with
// a semicolon
if ($text != '') {
$text .= ';';
}
if ($param_val === null) {
// no parameter value was specified, which is typical
// for vCard version 2.1 -- the name is the value.
$this->escape($param_name);
$text .= $param_name;
} else {
// set the parameter name...
$text .= strtoupper($param_name) . '=';
// ...then escape and comma-separate the parameter
// values.
$this->escape($param_val);
$text .= implode(',', $param_val);
}
}
}
// if there were no parameters, this will be blank.
return $text;
}
/**
*
* Resets the vCard values and params to be blank.
*
* @access public
*
* @param string $version The vCard version to reset to ('2.1' or
* '3.0' -- default is the same version as previously set).
*
* @return void
*
*/
function reset($version = null)
{
$prev = $this->value['VERSION'][0][0][0];
$this->value = array();
$this->param = array();
$this->autoparam = null;
if ($version === null) {
$this->setVersion($prev);
} else {
$this->setVersion($version);
}
}
/**
*
* Gets the left-side/prefix/before-the-colon (metadata) part of a
* vCard line, including the component identifier, the parameter
* list, and a colon.
*
* @access public
*
* @param string $comp The component to get metadata for (ADR, TEL,
* etc).
*
* @param int $iter The vCard component iteration to get the metadata
* for. E.g., if you have more than one ADR component, 0 refers to
* the first ADR, 1 to the second ADR, and so on.
*
* @return string The line prefix metadata.
*
*/
function getMeta($comp, $iter = 0)
{
$params = $this->getParam($comp, $iter);
if (trim($params) == '') {
// no parameters
$text = $comp . ':';
} else {
// has parameters. put an extra semicolon in.
$text = $comp . ';' . $params . ':';
}
return $text;
}
/**
*
* Generic, all-purpose method to store a string or array in
* $this->value, in a way suitable for later output as a vCard
* element. This forces the value to be the passed text or array
* value, overriding any prior values.
*
* @access public
*
* @param string $comp The component to set the value for ('N',
* 'ADR', etc).
*
* @param int $iter The component-iteration to set the value for.
*
* @param int $part The part number of the component-iteration to set
* the value for.
*
* @param mixed $text A string or array; the set of repeated values
* for this component-iteration part.
*
* @return void
*
*/
function setValue($comp, $iter, $part, $text)
{
$comp = strtoupper($comp);
settype($text, 'array');
$this->value[$comp][$iter][$part] = $text;
$this->autoparam = $comp;
}
/**
*
* Generic, all-purpose method to add a repetition of a string or
* array in $this->value, in a way suitable for later output as a
* vCard element. This appends the value to be the passed text or
* array value, leaving any prior values in place.
*
* @access public
*
* @param string $comp The component to set the value for ('N',
* 'ADR', etc).
*
* @param int $iter The component-iteration to set the value for.
*
* @param int $part The part number of the component-iteration to set
* the value for.
*
* @param mixed $text A string or array; the set of repeated values
* for this component-iteration part.
*
* @return void
*
*/
function addValue($comp, $iter, $part, $text)
{
$comp = strtoupper($comp);
settype($text, 'array');
foreach ($text as $val) {
$this->value[$comp][$iter][$part][] = $val;
}
$this->autoparam = $comp;
}
/**
*
* Generic, all-purpose method to get back the data stored in $this->value.
*
* @access public
*
* @param string $comp The component to set the value for ('N',
* 'ADR', etc).
*
* @param int $iter The component-iteration to set the value for.
*
* @param int $part The part number of the component-iteration to get
* the value for.
*
* @param mixed $rept The repetition number within the part to get;
* if null, get all repetitions of the part within the iteration.
*
* @return string The value, escaped and delimited, of all
* repetitions in the component-iteration part (or specific