예제 #1
0
 /**
  * Writes the contents of this SourceDescription to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->about) {
         $writer->writeAttribute('about', $this->about);
     }
     if ($this->mediaType) {
         $writer->writeAttribute('mediaType', $this->mediaType);
     }
     if ($this->resourceType) {
         $writer->writeAttribute('resourceType', $this->resourceType);
     }
     parent::writeXmlContents($writer);
     if ($this->citations) {
         foreach ($this->citations as $i => $x) {
             $writer->startElementNs('gx', 'citation', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->mediator) {
         $writer->startElementNs('gx', 'mediator', null);
         $this->mediator->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sources) {
         foreach ($this->sources as $i => $x) {
             $writer->startElementNs('gx', 'source', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->analysis) {
         $writer->startElementNs('gx', 'analysis', null);
         $this->analysis->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->componentOf) {
         $writer->startElementNs('gx', 'componentOf', null);
         $this->componentOf->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->titles) {
         foreach ($this->titles as $i => $x) {
             $writer->startElementNs('gx', 'title', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->titleLabel) {
         $writer->startElementNs('gx', 'titleLabel', null);
         $this->titleLabel->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->notes) {
         foreach ($this->notes as $i => $x) {
             $writer->startElementNs('gx', 'note', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sortKey) {
         $writer->startElementNs('gx', 'sortKey', null);
         $writer->text($this->sortKey);
         $writer->endElement();
     }
     if ($this->descriptions) {
         foreach ($this->descriptions as $i => $x) {
             $writer->startElementNs('gx', 'description', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->identifiers) {
         foreach ($this->identifiers as $i => $x) {
             $writer->startElementNs('gx', 'identifier', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->created) {
         $writer->startElementNs('gx', 'created', null);
         $writer->text($this->created);
         $writer->endElement();
     }
     if ($this->modified) {
         $writer->startElementNs('gx', 'modified', null);
         $writer->text($this->modified);
         $writer->endElement();
     }
     if ($this->coverage) {
         foreach ($this->coverage as $i => $x) {
             $writer->startElementNs('gx', 'coverage', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->rights) {
         foreach ($this->rights as $i => $x) {
             $writer->startElementNs('gx', 'rights', null);
             $writer->text($x);
             $writer->endElement();
         }
     }
     if ($this->fields) {
         foreach ($this->fields as $i => $x) {
             $writer->startElementNs('gx', 'field', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->repository) {
         $writer->startElementNs('gx', 'repository', null);
         $this->repository->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->descriptorRef) {
         $writer->startElementNs('gx', 'descriptor', null);
         $this->descriptorRef->writeXmlContents($writer);
         $writer->endElement();
     }
 }
예제 #2
0
 /**
  * @return \Gedcomx\Source\SourceDescription
  */
 private function createSourceDescription()
 {
     $sd = new SourceDescription();
     $citation = new SourceCitation();
     $citation->setValue("\"United States Census, 1900.\" database and digital images, FamilySearch (https://familysearch.org/: accessed 17 Mar 2012), Ethel Hollivet, 1900; citing United States Census Office, Washington, D.C., 1900 Population Census Schedules, Los Angeles, California, population schedule, Los Angeles Ward 6, Enumeration District 58, p. 20B, dwelling 470, family 501, FHL microfilm 1,240,090; citing NARA microfilm publication T623, roll 90.");
     $sd->setCitations(array($citation));
     $title = new TextValue();
     $title->setValue("1900 US Census, Ethel Hollivet");
     $sd->setTitles(array($title));
     $note = new Note();
     $note->setText("Ethel Hollivet (line 75) with husband Albert Hollivet (line 74); also in the dwelling: step-father Joseph E Watkins (line 72), mother Lina Watkins (line 73), and grandmother -- Lina's mother -- Mary Sasnett (line 76).  Albert's mother and brother also appear on this page -- Emma Hollivet (line 68), and Eddie (line 69).");
     $sd->setNotes(array($note));
     $attribution = new Attribution();
     $rr = new ResourceReference();
     $rr->setResource("https://familysearch.org/platform/users/agents/MM6M-8QJ");
     $rr->setResourceId("MM6M-8QJ");
     $attribution->setContributor($rr);
     $attribution->setModified(time());
     $attribution->setChangeMessage("This is the change message");
     $sd->setAttribution($attribution);
     return $sd;
 }
