record = WT_Individual::getInstance($xref);
if (!$this->record && $USE_RIN) {
$rin = find_rin_id($xref);
$this->record = WT_Individual::getInstance($rin);
}
parent::__construct();
$this->tabs = WT_Module::getActiveTabs();
// 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());
}
}
// Get significant information from this page, to allow other pages such as
// charts and reports to initialise with the same records
public function getSignificantIndividual() {
if ($this->record) {
return $this->record;
}
return parent::getSignificantIndividual();
}
public function getSignificantFamily() {
if ($this->record) {
foreach ($this->record->getChildFamilies() as $family) {
return $family;
}
foreach ($this->record->getSpouseFamilies() as $family) {
return $family;
}
}
return parent::getSignificantFamily();
}
// Handle AJAX requests - to generate the tab content
public function ajaxRequest() {
global $SEARCH_SPIDER;
// Search engines should not make AJAX requests
if ($SEARCH_SPIDER) {
header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
exit;
}
// Initialise tabs
$tab=WT_Filter::get('module');
// A request for a non-existant tab?
if (array_key_exists($tab, $this->tabs)) {
$mod=$this->tabs[$tab];
} else {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
exit;
}
header("Content-Type: text/html; charset=UTF-8"); // AJAX calls do not have the meta tag headers and need this set
header("X-Robots-Tag: noindex,follow"); // AJAX pages should not show up in search results, any links can be followed though
Zend_Session::writeClose();
echo $mod->getTabContent();
if (WT_DEBUG_SQL) {
echo WT_DB::getQueryLog();
}
}
/**
* print information for a name record
*
* Called from the individual information page
* @see individual.php
* @param Event $event the event object
*/
function print_name_record(WT_Fact $event) {
$factrec = $event->getGedcom();
// Create a dummy record, so we can extract the formatted NAME value from the event.
$dummy=new WT_Individual(
'xref',
"0 @xref@ INDI\n1 DEAT Y\n".$factrec,
null,
WT_GED_ID
);
$all_names=$dummy->getAllNames();
$primary_name=$all_names[0];
$this->name_count++;
if ($this->name_count >1) { echo '
',$dummy->getFullName(), '
'; } //Other names accordion element
echo '';
echo '
';
echo '
- ', WT_I18N::translate('Name'), '
';
$dummy->setPrimaryName(0);
echo '- ', $dummy->getFullName();
if ($this->name_count == 1) {
if (WT_USER_IS_ADMIN) {
$user_id=get_user_from_gedcom_xref(WT_GED_ID, $this->record->getXref());
if ($user_id) {
$user_name=get_user_name($user_id);
echo ' - '.$user_name.'';
}
}
}
if ($this->record->canEdit() && !$event->isOld()) {
echo "";
echo "";
}
echo '
';
echo '
';
echo '
';
$ct = preg_match_all('/\n2 (\w+) (.*)/', $factrec, $nmatch, PREG_SET_ORDER);
for ($i=0; $i<$ct; $i++) {
echo '
';
$fact = $nmatch[$i][1];
if ($fact!='SOUR' && $fact!='NOTE' && $fact!='SPFX') {
echo '
- ', WT_Gedcom_Tag::getLabel($fact, $this->record), '
';
echo '- '; // Before using dir="auto" on this field, note that Gecko treats this as an inline element but WebKit treats it as a block element
if (isset($nmatch[$i][2])) {
$name = WT_Filter::escapeHtml($nmatch[$i][2]);
$name = str_replace('/', '', $name);
$name=preg_replace('/(\S*)\*/', '\\1', $name);
switch ($fact) {
case 'TYPE':
echo WT_Gedcom_Code_Name::getValue($name, $this->record);
break;
case 'SURN':
// The SURN field is not necessarily the surname.
// Where it is not a substring of the real surname, show it after the real surname.
if (strpos($primary_name['surname'], str_replace(',', ' ', $name))!==false) {
echo $primary_name['surname'];
} else {
echo WT_I18N::translate('%1$s (%2$s)', $primary_name['surname'], $name);
}
break;
default:
echo $name;
break;
}
}
echo '
';
echo '
';
}
echo '
';
}
if (preg_match("/\n2 SOUR/", $factrec)) {
echo '
', print_fact_sources($factrec, 2), '
';
}
if (preg_match("/\n2 NOTE/", $factrec)) {
echo '
', print_fact_notes($factrec, 2), '
';
}
echo '
';
}
/**
* print information for a sex record
*
* Called from the individual information page
* @see individual.php
* @param Event $event the Event object
*/
function print_sex_record(WT_Fact $event) {
$sex = $event->getValue();
if (empty($sex)) $sex = 'U';
echo 'canEdit()) {
echo ' title="', WT_I18N::translate('Male'), ' - ', WT_I18N::translate('Edit'), '"';
echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">';
} else {
echo ' title="', WT_I18N::translate('Male'), '">';
}
break;
case 'F':
echo 'female_gender"';
if ($event->canEdit()) {
echo ' title="', WT_I18N::translate('Female'), ' - ', WT_I18N::translate('Edit'), '"';
echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">';
} else {
echo ' title="', WT_I18N::translate('Female'), '">';
}
break;
case 'U':
echo 'unknown_gender"';
if ($event->canEdit()) {
echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), ' - ', WT_I18N::translate('Edit'), '"';
echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">';
} else {
echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), '">';
}
break;
}
echo '';
}
/**
* get edit menu
*/
function getEditMenu() {
$SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD');
if (!$this->record || $this->record->isOld()) {
return null;
}
// edit menu
$menu = new WT_Menu(WT_I18N::translate('Edit'), '#', 'menu-indi');
$menu->addLabel($menu->label, 'down');
// What behaviour shall we give the main menu? If we leave it blank, the framework
// will copy the first submenu - which may be edit-raw or delete.
// As a temporary solution, make it edit the name
$menu->addOnclick("return false;");
if (WT_USER_CAN_EDIT) {
foreach ($this->record->getFacts() as $fact) {
if ($fact->getTag()=='NAME' && $fact->canEdit())
$menu->addOnclick("return edit_name('".$this->record->getXref() . "', '" . $fact->getFactId() . "');");
break;
}
$submenu = new WT_Menu(WT_I18N::translate('Add a new name'), '#', 'menu-indi-addname');
$submenu->addOnclick("return add_name('".$this->record->getXref()."');");
$menu->addSubmenu($submenu);
$has_sex_record = false;
$submenu = new WT_Menu(WT_I18N::translate('Edit gender'), '#', 'menu-indi-editsex');
foreach ($this->record->getFacts() as $fact) {
if ($fact->getTag()=='SEX' && $fact->canEdit()) {
$submenu->addOnclick("return edit_record('" . $this->record->getXref() . "', '" . $fact->getFactId() . "');");
$has_sex_record = true;
break;
}
}
if (!$has_sex_record) {
$submenu->addOnclick("return add_new_record('" . $this->record->getXref() . "', 'SEX');");
}
$menu->addSubmenu($submenu);
if (count($this->record->getSpouseFamilies())>1) {
$submenu = new WT_Menu(WT_I18N::translate('Re-order families'), '#', 'menu-indi-orderfam');
$submenu->addOnclick("return reorder_families('".$this->record->getXref()."');");
$menu->addSubmenu($submenu);
}
}
// delete
if (WT_USER_CAN_EDIT) {
$submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-indi-del');
$submenu->addOnclick("return delete_individual('".WT_I18N::translate('Are you sure you want to delete ā%sā?', WT_Filter::escapeJs(strip_tags($this->record->getFullName())))."', '".$this->record->getXref()."');");
$menu->addSubmenu($submenu);
}
// edit raw
if (WT_USER_IS_ADMIN || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) {
$submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-indi-editraw');
$submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
}
// add to favorites
if (array_key_exists('user_favorites', WT_Module::getActiveModules())) {
$submenu = new WT_Menu(
/* I18N: Menu option. Add [the current page] to the list of favorites */ WT_I18N::translate('Add to favorites'),
'#',
'menu-indi-addfav'
);
$submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})");
$menu->addSubmenu($submenu);
}
return $menu;
}
/**
* get the person box stylesheet class
* for the given person
* @param Person $person
* @return string returns 'person_box', 'person_boxF', or 'person_boxNN'
*/
function getPersonStyle($person) {
switch($person->getSex()) {
case 'M':
$class = 'person_box';
break;
case 'F':
$class = 'person_boxF';
break;
default:
$class = 'person_boxNN';
break;
}
if ($person->isOld()) {
$class .= ' old';
} elseif ($person->isNew()) {
$class .= ' new';
}
return $class;
}
// Get significant information from this page, to allow other pages such as
// charts and reports to initialise with the same records
public function getSignificantSurname() {
if ($this->record) {
list($surn, $givn)=explode(',', $this->record->getSortname());
return $surn;
} else {
return '';
}
}
// Get the contents of sidebar.
// TODO?? - only load one block immediately - load the others by AJAX.
public function getSideBarContent() {
global $controller;
$html='';
$active=0;
$n=0;
foreach (WT_Module::getActiveSidebars() as $mod) {
if ($mod->hasSidebarContent()) {
$html.='';
$html.=''.$mod->getSidebarContent().'
';
// The family navigator should be opened by default
if ($mod->getName()=='family_nav') {
$active=$n;
}
++$n;
}
}
$controller
->addInlineJavascript('
jQuery("#sidebarAccordion").accordion({
active:' . $active . ',
heightStyle: "content",
collapsible: true,
icons:{ "header": "ui-icon-triangle-1-s", "headerSelected": "ui-icon-triangle-1-n" }
});
');
return '';
}
}