-;
-
-
-/**
- * @param vcard_source_data $vcardsource
- * @return string
- */
-function vcard_source_compile($vcardsource)
-{
- $str = "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//" . DAV_APPNAME . "//DAV-Plugin//EN\r\n";
- $str .= "N:" . str_replace(";", ",", $vcardsource->name_last) . ";" . str_replace(";", ",", $vcardsource->name_first) . ";" . str_replace(";", ",", $vcardsource->name_middle) . ";;\r\n";
- $str .= "FN:" . str_replace(";", ",", $vcardsource->name_first) . " " . str_replace(";", ",", $vcardsource->name_middle) . " " . str_replace(";", ",", $vcardsource->name_last) . "\r\n";
- $str .= "REV:" . str_replace(" ", "T", $vcardsource->last_update) . "Z\r\n";
-
- $item_count = 0;
- for ($i = 0; $i < count($vcardsource->homepages); $i++) {
- if ($i == 0) $str .= "URL;type=" . $vcardsource->homepages[0]->type . ":" . $vcardsource->homepages[0]->homepage . "\r\n";
- else {
- $c = ++$item_count;
- $str .= "item$c.URL;type=" . $vcardsource->homepages[0]->type . ":" . $vcardsource->homepages[0]->homepage . "\r\n";
- $str .= "item$c.X-ABLabel:_\$!<HomePage>!\$_\r\n";
- }
- }
-
- if (is_object($vcardsource->photo)) {
- $data = base64_encode($vcardsource->photo->binarydata);
- $str .= "PHOTO;ENCODING=BASE64;TYPE=" . $vcardsource->photo->type . ":" . $data . "\r\n";
- }
-
- if (isset($vcardsource->socialnetworks) && is_array($vcardsource->socialnetworks)) foreach ($vcardsource->socialnetworks as $netw) switch ($netw->type) {
- case "dfrn":
- $str .= "X-SOCIALPROFILE;type=dfrn;x-user=" . $netw->nick . ":" . $netw->url . "\r\n";
- break;
- case "facebook":
- $str .= "X-SOCIALPROFILE;type=facebook;x-user=" . $netw->nick . ":" . $netw->url . "\r\n";
- break;
- case "twitter":
- $str .= "X-SOCIALPROFILE;type=twitter;x-user=" . $netw->nick . ":" . $netw->url . "\r\n";
- break;
- }
-
- $str .= "END:VCARD\r\n";
- return $str;
-}
-