Esempio n. 1
0
     return;
 }
 $person = Individual::getInstance($xref, $WT_TREE);
 $family = Family::getInstance($famid, $WT_TREE);
 check_record_access($person);
 check_record_access($family);
 $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child'))->pageHeader();
 // Replace any existing child->family link (we may be changing the PEDI);
 $fact_id = null;
 foreach ($person->getFacts('FAMC') as $fact) {
     if ($family === $fact->getTarget()) {
         $fact_id = $fact->getFactId();
         break;
     }
 }
 $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid);
 $person->updateFact($fact_id, $gedcom, true);
 // Only set the family->child link if it does not already exist
 $edit_fact = null;
 foreach ($family->getFacts('CHIL') as $fact) {
     if ($person === $fact->getTarget()) {
         $edit_fact = $fact;
         break;
     }
 }
 if (!$edit_fact) {
     $family->createFact('1 CHIL @' . $person->getXref() . '@', true);
 }
 $controller->addInlineJavascript('closePopupAndReloadParent();');
 break;
 ////////////////////////////////////////////////////////////////////////////////
Esempio n. 2
0
 /**
  * A label for a parental family group
  *
  * @param Family $family
  *
  * @return string
  */
 public function getChildFamilyLabel(Family $family)
 {
     if (preg_match('/\\n1 FAMC @' . $family->getXref() . '@(?:\\n[2-9].*)*\\n2 PEDI (.+)/', $this->getGedcom(), $match)) {
         // A specified pedigree
         return GedcomCodePedi::getChildFamilyLabel($match[1]);
     } else {
         // Default (birth) pedigree
         return GedcomCodePedi::getChildFamilyLabel('');
     }
 }
Esempio n. 3
0
 /**
  * Generate a recursive list of descendants of an individual.
  * If parents are specified, we can also show the pedigree (adopted, etc.).
  *
  * @param Individual  $individual
  * @param Family|null $parents
  *
  * @return string
  */
 private function getDescendantsHtml(Individual $individual, Family $parents = null)
 {
     // A person has many names. Select the one that matches the searched surname
     $person_name = '';
     foreach ($individual->getAllNames() as $name) {
         list($surn1) = explode(",", $name['sort']);
         if (stripos($surn1, $this->surname) !== false || stripos($this->surname, $surn1) !== false || $this->soundex_std && Soundex::compare(Soundex::russell($surn1), Soundex::russell($this->surname)) || $this->soundex_dm && Soundex::compare(Soundex::daitchMokotoff($surn1), Soundex::daitchMokotoff($this->surname))) {
             $person_name = $name['full'];
             break;
         }
     }
     // No matching name? Typically children with a different surname. The branch stops here.
     if (!$person_name) {
         return '<li title="' . strip_tags($individual->getFullName()) . '">' . $individual->getSexImage() . '…</li>';
     }
     // Is this individual one of our ancestors?
     $sosa = array_search($individual, $this->ancestors, true);
     if ($sosa) {
         $sosa_class = 'search_hit';
         $sosa_html = ' <a class="details1 ' . $individual->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . $this->ancestors[1]->getXref() . '&amp;pid1=' . $individual->getXref() . '">' . $sosa . '</a>' . self::sosaGeneration($sosa);
     } else {
         $sosa_class = '';
         $sosa_html = '';
     }
     // Generate HTML for this individual, and all their descendants
     $indi_html = $individual->getSexImage() . '<a class="' . $sosa_class . '" href="' . $individual->getHtmlUrl() . '">' . $person_name . '</a> ' . $individual->getLifeSpan() . $sosa_html;
     // If this is not a birth pedigree (e.g. an adoption), highlight it
     if ($parents) {
         $pedi = '';
         foreach ($individual->getFacts('FAMC') as $fact) {
             if ($fact->getTarget() === $parents) {
                 $pedi = $fact->getAttribute('PEDI');
                 break;
             }
         }
         if ($pedi && $pedi != 'birth') {
             $indi_html = '<span class="red">' . GedcomCodePedi::getValue($pedi, $individual) . '</span> ' . $indi_html;
         }
     }
     // spouses and children
     $spouse_families = $individual->getSpouseFamilies();
     if ($spouse_families) {
         usort($spouse_families, '\\Fisharebest\\Webtrees\\Family::compareMarrDate');
         $fam_html = '';
         foreach ($spouse_families as $family) {
             $fam_html .= $indi_html;
             // Repeat the individual details for each spouse.
             $spouse = $family->getSpouse($individual);
             if ($spouse) {
                 $sosa = array_search($spouse, $this->ancestors, true);
                 if ($sosa) {
                     $sosa_class = 'search_hit';
                     $sosa_html = ' <a class="details1 ' . $spouse->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . $this->ancestors[1]->getXref() . '&amp;pid1=' . $spouse->getXref() . '"> ' . $sosa . ' </a>' . self::sosaGeneration($sosa);
                 } else {
                     $sosa_class = '';
                     $sosa_html = '';
                 }
                 $marriage_year = $family->getMarriageYear();
                 if ($marriage_year) {
                     $fam_html .= ' <a href="' . $family->getHtmlUrl() . '" title="' . strip_tags($family->getMarriageDate()->display()) . '"><i class="icon-rings"></i>' . $marriage_year . '</a>';
                 } elseif ($family->getFirstFact('MARR')) {
                     $fam_html .= ' <a href="' . $family->getHtmlUrl() . '" title="' . GedcomTag::getLabel('MARR') . '"><i class="icon-rings"></i></a>';
                 } elseif ($family->getFirstFact('_NMR')) {
                     $fam_html .= ' <a href="' . $family->getHtmlUrl() . '" title="' . GedcomTag::getLabel('_NMR') . '"><i class="icon-rings"></i></a>';
                 }
                 $fam_html .= ' ' . $spouse->getSexImage() . '<a class="' . $sosa_class . '" href="' . $spouse->getHtmlUrl() . '">' . $spouse->getFullName() . '</a> ' . $spouse->getLifeSpan() . ' ' . $sosa_html;
             }
             $fam_html .= '<ol>';
             foreach ($family->getChildren() as $child) {
                 $fam_html .= $this->getDescendantsHtml($child, $family);
             }
             $fam_html .= '</ol>';
         }
         return '<li>' . $fam_html . '</li>';
     } else {
         // No spouses - just show the individual
         return '<li>' . $indi_html . '</li>';
     }
 }
Esempio n. 4
0
 /**
  * Print an edit control for a PEDI field.
  *
  * @param string          $name
  * @param string          $selected
  * @param string          $extra
  * @param Individual|null $individual
  *
  * @return string
  */
 public static function editFieldPedigree($name, $selected = '', $extra = '', Individual $individual = null)
 {
     return self::selectEditControl($name, GedcomCodePedi::getValues($individual), '', $selected, $extra);
 }