本文整理汇总了PHP中Fisharebest\Webtrees\Family::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Family::getInstance方法的具体用法?PHP Family::getInstance怎么用?PHP Family::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Family
的用法示例。
在下文中一共展示了Family::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Startup activity
*/
public function __construct()
{
global $WT_TREE;
$xref = Filter::get('famid', WT_REGEX_XREF);
$this->record = Family::getInstance($xref, $WT_TREE);
parent::__construct();
}
示例2: getIntance
/**
* Extend \Fisharebest\Webtrees\Family getInstance, in order to retrieve directly a \MyArtJaub\Webtrees\Family object
*
* @param string $xref
* @param Tree $tree
* @param string $gedcom
* @return NULL|\MyArtJaub\Webtrees\Family
*/
public static function getIntance($xref, Tree $tree, $gedcom = null)
{
$dfam = null;
$fam = fw\Family::getInstance($xref, $tree, $gedcom);
if ($fam) {
$dfam = new Family($fam);
}
return $dfam;
}
示例3: printCousins
/**
* print cousins list
*
* @param string $famid family ID
* @param int $show_full large or small box
*/
public static function printCousins($famid, $show_full = 1)
{
global $WT_TREE;
if ($show_full) {
$bheight = Theme::theme()->parameter('chart-box-y');
} else {
$bheight = Theme::theme()->parameter('compact-chart-box-y');
}
$family = Family::getInstance($famid, $WT_TREE);
$fchildren = $family->getChildren();
$kids = count($fchildren);
echo '<td valign="middle" height="100%">';
if ($kids) {
echo '<table cellspacing="0" cellpadding="0" border="0" ><tr valign="middle">';
if ($kids > 1) {
echo '<td rowspan="', $kids, '" valign="middle" align="right"><img width="3px" height="', ($bheight + 9) * ($kids - 1), 'px" src="', Theme::theme()->parameter('image-vline'), '" alt=""></td>';
}
$ctkids = count($fchildren);
$i = 1;
foreach ($fchildren as $fchil) {
if ($i == 1) {
echo '<td><img width="10px" height="3px" align="top"';
} else {
echo '<td><img width="10px" height="3px"';
}
if (I18N::direction() === 'ltr') {
echo ' style="padding-right: 2px;"';
} else {
echo ' style="padding-left: 2px;"';
}
echo ' src="', Theme::theme()->parameter('image-hline'), '" alt=""></td><td>';
FunctionsPrint::printPedigreePerson($fchil, $show_full);
echo '</td></tr>';
if ($i < $ctkids) {
echo '<tr>';
$i++;
}
}
echo '</table>';
} else {
// If there is known that there are no children (as opposed to no known children)
if (preg_match('/\\n1 NCHI (\\d+)/', $family->getGedcom(), $match) && $match[1] == 0) {
echo ' <i class="icon-childless" title="', I18N::translate('This family remained childless'), '"></i>';
}
}
echo '</td>';
}
示例4: 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();
}
}
示例5: oldStyleRelationshipPath
/**
* Convert a path (list of XREFs) to an "old-style" string of relationships.
*
* Return an empty array, if privacy rules prevent us viewing any node.
*
* @param GedcomRecord[] $path Alternately Individual / Family
*
* @return string[]
*/
public function oldStyleRelationshipPath(array $path)
{
global $WT_TREE;
$spouse_codes = array('M' => 'hus', 'F' => 'wif', 'U' => 'spo');
$parent_codes = array('M' => 'fat', 'F' => 'mot', 'U' => 'par');
$child_codes = array('M' => 'son', 'F' => 'dau', 'U' => 'chi');
$sibling_codes = array('M' => 'bro', 'F' => 'sis', 'U' => 'sib');
$relationships = array();
for ($i = 1; $i < count($path); $i += 2) {
$family = Family::getInstance($path[$i], $WT_TREE);
$prev = Individual::getInstance($path[$i - 1], $WT_TREE);
$next = Individual::getInstance($path[$i + 1], $WT_TREE);
if (preg_match('/\\n\\d (HUSB|WIFE|CHIL) @' . $prev->getXref() . '@/', $family->getGedcom(), $match)) {
$rel1 = $match[1];
} else {
return array();
}
if (preg_match('/\\n\\d (HUSB|WIFE|CHIL) @' . $next->getXref() . '@/', $family->getGedcom(), $match)) {
$rel2 = $match[1];
} else {
return array();
}
if (($rel1 === 'HUSB' || $rel1 === 'WIFE') && ($rel2 === 'HUSB' || $rel2 === 'WIFE')) {
$relationships[$i] = $spouse_codes[$next->getSex()];
} elseif (($rel1 === 'HUSB' || $rel1 === 'WIFE') && $rel2 === 'CHIL') {
$relationships[$i] = $child_codes[$next->getSex()];
} elseif ($rel1 === 'CHIL' && ($rel2 === 'HUSB' || $rel2 === 'WIFE')) {
$relationships[$i] = $parent_codes[$next->getSex()];
} elseif ($rel1 === 'CHIL' && $rel2 === 'CHIL') {
$relationships[$i] = $sibling_codes[$next->getSex()];
}
}
return $relationships;
}
示例6: topTenGrandFamilyQuery
/**
* Find the couple with the most grandchildren.
*
* @param string $type
* @param string[] $params
*
* @return string
*/
private function topTenGrandFamilyQuery($type = 'list', $params = array())
{
if (isset($params[0])) {
$total = (int) $params[0];
} else {
$total = 10;
}
$rows = $this->runSql("SELECT SQL_CACHE COUNT(*) AS tot, f_id AS id" . " FROM `##families`" . " JOIN `##link` AS children ON children.l_file = {$this->tree->getTreeId()}" . " JOIN `##link` AS mchildren ON mchildren.l_file = {$this->tree->getTreeId()}" . " JOIN `##link` AS gchildren ON gchildren.l_file = {$this->tree->getTreeId()}" . " WHERE" . " f_file={$this->tree->getTreeId()} AND" . " children.l_from=f_id AND" . " children.l_type='CHIL' AND" . " children.l_to=mchildren.l_from AND" . " mchildren.l_type='FAMS' AND" . " mchildren.l_to=gchildren.l_from AND" . " gchildren.l_type='CHIL'" . " GROUP BY id" . " ORDER BY tot DESC" . " LIMIT " . $total);
if (!isset($rows[0])) {
return '';
}
$top10 = array();
foreach ($rows as $row) {
$family = Family::getInstance($row['id'], $this->tree);
if ($family->canShow()) {
if ($type === 'list') {
$top10[] = '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a> - ' . I18N::plural('%s grandchild', '%s grandchildren', $row['tot'], I18N::number($row['tot']));
} else {
$top10[] = '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a> - ' . I18N::plural('%s grandchild', '%s grandchildren', $row['tot'], I18N::number($row['tot']));
}
}
}
if ($type === 'list') {
$top10 = implode('', $top10);
} else {
$top10 = implode('; ', $top10);
}
if (I18N::direction() === 'rtl') {
$top10 = str_replace(array('[', ']', '(', ')', '+'), array('‏[', '‏]', '‏(', '‏)', '‏+'), $top10);
}
if ($type === 'list') {
return '<ul>' . $top10 . '</ul>';
}
return $top10;
}
示例7: exportGedcom
/**
* Export the database in GEDCOM format
*
* @param Tree $tree Which tree to export
* @param resource $gedout Handle to a writable stream
* @param string[] $exportOptions Export options are as follows:
* 'privatize': which Privacy rules apply? (none, visitor, user, manager)
* 'toANSI': should the output be produced in ISO-8859-1 instead of UTF-8? (yes, no)
* 'path': what constant should prefix all media file paths? (eg: media/ or c:\my pictures\my family
* 'slashes': what folder separators apply to media file paths? (forward, backward)
*/
public static function exportGedcom(Tree $tree, $gedout, $exportOptions)
{
switch ($exportOptions['privatize']) {
case 'gedadmin':
$access_level = Auth::PRIV_NONE;
break;
case 'user':
$access_level = Auth::PRIV_USER;
break;
case 'visitor':
$access_level = Auth::PRIV_PRIVATE;
break;
case 'none':
$access_level = Auth::PRIV_HIDE;
break;
}
$head = self::gedcomHeader($tree);
if ($exportOptions['toANSI'] == 'yes') {
$head = str_replace('UTF-8', 'ANSI', $head);
$head = utf8_decode($head);
}
$head = self::reformatRecord($head);
fwrite($gedout, $head);
// Buffer the output. Lots of small fwrite() calls can be very slow when writing large gedcoms.
$buffer = '';
// Generate the OBJE/SOUR/REPO/NOTE records first, as their privacy calcualations involve
// database queries, and we wish to avoid large gaps between queries due to MySQL connection timeouts.
$tmp_gedcom = '';
$rows = Database::prepare("SELECT m_id AS xref, m_gedcom AS gedcom" . " FROM `##media` WHERE m_file = :tree_id ORDER BY m_id")->execute(array('tree_id' => $tree->getTreeId()))->fetchAll();
foreach ($rows as $row) {
$rec = Media::getInstance($row->xref, $tree, $row->gedcom)->privatizeGedcom($access_level);
$rec = self::convertMediaPath($rec, $exportOptions['path']);
if ($exportOptions['toANSI'] === 'yes') {
$rec = utf8_decode($rec);
}
$tmp_gedcom .= self::reformatRecord($rec);
}
$rows = Database::prepare("SELECT s_id AS xref, s_file AS gedcom_id, s_gedcom AS gedcom" . " FROM `##sources` WHERE s_file = :tree_id ORDER BY s_id")->execute(array('tree_id' => $tree->getTreeId()))->fetchAll();
foreach ($rows as $row) {
$rec = Source::getInstance($row->xref, $tree, $row->gedcom)->privatizeGedcom($access_level);
if ($exportOptions['toANSI'] === 'yes') {
$rec = utf8_decode($rec);
}
$tmp_gedcom .= self::reformatRecord($rec);
}
$rows = Database::prepare("SELECT o_type AS type, o_id AS xref, o_gedcom AS gedcom" . " FROM `##other` WHERE o_file = :tree_id AND o_type NOT IN ('HEAD', 'TRLR') ORDER BY o_id")->execute(array('tree_id' => $tree->getTreeId()))->fetchAll();
foreach ($rows as $row) {
switch ($row->type) {
case 'NOTE':
$record = Note::getInstance($row->xref, $tree, $row->gedcom);
break;
case 'REPO':
$record = Repository::getInstance($row->xref, $tree, $row->gedcom);
break;
default:
$record = GedcomRecord::getInstance($row->xref, $tree, $row->gedcom);
break;
}
$rec = $record->privatizeGedcom($access_level);
if ($exportOptions['toANSI'] === 'yes') {
$rec = utf8_decode($rec);
}
$tmp_gedcom .= self::reformatRecord($rec);
}
$rows = Database::prepare("SELECT i_id AS xref, i_gedcom AS gedcom" . " FROM `##individuals` WHERE i_file = :tree_id ORDER BY i_id")->execute(array('tree_id' => $tree->getTreeId()))->fetchAll();
foreach ($rows as $row) {
$rec = Individual::getInstance($row->xref, $tree, $row->gedcom)->privatizeGedcom($access_level);
if ($exportOptions['toANSI'] === 'yes') {
$rec = utf8_decode($rec);
}
$buffer .= self::reformatRecord($rec);
if (strlen($buffer) > 65536) {
fwrite($gedout, $buffer);
$buffer = '';
}
}
$rows = Database::prepare("SELECT f_id AS xref, f_gedcom AS gedcom" . " FROM `##families` WHERE f_file = :tree_id ORDER BY f_id")->execute(array('tree_id' => $tree->getTreeId()))->fetchAll();
foreach ($rows as $row) {
$rec = Family::getInstance($row->xref, $tree, $row->gedcom)->privatizeGedcom($access_level);
if ($exportOptions['toANSI'] === 'yes') {
$rec = utf8_decode($rec);
}
$buffer .= self::reformatRecord($rec);
if (strlen($buffer) > 65536) {
fwrite($gedout, $buffer);
$buffer = '';
}
}
fwrite($gedout, $buffer);
//.........这里部分代码省略.........
示例8: renderFamSosaListIndi
//.........这里部分代码省略.........
/* 11-SURN,GIVN */ { type: "unicode", visible: false},
/* 12-Wife Age */ { dataSort: 13, class: "center"},
/* 13-AGE */ { type: "num", visible: false},
/* 14-Marr Date */ { dataSort: 15, class: "center"},
/* 15-MARR:DATE */ { visible: false},
/* 16-Marr Plac */ { type: "unicode", class: "center"},
/* 17-Marr Sour */ { dataSort : 18, class: "center", visible: ' . (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME) ? 'true' : 'false') . ' },
/* 18-Sort Sour */ { visible: false},
/* 19-Children */ { dataSort: 20, class: "center"},
/* 20-NCHI */ { type: "num", visible: false},
/* 21-MARR */ { visible: false},
/* 22-DEAT */ { visible: false},
/* 23-TREE */ { visible: false}
],
sorting: [[0, "asc"]],
displayLength: 16,
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("#sosa-fam-list").css("visibility", "visible");
jQuery("#btn-toggle-statistics-' . $table_id . '").click();
');
$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] = '';
}
foreach ($listFamSosa as $sosa => $fid) {
$sfamily = Family::getInstance($fid, $WT_TREE);
if (!$sfamily || !$sfamily->canShow()) {
unset($sfamily[$sosa]);
continue;
}
$mdate = $sfamily->getMarriageDate();
if (($husb = $sfamily->getHusband()) && ($hdate = $husb->getBirthDate()) && $hdate->isOK() && $mdate->isOK()) {
if (FunctionsPrint::isDateWithinChartsRange($hdate)) {
$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();
}
}
if (($wife = $sfamily->getWife()) && ($wdate = $wife->getBirthDate()) && $wdate->isOK() && $mdate->isOK()) {
if (FunctionsPrint::isDateWithinChartsRange($wdate)) {
$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();
}
}
if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) {
$marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
}
$listFamSosa[$sosa] = $sfamily;
}
$this->view_bag->set('sosa_list', $listFamSosa);
$this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
$this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')));
$this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')));
}
ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render();
}
示例9: createPrivateGedcomRecord
/**
* Generate a private version of this record
*
* @param int $access_level
*
* @return string
*/
protected function createPrivateGedcomRecord($access_level)
{
$SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
$rec = '0 @' . $this->xref . '@ INDI';
if ($this->tree->getPreference('SHOW_LIVING_NAMES') >= $access_level) {
// Show all the NAME tags, including subtags
foreach ($this->getFacts('NAME') as $fact) {
$rec .= "\n" . $fact->getGedcom();
}
}
// Just show the 1 FAMC/FAMS tag, not any subtags, which may contain private data
preg_match_all('/\\n1 (?:FAMC|FAMS) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$rela = Family::getInstance($match[1], $this->tree);
if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) {
$rec .= $match[0];
}
}
// Don’t privatize sex.
if (preg_match('/\\n1 SEX [MFU]/', $this->gedcom, $match)) {
$rec .= $match[0];
}
return $rec;
}
示例10:
if ($linktoid == "") {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktopid" size="3" value="', $linktoid, '"> ';
echo FunctionsPrint::printFindIndividualLink('linktopid');
} else {
$record = Individual::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
if ($linkto == "family") {
echo I18N::translate('Family'), '</td>';
echo '<td class="optionbox wrap">';
if ($linktoid == "") {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktofamid" size="3" value="', $linktoid, '"> ';
echo FunctionsPrint::printFindFamilyLink('linktofamid');
} else {
$record = Family::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
if ($linkto == "source") {
echo I18N::translate('Source'), "</td>";
echo '<td class="optionbox wrap">';
if ($linktoid == "") {
echo '<input class="pedigree_form" type="text" name="linktoid" id="linktosid" size="3" value="', $linktoid, '"> ';
echo FunctionsPrint::printFindSourceLink('linktosid');
} else {
$record = Source::getInstance($linktoid, $WT_TREE);
echo $record->formatList('span', false, $record->getFullName());
}
}
if ($linkto == "repository") {
示例11: listStartHandler
/**
* XML <List>
*
* @param array $attrs an array of key value pairs for the attributes
*/
private function listStartHandler($attrs)
{
global $WT_TREE;
$this->process_repeats++;
if ($this->process_repeats > 1) {
return;
}
$match = array();
if (isset($attrs['sortby'])) {
$sortby = $attrs['sortby'];
if (preg_match("/\\\$(\\w+)/", $sortby, $match)) {
$sortby = $this->vars[$match[1]]['id'];
$sortby = trim($sortby);
}
} else {
$sortby = "NAME";
}
if (isset($attrs['list'])) {
$listname = $attrs['list'];
} else {
$listname = "individual";
}
// Some filters/sorts can be applied using SQL, while others require PHP
switch ($listname) {
case "pending":
$rows = Database::prepare("SELECT xref, CASE new_gedcom WHEN '' THEN old_gedcom ELSE new_gedcom END AS gedcom" . " FROM `##change`" . " WHERE (xref, change_id) IN (" . " SELECT xref, MAX(change_id)" . " FROM `##change`" . " WHERE status = 'pending' AND gedcom_id = :tree_id" . " GROUP BY xref" . " )")->execute(array('tree_id' => $WT_TREE->getTreeId()))->fetchAll();
$this->list = array();
foreach ($rows as $row) {
$this->list[] = GedcomRecord::getInstance($row->xref, $WT_TREE, $row->gedcom);
}
break;
case 'individual':
$sql_select = "SELECT i_id AS xref, i_gedcom AS gedcom FROM `##individuals` ";
$sql_join = "";
$sql_where = " WHERE i_file = :tree_id";
$sql_order_by = "";
$sql_params = array('tree_id' => $WT_TREE->getTreeId());
foreach ($attrs as $attr => $value) {
if (strpos($attr, 'filter') === 0 && $value) {
$value = $this->substituteVars($value, false);
// Convert the various filters into SQL
if (preg_match('/^(\\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
$sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=i_file AND {$attr}.d_gid=i_id)";
$sql_where .= " AND {$attr}.d_fact = :{$attr}fact";
$sql_params[$attr . 'fact'] = $match[1];
$date = new Date($match[3]);
if ($match[2] == "LTE") {
$sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date";
$sql_params[$attr . 'date'] = $date->maximumJulianDay();
} else {
$sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date";
$sql_params[$attr . 'date'] = $date->minimumJulianDay();
}
if ($sortby == $match[1]) {
$sortby = "";
$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1";
}
unset($attrs[$attr]);
// This filter has been fully processed
} elseif (preg_match('/^NAME CONTAINS (.*)$/', $value, $match)) {
// Do nothing, unless you have to
if ($match[1] != '' || $sortby == 'NAME') {
$sql_join .= " JOIN `##name` AS {$attr} ON (n_file=i_file AND n_id=i_id)";
// Search the DB only if there is any name supplied
if ($match[1] != "") {
$names = explode(" ", $match[1]);
foreach ($names as $n => $name) {
$sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')";
$sql_params[$attr . 'name' . $n] = $name;
}
}
// Let the DB do the name sorting even when no name was entered
if ($sortby == "NAME") {
$sortby = "";
$sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.n_sort";
}
}
unset($attrs[$attr]);
// This filter has been fully processed
} elseif (preg_match('/^REGEXP \\/(.+)\\//', $value, $match)) {
$sql_where .= " AND i_gedcom REGEXP :{$attr}gedcom";
// PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT"
$sql_params[$attr . 'gedcom'] = str_replace('\\n', "\n", $match[1]);
unset($attrs[$attr]);
// This filter has been fully processed
} elseif (preg_match('/^(?:\\w+):PLAC CONTAINS (.+)$/', $value, $match)) {
$sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file = i_file)";
$sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file = {$attr}b.pl_file AND {$attr}b.pl_p_id = {$attr}a.p_id AND {$attr}b.pl_gid = i_id)";
$sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')";
$sql_params[$attr . 'place'] = $match[1];
// Don't unset this filter. This is just initial filtering
} elseif (preg_match('/^(\\w*):*(\\w*) CONTAINS (.+)$/', $value, $match)) {
$sql_where .= " AND i_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')";
$sql_params[$attr . 'contains1'] = $match[1];
$sql_params[$attr . 'contains2'] = $match[2];
//.........这里部分代码省略.........
示例12: addSimpleTag
//.........这里部分代码省略.........
case 'NAME':
if ($upperlevel !== 'REPO' && $upperlevel !== 'UNKNOWN') {
echo FunctionsPrint::helpLink($fact);
}
break;
case 'DATE':
case 'PLAC':
case 'RESN':
case 'ROMN':
case 'SURN':
case '_HEB':
echo FunctionsPrint::helpLink($fact);
break;
}
}
// tag level
if ($level > 0) {
if ($fact === 'TEXT' && $level > 1) {
echo '<input type="hidden" name="glevels[]" value="', $level - 1, '">';
echo '<input type="hidden" name="islink[]" value="0">';
echo '<input type="hidden" name="tag[]" value="DATA">';
// leave data text[] value empty because the following TEXT line will cause the DATA to be added
echo '<input type="hidden" name="text[]" value="">';
}
echo '<input type="hidden" name="glevels[]" value="', $level, '">';
echo '<input type="hidden" name="islink[]" value="', $islink, '">';
echo '<input type="hidden" name="tag[]" value="', $fact, '">';
}
echo '</td>';
// value
echo '<td class="optionbox wrap">';
// retrieve linked NOTE
if ($fact === 'NOTE' && $islink) {
$note1 = Note::getInstance($value, $WT_TREE);
if ($note1) {
$noterec = $note1->getGedcom();
preg_match('/' . $value . '/i', $noterec, $notematch);
$value = $notematch[0];
}
}
// Show names for spouses in MARR/HUSB/AGE and MARR/WIFE/AGE
if ($fact === 'HUSB' || $fact === 'WIFE') {
$family = Family::getInstance($xref, $WT_TREE);
if ($family) {
$spouse_link = $family->getFirstFact($fact);
if ($spouse_link) {
$spouse = $spouse_link->getTarget();
if ($spouse) {
echo $spouse->getFullName();
}
}
}
}
if (in_array($fact, Config::emptyFacts()) && ($value === '' || $value === 'Y' || $value === 'y')) {
echo '<input type="hidden" id="', $element_id, '" name="', $element_name, '" value="', $value, '">';
if ($level <= 1) {
echo '<input type="checkbox" ';
if ($value) {
echo 'checked';
}
echo ' onclick="document.getElementById(\'' . $element_id . '\').value = (this.checked) ? \'Y\' : \'\';">';
echo I18N::translate('yes');
}
if ($fact === 'CENS' && $value === 'Y') {
echo self::censusDateSelector(WT_LOCALE, $xref);
if (Module::getModuleByName('GEDFact_assistant') && GedcomRecord::getInstance($xref, $WT_TREE) instanceof Individual) {
示例13: __construct
/**
* Create the clippings controller
*/
public function __construct()
{
global $WT_TREE;
// Our cart is an array of items in the session
$this->cart = Session::get('cart', array());
if (!array_key_exists($WT_TREE->getTreeId(), $this->cart)) {
$this->cart[$WT_TREE->getTreeId()] = array();
}
$this->action = Filter::get('action');
$this->id = Filter::get('id');
$convert = Filter::get('convert', 'yes|no', 'no');
$this->Zip = Filter::get('Zip');
$this->IncludeMedia = Filter::get('IncludeMedia');
$this->conv_path = Filter::get('conv_path');
$this->privatize_export = Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor');
$this->level1 = Filter::getInteger('level1');
$this->level2 = Filter::getInteger('level2');
$this->level3 = Filter::getInteger('level3');
$others = Filter::get('others');
$this->type = Filter::get('type');
if (($this->privatize_export === 'none' || $this->privatize_export === 'none') && !Auth::isManager($WT_TREE)) {
$this->privatize_export = 'visitor';
}
if ($this->privatize_export === 'user' && !Auth::isMember($WT_TREE)) {
$this->privatize_export = 'visitor';
}
if ($this->action === 'add') {
if (empty($this->type) && !empty($this->id)) {
$obj = GedcomRecord::getInstance($this->id, $WT_TREE);
if ($obj) {
$this->type = $obj::RECORD_TYPE;
} else {
$this->type = '';
$this->id = '';
$this->action = '';
}
} elseif (empty($this->id)) {
$this->action = '';
}
if (!empty($this->id) && $this->type !== 'FAM' && $this->type !== 'INDI' && $this->type !== 'SOUR') {
$this->action = 'add1';
}
}
if ($this->action === 'add1') {
$obj = GedcomRecord::getInstance($this->id, $WT_TREE);
$this->addClipping($obj);
if ($this->type === 'SOUR') {
if ($others === 'linked') {
foreach ($obj->linkedIndividuals('SOUR') as $indi) {
$this->addClipping($indi);
}
foreach ($obj->linkedFamilies('SOUR') as $fam) {
$this->addClipping($fam);
}
}
}
if ($this->type === 'FAM') {
if ($others === 'parents') {
$this->addClipping($obj->getHusband());
$this->addClipping($obj->getWife());
} elseif ($others === "members") {
$this->addFamilyMembers(Family::getInstance($this->id, $WT_TREE));
} elseif ($others === "descendants") {
$this->addFamilyDescendancy(Family::getInstance($this->id, $WT_TREE));
}
} elseif ($this->type === 'INDI') {
if ($others === 'parents') {
foreach (Individual::getInstance($this->id, $WT_TREE)->getChildFamilies() as $family) {
$this->addFamilyMembers($family);
}
} elseif ($others === 'ancestors') {
$this->addAncestorsToCart(Individual::getInstance($this->id, $WT_TREE), $this->level1);
} elseif ($others === 'ancestorsfamilies') {
$this->addAncestorsToCartFamilies(Individual::getInstance($this->id, $WT_TREE), $this->level2);
} elseif ($others === 'members') {
foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) {
$this->addFamilyMembers($family);
}
} elseif ($others === 'descendants') {
foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) {
$this->addClipping($family);
$this->addFamilyDescendancy($family, $this->level3);
}
}
uksort($this->cart[$WT_TREE->getTreeId()], array($this, 'compareClippings'));
}
} elseif ($this->action === 'remove') {
unset($this->cart[$WT_TREE->getTreeId()][$this->id]);
} elseif ($this->action === 'empty') {
$this->cart[$WT_TREE->getTreeId()] = array();
} elseif ($this->action === 'download') {
$media = array();
$mediacount = 0;
$filetext = FunctionsExport::gedcomHeader($WT_TREE);
// Include SUBM/SUBN records, if they exist
$subn = Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBN', $WT_TREE->getTreeId()))->fetchOne();
if ($subn) {
//.........这里部分代码省略.........
示例14: linkedFamilies
/**
* {@inhericDoc}
* @see \Fisharebest\Webtrees\GedcomRecord::linkedFamilies()
*/
public function linkedFamilies($link = '_ACT')
{
$rows = Database::prepare('SELECT f_id AS xref, f_gedcom AS gedcom' . ' FROM `##families`' . ' WHERE f_file= :gedcom_id AND f_gedcom LIKE :gedcom')->execute(array('gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT ' . $this->getFilename() . '%'))->fetchAll();
$list = array();
foreach ($rows as $row) {
$record = Family::getInstance($row->xref, $this->tree, $row->gedcom);
if ($record->canShowName()) {
$list[] = $record;
}
}
return $list;
}
示例15: getCalendarEvents
/**
* Get a list of events which occured during a given date range.
*
* @param int $jd1 the start range of julian day
* @param int $jd2 the end range of julian day
* @param string $facts restrict the search to just these facts or leave blank for all
* @param Tree $tree the tree to search
*
* @return Fact[]
*/
public static function getCalendarEvents($jd1, $jd2, $facts, Tree $tree)
{
// If no facts specified, get all except these
$skipfacts = "CHAN,BAPL,SLGC,SLGS,ENDL,CENS,RESI,NOTE,ADDR,OBJE,SOUR,PAGE,DATA,TEXT";
if ($facts != '_TODO') {
$skipfacts .= ',_TODO';
}
$found_facts = array();
// Events that start or end during the period
$where = "WHERE (d_julianday1>={$jd1} AND d_julianday1<={$jd2} OR d_julianday2>={$jd1} AND d_julianday2<={$jd2})";
// Restrict to certain types of fact
if (empty($facts)) {
$excl_facts = "'" . preg_replace('/\\W+/', "','", $skipfacts) . "'";
$where .= " AND d_fact NOT IN ({$excl_facts})";
} else {
$incl_facts = "'" . preg_replace('/\\W+/', "','", $facts) . "'";
$where .= " AND d_fact IN ({$incl_facts})";
}
// Only get events from the current gedcom
$where .= " AND d_file=" . $tree->getTreeId();
// Now fetch these events
$ind_sql = "SELECT d_gid AS xref, i_gedcom AS gedcom, d_type, d_day, d_month, d_year, d_fact, d_type FROM `##dates`, `##individuals` {$where} AND d_gid=i_id AND d_file=i_file ORDER BY d_julianday1";
$fam_sql = "SELECT d_gid AS xref, f_gedcom AS gedcom, d_type, d_day, d_month, d_year, d_fact, d_type FROM `##dates`, `##families` {$where} AND d_gid=f_id AND d_file=f_file ORDER BY d_julianday1";
foreach (array('INDI' => $ind_sql, 'FAM' => $fam_sql) as $type => $sql) {
$rows = Database::prepare($sql)->fetchAll();
foreach ($rows as $row) {
if ($type === 'INDI') {
$record = Individual::getInstance($row->xref, $tree, $row->gedcom);
} else {
$record = Family::getInstance($row->xref, $tree, $row->gedcom);
}
$anniv_date = new Date($row->d_type . ' ' . $row->d_day . ' ' . $row->d_month . ' ' . $row->d_year);
foreach ($record->getFacts() as $fact) {
if (($fact->getDate()->minimumDate() == $anniv_date->minimumDate() || $fact->getDate()->maximumDate() == $anniv_date->minimumDate()) && $fact->getTag() === $row->d_fact) {
$fact->anniv = 0;
$found_facts[] = $fact;
}
}
}
}
return $found_facts;
}