<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | hide@address.com so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Andreas Haberstroh <hide@address.com> |
// +----------------------------------------------------------------------+
//
// $Id$
require_once('class.imcProperty.php');
/*
Type name: N
Type purpose: To specify the components of the name of the object the
vCard represents.
Type encoding: 8bit
Type value: A single structured text value. Each component can have
multiple values.
Type special note: The structured type value corresponds, in
sequence, to the Family Name, Given Name, Additional Names, Honorific
Prefixes, and Honorific Suffixes. The text components are separated
by the SEMI-COLON character (ASCII decimal 59). Individual text
components can include multiple text values (e.g., multiple
Additional Names) separated by the COMMA character (ASCII decimal
44). This type is based on the semantics of the X.520 individual name
attributes. The property MUST be present in the vCard object.
Type example:
N:Public;John;Quinlan;Mr.;Esq.
N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.
*/
class imcPropertyN extends imcProperty
{
// {{{ imcPropertyN
/**
* Default constructor.
*/
function imcPropertyN() {
// normally, we don't have any endcoding
$this->encoding_func = 'none';
// make space for the 5 pieces of the N property
$this->setValue(array('','','','',''));
}
// {{{ setEncodedValue
/**
* Decodes a N property value and splits it into the proper
* fields of our value array.
*
* @param string N encoded value
* @see getEncodedValue
*/
function setEncodedValue($string) {
$n = explode(";", $this->_decodeValue($string));
$this->value[0] = $n[0];
$this->value[1] = $n[1];
$this->value[2] = $n[2];
$this->value[3] = $n[3];
$this->value[4] = $n[4];
}
// {{{ getEncodedValue
/**
* Encodes our value array into a N property value.
*
* @return string N encoded value
* @see setEncodedValue
*/
function getEncodedValue() {
$value = implode(";", $this->value);
// strip off the extra semicolons at the end of the value
while ( $value[strlen($value) - 1] == ';' ) {
$value = substr($value, 0, strlen($value) - 1);
}
return $value;
}
// {{{ setFamilyName
/**
* Sets the last name portion of the property
*
* @param string Last name value
* @see getFamilyName
*/
function setFamilyName($value) {
$this->value[0] = $value;
}
// {{{ getFamilyName
/**
* Gets the last name portion of the property
*
* @return string Last name value
* @see setFamilyName
*/
function getFamilyName() {
return $this->value[0];
}
// {{{ setGivenName
/**
* Sets the first name portion of the property
*
* @param string First name value
* @see getGivenName
*/
function setGivenName($value) {
$this->value[1] = $value;
}
// {{{ getGivenName
/**
* Gets the first name portion of the property
*
* @return string First name value
* @see setGivenName
*/
function getGivenName() {
return $this->value[1];
}
// {{{ setAdditionalNames
/**
* Sets the middle name portion of the property
*
* @param string Middle name value
* @see getAdditionalNames
*/
function setAdditionalNames($value) {
$this->value[2] = $value;
}
// {{{ getAdditionalNames
/**
* Gets the middle name portion of the property
*
* @return string Middle name value
* @see setAdditionalNames
*/
function getAdditionalNames() {
return $this->value[2];
}
// {{{ setNamePrefix
/**
* Sets the prefix portion of the property.
* Common values are: Mr., Mrs., Ms., etc.
*
* @param string Middle name value
* @see getNamePrefix
*/
function setNamePrefix($value) {
$this->value[3] = $value;
}
// {{{ getNamePrefix
/**
* Gets the prefix portion of the property.
*
* @return string Middle name value
* @see setNamePrefix
*/
function getNamePrefix() {
return $this->value[3];
}
// {{{ setNameSuffix
/**
* Sets the suffix portion of the property.
* Common values are: Jr., Sr., I, II and III
*
* @param string Middle name value
* @see getNameSuffix
*/
function setNameSuffix($value) {
$this->value[4] = $value;
}
// {{{ getNameSuffix
/**
* Gets the suffix portion of the property.
*
* @return string Middle name value
* @see setNameSuffix
*/
function getNameSuffix() {
return $this->value[4];
}
}
?>