Пример #1
0
 private function readData($title, $revid)
 {
     $data = array();
     $data['title'] = $title->getText();
     if ($title->getNamespace() == NS_FAMILY) {
         $obj = new Family($title->getText());
     } else {
         $obj = new Person($title->getText());
     }
     $obj->loadPage($revid);
     $xml = $obj->getPageXml();
     if (!$xml) {
         return null;
     }
     MergeForm::readXmlData($title->getNamespace() == NS_FAMILY, $xml, $data);
     return $data;
 }
Пример #2
0
 private function readData()
 {
     $first = true;
     $familyMembers = array();
     foreach ($this->data as &$datai) {
         $j = 0;
         while ($j < count($datai)) {
             $dataij =& $datai[$j];
             if (GedcomUtil::isGedcomTitle($dataij['title'])) {
                 $xml = GedcomUtil::getGedcomXml($this->gedcomData, $dataij['title']);
                 if ($xml['merged'] == 'true' && (string) $xml['match'] == (string) $datai[count($datai) - 1]['title']) {
                     $this->redirects[] = Title::newFromText($dataij['title'], $this->namespace == 'Family' && $first ? NS_FAMILY : NS_PERSON);
                     array_splice($datai, $j, 1);
                     // remove this page from the merge
                     $j--;
                 } else {
                     $dataij['gedcom'] = true;
                     $dataij['object'] = null;
                     $dataij['revid'] = false;
                     $dataij['talkrevid'] = false;
                     MergeForm::readXmlData($this->namespace == 'Family' && $first, $xml, $dataij);
                     $dataij['contents'] = GedcomUtil::getGedcomContents($this->gedcomData, $dataij['title']);
                 }
             } else {
                 $dataij['gedcom'] = false;
                 if ($this->namespace == 'Family' && $first) {
                     $title = Title::newFromText($dataij['title'], NS_FAMILY);
                     $dataij['object'] = new Family($dataij['title']);
                 } else {
                     $title = Title::newFromText($dataij['title'], NS_PERSON);
                     $dataij['object'] = new Person($dataij['title']);
                 }
                 $dataij['revid'] = $title->getLatestRevID(GAID_FOR_UPDATE);
                 // make sure you read the master db
                 $dataij['object']->loadPage($dataij['revid']);
                 $xml = $dataij['object']->getPageXml();
                 $talkTitle = $title->getTalkPage();
                 $dataij['talkrevid'] = $talkTitle->getLatestRevID(GAID_FOR_UPDATE);
                 // make sure you read the master db
                 // this must be a family member
                 // non-family members can appear in gedcom updates -- gedcom page has been matched to a page in another family
                 // or they can appear when the family is do not merge
                 if ($this->namespace == 'Family' && !$first && !@$familyMembers[$dataij['title']]) {
                     array_splice($datai, $j, 1);
                     // remove this page from the merge
                     $j--;
                 } else {
                     if ($this->doNotMerge($datai, $title)) {
                         $this->nomerges[] = $title;
                     } else {
                         if (isset($xml)) {
                             MergeForm::readXmlData($this->namespace == 'Family' && $first, $xml, $dataij);
                             $dataij['contents'] =& $dataij['object']->getPageContents();
                             if ($this->namespace == 'Family' && $first) {
                                 foreach ($xml->husband as $m) {
                                     $familyMembers[(string) $m['title']] = 1;
                                 }
                                 $data['wifeTitle'] = array();
                                 foreach ($xml->wife as $m) {
                                     $familyMembers[(string) $m['title']] = 1;
                                 }
                                 $data['childTitle'] = array();
                                 foreach ($xml->child as $m) {
                                     $familyMembers[(string) $m['title']] = 1;
                                 }
                             }
                         } else {
                             if (StructuredData::isRedirect($dataij['object']->getPageContents())) {
                                 $this->redirects[] = $title;
                                 array_splice($datai, $j, 1);
                                 // remove this page from the merge
                                 $j--;
                             } else {
                                 if ($dataij['revid']) {
                                     // page exists but doesn't have xml and is not a redirect
                                     array_splice($datai, $j, 1);
                                     // remove this page from the merge
                                     $j--;
                                     error_log("ERROR: Merging page exists without XML: " . $title->getPrefixedText() . "\n");
                                 }
                             }
                         }
                     }
                 }
             }
             $j++;
         }
         $first = false;
     }
     $this->removeSingletonFamilyMemberRows();
 }