. */ namespace Fisharebest\Webtrees; /** * 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) { $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(); if ($controller->record->isPendingDeletion()) { if (Auth::isModerator($controller->record->getTree())) { FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( 'This individual has been deleted. You should review the deletion and then %1$s or %2$s it.', '' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '', '' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '' ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); } elseif (Auth::isEditor($controller->record->getTree())) { FlashMessages::addMessage(I18N::translate('This individual has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); } } elseif ($controller->record->isPendingAddtion()) { if (Auth::isModerator($controller->record->getTree())) { FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( 'This individual has been edited. You should review the changes and then %1$s or %2$s them.', '' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '', '' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '' ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); } elseif (Auth::isEditor($controller->record->getTree())) { FlashMessages::addMessage(I18N::translate('This individual has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); } } $controller->pageHeader(); } elseif ($controller->record && $controller->record->canShowName()) { // Just show the name. $controller->pageHeader(); echo '

', $controller->record->getFullName(), '

'; echo '

', I18N::translate('The details of this individual are private.'), '

'; return; } else { FlashMessages::addMessage(I18N::translate('This individual does not exist or you do not have permission to view it.'), 'danger'); http_response_code(404); $controller->pageHeader(); return; } $controller->addInlineJavascript(' var WT_INDIVIDUAL = (function () { var instance, jQseparator = jQuery("#separator"), jQsidebar = jQuery ("#sidebar"); function init() { jQuery ("#header_accordion1").accordion ({ active: 0, heightStyle: "content", collapsible: true }); jQuery ("#tabs").tabs ({ // Remember the currently selected tab between pages. active: sessionStorage.getItem("indi-tab"), activate: function (event, ui) { sessionStorage.setItem("indi-tab", jQuery(this).tabs("option", "active")); }, // Only load each tab once beforeLoad: function (event, ui) { if (ui.tab.data ("loaded")) { event.preventDefault (); return; } jQuery (ui.panel.selector).append (\'
\'); ui.jqXHR.success (function () { ui.tab.data ("loaded", true); }); } }); if (jQsidebar.length) { // Have we got a sidebar ? // toggle sidebar visibility jQuery ("#main").on ("click", "#separator", function (e) { e.preventDefault (); jQsidebar.animate ({width: "toggle"}, { duration: 300, done: function () { sessionStorage.setItem("hide-sb", jQsidebar.is(":hidden")); jQseparator.toggleClass("separator-hidden separator-visible"); } }); }); // Set initial sidebar state if (sessionStorage.getItem("hide-sb") === "true") { jQsidebar.hide (); jQseparator.addClass("separator-hidden"); } else { jQsidebar.show (); jQseparator.addClass("separator-visible"); } } } return { getInstance: function () { if (!instance) { instance = init (); } return instance; } }; }) (); WT_INDIVIDUAL.getInstance (); '); // ===================================== header area echo '
', //overall page container '
', '
'; if ($controller->record->canShow()) { // Highlight image or silhouette echo '
', $controller->record->displayImage(), '
'; echo '
'; // contain accordions for names echo '

', $controller->record->getFullName(), ''; // First name accordion header $bdate = $controller->record->getBirthDate(); $ddate = $controller->record->getDeathDate(); echo ''; if ($bdate->isOK() && !$controller->record->isDead()) { // If living display age echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, new Date(strtoupper(date('d M Y'))))), $controller->record, 'span'); } elseif ($bdate->isOK() && $ddate->isOK()) { // If dead, show age at death echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, $ddate)), $controller->record, 'span'); } echo ''; // Display summary birth/death info. echo '', $controller->record->getLifeSpan(), ''; // Display gender icon foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'SEX') { $controller->printSexRecord($fact); } } echo '

'; // close first name accordion header // Display name details foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'NAME') { $controller->printNameRecord($fact); } } echo '
'; // close header_accordion1 } echo '
'; // close #indi_header // ===================================== main content tabs foreach ($controller->tabs as $tab) { echo $tab->getPreLoadContent(); } echo '
'; echo '
    '; foreach ($controller->tabs as $tab) { if ($tab->isGrayedOut()) { $greyed_out = 'rela'; } else { $greyed_out = ''; } if ($tab->hasTabContent()) { echo '
  • canLoadAjax()) { // AJAX tabs load only when selected echo ' href="' . $controller->record->getHtmlUrl(), '&action=ajax&module=', $tab->getName() . '"'; echo ' rel="nofollow"'; } else { // Non-AJAX tabs load immediately echo ' href="#', $tab->getName() . '"'; } echo ' title="', $tab->getDescription(), '">', $tab->getTitle(), '
  • '; } } echo '
'; foreach ($controller->tabs as $tab) { if ($tab->hasTabContent()) { if (!$tab->canLoadAjax()) { echo '
', $tab->getTabContent(), '
'; } } } echo '
', // close #tabs '
'; //close indi_left if ($sidebar_html) { echo '
' . $sidebar_html; } echo '
'; // close #main