diff options
| author | fisharebest <fisharebest@gmail.com> | 2013-06-29 22:33:03 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2013-06-29 22:33:03 +0000 |
| commit | 660cbf5fdbf1c5ece6b6c3aadc752fc09a10fd47 (patch) | |
| tree | ca94e6fcde611712d23b38a8dc1fa74a66753b53 /modules_v3 | |
| parent | e40bcb61e289f4fb6e5802407d3d44fa278da82b (diff) | |
| download | webtrees-660cbf5fdbf1c5ece6b6c3aadc752fc09a10fd47.tar.gz webtrees-660cbf5fdbf1c5ece6b6c3aadc752fc09a10fd47.tar.bz2 webtrees-660cbf5fdbf1c5ece6b6c3aadc752fc09a10fd47.zip | |
Diffstat (limited to 'modules_v3')
39 files changed, 1151 insertions, 1108 deletions
diff --git a/modules_v3/GEDFact_assistant/_CENS/addnoteaction_assisted.php b/modules_v3/GEDFact_assistant/_CENS/addnoteaction_assisted.php index 858d232fb4..89b0ecd310 100644 --- a/modules_v3/GEDFact_assistant/_CENS/addnoteaction_assisted.php +++ b/modules_v3/GEDFact_assistant/_CENS/addnoteaction_assisted.php @@ -90,13 +90,13 @@ if (!empty($NOTE)) { } if ($pid_array != '') { - $xref = append_gedrec($newgedrec, WT_GED_ID); + $record = WT_GedcomRecord::createRecord($newgedrec, WT_GED_ID); } else { - $xref=''; + $record=''; echo '<div class="indent">No individuals entered, close and try again </div>'; } -if ($xref) { +if ($record) { $controller->addInlineJavascript(' if (parent.opener.document.getElementById("pids_array_edit") == null || parent.opener.document.getElementById("pids_array_edit") == "undefined") { } else { @@ -106,6 +106,6 @@ if ($xref) { } else { parent.opener.document.addform.pids_array_add.value="' . $pid_array . '"; } - openerpasteid("' . $xref . '") + openerpasteid("' . $record->getXref() . '") '); } diff --git a/modules_v3/GEDFact_assistant/_CENS/census_1_ctrl.php b/modules_v3/GEDFact_assistant/_CENS/census_1_ctrl.php index 97969e5f7a..0fa8dfe06f 100644 --- a/modules_v3/GEDFact_assistant/_CENS/census_1_ctrl.php +++ b/modules_v3/GEDFact_assistant/_CENS/census_1_ctrl.php @@ -4,7 +4,7 @@ // Census information about an individual // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2010 PGV Development Team. All rights reserved. @@ -43,7 +43,7 @@ $ctry = 'UK'; // === Set $married to "Not married as we only want the Birth name here" === $married=-1; -$person=WT_Person::getInstance($pid); +$person=WT_Individual::getInstance($pid); // var_dump($person->getAllNames()); $nam = $person->getAllNames(); if ($person->getDeathYear() == 0) { $DeathYr = ""; } else { $DeathYr = $person->getDeathYear(); } diff --git a/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php b/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php index 60ded5a136..d7b372eb63 100644 --- a/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php +++ b/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php @@ -128,7 +128,7 @@ if (!defined('WT_WEBTREES')) { if (isset($people["husb"])) { //-- Parents Husbands Parents -------------------------------------- - $gparent=WT_Person::getInstance($people["husb"]->getXref()); + $gparent=WT_Individual::getInstance($people["husb"]->getXref()); $fams = $gparent->getChildFamilies(); foreach ($fams as $famid=>$family) { if (!is_null($family)) { @@ -177,7 +177,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($people["husb"]->canDisplayDetails())) { + if (($people["husb"]->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $people["husb"]->getXref() ; // pid = PID @@ -250,7 +250,7 @@ if (!defined('WT_WEBTREES')) { if (isset($people["wife"])) { //-- Parents Wifes Parent Family --------------------------- - $gparent=WT_Person::getInstance($people["wife"]->getXref()); + $gparent=WT_Individual::getInstance($people["wife"]->getXref()); $fams = $gparent->getChildFamilies(); foreach ($fams as $famid=>$family) { if (!is_null($family)) { @@ -309,7 +309,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($people["wife"]->canDisplayDetails())) { + if (($people["wife"]->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $people["wife"]->getXref() ; // pid = PID @@ -454,7 +454,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($child->canDisplayDetails())) { + if (($child->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $child->getXref(); // pid = PID @@ -562,7 +562,7 @@ if (!defined('WT_WEBTREES')) { if (isset($people["husb"])) { //-- Step Husbands Parent Family -------------------------------------- - $gparent=WT_Person::getInstance($people["husb"]->getXref()); + $gparent=WT_Individual::getInstance($people["husb"]->getXref()); $fams = $gparent->getChildFamilies(); foreach ($fams as $famid=>$family) { if (!is_null($family)) { @@ -617,7 +617,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($people["husb"]->canDisplayDetails())) { + if (($people["husb"]->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $people["husb"]->getXref(); // pid = PID @@ -695,7 +695,7 @@ if (!defined('WT_WEBTREES')) { if (isset($people["wife"])) { //-- Step Wifes Parent Family -------------------------------------- - $gparent=WT_Person::getInstance($people["wife"]->getXref()); + $gparent=WT_Individual::getInstance($people["wife"]->getXref()); $fams = $gparent->getChildFamilies(); foreach ($fams as $famid=>$family) { if (!is_null($family)) { @@ -761,7 +761,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($people["wife"]->canDisplayDetails())) { + if (($people["wife"]->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $people["wife"]->getXref() ; // pid = PID @@ -895,7 +895,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($child->canDisplayDetails())) { + if (($child->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $child->getXref() ; // pid = PID @@ -992,7 +992,7 @@ if (!defined('WT_WEBTREES')) { if (isset($people["husb"])) { //-- Spouse Husbands Parents -------------------------------------- - $gparent=WT_Person::getInstance($people["husb"]->getXref()); + $gparent=WT_Individual::getInstance($people["husb"]->getXref()); $fams = $gparent->getChildFamilies(); foreach ($fams as $family) { if (!is_null($family)) { @@ -1048,7 +1048,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($people["husb"]->canDisplayDetails())) { + if (($people["husb"]->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $people["husb"]->getXref() ; // pid = PID @@ -1125,7 +1125,7 @@ if (!defined('WT_WEBTREES')) { if (isset($people["wife"])) { //-- Spouse Wifes Parents -------------------------------------- - $gparent=WT_Person::getInstance($people["wife"]->getXref()); + $gparent=WT_Individual::getInstance($people["wife"]->getXref()); $fams = $gparent->getChildFamilies(); foreach ($fams as $family) { if (!is_null($family)) { @@ -1193,7 +1193,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($people["wife"]->canDisplayDetails())) { + if (($people["wife"]->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $people["wife"]->getXref() ; // pid = PID @@ -1331,7 +1331,7 @@ if (!defined('WT_WEBTREES')) { <td align="left" class="facts_value nowrap"> <font size=1> <?php - if (($child->canDisplayDetails())) { + if (($child->canShow())) { ?> <a href='#' onclick='insertRowToTable("<?php echo $child->getXref() ; // pid = PID @@ -1442,7 +1442,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if (!isset($OLD_PGENS)) $OLD_PGENS = $DEFAULT_PEDIGREE_GENERATIONS; if (!isset($talloffset)) $talloffset = $PEDIGREE_LAYOUT; - $person=WT_Person::getInstance($pid); + $person=WT_Individual::getInstance($pid); if ($pid==false || empty($person)) { $spouselinks = false; $parentlinks = false; @@ -1454,9 +1454,9 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", $spouselinks = ""; $parentlinks = ""; $step_parentlinks = ""; - $disp=$person->canDisplayDetails(); + $disp=$person->canShow(); - if ($person->canDisplayName() && !$SEARCH_SPIDER) { + if ($person->canShowName() && !$SEARCH_SPIDER) { //-- draw a box for the family popup if ($TEXT_DIRECTION=="rtl") { @@ -1512,7 +1512,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($husb || $num>0) { if ($husb) { //-- Parent Husbands Parents ---------------------- - $gparent=WT_Person::getInstance($husb->getXref()); + $gparent=WT_Individual::getInstance($husb->getXref()); $parfams = $gparent->getChildFamilies(); foreach ($parfams as $pfamily) { if (!is_null($pfamily)) { @@ -1525,7 +1525,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", //-- Parent Husbands Details ---------------------- $person_parent="Yes"; $tmp=$husb->getXref(); - if ($husb->canDisplayName()) { + if ($husb->canShowName()) { $nam = $husb->getAllNames(); $fulln = rtrim($nam[0]['givn'],'*')." ".$nam[0]['surname']; $fulln = str_replace("@N.N.", "(".WT_I18N::translate('unknown').")", $fulln); @@ -1594,7 +1594,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($wife || $num>0) { if ($wife) { //-- Parent Wifes Parents ---------------------- - $gparent=WT_Person::getInstance($wife->getXref()); + $gparent=WT_Individual::getInstance($wife->getXref()); $parfams = $gparent->getChildFamilies(); foreach ($parfams as $pfamily) { if (!is_null($pfamily)) { @@ -1607,7 +1607,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", //-- Parent Wifes Details ---------------------- $person_parent="Yes"; $tmp=$wife->getXref(); - if ($wife->canDisplayName()) { + if ($wife->canShowName()) { $married = WT_Date::Compare($censdate, $marrdate); $nam = $wife->getAllNames(); $fulln = rtrim($nam[0]['givn'],'*')." ".$nam[0]['surname']; @@ -1721,7 +1721,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if (($husb || $num>0) && $husb->getLabel() != ".") { if ($husb) { //-- Step Husbands Parents ----------------------------- - $gparent=WT_Person::getInstance($husb->getXref()); + $gparent=WT_Individual::getInstance($husb->getXref()); $parfams = $gparent->getChildFamilies(); foreach ($parfams as $pfamily) { if (!is_null($pfamily)) { @@ -1734,7 +1734,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", //-- Step Husband Details ------------------------------ $person_step="Yes"; $tmp=$husb->getXref(); - if ($husb->canDisplayName()) { + if ($husb->canShowName()) { $nam = $husb->getAllNames(); $fulln = rtrim($nam[0]['givn'],'*')." ".$nam[0]['surname']; $fulln = str_replace("@N.N.", "(".WT_I18N::translate('unknown').")", $fulln); @@ -1806,7 +1806,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($wife || $num>0) { if ($wife) { //-- Step Wifes Parents --------------------------- - $gparent=WT_Person::getInstance($wife->getXref()); + $gparent=WT_Individual::getInstance($wife->getXref()); $parfams = $gparent->getChildFamilies(); foreach ($parfams as $pfamily) { if (!is_null($pfamily)) { @@ -1819,7 +1819,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", //-- Step Wife Details ------------------------------ $person_step="Yes"; $tmp=$wife->getXref(); - if ($wife->canDisplayName()) { + if ($wife->canShowName()) { $married = WT_Date::Compare($censdate, $marrdate); $nam = $wife->getAllNames(); $fulln = rtrim($nam[0]['givn'],'*')." ".$nam[0]['surname']; @@ -1932,7 +1932,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($spouse) { //-- Spouse Parents ----------------------------- - $gparent=WT_Person::getInstance($spouse->getXref()); + $gparent=WT_Individual::getInstance($spouse->getXref()); $spousefams = $gparent->getChildFamilies(); foreach ($spousefams as $pfamily) { if (!is_null($pfamily)) { @@ -1945,7 +1945,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", //-- Spouse Details ----------------------------- $tmp=$spouse->getXref(); - if ($spouse->canDisplayName()) { + if ($spouse->canShowName()) { $married = WT_Date::Compare($censdate, $marrdate); $nam = $spouse->getAllNames(); $fulln = rtrim($nam[0]['givn'],'*')." ".$nam[0]['surname']; @@ -2035,7 +2035,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", $persons="Yes"; //-- Childs Parents --------------------- - $gparent=WT_Person::getInstance($child->getXref()); + $gparent=WT_Individual::getInstance($child->getXref()); $fams = $gparent->getChildFamilies(); $chfams = $gparent->getSpouseFamilies(); foreach ($fams as $family) { @@ -2077,7 +2077,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", } // Childs Details ------------------------- $spouselinks .= "<li>"; - if ($child->canDisplayName()) { + if ($child->canShowName()) { $nam = $child->getAllNames(); $fulln = rtrim($nam[0]['givn'],'*')." ".$nam[0]['surname']; $fulln = str_replace("@N.N.", "(".WT_I18N::translate('unknown').")", $fulln); diff --git a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php index 3ec3cb93ba..a8a4d82e88 100644 --- a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php +++ b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php @@ -36,7 +36,7 @@ $update_CHAN = safe_REQUEST($_REQUEST, 'preserve_last_changed', WT_REGEX_UNSAFE) $controller->addExternalJavascript(WT_STATIC_URL.'js/autocomplete.js'); $paramok = true; -if (!empty($linktoid)) $paramok = WT_GedcomRecord::getInstance($linktoid)->canDisplayDetails(); +if (!empty($linktoid)) $paramok = WT_GedcomRecord::getInstance($linktoid)->canShow(); if ($action == 'choose' && $paramok) { @@ -139,7 +139,7 @@ if ($action == 'choose' && $paramok) { echo "<td align='center'><input alt='", WT_I18N::translate('Keep Link in list'), "', title='", WT_I18N::translate('Keep Link in list'), "' type='radio' id='", $record->getXref(), "_off' name='", $record->getXref(), "' checked></td>"; echo "<td align='center'><input alt='", WT_I18N::translate('Remove Link from list'), "', title='", WT_I18N::translate('Remove Link from list'), "' type='radio' id='", $record->getXref(), "_on' name='", $record->getXref(), "'></td>"; - if ($record instanceof WT_Person) { + if ($record instanceof WT_Individual) { ?> <td align="center"><a href="#" class="icon-button_family" title="<?php echo WT_I18N::translate('Family navigator'); ?>" name="family_'<?php echo $record->getXref(); ?>'" onclick="openFamNav('<?php echo $record->getXref(); ?>'); return false;"></a></td> <?php @@ -173,7 +173,7 @@ if ($action == 'choose' && $paramok) { if ($linktoid=="") { // ---- } else { - $record=WT_Person::getInstance($linktoid); + $record=WT_Individual::getInstance($linktoid); echo '<b>', $record->getFullName(), '</b>'; } echo '<table><tr><td>'; diff --git a/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php b/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php index 1264df8029..ab5e17cba2 100644 --- a/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php +++ b/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php @@ -35,7 +35,7 @@ global $summary, $censyear, $censdate; $pid = safe_get('pid'); $year = "1901"; -$censevent = new WT_Event("1 CENS\n2 DATE 03 MAR".$year."", null, 0); +$censevent = new WT_Fact("1 CENS\n2 DATE 03 MAR".$year."", null, 0); $censdate = $censevent->getDate(); $censyear = $censdate->date1->y; $ctry = "UK"; @@ -49,7 +49,7 @@ if ($pid=="") { echo "<br><br>"; } else { - $person=WT_Person::getInstance($pid); + $person=WT_Individual::getInstance($pid); if ($person->getDeathYear() == 0) { $DeathYr = ""; } else { $DeathYr = $person->getDeathYear(); } if ($person->getBirthYear() == 0) { $BirthYr = ""; } else { $BirthYr = $person->getBirthYear(); } $currpid=$pid; @@ -169,7 +169,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($people["husb"]->canDisplayDetails())) { + if (($people["husb"]->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $people["husb"]->getXref() ; // pid = PID @@ -237,7 +237,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($people["wife"]->canDisplayDetails())) { + if (($people["wife"]->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $people["wife"]->getXref() ; // pid = PID @@ -323,7 +323,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($child->canDisplayDetails())) { + if (($child->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $child->getXref() ; // pid = PID @@ -419,7 +419,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($people["husb"]->canDisplayDetails())) { + if (($people["husb"]->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $people["husb"]->getXref() ; // pid = PID @@ -500,7 +500,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($people["wife"]->canDisplayDetails())) { + if (($people["wife"]->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $people["wife"]->getXref() ; // pid = PID @@ -576,7 +576,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($child->canDisplayDetails())) { + if (($child->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $child->getXref() ; // pid = PID @@ -661,7 +661,7 @@ if ($pid=="") { <td align="left" class="facts_value" > <font size=1> <?php - if (($people["husb"]->canDisplayDetails())) { + if (($people["husb"]->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $people["husb"]->getXref() ; // pid = PID @@ -744,7 +744,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($people["wife"]->canDisplayDetails())) { + if (($people["wife"]->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $people["wife"]->getXref() ; // pid = PID @@ -822,7 +822,7 @@ if ($pid=="") { <td align="left" class="facts_value"> <font size=1> <?php - if (($child->canDisplayDetails())) { + if (($child->canShow())) { ?> <a href='#' onclick='opener.insertRowToTable("<?php echo $child->getXref() ; // pid = PID @@ -907,7 +907,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if (!isset($OLD_PGENS)) $OLD_PGENS = $DEFAULT_PEDIGREE_GENERATIONS; if (!isset($talloffset)) $talloffset = $PEDIGREE_LAYOUT; - $person=WT_Person::getInstance($pid); + $person=WT_Individual::getInstance($pid); if ($pid==false || empty($person)) { $spouselinks = false; $parentlinks = false; @@ -919,9 +919,9 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", $spouselinks = ""; $parentlinks = ""; $step_parentlinks = ""; - $disp=$person->canDisplayDetails(); + $disp=$person->canShow(); - if ($person->canDisplayName() && !$SEARCH_SPIDER) { + if ($person->canShowName() && !$SEARCH_SPIDER) { //-- draw a box for the family popup if ($TEXT_DIRECTION=="rtl") { $spouselinks .= "<table id=\"flyoutFamRTL\" class=\"person_box$isF\"><tr><td class=\"name2 font9 rtl\">"; @@ -958,7 +958,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($husb) { $person_parent="Yes"; $tmp=$husb->getXref(); - if ($husb->canDisplayName()) { + if ($husb->canShowName()) { $fulln =strip_tags($husb->getFullName()); $parentlinks .= "<a href=\"#\" onclick=\"opener.insertRowToTable("; $parentlinks .= "'".$husb->getXref()."', "; // pid = PID @@ -995,7 +995,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($wife) { $person_parent="Yes"; $tmp=$wife->getXref(); - if ($wife->canDisplayName()) { + if ($wife->canShowName()) { $married = WT_Date::Compare($censdate, $marrdate); $fulln =strip_tags($wife->getFullName()); $parentlinks .= "<a href=\"#\" onclick=\"opener.insertRowToTable("; @@ -1048,7 +1048,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($husb) { $person_step="Yes"; $tmp=$husb->getXref(); - if ($husb->canDisplayName()) { + if ($husb->canShowName()) { $fulln =strip_tags($husb->getFullName()); $parentlinks .= "<a href=\"individual.php?pid={$tmp}&tab={$tabno}&gedcom=".WT_GEDURL."\">"; $parentlinks .= $husb->getFullName(); @@ -1068,7 +1068,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($wife) { $person_step="Yes"; $tmp=$wife->getXref(); - if ($wife->canDisplayName()) { + if ($wife->canShowName()) { $married = WT_Date::Compare($censdate, $marrdate); $fulln =addslashes($wife->getFullName()); $parentlinks .= "<a href=\"individual.php?pid={$tmp}&tab={$tabno}&gedcom=".WT_GEDURL."\">"; @@ -1096,7 +1096,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", if ($spouse || $num>0) { if ($spouse) { $tmp=$spouse->getXref(); - if ($spouse->canDisplayName()) { + if ($spouse->canShowName()) { $married = WT_Date::Compare($censdate, $marrdate); $fulln =strip_tags($spouse->getFullName()); $spouselinks .= "<a href=\"#\" onclick=\"opener.insertRowToTable("; @@ -1145,7 +1145,7 @@ function print_pedigree_person_nav2($pid, $style=1, $count=0, $personcount="1", foreach ($children as $c=>$child) { if ($child) { $persons="Yes"; - if ($child->canDisplayName()) { + if ($child->canShowName()) { $fulln =strip_tags($child->getFullName()); $spouselinks .= "<li>"; $spouselinks .= "<a href=\"#\" onclick=\"opener.insertRowToTable("; diff --git a/modules_v3/batch_update/admin_batch_update.php b/modules_v3/batch_update/admin_batch_update.php index 8ad5b6d145..7032345d6d 100644 --- a/modules_v3/batch_update/admin_batch_update.php +++ b/modules_v3/batch_update/admin_batch_update.php @@ -135,9 +135,9 @@ class batch_update { $newrecord=$this->PLUGIN->updateRecord($this->xref, $record); if ($newrecord!=$record) { if ($newrecord) { - replace_gedrec($this->xref, WT_GED_ID, $newrecord, $this->PLUGIN->chan); + WT_GedcomRecord::getInstance($this->xref)->updateRecord($newrecord, $this->PLUGIN->chan); } else { - delete_gedrec($this->xref, WT_GED_ID); + WT_GedcomRecord::getInstance($this->xref)->deleteRecord(); } } } @@ -150,9 +150,9 @@ class batch_update { $newrecord=$this->PLUGIN->updateRecord($xref, $record); if ($newrecord!=$record) { if ($newrecord) { - replace_gedrec($xref, WT_GED_ID, $newrecord, $this->PLUGIN->chan); + WT_GedcomRecord::getInstance($this->xref)->updateRecord($newrecord, $this->PLUGIN->chan); } else { - delete_gedrec($xref, WT_GED_ID); + WT_GedcomRecord::getInstance($this->xref)->deleteRecord(); } } } @@ -162,7 +162,7 @@ class batch_update { case 'delete': $record=self::getLatestRecord($this->xref, $this->all_xrefs[$this->xref]); if ($this->PLUGIN->doesRecordNeedUpdate($this->xref, $record)) { - delete_gedrec($this->xref, WT_GED_ID); + WT_GedcomRecord::getInstance($this->xref)->deleteRecord(); } $this->xref=$this->findNextXref($this->xref); break; @@ -170,7 +170,7 @@ class batch_update { foreach ($this->all_xrefs as $xref=>$type) { $record=self::getLatestRecord($xref, $type); if ($this->PLUGIN->doesRecordNeedUpdate($xref, $record)) { - delete_gedrec($xref, WT_GED_ID); + WT_GedcomRecord::getInstance($this->xref)->deleteRecord(); } } $xref->xref=''; diff --git a/modules_v3/batch_update/plugins/death_y.php b/modules_v3/batch_update/plugins/death_y.php index d7afa25895..011c68497a 100644 --- a/modules_v3/batch_update/plugins/death_y.php +++ b/modules_v3/batch_update/plugins/death_y.php @@ -2,7 +2,7 @@ // Batch Update plugin for phpGedView - add missing 1 BIRT/DEAT Y // // webtrees: Web based Family History software -// Copyright (C) 2011 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2008 Greg Roach. All rights reserved. @@ -38,7 +38,7 @@ class death_y_bu_plugin extends base_plugin { } static function doesRecordNeedUpdate($xref, $gedrec) { - return !preg_match('/\n1 ('.WT_EVENTS_DEAT.')/', $gedrec) && WT_Person::getInstance($xref)->isDead(); + return !preg_match('/\n1 ('.WT_EVENTS_DEAT.')/', $gedrec) && WT_Individual::getInstance($xref)->isDead(); } static function updateRecord($xref, $gedrec) { diff --git a/modules_v3/charts/module.php b/modules_v3/charts/module.php index 989be576ef..0c26023730 100644 --- a/modules_v3/charts/module.php +++ b/modules_v3/charts/module.php @@ -72,11 +72,11 @@ class charts_WT_Module extends WT_Module implements WT_Module_Block { } $PEDIGREE_FULL_DETAILS = $show_full; - $person = WT_Person::getInstance($pid); + $person = WT_Individual::getInstance($pid); if (!$person) { $pid = $PEDIGREE_ROOT_ID; set_block_setting($block_id, 'pid', $pid); - $person = WT_Person::getInstance($pid); + $person = WT_Individual::getInstance($pid); } if ($type!='treenav' && $person) { @@ -223,7 +223,7 @@ class charts_WT_Module extends WT_Module implements WT_Module_Block { <input type="text" name="pid" id="pid" value="<?php echo $pid; ?>" size="5"> <?php echo print_findindi_link('pid'); - $root=WT_Person::getInstance($pid); + $root=WT_Individual::getInstance($pid); if ($root) { echo ' <span class="list_item">', $root->getFullName(), $root->format_first_major_fact(WT_EVENTS_BIRT, 1), '</span>'; } diff --git a/modules_v3/clippings/clippings_ctrl.php b/modules_v3/clippings/clippings_ctrl.php index 21f5d286c8..3fbe7d4517 100644 --- a/modules_v3/clippings/clippings_ctrl.php +++ b/modules_v3/clippings/clippings_ctrl.php @@ -130,19 +130,19 @@ class WT_Controller_Clippings { } } elseif ($this->type == 'indi') { if ($others == 'parents') { - foreach (WT_Person::getInstance($this->id)->getChildFamilies() as $family) { + foreach (WT_Individual::getInstance($this->id)->getChildFamilies() as $family) { $this->add_family_members($family); } } elseif ($others == 'ancestors') { - $this->add_ancestors_to_cart(WT_Person::getInstance($this->id), $this->level1); + $this->add_ancestors_to_cart(WT_Individual::getInstance($this->id), $this->level1); } elseif ($others == 'ancestorsfamilies') { - $this->add_ancestors_to_cart_families(WT_Person::getInstance($this->id), $this->level2); + $this->add_ancestors_to_cart_families(WT_Individual::getInstance($this->id), $this->level2); } elseif ($others == 'members') { - foreach (WT_Person::getInstance($this->id)->getSpouseFamilies() as $family) { + foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) { $this->add_family_members($family); } } elseif ($others == 'descendants') { - foreach (WT_Person::getInstance($this->id)->getSpouseFamilies() as $family) { + foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) { $this->add_clipping($family); $this->add_family_descendancy($family, $this->level3); } @@ -195,7 +195,7 @@ class WT_Controller_Clippings { foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { $object=WT_GedcomRecord::getInstance($xref); if ($object) { // The object may have been deleted since we added it to the cart.... - list($record)=$object->privatizeGedcom($access_level); + $record = $object->privatizeGedcom($access_level); // Remove links to objects that aren't in the cart preg_match_all('/\n1 '.WT_REGEX_TAG.' @('.WT_REGEX_XREF.')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { @@ -319,10 +319,10 @@ class WT_Controller_Clippings { function add_clipping($record) { global $WT_SESSION; - if ($record->canDisplayName()) { + if ($record->canShowName()) { $WT_SESSION->cart[WT_GED_ID][$record->getXref()]=true; // Add directly linked records - preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @('.WT_REGEX_XREF.')@/', $record->getGedcomRecord(), $matches); + preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @('.WT_REGEX_XREF.')@/', $record->getGedcom(), $matches); foreach ($matches[1] as $match) { $WT_SESSION->cart[WT_GED_ID][$match]=true; } diff --git a/modules_v3/clippings/module.php b/modules_v3/clippings/module.php index 32bdd50c8c..1a7be1444b 100644 --- a/modules_v3/clippings/module.php +++ b/modules_v3/clippings/module.php @@ -333,7 +333,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module $submenu = new WT_Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged='.WT_GEDURL, 'menu-clippingscart'); $menu->addSubmenu($submenu); } - if (!empty($controller->record) && $controller->record->canDisplayDetails()) { + if (!empty($controller->record) && $controller->record->canShow()) { $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), 'module.php?mod=clippings&mod_action=index&action=add&id='.$controller->record->getXref(), 'menu-clippingsadd'); $menu->addSubmenu($submenu); } @@ -393,7 +393,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module if ($ret) return $this->askAddOptions($record); } } elseif (!empty($add1)) { - $record = WT_Person::getInstance($add1); + $record = WT_Individual::getInstance($add1); if ($record) { $clip_ctrl->id=$record->getXref(); $clip_ctrl->type=strtolower($record::RECORD_TYPE); @@ -456,7 +456,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module $out .=$record->getSexImage(); } $out .= ' '.$record->getFullName().' '; - if ($record::RECORD_TYPE == 'INDI' && $record->canDisplayDetails()) { + if ($record::RECORD_TYPE == 'INDI' && $record->canShow()) { $out .= ' ('.$record->getLifeSpan().')'; } $out .= '</a>'; @@ -477,7 +477,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module WT_I18N::translate('Download Now'). '</a>'; } - $record=WT_Person::getInstance($pid); + $record=WT_Individual::getInstance($pid); if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[WT_GED_ID])) { $out .= '<br><a href="module.php?mod='.$this->getName().'&mod_action=ajax&sb_action=clippings&add='.$pid.'&pid='.$pid.'" class="add_cart"><i class="icon-clippings"></i> '.WT_I18N::translate('Add %s to cart', $record->getFullName()).'</a>'; } diff --git a/modules_v3/descendancy/module.php b/modules_v3/descendancy/module.php index e9e7a6abdf..7eeef47220 100644 --- a/modules_v3/descendancy/module.php +++ b/modules_v3/descendancy/module.php @@ -132,7 +132,7 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { '</div>'; } - public function getPersonLi(WT_Person $person, $generations=0) { + public function getPersonLi(WT_Individual $person, $generations=0) { $out = '<li id="sb_desc_'.$person->getXref().'" class="sb_desc_indi_li"><a href="module.php?mod='.$this->getName().'&mod_action=ajax&sb_action=descendancy&pid='.$person->getXref().'" title="'.$person->getXref().'" class="sb_desc_indi">'; if ($generations>0) { $out .= '<i class="icon-minus plusminus"></i>'; @@ -140,7 +140,7 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { $out .= '<i class="icon-plus plusminus"></i>'; } $out .= $person->getSexImage().' '.$person->getFullName().' '; - if ($person->canDisplayDetails()) { + if ($person->canShow()) { $out .= ' ('.$person->getLifeSpan().')'; } $out .= '</a> <a href="'.$person->getHtmlUrl().'" class="icon-button_indi"></a>'; @@ -158,7 +158,7 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { return $out; } - public function getFamilyLi(WT_Family $family, WT_Person $person, $generations=0) { + public function getFamilyLi(WT_Family $family, WT_Individual $person, $generations=0) { $out = '<li id="sb_desc_'.$family->getXref().'" class="sb_desc_indi_li"><a href="module.php?mod='.$this->getName().'&mod_action=ajax&sb_action=descendancy&famid='.$family->getXref().'" title="'.$family->getXref().'" class="sb_desc_indi">'; $out .= '<i class="icon-minus plusminus"></i>'; $out .= $person->getSexImage().$person->getFullName(); @@ -181,19 +181,19 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { public function search($query) { if (strlen($query)<2) return ''; $rows=WT_DB::prepare( - "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". + "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom". " FROM `##individuals`, `##name`". " WHERE (i_id LIKE ? OR n_sort LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". " ORDER BY n_sort" ) - ->execute(array('INDI', "%{$query}%", "%{$query}%", WT_GED_ID)) - ->fetchAll(PDO::FETCH_ASSOC); + ->execute(array("%{$query}%", "%{$query}%", WT_GED_ID)) + ->fetchAll(); $out = ''; foreach ($rows as $row) { - $person=WT_Person::getInstance($row); - if ($person->canDisplayName()) { + $person=WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + if ($person->canShowName()) { $out .= $this->getPersonLi($person); } } @@ -206,8 +206,8 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { public function loadSpouses($pid, $generations=0) { $out = ''; - $person = WT_Person::getInstance($pid); - if ($person && $person->canDisplayDetails()) { + $person = WT_Individual::getInstance($pid); + if ($person && $person->canShow()) { foreach($person->getSpouseFamilies() as $family) { $spouse = $family->getSpouse($person); if ($spouse) { @@ -229,7 +229,7 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { public function loadChildren($famid, $generations=0) { $out = ''; $family = WT_Family::getInstance($famid); - if ($family->canDisplayDetails()) { + if ($family->canShow()) { $children = $family->getChildren(); if (count($children)>0) { foreach($children as $child) { diff --git a/modules_v3/extra_info/module.php b/modules_v3/extra_info/module.php index 1d65ef1eb4..581c111b3c 100644 --- a/modules_v3/extra_info/module.php +++ b/modules_v3/extra_info/module.php @@ -2,7 +2,7 @@ // A sidebar to show extra/non-genealogical information about an individual
//
// webtrees: Web based Family History software
-// Copyright (C) 2012 webtrees development team.
+// Copyright (C) 2013 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
@@ -49,16 +49,21 @@ class extra_info_WT_Module extends WT_Module implements WT_Module_Sidebar { // Implement WT_Module_Sidebar
public function getSidebarContent() {
global $SHOW_COUNTER, $controller;
+
+ $indifacts = array();
+ // The individual's own facts
+ foreach ($controller->record->getFacts() as $fact) {
+ if (self::showFact($fact) && $fact->canShow()) {
+ $indifacts[] = $fact;
+ }
+ }
ob_start();
- $indifacts = $controller->getIndiFacts();
- if (count($indifacts)==0) {
+ if (!$indifacts) {
echo WT_I18N::translate('There are no Facts for this individual.');
} else {
foreach ($indifacts as $fact) {
- if (in_array($fact->getTag(), WT_Gedcom_Tag::getReferenceFacts())) {
- print_fact($fact, $controller->record);
- }
+ print_fact($fact, $controller->record);
}
}
echo '<div id="hitcounter">';
@@ -75,4 +80,21 @@ class extra_info_WT_Module extends WT_Module implements WT_Module_Sidebar { public function getSidebarAjaxContent() {
return '';
}
+
+ // Does this module display a particular fact
+ public static function showFact(WT_Fact $fact) {
+ switch ($fact->getTag()) {
+ case 'AFN':
+ case 'CHAN':
+ case 'IDNO':
+ case 'REFN':
+ case 'RFN':
+ case 'RIN':
+ case 'SSN':
+ case '_UID':
+ return true;
+ default:
+ return false;
+ }
+ }
}
diff --git a/modules_v3/families/module.php b/modules_v3/families/module.php index 3a15b93269..4794c9aa19 100644 --- a/modules_v3/families/module.php +++ b/modules_v3/families/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -187,9 +187,9 @@ class families_WT_Module extends WT_Module implements WT_Module_Sidebar { $families=WT_Query_Name::families($surname, $alpha, '', true, WT_GED_ID); $out = '<ul>'; foreach ($families as $family) { - if ($family->canDisplayName()) { + if ($family->canShowName()) { $out .= '<li><a href="'.$family->getHtmlUrl().'">'.$family->getFullName().' '; - if ($family->canDisplayDetails()) { + if ($family->canShow()) { $marriage_year=$family->getMarriageYear(); if ($marriage_year) { $out.=' ('.$marriage_year.')'; @@ -209,17 +209,17 @@ class families_WT_Module extends WT_Module implements WT_Module_Sidebar { //-- search for INDI names $rows=WT_DB::prepare( - "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". + "SELECT i_id AS xref". " FROM `##individuals`, `##name`". " WHERE (i_id LIKE ? OR n_sort LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". " ORDER BY n_sort" ) - ->execute(array('INDI', "%{$query}%", "%{$query}%", WT_GED_ID)) - ->fetchAll(PDO::FETCH_ASSOC); + ->execute(array("%{$query}%", "%{$query}%", WT_GED_ID)) + ->fetchAll(); $ids = array(); foreach ($rows as $row) { - $ids[] = $row['xref']; + $ids[] = $row->xref; } $vars=array('FAM'); @@ -235,16 +235,16 @@ class families_WT_Module extends WT_Module implements WT_Module_Sidebar { } $vars[]=WT_GED_ID; - $rows=WT_DB::prepare("SELECT ? AS type, f_id AS xref, f_file AS ged_id, f_gedcom AS gedrec FROM `##families` WHERE {$where} AND f_file=?") + $rows=WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE {$where} AND f_file=?") ->execute($vars) - ->fetchAll(PDO::FETCH_ASSOC); + ->fetchAll(); $out = '<ul>'; foreach ($rows as $row) { - $family=WT_Family::getInstance($row); - if ($family->canDisplayName()) { + $family=WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + if ($family->canShowName()) { $out .= '<li><a href="'.$family->getHtmlUrl().'">'.$family->getFullName().' '; - if ($family->canDisplayDetails()) { + if ($family->canShow()) { $marriage_year=$family->getMarriageYear(); if ($marriage_year) { $out.=' ('.$marriage_year.')'; diff --git a/modules_v3/family_nav/module.php b/modules_v3/family_nav/module.php index 2e383ea714..ed8256cae8 100644 --- a/modules_v3/family_nav/module.php +++ b/modules_v3/family_nav/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -293,7 +293,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { $parentlinks = ''; $step_parentlinks = ''; - if ($person->canDisplayName() && !$SEARCH_SPIDER) { + if ($person->canShowName() && !$SEARCH_SPIDER) { //-- draw a box for the family flyout $parentlinks .= '<div class="flyout4"><b>' . WT_I18N::translate('Parents') . '</b></div>'; $step_parentlinks .= '<div class="flyout4"><b>' . WT_I18N::translate('Parents') . '</b></div>'; diff --git a/modules_v3/faq/module.php b/modules_v3/faq/module.php index 300808366a..7b945266cd 100644 --- a/modules_v3/faq/module.php +++ b/modules_v3/faq/module.php @@ -314,8 +314,7 @@ class faq_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module_Block echo '<a href="#body">', WT_I18N::translate('back to top'), '</a>'; echo '</div>'; echo '</div>'; - // PHP5.3 echo '<div class="faq_body">', substr($faqbody, 0, 1)=='<' ? $faqbody : nl2br($faqbody, false), '</div>'; - echo '<div class="faq_body">', substr($faqbody, 0, 1)=='<' ? $faqbody : nl2br($faqbody), '</div>'; + echo '<div class="faq_body">', substr($faqbody, 0, 1)=='<' ? $faqbody : nl2br($faqbody, false), '</div>'; echo '<hr>'; } } diff --git a/modules_v3/gedcom_favorites/module.php b/modules_v3/gedcom_favorites/module.php index d65769338e..e4f382d589 100644 --- a/modules_v3/gedcom_favorites/module.php +++ b/modules_v3/gedcom_favorites/module.php @@ -64,7 +64,7 @@ class gedcom_favorites_WT_Module extends WT_Module implements WT_Module_Block { if ($gid) { $record=WT_GedcomRecord::getInstance($gid); - if ($record && $record->canDisplayDetails()) { + if ($record && $record->canShow()) { self::addFavorite(array( 'user_id' =>$ctype=='user' ? WT_USER_ID : null, 'gedcom_id'=>WT_GED_ID, @@ -131,8 +131,8 @@ class gedcom_favorites_WT_Module extends WT_Module implements WT_Module_Block { $content .= '</div>'; } else { $record=WT_GedcomRecord::getInstance($favorite['gid']); - if ($record && $record->canDisplayDetails()) { - if ($record instanceof WT_Person) { + if ($record && $record->canShow()) { + if ($record instanceof WT_Individual) { $content .= '<div id="box'.$favorite["gid"].'.0" class="person_box action_header'; switch($record->getsex()) { case 'M': diff --git a/modules_v3/googlemap/googlemap.php b/modules_v3/googlemap/googlemap.php index 3861c21ebf..27f26bd708 100644 --- a/modules_v3/googlemap/googlemap.php +++ b/modules_v3/googlemap/googlemap.php @@ -154,7 +154,7 @@ function setup_map() { <?php } -function build_indiv_map($indifacts, $famids) { +function build_indiv_map(WT_Individual $indi, $indifacts, $famids) { global $controller, $GOOGLEMAP_MAX_ZOOM, $GOOGLEMAP_YSIZE, $GM_DEFAULT_TOP_VALUE; // Create the markers list array @@ -165,8 +165,8 @@ function build_indiv_map($indifacts, $famids) { $i = 0; foreach ($indifacts as $key => $value) { $fact = $value->getTag(); - $fact_data=$value->getDetail(); - $factrec = $value->getGedComRecord(); + $fact_data=$value->getValue(); + $factrec = $value->getGedcom(); $placerec = null; if ($value->getPlace()!=null) { @@ -181,9 +181,13 @@ function build_indiv_map($indifacts, $famids) { if (!empty($placerec)) { $ctla = preg_match("/\d LATI (.*)/", $placerec, $match1); $ctlo = preg_match("/\d LONG (.*)/", $placerec, $match2); - $spouse = $value->getSpouse(); + if ($value->getParent() instanceof WT_Family) { + $spouse = $value->getParent()->getSpouse($indi); + } else { + $spouse = null; + } if ($spouse) { - $useThisItem = $spouse->canDisplayDetails(); + $useThisItem = $spouse->canShow(); } else { $useThisItem = true; } @@ -265,13 +269,13 @@ function build_indiv_map($indifacts, $famids) { if ($famrec) { $num = preg_match_all("/1\s*CHIL\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER); for ($j=0; $j<$num; $j++) { - $person=WT_Person::getInstance($smatch[$j][1]); - if ($person->canDisplayDetails()) { + $person=WT_Individual::getInstance($smatch[$j][1]); + if ($person->canShow()) { $srec = find_person_record($smatch[$j][1], WT_GED_ID); $birthrec = ''; $placerec = ''; - foreach ($person->getAllFactsByType('BIRT') as $sEvent) { - $birthrec = $sEvent->getGedcomRecord(); + foreach ($person->getFacts('BIRT') as $sEvent) { + $birthrec = $sEvent->getGedcom(); $placerec = get_sub_record(2, '2 PLAC', $birthrec); if (!empty($placerec)) { $ctd = preg_match("/\d DATE (.*)/", $birthrec, $matchd); @@ -424,7 +428,7 @@ function build_indiv_map($indifacts, $famids) { echo '<span class="field">', $marker['info'], '</span><br>'; } if (!empty($marker['name'])) { - $person=WT_Person::getInstance($marker['name']); + $person=WT_Individual::getInstance($marker['name']); if ($person) { echo '<a href="', $person->getHtmlUrl(), '">', $person->getFullName(), '</a>'; } diff --git a/modules_v3/googlemap/module.php b/modules_v3/googlemap/module.php index 7ef37e4fd7..e727be8565 100644 --- a/modules_v3/googlemap/module.php +++ b/modules_v3/googlemap/module.php @@ -144,8 +144,22 @@ class googlemap_WT_Module extends WT_Module implements WT_Module_Config, WT_Modu foreach ($families as $family) { $famids[] = $family->getXref(); } - $controller->record->add_family_facts(false); - build_indiv_map($controller->record->getIndiFacts(), $famids); + $indifacts = array(); + foreach ($controller->record->getFacts() as $fact) { + if ($fact->canShow()) { + $indifacts[] = $fact; + } + } + foreach ($controller->record->getSpouseFamilies() as $family) { + foreach ($family->getFacts() as $fact) { + if ($fact->canShow()) { + $indifacts[] = $fact; + } + } + } + sort_facts($indifacts); + + build_indiv_map($controller->record, $indifacts, $famids); echo '</div>'; echo '</td>'; echo '</tr></table>'; @@ -739,7 +753,7 @@ class googlemap_WT_Module extends WT_Module implements WT_Module_Config, WT_Modu for ($i=0; $i<($controller->treesize); $i++) { // -- check to see if we have moved to the next generation if ($i+1 >= pow(2, $curgen)) {$curgen++;} - $person = WT_Person::getInstance($controller->treeid[$i]); + $person = WT_Individual::getInstance($controller->treeid[$i]); if (!empty($person)) { $name = $person->getFullName(); if ($name == WT_I18N::translate('Private')) $priv++; @@ -1238,7 +1252,7 @@ class googlemap_WT_Module extends WT_Module implements WT_Module_Config, WT_Modu for ($i=0; $i<($controller->treesize); $i++) { // moved up to grab the sex of the individuals - $person = WT_Person::getInstance($controller->treeid[$i]); + $person = WT_Individual::getInstance($controller->treeid[$i]); if ($person) { $name = $person->getFullName(); diff --git a/modules_v3/googlemap/wt_v3_googlemap.js.php b/modules_v3/googlemap/wt_v3_googlemap.js.php index ed3295fd36..1a6baf121f 100644 --- a/modules_v3/googlemap/wt_v3_googlemap.js.php +++ b/modules_v3/googlemap/wt_v3_googlemap.js.php @@ -438,10 +438,10 @@ $STREETVIEW=get_module_setting('googlemap', 'GM_USE_STREETVIEW'); // create thumbnail images of highlighted images if (!empty($pid)) { - $this_person = WT_Person::getInstance($pid); + $this_person = WT_Individual::getInstance($pid); } if (!empty($gmark['name'])) { - $person = WT_Person::getInstance($gmark['name']); + $person = WT_Individual::getInstance($gmark['name']); } else { $person = null; } @@ -482,7 +482,7 @@ $STREETVIEW=get_module_setting('googlemap', 'GM_USE_STREETVIEW'); "<?php echo $gmark['lng']; ?>", "<?php if (!empty($gmark['date'])) { $date=new WT_Date($gmark['date']); echo addslashes($date->Display(true)); } else { echo WT_I18N::translate('Date not known'); } ?>", "<?php if (!empty($gmark['info'])) { echo addslashes($gmark['info']); } else { echo NULL; } ?>", - "<?php if (!empty($gmark['name'])) { $person=WT_Person::getInstance($gmark['name']); if ($person) { echo '<a href=\"', $person->getHtmlUrl(), '\">', addslashes($person->getFullName()), '<\/a>'; } } ?>", + "<?php if (!empty($gmark['name'])) { $person=WT_Individual::getInstance($gmark['name']); if ($person) { echo '<a href=\"', $person->getHtmlUrl(), '\">', addslashes($person->getFullName()), '<\/a>'; } } ?>", "<?php echo addslashes(print_fact_place_map($gmark['placerec'])); ?>", "<?php echo $gmark['index'].''; ?>", "<?php echo $gmark['tabindex'].''; ?>", @@ -492,7 +492,7 @@ $STREETVIEW=get_module_setting('googlemap', 'GM_USE_STREETVIEW'); "<?php echo strip_tags(preg_replace('/\"/', '\\\"', print_fact_place_map($gmark['placerec']))); ?>", // Element 11. persons Name - "<?php if (!empty($gmark['name'])) { $person=WT_Person::getInstance($gmark['name']); if ($person) { echo addslashes($person->getFullName()); } } ?>", + "<?php if (!empty($gmark['name'])) { $person=WT_Individual::getInstance($gmark['name']); if ($person) { echo addslashes($person->getFullName()); } } ?>", // Element 12. Other people's Highlighted image. "<?php if (!empty($gmark['name'])) { echo $image2; } else { echo ''; } ?>", diff --git a/modules_v3/individuals/module.php b/modules_v3/individuals/module.php index 599b354b17..20f9677054 100644 --- a/modules_v3/individuals/module.php +++ b/modules_v3/individuals/module.php @@ -186,9 +186,9 @@ class individuals_WT_Module extends WT_Module implements WT_Module_Sidebar { $indis=WT_Query_Name::individuals($surname, $alpha, '', true, false, WT_GED_ID); $out = '<ul>'; foreach ($indis as $person) { - if ($person->canDisplayName()) { + if ($person->canShowName()) { $out .= '<li><a href="'.$person->getHtmlUrl().'">'.$person->getSexImage().' '.$person->getFullName().' '; - if ($person->canDisplayDetails()) { + if ($person->canShow()) { $bd = $person->getLifeSpan(); if (!empty($bd)) { $out .= ' ('.$bd.')'; @@ -207,22 +207,22 @@ class individuals_WT_Module extends WT_Module implements WT_Module_Sidebar { } $rows= WT_DB::prepare( - "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". + "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom". " FROM `##individuals`, `##name`". " WHERE (i_id LIKE ? OR n_sort LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". " ORDER BY n_sort COLLATE '".WT_I18N::$collation."'". " LIMIT 50" ) - ->execute(array('INDI', "%{$query}%", "%{$query}%", WT_GED_ID)) - ->fetchAll(PDO::FETCH_ASSOC); + ->execute(array("%{$query}%", "%{$query}%", WT_GED_ID)) + ->fetchAll(); $out = '<ul>'; foreach ($rows as $row) { - $person=WT_Person::getInstance($row); - if ($person->canDisplayName()) { + $person = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + if ($person->canShowName()) { $out .= '<li><a href="'.$person->getHtmlUrl().'">'.$person->getSexImage().' '.$person->getFullName().' '; - if ($person->canDisplayDetails()) { + if ($person->canShow()) { $bd = $person->getLifeSpan(); if (!empty($bd)) $out .= ' ('.$bd.')'; } diff --git a/modules_v3/lightbox/css/album_page.css b/modules_v3/lightbox/css/album_page.css index 6619302f2c..46f9d8dc37 100644 --- a/modules_v3/lightbox/css/album_page.css +++ b/modules_v3/lightbox/css/album_page.css @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * @version $Id$ + * $Id$ */ /* lightbox_plus.css version 3.00 29/06/2007 */ @@ -35,20 +35,18 @@ .pic{border:0; border-color:#fff; border-style:solid; padding:0;} .thumbcontainer{display:block; width:100%;} #lb_icons{text-align:justify;} -#thumblist_1,#thumblist_2,#thumblist_3,#thumblist_4,#thumblist_5,#thumblist_1a,#thumblist_2a,#thumblist_3a,#thumblist_4a,#thumblist_5a{display:block; float:left; list-style-type:none;} -#thumblist_1 li,#thumblist_2 li,#thumblist_3 li,#thumblist_4 li,#thumblist_5 li,#thumblist_1a li,#thumblist_2a li,#thumblist_3a li,#thumblist_4a li,#thumblist_5a li{display:block; float:left; list-style-type:none; margin-right:5px; padding-bottom:0; padding-left:4px; padding-right:4px;} +.thumblist {display:block; float:left; list-style-type:none;} +.thumblist li {display:block; float:left; list-style-type:none; margin-right:5px; padding-bottom:0; padding-left:4px; padding-right:4px;} li.li_norm{border:2px solid transparent; height:112px;} li.li_new{border:2px solid #00f;} li.li_old{border:2px solid red;} -#thumblist_1 a img,#thumblist_2 a img,#thumblist_3 a img,#thumblist_4 a img,#thumblist_5 a img,#thumblist_1a a img,#thumblist_2a a img,#thumblist_3a a img,#thumblist_4a a img,#thumblist_5a a img{border:1px; border-style:none; padding:1px;max-height:78px;max-width:100px;height:auto;width:auto;} -#thumblist_1 a:hover img,#thumblist_2 a:hover img,#thumblist_3 a:hover img,#thumblist_4 a:hover img,#thumblist_5 a:hover img,#thumblist_1a a:hover img,#thumblist_2a a:hover img,#thumblist_3a a:hover img,#thumblist_4a a:hover img,#thumblist_5a a:hover img{background-color:#BDB071; border:0; border-style:none; padding:1px;} +.thumblist a img {border:1px; border-style:none; padding:1px;max-height:78px;max-width:100px;height:auto;width:auto;} +.thumblist a:hover img {background-color:#BDB071; border:0; border-style:none; padding:1px;} .clearlist:after{clear:both; content:"."; display:block; height:0; visibility:hidden;} #lightbox_content span {padding:10px;} #lightbox_content span img {vertical-align:top;} -/* Hides from IE-mac \ */ -* html .clearfix{height:1%;} -#clearlist{display:block;} +#clearlist {display:block;} /* RTL changes */ -html[dir='rtl'] #thumblist_1,html[dir='rtl'] #thumblist_2,html[dir='rtl'] #thumblist_3,html[dir='rtl'] #thumblist_4,html[dir='rtl'] #thumblist_5,html[dir='rtl'] #thumblist_1a,html[dir='rtl'] #thumblist_2a,html[dir='rtl'] #thumblist_3a,html[dir='rtl'] #thumblist_4a,html[dir='rtl'] #thumblist_5a{float:right;} -html[dir='rtl'] #thumblist_1 li,html[dir='rtl'] #thumblist_2 li,html[dir='rtl'] #thumblist_3 li,html[dir='rtl'] #thumblist_4 li,html[dir='rtl'] #thumblist_5 li,html[dir='rtl'] #thumblist_1a li,html[dir='rtl'] #thumblist_2a li,html[dir='rtl'] #thumblist_3a li,html[dir='rtl'] #thumblist_4a li,html[dir='rtl'] #thumblist_5a li{float:right; margin-left:5px;} +html[dir='rtl'] #thumblist {float:right;} +html[dir='rtl'] #thumblist li {float:right; margin-left:5px;} diff --git a/modules_v3/lightbox/functions/lightbox_print_media.php b/modules_v3/lightbox/functions/lightbox_print_media.php deleted file mode 100644 index 970eb373dd..0000000000 --- a/modules_v3/lightbox/functions/lightbox_print_media.php +++ /dev/null @@ -1,460 +0,0 @@ -<?php -// Lightbox Album module for webtrees -// -// Display media Items using Lightbox -// -// webtrees: Web based Family History software -// Copyright (C) 2013 webtrees development team. -// -// Derived from PhpGedView -// Copyright (C) 2007 to 2009 PGV Development Team. All rights reserved. -// -// 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 2 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, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// $Id$ - -if (!defined('WT_WEBTREES')) { - header('HTTP/1.0 403 Forbidden'); - exit; -} - -/** - * ----------------------------------------------------------------------------- - * Print the links to media objects - * @param string $pid The the xref id of the object to find media records related to - * @param int $level The level of media object to find - * @param boolean $related Whether or not to grab media from related records - */ -function lightbox_print_media($pid, $level=1, $related=false, $kind=1, $noedit=false) { - global $GEDCOM; - global $res, $rowm; - global $rownum, $rownum1, $rownum2, $rownum3, $rownum4; - - $ged_id=get_id_from_gedcom($GEDCOM); - $person = WT_Person::getInstance($pid); - $ctf=0; - if ($level>0) { - $regexp = '/\n' . $level . ' OBJE @(.*)@/'; - } else { - $regexp = '/\n\d OBJE @(.*)@/'; - } - //-- find all of the related ids - $ids = array($person->getXref()); - if ($related) { - foreach ($person->getSpouseFamilies() as $family) { - $ids[] = $family->getXref(); - $ctf += preg_match_all($regexp, $family->getGedcomRecord(), $match, PREG_SET_ORDER); - } - } - //-- If they exist, get a list of the sorted current objects in the indi gedcom record - (1 _WT_OBJE_SORT @xxx@ .... etc) ---------- - $sort_current_objes = array(); - $sort_ct = preg_match_all('/\n1 _WT_OBJE_SORT @(.*)@/', $person->getGedcomRecord(), $sort_match, PREG_SET_ORDER); - for ($i=0; $i<$sort_ct; $i++) { - if (!isset($sort_current_objes[$sort_match[$i][1]])) { - $sort_current_objes[$sort_match[$i][1]] = 1; - } else { - $sort_current_objes[$sort_match[$i][1]]++; - } - $sort_obje_links[$sort_match[$i][1]][] = $sort_match[$i][0]; - } - - // create ORDER BY list from Gedcom sorted records list --------------------------- - $orderbylist = 'ORDER BY '; // initialize - foreach ($sort_match as $id) { - $orderbylist .= "m_id='$id[1]' DESC, "; - } - $orderbylist = rtrim($orderbylist, ', '); - - //-- get a list of the current objects in the record - $current_objes = array(); - $ct = preg_match_all($regexp, $person->getGedcomRecord(), $match, PREG_SET_ORDER); - for ($i=0; $i<$ct; $i++) { - if (!isset($current_objes[$match[$i][1]])) { - $current_objes[$match[$i][1]] = 1; - } else { - $current_objes[$match[$i][1]]++; - } - $obje_links[$match[$i][1]][] = $match[$i][0]; - } - - $media_found = false; - - // Get the related media items - $sqlmm = - "SELECT DISTINCT m_id, m_ext, m_filename, m_titl, m_file, m_gedcom, l_from AS pid" . - " FROM `##media`" . - " JOIN `##link` ON (m_id=l_to AND m_file=l_file AND l_type='OBJE')" . - " WHERE m_file=? AND l_from IN ("; - $i=0; - $vars=array(WT_GED_ID); - foreach ($ids as $media_id) { - if ($i>0) $sqlmm .= ", "; - $sqlmm .= "?"; - $vars[]=$media_id; - $i++; - } - $sqlmm .= ')'; - - // Set type of media from call in album - switch ($kind) { - case 1: - $tt=WT_I18N::translate('Photo'); - $sqlmm.="AND (m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ?)"; - $vars[]='%TYPE photo%'; - $vars[]='%TYPE map%'; - $vars[]='%TYPE painting%'; - $vars[]='%TYPE tombstone%'; - break; - case 2: - $tt=WT_I18N::translate('Document'); - $sqlmm.="AND (m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ?)"; - $vars[]='%TYPE card%'; - $vars[]='%TYPE certificate%'; - $vars[]='%TYPE document%'; - $vars[]='%TYPE magazine%'; - $vars[]='%TYPE manuscript%'; - $vars[]='%TYPE newspaper%'; - break; - case 3: - $tt=WT_I18N::translate('Census'); - $sqlmm.="AND (m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ?)"; - $vars[]='%TYPE electronic%'; - $vars[]='%TYPE fiche%'; - $vars[]='%TYPE film%'; - break; - case 4: - $tt=WT_I18N::translate('Other'); - $sqlmm.="AND (m_gedcom NOT LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ? OR m_gedcom LIKE ?)"; - $vars[]='%TYPE %'; - $vars[]='%TYPE coat%'; - $vars[]='%TYPE book%'; - $vars[]='%TYPE audio%'; - $vars[]='%TYPE video%'; - $vars[]='%TYPE other%'; - break; - case 5: - default: - $tt = WT_I18N::translate('Not in DB'); - break; - } - - if ($sort_ct>0) { - $sqlmm .= $orderbylist; - } - - $rows=WT_DB::prepare($sqlmm)->execute($vars)->fetchAll(PDO::FETCH_ASSOC); - - $foundObjs = array(); - $numm = count($rows); - - // Begin to Layout the Album Media Rows - if ($numm>0 || $kind==5) { - if ($kind!=5) { - echo '<table width="100%" class="facts_table"><tr>'; - echo '<td width="100" align="center" class="descriptionbox" style="vertical-align:middle;">'; - echo '<b>', $tt, '</b>'; - echo '</td>'; - echo '<td class="facts_value" >'; - echo '<table class="facts_table" width="100%" cellpadding="0"><tr><td >'; - echo '<div id="thumbcontainer', $kind, '">'; - echo '<ul class="section" id="thumblist_', $kind, '">'; - } - // ================================================== - // Start pulling media items into thumbcontainer div ============================== - foreach ($rows as $rowm) { - if (isset($foundObjs[$rowm['m_id']])) { - if (isset($current_objes[$rowm['m_id']])) { - $current_objes[$rowm['m_id']]--; - } - continue; - } - $rows=array(); - - //-- if there is a change to this media item then get the - //-- updated media item and show it - if (($newrec=find_updated_record($rowm['m_id'], $ged_id)) && $kind!=5 ) { - $row = array(); - $row['m_id'] = $rowm['m_id']; - $row['m_file'] = $ged_id; - $row['m_filename'] = get_gedcom_value('FILE', 1, $newrec); - $row['m_titl'] = get_gedcom_value('TITL', 1, $newrec); - if (empty($row['m_titl'])) $row['m_titl'] = get_gedcom_value('FILE:TITL', 1, $newrec); - $row['m_gedcom'] = $newrec; - $et = preg_match('/\.(\w+)$/', $row['m_filename'], $ematch); - $ext = ''; - if ($et>0) $ext = $ematch[1]; - $row['m_ext'] = $ext; - $row['pid'] = $pid; - $rows['new'] = $row; - $rows['old'] = $rowm; - } else { - if (!isset($current_objes[$rowm['m_id']]) && ($rowm['pid']==$pid)) { - $rows['old'] = $rowm; - } else { - $rows['normal'] = $rowm; - if (isset($current_objes[$rowm['m_id']])) { - $current_objes[$rowm['m_id']]--; - } - } - } - foreach ($rows as $rtype => $rowm) { - if ($kind!=5) { - $res = lightbox_print_media_row($rtype, $rowm, $pid); - } - $media_found = $media_found || $res; - $foundObjs[$rowm['m_id']]=true; - } - } - - // TODO the following logic assumes that each media file is linked only - // once from each individual. But if you are baptised and buried in - // the same church, and have a photo of it in both events, it fails. - - // ===================================================================================== - //-- Objects are removed from the $current_objes list as they are printed. - //-- Any “Extra” objects left in the list are new objects recently added to the gedcom - //-- but not yet accepted into the database. - //-- We will print them too, and put any “Extra Items not in DB” into a new Row. - - // Compare Items count in Database versus Item count in GEDCOM - if ($kind==5 && $ct+$ctf!=$numm) { - // If any items are left in $current_objes list for this individual, put them into $kind 5 (“Not in DB”) row - echo '<table width="100%" class="facts_table"><tr>'; - echo '<td width="100" align="center" class="descriptionbox" style="vertical-align:middle;">'; - echo '<b>', $tt, '</b>'; - echo '</td>'; - echo '<td class="facts_value" >'; - echo '<table class="facts_table" width="100%" cellpadding="0"><tr><td >'; - echo '<div id="thumbcontainer', $kind, '">'; - echo '<ul class="section" id="thumblist_', $kind, '">'; - foreach ($current_objes as $media_id=>$value) { - while ($value>0) { - $objSubrec = array_pop($obje_links[$media_id]); - $row = array(); - $newrec = find_gedcom_record($media_id, $ged_id, true); - $row['m_id'] = $media_id; - $row['m_file']=$ged_id; - $row['m_filename'] = get_gedcom_value("FILE", 1, $newrec); - $row['m_titl'] = get_gedcom_value("TITL", 1, $newrec); - if (empty($row['m_titl'])) $row['m_titl'] = get_gedcom_value("FILE:TITL", 1, $newrec); - $row['m_gedcom'] = $newrec; - $et = preg_match("/(\.\w+)$/", $row['m_file'], $ematch); - $ext = ""; - if ($et>0) $ext = substr(trim($ematch[1]), 1); - $row['m_ext'] = $ext; - $row['pid'] = $pid; - $res = lightbox_print_media_row('new', $row, $pid); - $media_found = $media_found || $res; - $value--; - } - } - } - // No “Extra” Media Items ============================ - if ($kind==5 && $ct+$ctf==$numm) { - // “Extra” Media Item in GEDCOM but NOT in DB ======== - } else if ($kind==5 && $ct+$ctf!=$numm) { - echo '</ul>'; - echo '</div>'; - echo '<div class="clearlist">'; - echo '</div>'; - echo '</td></tr></table>'; - echo '</td>'; - echo '</tr>'; - echo '</table>'; - // Media Item in GEDCOM & in DB ====================== - } else { - echo '</ul>'; - echo '</div>'; - echo '<div class="clearlist">'; - echo '</div>'; - echo '</td></tr></table>'; - if ($kind==3 && $numm > 0) { - echo '<font size="1">'; - echo 'UK census images have been obtained from The National Archives, the custodian of the original records, and appear here with their approval on the condition that no commercial use is made of them without permission. Requests for commercial publication of these or other UK census images appearing on this website should be directed to: Image Library, The National Archives, Kew, Surrey, TW9 4DU, United Kingdom.'; - echo '</font>'; - } - echo '</td>'; - echo '</tr>'; - echo '</table>'; - } - } - if ($media_found) return $is_media='YES'; - else return $is_media='NO'; -} - -/** - * print a media row in a table - * @param string $rtype whether this is a 'new', 'old', or 'normal' media row... this is used to determine if the rows should be printed with an outline color - * @param array $rowm An array with the details about this media item - * @param string $pid The record id this media item was attached to - */ -function lightbox_print_media_row($rtype, $rowm, $pid) { - - global $sort_i, $notes; - - $media=WT_Media::getInstance($rowm['m_id']); - - if ($media && !$media->canDisplayDetails()) { - // This media object is private; - return false; - } - - if (!canDisplayFact($rowm['m_id'], $rowm['m_file'], $rowm['m_gedcom'])) { - // The link to this media object is private. e.g. 1 OBJE/2 RESN - return false; - } - - // Highlight Album Thumbnails - Changed=new (blue), Changed=old (red), Changed=no (none) - if ($rtype=='new') { - echo '<li class="li_new">'; - } else if ($rtype=='old') { - echo '<li class="li_old">'; - } else { - echo '<li class="li_norm">'; - } - - // Get the title of the media - if ($media) { - $mediaTitle = $media->getFullName(); - } else { - $mediaTitle = $rowm['m_id']; - } - - //Get media item Notes - $haystack = $rowm['m_gedcom']; - $needle = '1 NOTE'; - $before = substr($haystack, 0, strpos($haystack, $needle)); - $after = substr(strstr($haystack, $needle), strlen($needle)); - $final = $before.$needle.$after; - $notes = htmlspecialchars(addslashes(print_fact_notes($final, 1, true, true)), ENT_QUOTES); - - // Prepare Below Thumbnail menu ---------------------------------------------------- - $mtitle = '<div style="max-width:120px;overflow:hidden;text-overflow:ellipsis;">' . $mediaTitle . '</div>'; - $menu = new WT_Menu(); - $menu->addLabel($mtitle, 'right'); - - if ($rtype=='old') { - // Do not print menu if item has changed and this is the old item - } else { - // Continue printing menu - $menu->addClass('', 'submenu'); - - // View Notes - if (strpos($rowm['m_gedcom'], "\n1 NOTE")) { - $submenu = new WT_Menu(WT_I18N::translate('View Notes'), '#'); - // Notes Tooltip ---------------------------------------------------- - $submenu->addOnclick("modalNotes('". $notes ."','". WT_I18N::translate('View Notes') ."'); return false;"); - $submenu->addClass("submenuitem"); - $menu->addSubMenu($submenu); - } - //View Details - $submenu = new WT_Menu(WT_I18N::translate('View Details'), WT_SERVER_NAME.WT_SCRIPT_PATH . "mediaviewer.php?mid=".$rowm['m_id'].'&ged='.WT_GEDURL, 'right'); - $submenu->addClass("submenuitem"); - $menu->addSubMenu($submenu); - - //View Sources - $source_menu = null; - foreach ($media->getAllFactsByType('SOUR') as $source_fact) { - $source = WT_Source::getInstance(trim($source_fact->detail, '@')); - if ($source && $source->canDisplayDetails()) { - if (!$source_menu) { - // Group sources under a top level menu - $source_menu = new WT_Menu(WT_I18N::translate('Sources'), '#', null, 'right', 'right'); - $source_menu->addClass('submenuitem', 'submenu'); - } - //now add a link to the actual source as a submenu - $submenu = new WT_Menu(new WT_Menu(strip_tags($source->getFullName()), $source->getHtmlUrl())); - $submenu->addClass('submenuitem', 'submenu'); - $source_menu->addSubMenu($submenu); - } - } - if ($source_menu) { - $menu->addSubMenu($source_menu); - } - - if (WT_USER_CAN_EDIT) { - // Edit Media - $submenu = new WT_Menu(WT_I18N::translate('Edit media')); - $submenu->addOnclick("return window.open('addmedia.php?action=editmedia&pid={$rowm['m_id']}', '_blank', edit_window_specs);"); - $submenu->addClass("submenuitem"); - $menu->addSubMenu($submenu); - if (WT_USER_IS_ADMIN) { - // Manage Links - if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) { - $submenu = new WT_Menu(WT_I18N::translate('Manage links')); - $submenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_id']}&linkto=manage', '_blank', find_window_specs);"); - $submenu->addClass("submenuitem"); - $menu->addSubMenu($submenu); - } else { - $submenu = new WT_Menu(WT_I18N::translate('Set link'), '#', null, 'right', 'right'); - $submenu->addClass('submenuitem', 'submenu'); - - $ssubmenu = new WT_Menu(WT_I18N::translate('To Person')); - $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_id']}&linkto=person', '_blank', find_window_specs);"); - $ssubmenu->addClass('submenuitem', 'submenu'); - $submenu->addSubMenu($ssubmenu); - - $ssubmenu = new WT_Menu(WT_I18N::translate('To Family')); - $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_id']}&linkto=family', '_blank', find_window_specs);"); - $ssubmenu->addClass('submenuitem', 'submenu'); - $submenu->addSubMenu($ssubmenu); - - $ssubmenu = new WT_Menu(WT_I18N::translate('To Source')); - $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid={$rowm['m_id']}&linkto=source', '_blank', find_window_specs);"); - $ssubmenu->addClass('submenuitem', 'submenu'); - $submenu->addSubMenu($ssubmenu); - - $menu->addSubMenu($submenu); - } - // Unlink Media - $submenu = new WT_Menu(WT_I18N::translate('Unlink Media')); - $submenu->addOnclick("return delete_fact('$pid', 'OBJE', '".$rowm['m_id']."', '".WT_I18N::translate('Are you sure you want to delete this fact?')."');"); - $submenu->addClass("submenuitem"); - $menu->addSubMenu($submenu); - } - } - } - - // Start Thumbnail Enclosure table --------------------------------------------- - // Pull table up 90px if media object is a “streetview” - if (strpos($rowm['m_filename'], 'http://maps.google.')===0) { - echo '<table width="10px" style="margin-top:-90px;" class="pic" border="0"><tr>'; - } else { - echo '<table width="10px" class="pic" border="0"><tr>'; - } - echo '<td align="center" rowspan="2">'; - echo '<div style="width:1px; height:100px;"></div>'; - echo '</td>'; - echo '<td colspan="3" valign="middle" align="center">'; - if ($media) { - echo $media->displayImage(); - } - echo '</td></tr>'; - - //View Edit Menu ---------------------------------- - echo '<tr>'; - echo '<td width="5px"></td>'; - echo '<td valign="bottom" align="center" class="nowrap">'; - echo $menu->getMenu(); - echo '</td>'; - echo '<td width="5px"></td>'; - echo '</tr>'; - echo '</table>'; - $media_data = $rowm['m_id']; - echo '<input type="hidden" name="order1[', $media_data, ']" value="', $sort_i, '">'; - $sort_i++; - echo '</li>'; - return true; -} diff --git a/modules_v3/lightbox/module.php b/modules_v3/lightbox/module.php index 46df579133..6ba96df435 100644 --- a/modules_v3/lightbox/module.php +++ b/modules_v3/lightbox/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -29,6 +29,8 @@ if (!defined('WT_WEBTREES')) { } class lightbox_WT_Module extends WT_Module implements WT_Module_Tab { + private $facts; + // Extend WT_Module public function getTitle() { return /* I18N: Name of a module */ WT_I18N::translate('Album'); @@ -46,19 +48,39 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->get_media_count()>0; + return WT_USER_CAN_EDIT || $this->get_facts(); } // Implement WT_Module_Tab public function isGrayedOut() { - return $this->get_media_count()==0; + return !$this->get_facts(); } // Implement WT_Module_Tab public function getTabContent() { global $controller, $sort_i; - require_once WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lightbox_print_media.php'; + // Group the media objects by type. + // (The old code further grouped them into 5 categories - was this really wanted??) + $types = WT_Gedcom_Tag::getFileFormTypes(); + $groups = array(); + foreach ($this->get_facts() as $fact) { + preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches); + foreach ($matches[1] as $match) { + $media = WT_Media::getInstance($match); + if ($media->canShow()) { + $type = $media->getMediaType(); + if (!array_key_exists($type, $types)) { + $type = 'other'; + } + if (!isset($groups[$type])) { + $groups[$type] = array(); + } + $groups[$type][] = array('fact' => $fact, 'media' => $media); + } + } + } + $html='<div id="'.$this->getName().'_content">'; //Show Lightbox-Album header Links if (WT_USER_CAN_EDIT) { @@ -76,7 +98,7 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Tab { $html.=WT_I18N::translate('Link to an existing media object'); $html.='</a></span>'; } - if (WT_USER_GEDCOM_ADMIN && $this->get_media_count()>1) { + if (WT_USER_GEDCOM_ADMIN && $this->get_facts()) { // Popup Reorder Media $html.='<span><a href="#" onclick="reorder_media(\''.$controller->record->getXref().'\')">'; $html.='<img src="'.WT_STATIC_URL.WT_MODULES_DIR.'lightbox/images/images.png" id="head_icon" class="icon" title="'.WT_I18N::translate('Re-order media').'" alt="'.WT_I18N::translate('Re-order media').'">'; @@ -89,60 +111,186 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Tab { $media_found = false; // Used when sorting media on album tab page - $html.='<table width="100%" cellpadding="0" border="0"><tr>'; - $html.='<td width="100%" valign="top" >'; - ob_start(); - lightbox_print_media($controller->record->getXref(), 0, true, 1); // map, painting, photo, tombstone) - lightbox_print_media($controller->record->getXref(), 0, true, 2); // card, certificate, document, magazine, manuscript, newspaper - lightbox_print_media($controller->record->getXref(), 0, true, 3); // electronic, fiche, film - lightbox_print_media($controller->record->getXref(), 0, true, 4); // audio, book, coat, video, other - lightbox_print_media($controller->record->getXref(), 0, true, 5); // footnotes - return - $html. - ob_get_clean(). - '</td></tr></table></div>'; - } + $html.='<table width="100%" cellpadding="0" border="0">'; + foreach ($groups as $type=>$media_list) { + $html .= '<tr>'; + $html .= '<td class="facts_label width20">'; + $html .= $types[$type]; + $html .= '</td>'; + $html .= '<td class="facts_value">'; + $html .= '<div class="thumbcontainer">'; + $html .= '<ul class="thumblist">'; + foreach ($media_list as $media_list_item) { + if ($media_list_item['fact']->isNew()) { + $html .= '<li class="li_new">'; + } elseif ($media_list_item['fact']->isOld()) { + $html .= '<li class="li_old">'; + } else { + $html .= '<li class="li_norm">'; + } + // ...and now the actual image + if (strpos($media_list_item['media']->getFilename(), 'http://maps.google.')===0) { + $html .= '<table width="10px" style="margin-top:-90px;" class="pic" border="0"><tr>'; + } else { + $html .= '<table width="10px" class="pic" border="0"><tr>'; + } + $html .= '<td align="center" rowspan="2">'; + $html .= '<div style="width:1px; height:100px;"></div>'; + $html .= '</td>'; + $html .= '<td colspan="3" valign="middle" align="center">'; + $html .= $media_list_item['media']->displayImage(); + $html .= '</td></tr>'; - // Implement WT_Module_Tab - public function canLoadAjax() { - global $SEARCH_SPIDER; + //View Edit Menu ---------------------------------- + $html .= '<tr>'; + $html .= '<td width="5px"></td>'; + $html .= '<td valign="bottom" align="center" class="nowrap">'; - return !$SEARCH_SPIDER; // Search engines cannot use AJAX - } - // Implement WT_Module_Tab - public function getPreLoadContent() { - return ''; - } - protected $mediaCount = null; + //Get media item Notes + $haystack = $media_list_item['media']->getGedcom(); + $needle = '1 NOTE'; + $before = substr($haystack, 0, strpos($haystack, $needle)); + $after = substr(strstr($haystack, $needle), strlen($needle)); + $final = $before.$needle.$after; + $notes = htmlspecialchars(addslashes(print_fact_notes($final, 1, true, true)), ENT_QUOTES); - private function get_media_count() { + // Prepare Below Thumbnail menu ---------------------------------------------------- + $mtitle = '<div style="max-width:120px;overflow:hidden;text-overflow:ellipsis;">' . $media_list_item['media']->getFullName() . '</div>'; + $menu = new WT_Menu(); + $menu->addLabel($mtitle, 'right'); + + if ($media_list_item['fact']->isOld()) { + // Do not print menu if item has changed and this is the old item + } else { + // Continue printing menu + $menu->addClass('', 'submenu'); + + // View Notes + if (strpos($media_list_item['media']->getGedcom(), "\n1 NOTE")) { + $submenu = new WT_Menu(WT_I18N::translate('View Notes'), '#'); + // Notes Tooltip ---------------------------------------------------- + $submenu->addOnclick("modalNotes('". $notes ."','". WT_I18N::translate('View Notes') ."'); return false;"); + $submenu->addClass("submenuitem"); + $menu->addSubMenu($submenu); + } + //View Details + $submenu = new WT_Menu(WT_I18N::translate('View Details'), WT_SERVER_NAME.WT_SCRIPT_PATH . "mediaviewer.php?mid=".$media_list_item['media']->getXref().'&ged='.WT_GEDURL, 'right'); + $submenu->addClass("submenuitem"); + $menu->addSubMenu($submenu); + + //View Sources + $source_menu = null; + foreach ($media->getFacts('SOUR') as $source_fact) { + $source = WT_Source::getInstance(trim($source_fact->detail, '@')); + if ($source && $source->canShow()) { + if (!$source_menu) { + // Group sources under a top level menu + $source_menu = new WT_Menu(WT_I18N::translate('Sources'), '#', null, 'right', 'right'); + $source_menu->addClass('submenuitem', 'submenu'); + } + //now add a link to the actual source as a submenu + $submenu = new WT_Menu(new WT_Menu(strip_tags($source->getFullName()), $source->getHtmlUrl())); + $submenu->addClass('submenuitem', 'submenu'); + $source_menu->addSubMenu($submenu); + } + } + if ($source_menu) { + $menu->addSubMenu($source_menu); + } + + if (WT_USER_CAN_EDIT) { + // Edit Media + $submenu = new WT_Menu(WT_I18N::translate('Edit media')); + $submenu->addOnclick("return window.open('addmedia.php?action=editmedia&pid=".$media_list_item['media']->getXref()."', '_blank', edit_window_specs);"); + $submenu->addClass("submenuitem"); + $menu->addSubMenu($submenu); + if (WT_USER_IS_ADMIN) { + // Manage Links + if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) { + $submenu = new WT_Menu(WT_I18N::translate('Manage links')); + $submenu->addOnclick("return window.open('inverselink.php?mediaid=".$media_list_item['media']->getXref()."&linkto=manage', '_blank', find_window_specs);"); + $submenu->addClass("submenuitem"); + $menu->addSubMenu($submenu); + } else { + $submenu = new WT_Menu(WT_I18N::translate('Set link'), '#', null, 'right', 'right'); + $submenu->addClass('submenuitem', 'submenu'); + + $ssubmenu = new WT_Menu(WT_I18N::translate('To Person')); + $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid=".$media_list_item['media']->getXref()."&linkto=person', '_blank', find_window_specs);"); + $ssubmenu->addClass('submenuitem', 'submenu'); + $submenu->addSubMenu($ssubmenu); + + $ssubmenu = new WT_Menu(WT_I18N::translate('To Family')); + $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid=".$media_list_item['media']->getXref()."&linkto=family', '_blank', find_window_specs);"); + $ssubmenu->addClass('submenuitem', 'submenu'); + $submenu->addSubMenu($ssubmenu); + + $ssubmenu = new WT_Menu(WT_I18N::translate('To Source')); + $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid=".$media_list_item['media']->getXref()."&linkto=source', '_blank', find_window_specs);"); + $ssubmenu->addClass('submenuitem', 'submenu'); + $submenu->addSubMenu($ssubmenu); + + $menu->addSubMenu($submenu); + } + // Unlink Media + $submenu = new WT_Menu(WT_I18N::translate('Unlink Media')); + $submenu->addOnclick("return delete_fact('".$media_list_item['media']->getXref()."', 'OBJE', '".$media_list_item['media']->getXref()."', '".WT_I18N::translate('Are you sure you want to delete this fact?')."');"); + $submenu->addClass("submenuitem"); + $menu->addSubMenu($submenu); + } + } + $html .= $menu->getMenu(); + } + $html .= '</td>'; + $html .= '<td width="5px"></td>'; + $html .= '</tr>'; + $html .= '</table>'; + $html .= '<input type="hidden" name="order1[' . $media_list_item['media']->getXref() . ']" value="' . $sort_i . '">'; + $sort_i++; + $html .= '</li>'; + } + $html .= '</ul>'; + $html .= '<div class="clearlist"></div>'; + $html .= '</td>'; + $html .= '</tr>'; + } + $html .= '</table></div>'; + return $html; + } + + private function get_facts() { global $controller; - if ($this->mediaCount===null) { - $this->mediaCount = 0; - preg_match_all('/\d OBJE @(' . WT_REGEX_XREF . ')@/', $controller->record->getGedcomRecord(), $matches); - foreach ($matches[1] as $match) { - $obje = WT_Media::getInstance($match); - if ($obje && $obje->canDisplayDetails()) { - $this->mediaCount++; + if ($this->facts === null) { + $facts = $controller->record->getFacts(); + foreach ($controller->record->getSpouseFamilies() as $family) { + if ($family->canShow()) { + foreach ($family->getFacts() as $fact) { + $facts[] = $fact; + } } } - foreach ($controller->record->getSpouseFamilies() as $sfam) { - preg_match_all('/\d OBJE @(' . WT_REGEX_XREF . ')@/', $sfam->getGedcomRecord(), $matches); - foreach ($matches[1] as $match) { - $obje = WT_Media::getInstance($match); - if ($obje && $obje->canDisplayDetails()) { - $this->mediaCount++; - } + $this->facts = array(); + foreach ($facts as $fact) { + if (preg_match('/(?:^1|\n\d) OBJE @' . WT_REGEX_XREF . '@/', $fact->getGedcom())) { + $this->facts[] = $fact; } } } - return $this->mediaCount; + return $this->facts; + } + + // Implement WT_Module_Tab + public function canLoadAjax() { + global $SEARCH_SPIDER; + + return !$SEARCH_SPIDER; // Search engines cannot use AJAX } - private function getJS() { + // Implement WT_Module_Tab + public function getPreLoadContent() { return ''; } } diff --git a/modules_v3/media/module.php b/modules_v3/media/module.php index 21dc794102..8750a95ffa 100644 --- a/modules_v3/media/module.php +++ b/modules_v3/media/module.php @@ -29,6 +29,8 @@ if (!defined('WT_WEBTREES')) { } class media_WT_Module extends WT_Module implements WT_Module_Tab { + private $facts; + // Extend WT_Module public function getTitle() { return /* I18N: Name of a module */ WT_I18N::translate('Media'); @@ -44,16 +46,14 @@ class media_WT_Module extends WT_Module implements WT_Module_Tab { return 50; } - protected $mediaCount = null; - // Implement WT_Module_Tab public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->get_media_count()>0; + return WT_USER_CAN_EDIT || $this->get_facts(); } // Implement WT_Module_Tab public function isGrayedOut() { - return $this->get_media_count()==0; + return !$this->get_facts(); } // Implement WT_Module_Tab @@ -62,31 +62,51 @@ class media_WT_Module extends WT_Module implements WT_Module_Tab { ob_start(); echo '<table class="facts_table">'; - // Reorder media ------------------------------------ - if (WT_USER_GEDCOM_ADMIN && $this->get_media_count()>1) { - echo '<tr><td colspan="2" class="descriptionbox rela">'; - echo '<span><a href="#" onclick="reorder_media(\''.$controller->record->getXref().'\'); return false;"><i class="icon-media-shuffle"></i>'; - echo WT_I18N::translate('Re-order media'); - echo '</a></span>'; - echo '</td></tr>'; + if (WT_USER_GEDCOM_ADMIN && $this->get_facts()) { + ?> + <tr> + <td colspan="2" class="descriptionbox rela"> + <span> + <a href="#" onclick="reorder_media(\''.$controller->record->getXref().'\'); return false;"> + <i class="icon-media-shuffle"></i> + <?php echo WT_I18N::translate('Re-order media'); ?> + </a> + </span> + </td> + </tr> + <?php } - $media_found = print_main_media($controller->record->getXref(), 0, true); - if (!$media_found) { + foreach ($this->get_facts() as $fact) { + if ($fact->getTag() == 'OBJE') { + print_main_media($fact, 1); + } else { + for ($i=2; $i<4; ++$i) { + print_main_media($fact, $i); + } + } + } + if (!$this->get_facts()) { echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', WT_I18N::translate('There are no media objects for this individual.'), '</td></tr>'; } - //-- New Media link - if (WT_USER_CAN_EDIT && $controller->record->canDisplayDetails() && get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { - ?> + // New media link + if ($controller->record->canEdit() && get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { + ?> <tr> - <td class="facts_label"><?php echo WT_Gedcom_Tag::getLabel('OBJE'); ?></td> + <td class="facts_label"> + <?php echo WT_Gedcom_Tag::getLabel('OBJE'); ?> + </td> <td class="facts_value"> - <a href="#" onclick="window.open('addmedia.php?action=showmediaform&linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo WT_GEDURL; ?>', '_blank', edit_window_specs); return false;"> <?php echo WT_I18N::translate('Add a new media object'); ?></a> + <a href="#" onclick="window.open('addmedia.php?action=showmediaform&linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo WT_GEDURL; ?>', '_blank', edit_window_specs); return false;"> + <?php echo WT_I18N::translate('Add a new media object'); ?> + </a> <?php echo help_link('OBJE'); ?> <br> - <a href="#" onclick="window.open('inverselink.php?linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo WT_GEDURL; ?>&linkto=person', '_blank', find_window_specs); return false;"><?php echo WT_I18N::translate('Link to an existing media object'); ?></a> + <a href="#" onclick="window.open('inverselink.php?linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo WT_GEDURL; ?>&linkto=person', '_blank', find_window_specs); return false;"> + <?php echo WT_I18N::translate('Link to an existing media object'); ?> + </a> </td> </tr> - <?php + <?php } ?> </table> @@ -94,33 +114,27 @@ class media_WT_Module extends WT_Module implements WT_Module_Tab { return '<div id="'.$this->getName().'_content">'.ob_get_clean().'</div>'; } - /** - * get the number of media items for this person - * @return int - */ - function get_media_count() { + // Get all facts containing media links for this person and their spouse-family records + function get_facts() { global $controller; - if ($this->mediaCount===null) { - $this->mediaCount = 0; - preg_match_all('/\d OBJE @(' . WT_REGEX_XREF . ')@/', $controller->record->getGedcomRecord(), $matches); - foreach ($matches[1] as $match) { - $obje = WT_Media::getInstance($match); - if ($obje && $obje->canDisplayDetails()) { - $this->mediaCount++; + if ($this->facts === null) { + $facts = $controller->record->getFacts(); + foreach ($controller->record->getSpouseFamilies() as $family) { + if ($family->canShow()) { + foreach ($family->getFacts() as $fact) { + $facts[] = $fact; + } } } - foreach ($controller->record->getSpouseFamilies() as $sfam) { - preg_match_all('/\d OBJE @(' . WT_REGEX_XREF . ')@/', $sfam->getGedcomRecord(), $matches); - foreach ($matches[1] as $match) { - $obje = WT_Media::getInstance($match); - if ($obje && $obje->canDisplayDetails()) { - $this->mediaCount++; - } + $this->facts = array(); + foreach ($facts as $fact) { + if (preg_match('/(?:^1|\n\d) OBJE @' . WT_REGEX_XREF . '@/', $fact->getGedcom())) { + $this->facts[] = $fact; } } } - return $this->mediaCount; + return $this->facts; } // Implement WT_Module_Tab diff --git a/modules_v3/notes/module.php b/modules_v3/notes/module.php index c799033869..1a683092ff 100644 --- a/modules_v3/notes/module.php +++ b/modules_v3/notes/module.php @@ -29,6 +29,8 @@ if (!defined('WT_WEBTREES')) { } class notes_WT_Module extends WT_Module implements WT_Module_Tab { + private $facts; + // Extend WT_Module public function getTitle() { return /* I18N: Name of a module */ WT_I18N::translate('Notes'); @@ -44,73 +46,72 @@ class notes_WT_Module extends WT_Module implements WT_Module_Tab { return 40; } - protected $noteCount = null; + // Implement WT_Module_Tab + public function hasTabContent() { + return WT_USER_CAN_EDIT || $this->get_facts(); + } // Implement WT_Module_Tab + public function isGrayedOut() { + return !$this->get_facts(); + } + // Implement WT_Module_Tab public function getTabContent() { global $SHOW_LEVEL2_NOTES, $NAV_NOTES, $controller; ob_start(); + echo '<table class="facts_table">'; ?> - <table class="facts_table"> - <tr> - <td colspan="2" class="descriptionbox rela"> - <input id="checkbox_note2" type="checkbox" <?php if ($SHOW_LEVEL2_NOTES) echo ' checked="checked"'; ?> onclick="jQuery('tr.row_note2').toggle();"> - <label for="checkbox_note2"><?php echo WT_I18N::translate('Show all notes'); ?></label> - <?php echo help_link('show_fact_sources'); ?> - </td> - </tr> + <tr> + <td colspan="2" class="descriptionbox rela"> + <input id="checkbox_note2" type="checkbox" <?php if ($SHOW_LEVEL2_NOTES) echo ' checked="checked"'; ?> onclick="jQuery('tr.row_note2').toggle();"> + <label for="checkbox_note2"><?php echo WT_I18N::translate('Show all notes'); ?></label> + <?php echo help_link('show_fact_sources'); ?> + </td> + </tr> <?php - $globalfacts = $controller->getGlobalFacts(); - foreach ($globalfacts as $event) { - $fact = $event->getTag(); - if ($fact=='NAME') { - print_main_notes($event, 2); + foreach ($this->get_facts() as $fact) { + if ($fact->getTag() == 'NOTE') { + print_main_notes($fact, 1); + } else { + for ($i=2; $i<4; ++$i) { + print_main_notes($fact, $i); + } } } - $otherfacts = $controller->getOtherFacts(); - foreach ($otherfacts as $event) { - $fact = $event->getTag(); - if ($fact=='NOTE') { - print_main_notes($event, 1); + if (!$this->get_facts()) { + echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', WT_I18N::translate('There are no Notes for this individual.'), '</td></tr>'; } - } - // 2nd to 5th level notes/sources - $controller->record->add_family_facts(false); - foreach ($controller->getIndiFacts() as $factrec) { - for ($i=2; $i<6; $i++) { - print_main_notes($factrec, $i); - } - } - if ($this->get_note_count()==0) { - echo '<tr><td id="no_tab2" colspan="2" class="facts_value">', WT_I18N::translate('There are no Notes for this individual.'), '</td></tr>'; - } - //-- New Note Link + + // New note link if ($controller->record->canEdit()) { ?> - <tr> - <td class="facts_label"><?php echo WT_Gedcom_Tag::getLabel('NOTE'); ?></td> - <td class="facts_value"> - <a href="#" onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','NOTE'); return false;"> - <?php echo WT_I18N::translate('Add a new note'); ?> - </a> - <?php echo help_link('add_note'); ?> - </td> - </tr> - <tr> - <td class="facts_label"><?php echo WT_Gedcom_Tag::getLabel('SHARED_NOTE'); ?></td> - <td class="facts_value"> - <a href="#" onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','SHARED_NOTE'); return false;"> - <?php echo WT_I18N::translate('Add a new shared note'); ?> - </a> - <?php echo help_link('add_shared_note'); ?> - </td> - </tr> - <?php + <tr> + <td class="facts_label"> + <?php echo WT_Gedcom_Tag::getLabel('NOTE'); ?> + </td> + <td class="facts_value"> + <a href="#" onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','NOTE'); return false;"> + <?php echo WT_I18N::translate('Add a new note'); ?> + </a> + <?php echo help_link('add_note'); ?> + </td> + </tr> + <tr> + <td class="facts_label"> + <?php echo WT_Gedcom_Tag::getLabel('SHARED_NOTE'); ?> + </td> + <td class="facts_value"> + <a href="#" onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','SHARED_NOTE'); return false;"> + <?php echo WT_I18N::translate('Add a new shared note'); ?> + </a> + <?php echo help_link('add_shared_note'); ?> + </td> + </tr> + <?php } ?> </table> - <br> <?php if (!$SHOW_LEVEL2_NOTES) { echo '<script>jQuery("tr.row_note2").toggle();</script>'; @@ -118,27 +119,29 @@ class notes_WT_Module extends WT_Module implements WT_Module_Tab { return '<div id="'.$this->getName().'_content">'.ob_get_clean().'</div>'; } - function get_note_count() { + function get_facts() { global $controller; - if ($this->noteCount===null) { - $ct = preg_match_all("/\d NOTE /", $controller->record->getGedcomRecord(), $match, PREG_SET_ORDER); - foreach ($controller->record->getSpouseFamilies() as $sfam) - $ct += preg_match("/\d NOTE /", $sfam->getGedcomRecord()); - $this->noteCount = $ct; + if ($this->facts === null) { + $facts = $controller->record->getFacts(); + foreach ($controller->record->getSpouseFamilies() as $family) { + if ($family->canShow()) { + foreach ($family->getFacts() as $fact) { + $facts[] = $fact; + } + } + } + $this->facts = array(); + foreach ($facts as $fact) { + if (preg_match('/(?:^1|\n\d) NOTE/', $fact->getGedcom())) { + $this->facts[] = $fact; + } + } } - return $this->noteCount; + return $this->facts; } // Implement WT_Module_Tab - public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->get_note_count()>0; - } - // Implement WT_Module_Tab - public function isGrayedOut() { - return $this->get_note_count()==0; - } - // Implement WT_Module_Tab public function canLoadAjax() { global $SEARCH_SPIDER; diff --git a/modules_v3/personal_facts/module.php b/modules_v3/personal_facts/module.php index 8e3257eae5..ca557b457c 100644 --- a/modules_v3/personal_facts/module.php +++ b/modules_v3/personal_facts/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -54,57 +54,117 @@ class personal_facts_WT_Module extends WT_Module implements WT_Module_Tab { global $EXPAND_RELATIVES_EVENTS, $controller; $EXPAND_HISTO_EVENTS = false; + $indifacts = array(); + // The individual's own facts + foreach ($controller->record->getFacts() as $fact) { + switch ($fact->getTag()) { + case 'SEX': + case 'NAME': + case 'SOUR': + case 'OBJE': + case 'NOTE': + case 'FAMC': + case 'FAMS': + break; + default: + if (!array_key_exists('extra_info', WT_Module::getActiveSidebars()) || !extra_info_WT_Module::showFact($fact)) { + if ($fact->canShow()) { + $indifacts[] = $fact; + } + } + break; + } + } + + // Add spouse-family facts + foreach ($controller->record->getSpouseFamilies() as $family) { + $spouse = $family->getSpouse($controller->record); + $divorced = false; + foreach ($family->getFacts() as $fact) { + switch ($fact->getTag()) { + case 'SOUR': + case 'NOTE': + case 'CHAN': + case '_UID': + case 'RIN': + case 'HUSB': + case 'WIFE': + case 'CHIL': + break; + default: + if ($fact->getTag() == 'DIV') { + $divorced = true; + } + if ($fact->canShow()) { + $indifacts[] = $fact; + } + break; + } + } + + // Don't show family facts for divorced spouses + if (!$divorced) { + foreach (self::spouse_facts($controller->record, $spouse) as $fact) { + $indifacts[] = $fact; + } + } + foreach (self::child_facts($controller->record, $family, '_CHIL', '') as $fact) { + $indifacts[] = $fact; + } + } + + foreach (self::parent_facts($controller->record, 1) as $fact) { + $indifacts[] = $fact; + } + foreach (self::historical_facts($controller->record) as $fact) { + $indifacts[] = $fact; + } + foreach (self::associate_facts($controller->record) as $fact) { + $indifacts[] = $fact; + } + + sort_facts($indifacts); + + ob_start(); + + echo '<table class="facts_table">'; echo '<script>'; if (!$EXPAND_RELATIVES_EVENTS) { - echo "jQuery('tr.row_rela').toggle();"; + echo "jQuery('tr.rela').toggle();"; } if (!$EXPAND_HISTO_EVENTS) { - echo "jQuery('tr.row_histo').toggle();"; + echo "jQuery('tr.histo').toggle();"; } echo '</script>'; - //-- only need to add family facts on this tab - if (!isset($controller->skipFamilyFacts)) { - $controller->record->add_family_facts(); + if (!$indifacts) { + echo '<tr><td colspan="2" class="facts_value">', WT_I18N::translate('There are no Facts for this individual.'), '</td></tr>'; } - ob_start(); - echo '<table class="facts_table">'; - $indifacts = $controller->getIndiFacts(); - if (count($indifacts)==0) { - echo '<tr><td colspan="2" class="facts_value">', WT_I18N::translate('There are no Facts for this individual.'), '</td></tr>'; + echo '<tr><td colspan="2" class="descriptionbox rela"><input id="checkbox_rela_facts" type="checkbox"'; + if ($EXPAND_RELATIVES_EVENTS) { + echo ' checked="checked"'; } - if (!isset($controller->skipFamilyFacts)) { - echo '<tr id="row_top"><td colspan="2" class="descriptionbox rela"><input id="checkbox_rela_facts" type="checkbox"'; - if ($EXPAND_RELATIVES_EVENTS) { + echo ' onclick="jQuery(\'tr.rela\').toggle();"><label for="checkbox_rela_facts">', WT_I18N::translate('Events of close relatives'), '</label>'; + if (file_exists(WT_Site::preference('INDEX_DIRECTORY').'histo.'.WT_LOCALE.'.php')) { + echo ' <input id="checkbox_histo" type="checkbox"'; + if ($EXPAND_HISTO_EVENTS) { echo ' checked="checked"'; } - echo ' onclick="jQuery(\'tr.row_rela\').toggle();"><label for="checkbox_rela_facts">', WT_I18N::translate('Events of close relatives'), '</label>'; - if (file_exists(WT_Site::preference('INDEX_DIRECTORY').'histo.'.WT_LOCALE.'.php')) { - echo ' <input id="checkbox_histo" type="checkbox"'; - if ($EXPAND_HISTO_EVENTS) { - echo ' checked="checked"'; - } - echo ' onclick="jQuery(\'tr.row_histo\').toggle();"><label for="checkbox_histo">', WT_I18N::translate('Historical facts'), '</label>'; - } - echo '</td></tr>'; + echo ' onclick="jQuery(\'tr.histo\').toggle();"><label for="checkbox_histo">', WT_I18N::translate('Historical facts'), '</label>'; } + echo '</td></tr>'; + foreach ($indifacts as $fact) { - if ($fact->getParentObject() instanceof WT_Family) { - // Print all family facts - print_fact($fact, $controller->record); - } else { - // Individual/reference facts (e.g. CHAN, IDNO, RFN, AFN, REFN, RIN, _UID) can be shown in the sidebar - if (!in_array($fact->getTag(), WT_Gedcom_Tag::getReferenceFacts()) || !array_key_exists('extra_info', WT_Module::getActiveSidebars())) { - print_fact($fact, $controller->record); - } - } + print_fact($fact, $controller->record); } + //-- new fact link if ($controller->record->canEdit()) { print_add_new_fact($controller->record->getXref(), $indifacts, 'INDI'); } echo '</table>'; + return '<div id="'.$this->getName().'_content">'.ob_get_clean().'</div>'; } @@ -124,4 +184,325 @@ class personal_facts_WT_Module extends WT_Module implements WT_Module_Tab { public function getPreLoadContent() { return ''; } + + // Extra facts to be shown on this tabparent + private static function spouse_facts(WT_Individual $person, WT_Individual $spouse) { + global $SHOW_RELATIVES_EVENTS; + + $facts = array(); + if ($spouse && strstr($SHOW_RELATIVES_EVENTS, '_DEAT_SPOU')) { + // Only include events between birth and death + $birt_date = $person->getEstimatedBirthDate(); + $deat_date = $person->getEstimatedDeathDate(); + + foreach ($spouse->getFacts(WT_EVENTS_DEAT) as $fact) { + + $fact_date = $fact->getDate(); + if ($fact_date->isOK() && WT_Date::Compare($birt_date, $fact_date)<=0 && WT_Date::Compare($fact_date, $deat_date)<=0) { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_'.$fact->getTag().'_SPOU'); + $facts[] = $rela_fact; + } + } + } + + return $facts; + } + + private static function child_facts(WT_Individual $person, WT_Family $family, $option, $relation) { + global $SHOW_RELATIVES_EVENTS; + + $facts = array(); + + // Only include events between birth and death + $birt_date = $person->getEstimatedBirthDate(); + $deat_date = $person->getEstimatedDeathDate(); + + // Deal with recursion. + switch ($option) { + case '_CHIL': + // Add grandchildren + foreach ($family->getChildren() as $child) { + foreach ($child->getSpouseFamilies() as $cfamily) { + switch ($child->getSex()) { + case 'M': + foreach (self::child_facts($person, $cfamily, '_GCHI', 'son') as $fact) { + $facts[] = $fact; + } + break; + case 'F': + foreach (self::child_facts($person, $cfamily, '_GCHI', 'dau') as $fact) { + $facts[] = $fact; + } + break; + case 'U': + foreach (self::child_facts($person, $cfamily, '_GCHI', 'chi') as $fact) { + $facts[] = $fact; + } + break; + } + } + } + break; + } + + // For each child in the family + foreach ($family->getChildren() as $child) { + if ($child->getXref()==$person->getXref()) { + // We are not our own sibling! + continue; + } + // add child's birth + if (strpos($SHOW_RELATIVES_EVENTS, '_BIRT'.str_replace('_HSIB', '_SIBL', $option))!==false) { + foreach ($child->getFacts(WT_EVENTS_BIRT) as $fact) { + $sgdate=$fact->getDate(); + // Always show _BIRT_CHIL, even if the dates are not known + if ($option=='_CHIL' || $sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate)<=0 && WT_Date::Compare($sgdate, $deat_date)<=0) { + if ($option=='_GCHI' && $relation=='dau') { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . '_GCH1'); + $facts[] = $rela_fact; + } elseif ($option=='_GCHI' && $relation=='son') { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . '_GCH2'); + $facts[] = $rela_fact; + } else { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . $option); + $facts[] = $rela_fact; + } + } + } + } + // add child's death + if (strpos($SHOW_RELATIVES_EVENTS, '_DEAT'.str_replace('_HSIB', '_SIBL', $option))!==false) { + foreach ($child->getFacts(WT_EVENTS_DEAT) as $fact) { + $sgdate=$fact->getDate(); + $srec = $fact->getGedcom(); + if ($sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate)<=0 && WT_Date::Compare($sgdate, $deat_date)<=0) { + if ($option=='_GCHI' && $relation=='dau') { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . '_GCH1'); + $facts[] = $rela_fact; + } elseif ($option=='_GCHI' && $relation=='son') { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . '_GCH2'); + $facts[] = $rela_fact; + } else { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . $option); + $facts[] = $rela_fact; + } + } + } + } + // add child's marriage + if (strstr($SHOW_RELATIVES_EVENTS, '_MARR'.str_replace('_HSIB', '_SIBL', $option))) { + foreach ($child->getSpouseFamilies() as $sfamily) { + foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) { + $sgdate=$fact->getDate(); + if ($sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate)<=0 && WT_Date::Compare($sgdate, $deat_date)<=0) { + if ($option=='_GCHI' && $relation=='dau') { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . '_GCH1'); + $facts[] = $rela_fact; + } elseif ($option=='_GCHI' && $relation=='son') { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . '_GCH2'); + $facts[] = $rela_fact; + } else { + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_' . $fact->getTag() . $option); + $facts[] = $rela_fact; + } + } + } + } + } + } + + return $facts; + } + + private static function parent_facts(WT_Individual $person, $sosa) { + global $SHOW_RELATIVES_EVENTS; + + $facts = array(); + + if ($sosa==1) { + foreach ($person->getChildFamilies() as $family) { + // Add siblings + foreach (self::child_facts($person, $family, '_SIBL', '') as $fact) { + $facts[] = $fact; + } + foreach ($family->getSpouses() as $spouse) { + foreach ($spouse->getSpouseFamilies() as $sfamily) { + if (!$family->equals($sfamily)) { + // Add half-siblings + foreach (self::child_facts($person, $sfamily, '_HSIB', '') as $fact) { + $facts[] = $fact; + } + } + } + // Add grandparents + foreach (self::parent_facts($spouse, $spouse->getSex()=='F' ? 3 : 2) as $fact) { + $facts[] = $fact; + } + } + } + } + + // Only include events between birth and death + $birt_date=$person->getEstimatedBirthDate(); + $deat_date=$person->getEstimatedDeathDate(); + + foreach ($person->getChildFamilies() as $family) { + foreach ($family->getSpouses() as $parent) { + if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT'.($sosa==1 ? '_PARE' : '_GPAR'))) { + foreach ($parent->getFacts(WT_EVENTS_DEAT) as $fact) { + if ($fact->getDate()->isOK() && WT_Date::Compare($birt_date, $fact->getDate())<=0 && WT_Date::Compare($fact->getDate(), $deat_date)<=0) { + switch ($sosa) { + case 1: + // Convert the event to a close relatives event. + $rela_fact = clone($fact); + $rela_fact->setTag('_'.$fact->getTag().'_PARE'); + $facts[] = $rela_fact; + break; + case 2: + // Convert the event to a close relatives event + $rela_fact = clone($fact); + $rela_fact->setTag('_'.$fact->getTag().'_GPA1'); + $facts[] = $rela_fact; + break; + case 3: + // Convert the event to a close relatives event + $rela_fact = clone($fact); + $rela_fact->setTag('_'.$fact->getTag().'_GPA2'); + $facts[] = $rela_fact; + break; + } + } + } + } + } + + if ($sosa==1 && strstr($SHOW_RELATIVES_EVENTS, '_MARR_PARE')) { + // add father/mother marriages + foreach ($family->getSpouses() as $parent) { + foreach ($parent->getSpouseFamilies() as $sfamily) { + foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) { + if ($fact->getDate()->isOK() && WT_Date::Compare($birt_date, $fact->getDate())<=0 && WT_Date::Compare($fact->getDate(), $deat_date)<=0) { + if ($sfamily->equals($family)) { + if ($parent->getSex()=='F') { + // show current family marriage only once + continue; + } + // marriage of parents (to each other) + $rela_fact = clone($fact); + $rela_fact->setTag('_'.$fact->getTag().'_FAMC'); + $facts[] = $rela_fact; + break; + + } else { + // marriage of a parent (to another spouse) + // Convert the event to a close relatives event + $rela_fact = clone($fact); + $rela_fact->setTag('_'.$fact->getTag().'_PARE'); + $facts[] = $rela_fact; + } + } + } + } + } + } + } + + return $facts; + } + + private static function historical_facts(WT_Individual $person) { + global $SHOW_RELATIVES_EVENTS; + if (!$SHOW_RELATIVES_EVENTS) return; + + $facts = array(); + + // Only include events between birth and death + $birt_date = $person->getEstimatedBirthDate(); + $deat_date = $person->getEstimatedDeathDate(); + + if (file_exists(WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) { + require WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php'; + foreach ($histo as $hist) { + $sdate = new WT_Date(get_gedcom_value('DATE', 2, $hist)); + if ($sdate->isOK() && WT_Date::Compare($birt_date, $sdate)<=0 && WT_Date::Compare($sdate, $deat_date)<=0) { + $facts[] = new WT_Fact($hist, null, 'histo'); + } + } + } + + return $facts; + } + + private static function associate_facts(WT_Individual $person) { + $facts = array(); + + $associates=array_merge( + fetch_linked_indi($person->getXref(), 'ASSO', $person->getGedcomId()), + fetch_linked_indi($person->getXref(), '_ASSO', $person->getGedcomId()), + fetch_linked_fam ($person->getXref(), 'ASSO', $person->getGedcomId()), + fetch_linked_fam ($person->getXref(), '_ASSO', $person->getGedcomId()) + ); + foreach ($associates as $associate) { + foreach ($associate->getFacts() as $fact) { + $srec = $fact->getGedcom(); + foreach (array('ASSO', '_ASSO') as $asso_tag) { + $arec = get_sub_record(2, '2 ' . $asso_tag . ' @' . $person->getXref() . '@', $srec); + if ($arec) { + // Extract the important details from the fact + $factrec='1 '.$fact->getTag(); + if (preg_match('/\n2 DATE .*/', $srec, $match)) { + $factrec.=$match[0]; + } + if (preg_match('/\n2 PLAC .*/', $srec, $match)) { + $factrec.=$match[0]; + } + if ($associate instanceof WT_Family) { + foreach ($associate->getSpouses() as $spouse) { + $factrec.="\n2 $asso_tag @".$spouse->getXref().'@'; + } + } else { + $factrec.="\n2 $asso_tag @".$associate->getXref().'@'; + // CHR/BAPM events are commonly used. Generate the reverse relationship + if (preg_match('/^(?:BAPM|CHR)$/', $fact->getTag()) && preg_match('/3 RELA god(?:parent|mother|father)/', $fact->getGedcom())) { + switch ($associate->getSex()) { + case 'M': + $factrec.="\n3 RELA godson"; + break; + case 'F': + $factrec.="\n3 RELA goddaughter"; + break; + case 'U': + $factrec.="\n3 RELA godchild"; + break; + } + } + } + $facts[] = new WT_Fact($factrec, $associate, 'asso'); + } + } + } + } + + return $facts; + } } diff --git a/modules_v3/random_media/module.php b/modules_v3/random_media/module.php index 4175d11265..0abaceb0d4 100644 --- a/modules_v3/random_media/module.php +++ b/modules_v3/random_media/module.php @@ -94,13 +94,13 @@ class random_media_WT_Module extends WT_Module implements WT_Module_Block { while ($all_media) { $n=array_rand($all_media); $media=WT_Media::getInstance($all_media[$n]); - if ($media->canDisplayDetails() && !$media->isExternal()) { + if ($media->canShow() && !$media->isExternal()) { // Check if it is linked to a suitable individual foreach ($media->fetchLinkedIndividuals() as $indi) { if ( $filter=='all' || - $filter=='indi' && strpos($indi->getGedcomRecord(), "\n1 OBJE @" . $media->getXref() . '@') !==false || - $filter=='event' && strpos($indi->getGedcomRecord(), "\n2 OBJE @" . $media->getXref() . '@') !==false + $filter=='indi' && strpos($indi->getGedcom(), "\n1 OBJE @" . $media->getXref() . '@') !==false || + $filter=='event' && strpos($indi->getGedcom(), "\n2 OBJE @" . $media->getXref() . '@') !==false ) { // Found one :-) $random_media=$media; @@ -187,7 +187,7 @@ class random_media_WT_Module extends WT_Module implements WT_Module_Block { $content .= '<a href="' . $source->getHtmlUrl() . '">' . WT_I18N::translate('View Source') . ' — ' . $source->getFullname().'</a><br>'; } $content .= '<br><div class="indent">'; - $content .= print_fact_notes($random_media->getGedcomRecord(), "1", false, true); + $content .= print_fact_notes($random_media->getGedcom(), "1", false, true); $content .= '</div>'; $content .= '</td></tr></table>'; $content .= '</div>'; // random_picture_content diff --git a/modules_v3/relatives/module.php b/modules_v3/relatives/module.php index 557422cd00..16f450c8ec 100644 --- a/modules_v3/relatives/module.php +++ b/modules_v3/relatives/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -48,232 +48,167 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { return 20; } - function printFamilyHeader($url, $label) { - echo '<table><tr>'; - echo '<td><i class="icon-cfamily"></i></td>'; - echo '<td><span class="subheaders">', $label, '</span>'; - echo ' - <a href="', $url, '">', WT_I18N::translate('View Family'), '</a></td>'; - echo '</tr></table>'; - } - - /** - * print parents informations - * @param Family family - * @param Array people - * @param String family type - * @return html table rows - */ - function printParentsRows($family, $people, $type) { - global $personcount, $SHOW_PEDIGREE_PLACES, $controller, $SEARCH_SPIDER; + // print parents informations + function printFamily(WT_Family $family, $type, $label) { + global $controller; + global $personcount; // TODO: use a unique id instead? - $elderdate = ""; - //-- new father/husband - $styleadd = ""; - if (isset($people["newhusb"])) { - $styleadd = "red"; - ?> + ?> + <table> <tr> - <td class="facts_labelblue"><?php echo $people["newhusb"]->getLabel(); ?></td> - <td class="<?php echo $controller->getPersonStyle($people["newhusb"]); ?>"> - <?php print_pedigree_person($people["newhusb"], 2, 0, $personcount++); ?> + <td> + <i class="icon-cfamily"></i> + </td> + <td> + <span class="subheaders"> <?php echo $label; ?> </span> - + <a href="<?php echo $family->getHtmlUrl() ; ?>"><?php echo WT_I18N::translate('View Family'); ?></a> </td> </tr> - <?php - $elderdate = $people["newhusb"]->getBirthDate(); - } - //-- father/husband - if (isset($people["husb"])) { + </table> + <table class="facts_table"> + <?php + + ///// HUSB ///// + $found = false; + foreach ($family->getFacts('HUSB') as $fact) { + $found |= !$fact->isOld(); + if ($fact->isNew()) { + $class = 'facts_label new'; + } elseif ($fact->isOld()) { + $class = 'facts_label old'; + } else { + $class = 'facts_label'; + } + $person = $fact->getTarget(); + if ($person->equals($controller->record)) { + $label = '<i class="icon-selected"></i>'; + } else { + $label = get_relationship_name(get_relationship($controller->record, $person, true, 3)); + } ?> <tr> - <td class="facts_label<?php echo $styleadd; ?>"><?php echo $people["husb"]->getLabel(); ?></td> - <td class="<?php echo $controller->getPersonStyle($people["husb"]); ?>"> - <?php print_pedigree_person($people["husb"], 2, 0, $personcount++); ?> + <td class="<?php echo $class; ?>"> + <?php echo $label; ?> + </td> + <td class="<?php echo $controller->getPersonStyle($person); ?>"> + <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php - $elderdate = $people["husb"]->getBirthDate(); - } - //-- missing father - if ($type=="parents" && !isset($people["husb"]) && !isset($people["newhusb"])) { - if ($controller->record->canEdit()) { - ?> - <tr> - <td class="facts_label"><?php echo WT_I18N::translate('Add a new father'); ?></td> - <td class="facts_value"><a href="#" onclick="return addnewparentfamily('<?php echo $controller->record->getXref(); ?>', 'HUSB', '<?php echo $family->getXref(); ?>');"><?php echo WT_I18N::translate('Add a new father'); ?></a></td> - </tr> - <?php - } - } - //-- missing husband - if ($type=="spouse" && !isset($people["husb"]) && !isset($people["newhusb"])) { - if ($controller->record->canEdit()) { - ?> - <tr> - <td class="facts_label"><?php echo WT_I18N::translate('Add husband'); ?></td> - <td class="facts_value"><a href="#" onclick="return addnewspouse('<?php echo $family->getXref(); ?>', 'HUSB');"><?php echo WT_I18N::translate('Add a husband to this family'); ?></a></td> - </tr> - <?php - } } - //-- new mother/wife - $styleadd = ""; - if (isset($people["newwife"])) { - $styleadd = "red"; + if (!$found && $family->canEdit()) { ?> <tr> - <td class="facts_labelblue"><?php echo $people["newwife"]->getLabel($elderdate); ?></td> - <td class="<?php echo $controller->getPersonStyle($people["newwife"]); ?>"> - <?php print_pedigree_person($people["newwife"], 2, 0, $personcount++); ?> - </td> + <td class="facts_label"><?php echo WT_I18N::translate('Add husband'); ?></td> + <td class="facts_value"><a href="#" onclick="return addnewspouse('<?php echo $family->getXref(); ?>', 'HUSB');"><?php echo WT_I18N::translate('Add a husband to this family'); ?></a></td> </tr> <?php } - //-- mother/wife - if (isset($people["wife"])) { + + ///// MARR ///// + $found = false; + foreach ($family->getFacts('MARR|_NMR') as $fact) { + $found |= !$fact->isOld(); + if ($fact->isNew()) { + $class = 'facts_label new'; + } elseif ($fact->isOld()) { + $class = 'facts_label old'; + } else { + $class = 'facts_label'; + } ?> <tr> - <td class="facts_label<?php echo $styleadd; ?>"><?php echo $people["wife"]->getLabel($elderdate); ?></td> - <td class="<?php echo $controller->getPersonStyle($people["wife"]); ?>"> - <?php print_pedigree_person($people["wife"], 2, 0, $personcount++); ?> + <td class="facts_label"> + + </td> + <td class="facts_value"> + <?php echo WT_Gedcom_Tag::getLabelValue($fact->getTag(), $fact->getPlace() . ' — ' . $fact->getDate()->Display(false)); ?> </td> </tr> <?php } - //-- missing mother - if ($type=="parents" && !isset($people["wife"]) && !isset($people["newwife"])) { - if ($controller->record->canEdit()) { - ?> - <tr> - <td class="facts_label"><?php echo WT_I18N::translate('Add a new mother'); ?></td> - <td class="facts_value"><a href="#" onclick="return addnewparentfamily('<?php echo $controller->record->getXref(); ?>', 'WIFE', '<?php echo $family->getXref(); ?>');"><?php echo WT_I18N::translate('Add a new mother'); ?></a></td> - </tr> - <?php - } - } - //-- missing wife - if ($type=="spouse" && !isset($people["wife"]) && !isset($people["newwife"])) { - if ($controller->record->canEdit()) { - ?> - <tr> - <td class="facts_label"><?php echo WT_I18N::translate('Add wife'); ?></td> - <td class="facts_value"><a href="#" onclick="return addnewspouse('<?php echo $family->getXref(); ?>', 'WIFE');"><?php echo WT_I18N::translate('Add a wife to this family'); ?></a></td> - </tr> - <?php - } - } - //-- marriage row - if ($family->getMarriageRecord()!="" || WT_USER_CAN_EDIT) { + if (!$found && $family->canEdit()) { + // Add a new marriage ?> <tr> <td class="facts_label"> </td> <td class="facts_value"> - <?php $marr_type = strtoupper($family->getMarriageType()); - if ($marr_type=='CIVIL' || $marr_type=='PARTNERS' || $marr_type=='RELIGIOUS' || $marr_type=='UNKNOWN') { - $marr_fact = 'MARR_' . $marr_type; - } else { - $marr_fact = 'MARR'; - } - $famid = $family->getXref(); - $place = $family->getMarriagePlace(); - $date = $family->getMarriageDate(); - if ($date && $date->isOK() || $place) { - if ($date) { - $details=$date->Display(false); - } - if ($place) { - if ($details) { - $details .= ' — '; - } - $tmp=new WT_Place($place, WT_GED_ID); - $details .= $tmp->getShortName(); - } - echo WT_Gedcom_Tag::getLabelValue('MARR', $details); - } else if (get_sub_record(1, "1 _NMR", find_family_record($famid, WT_GED_ID))) { - $husb = $family->getHusband(); - $wife = $family->getWife(); - if (empty($wife) && !empty($husb)) { - echo WT_Gedcom_Tag::getLabel('_NMR', $husb); - } elseif (empty($husb) && !empty($wife)) { - echo WT_Gedcom_Tag::getLabel('_NMR', $wife); - } else { - echo WT_Gedcom_Tag::getLabel('_NMR'); - } - } else if ($family->getMarriageRecord()=="" && $controller->record->canEdit()) { - echo "<a href=\"#\" onclick=\"return add_new_record('".$famid."', 'MARR');\">".WT_I18N::translate('Add marriage details')."</a>"; - } else { - echo WT_Gedcom_Tag::getLabelValue($marr_fact, WT_I18N::translate('yes')); - } - ?> + <a href="#" onclick="return add_new_record('<?php echo $family->getXref(); ?>', 'MARR');"> + <?php echo WT_I18N::translate('Add marriage details'); ?> + </a> </td> </tr> <?php } - } - - /** - * print children informations - * @param Family family - * @param Array people - * @param String family type - * @return html table rows - */ - function printChildrenRows($family, $people, $type) { - global $personcount, $controller; - $elderdate = $family->getMarriageDate(); - $key=0; - foreach ($people["children"] as $child) { - $label = $child->getLabel(); - $styleadd = ""; + ///// WIFE ///// + $found = false; + foreach ($family->getFacts('WIFE') as $fact) { + $found |= !$fact->isOld(); + if ($fact->isNew()) { + $class = 'facts_label new'; + } elseif ($fact->isOld()) { + $class = 'facts_label old'; + } else { + $class = 'facts_label'; + } + $person = $fact->getTarget(); + if ($person->equals($controller->record)) { + $label = '<i class="icon-selected"></i>'; + } else { + $label = get_relationship_name(get_relationship($controller->record, $person, true, 3)); + } ?> <tr> - <td class="facts_label<?php echo $styleadd; ?>"><?php if ($styleadd=="red") echo $child->getLabel(); else echo $child->getLabel($elderdate, $key+1); ?></td> - <td class="<?php echo $controller->getPersonStyle($child); ?>"> - <?php - print_pedigree_person($child, 2, 0, $personcount++); - ?> + <td class="<?php echo $class; ?>"> + <?php echo $label; ?> + </td> + <td class="<?php echo $controller->getPersonStyle($person); ?>"> + <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php - $elderdate = $child->getBirthDate(); - ++$key; } - foreach ($people["newchildren"] as $child) { - $label = $child->getLabel(); - $styleadd = "blue"; + if (!$found && $family->canEdit()) { ?> <tr> - <td class="facts_label<?php echo $styleadd; ?>"><?php if ($styleadd=="red") echo $child->getLabel(); else echo $child->getLabel($elderdate, $key+1); ?></td> - <td class="<?php echo $controller->getPersonStyle($child); ?>"> - <?php - print_pedigree_person($child, 2, 0, $personcount++); - ?> - </td> + <td class="facts_label"><?php echo WT_I18N::translate('Add wife'); ?></td> + <td class="facts_value"><a href="#" onclick="return addnewspouse('<?php echo $family->getXref(); ?>', 'WIFE');"><?php echo WT_I18N::translate('Add a wife to this family'); ?></a></td> </tr> <?php - $elderdate = $child->getBirthDate(); - ++$key; } - foreach ($people["delchildren"] as $child) { - $label = $child->getLabel(); - $styleadd = "red"; + + ///// CHIL ///// + foreach ($family->getFacts('CHIL') as $fact) { + if ($fact->isNew()) { + $class = 'facts_label new'; + } elseif ($fact->isOld()) { + $class = 'facts_label old'; + } else { + $class = 'facts_label'; + } + $person = $fact->getTarget(); + if ($person->equals($controller->record)) { + $label = '<i class="icon-selected"></i>'; + } else { + $label = get_relationship_name(get_relationship($controller->record, $person, true, 3)); + } ?> <tr> - <td class="facts_label<?php echo $styleadd; ?>"><?php if ($styleadd=="red") echo $child->getLabel(); else echo $child->getLabel($elderdate, $key+1); ?></td> - <td class="<?php echo $controller->getPersonStyle($child); ?>"> - <?php - print_pedigree_person($child, 2, 0, $personcount++); - ?> + <td class="<?php echo $class; ?>"> + <?php echo $label; ?> + </td> + <td class="<?php echo $controller->getPersonStyle($person); ?>"> + <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php - $elderdate = $child->getBirthDate(); - ++$key; } - if (isset($family) && $controller->record->canEdit()) { - if ($type == "spouse") { + // Re-order children / add a new child + if ($family->canEdit()) { + if ($type == 'FAMS') { $child_u = WT_I18N::translate('Add a new son or daughter'); $child_m = WT_I18N::translate('son'); $child_f = WT_I18N::translate('daughter'); @@ -282,10 +217,10 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { $child_m = WT_I18N::translate('brother'); $child_f = WT_I18N::translate('sister'); } - ?> + ?> <tr> <td class="facts_label"> - <?php if (WT_USER_CAN_EDIT && isset($people["children"][1])) { ?> + <?php if (count($family->getChildren())>1) { ?> <a href="#" onclick="reorder_children('<?php echo $family->getXref(); ?>');tabswitch(5);"><i class="icon-media-shuffle"></i> <?php echo WT_I18N::translate('Re-order children'); ?></a> <?php } ?> </td> @@ -299,6 +234,10 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { </tr> <?php } + + echo '</table>'; + + return; } // Implement WT_Module_Tab @@ -320,60 +259,38 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { <?php $personcount=0; $families = $controller->record->getChildFamilies(); - if (count($families)==0) { - if ($controller->record->canEdit()) { - ?> - <table class="facts_table"> - <tr> - <td class="facts_value"><a href="#" onclick="return addnewparent('<?php echo $controller->record->getXref(); ?>', 'HUSB');"><?php echo WT_I18N::translate('Add a new father'); ?></td> - </tr> - <tr> - <td class="facts_value"><a href="#" onclick="return addnewparent('<?php echo $controller->record->getXref(); ?>', 'WIFE');"><?php echo WT_I18N::translate('Add a new mother'); ?></a></td> - </tr> - </table> - <?php - } + if (!$families && $controller->record->canEdit()) { + ?> + <table class="facts_table"> + <tr> + <td class="facts_value"><a href="#" onclick="return addnewparent('<?php echo $controller->record->getXref(); ?>', 'HUSB');"><?php echo WT_I18N::translate('Add a new father'); ?></td> + </tr> + <tr> + <td class="facts_value"><a href="#" onclick="return addnewparent('<?php echo $controller->record->getXref(); ?>', 'WIFE');"><?php echo WT_I18N::translate('Add a new mother'); ?></a></td> + </tr> + </table> + <?php } // parents foreach ($families as $family) { - $people = $controller->buildFamilyList($family, "parents"); - $this->printFamilyHeader($family->getHtmlUrl(), $controller->record->getChildFamilyLabel($family)); - echo '<table class="facts_table">'; - $this->printParentsRows($family, $people, "parents"); - $this->printChildrenRows($family, $people, "parents"); - echo '</table>'; + $this->printFamily($family, 'FAMC', $controller->record->getChildFamilyLabel($family)); } // step-parents foreach ($controller->record->getChildStepFamilies() as $family) { - $people = $controller->buildFamilyList($family, "step-parents"); - $this->printFamilyHeader($family->getHtmlUrl(), $controller->record->getStepFamilyLabel($family)); - echo '<table class="facts_table">'; - $this->printParentsRows($family, $people, "parents"); - $this->printChildrenRows($family, $people, "parents"); - echo '</table>'; + $this->printFamily($family, 'FAMC', $controller->record->getStepFamilyLabel($family)); } // spouses $families = $controller->record->getSpouseFamilies(); foreach ($families as $family) { - $people = $controller->buildFamilyList($family, "spouse"); - $this->printFamilyHeader($family->getHtmlUrl(), $controller->record->getSpouseFamilyLabel($family)); - echo '<table class="facts_table">'; - $this->printParentsRows($family, $people, "spouse"); - $this->printChildrenRows($family, $people, "spouse"); - echo '</table>'; + $this->printFamily($family, 'FAMS', $controller->record->getSpouseFamilyLabel($family)); } // step-children foreach ($controller->record->getSpouseStepFamilies() as $family) { - $people = $controller->buildFamilyList($family, "step-children"); - $this->printFamilyHeader($family->getHtmlUrl(), $family->getFullName()); - echo '<table class="facts_table">'; - $this->printParentsRows($family, $people, "spouse"); - $this->printChildrenRows($family, $people, "spouse"); - echo '</table>'; + $this->printFamily($family, 'FAMS', $family->getFullName()); } if (!$SHOW_AGE_DIFF) { @@ -407,11 +324,6 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { <a href="#" onclick="return linkspouse('<?php echo $controller->record->getXref(); ?>','WIFE');"><?php echo WT_I18N::translate('Add a wife using an existing person'); ?></a> </td> </tr> - <tr> - <td class="facts_value"> - <a href="#" onclick="return add_fams('<?php echo $controller->record->getXref(); ?>','HUSB');"><?php echo WT_I18N::translate('Link this person to an existing family as a husband'); ?></a> - </td> - </tr> <?php } if ($controller->record->getSex()!="M") { ?> <tr> @@ -424,11 +336,6 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { <a href="#" onclick="return linkspouse('<?php echo $controller->record->getXref(); ?>','HUSB');"><?php echo WT_I18N::translate('Add a husband using an existing person'); ?></a> </td> </tr> - <tr> - <td class="facts_value"> - <a href="#" onclick="return add_fams('<?php echo $controller->record->getXref(); ?>','WIFE');"><?php echo WT_I18N::translate('Link this person to an existing family as a wife'); ?></a> - </td> - </tr> <?php } ?> <tr> <td class="facts_value"> diff --git a/modules_v3/review_changes/module.php b/modules_v3/review_changes/module.php index 3d6e3206c2..e09f2a413a 100644 --- a/modules_v3/review_changes/module.php +++ b/modules_v3/review_changes/module.php @@ -119,7 +119,7 @@ class review_changes_WT_Module extends WT_Module implements WT_Module_Block { )->execute(array(WT_GED_ID))->fetchAll(); foreach ($changes as $change) { $record=WT_GedcomRecord::getInstance($change->xref); - if ($record->canDisplayDetails()) { + if ($record->canShow()) { $content.='<b>'.$record->getFullName().'</b>'; $content.=$block ? '<br>' : ' '; $content.='<a href="'.$record->getHtmlUrl().'">'.WT_I18N::translate('View the changes').'</a>'; diff --git a/modules_v3/sitemap/module.php b/modules_v3/sitemap/module.php index 35c70ba21c..51072b398e 100644 --- a/modules_v3/sitemap/module.php +++ b/modules_v3/sitemap/module.php @@ -130,67 +130,67 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config { switch ($rec_type) { case 'i': $rows=WT_DB::prepare( - "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". + "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom". " FROM `##individuals`". " WHERE i_file=?". " ORDER BY i_id". " LIMIT ".self::RECORDS_PER_VOLUME." OFFSET ".($volume*self::RECORDS_PER_VOLUME) - )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); + )->execute(array($ged_id))->fetchAll(); foreach ($rows as $row) { - $records[]=WT_Person::getInstance($row); + $records[]=WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } break; case 's': $rows=WT_DB::prepare( - "SELECT 'SOUR' AS type, s_id AS xref, s_file AS ged_id, s_gedcom AS gedrec". + "SELECT s_id AS xref, s_file AS gedcom_id, s_gedcom AS gedcom". " FROM `##sources`". " WHERE s_file=?". " ORDER BY s_id". " LIMIT ".self::RECORDS_PER_VOLUME." OFFSET ".($volume*self::RECORDS_PER_VOLUME) - )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); + )->execute(array($ged_id))->fetchAll(); foreach ($rows as $row) { - $records[]=WT_Source::getInstance($row); + $records[]=WT_Source::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } break; case 'r': $rows=WT_DB::prepare( - "SELECT 'REPO' AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec". + "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom". " FROM `##other`". " WHERE o_file=? AND o_type='REPO'". " ORDER BY o_id". " LIMIT ".self::RECORDS_PER_VOLUME." OFFSET ".($volume*self::RECORDS_PER_VOLUME) - )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); + )->execute(array($ged_id))->fetchAll(); foreach ($rows as $row) { - $records[]=WT_Repository::getInstance($row); + $records[]=WT_Repository::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } break; case 'n': $rows=WT_DB::prepare( - "SELECT 'NOTE' AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec". + "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom". " FROM `##other`". " WHERE o_file=? AND o_type='NOTE'". " ORDER BY o_id". " LIMIT ".self::RECORDS_PER_VOLUME." OFFSET ".($volume*self::RECORDS_PER_VOLUME) - )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); + )->execute(array($ged_id))->fetchAll(); foreach ($rows as $row) { - $records[]=WT_Note::getInstance($row); + $records[]=WT_Note::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } break; case 'm': $rows=WT_DB::prepare( - "SELECT 'OBJE' AS type, m_id AS xref, m_file AS ged_id, m_gedcom AS gedrec, m_titl, m_filename". + "SELECT m_id AS xref, m_file AS gedcom_id, m_gedcom AS gedcom". " FROM `##media`". " WHERE m_file=?". " ORDER BY m_id". " LIMIT ".self::RECORDS_PER_VOLUME." OFFSET ".($volume*self::RECORDS_PER_VOLUME) - )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); + )->execute(array($ged_id))->fetchAll(); foreach ($rows as $row) { - $records[]=WT_Media::getInstance($row); + $records[]=WT_Media::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } break; } foreach ($records as $record) { - if ($record->canDisplayName()) { + if ($record->canShowName()) { $data.='<url>'; $data.='<loc>'.WT_SERVER_NAME.WT_SCRIPT_PATH.$record->getHtmlUrl().'</loc>'; $chan=$record->getChangeEvent(); diff --git a/modules_v3/sources_tab/module.php b/modules_v3/sources_tab/module.php index da493e3b50..d1644cf362 100644 --- a/modules_v3/sources_tab/module.php +++ b/modules_v3/sources_tab/module.php @@ -29,6 +29,8 @@ if (!defined('WT_WEBTREES')) { } class sources_tab_WT_Module extends WT_Module implements WT_Module_Tab { + private $facts; + // Extend WT_Module public function getTitle() { return /* I18N: Name of a module */ WT_I18N::translate('Sources'); @@ -44,49 +46,60 @@ class sources_tab_WT_Module extends WT_Module implements WT_Module_Tab { return 30; } - protected $sourceCount = null; + // Implement WT_Module_Tab + public function hasTabContent() { + return WT_USER_CAN_EDIT || $this->get_facts(); + } // Implement WT_Module_Tab + public function isGrayedOut() { + return !$this->get_facts(); + } + // Implement WT_Module_Tab public function getTabContent() { global $SHOW_LEVEL2_NOTES, $NAV_SOURCES, $controller; ob_start(); + echo '<table class="facts_table">'; + ?> + <tr> + <td colspan="2" class="descriptionbox rela"> + <input id="checkbox_sour2" type="checkbox" <?php if ($SHOW_LEVEL2_NOTES) echo " checked=\"checked\""; ?> onclick="jQuery('tr.row_sour2').toggle();"> + <label for="checkbox_sour2"><?php echo WT_I18N::translate('Show all sources'), help_link('show_fact_sources'); ?></label> + </td> + </tr> + <?php + foreach ($this->get_facts() as $fact) { + if ($fact->getTag() == 'SOUR') { + print_main_sources($fact, 1); + } else { + for ($i=2; $i<4; ++$i) { + print_main_sources($fact, $i); + } + } + } + if (!$this->get_facts()) { + echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', WT_I18N::translate('There are no Source citations for this individual.'), '</td></tr>'; + } + + // New Source Link + if ($controller->record->canEdit()) { ?> - <table class="facts_table"> <tr> - <td colspan="2" class="descriptionbox rela"> - <input id="checkbox_sour2" type="checkbox" <?php if ($SHOW_LEVEL2_NOTES) echo " checked=\"checked\""; ?> onclick="jQuery('tr.row_sour2').toggle();"> - <label for="checkbox_sour2"><?php echo WT_I18N::translate('Show all sources'), help_link('show_fact_sources'); ?></label> + <td class="facts_label"> + <?php echo WT_Gedcom_Tag::getLabel('SOUR'); ?> </td> - </tr> - <?php - $otheritems = $controller->getOtherFacts(); - foreach ($otheritems as $event) { - if ($event->getTag()=='SOUR') { - print_main_sources($event, 1); - } - } - // 2nd level sources [ 1712181 ] - $controller->record->add_family_facts(false); - foreach ($controller->getIndiFacts() as $event) { - print_main_sources($event, 2); - } - if ($this->get_source_count()==0) echo "<tr><td id=\"no_tab3\" colspan=\"2\" class=\"facts_value\">".WT_I18N::translate('There are no Source citations for this individual.')."</td></tr>"; - //-- New Source Link - if ($controller->record->canEdit()) { - ?> - <tr> - <td class="facts_label"><?php echo WT_Gedcom_Tag::getLabel('SOUR'); ?></td> - <td class="facts_value"> - <a href="#" onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','SOUR'); return false;"><?php echo WT_I18N::translate('Add a new source citation'); ?></a> + <td class="facts_value"> + <a href="#" onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','SOUR'); return false;"> + <?php echo WT_I18N::translate('Add a new source citation'); ?> + </a> <?php echo help_link('add_source'); ?> - </td> - </tr> + </td> + </tr> <?php - } + } ?> </table> - <br> <?php if (!$SHOW_LEVEL2_NOTES) { echo '<script>jQuery("tr.row_sour2").toggle();</script>'; @@ -94,27 +107,29 @@ class sources_tab_WT_Module extends WT_Module implements WT_Module_Tab { return '<div id="'.$this->getName().'_content">'.ob_get_clean().'</div>'; } - function get_source_count() { + function get_facts() { global $controller; - if ($this->sourceCount===null) { - $ct = preg_match_all("/\d SOUR @(.*)@/", $controller->record->getGedcomRecord(), $match, PREG_SET_ORDER); - foreach ($controller->record->getSpouseFamilies() as $sfam) - $ct += preg_match("/\d SOUR /", $sfam->getGedcomRecord()); - $this->sourceCount = $ct; + if ($this->facts === null) { + $facts = $controller->record->getFacts(); + foreach ($controller->record->getSpouseFamilies() as $family) { + if ($family->canShow()) { + foreach ($family->getFacts() as $fact) { + $facts[] = $fact; } - return $this->sourceCount; + } + } + $this->facts = array(); + foreach ($facts as $fact) { + if (preg_match('/(?:^1|\n\d) SOUR/', $fact->getGedcom())) { + $this->facts[] = $fact; + } + } + } + return $this->facts; } // Implement WT_Module_Tab - public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->get_source_count()>0; - } - // Implement WT_Module_Tab - public function isGrayedOut() { - return $this->get_source_count()==0; - } - // Implement WT_Module_Tab public function canLoadAjax() { global $SEARCH_SPIDER; diff --git a/modules_v3/stories/module.php b/modules_v3/stories/module.php index c3e3d082ed..77dcb2ee20 100644 --- a/modules_v3/stories/module.php +++ b/modules_v3/stories/module.php @@ -252,7 +252,7 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ echo '<input type="text" name="xref" id="pid" size="4" value="'.$xref.'">'; echo print_findindi_link('pid'); if ($xref) { - $person=WT_Person::getInstance($xref); + $person=WT_Individual::getInstance($xref); if ($person) { echo ' ', $person->format_list('span'); } @@ -355,7 +355,7 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ echo '<tbody>'; foreach ($stories as $story) { $story_title = get_block_setting($story->block_id, 'title'); - $indi=WT_Person::getInstance($story->xref); + $indi=WT_Individual::getInstance($story->xref); if ($indi) { echo '<tr><td><a href="', $indi->getHtmlUrl().'#stories">', $story_title, '<a></td> <td><a href="', $indi->getHtmlUrl().'#stories">'.$indi->getFullName(), '</a></td>'; @@ -417,12 +417,12 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ </tr></thead> <tbody>'; foreach ($stories as $story) { - $indi=WT_Person::getInstance($story->xref); + $indi=WT_Individual::getInstance($story->xref); $story_title = get_block_setting($story->block_id, 'title'); $languages=get_block_setting($story->block_id, 'languages'); if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) { if ($indi) { - if ($indi->canDisplayDetails()) { + if ($indi->canShow()) { echo '<tr><td><a href="'.$indi->getHtmlUrl().'#stories">'.$story_title.'</a></td><td><a href="'.$indi->getHtmlUrl().'#stories">'.$indi->getFullName().'</a></td></tr>'; } } else { diff --git a/modules_v3/todo/module.php b/modules_v3/todo/module.php index 3ccb2f21ac..21b919c3fd 100644 --- a/modules_v3/todo/module.php +++ b/modules_v3/todo/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -105,7 +105,7 @@ class todo_WT_Module extends WT_Module implements WT_Module_Block { $end_jd=$show_future ? 99999999 : WT_CLIENT_JD; foreach (get_calendar_events(0, $end_jd, '_TODO', WT_GED_ID) as $todo) { $record=WT_GedcomRecord::getInstance($todo['id']); - if ($record && $record->canDisplayDetails()) { + if ($record && $record->canShow()) { $user_name = preg_match('/\n2 _WT_USER (.+)/', $todo['factrec'], $match) ? $match[1] : ''; if ($user_name==WT_USER_NAME || !$user_name && $show_unassigned || $user_name && $show_other) { $content.='<tr>'; diff --git a/modules_v3/top10_pageviews/module.php b/modules_v3/top10_pageviews/module.php index 54891ebe87..d0bbc7595c 100644 --- a/modules_v3/top10_pageviews/module.php +++ b/modules_v3/top10_pageviews/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -80,7 +80,7 @@ class top10_pageviews_WT_Module extends WT_Module implements WT_Module_Block { } foreach ($top10 as $id=>$count) { $record=WT_GedcomRecord::getInstance($id); - if ($record && $record->canDisplayDetails()) { + if ($record && $record->canShow()) { $content .= '<tr valign="top">'; if ($count_placement=='before') { $content .= '<td dir="ltr" align="right">['.$count.']</td>'; diff --git a/modules_v3/top10_surnames/module.php b/modules_v3/top10_surnames/module.php index 5a9e8d1620..63a4b7622f 100644 --- a/modules_v3/top10_surnames/module.php +++ b/modules_v3/top10_surnames/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay diff --git a/modules_v3/tree/class_treeview.php b/modules_v3/tree/class_treeview.php index 07065fbdf8..81cb5ef422 100644 --- a/modules_v3/tree/class_treeview.php +++ b/modules_v3/tree/class_treeview.php @@ -55,7 +55,7 @@ class TreeView { * @param string $rootPersonId the id of the root person * @param int $generations number of generations to draw */ - public function drawViewport(WT_Person $rootPerson, $generations) { + public function drawViewport(WT_Individual $rootPerson, $generations) { global $GEDCOM, $controller; if (WT_SCRIPT_NAME == 'individual.php') { @@ -118,7 +118,7 @@ class TreeView { */ public function getDetails($pid) { - $person = WT_Person::getInstance($pid); + $person = WT_Individual::getInstance($pid); $r = $this->getPersonDetails($person, $person, null); foreach ($person->getSpouseFamilies() as $family) { if (!empty($family)) { @@ -309,7 +309,7 @@ class TreeView { /** * Draw a person name preceded by sex icon, with parents as tooltip - * @param WT_Person $p a person + * @param WT_Individual $p a person * @param $dashed if = 'dashed' print dashed top border to separate multiple spuses */ private function drawPersonName($p, $dashed='') { diff --git a/modules_v3/user_blog/module.php b/modules_v3/user_blog/module.php index 74af7cad48..4eaf49915a 100644 --- a/modules_v3/user_blog/module.php +++ b/modules_v3/user_blog/module.php @@ -86,8 +86,7 @@ class user_blog_WT_Module extends WT_Module implements WT_Module_Block { $content .= "<div class=\"news_date\">".format_timestamp($news['date']).'</div>'; if ($news["text"]==strip_tags($news["text"])) { // No HTML? - // PHP5.3 $news["text"]=nl2br($news["text"], false); - $news["text"]=nl2br($news["text"]); + $news["text"]=nl2br($news["text"], false); } $content .= $news["text"]."<br><br>"; $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?news_id='+".$key.", '_blank', indx_window_specs); return false;\">".WT_I18N::translate('Edit')."</a> | "; diff --git a/modules_v3/user_favorites/module.php b/modules_v3/user_favorites/module.php index 662a359678..deb741f806 100644 --- a/modules_v3/user_favorites/module.php +++ b/modules_v3/user_favorites/module.php @@ -67,10 +67,10 @@ class user_favorites_WT_Module extends gedcom_favorites_WT_Module { case 'menu-add-favorite': // Process the "add to user favorites" menu item on indi/fam/etc. pages $record=WT_GedcomRecord::getInstance(safe_POST_xref('xref')); - if (WT_USER_ID && $record->canDisplayName()) { + if (WT_USER_ID && $record->canShowName()) { self::addFavorite(array( 'user_id' =>WT_USER_ID, - 'gedcom_id'=>$record->getGedId(), + 'gedcom_id'=>$record->getGedcomId(), 'gid' =>$record->getXref(), 'type' =>$record::RECORD_TYPE, 'url' =>null, diff --git a/modules_v3/user_messages/module.php b/modules_v3/user_messages/module.php index f9025b6dd7..95f304565e 100644 --- a/modules_v3/user_messages/module.php +++ b/modules_v3/user_messages/module.php @@ -109,8 +109,7 @@ class user_messages_WT_Module extends WT_Module implements WT_Module_Block { $content.='</td>'; $content.='</tr>'; $content.='<tr><td class="list_value_wrap" colspan="5"><div id="message'.$message->message_id.'" style="display:none;">'; - // PHP5.3 $content.=expand_urls(nl2br(htmlspecialchars($message->body), false)).'<br><br>'; - $content.=expand_urls(nl2br(htmlspecialchars($message->body))).'<br><br>'; + $content.=expand_urls(nl2br(htmlspecialchars($message->body), false)).'<br><br>'; if (strpos($message->subject, /* I18N: When replying to an email, the subject becomes “RE: <subject>” */ WT_I18N::translate('RE: '))!==0) { $message->subject= WT_I18N::translate('RE: ').$message->subject; } |
