From cf193a28e987c1f86cf8abe0f28c0aaf14f2a34d Mon Sep 17 00:00:00 2001 From: Nigel Osborne Date: Thu, 24 Nov 2011 01:35:35 +0000 Subject: Change fam-list function to use a variable rather than echoing every cell --- includes/functions/functions_print_lists.php | 228 ++++++++++++++------------- 1 file changed, 115 insertions(+), 113 deletions(-) (limited to 'includes') diff --git a/includes/functions/functions_print_lists.php b/includes/functions/functions_print_lists.php index 61c33605c9..9195d957a2 100644 --- a/includes/functions/functions_print_lists.php +++ b/includes/functions/functions_print_lists.php @@ -271,7 +271,7 @@ function format_indi_table($datalist, $option='') { $html .= ''. highlight_search_hits($name['full']). ''. $sex_image. '
'; } // Indi parents - $html .= $person->getPrimaryParentsNames("parents_indi_list_table_".$table_id." details1", 'none'); + $html .= $person->getPrimaryParentsNames('parents_indi_list_table_'.$table_id.' details1', 'none'); $html .= ''; // Dummy column to match colspan in header $html .= ''; @@ -453,10 +453,11 @@ function format_indi_table($datalist, $option='') { } // print a table of families -function print_fam_table($datalist, $option='') { +function format_fam_table($datalist, $option='') { global $GEDCOM, $SHOW_LAST_CHANGE, $WT_IMAGES, $SEARCH_SPIDER, $controller; $table_id = 'ID'.floor(microtime()*1000000); // lists requires a unique ID in case there are multiple lists per page if ($option=='BIRT_PLAC' || $option=='DEAT_PLAC') return; + $html = ''; $controller ->addExternalJavaScript(WT_STATIC_URL.'js/jquery/jquery.dataTables.min.js') @@ -621,35 +622,35 @@ function print_fam_table($datalist, $option='') { for ($year=1550; $year<2030; $year+=10) $birt_by_decade[$year]=''; for ($year=1550; $year<2030; $year+=10) $marr_by_decade[$year]=''; //--table wrapper - echo '
 
'; - echo '
'; + $html .= '
 
'; + $html .= '
'; //-- table header - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + $html .= '
', WT_Gedcom_Tag::getLabel('GIVN'), '', WT_Gedcom_Tag::getLabel('SURN'), 'HUSB:GIVN_SURNHUSB:SURN_GIVN', WT_Gedcom_Tag::getLabel('AGE'), 'AGE', WT_Gedcom_Tag::getLabel('GIVN'), '', WT_Gedcom_Tag::getLabel('SURN'), 'WIFE:GIVN_SURNWIFE:SURN_GIVN', WT_Gedcom_Tag::getLabel('AGE'), 'AGE', WT_Gedcom_Tag::getLabel('MARR'), 'MARR:DATE', WT_I18N::translate('Anniversary'), '', WT_Gedcom_Tag::getLabel('PLAC'), '', WT_I18N::translate('Children'), 'NCHI', WT_Gedcom_Tag::getLabel('CHAN'), 'MARRDEATTREE
'; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; //-- table body - echo ''; + $html .= ''; $num = 0; $d100y=new WT_Date(date('Y')-100); // 100 years ago foreach ($datalist as $key => $value) { @@ -675,9 +676,9 @@ function print_fam_table($datalist, $option='') { } //-- place filtering if ($option=='MARR_PLAC' && strstr($family->getMarriagePlace(), $filter)===false) continue; - echo ''; + $html .= ''; //-- Husband name(s) - echo ''; + $html .= $husb->getPrimaryParentsNames('parents_'.$table_id.' details1', 'none'); + $html .= ''; // Dummy column to match colspan in header - echo ''; + $html .= ''; //-- Husb GIVN // Use "AAAA" as a separator (instead of ",") as JavaScript.localeCompare() ignores // punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it. // Similarly, @N.N. would sort as NN. - echo ''; - echo ''; + $html .= ''; + $html .= ''; $mdate=$family->getMarriageDate(); //-- Husband age - echo ''; + $html .= ''; //-- Wife name(s) - echo ''; + $html .= $wife->getPrimaryParentsNames("parents_".$table_id." details1", 'none'); + $html .= ''; // Dummy column to match colspan in header - echo ''; + $html .= ''; //-- Wife GIVN //-- Husb GIVN // Use "AAAA" as a separator (instead of ",") as JavaScript.localeCompare() ignores // punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it. // Similarly, @N.N. would sort as NN. - echo ''; - echo ''; + $html .= ''; + $html .= ''; $mdate=$family->getMarriageDate(); //-- Wife age - echo ''; + $html .= ''; //-- Marriage date - echo ''; + $html .= ''; //-- Event date (sortable)hidden by datatables code - echo ''; + $html .= ''; //-- Marriage anniversary - echo ''; + $html .= ''; //-- Marriage place - echo ''; + $html .= ''; //-- Number of children $nchi=$family->getNumberOfChildren(); - echo ''; + $html .= ''; //-- Last change if ($SHOW_LAST_CHANGE) { - echo ''; + $html .= ''; } else { - echo ''; + $html .= ''; } //-- Sorting by marriage date - echo ''; + $html .= ''; //-- Sorting alive/dead - echo ''; + if (!$husb->isDead() && !$wife->isDead()) $html .= 'N'; + $html .= ''; //-- Roots or Leaves - echo '', - ''; + $html .= ' + '; } - echo '', + $html .= ''. '
'. WT_Gedcom_Tag::getLabel('GIVN'). ''. WT_Gedcom_Tag::getLabel('SURN'). 'HUSB:GIVN_SURNHUSB:SURN_GIVN'. WT_Gedcom_Tag::getLabel('AGE'). 'AGE'. WT_Gedcom_Tag::getLabel('GIVN'). ''. WT_Gedcom_Tag::getLabel('SURN'). 'WIFE:GIVN_SURNWIFE:SURN_GIVN'. WT_Gedcom_Tag::getLabel('AGE'). 'AGE'. WT_Gedcom_Tag::getLabel('MARR'). 'MARR:DATE'. WT_I18N::translate('Anniversary'). ''. WT_Gedcom_Tag::getLabel('PLAC'). ''. WT_I18N::translate('Children'). 'NCHI'. WT_Gedcom_Tag::getLabel('CHAN'). 'MARRDEATTREE
'; + $html .= ''; foreach ($husb->getAllNames() as $num=>$name) { if ($name['type']=='NAME') { $title=''; @@ -694,23 +695,23 @@ function print_fam_table($datalist, $option='') { } // Only show married names if they are the name we are filtering by. if ($name['type']!='_MARNM' || $num==$husb->getPrimaryName()) { - echo '', highlight_search_hits($name['full']), '', $sex_image, '
'; + $html .= ''. highlight_search_hits($name['full']). ''. $sex_image. '
'; } } // Husband parents - echo $husb->getPrimaryParentsNames('parents_'.$table_id.' details1', 'none'); - echo '
', htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)), 'AAAA', htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)), '', htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)), 'AAAA', htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)), ''. htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)). 'AAAA'. htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)). ''. htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)). 'AAAA'. htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)). ''; + $html .= ''; $hdate=$husb->getBirthDate(); if ($hdate->isOK() && $mdate->isOK()) { if ($hdate->gregorianYear()>=1550 && $hdate->gregorianYear()<2030) { @@ -718,14 +719,14 @@ function print_fam_table($datalist, $option='') { } $hage=WT_Date::GetAgeYears($hdate, $mdate); $hage_jd = $mdate->MinJD()-$hdate->MinJD(); - echo WT_I18N::number($hage); + $html .= WT_I18N::number($hage); $marr_by_age[max(0, min($max_age, $hage))] .= $husb->getSex(); } else { $hage=0; } - echo '', $hage, ''. $hage. ''; + $html .= ''; foreach ($wife->getAllNames() as $num=>$name) { if ($name['type']=='NAME') { $title=''; @@ -742,24 +743,24 @@ function print_fam_table($datalist, $option='') { } // Only show married names if they are the name we are filtering by. if ($name['type']!='_MARNM' || $num==$wife->getPrimaryName()) { - echo '', highlight_search_hits($name['full']), '', $sex_image, '
'; + $html .= ''. highlight_search_hits($name['full']). ''. $sex_image. '
'; } } // Wife parents - echo $wife->getPrimaryParentsNames('parents_'.$table_id.' details1', 'none'); - echo '
', htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)), 'AAAA', htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)), '', htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)), 'AAAA', htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)), ''. htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)). 'AAAA'. htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)). ''. htmlspecialchars(str_replace('@N.N.', 'AAAA', $surn)). 'AAAA'. htmlspecialchars(str_replace('@P.N.', 'AAAA', $givn)). ''; + $html .= ''; $wdate=$wife->getBirthDate(); if ($wdate->isOK() && $mdate->isOK()) { if ($wdate->gregorianYear()>=1550 && $wdate->gregorianYear()<2030) { @@ -767,20 +768,20 @@ function print_fam_table($datalist, $option='') { } $wage=WT_Date::GetAgeYears($wdate, $mdate); $wage_jd = $mdate->MinJD()-$wdate->MinJD(); - echo WT_I18N::number($wage); + $html .= WT_I18N::number($wage); $marr_by_age[max(0, min($max_age, $wage))] .= $wife->getSex(); } else { $wage=0; } - echo '', $wage, ''. $wage. ''; + $html .= ''; if ($marriage_dates=$family->getAllMarriageDates()) { foreach ($marriage_dates as $n=>$marriage_date) { if ($n) { - echo '
'; + $html .= '
'; } - echo '
', $marriage_date->Display(!$SEARCH_SPIDER), '
'; + $html .= '
'. $marriage_date->Display(!$SEARCH_SPIDER). '
'; } if ($marriage_dates[0]->gregorianYear()>=1550 && $marriage_dates[0]->gregorianYear()<2030) { $marr_by_decade[floor($marriage_dates[0]->gregorianYear()/10)*10] .= $husb->getSex().$wife->getSex(); @@ -788,123 +789,124 @@ function print_fam_table($datalist, $option='') { } else if (get_sub_record(1, '1 _NMR', $family->getGedcomRecord())) { $hus = $family->getHusband(); $wif = $family->getWife(); - if (empty($wif) && !empty($hus)) echo WT_Gedcom_Tag::getLabel('_NMR', $hus); - else if (empty($hus) && !empty($wif)) echo WT_Gedcom_Tag::getLabel('_NMR', $wif); - else echo WT_Gedcom_Tag::getLabel('_NMR'); + if (empty($wif) && !empty($hus)) $html .= WT_Gedcom_Tag::getLabel('_NMR', $hus); + else if (empty($hus) && !empty($wif)) $html .= WT_Gedcom_Tag::getLabel('_NMR', $wif); + else $html .= WT_Gedcom_Tag::getLabel('_NMR'); } else if (get_sub_record(1, '1 _NMAR', $family->getGedcomRecord())) { $hus = $family->getHusband(); $wif = $family->getWife(); - if (empty($wif) && !empty($hus)) echo WT_Gedcom_Tag::getLabel('_NMAR', $hus); - else if (empty($hus) && !empty($wif)) echo WT_Gedcom_Tag::getLabel('_NMAR', $wif); - else echo WT_Gedcom_Tag::getLabel('_NMAR'); + if (empty($wif) && !empty($hus)) $html .= WT_Gedcom_Tag::getLabel('_NMAR', $hus); + else if (empty($hus) && !empty($wif)) $html .= WT_Gedcom_Tag::getLabel('_NMAR', $wif); + else $html .= WT_Gedcom_Tag::getLabel('_NMAR'); } else { $factdetail = explode(' ', trim($family->getMarriageRecord())); if (isset($factdetail)) { if (count($factdetail) >= 3) { if (strtoupper($factdetail[2]) != "N") { - echo WT_I18N::translate('yes'); + $html .= WT_I18N::translate('yes'); } else { - echo WT_I18N::translate('no'); + $html .= WT_I18N::translate('no'); } } else { - echo ' '; + $html .= ' '; } } } - echo '
'; + $html .= ''; if ($marriage_dates) { - echo $marriage_date->JD(); + $html .= $marriage_date->JD(); } else { - echo 0; + $html .= 0; } - echo ''; + $html .= ''; $mage=WT_Date::GetAgeYears($mdate); if ($mage) { - echo WT_I18N::number($mage); + $html .= WT_I18N::number($mage); } else { - echo ' '; + $html .= ' '; } - echo ''; + $html .= ''; foreach ($family->getAllMarriagePlaces() as $n=>$marriage_place) { if ($n) { - echo '
'; + $html .= '
'; } if ($SEARCH_SPIDER) { - echo get_place_short($marriage_place), ' '; + $html .= get_place_short($marriage_place). ' '; } else { - echo ''; - echo highlight_search_hits(get_place_short($marriage_place)), ''; + $html .= ''; + $html .= highlight_search_hits(get_place_short($marriage_place)). ''; } } - echo '
', WT_I18N::number($nchi), '', $nchi, ''. WT_I18N::number($nchi). ''. $nchi. '', $family->LastChangeTimestamp(empty($SEARCH_SPIDER)), ''. $family->LastChangeTimestamp(empty($SEARCH_SPIDER)). '  '; + $html .= ''; if (!$family->canDisplayDetails() || !$mdate->isOK()) { - echo 'U'; + $html .= 'U'; } else { if (WT_Date::Compare($mdate, $d100y)>0) { - echo 'Y100'; + $html .= 'Y100'; } else { - echo 'YES'; + $html .= 'YES'; } } if ($family->isDivorced()) { - echo 'D'; + $html .= 'D'; } if (count($husb->getSpouseFamilies())>1 || count($wife->getSpouseFamilies())>1) { - echo 'M'; + $html .= 'M'; } - echo ''; - if ($husb->isDead() && $wife->isDead()) echo 'Y'; + $html .= ''; + if ($husb->isDead() && $wife->isDead()) $html .= 'Y'; if ($husb->isDead() && !$wife->isDead()) { - if ($wife->getSex()=='F') echo 'H'; - if ($wife->getSex()=='M') echo 'W'; // male partners + if ($wife->getSex()=='F') $html .= 'H'; + if ($wife->getSex()=='M') $html .= 'W'; // male partners } if (!$husb->isDead() && $wife->isDead()) { - if ($husb->getSex()=='M') echo 'W'; - if ($husb->getSex()=='F') echo 'H'; // female partners + if ($husb->getSex()=='M') $html .= 'W'; + if ($husb->getSex()=='F') $html .= 'H'; // female partners } - if (!$husb->isDead() && !$wife->isDead()) echo 'N'; - echo ''; - if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } // roots - elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren()<1) { echo 'L'; } // leaves - else { echo ' '; } - echo '
'; + if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { $html .= 'R'; } // roots + elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren()<1) { $html .= 'L'; } // leaves + else { $html .= ' '; } + $html .= '
'; //-- charts - echo '', - '
'; // Close "fam-list" + $html .= ' +
'; // Close "fam-list" + + return $html; } // print a table of sources -- cgit v1.3