示例#1
0
 /**
  * Internal helper to fill in details of a vcard.
  * @param array $row The associative array row returned from the db. Not empty.
  * @return VCard The finished vcard.
  */
 protected function fetchVCard(array $row)
 {
     assert(isset($this->connection));
     assert(!empty($row));
     $vcard = new VCard();
     $vcard->setUID($row["UID"]);
     // FIXME: fetch columns explicitly instead of "SELECT *" and map
     $simpleCols = ['KIND', 'FN', 'BDAY', 'ANNIVERSARY', 'REV', 'VERSION'];
     foreach ($simpleCols as $col) {
         if (!empty($row[$col])) {
             $vcard->push(VCard::builder(\strtolower($col))->setValue($row[$col])->build());
         }
     }
     $vcard->push(VCard::builder('prodid')->setValue(self::VCARD_PRODUCT_ID)->build());
     foreach (['org', 'adr', 'n'] as $structuredProperty) {
         $vcard->{$structuredProperty} = $this->fetchStructuredProperty($structuredProperty, $vcard->getUID());
     }
     // Basic Properties
     foreach (['title', 'role', 'tz', 'nickname', 'url', 'note', 'email', 'tel', 'categories', 'geo', 'logo', 'photo', 'sound', 'key', 'related'] as $property) {
         $vcard->{$property} = $this->fetchBasicProperty($property, $vcard->getUID());
     }
     $xtended = $this->fetchXtendedProperties($vcard->getUID());
     if (null !== $xtended) {
         $vcard->push($xtended);
     }
     return $vcard;
 }
示例#2
0
 /**
  * Fetch a pre-constructed sample vcard.
  * @return an individual VCard.
  */
 public function getSeinarAPL()
 {
     $inputs = $this->getSeinarAPLInputs();
     $vcard = new VCard();
     $vcard->setUID($inputs['uid']);
     VCard::builder('org')->setValue($inputs['org'])->pushTo($vcard);
     VCard::builder('fn')->setValue($inputs['fn'])->pushTo($vcard);
     VCard::builder('logo')->setValue($inputs['logo'])->pushTo($vcard);
     VCard::builder('categories')->setValue($inputs['category1'])->pushTo($vcard);
     VCard::builder('categories')->setValue($inputs['category2'])->pushTo($vcard);
     VCard::builder('categories')->setValue($inputs['category3'])->pushTo($vcard);
     VCard::builder('kind')->setValue($inputs['kind'])->pushTo($vcard);
     return $vcard;
 }