/** * 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; $days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'date_desc'); $block = $this->getBlockSetting($block_id, 'block', '1'); $hide_empty = $this->getBlockSetting($block_id, 'hide_empty', '0'); foreach (array('days', 'infoStyle', 'sortStyle', 'hide_empty', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $found_facts = FunctionsDb::getRecentChanges(WT_CLIENT_JD - $days); if (!$found_facts && $hide_empty) { return ''; } // Print block header $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 .= I18N::plural('Changes in the last %s day', 'Changes in the last %s days', $days, I18N::number($days)); $content = ''; // Print block content if (count($found_facts) == 0) { $content .= I18N::plural('There have been no changes within the last %s day.', 'There have been no changes within the last %s days.', $days, I18N::number($days)); } else { ob_start(); switch ($infoStyle) { case 'list': $content .= FunctionsPrintLists::changesList($found_facts, $sortStyle); break; case 'table': // sortable table $content .= FunctionsPrintLists::changesTable($found_facts, $sortStyle); break; } $content .= ob_get_clean(); } if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * Startup activity */ public function __construct() { global $WT_TREE; $xref = Filter::get('pid', WT_REGEX_XREF); $this->record = Individual::getInstance($xref, $WT_TREE); if (!$this->record && $WT_TREE->getPreference('USE_RIN')) { $rin = FunctionsDb::findRin($xref); $this->record = Individual::getInstance($rin, $WT_TREE); } parent::__construct(); // If we can display the details, add them to the page header if ($this->record && $this->record->canShow()) { $this->setPageTitle($this->record->getFullName() . ' ' . $this->record->getLifespan()); $this->tabs = Module::getActiveTabs($this->record->getTree()); } }
/** * Find a media object. */ private static function mediaFind() { global $WT_TREE; $controller = new SimpleController(); $filter = Filter::get('filter'); $multiple = Filter::getBool('multiple'); $controller->setPageTitle(I18N::translate('Find an individual'))->pageHeader(); ?> <script> function pasterow(id, name, gend, yob, age, bpl) { window.opener.opener.insertRowToTable(id, name, '', gend, '', yob, age, 'Y', '', bpl); } function pasteid(id, name, thumb) { if (thumb) { window.opener.paste_id(id, name, thumb); <?php if (!$multiple) { echo "window.close();"; } ?> } else { // GEDFact_assistant ======================== if (window.opener.document.getElementById('addlinkQueue')) { window.opener.insertRowToTable(id, name); } window.opener.paste_id(id); if (window.opener.pastename) { window.opener.pastename(name); } <?php if (!$multiple) { echo "window.close();"; } ?> } } function checknames(frm) { if (document.forms[0].subclick) { button = document.forms[0].subclick.value; } else { button = ""; } if (frm.filter.value.length < 2 && button !== "all") { alert("<?php echo I18N::translate('Please enter more than one character.'); ?> "); frm.filter.focus(); return false; } if (button=="all") { frm.filter.value = ""; } return true; } </script> <?php echo '<div>'; echo '<table class="list_table width90" border="0">'; echo '<tr><td style="padding: 10px;" class="facts_label03 width90">'; // start column for find text header echo $controller->getPageTitle(); echo '</td>'; echo '</tr>'; echo '</table>'; echo '<br>'; echo '<button onclick="window.close();">', I18N::translate('close'), '</button>'; echo '<br>'; $filter = trim($filter); $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); echo '<table class="tabs_table width90"><tr>'; $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE)); if ($myindilist) { echo '<td class="list_value_wrap"><ul>'; usort($myindilist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare'); foreach ($myindilist as $indi) { $nam = Filter::escapeHtml($indi->getFullName()); echo "<li><a href=\"#\" onclick=\"pasterow(\n\t\t\t\t\t'" . $indi->getXref() . "' ,\n\t\t\t\t\t'" . $nam . "' ,\n\t\t\t\t\t'" . $indi->getSex() . "' ,\n\t\t\t\t\t'" . $indi->getBirthYear() . "' ,\n\t\t\t\t\t'" . (1901 - $indi->getBirthYear()) . "' ,\n\t\t\t\t\t'" . $indi->getBirthPlace() . "'); return false;\">\n\t\t\t\t\t<b>" . $indi->getFullName() . "</b> "; $born = GedcomTag::getLabel('BIRT'); echo "</span><br><span class=\"list_item\">", $born, " ", $indi->getBirthYear(), " ", $indi->getBirthPlace(), "</span></a></li>"; echo "<hr>"; } echo '</ul></td></tr><tr><td class="list_label">', I18N::translate('Total individuals: %s', count($myindilist)), '</tr></td>'; } else { echo "<td class=\"list_value_wrap\">"; echo I18N::translate('No results found.'); echo "</td></tr>"; } echo "</table>"; echo '</div>'; }
} else { $IconRarrow = 'icon-larrow'; $IconLarrow = 'icon-rarrow'; $IconRDarrow = 'icon-ldarrow'; $IconLDarrow = 'icon-rdarrow'; } $all_blocks = array(); foreach (Module::getActiveBlocks($WT_TREE) as $name => $block) { if ($user_id && $block->isUserBlock() || $gedcom_id && $block->isGedcomBlock()) { $all_blocks[$name] = $block; } } if ($user_id) { $blocks = FunctionsDb::getUserBlocks($user_id); } else { $blocks = FunctionsDb::getTreeBlocks($gedcom_id); } if ($action === 'update') { foreach (array('main', 'side') as $location) { if ($location === 'main') { $new_blocks = $main; } else { $new_blocks = $right; } foreach ($new_blocks as $order => $block_name) { if (is_numeric($block_name)) { // existing block Database::prepare("UPDATE `##block` SET block_order=? WHERE block_id=?")->execute(array($order, $block_name)); // existing block moved location Database::prepare("UPDATE `##block` SET location=? WHERE block_id=?")->execute(array($location, $block_name)); } else {
* Copyright (C) 2016 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsDb; use Fisharebest\Webtrees\Functions\FunctionsPrintLists; define('WT_SCRIPT_NAME', 'repolist.php'); require './includes/session.php'; $controller = new PageController(); $controller->setPageTitle(I18N::translate('Repositories')); $controller->pageHeader(); echo '<div id="repolist-page">', '<h2>', I18N::translate('Repositories'), '</h2>'; echo FunctionsPrintLists::repositoryTable(FunctionsDb::getRepositoryList($WT_TREE)); echo '</div>';
* Copyright (C) 2015 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsDb; use Fisharebest\Webtrees\Functions\FunctionsPrintLists; define('WT_SCRIPT_NAME', 'sourcelist.php'); require './includes/session.php'; $controller = new PageController(); $controller->setPageTitle(I18N::translate('Sources')); $controller->pageHeader(); echo '<div id="sourcelist-page">', '<h2>', I18N::translate('Sources'), '</h2>'; echo FunctionsPrintLists::sourceTable(FunctionsDb::getSourceList($WT_TREE)); echo '</div>';
/** * Create a chart of common surnames. * * @param string[] $params * * @return string */ public function chartCommonSurnames($params = array()) { $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values'); $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values'); $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x'); $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y'); if (isset($params[0]) && $params[0] != '') { $size = strtolower($params[0]); } else { $size = $WT_STATS_S_CHART_X . "x" . $WT_STATS_S_CHART_Y; } if (isset($params[1]) && $params[1] != '') { $color_from = strtolower($params[1]); } else { $color_from = $WT_STATS_CHART_COLOR1; } if (isset($params[2]) && $params[2] != '') { $color_to = strtolower($params[2]); } else { $color_to = $WT_STATS_CHART_COLOR2; } if (isset($params[3]) && $params[3] != '') { $threshold = strtolower($params[3]); } else { $threshold = $this->tree->getPreference('COMMON_NAMES_THRESHOLD'); } if (isset($params[4]) && $params[4] != '') { $maxtoshow = strtolower($params[4]); } else { $maxtoshow = 7; } $sizes = explode('x', $size); $tot_indi = $this->totalIndividualsQuery(); $surnames = FunctionsDb::getCommonSurnames($threshold, $this->tree); if (count($surnames) <= 0) { return ''; } $SURNAME_TRADITION = $this->tree->getPreference('SURNAME_TRADITION'); uasort($surnames, '\\Fisharebest\\Webtrees\\Stats::nameTotalReverseSort'); $surnames = array_slice($surnames, 0, $maxtoshow); $all_surnames = array(); foreach (array_keys($surnames) as $n => $surname) { if ($n >= $maxtoshow) { break; } $all_surnames = array_merge($all_surnames, QueryName::surnames($this->tree, I18N::strtoupper($surname), '', false, false)); } $tot = 0; foreach ($surnames as $surname) { $tot += $surname['match']; } $chd = ''; $chl = array(); foreach ($all_surnames as $surns) { $count_per = 0; $max_name = 0; $top_name = ''; foreach ($surns as $spfxsurn => $indis) { $per = count($indis); $count_per += $per; // select most common surname from all variants if ($per > $max_name) { $max_name = $per; $top_name = $spfxsurn; } } switch ($SURNAME_TRADITION) { case 'polish': // most common surname should be in male variant (Kowalski, not Kowalska) $top_name = preg_replace(array('/ska$/', '/cka$/', '/dzka$/', '/żka$/'), array('ski', 'cki', 'dzki', 'żki'), $top_name); } $per = round(100 * $count_per / $tot_indi, 0); $chd .= $this->arrayToExtendedEncoding(array($per)); $chl[] = $top_name . ' - ' . I18N::number($count_per); } $per = round(100 * ($tot_indi - $tot) / $tot_indi, 0); $chd .= $this->arrayToExtendedEncoding(array($per)); $chl[] = I18N::translate('Other') . ' - ' . I18N::number($tot_indi - $tot); $chart_title = implode(I18N::$list_separator, $chl); $chl = implode('|', $chl); return '<img src="https://chart.googleapis.com/chart?cht=p3&chd=e:' . $chd . '&chs=' . $size . '&chco=' . $color_from . ',' . $color_to . '&chf=bg,s,ffffff00&chl=' . rawurlencode($chl) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . $chart_title . '" title="' . $chart_title . '" />'; }
/** * 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 $WT_TREE, $ctype; $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); // This can be overriden when embedding in an HTML block $block = '0'; $stat_link = '1'; foreach (array('show_common_surnames', 'stat_indi', 'stat_fam', 'stat_sour', 'stat_media', 'stat_surname', 'stat_events', 'stat_users', 'stat_first_birth', 'stat_last_birth', 'stat_first_death', 'stat_last_death', 'stat_long_life', 'stat_avg_life', 'stat_most_chil', 'stat_avg_chil', 'stat_link', '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(); $stats = new Stats($WT_TREE); $content = '<b>' . $WT_TREE->getTitleHtml() . '</b><br>'; if ($show_last_update) { $content .= '<div>' . I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</div>'; } /** Responsive Design */ $content .= '<div class="stat-table1">'; if ($stat_indi) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individuals') . '</div><div class="facts_value stats_value stat-cell"><a href="' . "indilist.php?surname_sublist=no&ged=" . $WT_TREE->getNameUrl() . '">' . $stats->totalIndividuals() . '</a></div></div>'; $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Males') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</div></div>'; $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Females') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</div></div>'; } if ($stat_surname) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total surnames') . '</div><div class="facts_value stats_value stat-cell"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSurnames() . '</a></div></div>'; } if ($stat_fam) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Families') . '</div><div class="facts_value stats_value stat-cell"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalFamilies() . '</a></div></div>'; } if ($stat_sour) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Sources') . '</div><div class="facts_value stats_value stat-cell"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSources() . '</a></div></div>'; } if ($stat_media) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Media objects') . '</div><div class="facts_value stats_value stat-cell"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalMedia() . '</a></div></div>'; } if ($stat_repo) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Repositories') . '</div><div class="facts_value stats_value stat-cell"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalRepositories() . '</a></div></div>'; } if ($stat_events) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total events') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalEvents() . '</div></div>'; } if ($stat_users) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total users') . '</div><div class="facts_value stats_value stat-cell">'; if (Auth::isManager($WT_TREE)) { $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>'; } else { $content .= $stats->totalUsers(); } $content .= '</div></div>'; } if (!$block) { $content .= '</div><div class="facts_table stat-table2">'; } if ($stat_first_birth) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstBirthYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->firstBirth() . '</div>'; } $content .= '</div>'; } if ($stat_last_birth) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastBirthYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->lastBirth() . '</div>'; } $content .= '</div>'; } if ($stat_first_death) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstDeathYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->firstDeath() . '</div>'; } $content .= '</div>'; } if ($stat_last_death) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastDeathYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->lastDeath() . '</div>'; } $content .= '</div>'; } if ($stat_long_life) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individual who lived the longest') . '</div><div class="facts_value stats_value stat-cell">' . $stats->longestLifeAge() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->longestLife() . '</div>'; } $content .= '</div>'; } if ($stat_avg_life) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average age at death') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageLifespan() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ': ' . $stats->averageLifespanMale(); $content .= ' ' . I18N::translate('Females') . ': ' . $stats->averageLifespanFemale() . '</div>'; } $content .= '</div>'; } if ($stat_most_chil && !$block) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Family with the most children') . '</div><div class="facts_value stats_value stat-cell">' . $stats->largestFamilySize() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->largestFamily() . '</div>'; } $content .= '</div>'; } if ($stat_avg_chil) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average number of children per family') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageChildren() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left"></div>'; } $content .= '</div>'; } $content .= '</div>'; if ($stat_link) { $content .= '<div class="clearfloat"><a href="statistics.php?ged=' . $WT_TREE->getNameUrl() . '" rel="nofollow"><b>' . I18N::translate('View statistics as graphs') . '</b></a></div>'; } if ($show_common_surnames) { $surnames = FunctionsDb::getCommonSurnames($WT_TREE->getPreference('COMMON_NAMES_THRESHOLD'), $WT_TREE); if (count($surnames) > 0) { $content .= '<div class="clearfloat"><p><b>' . I18N::translate('Most common surnames') . '</b></p>'; $content .= '<div class="common_surnames">'; $i = 0; foreach ($surnames as $indexval => $surname) { if (stristr($surname['name'], '@N.N') === false) { if ($i > 0) { $content .= ', '; } $content .= '<a href="' . "indilist.php?ged=" . $WT_TREE->getNameUrl() . "&surname=" . rawurlencode($surname['name']) . '">' . $surname['name'] . '</a>'; $i++; } } $content .= '</div>'; } } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * Print a list of events * * This performs the same function as print_events_table(), but formats the output differently. * * @param int $startjd * @param int $endjd * @param string $events * @param bool $only_living * @param string $sort_by * * @return string */ public static function eventsList($startjd, $endjd, $events = 'BIRT MARR DEAT', $only_living = false, $sort_by = 'anniv') { global $WT_TREE; // Did we have any output? Did we skip anything? $output = 0; $filter = 0; $filtered_events = array(); $html = ''; foreach (FunctionsDb::getEventsList($startjd, $endjd, $events, $WT_TREE) as $fact) { $record = $fact->getParent(); //-- only living people ? if ($only_living) { if ($record instanceof Individual && $record->isDead()) { $filter++; continue; } if ($record instanceof Family) { $husb = $record->getHusband(); if (is_null($husb) || $husb->isDead()) { $filter++; continue; } $wife = $record->getWife(); if (is_null($wife) || $wife->isDead()) { $filter++; continue; } } } $output++; $filtered_events[] = $fact; } // Now we've filtered the list, we can sort by event, if required switch ($sort_by) { case 'anniv': // Data is already sorted by anniversary date break; case 'alpha': uasort($filtered_events, function (Fact $x, Fact $y) { return GedcomRecord::compare($x->getParent(), $y->getParent()); }); break; } foreach ($filtered_events as $fact) { $record = $fact->getParent(); $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>'; if ($record instanceof Individual) { $html .= $record->getSexImage(); } $html .= '<br><div class="indent">'; $html .= $fact->getLabel() . ' — ' . $fact->getDate()->display(true); if ($fact->anniv) { $html .= ' (' . I18N::translate('%s year anniversary', I18N::number($fact->anniv)) . ')'; } if (!$fact->getPlace()->isEmpty()) { $html .= ' — <a href="' . $fact->getPlace()->getURL() . '">' . $fact->getPlace()->getFullName() . '</a>'; } $html .= '</div>'; } // Print a final summary message about restricted/filtered facts $summary = ''; if ($endjd == WT_CLIENT_JD) { // We're dealing with the Today’s Events block if ($output == 0) { if ($filter == 0) { $summary = I18N::translate('No events exist for today.'); } else { $summary = I18N::translate('No events for living individuals exist for today.'); } } } else { // We're dealing with the Upcoming Events block if ($output == 0) { if ($filter == 0) { if ($endjd == $startjd) { $summary = I18N::translate('No events exist for tomorrow.'); } else { // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow” $summary = I18N::plural('No events exist for the next %s day.', 'No events exist for the next %s days.', $endjd - $startjd + 1, I18N::number($endjd - $startjd + 1)); } } else { if ($endjd == $startjd) { $summary = I18N::translate('No events for living individuals exist for tomorrow.'); } else { // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow” $summary = I18N::plural('No events for living people exist for the next %s day.', 'No events for living people exist for the next %s days.', $endjd - $startjd + 1, I18N::number($endjd - $startjd + 1)); } } } } if ($summary) { $html .= "<b>" . $summary . "</b>"; } return $html; }
/** * 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 $WT_TREE, $ctype; $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); // This can be overriden when embedding in an HTML block $block = '0'; foreach (array('show_common_surnames', 'number_common_surnames', 'stat_indi', 'stat_fam', 'stat_sour', 'stat_media', 'stat_surname', 'stat_events', 'stat_users', 'stat_first_birth', 'stat_last_birth', 'stat_first_death', 'stat_last_death', 'stat_long_life', 'stat_avg_life', 'stat_most_chil', 'stat_avg_chil', '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('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; } else { $title = ''; } $title .= $this->getTitle() . ' — ' . $WT_TREE->getTitleHtml(); $stats = new Stats($WT_TREE); $content = ''; if ($show_last_update) { $content .= '<p>' . I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</p>'; } /** Responsive Design */ $content .= '<div class="stat-table1">'; if ($stat_indi) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individuals') . '</div><div class="facts_value stats_value stat-cell"><a href="' . "indilist.php?surname_sublist=no&ged=" . $WT_TREE->getNameUrl() . '">' . $stats->totalIndividuals() . '</a></div></div>'; $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Males') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</div></div>'; $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Females') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</div></div>'; } if ($stat_surname) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total surnames') . '</div><div class="facts_value stats_value stat-cell"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSurnames() . '</a></div></div>'; } if ($stat_fam) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Families') . '</div><div class="facts_value stats_value stat-cell"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalFamilies() . '</a></div></div>'; } if ($stat_sour) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Sources') . '</div><div class="facts_value stats_value stat-cell"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSources() . '</a></div></div>'; } if ($stat_media) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Media objects') . '</div><div class="facts_value stats_value stat-cell"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalMedia() . '</a></div></div>'; } if ($stat_repo) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Repositories') . '</div><div class="facts_value stats_value stat-cell"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalRepositories() . '</a></div></div>'; } if ($stat_events) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total events') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalEvents() . '</div></div>'; } if ($stat_users) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total users') . '</div><div class="facts_value stats_value stat-cell">'; if (Auth::isManager($WT_TREE)) { $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>'; } else { $content .= $stats->totalUsers(); } $content .= '</div></div>'; } if (!$block) { $content .= '</div><div class="facts_table stat-table2">'; } if ($stat_first_birth) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstBirthYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->firstBirth() . '</div>'; } $content .= '</div>'; } if ($stat_last_birth) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastBirthYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->lastBirth() . '</div>'; } $content .= '</div>'; } if ($stat_first_death) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstDeathYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->firstDeath() . '</div>'; } $content .= '</div>'; } if ($stat_last_death) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastDeathYear() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->lastDeath() . '</div>'; } $content .= '</div>'; } if ($stat_long_life) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individual who lived the longest') . '</div><div class="facts_value stats_value stat-cell">' . $stats->longestLifeAge() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->longestLife() . '</div>'; } $content .= '</div>'; } if ($stat_avg_life) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average age at death') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageLifespan() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ': ' . $stats->averageLifespanMale(); $content .= ' ' . I18N::translate('Females') . ': ' . $stats->averageLifespanFemale() . '</div>'; } $content .= '</div>'; } if ($stat_most_chil && !$block) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Family with the most children') . '</div><div class="facts_value stats_value stat-cell">' . $stats->largestFamilySize() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left">' . $stats->largestFamily() . '</div>'; } $content .= '</div>'; } if ($stat_avg_chil) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average number of children per family') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageChildren() . '</div>'; if (!$block) { $content .= '<div class="facts_value stat-cell left"></div>'; } $content .= '</div>'; } $content .= '</div>'; if ($show_common_surnames) { $surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), 0, (int) $number_of_surnames); $all_surnames = array(); foreach (array_keys($surnames) as $surname) { $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $surname, '', false, false)); } if (!empty($surnames)) { ksort($all_surnames); $content .= '<div class="clearfloat">'; $content .= '<p>'; $content .= '<strong>' . I18N::translate('Most common surnames') . '</strong>'; $content .= '<br>'; $content .= '<span class="common_surnames">' . FunctionsPrintLists::surnameList($all_surnames, 2, false, 'indilist.php', $WT_TREE) . '</span>'; $content .= '</p>'; $content .= '</div>'; } } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * 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, $controller, $WT_TREE; $show_other = $this->getBlockSetting($block_id, 'show_other', '1'); $show_unassigned = $this->getBlockSetting($block_id, 'show_unassigned', '1'); $show_future = $this->getBlockSetting($block_id, 'show_future', '1'); $block = $this->getBlockSetting($block_id, 'block', '1'); foreach (array('show_unassigned', 'show_other', 'show_future', '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(); $table_id = Uuid::uuid4(); // create a unique ID $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript(' jQuery("#' . $table_id . '").dataTable({ dom: \'t\', ' . I18N::datatablesI18N() . ', autoWidth: false, paginate: false, lengthChange: false, filter: false, info: true, jQueryUI: true, columns: [ /* 0-DATE */ { visible: false }, /* 1-Date */ { dataSort: 0 }, /* 1-Record */ null, /* 2-Username */ null, /* 3-Text */ null ] }); jQuery("#' . $table_id . '").css("visibility", "visible"); jQuery(".loading-image").css("display", "none"); '); $content = ''; $content .= '<div class="loading-image"> </div>'; $content .= '<table id="' . $table_id . '" style="visibility:hidden;">'; $content .= '<thead><tr>'; $content .= '<th>DATE</th>'; //hidden by datables code $content .= '<th>' . GedcomTag::getLabel('DATE') . '</th>'; $content .= '<th>' . I18N::translate('Record') . '</th>'; if ($show_unassigned || $show_other) { $content .= '<th>' . I18N::translate('Username') . '</th>'; } $content .= '<th>' . GedcomTag::getLabel('TEXT') . '</th>'; $content .= '</tr></thead><tbody>'; $found = false; $end_jd = $show_future ? 99999999 : WT_CLIENT_JD; foreach (FunctionsDb::getCalendarEvents(0, $end_jd, '_TODO', $WT_TREE) as $fact) { $record = $fact->getParent(); $user_name = $fact->getAttribute('_WT_USER'); if ($user_name === Auth::user()->getUserName() || !$user_name && $show_unassigned || $user_name && $show_other) { $content .= '<tr>'; //-- Event date (sortable) $content .= '<td>'; //hidden by datables code $content .= $fact->getDate()->julianDay(); $content .= '</td>'; $content .= '<td class="wrap">' . $fact->getDate()->display() . '</td>'; $content .= '<td class="wrap"><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>'; if ($show_unassigned || $show_other) { $content .= '<td class="wrap">' . $user_name . '</td>'; } $text = $fact->getValue(); $content .= '<td class="wrap">' . $text . '</td>'; $content .= '</tr>'; $found = true; } } $content .= '</tbody></table>'; if (!$found) { $content .= '<p>' . I18N::translate('There are no research tasks in this family tree.') . '</p>'; } if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
/** * Create a chart of common surnames. * * @param string[] $params * * @return string */ public function chartCommonSurnames($params = array()) { $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values'); $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values'); $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x'); $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y'); $size = empty($params[0]) ? $WT_STATS_S_CHART_X . "x" . $WT_STATS_S_CHART_Y : strtolower($params[0]); $color_from = empty($params[1]) ? $WT_STATS_CHART_COLOR1 : strtolower($params[1]); $color_to = empty($params[2]) ? $WT_STATS_CHART_COLOR2 : strtolower($params[2]); $number_of_surnames = empty($params[3]) ? 10 : (int) $params[3]; $sizes = explode('x', $size); $tot_indi = $this->totalIndividualsQuery(); $surnames = FunctionsDb::getTopSurnames($this->tree->getTreeId(), 0, $number_of_surnames); if (empty($surnames)) { return ''; } $SURNAME_TRADITION = $this->tree->getPreference('SURNAME_TRADITION'); $all_surnames = array(); $tot = 0; foreach ($surnames as $surname => $num) { $all_surnames = array_merge($all_surnames, QueryName::surnames($this->tree, I18N::strtoupper($surname), '', false, false)); $tot += $num; } $chd = ''; $chl = array(); foreach ($all_surnames as $surns) { $count_per = 0; $max_name = 0; $top_name = ''; foreach ($surns as $spfxsurn => $indis) { $per = count($indis); $count_per += $per; // select most common surname from all variants if ($per > $max_name) { $max_name = $per; $top_name = $spfxsurn; } } switch ($SURNAME_TRADITION) { case 'polish': // most common surname should be in male variant (Kowalski, not Kowalska) $top_name = preg_replace(array('/ska$/', '/cka$/', '/dzka$/', '/żka$/'), array('ski', 'cki', 'dzki', 'żki'), $top_name); } $per = round(100 * $count_per / $tot_indi, 0); $chd .= $this->arrayToExtendedEncoding(array($per)); $chl[] = $top_name . ' - ' . I18N::number($count_per); } $per = round(100 * ($tot_indi - $tot) / $tot_indi, 0); $chd .= $this->arrayToExtendedEncoding(array($per)); $chl[] = I18N::translate('Other') . ' - ' . I18N::number($tot_indi - $tot); $chart_title = implode(I18N::$list_separator, $chl); $chl = implode('|', $chl); return '<img src="https://chart.googleapis.com/chart?cht=p3&chd=e:' . $chd . '&chs=' . $size . '&chco=' . $color_from . ',' . $color_to . '&chf=bg,s,ffffff00&chl=' . rawurlencode($chl) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . $chart_title . '" title="' . $chart_title . '" />'; }
/** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\IndividualController; use Fisharebest\Webtrees\Functions\FunctionsDate; use Fisharebest\Webtrees\Functions\FunctionsDb; use Fisharebest\Webtrees\Functions\FunctionsPrint; define('WT_SCRIPT_NAME', 'individual.php'); require './includes/session.php'; $pid = Filter::get('pid', WT_REGEX_XREF); $record = Individual::getInstance($pid, $WT_TREE); if (!$record && $WT_TREE->getPreference('USE_RIN')) { $record = Individual::getInstance(FunctionsDb::findRin($pid), $WT_TREE); } $controller = new IndividualController($record); if ($controller->record && $controller->record->canShow()) { if (Filter::get('action') == 'ajax') { $controller->ajaxRequest(); return; } // Generate the sidebar content *before* we display the page header, // as the clippings cart needs to have write access to the session. $sidebar_html = $controller->getSideBarContent(); $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This individual has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>'; } elseif (Auth::isEditor($controller->record->getTree())) {
break; } $messages = false; $move_file = false; // Move files on disk (if we can) to reflect the change to the GEDCOM data if (!$media->isExternal()) { $oldServerFile = $media->getServerFilename('main'); $oldServerThumb = $media->getServerFilename('thumb'); $newmedia = new Media("xxx", "0 @xxx@ OBJE\n1 FILE " . $newFilename, null, $WT_TREE); $newServerFile = $newmedia->getServerFilename('main'); $newServerThumb = $newmedia->getServerFilename('thumb'); // We could be either renaming an existing file, or updating a record (with no valid file) to point to a new file if ($oldServerFile !== $newServerFile) { //-- check if the file is used in more than one gedcom //-- do not allow it to be moved or renamed if it is if (!$media->isExternal() && FunctionsDb::isMediaUsedInOtherTree($media->getFilename(), $WT_TREE->getTreeId())) { FlashMessages::addMessage(I18N::translate('This file is linked to another family tree on this server. It cannot be deleted, moved, or renamed until these links have been removed.')); break; } $move_file = true; if (!file_exists($newServerFile) || md5_file($oldServerFile) === md5_file($newServerFile)) { try { rename($oldServerFile, $newServerFile); FlashMessages::addMessage(I18N::translate('The media file %1$s has been renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename))); } catch (\ErrorException $ex) { FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename))); } $messages = true; } if (!file_exists($newServerFile)) { FlashMessages::addMessage(I18N::translate('The media file %s does not exist.', Html::filename($newFilename)));
/** * Returns the last changes for 1 day. * * @return \string[] */ public function getRecentChanges() { // TODO: Make configurable. $days = 1; $found_facts = FunctionsDb::getRecentChanges(WT_CLIENT_JD - $days); return $found_facts; }
if ($record && $record->canShow() && $record->canEdit()) { foreach ($record->getFacts() as $fact) { if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) { $record->deleteFact($fact_id, true); break 2; } } } // Can’t find the record/fact, or don’t have permission to delete it. http_response_code(406); break; case 'delete-record': $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) { // Delete links to this record foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) { $linker = GedcomRecord::getInstance($xref, $WT_TREE); $old_gedcom = $linker->getGedcom(); $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref()); // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the // record itself) may have already been deleted. if ($old_gedcom !== $new_gedcom) { // If we have removed a link from a family to an individual, and it has only one member if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) { // Delete the family $family = GedcomRecord::getInstance($xref, $WT_TREE); FlashMessages::addMessage(I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName())); $family->deleteRecord(); // Delete any remaining link to this family if ($match) { $relict = GedcomRecord::getInstance($match[2][0], $WT_TREE);
use Fisharebest\Webtrees\Functions\FunctionsDb; define('WT_SCRIPT_NAME', 'index.php'); require './includes/session.php'; // The only option for action is "ajax" $action = Filter::get('action'); // The default view depends on whether we are logged in if (Auth::check()) { $ctype = Filter::get('ctype', 'gedcom|user', 'user'); } else { $ctype = 'gedcom'; } // Get the blocks list if ($ctype === 'user') { $blocks = FunctionsDb::getUserBlocks(Auth::id()); } else { $blocks = FunctionsDb::getTreeBlocks($WT_TREE->getTreeId()); } $active_blocks = Module::getActiveBlocks($WT_TREE); // The latest version is shown on the administration page. This updates it every day. Functions::fetchLatestVersion(); // We generate individual blocks using AJAX if ($action === 'ajax') { $controller = new AjaxController(); $controller->pageHeader(); // Check we’re displaying an allowable block. $block_id = Filter::getInteger('block_id'); if (array_key_exists($block_id, $blocks['main'])) { $module_name = $blocks['main'][$block_id]; } elseif (array_key_exists($block_id, $blocks['side'])) { $module_name = $blocks['side'][$block_id]; } else {
* webtrees: online genealogy * Copyright (C) 2015 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsDb; use Fisharebest\Webtrees\Functions\FunctionsPrintLists; define('WT_SCRIPT_NAME', 'notelist.php'); require './includes/session.php'; $controller = new PageController(); $controller->setPageTitle(I18N::translate('Shared notes')); $controller->pageHeader(); echo '<div id="notelist-page">', '<h2>', I18N::translate('Shared notes'), '</h2>', FunctionsPrintLists::noteTable(FunctionsDb::getNoteList($WT_TREE)); echo '</div>';
/** * 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, $controller, $WT_TREE; $days = $this->getBlockSetting($block_id, 'days', '7'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $calendar = $this->getBlockSetting($block_id, 'calendar', 'jewish'); $block = $this->getBlockSetting($block_id, 'block', '1'); foreach (array('days', 'infoStyle', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $startjd = WT_CLIENT_JD; $endjd = WT_CLIENT_JD + $days - 1; $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 = ''; // The standard anniversary rules cover most of the Yahrzeit rules, we just // need to handle a few special cases. // Fetch normal anniversaries... $yahrzeits = array(); for ($jd = $startjd - 1; $jd <= $endjd + $days; ++$jd) { foreach (FunctionsDb::getAnniversaryEvents($jd, 'DEAT _YART', $WT_TREE) as $fact) { // Exact hebrew dates only $date = $fact->getDate(); if ($date->minimumDate() instanceof JewishDate && $date->minimumJulianDay() === $date->maximumJulianDay()) { $fact->jd = $jd; $yahrzeits[] = $fact; } } } // ...then adjust dates $jewish_calendar = new JewishCalendar(); foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->getTag() === 'DEAT') { $today = new JewishDate($yahrzeit->jd); $hd = $yahrzeit->getDate()->minimumDate(); $hd1 = new JewishDate($hd); $hd1->y += 1; $hd1->setJdFromYmd(); // Special rules. See http://www.hebcal.com/help/anniv.html // Everything else is taken care of by our standard anniversary rules. if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->daysInMonth() < 30) { // 30 CSH - Last day in CSH $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 3, 1) - 1; } elseif ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->daysInMonth() < 30) { // 30 KSL - Last day in KSL $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 4, 1) - 1; } elseif ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->daysInMonth() < 30 && !$today->isLeapYear()) { // 30 ADR - Last day in SHV $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 6, 1) - 1; } } } switch ($infoStyle) { case 'list': foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) { $ind = $yahrzeit->getParent(); $content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage(); $content .= "<div class=\"indent\">"; $content .= $yahrzeit->getDate()->display(true); $content .= ', ' . I18N::translate('%s year anniversary', $yahrzeit->anniv); $content .= "</div>"; } } break; case 'table': default: $table_id = Uuid::uuid4(); // table requires a unique ID $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript(' jQuery("#' . $table_id . '").dataTable({ dom: \'t\', ' . I18N::datatablesI18N() . ', autoWidth: false, paginate: false, lengthChange: false, filter: false, info: true, jQueryUI: true, sorting: [[5,"asc"]], columns: [ /* 0-name */ { dataSort: 1 }, /* 1-NAME */ { visible: false }, /* 2-date */ { dataSort: 3 }, /* 3-DATE */ { visible: false }, /* 4-Aniv */ { class: "center"}, /* 5-yart */ { dataSort: 6 }, /* 6-YART */ { visible: false } ] }); jQuery("#' . $table_id . '").css("visibility", "visible"); jQuery(".loading-image").css("display", "none"); '); $content = ''; $content .= '<div class="loading-image"> </div>'; $content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">'; $content .= '<thead><tr>'; $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>'; $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>'; $content .= '<th>' . GedcomTag::getLabel('DEAT') . '</th>'; $content .= '<th>DEAT</th>'; $content .= '<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>'; $content .= '<th>' . GedcomTag::getLabel('_YART') . '</th>'; $content .= '<th>_YART</th>'; $content .= '</tr></thead><tbody>'; foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) { $content .= '<tr>'; $ind = $yahrzeit->getParent(); // Individual name(s) $name = $ind->getFullName(); $url = $ind->getHtmlUrl(); $content .= '<td>'; $content .= '<a href="' . $url . '">' . $name . '</a>'; $content .= $ind->getSexImage(); $addname = $ind->getAddName(); if ($addname) { $content .= '<br><a href="' . $url . '">' . $addname . '</a>'; } $content .= '</td>'; $content .= '<td>' . $ind->getSortName() . '</td>'; // death/yahrzeit event date $content .= '<td>' . $yahrzeit->getDate()->display() . '</td>'; $content .= '<td>' . $yahrzeit->getDate()->julianDay() . '</td>'; // sortable date // Anniversary $content .= '<td>' . $yahrzeit->anniv . '</td>'; // upcomming yahrzeit dates switch ($calendar) { case 'gregorian': $today = new GregorianDate($yahrzeit->jd); break; case 'jewish': default: $today = new JewishDate($yahrzeit->jd); break; } $td = new Date($today->format('%@ %A %O %E')); $content .= '<td>' . $td->display() . '</td>'; $content .= '<td>' . $td->julianDay() . '</td>'; // sortable date $content .= '</tr>'; } } $content .= '</tbody></table>'; break; } if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
echo '<li><a href="', $note->getHtmlUrl(), '" onclick="pasteid(\'', $note->getXref(), '\');"><span class="list_item">', $note->getFullName(), '</span></a></li>'; } echo '</ul> <p>', I18N::translate('Shared notes found'), ' ', count($mynotelist), '</p>'; } else { echo '<p>', I18N::translate('No results found.'), '</p>'; } echo '</div>'; } // Output Sources if ($type == "source") { echo '<div id="find-output">'; if ($filter) { $mysourcelist = FunctionsDb::searchSources($filter_array, array($WT_TREE)); } else { $mysourcelist = FunctionsDb::getSourceList($WT_TREE); } if ($mysourcelist) { usort($mysourcelist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare'); echo '<ul>'; foreach ($mysourcelist as $source) { echo '<li><a href="', $source->getHtmlUrl(), '" onclick="pasteid(\'', $source->getXref(), '\', \'', Filter::escapeJs($source->getFullName()), '\');"><span class="list_item">', $source->getFullName(), '</span></a></li>'; } echo '</ul> <p>', I18N::translate('Total sources: %s', count($mysourcelist)), '</p>'; } else { echo '<p>', I18N::translate('No results found.'), '</p>'; } echo '</div>'; } // Output Special Characters
/** * 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 $WT_TREE, $ctype; $COMMON_NAMES_REMOVE = $WT_TREE->getPreference('COMMON_NAMES_REMOVE'); $COMMON_NAMES_THRESHOLD = $WT_TREE->getPreference('COMMON_NAMES_THRESHOLD'); $num = $this->getBlockSetting($block_id, 'num', '10'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $block = $this->getBlockSetting($block_id, 'block', '0'); foreach (array('num', 'infoStyle', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } // This next function is a bit out of date, and doesn't cope well with surname variants $top_surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), $COMMON_NAMES_THRESHOLD, $num); // Remove names found in the "Remove Names" list if ($COMMON_NAMES_REMOVE) { foreach (preg_split("/[,; ]+/", $COMMON_NAMES_REMOVE) as $delname) { unset($top_surnames[$delname]); unset($top_surnames[I18N::strtoupper($delname)]); } } $all_surnames = array(); $i = 0; foreach (array_keys($top_surnames) as $top_surname) { $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $top_surname, '', false, false)); if (++$i == $num) { break; } } if ($i < $num) { $num = $i; } $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 = ''; } if ($num == 1) { // I18N: i.e. most popular surname. $title .= I18N::translate('Top surname'); } else { // I18N: Title for a list of the most common surnames, %s is a number. Note that a separate translation exists when %s is 1 $title .= I18N::plural('Top %s surname', 'Top %s surnames', $num, I18N::number($num)); } switch ($infoStyle) { case 'tagcloud': uksort($all_surnames, '\\Fisharebest\\Webtrees\\I18N::strcasecmp'); $content = FunctionsPrintLists::surnameTagCloud($all_surnames, 'indilist.php', true, $WT_TREE); break; case 'list': uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort'); $content = FunctionsPrintLists::surnameList($all_surnames, '1', true, 'indilist.php', $WT_TREE); break; case 'array': uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort'); $content = FunctionsPrintLists::surnameList($all_surnames, '2', true, 'indilist.php', $WT_TREE); break; case 'table': default: uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort'); $content = FunctionsPrintLists::surnameTable($all_surnames, 'indilist.php', $WT_TREE); break; } if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
$tmp = $fact->getDate()->minimumDate(); if ($tmp->d >= 1 && $tmp->d <= $tmp->daysInMonth()) { // If the day is valid (for its own calendar), display it in the // anniversary day (for the display calendar). $found_facts[$jd - $cal_date->minJD + 1][] = $fact; } else { // Otherwise, display it in the "Day not set" box. $found_facts[0][] = $fact; } } } break; case 'year': $cal_date->m = 0; $cal_date->setJdFromYmd(); $found_facts = apply_filter(FunctionsDb::getCalendarEvents($ged_date->minimumJulianDay(), $ged_date->maximumJulianDay(), $filterev, $WT_TREE), $filterof, $filtersx); // Eliminate duplicates (e.g. BET JUL 1900 AND SEP 1900 will appear twice in 1900) $found_facts = array_unique($found_facts); break; } // Group the facts by family/individual $indis = array(); $fams = array(); $cal_facts = array(); switch ($view) { case 'year': case 'day': foreach ($found_facts as $fact) { $record = $fact->getParent(); $xref = $record->getXref(); if ($record instanceof Individual) {
foreach ($facts as $fact_id => $fact) { $gedcom .= "\n" . $fact->getGedcom(); } foreach ($facts1 as $fact_id => $fact) { if (in_array($fact_id, $keep1)) { $gedcom .= "\n" . $fact->getGedcom(); } } foreach ($facts2 as $fact_id => $fact) { if (in_array($fact_id, $keep2)) { $gedcom .= "\n" . $fact->getGedcom(); } } $rec1->updateRecord($gedcom, true); $rec2->deleteRecord(); FunctionsDb::updateFavorites($gid2, $gid1, $WT_TREE); FlashMessages::addMessage(I18N::translate('The records “%1$s” and “%2$s” have been merged.', '<a class="alert-link" href="' . $rec1->getHtmlUrl() . '">' . $rec1->getFullName() . '</a>', $record2_name), 'success'); header('Location: ' . WT_BASE_URL . Filter::post('url', 'admin_trees_duplicates\\.php', WT_SCRIPT_NAME)); return; } $controller->pageHeader(); ?> <ol class="breadcrumb small"> <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?> </a></li> <li><a href="admin_trees_manage.php"><?php echo I18N::translate('Manage family trees'); ?> </a></li>
/** * Gathers results for a soundex search * * NOTE * ==== * Does not search on the selected gedcoms, searches on all the gedcoms * Does not work on first names, instead of the code, value array is used in the search * Returns all the names even when Names with hit selected * Does not sort results by first name * Does not work on separate double word surnames * Does not work on duplicate code values of the searched text and does not give the correct code * Cohen should give DM codes 556000, 456000, 460000 and 560000, in 4.1 we search only on 560000?? * * The names' Soundex SQL table contains all the soundex values twice * The places table contains only one value */ private function soundexSearch() { if ((!empty($this->lastname) || !empty($this->firstname) || !empty($this->place)) && $this->search_trees) { $logstring = "Type: Soundex\n"; if (!empty($this->lastname)) { $logstring .= "Last name: " . $this->lastname . "\n"; } if (!empty($this->firstname)) { $logstring .= "First name: " . $this->firstname . "\n"; } if (!empty($this->place)) { $logstring .= "Place: " . $this->place . "\n"; } if (!empty($this->year)) { $logstring .= "Year: " . $this->year . "\n"; } Log::addSearchLog($logstring, $this->search_trees); if ($this->search_trees) { $this->myindilist = FunctionsDb::searchIndividualsPhonetic($this->soundex, $this->lastname, $this->firstname, $this->place, $this->search_trees); } else { $this->myindilist = array(); } } // Now we have the final list of individuals to be printed. // We may add the assos at this point. if ($this->showasso == 'on') { foreach ($this->myindilist as $indi) { foreach ($indi->linkedIndividuals('ASSO') as $asso) { $this->myindilist[] = $asso; } foreach ($indi->linkedIndividuals('_ASSO') as $asso) { $this->myindilist[] = $asso; } foreach ($indi->linkedFamilies('ASSO') as $asso) { $this->myfamlist[] = $asso; } foreach ($indi->linkedFamilies('_ASSO') as $asso) { $this->myfamlist[] = $asso; } } } //-- if only 1 item is returned, automatically forward to that item if (count($this->myindilist) == 1 && $this->action != "replace") { $indi = $this->myindilist[0]; header('Location: ' . WT_BASE_URL . $indi->getRawUrl()); exit; } usort($this->myindilist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare'); usort($this->myfamlist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare'); }
/** * 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 $WT_TREE, $ctype; $COMMON_NAMES_REMOVE = $WT_TREE->getPreference('COMMON_NAMES_REMOVE'); $COMMON_NAMES_THRESHOLD = $WT_TREE->getPreference('COMMON_NAMES_THRESHOLD'); $num = $this->getBlockSetting($block_id, 'num', '10'); // The “Minimum number of occurrences” input field from Control Panel’s Preferences page // has to be copied here otherwise user doesn't understand why the result is different // than expected (input of add and remove surnames may also be copied to make this module // indenpendent from module statistics; it is not copied yet). The data of original input // field is still used in the bottom of the statistics module $threshold = $this->getBlockSetting($block_id, 'threshold', '5'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $block = $this->getBlockSetting($block_id, 'block', '0'); foreach (array('num', 'infoStyle', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } // This next function is a bit out of date, and doesn't cope well with surname variants // First defining the upper limit of surname occurrences to get at least one row in // result list if user sets too high number in “Minimum number of occurrences” field. // Without this definition a short message “No data available in table” appears by // webtrees\packages\datatables-1.10.7\js\jquery.dataTables.min.js JavaScript file // without the possibility of translating (and only if presentation style is table; // all other styles result no message at all) $top_surnames_in_DB = FunctionsDb::getCommonSurnames($WT_TREE->getPreference('COMMON_NAMES_THRESHOLD'), $WT_TREE); $max_occurrences = 0; foreach ($top_surnames_in_DB as $array) { if ($array['match'] > $max_occurrences) { $max_occurrences = $array['match']; } } if ($threshold > $max_occurrences) { $threshold = $max_occurrences; } $top_surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), $threshold, $num); // Remove names found in the "Remove Names" list if ($COMMON_NAMES_REMOVE) { foreach (preg_split("/[,; ]+/", $COMMON_NAMES_REMOVE) as $delname) { unset($top_surnames[$delname]); unset($top_surnames[I18N::strtoupper($delname)]); } } $all_surnames = array(); $i = 0; foreach (array_keys($top_surnames) as $top_surname) { $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $top_surname, '', false, false)); if (++$i == $num) { break; } } if ($i < $num) { $num = $i; } $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 = ''; } if ($num == 1) { // I18N: i.e. most popular surname. $title .= I18N::translate('Top surname'); } else { // I18N: Title for a list of the most common surnames, %s is a number. Note that a separate translation exists when %s is 1 $title .= I18N::plural('Top %s surname', 'Top %s surnames', $num, I18N::number($num)); } switch ($infoStyle) { case 'tagcloud': uksort($all_surnames, '\\Fisharebest\\Webtrees\\I18N::strcasecmp'); $content = FunctionsPrintLists::surnameTagCloud($all_surnames, 'indilist.php', true, $WT_TREE); break; case 'list': uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort'); $content = FunctionsPrintLists::surnameList($all_surnames, '1', true, 'indilist.php', $WT_TREE); break; case 'array': uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort'); $content = FunctionsPrintLists::surnameList($all_surnames, '2', true, 'indilist.php', $WT_TREE); break; case 'table': default: uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort'); $content = FunctionsPrintLists::surnameTable($all_surnames, 'indilist.php', $WT_TREE); break; } if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }