/**
  * Generate the likely value of this census column, based on available information.
  *
  * @param Individual      $individual
  * @param Individual|null $head
  *
  * @return string
  */
 public function generate(Individual $individual, Individual $head = null)
 {
     foreach ($individual->getAllNames() as $name) {
         return $name['surn'] . ', ' . $name['givn'];
     }
     return '';
 }
Ejemplo n.º 2
0
 /**
  * Generate a SURN,GIVN and GIVN,SURN sortable name for an individual.
  * This allows table data to sort by surname or given names.
  *
  * Use AAAA as a separator (instead of ","), as Javascript localeCompare()
  * ignores punctuation and "ANN,ROACH" would sort after "ANNE,ROACH",
  * instead of before it.
  *
  * @param Individual $individual
  *
  * @return string[]
  */
 private static function sortableNames(Individual $individual)
 {
     $names = $individual->getAllNames();
     $primary = $individual->getPrimaryName();
     list($surn, $givn) = explode(',', $names[$primary]['sort']);
     $givn = str_replace('@P.N.', 'AAAA', $givn);
     $surn = str_replace('@N.N.', 'AAAA', $surn);
     return array($surn . 'AAAA' . $givn, $givn . 'AAAA' . $surn);
 }
 /**
  * Generate the likely value of this census column, based on available information.
  *
  * @param Individual      $individual
  * @param Individual|null $head
  *
  * @return string
  */
 public function generate(Individual $individual, Individual $head = null)
 {
     foreach ($individual->getAllNames() as $name) {
         $given = $name['givn'];
         if (strpos($given, ' ') === false) {
             return $given;
         } else {
             return substr($given, 0, strpos($given, ' ') + 2);
         }
     }
     return '';
 }
Ejemplo n.º 4
0
 /**
  * What was an individual's likely name on a given date, allowing
  * for marriages and married names.
  *
  * @param Individual $individual
  * @param Date       $census_date
  *
  * @return string[]
  */
 protected function nameAtCensusDate(Individual $individual, Date $census_date)
 {
     $names = $individual->getAllNames();
     $name = $names[0];
     foreach ($individual->getSpouseFamilies() as $family) {
         foreach ($family->getFacts('MARR') as $marriage) {
             if ($marriage->getDate()->isOK() && Date::compare($marriage->getDate(), $census_date) < 0) {
                 $spouse = $family->getSpouse($individual);
                 foreach ($names as $individual_name) {
                     foreach ($spouse->getAllNames() as $spouse_name) {
                         if ($individual_name['type'] === '_MARNM' && $individual_name['surn'] === $spouse_name['surn']) {
                             return $individual_name;
                         }
                     }
                 }
             }
         }
     }
     return $name;
 }
Ejemplo n.º 5
0
 /**
  * print information for a name record
  *
  * @param Fact $event the event object
  */
 public function printNameRecord(Fact $event)
 {
     $factrec = $event->getGedcom();
     // Create a dummy record, so we can extract the formatted NAME value from the event.
     $dummy = new Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, $event->getParent()->getTree());
     $all_names = $dummy->getAllNames();
     $primary_name = $all_names[0];
     $this->name_count++;
     if ($this->name_count > 1) {
         echo '<h3 class="name_two">', $dummy->getFullName(), '</h3>';
     }
     //Other names accordion element
     echo '<div class="indi_name_details';
     if ($event->isPendingDeletion()) {
         echo ' old';
     }
     if ($event->isPendingAddition()) {
         echo ' new';
     }
     echo '">';
     echo '<div class="name1">';
     echo '<dl><dt class="label">', I18N::translate('Name'), '</dt>';
     $dummy->setPrimaryName(0);
     echo '<dd class="field">', $dummy->getFullName();
     if ($this->name_count == 1) {
         if (Auth::isAdmin()) {
             $user = User::findByGenealogyRecord($this->record);
             if ($user) {
                 echo '<span> - <a class="warning" href="admin_users.php?filter=' . Filter::escapeHtml($user->getUserName()) . '">' . Filter::escapeHtml($user->getUserName()) . '</a></span>';
             }
         }
     }
     if ($this->record->canEdit() && !$event->isPendingDeletion()) {
         echo "<div class=\"deletelink\"><a class=\"deleteicon\" href=\"#\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '" . $this->record->getXref() . "', '" . $event->getFactId() . "');\" title=\"" . I18N::translate('Delete this name') . "\"><span class=\"link_text\">" . I18N::translate('Delete this name') . "</span></a></div>";
         echo "<div class=\"editlink\"><a href=\"#\" class=\"editicon\" onclick=\"edit_name('" . $this->record->getXref() . "', '" . $event->getFactId() . "'); return false;\" title=\"" . I18N::translate('Edit name') . "\"><span class=\"link_text\">" . I18N::translate('Edit name') . "</span></a></div>";
     }
     echo '</dd>';
     echo '</dl>';
     echo '</div>';
     $ct = preg_match_all('/\\n2 (\\w+) (.*)/', $factrec, $nmatch, PREG_SET_ORDER);
     for ($i = 0; $i < $ct; $i++) {
         echo '<div>';
         $fact = $nmatch[$i][1];
         if ($fact != 'SOUR' && $fact != 'NOTE' && $fact != 'SPFX') {
             echo '<dl><dt class="label">', GedcomTag::getLabel($fact, $this->record), '</dt>';
             echo '<dd class="field">';
             // Before using dir="auto" on this field, note that Gecko treats this as an inline element but WebKit treats it as a block element
             if (isset($nmatch[$i][2])) {
                 $name = Filter::escapeHtml($nmatch[$i][2]);
                 $name = str_replace('/', '', $name);
                 $name = preg_replace('/(\\S*)\\*/', '<span class="starredname">\\1</span>', $name);
                 switch ($fact) {
                     case 'TYPE':
                         echo GedcomCodeName::getValue($name, $this->record);
                         break;
                     case 'SURN':
                         // The SURN field is not necessarily the surname.
                         // Where it is not a substring of the real surname, show it after the real surname.
                         $surname = Filter::escapeHtml($primary_name['surname']);
                         if (strpos($primary_name['surname'], str_replace(',', ' ', $nmatch[$i][2])) !== false) {
                             echo '<span dir="auto">' . $surname . '</span>';
                         } else {
                             echo I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $surname . '</span>', '<span dir="auto">' . $name . '</span>');
                         }
                         break;
                     default:
                         echo '<span dir="auto">' . $name . '</span>';
                         break;
                 }
             }
             echo '</dd>';
             echo '</dl>';
         }
         echo '</div>';
     }
     if (preg_match("/\n2 SOUR/", $factrec)) {
         echo '<div id="indi_sour" class="clearfloat">', FunctionsPrintFacts::printFactSources($factrec, 2), '</div>';
     }
     if (preg_match("/\n2 NOTE/", $factrec)) {
         echo '<div id="indi_note" class="clearfloat">', FunctionsPrint::printFactNotes($factrec, 2), '</div>';
     }
     echo '</div>';
 }
