--------- Typoscript ------------------------------ includeLibs.vcardEncode = fileadmin/template/php/vcard-encode.php vcard = PAGE vcard { config.disableAllHeaderCode = 1 config.additionalHeaders = Content-Type: text/x-vcard|Content-Disposition: attachment; filename="vcard.vcf" ## setting the Typo3 Pagetype typeNum = 200 10 = RECORDS 10 { source.data = GPvar:tx\_myext\_pi1|showUid tables =tx\_myext\_persons conf.tx\_myext\_persons = TEMPLATE conf.tx\_myext\_persons { template = FILE template.file = fileadmin/template/vcard.txt marks { fullname = TEXT fullname.value = {field:academic\_title} {field:name} {field:surname} fullname.insertData = 1 fullname.postUserFunc = user\_vcard->encode surname = TEXT surname.field = surname surname.postUserFunc = user\_vcard->encode name = TEXT name.field = name email = TEXT email.field = email email.postUserFunc = user\_vcard->encode position = TEXT position.value = Anwalt position.lang.en = Lawyer tel = TEXT tel.field = telephone tel.postUserFunc = user\_vcard->encode fax = TEXT fax.field = fax fax.postUserFunc = user\_vcard->encode adress = RECORDS adress.source.field = locations adress.source.listNum = 0 adress.tables = tx\_myext\_locations adress.conf.tx\_myext\_locations = TEXT adress.conf.tx\_myext\_locations.value={field:address};{field:city};{field:state};{field:postalcode};{field:country} adress.conf.tx\_myext\_locations.insertData = 1 adress.conf.tx\_myext\_locations.postUserFunc = user\_vcard->encode } } } } --------- Typoscript End ------------------------------ --------- File: fileadmin/template/vcard.txt The Template ---------------------------------------------------- begin:vcard fn:###fullname### n:###surname###;###name###;;###academic\_title### org:###organisation### adr;type=work,postal,parcel:;;###adress### email:###email### title:###position### tel;work:###tel### tel;fax:###fax### URL;HOME: Http://www.my-company.com URL;WORK: Http://www.my-company.com version:2.1 end:vcard --------- File: fileadmin/template/vcard.txt End ---------------------------------------------------- --------- File: fileadmin/template/php/vcard-encode.php ---------------------------------------------------- <?php class user\_vcard { var $csConvObj = false; function encode($content,$conf){ if ($this->csConvObj == false){ $this->csConvObj = t3lib\_div::makeInstance('t3lib\_cs'); } //$content = mb\_convert\_encoding ($content ,); // conv ($str, $fromCS, $toCS, $useEntityForNoChar=0) $content = $this->csConvObj->conv($content,"utf-8","iso-8859-15",0); //$content = $this->quoted\_printable\_encode(trim($content)); return $content; } function quoted\_printable\_encode($input, $line\_max = 75) { $hex = array('0','1','2','3','4','5','6','7', '8','9','A','B','C','D','E','F'); $lines = preg\_split("/(?:\r\n|\r|\n)/", $input); $linebreak = "=0D=0A=\r\n"; /* the linebreak also counts as characters in the mime\_qp\_long\_line * rule of spam-assassin */ $line\_max = $line\_max - strlen($linebreak); $escape = "="; $output = ""; $cur\_conv\_line = ""; $length = 0; $whitespace\_pos = 0; $addtl\_chars = 0; for ($j=0; $j<count($lines); $j++) { $line = $lines[$j]; $linlen = strlen($line); for ($i = 0; $i < $linlen; $i++) { $c = substr($line, $i, 1); $dec = ord($c); $length++; if ($dec == 32) { // space occurring at end of line, need to encode if (($i == ($linlen - 1))) { $c = "=20"; $length += 2; } $addtl\_chars = 0; $whitespace\_pos = $i; } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { $h2 = floor($dec/16); $h1 = floor($dec%16); $c = $escape . $hex["$h2"] . $hex["$h1"]; $length += 2; $addtl\_chars += 2; } // length for wordwrap exceeded, get a newline into the text if ($length >= $line\_max) { $cur\_conv\_line .= $c; // read only up to the whitespace for the current line $whitesp\_diff = $i - $whitespace\_pos + $addtl\_chars; $output .= substr($cur\_conv\_line, 0, (strlen($cur\_conv\_line) - $whitesp\_diff)) . $linebreak; /* the text after the whitespace will have to be read * again ( + any additional characters that came into * existence as a result of the encoding process after the whitespace) */ $i = $i - $whitesp\_diff + $addtl\_chars; $cur\_conv\_line = ""; $length = 0; $whitespace\_pos = 0; } else { // length for wordwrap not reached, continue reading $cur\_conv\_line .= $c; } } // end of for $length = 0; $whitespace\_pos = 0; $output .= $cur\_conv\_line; $cur\_conv\_line = ""; if ($j<=count($lines)-1) { // $output .= $linebreak; } } return trim($output); } } ?>
{}