本文整理汇总了PHP中Fisharebest\Webtrees\GedcomRecord类的典型用法代码示例。如果您正苦于以下问题:PHP GedcomRecord类的具体用法?PHP GedcomRecord怎么用?PHP GedcomRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GedcomRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>';
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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>';
}
示例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();
}
}
示例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);
}
示例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;
}
}
}
示例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 {
示例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':
示例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);
//.........这里部分代码省略.........
示例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;
}
示例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);
}
}