Пример #1
0
 public static function readFamilyData($titleString, &$data, &$gedcomData, $includeRelativeData = false, $includeNonCompareData = false, $revid = 0, $timestamp = '')
 {
     $children = array();
     $data['familyTitle'][] = $titleString;
     if (GedcomUtil::isGedcomTitle($titleString)) {
         $title = null;
         $data['Exists'] = true;
         $xml = GedcomUtil::getGedcomXml($gedcomData, $titleString);
         $data['GedcomMatchTitle'] = (string) $xml['match'];
         $contents = GedcomUtil::getGedcomContents($gedcomData, $titleString);
     } else {
         $title = Title::newFromText($titleString, NS_FAMILY);
         $data['Exists'] = $title->exists();
         $p = new Family($titleString);
         $p->loadPage($revid);
         if ($revid) {
             $data['Revid'][] = $revid;
         }
         // for consistency with readPersonData
         $xml = $p->getPageXml();
         $contents = $p->getPageContents();
     }
     $husbandFound = $wifeFound = false;
     if ($includeRelativeData) {
         CompareForm::initPersonData('husband', $data);
         CompareForm::initPersonData('wife', $data);
     }
     if (isset($xml)) {
         foreach ($xml->event_fact as $ef) {
             $type = (string) $ef['type'];
             if ($type == Family::$MARRIAGE_TAG || $type == Family::$ALT_MARRIAGE_TAG) {
                 CompareForm::getDatePlace($ef, 'Marriagedate', 'Marriageplace', $data);
             } else {
                 if ($includeNonCompareData) {
                     CompareForm::getOtherEvent($ef, '', $data);
                 }
             }
         }
         if ($includeNonCompareData) {
             CompareForm::getSINContents($xml, $contents, '', $data);
         }
         if ($includeRelativeData) {
             $husbandFound = CompareForm::readRelativeData('husband', $xml->husband, $data, $gedcomData, true, false, $includeNonCompareData, $timestamp);
             $wifeFound = CompareForm::readRelativeData('wife', $xml->wife, $data, $gedcomData, true, false, $includeNonCompareData, $timestamp);
             $i = 0;
             foreach ($xml->child as $c) {
                 $childTitle = (string) $c['title'];
                 if ($childTitle) {
                     $children[$i] = array();
                     CompareForm::initPersonData('child', $children[$i]);
                     if (GedcomUtil::isGedcomTitle($childTitle)) {
                         $childRevid = 0;
                     } else {
                         $t = Title::newFromText($childTitle, NS_PERSON);
                         $childRevid = $timestamp ? StructuredData::getRevidForTimestamp($t, $timestamp) : 0;
                     }
                     CompareForm::readPersonData('child', $childTitle, $children[$i], $gedcomData, false, false, true, $includeNonCompareData, $childRevid);
                     $i++;
                 }
             }
         } else {
             $data['husbandTitle'] = array();
             foreach ($xml->husband as $m) {
                 $data['husbandTitle'][] = (string) $m['title'];
             }
             $data['wifeTitle'] = array();
             foreach ($xml->wife as $m) {
                 $data['wifeTitle'][] = (string) $m['title'];
             }
             $data['childTitle'] = array();
             foreach ($xml->child as $m) {
                 $data['childTitle'][] = (string) $m['title'];
             }
         }
     } else {
         if ($title && StructuredData::isRedirect($contents)) {
             $data['Redirect'] = true;
         }
     }
     if ($includeRelativeData && (!$husbandFound || !$wifeFound)) {
         list($fg, $fs, $mg, $ms) = StructuredData::parseFamilyTitle($titleString);
         if (!$husbandFound) {
             if ($fg) {
                 $data['husbandGiven'][] = $fg;
             }
             if ($fs) {
                 $data['husbandSurname'][] = $fs;
             }
         }
         if (!$wifeFound) {
             if ($mg) {
                 $data['wifeGiven'][] = $mg;
             }
             if ($ms) {
                 $data['wifeSurname'][] = $ms;
             }
         }
     }
     $data['Nomerge'] = CompareForm::getNomergeTitleStrings($title);
     if ($title) {
         $data['Updatable'] = CompareForm::isUpdatable($title, $contents);
     }
     return $children;
 }
Пример #2
0
 public function getUpdatable()
 {
     for ($m = 0; $m < count($this->data); $m++) {
         //   		$addedData = false;
         for ($p = 0; $p < count($this->data[$m]); $p++) {
             if (!GedcomUtil::isGedcomTitle($this->data[$m][$p]['title'])) {
                 $this->data[$m][$p]['updatable'] = CompareForm::isUpdatable($this->data[$m][$p]['object']->getTitle(), $this->data[$m][$p]['contents']);
             }
             //	   		if ($this->isGedcom() && $this->isSecondPhase() && $p > 0) {
             //					for ($r = 0; $r < count($this->add[$m][$p]); $r++) {
             //						if ($this->add[$m][$p][$r]) {
             //							$addedData = true;
             //							break;
             //						}
             //					}
             //	   		}
         }
         // Don't update if the user hasn't added/removed any data
         // We could do this for normal merges as well, but we might need to make Family always updatable
         //	   	if ($this->isGedcom() && $this->isSecondPhase()) {
         //				if (!$addedData && !$this->data[$m][0]['missingdata']) {
         //					$this->data[$m][0]['updatable'] = false;
         //				}
         //	   	}
     }
 }