Ejemplo n.º 6
0
    /**
     * {@inhericDoc}
     * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
     */
    protected function renderContent()
    {
        if ($this->data->get('has_sosa', false)) {
            $table_id = $this->data->get('table_id');
            ?>
   
        
		<div id="sosa-fam-list" class="sosa-list">
			<table id="<?php 
            echo $table_id;
            ?>
">
				<thead>
					<tr>
						<th colspan="24">
							<div class="btn-toolbar">
								<div class="btn-group">
									<button
										type="button"
										data-filter-column="22"
										data-filter-value="N"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show individuals who are alive or couples where both partners are alive.');
            ?>
"
									>
									<?php 
            echo I18N::translate('Both alive');
            ?>
									</button>
									<button
										type="button"
										data-filter-column="22"
										data-filter-value="W"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show couples where only the female partner is deceased.');
            ?>
"
									>
									<?php 
            echo I18N::translate('Widower');
            ?>
									</button>
									<button
										type="button"
										data-filter-column="22"
										data-filter-value="H"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show couples where only the male partner is deceased.');
            ?>
"
									>
									<?php 
            echo I18N::translate('Widow');
            ?>
									</button>
									<button
										type="button"
										data-filter-column="22"
										data-filter-value="Y"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show individuals who are dead or couples where both partners are deceased.');
            ?>
"
									>
									<?php 
            echo I18N::translate('Both dead');
            ?>
									</button>
								</div>
								<div class="btn-group">
									<button
										type="button"
										data-filter-column="23"
										data-filter-value="R"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show “roots” couples or individuals.  These individuals may also be called “patriarchs”.  They are individuals who have no parents recorded in the database.');
            ?>
"
									>
									<?php 
            echo I18N::translate('Roots');
            ?>
									</button>
									<button
										type="button"
										data-filter-column="23"
										data-filter-value="L"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show “leaves” couples or individuals.  These are individuals who are alive but have no children recorded in the database.');
            ?>
"
									>
									<?php 
            echo I18N::translate('Leaves');
            ?>
									</button>
								</div>
								<div class="btn-group">
									<button
										type="button"
										data-filter-column="21"
										data-filter-value="U"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show couples with an unknown marriage date.');
            ?>
"
									>
									<?php 
            echo GedcomTag::getLabel('MARR');
            ?>
									</button>
									<button
										type="button"
										data-filter-column="21"
										data-filter-value="YES"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show couples who married more than 100 years ago.');
            ?>
"
									>
									<?php 
            echo GedcomTag::getLabel('MARR');
            ?>
&gt;100
									</button>
									<button
										type="button"
										data-filter-column="21"
										data-filter-value="Y100"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show couples who married within the last 100 years.');
            ?>
"
									>
									<?php 
            echo GedcomTag::getLabel('MARR');
            ?>
&lt;=100
									</button>
									<button
										type="button"
										data-filter-column="21"
										data-filter-value="D"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show divorced couples.');
            ?>
"
									>
									<?php 
            echo GedcomTag::getLabel('DIV');
            ?>
									</button>
									<button
										type="button"
										data-filter-column="21"
										data-filter-value="M"
										class="ui-state-default"
										title="<?php 
            echo I18N::translate('Show couples where either partner married more than once.');
            ?>
"
									>
									<?php 
            echo I18N::translate('Multiple marriages');
            ?>
									</button>
								</div>
							</div>
						</th>
					</tr>
					<tr>
						<th><?php 
            echo I18N::translate('Sosa');
            ?>
</th>
						<th>SOSA</th>
						<th><?php 
            echo GedcomTag::getLabel('GIVN');
            ?>
</th>
						<th><?php 
            echo GedcomTag::getLabel('SURN');
            ?>
</th>
						<th>HUSB:GIVN_SURN</th>
						<th>HUSB:SURN_GIVN</th>
						<th><?php 
            echo GedcomTag::getLabel('AGE');
            ?>
</th>
						<th>AGE</th>
						<th><?php 
            echo GedcomTag::getLabel('GIVN');
            ?>
</th>
						<th><?php 
            echo GedcomTag::getLabel('SURN');
            ?>
</th>
						<th>WIFE:GIVN_SURN</th>
						<th>WIFE:SURN_GIVN</th>
						<th><?php 
            echo GedcomTag::getLabel('AGE');
            ?>
</th>
						<th>AGE</th>
						<th><?php 
            echo GedcomTag::getLabel('MARR');
            ?>
</th>
						<th>MARR:DATE</th>
						<th><?php 
            echo GedcomTag::getLabel('PLAC');
            ?>
</th>';
						<?php 
            if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) {
                ?>
						<th><i class="icon-source" title="<?php 
                echo I18N::translate('Sourced marriage');
                ?>
" border="0"></i></th>
						<th>SORT_MARRSC</th>
						<?php 
            } else {
                ?>
						<th>&nbsp;</th>
						<th></th>
						<?php 
            }
            ?>
						<th><i class="icon-children" title="<?php 
            echo I18N::translate('Children');
            ?>
"></i></th>
						<th>NCHI</th>
						<th>MARR</th>
						<th>DEAT</th>
						<th>TREE</th>
					</tr>
				</thead>
				<tbody>
			
			<?php 
            foreach ($this->data->get('sosa_list') as $sosa => $family) {
                /** @var \Fisharebest\Webtrees\Family $person */
                //PERSO Create decorator for Family
                $dfamily = new Family($family);
                $husb = $family->getHusband();
                if (is_null($husb)) {
                    $husb = new Individual('H', '0 @H@ INDI', null, $family->getTree());
                }
                $dhusb = new \MyArtJaub\Webtrees\Individual($husb);
                $wife = $family->getWife();
                if (is_null($wife)) {
                    $wife = new Individual('W', '0 @W@ INDI', null, $family->getTree());
                }
                $dwife = new \MyArtJaub\Webtrees\Individual($wife);
                $mdate = $family->getMarriageDate();
                if ($family->isPendingAddtion()) {
                    $class = ' class="new"';
                } elseif ($family->isPendingDeletion()) {
                    $class = ' class="old"';
                } else {
                    $class = '';
                }
                ?>
			
        		<tr <?php 
                echo $class;
                ?>
>
        			<td class="transparent"><?php 
                echo I18N::translate('%1$d/%2$d', $sosa, ($sosa + 1) % 10);
                ?>
</td>
        			<td class="transparent"><?php 
                echo $sosa;
                ?>
</td>
        			<!--  HUSBAND -->
        			<td colspan="2">
        			<?php 
                foreach ($husb->getAllNames() as $num => $name) {
                    if ($name['type'] == 'NAME') {
                        $title = '';
                    } else {
                        $title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $husb)) . '"';
                    }
                    if ($num == $husb->getPrimaryName()) {
                        $class = ' class="name2"';
                        $sex_image = $husb->getSexImage();
                        list($surn, $givn) = explode(',', $name['sort']);
                    } else {
                        $class = '';
                        $sex_image = '';
                    }
                    ?>
        				<a <?php 
                    echo $title . ' ' . $class;
                    ?>
 href="<?php 
                    echo $husb->getHtmlUrl();
                    ?>
">
        					<?php 
                    echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']);
                    ?>
        				</a>
        				<?php 
                    echo $sex_image . FunctionsPrint::formatSosaNumbers($dhusb->getSosaNumbers(), 1, 'smaller');
                    ?>
        				<br/>
            		<?php 
                }
                echo $husb->getPrimaryParentsNames('parents details1', 'none');
                ?>
            		</td>
            		<!-- Dummy column to match colspan in header -->
            		<td style="display:none;"></td>
            		<td>
            			<?php 
                echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn));
                ?>
            		</td>
            		<td>
            			<?php 
                echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn));
                ?>
            		</td>
            		<?php 
                $hdate = $husb->getBirthDate();
                ?>
            		<td><?php 
                Date::getAge($hdate, $mdate, 2);
                ?>
</td>
            		<td><?php 
                Date::getAge($hdate, $mdate, 1);
                ?>
</td>
            		<!--  WIFE -->
        			<td colspan="2">
        			<?php 
                foreach ($wife->getAllNames() as $num => $name) {
                    if ($name['type'] == 'NAME') {
                        $title = '';
                    } else {
                        $title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $wife)) . '"';
                    }
                    if ($num == $wife->getPrimaryName()) {
                        $class = ' class="name2"';
                        $sex_image = $wife->getSexImage();
                        list($surn, $givn) = explode(',', $name['sort']);
                    } else {
                        $class = '';
                        $sex_image = '';
                    }
                    ?>
        				<a <?php 
                    echo $title . ' ' . $class;
                    ?>
 href="<?php 
                    echo $wife->getHtmlUrl();
                    ?>
">
        					<?php 
                    echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']);
                    ?>
        				</a>
        				<?php 
                    echo $sex_image . FunctionsPrint::formatSosaNumbers($dwife->getSosaNumbers(), 1, 'smaller');
                    ?>
        				<br/>
            		<?php 
                }
                echo $wife->getPrimaryParentsNames('parents details1', 'none');
                ?>
            		</td>
            		<!-- Dummy column to match colspan in header -->
            		<td style="display:none;"></td>
            		<td>
            			<?php 
                echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn));
                ?>
            		</td>
            		<td>
            			<?php 
                echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn));
                ?>
            		</td>
            		<?php 
                $wdate = $wife->getBirthDate();
                ?>
            		<td><?php 
                Date::getAge($wdate, $mdate, 2);
                ?>
