src/FS/File/VCard/Builder.php
public static function build( ADT_VCard $card, $charsetIn = NULL, $charsetOut = NULL )
	{
		$lines		= array();

		if( $fields	= $card->getNameFields() )											//  NAME FIELDS
			$lines[]	= self::renderLine( "n", $fields );

		foreach( $card->getAddresses() as $address )									//  ADDRESSES
			$lines[]	= self::renderLine( "adr", $address, $address['types'] );

		if( $name	= $card->getFormatedName() )										//  FORMATED NAME
			$lines[]	= self::renderLine( "fn", $name );

		if( $nicknames = $card->getNicknames() )										//  NICKNAMES
			$lines[]	= self::renderLine( "nickname", $nicknames, NULL, TRUE, "," );

		if( $fields	= $card->getOrganisationFields() )									//  ORGANISATION
			$lines[]	= self::renderLine( "org", $fields, NULL, TRUE );

		if( $title	= $card->getTitle() )												//  TITLE
			$lines[]	= self::renderLine( "title", $title );

		if( $role	= $card->getRole() )												//  ROLE
			$lines[]	= self::renderLine( "role", $role );

		foreach( $card->getEmails() as $address => $types )								//  EMAIL ADDRESSES
			$lines[]	= self::renderLine( "email", $address, $types );

		foreach( $card->getUrls() as $url => $types )									//  URLS
			$lines[]	= self::renderLine( "url", $url, $types, FALSE );

		foreach( $card->getPhones() as $number => $types )								//  PHONES
			$lines[]	= self::renderLine( "tel", $number, $types );
		
		foreach( $card->getGeoTags() as $geo )											//  GEO TAGS
			$lines[]	= self::renderLine( "geo", $geo, $geo['types'] );
		
		if( self::$prodId )
			array_unshift( $lines, "PRODID:".self::$prodId );
		if( self::$version )
			array_unshift( $lines, "VERSION:".self::$version );
		array_unshift( $lines, "BEGIN:VCARD" );
		array_push( $lines, "END:VCARD" );
		$lines	= implode( "\n", $lines );
		if( $charsetIn && $charsetOut )
		{
			$lines	= Alg_Text_EncodingConverter::convert( $lines, $charsetIn, $charsetOut );
		}
		return $lines;
	}
public static function build( ADT_VCard $card, $charsetIn = NULL, $charsetOut = NULL )
	{
		$lines		= array();

		if( $fields	= $card->getNameFields() )											//  NAME FIELDS
			$lines[]	= self::renderLine( "n", $fields );

		foreach( $card->getAddresses() as $address )									//  ADDRESSES
			$lines[]	= self::renderLine( "adr", $address, $address['types'] );

		if( $name	= $card->getFormatedName() )										//  FORMATED NAME
			$lines[]	= self::renderLine( "fn", $name );

		if( $nicknames = $card->getNicknames() )										//  NICKNAMES
			$lines[]	= self::renderLine( "nickname", $nicknames, NULL, TRUE, "," );

		if( $fields	= $card->getOrganisationFields() )									//  ORGANISATION
			$lines[]	= self::renderLine( "org", $fields, NULL, TRUE );

		if( $title	= $card->getTitle() )												//  TITLE
			$lines[]	= self::renderLine( "title", $title );

		if( $role	= $card->getRole() )												//  ROLE
			$lines[]	= self::renderLine( "role", $role );

		foreach( $card->getEmails() as $address => $types )								//  EMAIL ADDRESSES
			$lines[]	= self::renderLine( "email", $address, $types );

		foreach( $card->getUrls() as $url => $types )									//  URLS
			$lines[]	= self::renderLine( "url", $url, $types, FALSE );

		foreach( $card->getPhones() as $number => $types )								//  PHONES
			$lines[]	= self::renderLine( "tel", $number, $types );
		
		foreach( $card->getGeoTags() as $geo )											//  GEO TAGS
			$lines[]	= self::renderLine( "geo", $geo, $geo['types'] );
		
		if( self::$prodId )
			array_unshift( $lines, "PRODID:".self::$prodId );
		if( self::$version )
			array_unshift( $lines, "VERSION:".self::$version );
		array_unshift( $lines, "BEGIN:VCARD" );
		array_push( $lines, "END:VCARD" );
		$lines	= implode( "\n", $lines );
		if( $charsetIn && $charsetOut )
		{
			$lines	= Alg_Text_EncodingConverter::convert( $lines, $charsetIn, $charsetOut );
		}
		return $lines;
	}
public static function build ( ADT_VCard $ card , $ charsetIn = NULL , $ charsetOut = NULL ) { $ lines = array ( ) ; if ( $ fields = $ card -> getNameFields ( ) ) //  NAME FIELDS $ lines [ ] = self :: renderLine ( "n" , $ fields ) ; foreach ( $ card -> getAddresses ( ) as $ address ) //  ADDRESSES $ lines [ ] = self :: renderLine ( "adr" , $ address , $ address [ 'types' ] ) ; if ( $ name = $ card -> getFormatedName ( ) ) //  FORMATED NAME $ lines [ ] = self :: renderLine ( "fn" , $ name ) ; if ( $ nicknames = $ card -> getNicknames ( ) ) //  NICKNAMES $ lines [ ] = self :: renderLine ( "nickname" , $ nicknames , NULL , TRUE , "," ) ; if ( $ fields = $ card -> getOrganisationFields ( ) ) //  ORGANISATION $ lines [ ] = self :: renderLine ( "org" , $ fields , NULL , TRUE ) ; if ( $ title = $ card -> getTitle ( ) ) //  TITLE $ lines [ ] = self :: renderLine ( "title" , $ title ) ; if ( $ role = $ card -> getRole ( ) ) //  ROLE $ lines [ ] = self :: renderLine ( "role" , $ role ) ; foreach ( $ card -> getEmails ( ) as $ address => $ types ) //  EMAIL ADDRESSES $ lines [ ] = self :: renderLine ( "email" , $ address , $ types ) ; foreach ( $ card -> getUrls ( ) as $ url => $ types ) //  URLS $ lines [ ] = self :: renderLine ( "url" , $ url , $ types , FALSE ) ; foreach ( $ card -> getPhones ( ) as $ number => $ types ) //  PHONES $ lines [ ] = self :: renderLine ( "tel" , $ number , $ types ) ; foreach ( $ card -> getGeoTags ( ) as $ geo ) //  GEO TAGS $ lines [ ] = self :: renderLine ( "geo" , $ geo , $ geo [ 'types' ] ) ; if ( self :: $ prodId ) array_unshift ( $ lines , "PRODID:" . self :: $ prodId ) ; if ( self :: $ version ) array_unshift ( $ lines , "VERSION:" . self :: $ version ) ; array_unshift ( $ lines , "BEGIN:VCARD" ) ; array_push ( $ lines , "END:VCARD" ) ; $ lines = implode ( "\n" , $ lines ) ; if ( $ charsetIn && $ charsetOut ) { $ lines = Alg_Text_EncodingConverter :: convert ( $ lines , $ charsetIn , $ charsetOut ) ; } return $ lines ; }
Builds vCard String from vCard Object and converts between Charsets.
@access		public
@static
@param		ADT_VCard	$card			VCard Data Object
@param		string		$charsetIn		Charset to convert from
@param		string		$charsetOut		Charset to convert to
@return		string
Builds vCard String from vCard Object and converts between Charsets .