예제 #3
0
 /**
  * @link https://familysearch.org/developers/docs/api/sources/Move_Sources_to_a_User-Defined_Collection_usecase
  */
 public function testMoveSourcesToAUserDefinedCollection()
 {
     $factory = new FamilySearchStateFactory();
     /** @var FamilySearchCollectionState $collection */
     $collection = $this->collectionState($factory, "https://sandbox.familysearch.org/platform/collections/sources");
     $sd = new SourceDescription();
     $citation = new SourceCitation();
     $citation->setValue("\"United States Census, 1900.\" database and digital images, FamilySearch (https://familysearch.org/: accessed 17 Mar 2012), Ethel Hollivet, 1900; citing United States Census Office, Washington, D.C., 1900 Population Census Schedules, Los Angeles, California, population schedule, Los Angeles Ward 6, Enumeration District 58, p. 20B, dwelling 470, family 501, FHL microfilm 1,240,090; citing NARA microfilm publication T623, roll 90.");
     $sd->setCitations(array($citation));
     $title = new TextValue();
     $title->setValue("1900 US Census, Ethel Hollivet");
     $sd->setTitles(array($title));
     $note = new Note();
     $note->setText("Ethel Hollivet (line 75) with husband Albert Hollivet (line 74); also in the dwelling: step-father Joseph E Watkins (line 72), mother Lina Watkins (line 73), and grandmother -- Lina's mother -- Mary Sasnett (line 76).  Albert's mother and brother also appear on this page -- Emma Hollivet (line 68), and Eddie (line 69).");
     $sd->setNotes(array($note));
     $attribution = new Attribution();
     $contributor = new ResourceReference();
     $contributor->setResource("https://familysearch.org/platform/users/agents/MM6M-8QJ");
     $contributor->setResourceId("MM6M-8QJ");
     $attribution->setContributor($contributor);
     $attribution->setModified(time());
     $attribution->setChangeMessage("This is the change message");
     $sd->SetAttribution($attribution);
     /** @var FamilySearchSourceDescriptionState $description */
     $description = $collection->addSourceDescription($sd);
     $this->queueForDelete($description);
     $this->assertEquals(HttpStatus::CREATED, $description->getResponse()->getStatusCode());
     $description = $description->get();
     $this->assertEquals(HttpStatus::OK, $description->getResponse()->getStatusCode());
     /** @var CollectionState $subcollection */
     $c = new Collection();
     $c->setTitle($this->faker->sha1);
     $subcollection = $collection->addCollection($c)->get();
     $this->queueForDelete($subcollection);
     /** @var FamilySearchSourceDescriptionState $state */
     $state = $description->moveToCollection($subcollection);
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals(HttpStatus::NO_CONTENT, $state->getResponse()->getStatusCode());
     // Ensure it doesn't exist in the old collection
     $rootCollection = $this->getRootCollection($collection);
     $found = $this->findInCollection($description->getSourceDescription(), $rootCollection->readSourceDescriptions()->getEntity()->getSourceDescriptions());
     $this->assertFalse($found);
     // Ensure it exists in the new collection
     $found = $this->findInCollection($description->getSourceDescription(), $subcollection->readSourceDescriptions()->getEntity()->getSourceDescriptions());
     $this->assertTrue($found);
 }
예제 #4
0
 public function addDescription($description, $locale)
 {
     $t = new TextValue();
     $this->descriptions[] = $t->setValue($description)->setLang($locale);
     return $this;
 }