</td>
            		<td><?php 
                Date::getAge($wdate, $mdate, 1);
                ?>
</td>
            		<td><?php 
                if ($marriage_dates = $family->getAllMarriageDates()) {
                    foreach ($marriage_dates as $n => $marriage_date) {
                        if ($n) {
                            echo '<br>';
                        }
                        ?>
        					<div><?php 
                        echo $marriage_date->display(true);
                        ?>
</div>
        				<?php 
                    }
                } elseif ($family->getFacts('_NMR')) {
                    echo I18N::translate('no');
                } elseif ($family->getFacts('MARR')) {
                    echo I18N::translate('yes');
                } else {
                    echo '&nbsp;';
                }
                ?>
            		</td>
            		<td><?php 
                echo $marriage_dates ? $marriage_date->julianDay() : 0;
                ?>
</td>
            		<td><?php 
                foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) {
                    $tmp = new Place($marriage_place, $family->getTree());
                    if ($n) {
                        ?>
<br><?php 
                    }
                    ?>
        				<a href="'<?php 
                    echo $tmp->getURL();
                    ?>
" title="<?php 
                    echo strip_tags($tmp->getFullName());
                    ?>
">
        					<?php 
                    echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName());
                    ?>
        				</a>
        			<?php 
                }
                ?>
        			</td>
        			<?php 
                if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) {
                    $isMSourced = $dfamily->isMarriageSourced();
                    ?>
				   	<td><?php 
                    echo FunctionsPrint::formatIsSourcedIcon('E', $isMSourced, 'MARR', 1, 'medium');
                    ?>
</td>
					<td><?php 
                    echo $isMSourced;
                    ?>
</td>
					<?php 
                } else {
                    ?>
					<td>&nbsp;</td>
					<td></td>
					<?php 
                }
                ?>
					<?php 
                $nchi = $family->getNumberOfChildren();
                ?>
					<td><?php 
                echo I18N::number($nchi);
                ?>
</td>
					<td><?php 
                echo $nchi;
                ?>
