本文整理汇总了PHP中Fisharebest\Webtrees\Individual::getXref方法的典型用法代码示例。如果您正苦于以下问题:PHP Individual::getXref方法的具体用法?PHP Individual::getXref怎么用?PHP Individual::getXref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Individual
的用法示例。
在下文中一共展示了Individual::getXref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateRelationships
/**
* Calculate the shortest paths - or all paths - between two individuals.
*
* @param Individual $individual1
* @param Individual $individual2
* @param int $recursion How many levels of recursion to use
* @param boo; $ancestor Restrict to relationships via a common ancestor
*
* @return string[][]
*/
public function calculateRelationships(Individual $individual1, Individual $individual2, $recursion, $ancestor = false)
{
$rows = Database::prepare("SELECT l_from, l_to FROM `##link` WHERE l_file = :tree_id AND l_type IN ('FAMS', 'FAMC')")->execute(array('tree_id' => $individual1->getTree()->getTreeId()))->fetchAll();
// Optionally restrict the graph to the ancestors of the individuals.
if ($ancestor) {
$ancestors = $this->allAncestors($individual1->getXref(), $individual2->getXref(), $individual1->getTree()->getTreeId());
$exclude = $this->excludeFamilies($individual1->getXref(), $individual2->getXref(), $individual1->getTree()->getTreeId());
} else {
$ancestors = array();
$exclude = array();
}
$graph = array();
foreach ($rows as $row) {
if (!$ancestors || in_array($row->l_from, $ancestors) && !in_array($row->l_to, $exclude)) {
$graph[$row->l_from][$row->l_to] = 1;
$graph[$row->l_to][$row->l_from] = 1;
}
}
$xref1 = $individual1->getXref();
$xref2 = $individual2->getXref();
$dijkstra = new Dijkstra($graph);
$paths = $dijkstra->shortestPaths($xref1, $xref2);
// Only process each exclusion list once;
$excluded = array();
$queue = array();
foreach ($paths as $path) {
// Insert the paths into the queue, with an exclusion list.
$queue[] = array('path' => $path, 'exclude' => array());
// While there are un-extended paths
while (list(, $next) = each($queue)) {
// For each family on the path
for ($n = count($next['path']) - 2; $n >= 1; $n -= 2) {
$exclude = $next['exclude'];
if (count($exclude) >= $recursion) {
continue;
}
$exclude[] = $next['path'][$n];
sort($exclude);
$tmp = implode('-', $exclude);
if (in_array($tmp, $excluded)) {
continue;
} else {
$excluded[] = $tmp;
}
// Add any new path to the queue
foreach ($dijkstra->shortestPaths($xref1, $xref2, $exclude) as $new_path) {
$queue[] = array('path' => $new_path, 'exclude' => $exclude);
}
}
}
}
// Extract the paths from the queue, removing duplicates.
$paths = array();
foreach ($queue as $next) {
$paths[implode('-', $next['path'])] = $next['path'];
}
return $paths;
}
示例2: getChartMenu
/**
* Return a menu item for this chart.
*
* @param Individual $individual
*
* @return Menu|null
*/
public function getChartMenu(Individual $individual)
{
$tree = $individual->getTree();
$gedcomid = $tree->getUserPreference(Auth::user(), 'gedcomid');
if ($gedcomid) {
return new Menu(I18N::translate('Relationship to me'), 'relationship.php?pid1=' . $gedcomid . '&pid2=' . $individual->getXref() . '&ged=' . $tree->getNameUrl(), 'menu-chart-relationship', array('rel' => 'nofollow'));
} else {
return new Menu(I18N::translate('Relationships'), 'relationship.php?pid1=' . $individual->getXref() . '&ged=' . $tree->getNameUrl(), 'menu-chart-relationship', array('rel' => 'nofollow'));
}
}
示例3: getEditMenu
/**
* get edit menu
*/
public function getEditMenu()
{
if (!$this->record || $this->record->isPendingDeletion()) {
return null;
}
// edit menu
$menu = new Menu(I18N::translate('Edit'), '#', 'menu-record');
// edit raw
if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) {
$menu->addSubmenu(new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-record-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");')));
}
// delete
if (Auth::isEditor($this->record->getTree())) {
$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-record-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
}
// add to favorites
if (Module::getModuleByName('user_favorites')) {
$menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-record-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite" ,{xref:"' . $this->record->getXref() . '"},function(){location.reload();})')));
}
// Get the link for the first submenu and set it as the link for the main menu
if ($menu->getSubmenus()) {
$submenus = $menu->getSubmenus();
$menu->setLink($submenus[0]->getLink());
$menu->setAttrs($submenus[0]->getAttrs());
}
return $menu;
}
示例4: getSpouseById
/**
* Find the spouse of a person, using the Xref comparison.
*
* @param Individual $person
*
* @return Individual|null
*/
public function getSpouseById(\Fisharebest\Webtrees\Individual $person)
{
if ($this->gedcomrecord->getWife() && $person->getXref() === $this->gedcomrecord->getWife()->getXref()) {
return $this->gedcomrecord->getHusband();
} else {
return $this->gedcomrecord->getWife();
}
}
示例5: getChartMenu
/**
* Return a menu item for this chart.
*
* We can only do this if the GD2 library is installed with TrueType support.
*
* @return Menu|null
*/
public function getChartMenu(Individual $individual)
{
if (function_exists('imagettftext')) {
return new Menu($this->getTitle(), 'fanchart.php?rootid=' . $individual->getXref() . '&ged=' . $individual->getTree()->getNameUrl(), 'menu-chart-fanchart', array('rel' => 'nofollow'));
} else {
return null;
}
}
示例6: __construct
/**
* Startup activity
*/
public function __construct()
{
// Automatically fix broken links
if ($this->record && $this->record->canEdit()) {
$broken_links = 0;
foreach ($this->record->getFacts('HUSB|WIFE|CHIL|FAMS|FAMC|REPO') as $fact) {
if (!$fact->isPendingDeletion() && $fact->getTarget() === null) {
$this->record->deleteFact($fact->getFactId(), false);
FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
$broken_links = true;
}
}
foreach ($this->record->getFacts('NOTE|SOUR|OBJE') as $fact) {
// These can be links or inline. Only delete links.
if (!$fact->isPendingDeletion() && $fact->getTarget() === null && preg_match('/^@.*@$/', $fact->getValue())) {
$this->record->deleteFact($fact->getFactId(), false);
FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
$broken_links = true;
}
}
if ($broken_links) {
// Reload the updated family
$this->record = GedcomRecord::getInstance($this->record->getXref(), $this->record->getTree());
}
}
parent::__construct();
// We want robots to index this page
$this->setMetaRobots('index,follow');
// Set a page title
if ($this->record) {
if ($this->record->canShowName()) {
// e.g. "John Doe" or "1881 Census of Wales"
$this->setPageTitle($this->record->getFullName());
} else {
// e.g. "Individual" or "Source"
$record = $this->record;
$this->setPageTitle(GedcomTag::getLabel($record::RECORD_TYPE));
}
} else {
// No such record
$this->setPageTitle(I18N::translate('Private'));
}
}
示例7: getEditMenu
/**
* get edit menu
*/
public function getEditMenu()
{
if (!$this->record || $this->record->isPendingDeletion()) {
return null;
}
// edit menu
$menu = new Menu(I18N::translate('Edit'), '#', 'menu-record');
// edit raw
if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) {
$menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-record-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");')));
}
// delete
if (Auth::isEditor($this->record->getTree())) {
$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-record-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
}
return $menu;
}
示例8: addFamily
/**
* Add a person (and optionally their immediate family members) to the pids array
*
* @param Individual $person
* @param bool $add_family
*
* @return array
*/
private function addFamily(Individual $person, $add_family)
{
$xrefs = array();
$xrefs[] = $person->getXref();
if ($add_family) {
foreach ($person->getSpouseFamilies() as $family) {
$spouse = $family->getSpouse($person);
if ($spouse) {
$xrefs[] = $spouse->getXref();
foreach ($family->getChildren() as $child) {
$xrefs[] = $child->getXref();
}
}
}
foreach ($person->getChildFamilies() as $family) {
foreach ($family->getSpouses() as $parent) {
$xrefs[] = $parent->getXref();
}
foreach ($family->getChildren() as $sibling) {
if ($person !== $sibling) {
$xrefs[] = $sibling->getXref();
}
}
}
}
return $xrefs;
}
示例9: getChartMenu
/**
* Return a menu item for this chart.
*
* @return Menu|null
*/
public function getChartMenu(Individual $individual)
{
return new Menu($this->getTitle(), 'compact.php?rootid=' . $individual->getXref() . '&ged=' . $individual->getTree()->getNameUrl(), 'menu-chart-compact', array('rel' => 'nofollow'));
}
示例10: printDescendency
/**
* Prints descendency of passed in person
*
* @param Individual $person person to print descendency for
* @param int $count count of generations to print
* @param bool $showNav
*
* @return int
*/
public function printDescendency($person, $count, $showNav = true)
{
global $lastGenSecondFam;
if ($count > $this->dgenerations) {
return 0;
}
$pid = $person->getXref();
$tablealign = 'right';
$otablealign = 'left';
if (I18N::direction() === 'rtl') {
$tablealign = 'left';
$otablealign = 'right';
}
//-- put a space between families on the last generation
if ($count == $this->dgenerations - 1) {
if (isset($lastGenSecondFam)) {
echo '<br>';
}
$lastGenSecondFam = true;
}
echo "<table id='table_{$pid}' class='hourglassChart' style='float:{$tablealign}'>";
echo '<tr>';
echo "<td style='text-align:{$tablealign}'>";
$numkids = 0;
$families = $person->getSpouseFamilies();
$famNum = 0;
$children = array();
if ($count < $this->dgenerations) {
// Put all of the children in a common array
foreach ($families as $family) {
$famNum++;
foreach ($family->getChildren() as $child) {
$children[] = $child;
}
}
$ct = count($children);
if ($ct > 0) {
echo "<table style='position: relative; top: auto; float: {$tablealign};'>";
for ($i = 0; $i < $ct; $i++) {
$person2 = $children[$i];
$chil = $person2->getXref();
echo '<tr>';
echo '<td id="td_', $chil, '" class="', I18N::direction(), '" style="text-align:', $otablealign, '">';
$kids = $this->printDescendency($person2, $count + 1);
$numkids += $kids;
echo '</td>';
// Print the lines
if ($ct > 1) {
if ($i == 0) {
// First child
echo "<td style='vertical-align:bottom'><img alt='' class='line1 tvertline' id='vline_{$chil}' src='" . Theme::theme()->parameter('image-vline') . "' width='3'></td>";
} elseif ($i == $ct - 1) {
// Last child
echo "<td style='vertical-align:top'><img alt='' class='bvertline' id='vline_{$chil}' src='" . Theme::theme()->parameter('image-vline') . "' width='3'></td>";
} else {
// Middle child
echo '<td style="background: url(\'' . Theme::theme()->parameter('image-vline') . '\');"><img src=\'' . Theme::theme()->parameter('image-spacer') . '\' width="3" alt=""></td>';
}
}
echo '</tr>';
}
echo '</table>';
}
echo '</td>';
echo '<td width="', $this->getBoxDimensions()->width, '">';
}
// Print the descendency expansion arrow
if ($count == $this->dgenerations) {
$numkids = 1;
$tbwidth = $this->getBoxDimensions()->width + 16;
for ($j = $count; $j < $this->dgenerations; $j++) {
echo "<div style='width: ", $tbwidth, "px;'><br></div></td><td style='width:", $this->getBoxDimensions()->width, "px'>";
}
$kcount = 0;
foreach ($families as $family) {
$kcount += $family->getNumberOfChildren();
}
if ($kcount == 0) {
echo "</td><td style='width:", $this->getBoxDimensions()->width, "px'>";
} else {
printf(self::LINK, $this->left_arrow, $pid, 'desc', $this->showFull(), $this->show_spouse);
//-- move the arrow up to line up with the correct box
if ($this->show_spouse) {
echo str_repeat('<br><br><br>', count($families));
}
echo "</td><td style='width:", $this->getBoxDimensions()->width, "px'>";
}
}
echo '<table id="table2_' . $pid . '"><tr><td>';
FunctionsPrint::printPedigreePerson($person, $this->showFull());
echo '</td><td><img class="line2" src="' . Theme::theme()->parameter('image-hline') . '" width="7" height="3">';
//.........这里部分代码省略.........
示例11: printFamilyParents
/**
* print the parents table for a family
*
* @param Family $family family gedcom ID
* @param int $sosa child sosa number
* @param string $label indi label (descendancy booklet)
* @param string $parid parent ID (descendancy booklet)
* @param string $gparid gd-parent ID (descendancy booklet)
* @param int $show_full large or small box
*/
public static function printFamilyParents(Family $family, $sosa = 0, $label = '', $parid = '', $gparid = '', $show_full = 1)
{
if ($show_full) {
$pbheight = Theme::theme()->parameter('chart-box-y') + 14;
} else {
$pbheight = Theme::theme()->parameter('compact-chart-box-y') + 14;
}
$husb = $family->getHusband();
if ($husb) {
echo '<a name="', $husb->getXref(), '"></a>';
} else {
$husb = new Individual('M', "0 @M@ INDI\n1 SEX M", null, $family->getTree());
}
$wife = $family->getWife();
if ($wife) {
echo '<a name="', $wife->getXref(), '"></a>';
} else {
$wife = new Individual('F', "0 @F@ INDI\n1 SEX F", null, $family->getTree());
}
if ($sosa) {
echo '<p class="name_head">', $family->getFullName(), '</p>';
}
/**
* husband side
*/
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td rowspan=\"2\">";
echo "<table border='0'><tr>";
if ($parid) {
if ($husb->getXref() == $parid) {
self::printSosaNumber($label);
} else {
self::printSosaNumber($label, "", "blank");
}
} elseif ($sosa) {
self::printSosaNumber($sosa * 2);
}
if ($husb->isPendingAddtion()) {
echo '<td valign="top" class="facts_value new">';
} elseif ($husb->isPendingDeletion()) {
echo '<td valign="top" class="facts_value old">';
} else {
echo '<td valign="top">';
}
FunctionsPrint::printPedigreePerson($husb, $show_full);
echo "</td></tr></table>";
echo "</td>";
// husband’s parents
$hfam = $husb->getPrimaryChildFamily();
if ($hfam) {
// remove the|| test for $sosa
echo "<td rowspan=\"2\"><img src=\"" . Theme::theme()->parameter('image-hline') . "\" alt=\"\"></td><td rowspan=\"2\"><img src=\"" . Theme::theme()->parameter('image-vline') . "\" width=\"3\" height=\"" . ($pbheight + 9) . "\" alt=\"\"></td>";
echo "<td><img class=\"line5\" src=\"" . Theme::theme()->parameter('image-hline') . "\" alt=\"\"></td><td>";
// husband’s father
if ($hfam && $hfam->getHusband()) {
echo "<table border='0'><tr>";
if ($sosa > 0) {
self::printSosaNumber($sosa * 4, $hfam->getHusband()->getXref(), "down");
}
if (!empty($gparid) && $hfam->getHusband()->getXref() == $gparid) {
self::printSosaNumber(trim(substr($label, 0, -3), ".") . ".");
}
echo "<td valign=\"top\">";
FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full);
echo "</td></tr></table>";
} elseif ($hfam && !$hfam->getHusband()) {
// Empty box for grandfather
echo "<table border='0'><tr>";
echo '<td valign="top">';
FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full);
echo '</td></tr></table>';
}
echo "</td>";
}
if ($hfam && $sosa != -1) {
echo '<td valign="middle" rowspan="2">';
self::printUrlArrow($sosa == 0 ? '?famid=' . $hfam->getXref() . '&ged=' . $hfam->getTree()->getNameUrl() : '#' . $hfam->getXref(), $hfam->getXref(), 1);
echo '</td>';
}
if ($hfam) {
// husband’s mother
echo "</tr><tr><td><img src=\"" . Theme::theme()->parameter('image-hline') . "\" alt=\"\"></td><td>";
if ($hfam && $hfam->getWife()) {
echo "<table border='0'><tr>";
if ($sosa > 0) {
self::printSosaNumber($sosa * 4 + 1, $hfam->getWife()->getXref(), "down");
}
if (!empty($gparid) && $hfam->getWife()->getXref() == $gparid) {
self::printSosaNumber(trim(substr($label, 0, -3), ".") . ".");
}
echo '<td valign="top">';
//.........这里部分代码省略.........
示例12: associateFacts
/**
* Get the events of associates.
*
* @param Individual $person
*
* @return Fact[]
*/
private static function associateFacts(Individual $person)
{
$facts = array();
$associates = array_merge($person->linkedIndividuals('ASSO'), $person->linkedIndividuals('_ASSO'), $person->linkedFamilies('ASSO'), $person->linkedFamilies('_ASSO'));
foreach ($associates as $associate) {
foreach ($associate->getFacts() as $fact) {
$arec = $fact->getAttribute('_ASSO');
if (!$arec) {
$arec = $fact->getAttribute('ASSO');
}
if ($arec && trim($arec, '@') === $person->getXref()) {
// Extract the important details from the fact
$factrec = '1 ' . $fact->getTag();
if (preg_match('/\\n2 DATE .*/', $fact->getGedcom(), $match)) {
$factrec .= $match[0];
}
if (preg_match('/\\n2 PLAC .*/', $fact->getGedcom(), $match)) {
$factrec .= $match[0];
}
if ($associate instanceof Family) {
foreach ($associate->getSpouses() as $spouse) {
$factrec .= "\n2 _ASSO @" . $spouse->getXref() . '@';
}
} else {
$factrec .= "\n2 _ASSO @" . $associate->getXref() . '@';
}
$facts[] = new Fact($factrec, $associate, 'asso');
}
}
}
return $facts;
}
示例13: individualBoxSmall
/**
* Display an individual in a box - for charts, etc.
*
* @param Individual $individual
*
* @return string
*/
public function individualBoxSmall(Individual $individual)
{
$personBoxClass = array_search($individual->getSex(), array('person_box' => 'M', 'person_boxF' => 'F', 'person_boxNN' => 'U'));
if ($individual->getTree()->getPreference('SHOW_HIGHLIGHT_IMAGES')) {
$thumbnail = $individual->displayImage();
} else {
$thumbnail = '';
}
return '<div data-pid="' . $individual->getXref() . '" class="person_box_template ' . $personBoxClass . ' iconz box-style0" style="width: ' . $this->parameter('compact-chart-box-x') . 'px; min-height: ' . $this->parameter('compact-chart-box-y') . 'px">' . '<div class="compact_view">' . $thumbnail . '<a href="' . $individual->getHtmlUrl() . '">' . '<span class="namedef name0">' . $individual->getFullName() . '</span>' . '</a>' . '<div class="inout2 details0">' . $individual->getLifeSpan() . '</div>' . '</div>' . '<div class="inout"></div>' . '</div>';
}
示例14: htmlIndividualForList
/**
* Return HTML Code to display individual in non structured list (e.g. Patronymic Lineages)
*
* @param \Fisharebest\Webtrees\Individual $individual Individual to print
* @param bool $isStrong Bolden the name ?
* @return string HTML Code for individual item
*/
public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true)
{
$html = '';
$tag = 'em';
if ($isStrong) {
$tag = 'strong';
}
if ($individual && $individual->canShow()) {
$dindi = new Individual($individual);
$html = $individual->getSexImage();
$html .= '<a class="list_item" href="' . $individual->getHtmlUrl() . '" title="' . I18N::translate('Informations for individual %s', $individual->getXref()) . '">';
$html .= '<' . $tag . '>' . $individual->getFullName() . '</' . $tag . '> (' . $individual->getXref() . ') ';
$html .= FunctionsPrint::formatSosaNumbers($dindi->getSosaNumbers(), 1, 'small');
$html .= ' <span><small><em>' . $dindi->formatFirstMajorFact(WT_EVENTS_BIRT, 10) . '</em></small></span>';
$html .= ' <span><small><em>' . $dindi->formatFirstMajorFact(WT_EVENTS_DEAT, 10) . '</em></small></span>';
$html .= '</a>';
} else {
$html .= '<span class=\\"list_item\\"><' . $tag . '>' . I18N::translate('Private') . '</' . $tag . '></span>';
}
return $html;
}
示例15: menuChartTimeline
/**
* Generate a menu item for the timeline chart (timeline.php).
*
* @param Individual $individual
*
* @return Menu
*/
protected function menuChartTimeline(Individual $individual)
{
return new Menu(I18N::translate('Timeline'), 'timeline.php?pids%5B%5D=' . $individual->getXref() . '&' . $this->tree_url, 'menu-chart-timeline', array('rel' => 'nofollow'));
}