/** * @brief Data structure of vCard * @param VObject\VCard $contact * @return associative array|null */ public static function serializeContact(Contact $contact) { if (!$contact->retrieve()) { \OCP\Util::writeLog('contacts', __METHOD__ . ' error reading: ' . print_r($contact, true), \OCP\Util::DEBUG); return null; } $details = array(); if (isset($contact->PHOTO) || isset($contact->LOGO)) { $details['photo'] = true; $details['thumbnail'] = Properties::cacheThumbnail($contact->getBackend()->name, $contact->getParent()->getId(), $contact->getId(), null, $contact); } foreach ($contact->children as $property) { $pname = $property->name; $temp = self::serializeProperty($property); if (!is_null($temp)) { // Get Apple X-ABLabels if (isset($contact->{$property->group . '.X-ABLABEL'})) { $temp['label'] = $contact->{$property->group . '.X-ABLABEL'}->value; if ($temp['label'] == '_$!<Other>!$_') { $temp['label'] = Properties::$l10n->t('Other'); } if ($temp['label'] == '_$!<HomePage>!$_') { $temp['label'] = Properties::$l10n->t('HomePage'); } } if (array_key_exists($pname, $details)) { $details[$pname][] = $temp; } else { $details[$pname] = array($temp); } } } return array('data' => $details, 'metadata' => $contact->getMetaData()); }