本文整理汇总了PHP中Fisharebest\Webtrees\GedcomRecord类的典型用法代码示例。如果您正苦于以下问题:PHP GedcomRecord类的具体用法?PHP GedcomRecord怎么用?PHP GedcomRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GedcomRecord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getActionPreview
/**
* Default previewer for plugins with no custom preview.
*
* @param GedcomRecord $record
*
* @return string
*/
public function getActionPreview(GedcomRecord $record)
{
$old_lines = preg_split('/[\\n]+/', $record->getGedcom());
$new_lines = preg_split('/[\\n]+/', $this->updateRecord($record->getXref(), $record->getGedcom()));
// Find matching lines using longest-common-subsequence algorithm.
$lcs = self::longestCommonSubsequence($old_lines, $new_lines, 0, count($old_lines) - 1, 0, count($new_lines) - 1);
$diff_lines = array();
$last_old = -1;
$last_new = -1;
while ($lcs) {
list($old, $new) = array_shift($lcs);
while ($last_old < $old - 1) {
$diff_lines[] = self::decorateDeletedText($old_lines[++$last_old]);
}
while ($last_new < $new - 1) {
$diff_lines[] = self::decorateInsertedText($new_lines[++$last_new]);
}
$diff_lines[] = $new_lines[$new];
$last_old = $old;
$last_new = $new;
}
while ($last_old < count($old_lines) - 1) {
$diff_lines[] = self::decorateDeletedText($old_lines[++$last_old]);
}
while ($last_new < count($new_lines) - 1) {
$diff_lines[] = self::decorateInsertedText($new_lines[++$last_new]);
}
return '<pre class="gedcom-data">' . self::createEditLinks(implode("\n", $diff_lines)) . '</pre>';
}
开发者ID:jflash,项目名称:webtrees,代码行数:36,代码来源:BatchUpdateBasePlugin.php
示例2: getValue
/**
* Translate a code, for an optional record
*
* @param string $type
* @param GedcomRecord|null $record
*
* @return string
*/
public static function getValue($type, GedcomRecord $record = null)
{
if ($record instanceof Individual) {
$sex = $record->getSex();
} else {
$sex = 'U';
}
switch ($type) {
case 'birth':
switch ($sex) {
case 'M':
return I18N::translateContext('Male pedigree', 'Birth');
case 'F':
return I18N::translateContext('Female pedigree', 'Birth');
default:
return I18N::translateContext('Pedigree', 'Birth');
}
case 'adopted':
switch ($sex) {
case 'M':
return I18N::translateContext('Male pedigree', 'Adopted');
case 'F':
return I18N::translateContext('Female pedigree', 'Adopted');
default:
return I18N::translateContext('Pedigree', 'Adopted');
}
case 'foster':
switch ($sex) {
case 'M':
return I18N::translateContext('Male pedigree', 'Foster');
case 'F':
return I18N::translateContext('Female pedigree', 'Foster');
default:
return I18N::translateContext('Pedigree', 'Foster');
}
case 'sealing':
switch ($sex) {
case 'M':
return I18N::translateContext('Male pedigree', 'Sealing');
case 'F':
return I18N::translateContext('Female pedigree', 'Sealing');
default:
return I18N::translateContext('Pedigree', 'Sealing');
}
case 'rada':
// Not standard GEDCOM - a webtrees extension
// This is an arabic word which does not exist in other languages.
// So, it will not have any inflected forms.
return I18N::translate('Rada');
default:
return $type;
}
}
开发者ID:tronsmit,项目名称:webtrees,代码行数:61,代码来源:GedcomCodePedi.php
示例3: canShowByType
/**
* Each object type may have its own special rules, and re-implement this function.
*
* @param int $access_level
*
* @return bool
*/
protected function canShowByType($access_level)
{
// Hide media objects if they are attached to private records
$linked_ids = Database::prepare("SELECT l_from FROM `##link` WHERE l_to = ? AND l_file = ?")->execute(array($this->xref, $this->tree->getTreeId()))->fetchOneColumn();
foreach ($linked_ids as $linked_id) {
$linked_record = GedcomRecord::getInstance($linked_id, $this->tree);
if ($linked_record && !$linked_record->canShow($access_level)) {
return false;
}
}
// ... otherwise apply default behaviour
return parent::canShowByType($access_level);
}
开发者ID:jflash,项目名称:webtrees,代码行数:20,代码来源:Media.php
示例4: getValue
/**
* Translate a code, for an (optional) record
*
* @param string $type
* @param GedcomRecord|null $record
*
* @return string
*/
public static function getValue($type, GedcomRecord $record = null)
{
if ($record instanceof Individual) {
$sex = $record->getSex();
} else {
$sex = 'U';
}
switch ($type) {
case 'BOTH':
switch ($sex) {
case 'M':
return I18N::translateContext('MALE', 'Adopted by both parents');
case 'F':
return I18N::translateContext('FEMALE', 'Adopted by both parents');
default:
return I18N::translate('Adopted by both parents');
}
case 'HUSB':
switch ($sex) {
case 'M':
return I18N::translateContext('MALE', 'Adopted by father');
case 'F':
return I18N::translateContext('FEMALE', 'Adopted by father');
default:
return I18N::translate('Adopted by father');
}
case 'WIFE':
switch ($sex) {
case 'M':
return I18N::translateContext('MALE', 'Adopted by mother');
case 'F':
return I18N::translateContext('FEMALE', 'Adopted by mother');
default:
return I18N::translate('Adopted by mother');
}
default:
return $type;
}
}
开发者ID:tunandras,项目名称:webtrees,代码行数:47,代码来源:GedcomCodeAdop.php
示例5: getBlock
/**
* Generate the HTML content of this block.
*
* @param int $block_id
* @param bool $template
* @param string[] $cfg
*
* @return string
*/
public function getBlock($block_id, $template = true, $cfg = array())
{
global $ctype, $WT_TREE;
$num = $this->getBlockSetting($block_id, 'num', '10');
$count_placement = $this->getBlockSetting($block_id, 'count_placement', 'before');
$block = $this->getBlockSetting($block_id, 'block', '0');
foreach (array('count_placement', 'num', 'block') as $name) {
if (array_key_exists($name, $cfg)) {
${$name} = $cfg[$name];
}
}
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
$title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>';
} else {
$title = '';
}
$title .= $this->getTitle();
$content = '';
// load the lines from the file
$top10 = Database::prepare("SELECT page_parameter, page_count" . " FROM `##hit_counter`" . " WHERE gedcom_id = :tree_id AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC LIMIT :limit")->execute(array('tree_id' => $WT_TREE->getTreeId(), 'limit' => (int) $num))->fetchAssoc();
if ($block) {
$content .= '<table width="90%">';
} else {
$content .= '<table>';
}
foreach ($top10 as $id => $count) {
$record = GedcomRecord::getInstance($id, $WT_TREE);
if ($record && $record->canShow()) {
$content .= '<tr>';
if ($count_placement == 'before') {
$content .= '<td dir="ltr" style="text-align:right">[' . $count . ']</td>';
}
$content .= '<td class="name2" ><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
if ($count_placement == 'after') {
$content .= '<td dir="ltr" style="text-align:right">[' . $count . ']</td>';
}
$content .= '</tr>';
}
}
$content .= "</table>";
if ($template) {
if ($block) {
$class .= ' small_inner_block';
}
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
开发者ID:josefpavlik,项目名称:webtrees,代码行数:60,代码来源:TopPageViewsModule.php
示例6: modAction
/**
* This is a general purpose hook, allowing modules to respond to routes
* of the form module.php?mod=FOO&mod_action=BAR
*
* @param string $mod_action
*/
public function modAction($mod_action)
{
global $WT_TREE;
switch ($mod_action) {
case 'menu-add-favorite':
// Process the "add to user favorites" menu item on indi/fam/etc. pages
$record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
if (Auth::check() && $record->canShowName()) {
self::addFavorite(array('user_id' => Auth::id(), 'gedcom_id' => $record->getTree()->getTreeId(), 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, 'note' => null, 'title' => null));
FlashMessages::addMessage(I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
}
break;
}
}
开发者ID:tronsmit,项目名称:webtrees,代码行数:20,代码来源:UserFavoritesModule.php
示例7: getActionPreview
/**
* Default previewer for plugins with no custom preview.
*
* @param GedcomRecord $record
*
* @return string
*/
public function getActionPreview(GedcomRecord $record)
{
$old_lines = preg_split('/[\\n]+/', $record->getGedcom());
$new_lines = preg_split('/[\\n]+/', $this->updateRecord($record->getXref(), $record->getGedcom()));
$algorithm = new MyersDiff();
$differences = $algorithm->calculate($old_lines, $new_lines);
$diff_lines = array();
foreach ($differences as $difference) {
switch ($difference[1]) {
case MyersDiff::DELETE:
$diff_lines[] = self::decorateDeletedText($difference[0]);
break;
case MyersDiff::INSERT:
$diff_lines[] = self::decorateInsertedText($difference[0]);
break;
default:
$diff_lines[] = $difference[0];
}
}
return '<pre class="gedcom-data">' . self::createEditLinks(implode("\n", $diff_lines)) . '</pre>';
}
开发者ID:tronsmit,项目名称:webtrees,代码行数:28,代码来源:BatchUpdateBasePlugin.php
示例8: getLatestRecord
/**
* Get the current view of a record, allowing for pending changes
*
* @param string $xref
* @param string $type
*
* @return string
*/
public static function getLatestRecord($xref, $type)
{
global $WT_TREE;
switch ($type) {
case 'INDI':
return Individual::getInstance($xref, $WT_TREE)->getGedcom();
case 'FAM':
return Family::getInstance($xref, $WT_TREE)->getGedcom();
case 'SOUR':
return Source::getInstance($xref, $WT_TREE)->getGedcom();
case 'REPO':
return Repository::getInstance($xref, $WT_TREE)->getGedcom();
case 'OBJE':
return Media::getInstance($xref, $WT_TREE)->getGedcom();
case 'NOTE':
return Note::getInstance($xref, $WT_TREE)->getGedcom();
default:
return GedcomRecord::getInstance($xref, $WT_TREE)->getGedcom();
}
}
开发者ID:tunandras,项目名称:webtrees,代码行数:28,代码来源:BatchUpdateModule.php
示例9: sortByNameAndChangeDate
/**
* Sort the records by (1) name and (2) last change date
*
* @param GedcomRecord $a
* @param GedcomRecord $b
*
* @return int
*/
private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b)
{
return GedcomRecord::compare($a, $b) ?: $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true);
}
开发者ID:tronsmit,项目名称:webtrees,代码行数:12,代码来源:RecentChangesModule.php
示例10: getMarriage
/**
* Determine if the family parents are married.
*
* Don't use the default function because we want to privatize the record but display the name
* and the parents of the spouse if the spouse him/herself is not private.
*
* @param type $family
* @return boolean
*/
private function getMarriage($family)
{
$record = GedcomRecord::getInstance($family->getXref(), $this->tree);
foreach ($record->getFacts('MARR', false, Auth::PRIV_HIDE) as $fact) {
if ($fact) {
return true;
}
}
}
开发者ID:bxbroze,项目名称:webtrees,代码行数:18,代码来源:FancyTreeviewClass.php
示例11: elseif
// Level 1 links
$source->deleteFact($fact->getFactId(), true);
} elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) {
// Level 2-3 links
$source->updateFact($fact->getFactId(), preg_replace(array('/\\n2 OBJE @' . $target . '@(\\n[3-9].*)*/', '/\\n3 OBJE @' . $target . '@(\\n[4-9].*)*/'), '', $fact->getGedcom()), true);
}
}
}
}
} else {
http_response_code(406);
}
break;
case 'reject-changes':
// Reject all the pending changes for a record
$record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) {
FlashMessages::addMessage(I18N::translate('The changes to “%s” have been rejected.', $record->getFullName()));
FunctionsImport::rejectAllChanges($record);
} else {
http_response_code(406);
}
break;
case 'theme':
// Change the current theme
$theme = Filter::post('theme');
if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) {
Session::put('theme_id', $theme);
// Remember our selection
Auth::user()->setPreference('theme', $theme);
} else {
开发者ID:josefpavlik,项目名称:webtrees,代码行数:31,代码来源:action.php
示例12:
// Insert the 1 FILE xxx record into the arrays used by function FunctionsEdit::handle_updatesges()
$glevels = array_merge(array('1'), $glevels);
$tag = array_merge(array('FILE'), $tag);
$islink = array_merge(array(0), $islink);
$text = array_merge(array($newFilename), $text);
$record = GedcomRecord::getInstance($pid, $WT_TREE);
$newrec = "0 @{$pid}@ OBJE\n";
$newrec = FunctionsEdit::handleUpdates($newrec);
$record->updateRecord($newrec, $update_CHAN);
if ($move_file) {
// We've moved a file. Therefore we must approve the change, as rejecting
// the change will create broken references.
FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId());
}
if ($pid && $linktoid) {
$record = GedcomRecord::getInstance($linktoid, $WT_TREE);
$record->createFact('1 OBJE @' . $pid . '@', true);
Log::addEditLog('Media ID ' . $pid . " successfully added to {$linktoid}.");
}
$controller->pageHeader();
if ($messages) {
echo '<button onclick="closePopupAndReloadParent();">', I18N::translate('close'), '</button>';
} else {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
return;
case 'showmediaform':
$controller->setPageTitle(I18N::translate('Create a new media object'));
$action = 'create';
break;
case 'editmedia':
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:31,代码来源:addmedia.php
示例13: printMainNotes
/**
* Print a row for the notes tab on the individual page.
*
* @param Fact $fact
* @param int $level
*/
public static function printMainNotes(Fact $fact, $level)
{
$factrec = $fact->getGedcom();
$fact_id = $fact->getFactId();
$parent = $fact->getParent();
$pid = $parent->getXref();
if ($fact->isPendingAddition()) {
$styleadd = ' new';
$can_edit = $level == 1 && $fact->canEdit();
} elseif ($fact->isPendingDeletion()) {
$styleadd = ' old';
$can_edit = false;
} else {
$styleadd = '';
$can_edit = $level == 1 && $fact->canEdit();
}
$ct = preg_match_all("/{$level} NOTE (.*)/", $factrec, $match, PREG_SET_ORDER);
for ($j = 0; $j < $ct; $j++) {
// Note object, or inline note?
if (preg_match("/{$level} NOTE @(.*)@/", $match[$j][0], $nmatch)) {
$note = Note::getInstance($nmatch[1], $fact->getParent()->getTree());
if ($note && !$note->canShow()) {
continue;
}
} else {
$note = null;
}
if ($level >= 2) {
echo '<tr class="row_note2"><td class="descriptionbox rela ', $styleadd, ' width20">';
} else {
echo '<tr><td class="descriptionbox ', $styleadd, ' width20">';
}
if ($can_edit) {
echo '<a onclick="return edit_record(\'', $pid, '\', \'', $fact_id, '\');" href="#" title="', I18N::translate('Edit'), '">';
if ($level < 2) {
if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) {
echo '<i class="icon-note"></i> ';
}
if ($note) {
echo GedcomTag::getLabel('SHARED_NOTE');
} else {
echo GedcomTag::getLabel('NOTE');
}
echo '</a>';
echo '<div class="editfacts">';
echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . I18N::translate('Edit') . "\"><span class=\"link_text\">" . I18N::translate('Edit') . "</span></a></div>";
echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>';
echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . I18N::translate('Delete') . "\"><span class=\"link_text\">" . I18N::translate('Delete') . "</span></a></div>";
if ($note) {
echo '<a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a>';
}
echo '</div>';
}
} else {
if ($level < 2) {
if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) {
echo '<i class="icon-note"></i> ';
}
if ($note) {
echo GedcomTag::getLabel('SHARED_NOTE');
} else {
echo GedcomTag::getLabel('NOTE');
}
}
$factlines = explode("\n", $factrec);
// 1 BIRT Y\n2 NOTE ...
$factwords = explode(" ", $factlines[0]);
// 1 BIRT Y
$factname = $factwords[1];
// BIRT
$parent = GedcomRecord::getInstance($pid, $fact->getParent()->getTree());
if ($factname == 'EVEN' || $factname == 'FACT') {
// Add ' EVEN' to provide sensible output for an event with an empty TYPE record
$ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch);
if ($ct > 0) {
$factname = trim($ematch[1]);
echo $factname;
} else {
echo GedcomTag::getLabel($factname, $parent);
}
} elseif ($factname != 'NOTE') {
// Note is already printed
echo GedcomTag::getLabel($factname, $parent);
if ($note) {
echo '<div class="editfacts"><a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a></div>';
}
}
}
echo '</td>';
if ($note) {
// Note objects
if (Module::getModuleByName('GEDFact_assistant')) {
// If Census assistant installed, allow it to format the note
$text = CensusAssistantModule::formatCensusNote($note);
//.........这里部分代码省略.........
开发者ID:jflash,项目名称:webtrees,代码行数:101,代码来源:FunctionsPrintFacts.php
示例14: calendar_list_text
/**
* Format a list of facts for display
*
* @param Fact[] $list
* @param string $tag1
* @param string $tag2
* @param bool $show_sex_symbols
*
* @return string
*/
function calendar_list_text($list, $tag1, $tag2, $show_sex_symbols)
{
global $males, $females, $WT_TREE;
$html = '';
foreach ($list as $id => $facts) {
$tmp = GedcomRecord::getInstance($id, $WT_TREE);
$html .= $tag1 . '<a href="' . $tmp->getHtmlUrl() . '">' . $tmp->getFullName() . '</a> ';
if ($show_sex_symbols && $tmp instanceof Individual) {
switch ($tmp->getSex()) {
case 'M':
$html .= '<i class="icon-sex_m_9x9" title="' . I18N::translate('Male') . '"></i>';
++$males;
break;
case 'F':
$html .= '<i class="icon-sex_f_9x9" title="' . I18N::translate('Female') . '"></i>';
++$females;
break;
default:
$html .= '<i class="icon-sex_u_9x9" title="' . I18N::translateContext('unknown gender', 'Unknown') . '"></i>';
break;
}
}
$html .= '<div class="indent">' . $facts . '</div>' . $tag2;
}
return $html;
}
开发者ID:josefpavlik,项目名称:webtrees,代码行数:36,代码来源:calendar.php
示例15: menuFavorites
/**
* Favorites menu.
*
* @return Menu|null
*/
protected function menuFavorites()
{
global $controller;
$show_user_favorites = $this->tree && Module::getModuleByName('user_favorites') && Auth::check();
$show_tree_favorites = $this->tree && Module::getModuleByName('gedcom_favorites');
if ($show_user_favorites && $show_tree_favorites) {
$favorites = array_merge(FamilyTreeFavoritesModule::getFavorites($this->tree->getTreeId()), UserFavoritesModule::getFavorites(Auth::id()));
} elseif ($show_user_favorites) {
$favorites = UserFavoritesModule::getFavorites(Auth::id());
} elseif ($show_tree_favorites) {
$favorites = FamilyTreeFavoritesModule::getFavorites($this->tree->getTreeId());
} else {
$favorites = array();
}
$submenus = array();
$records = array();
foreach ($favorites as $favorite) {
switch ($favorite['type']) {
case 'URL':
$submenus[] = new Menu($favorite['title'], $favorite['url']);
break;
case 'INDI':
case 'FAM':
case 'SOUR':
case 'OBJE':
case 'NOTE':
$record = GedcomRecord::getInstance($favorite['gid'], $this->tree);
if ($record && $record->canShowName()) {
$submenus[] = new Menu($record->getFullName(), $record->getHtmlUrl());
$records[] = $record;
}
break;
}
}
if ($show_user_favorites && isset($controller->record) && $controller->record instanceof GedcomRecord && !in_array($controller->record, $records)) {
$submenus[] = new Menu(I18N::translate('Add to favorites'), '#', '', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite", {xref:"' . $controller->record->getXref() . '"},function(){location.reload();})'));
}
if (empty($submenus)) {
return null;
} else {
return new Menu(I18N::translate('Favorites'), '#', 'menu-favorites', array(), $submenus);
}
}
开发者ID:tronsmit,项目名称:webtrees,代码行数:48,代码来源:AbstractTheme.php
示例16: formatFactDate
/**
* Print fact DATE/TIME
*
* @param Fact $event event containing the date/age
* @param GedcomRecord $record the person (or couple) whose ages should be printed
* @param bool $anchor option to print a link to calendar
* @param bool $time option to print TIME value
*
* @return string
*/
public static function formatFactDate(Fact $event, GedcomRecord $record, $anchor, $time)
{
global $pid;
$factrec = $event->getGedcom();
$html = '';
// Recorded age
if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) {
$fact_age = $match[1];
} else {
$fact_age = '';
}
if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) {
$husb_age = $match[1];
} else {
$husb_age = '';
}
if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) {
$wife_age = $match[1];
} else {
$wife_age = '';
}
// Calculated age
if (preg_match('/\\n2 DATE (.+)/', $factrec, $match)) {
$date = new Date($match[1]);
$html .= ' ' . $date->display($anchor);
// time
if ($time && preg_match('/\\n3 TIME (.+)/', $factrec, $match)) {
$html .= ' – <span class="date">' . $match[1] . '</span>';
}
$fact = $event->getTag();
if ($record instanceof Individual) {
if ($fact === 'BIRT' && $record->getTree()->getPreference('SHOW_PARENTS_AGE')) {
// age of parents at child birth
$html .= self::formatParentsAges($record, $date);
} elseif ($fact !== 'CHAN' && $fact !== '_TODO') {
// age at event
$birth_date = $record->getBirthDate();
// Can't use getDeathDate(), as this also gives BURI/CREM events, which
// wouldn't give the correct "days after death" result for people with
// no DEAT.
$death_event = $record->getFirstFact('DEAT');
if ($death_event) {
$death_date = $death_event->getDate();
} else {
$death_date = new Date('');
}
$ageText = '';
if (Date::compare($date, $death_date) <= 0 || !$record->isDead() || $fact == 'DEAT') {
// Before death, print age
$age = Date::getAgeGedcom($birth_date, $date);
// Only show calculated age if it differs from recorded age
if ($age != '') {
if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $record->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $record->getSex() == 'F' && $wife_age != $age) {
if ($age != "0d") {
$ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')';
}
}
}
}
if ($fact != 'DEAT' && Date::compare($date, $death_date) >= 0) {
// After death, print time since death
$age = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($death_date, $date), true);
if ($age != '') {
if (Date::getAgeGedcom($death_date, $date) == "0d") {
$ageText = '(' . I18N::translate('on the date of death') . ')';
} else {
$ageText = '(' . $age . ' ' . I18N::translate('after death') . ')';
// Family events which occur after death are probably errors
if ($event->getParent() instanceof Family) {
$ageText .= '<i class="icon-warning"></i>';
}
}
}
}
if ($ageText) {
$html .= ' <span class="age">' . $ageText . '</span>';
}
}
} elseif ($record instanceof Family) {
$indi = Individual::getInstance($pid, $record->getTree());
if ($indi) {
$birth_date = $indi->getBirthDate();
$death_date = $indi->getDeathDate();
$ageText = '';
if (Date::compare($date, $death_date) <= 0) {
$age = Date::getAgeGedcom($birth_date, $date);
// Only show calculated age if it differs from recorded age
if ($age != '' && $age > 0) {
if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $indi->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $indi->getSex() == 'F' && $wife_age != $age) {
$ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')';
//.........这里部分代码省略.........
开发者ID:jflash,项目名称:webtrees,代码行数:101,代码来源:FunctionsPrint.php
示例17: eventQuery
/**
* Events
*
* @param string $type
* @param string $direction
* @param string $facts
*
* @return string
*/
private function eventQuery($type, $direction, $facts)
{
$eventTypes = array('BIRT' => I18N::translate('birth'), 'DEAT' => I18N::translate('death'), 'MARR' => I18N::translate('marriage'), 'ADOP' => I18N::translate('adoption'), 'BURI' => I18N::translate('burial'), 'CENS' => I18N::translate('census added'));
$fact_query = "IN ('" . str_replace('|', "','", $facts) . "')";
if ($direction != 'ASC') {
$direction = 'DESC';
}
$rows = $this->runSql('' . ' SELECT SQL_CACHE' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " `##dates`" . ' WHERE' . " d_file={$this->tree->getTreeId()} AND" . " d_gid<>'HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1<>0' . ' ORDER BY' . " d_julianday1 {$direction}, d_type LIMIT 1");
if (!isset($rows[0])) {
return '';
}
$row = $rows[0];
$record = GedcomRecord::getInstance($row['id'], $this->tree);
switch ($type) {
default:
case 'full':
if ($record->canShow()) {
$result = $record->formatList('span', false, $record->getFullName());
} else {
$result = I18N::translate('This information is private and cannot be shown.');
}
break;
case 'year':
$date = new Date($row['type'] . ' ' . $row['year']);
$result = $date->display();
break;
case 'type':
if (isset($eventTypes[$row['fact']])) {
$result = $eventTypes[$row['fact']];
} else {
$result = GedcomTag::getLabel($row['fact']);
}
break;
case 'name':
$result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>";
break;
case 'place':
$fact = $record->getFirstFact($row['fact']);
if ($fact) {
$result = FunctionsPrint::formatFactPlace($fact, true, true, true);
} else {
$result = I18N::translate('Private');
}
break;
}
return $result;
}
开发者ID:AlexSnet,项目名称:webtrees,代码行数:56,代码来源:Stats.php
示例18: eventSortName
/**
* Sort a list events for the today/upcoming blocks
*
* @param array $a
* @param array $b
*
* @return int
*/
public static function eventSortName($a, $b)
{
if ($a['jd'] == $b['jd']) {
return GedcomRecord::compare($a['record'], $b['record']);
} else {
return $a['jd'] - $b['jd'];
}
}
开发者ID:jflash,项目名称:webtrees,代码行数:16,代码来源:Functions.php
示例19: Family
$record = new Family($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'SOUR':
$record = new Source($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'REPO':
$record = new Repository($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'OBJE':
$record = new Media($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'NOTE':
$record = new Note($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
default:
$record = new GedcomRecord($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
}
if ($change->xref != $prev_xref || $change->gedcom_id != $prev_gedcom_id) {
if ($prev_xref) {
$output .= '</table></td></tr>';
}
$prev_xref = $change->xref;
$prev_gedcom_id = $change->gedcom_id;
$output .= '<tr><td class="list_value">';
$output .= '<b><a href="#" onclick="return show_diff(\'' . $record->getHtmlUrl() . '\');"> ' . $record->getFullName() . '</a></b>';
$output .= '<div class="indent">';
$output .= '<table class="list_table"><tr>';
$output .= '<td class="list_label">' . I18N::translate('Accept') . '</td>';
$output .= '<td class="list_label">' . I18N::translate('Changes') . '</td>';
$output .= '<td class="list_label">' . I18N::translate('User') . '</td>';
开发者ID:tunandras,项目名称:webtrees,代码行数:31,代码来源:edit_changes.php
示例20: array
$formats = array('' => I18N::translate('none'), 'markdown' => I18N::translate('markdown'));
$source_types = array(0 => I18N::translate('none'), 1 => I18N::translate('facts'), 2 => I18N::translate('records'));
$no_yes = array(0 => I18N::translate('no'), 1 => I18N::translate('yes'));
$PRIVACY_CONSTANTS = array('none' => I18N::translate('Show to visitors'), 'privacy' => I18N::translate('Show to members'), 'confidential' => I18N::translate('Show to managers'), 'hidden' => I18N::translate('Hide from everyone'));
$privacy = array(Auth::PRIV_PRIVATE => I18N::translate('Show to visitors'), Auth::PRIV_USER => I18N::translate('Show to members'), Auth::PRIV_NONE => I18N::translate('Show to managers'), Auth::PRIV_HIDE => I18N::translate('Hide from everyone'));
$tags = array_unique(array_merge(explode(',', $WT_TREE->getPreference('INDI_FACTS_ADD')), explode(',', $WT_TREE->getPreference('INDI_FACTS_UNIQUE')), explode(',', $WT_TREE->getPreference('FAM_FACTS_ADD')), explode(',', $WT_TREE->getPreference('FAM_FACTS_UNIQUE')), explode(',', $WT_TREE->getPreference('NOTE_FACTS_ADD')), explode(',', $WT_TREE->getPreference('NOTE_FACTS_UNIQUE')), explode(',', $WT_TREE->getPreference('SOUR_FACTS_ADD')), explode(',', $WT_TREE->getPreference('SOUR_FACTS_UNIQUE')), explode(',',
|
请发表评论