</td>
					<td><?php 
                if (!$mdate->isOK()) {
                    echo 'U';
                } else {
                    if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) {
                        echo 'Y100';
                    } else {
                        echo 'YES';
                    }
                }
                if ($family->getFacts(WT_EVENTS_DIV)) {
                    echo 'D';
                }
                if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) {
                    echo 'M';
                }
                ?>
					</td>
					<td><?php 
                if ($husb->isDead() && $wife->isDead()) {
                    echo 'Y';
                }
                if ($husb->isDead() && !$wife->isDead()) {
                    if ($wife->getSex() == 'F') {
                        echo 'H';
                    }
                    if ($wife->getSex() == 'M') {
                        echo 'W';
                    }
                    // male partners
                }
                if (!$husb->isDead() && $wife->isDead()) {
                    if ($husb->getSex() == 'M') {
                        echo 'W';
                    }
                    if ($husb->getSex() == 'F') {
                        echo 'H';
                    }
                    // female partners
                }
                if (!$husb->isDead() && !$wife->isDead()) {
                    echo 'N';
                }
                ?>
        			</td>
        			<td><?php 
                if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) {
                    echo 'R';
                } elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) {
                    echo 'L';
                } else {
                    echo '&nbsp;';
                }
                ?>
			         </td>
				</tr>
        	<?php 
            }
            ?>
        	</tbody>
        	<tfoot>
				<tr>
					<th colspan="24">
						<div class="btn-toolbar">
							<div class="btn-group">
								<button type="button" class="ui-state-default btn-toggle-parents">
									<?php 
            echo I18N::translate('Show parents');
            ?>
								</button>
								<button id="btn-toggle-statistics-<?php 
            echo $table_id;
            ?>
" type="button" class="ui-state-default btn-toggle-statistics">
									<?php 
            echo I18N::translate('Show statistics charts');
            ?>
								</button>
							</div>
						</div>
					</th>
				</tr>
			</tfoot>
        	</table>
				<div id="fam_list_table-charts_<?php 
            echo $table_id;
            ?>
" style="display:none">
					<table class="list-charts">
						<tr>
							<td><?php 
            echo $this->data->get('chart_births');
            ?>
</td>
							<td><?php 
            echo $this->data->get('chart_marriages');
            ?>
</td>
						</tr>
						<tr>
							<td colspan="2"><?php 
            echo $this->data->get('chart_ages');
            ?>
</td>
						</tr>
					</table>
				</div>
			</div>
		<?php 
        } else {
            ?>
        <p class="warning"><?php 
            echo I18N::translate('No family has been found for generation %d', $this->data->get('generation'));
            ?>
</p>
        <?php 
        }
    }
Ejemplo n.º 7
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>';
     }
 }
 /**
  * Based on function print_name_record() in /app/Controller/IndividualController.php
  * 
  * @param Fact $event
  * @return array
  */
 protected function getPrimaryName(Fact $event)
 {
     $factrec = $event->getGedCom();
     // Create a dummy record, so we can extract the formatted NAME value from the event.
     $dummy = new Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, $event->getParent()->getTree());
     $all_names = $dummy->getAllNames();
     return $all_names[0];
 }
