Exemplo n.º 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;
 }