/** * Creates a new file * * The contents of the new file must be a valid VCARD. * * This method may return an ETag. * * @param string $name * @param resource $vcardData * @return string|null */ public function createFile($name, $vcardData = null) { if (is_resource($vcardData)) { $vcardData = stream_get_contents($vcardData); } // Converting to UTF-8, if needed $vcardData = DAV\StringUtil::ensureUTF8($vcardData); return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $vcardData); }
/** * Main processing method. * Fetches all foaf persons from RDF store, creates ContactInformation objects out of them and converts them to * vcards. The vcards will be stored in the CardDAV backend and printed. * * @throws \Erfurt_Store_Exception if something goes wrong */ public function convert() { $query = 'PREFIX ' . $this->vocabularies['foaf']->name . ': <' . $this->vocabularies['foaf']->prefix . '> ' . 'SELECT ?person ' . 'WHERE { ' . '?person a ' . $this->vocabularies['foaf']->name . ':' . $this->vocabularies['foaf']->entityName . ' . ' . '}'; $result = $this->getStore()->sparqlQuery($query); foreach ($result as $person) { $name_arr = explode('/', $person['person']); $name = $name_arr[count($name_arr) - 1] . '.vcf'; $vcard = $this->contactToVCard($this->createContact($person['person'], $this->vocabularies['foaf']))->serialize(); $this->cardDav->createCard(1, $name, $vcard); echo $vcard . "\n"; } }