Ejemplo n.º 9
0
    /**
     * Print a table of families
     *
     * @param Family[] $datalist
     *
     * @return string
     */
    public static function familyTable($datalist)
    {
        global $WT_TREE, $controller;
        $table_id = 'table-fam-' . Uuid::uuid4();
        // lists requires a unique ID in case there are multiple lists per page
        $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript('
				jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
				jQuery.fn.dataTableExt.oSort["unicode-desc"]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
				jQuery("#' . $table_id . '").dataTable( {
					dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
					' . I18N::datatablesI18N() . ',
					jQueryUI: true,
					autoWidth: false,
					processing: true,
					retrieve: true,
					columns: [
						/*  0 husb givn */ {dataSort: 2},
						/*  1 husb surn */ {dataSort: 3},
						/*  2 GIVN,SURN */ {type: "unicode", visible: false},
						/*  3 SURN,GIVN */ {type: "unicode", visible: false},
						/*  4 age       */ {dataSort: 5, class: "center"},
						/*  5 AGE       */ {type: "num", visible: false},
						/*  6 wife givn */ {dataSort: 8},
						/*  7 wife surn */ {dataSort: 9},
						/*  8 GIVN,SURN */ {type: "unicode", visible: false},
						/*  9 SURN,GIVN */ {type: "unicode", visible: false},
						/* 10 age       */ {dataSort: 11, class: "center"},
						/* 11 AGE       */ {type: "num", visible: false},
						/* 12 marr date */ {dataSort: 13},
						/* 13 MARR:DATE */ {visible: false},
						/* 14 anniv     */ {dataSort: 13, class: "center"},
						/* 15 marr plac */ {type: "unicode"},
						/* 16 children  */ {dataSort: 17, class: "center"},
						/* 17 NCHI      */ {type: "num", visible: false},
						/* 18 CHAN      */ {dataSort: 19, visible: ' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? 'true' : 'false') . '},
						/* 19 CHAN_sort */ {visible: false},
						/* 20 MARR      */ {visible: false},
						/* 21 DEAT      */ {visible: false},
						/* 22 TREE      */ {visible: false}
					],
					sorting: [[1, "asc"]],
					displayLength: 20,
					pagingType: "full_numbers"
			   });

				jQuery("#' . $table_id . '")
				/* Hide/show parents */
				.on("click", ".btn-toggle-parents", function() {
					jQuery(this).toggleClass("ui-state-active");
					jQuery(".parents", jQuery(this).closest("table").DataTable().rows().nodes()).slideToggle();
				})
				/* Hide/show statistics */
				.on("click",  ".btn-toggle-statistics", function() {
					jQuery(this).toggleClass("ui-state-active");
					jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle();
				})
				/* Filter buttons in table header */
				.on("click", "button[data-filter-column]", function() {
					var btn = $(this);
					// De-activate the other buttons in this button group
					btn.siblings().removeClass("ui-state-active");
					// Apply (or clear) this filter
					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
					if (btn.hasClass("ui-state-active")) {
						btn.removeClass("ui-state-active");
						col.search("").draw();
					} else {
						btn.addClass("ui-state-active");
						col.search(btn.data("filter-value")).draw();
					}
				});

				jQuery(".fam-list").css("visibility", "visible");
				jQuery(".loading-image").css("display", "none");
		');
        $stats = new Stats($WT_TREE);
        $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1;
        //-- init chart data
        $marr_by_age = array();
        for ($age = 0; $age <= $max_age; $age++) {
            $marr_by_age[$age] = '';
        }
        $birt_by_decade = array();
        $marr_by_decade = array();
        for ($year = 1550; $year < 2030; $year += 10) {
            $birt_by_decade[$year] = '';
            $marr_by_decade[$year] = '';
        }
        $html = '
			<div class="loading-image">&nbsp;</div>
			<div class="fam-list">
				<table id="' . $table_id . '">
					<thead>
						<tr>
							<th colspan="23">
								<div class="btn-toolbar">
									<div class="btn-group">
										<button
											type="button"
											data-filter-column="21"
											data-filter-value="N"
											class="ui-state-default"
											title="' . I18N::translate('Show individuals who are alive or couples where both partners are alive.') . '"
										>
											' . I18N::translate('Both alive') . '
										</button>
										<button
											type="button"
											data-filter-column="21"
											data-filter-value="W"
											class="ui-state-default"
											title="' . I18N::translate('Show couples where only the female partner is deceased.') . '"
										>
											' . I18N::translate('Widower') . '
										</button>
										<button
											type="button"
											data-filter-column="21"
											data-filter-value="H"
											class="ui-state-default"
											title="' . I18N::translate('Show couples where only the male partner is deceased.') . '"
										>
											' . I18N::translate('Widow') . '
										</button>
										<button
											type="button"
											data-filter-column="21"
											data-filter-value="Y"
											class="ui-state-default"
											title="' . I18N::translate('Show individuals who are dead or couples where both partners are deceased.') . '"
										>
											' . I18N::translate('Both dead') . '
										</button>
									</div>
									<div class="btn-group">
										<button
											type="button"
											data-filter-column="22"
											data-filter-value="R"
											class="ui-state-default"
											title="' . I18N::translate('Show “roots” couples or individuals.  These individuals may also be called “patriarchs”.  They are individuals who have no parents recorded in the database.') . '"
										>
											' . I18N::translate('Roots') . '
										</button>
										<button
											type="button"
											data-filter-column="22"
											data-filter-value="L"
											class="ui-state-default"
											title="' . I18N::translate('Show “leaves” couples or individuals.  These are individuals who are alive but have no children recorded in the database.') . '"
										>
											' . I18N::translate('Leaves') . '
										</button>
									</div>
									<div class="btn-group">
										<button
											type="button"
											data-filter-column="20"
											data-filter-value="U"
											class="ui-state-default"
											title="' . I18N::translate('Show couples with an unknown marriage date.') . '"
										>
											' . GedcomTag::getLabel('MARR') . '
										</button>
										<button
											type="button"
											data-filter-column="20"
											data-filter-value="YES"
											class="ui-state-default"
											title="' . I18N::translate('Show couples who married more than 100 years ago.') . '"
										>
											' . GedcomTag::getLabel('MARR') . '&gt;100
										</button>
										<button
											type="button"
											data-filter-column="20"
											data-filter-value="Y100"
											class="ui-state-default"
											title="' . I18N::translate('Show couples who married within the last 100 years.') . '"
										>
											' . GedcomTag::getLabel('MARR') . '&lt;=100
										</button>
										<button
											type="button"
											data-filter-column="20"
											data-filter-value="D"
											class="ui-state-default"
											title="' . I18N::translate('Show divorced couples.') . '"
										>
											' . GedcomTag::getLabel('DIV') . '
										</button>
										<button
											type="button"
											data-filter-column="20"
											data-filter-value="M"
											class="ui-state-default"
											title="' . I18N::translate('Show couples where either partner married more than once.') . '"
										>
											' . I18N::translate('Multiple marriages') . '
										</button>
									</div>
								</div>
							</th>
						</tr>
						<tr>
							<th>' . GedcomTag::getLabel('GIVN') . '</th>
							<th>' . GedcomTag::getLabel('SURN') . '</th>
							<th>HUSB:GIVN_SURN</th>
							<th>HUSB:SURN_GIVN</th>
							<th>' . GedcomTag::getLabel('AGE') . '</th>
							<th>AGE</th>
							<th>' . GedcomTag::getLabel('GIVN') . '</th>
							<th>' . GedcomTag::getLabel('SURN') . '</th>
							<th>WIFE:GIVN_SURN</th>
							<th>WIFE:SURN_GIVN</th>
							<th>' . GedcomTag::getLabel('AGE') . '</th>
							<th>AGE</th>
							<th>' . GedcomTag::getLabel('MARR') . '</th>
							<th>MARR:DATE</th>
							<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>
							<th>' . GedcomTag::getLabel('PLAC') . '</th>
							<th><i class="icon-children" title="' . I18N::translate('Children') . '"></i></th>
						<th>NCHI</th>
						<th>' . GedcomTag::getLabel('CHAN') . '</th>
						<th>CHAN</th>
						<th>MARR</th>
						<th>DEAT</th>
						<th>TREE</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th colspan="23">
							<div class="btn-toolbar">
								<div class="btn-group">
									<button type="button" class="ui-state-default btn-toggle-parents">
										' . I18N::translate('Show parents') . '
									</button>
									<button type="button" class="ui-state-default btn-toggle-statistics">
										' . I18N::translate('Show statistics charts') . '
									</button>
								</div>
							</div>
						</th>
					</tr>
				</tfoot>
				<tbody>';
        $d100y = new Date(date('Y') - 100);
        // 100 years ago
        foreach ($datalist as $family) {
            //-- Retrieve husband and wife
            $husb = $family->getHusband();
            if (is_null($husb)) {
                $husb = new Individual('H', '0 @H@ INDI', null, $family->getTree());
            }
            $wife = $family->getWife();
            if (is_null($wife)) {
                $wife = new Individual('W', '0 @W@ INDI', null, $family->getTree());
            }
            if (!$family->canShow()) {
                continue;
            }
            if ($family->isPendingAddtion()) {
                $class = ' class="new"';
            } elseif ($family->isPendingDeletion()) {
                $class = ' class="old"';
            } else {
                $class = '';
            }
            $html .= '<tr' . $class . '>';
            //-- Husband name(s)
            $html .= '<td colspan="2">';
            foreach ($husb->getAllNames() as $num => $name) {
                if ($name['type'] == 'NAME') {
                    $title = '';
                } else {
                    $title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $husb)) . '"';
                }
                if ($num == $husb->getPrimaryName()) {
                    $class = ' class="name2"';
                    $sex_image = $husb->getSexImage();
                    list($surn, $givn) = explode(',', $name['sort']);
                } else {
                    $class = '';
                    $sex_image = '';
                }
                // Only show married names if they are the name we are filtering by.
                if ($name['type'] != '_MARNM' || $num == $husb->getPrimaryName()) {
                    $html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . FunctionsPrint::highlightSearchHits($name['full']) . '</a>' . $sex_image . '<br>';
                }
            }
            // Husband parents
            $html .= $husb->getPrimaryParentsNames('parents details1', 'none');
            $html .= '</td>';
            // Dummy column to match colspan in header
            $html .= '<td style="display:none;"></td>';
            //-- Husb GIVN
            // Use "AAAA" as a separator (instead of ",") as Javascript.localeCompare() ignores
            // punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it.
            // Similarly, @N.N. would sort as NN.
            $html .= '<td>' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . '</td>';
            $html .= '<td>' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . '</td>';
            $mdate = $family->getMarriageDate();
            //-- Husband age
            $hdate = $husb->getBirthDate();
            if ($hdate->isOK() && $mdate->isOK()) {
                if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) {
                    $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
                }
                $hage = Date::getAge($hdate, $mdate, 0);
                if ($hage >= 0 && $hage <= $max_age) {
                    $marr_by_age[$hage] .= $husb->getSex();
                }
            }
            $html .= '<td>' . Date::getAge($hdate, $mdate, 2) . '</td><td>' . Date::getAge($hdate, $mdate, 1) . '</td>';
            //-- Wife name(s)
            $html .= '<td colspan="2">';
            foreach ($wife->getAllNames() as $num => $name) {
                if ($name['type'] == 'NAME') {
                    $title = '';
                } else {
                    $title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $wife)) . '"';
                }
                if ($num == $wife->getPrimaryName()) {
                    $class = ' class="name2"';
                    $sex_image = $wife->getSexImage();
                    list($surn, $givn) = explode(',', $name['sort']);
                } else {
                    $class = '';
                    $sex_image = '';
                }
                // Only show married names if they are the name we are filtering by.
                if ($name['type'] != '_MARNM' || $num == $wife->getPrimaryName()) {
                    $html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . FunctionsPrint::highlightSearchHits($name['full']) . '</a>' . $sex_image . '<br>';
                }
            }
            // Wife parents
            $html .= $wife->getPrimaryParentsNames('parents details1', 'none');
            $html .= '</td>';
            // Dummy column to match colspan in header
            $html .= '<td style="display:none;"></td>';
            //-- Wife GIVN
            //-- Husb GIVN
            // Use "AAAA" as a separator (instead of ",") as Javascript.localeCompare() ignores
            // punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it.
            // Similarly, @N.N. would sort as NN.
            $html .= '<td>' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . '</td>';
            $html .= '<td>' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . '</td>';
            $mdate = $family->getMarriageDate();
            //-- Wife age
            $wdate = $wife->getBirthDate();
            if ($wdate->isOK() && $mdate->isOK()) {
                if ($wdate->gregorianYear() >= 1550 && $wdate->gregorianYear() < 2030) {
                    $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
                }
                $wage = Date::getAge($wdate, $mdate, 0);
                if ($wage >= 0 && $wage <= $max_age) {
                    $marr_by_age[$wage] .= $wife->getSex();
                }
            }
            $html .= '<td>' . Date::getAge($wdate, $mdate, 2) . '</td><td>' . Date::getAge($wdate, $mdate, 1) . '</td>';
            //-- Marriage date
            $html .= '<td>';
            if ($marriage_dates = $family->getAllMarriageDates()) {
                foreach ($marriage_dates as $n => $marriage_date) {
                    if ($n) {
                        $html .= '<br>';
                    }
                    $html .= '<div>' . $marriage_date->display(true) . '</div>';
                }
                if ($marriage_dates[0]->gregorianYear() >= 1550 && $marriage_dates[0]->gregorianYear() < 2030) {
                    $marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
                }
            } elseif ($family->getFacts('_NMR')) {
                $html .= I18N::translate('no');
            } elseif ($family->getFacts('MARR')) {
                $html .= I18N::translate('yes');
            } else {
                $html .= '&nbsp;';
            }
            $html .= '</td>';
            //-- Event date (sortable)hidden by datatables code
            $html .= '<td>';
            if ($marriage_dates) {
                $html .= $marriage_date->julianDay();
            } else {
                $html .= 0;
            }
            $html .= '</td>';
            //-- Marriage anniversary
            $html .= '<td>' . Date::getAge($mdate, null, 2) . '</td>';
            //-- Marriage place
            $html .= '<td>';
            foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) {
                $tmp = new Place($marriage_place, $family->getTree());
                if ($n) {
                    $html .= '<br>';
                }
                $html .= '<a href="' . $tmp->getURL() . '" title="' . strip_tags($tmp->getFullName()) . '">';
                $html .= FunctionsPrint::highlightSearchHits($tmp->getShortName()) . '</a>';
            }
            $html .= '</td>';
            //-- Number of children
            $nchi = $family->getNumberOfChildren();
            $html .= '<td>' . I18N::number($nchi) . '</td><td>' . $nchi . '</td>';
            //-- Last change
            $html .= '<td>' . $family->LastChangeTimestamp() . '</td>';
            $html .= '<td>' . $family->LastChangeTimestamp(true) . '</td>';
            //-- Sorting by marriage date
            $html .= '<td>';
            if (!$family->canShow() || !$mdate->isOK()) {
                $html .= 'U';
            } else {
                if (Date::compare($mdate, $d100y) > 0) {
                    $html .= 'Y100';
                } else {
                    $html .= 'YES';
                }
            }
            if ($family->getFacts(WT_EVENTS_DIV)) {
                $html .= 'D';
            }
            if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) {
                $html .= 'M';
            }
            $html .= '</td>';
            //-- Sorting alive/dead
            $html .= '<td>';
            if ($husb->isDead() && $wife->isDead()) {
                $html .= 'Y';
            }
            if ($husb->isDead() && !$wife->isDead()) {
                if ($wife->getSex() == 'F') {
                    $html .= 'H';
                }
                if ($wife->getSex() == 'M') {
                    $html .= 'W';
                }
                // male partners
            }
            if (!$husb->isDead() && $wife->isDead()) {
                if ($husb->getSex() == 'M') {
                    $html .= 'W';
                }
                if ($husb->getSex() == 'F') {
                    $html .= 'H';
                }
                // female partners
            }
            if (!$husb->isDead() && !$wife->isDead()) {
                $html .= 'N';
            }
            $html .= '</td>';
            //-- Roots or Leaves
            $html .= '<td>';
            if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) {
                $html .= 'R';
            } elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) {
                $html .= 'L';
            } else {
                $html .= '&nbsp;';
            }
            $html .= '</td>
			</tr>';
        }
        $html .= '
					</tbody>
				</table>
				<div id="fam_list_table-charts_' . $table_id . '" style="display:none">
					<table class="list-charts">
						<tr>
							<td>
								' . self::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')) . '
							</td>
							<td>
								' . self::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')) . '
							</td>
						</tr>
						<tr>
							<td colspan="2">
								' . self::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')) . '
							</td>
						</tr>
					</table>
				</div>
			</div>';
        return $html;
    }