diff --git a/examples/example.php b/examples/example.php index 5471a74..8adaae1 100644 --- a/examples/example.php +++ b/examples/example.php @@ -45,7 +45,7 @@ $person -> set("last_name", "McKay"); $person -> set('name_prefix', "PREF"); $person -> set('name_suffix', "SUFF"); - $person -> set('nickname', "traktor"); + $person -> set('nickname', "NICK"); $person -> set('title', "PhD"); $person -> set('role', "Scientist"); $person -> set('department', "SGA"); @@ -68,12 +68,11 @@ $person -> set('home_tel', "111 222 000"); $person -> set('cell_tel', "999 999 999"); // mobile $person -> set('email1', "hub@hub.com"); - $person -> set('email2', "mail@gmail.com"); $person -> set('url', "www.diginex.cz"); - $person -> set('photo', ""); + $person -> set('photo', "https://upload.wikimedia.org/wikipedia/commons/5/54/David-hewlett-vancouver-300.png"); $person -> set('birthday', "1.1.1970"); $person -> set('timezone', "2"); - $person -> set('note', "Fll example"); + $person -> set('note', "Full example"); # add person to vCard queue $vCard -> addPerson($person); diff --git a/src/VCard.class.php b/src/VCard.class.php index 0660a00..04ecd2a 100644 --- a/src/VCard.class.php +++ b/src/VCard.class.php @@ -154,7 +154,7 @@ private function buildOne($data){ $txt[] = "URL;type=WORK:" . $data['url'] . ""; } if ($data['birthday']) { - $txt[] = "BDAY:" . $data['birthday'] . ""; + $txt[] = "BDAY:" . date('Y-m-d', strToTime($data['birthday'])) . ""; } if ($data['role']) { $txt[] = "ROLE:" . $data['role'] . ""; @@ -162,6 +162,14 @@ private function buildOne($data){ if ($data['note']) { $txt[] = "NOTE:" . $data['note'] . ""; } + if ($data['photo']) { + $file = file_get_contents($data['photo']); + + if($file){ + $ext = pathinfo($data['photo'], PATHINFO_EXTENSION); + $txt[] = "PHOTO;TYPE={$ext};ENCODING=B:" . base64_encode($file) . ""; + } + } $txt[] = "TZ:" . $data['timezone'] . ""; $txt[] = "END:VCARD";