本文整理汇总了PHP中Fisharebest\Webtrees\Individual::getAllNames方法的典型用法代码示例。如果您正苦于以下问题:PHP Individual::getAllNames方法的具体用法?PHP Individual::getAllNames怎么用?PHP Individual::getAllNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Individual
的用法示例。
在下文中一共展示了Individual::getAllNames方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* 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 '';
}
示例2: sortableNames
/**
* 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);
}
示例3: generate
/**
* 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 '';
}
示例4: nameAtCensusDate
/**
* 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;
}
示例5: printNameRecord
/**
* 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>';
}
示例6: renderContent
//.........这里部分代码省略.........
$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');
示例7: getDescendantsHtml
/**
* 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() . '&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() . '&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>';
}
}
示例8: getPrimaryName
/**
* 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];
}
示例9: familyTable
//.........这里部分代码省略.........
' . 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();