Skip to content

Commit

Permalink
Beta 0.1
Browse files Browse the repository at this point in the history
Tested od Android 2.3.3, add image support, fixed b-day dateformat
  • Loading branch information
Sekiphp committed Aug 25, 2015
1 parent 703464f commit 2325fa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 3 additions & 4 deletions examples/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -68,12 +68,11 @@
$person -> set('home_tel', "111 222 000");
$person -> set('cell_tel', "999 999 999"); // mobile
$person -> set('email1', "[email protected]");
$person -> set('email2', "[email protected]");
$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);

Expand Down
10 changes: 9 additions & 1 deletion src/VCard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,22 @@ 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'] . "";
}
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";
Expand Down

0 comments on commit 2325fa8

Please sign in to comment.