/[drupal]/contributions/modules/family/view.inc
ViewVC logotype

Contents of /contributions/modules/family/view.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download) (as text)
Sat Dec 6 03:18:15 2008 UTC (11 months, 2 weeks ago) by pyutaros
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -2 lines
File MIME type: text/x-php
#322607 by Microbe:  Ascendants and Descendants tabs appear on every node type
#326432 by Microbe:  New 6.x-1.0-beta2 instalation - warning: mysql_fetch_array()
#339263 by Microbe:  Misspelling of word "Birth" in table
#339265 by Microbe:  Marriage type fields requested, in addition to "Religious"
#331459 by Microbe:  GEDCOM data confused on import
1 <?php
2 // $Id: view.inc,v 1.6.2.1 2008/10/09 01:55:57 pyutaros Exp $
3 function family_make_location($var, $link=TRUE){
4 if(is_numeric($var)){
5 $location=db_fetch_array(db_query("SELECT * FROM {family_location} WHERE nid=%d", $var));
6 $locationname="";
7 $start=FALSE;
8 if($location['building']){
9 $start=TRUE;
10 $locationname.=$location['building'];
11 }
12 if($location['street']){
13 if($start==TRUE){
14 $locationname.=" ";
15 }
16 $start=TRUE;
17 $locationname.=$location['street'];
18 }
19 if($location['city']){
20 if($start==TRUE){
21 $locationname.=", ";
22 }
23 $start=TRUE;
24 $locationname.=$location['city'];
25 }
26 if($location['county']){
27 if($start==TRUE){
28 $locationname.=", ";
29 }
30 $start=TRUE;
31 $locationname.=$location['county'];
32 }
33 if($location['state_province']){
34 if($start==TRUE){
35 $locationname.=", ";
36 }
37 $start=TRUE;
38 $locationname.=$location['state_province'];
39 }
40 if($location['country']){
41 if($start==TRUE){
42 $locationname.=", ";
43 }
44 $start=TRUE;
45 $locationname.=$location['country'];
46 }
47 if($link==TRUE){
48 $locationname = family_make_link($var,($locationname));
49 }
50 return $locationname;
51 }else{
52 return $var;
53 }
54 }
55
56
57 // Generate summary of individual information
58 function family_summ_indi ($nid) {
59 $content="<P>";
60 $content .= "<strong>". family_make_name($nid, TRUE) ."</strong>";
61 $facts=db_fetch_array(db_query("SELECT * FROM {family_individual} WHERE nid = %d",$nid));
62 if ($show_record = TRUE) { //this should check privacy
63 if ($facts['gender']) {
64 $content .= ", ".$facts['gender'];
65 }
66 $content .= "<br>";
67 }
68 $content .= "<font size=\"-2\">".l("View Ascendants", "node/".$nid."/tree/asc")."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".l("View Descendants", "node/".$nid."/tree/desc")."</font></br>";
69 //Find parents
70 $fam=db_fetch_array(db_query("SELECT parent1, parent2 FROM {family_group} WHERE nid='%s'",$facts['ancestor_group']));
71 if ($fam) {
72 $father = $fam['parent1'];
73 if ($father) {
74 $list[] = 'Father: '. family_make_name($father,TRUE);
75 }
76 $mother = $fam['parent2'];
77 if ($mother) {
78 $list[] = 'Mother: '. family_make_name($mother,TRUE);
79 }
80 }
81 if ($show_record) {
82 if ($facts['birthdate']!='0000-00-00 00:00:00') {
83 $value=explode(' ',$facts['birthdate']);
84 $value=$value[0];
85 $list[] = 'Birth Date: '.$value;
86 }
87 if ($facts['birthplace']) {
88
89 $list[] = 'Birth Place: '.family_make_location($facts['birthplace']);
90 }
91 if ($facts['deathdate']!='0000-00-00 00:00:00') {
92 $value=explode(' ',$facts['deathdate']);
93 $value=$value[0];
94 $list[] = 'Death Date: '.$value;
95 }
96 if ($facts['deathplace']) {
97 $list[] = 'Death Place: '.family_make_location($facts['deathplace']);
98 }
99 }
100 $content .= theme('item_list', $list);
101 $content .= "</P>";
102 return ($content);
103 }
104
105 // Display family view of individual fid (fact id)
106 function family_view_indi($nid,$type) {
107 $content="";
108 $content .= family_summ_indi ($nid);
109
110 //Find families where the individual is husband or wife
111 $families = db_query("SELECT * FROM {family_group} WHERE (parent1='%s' OR parent2='%s')", $nid, $nid);
112 if ($families) {
113 $list1 = array();
114 while ($family = db_fetch_array($families)) {
115
116 //Spouse info
117 if($family['parent1'] == $nid) {
118 $spouse = $family['parent2'];
119 }
120 else {
121 $spouse = $family['parent1'];
122 }
123 if ($spouse) {
124 $parents=TRUE;
125 $content .= "<hr><strong>Spouse: </strong>".family_summ_indi($spouse);
126 $spousename = family_make_name($spouse, FALSE);
127 }
128 else {
129 $content .= "<hr><p><strong>Spouse: </strong>Unknown</p>";
130 $spousename = "Unknown";
131 }
132 //Marriage info
133 $content .='<div class="marriage_data"><p>';
134 $content.=family_summ_group($family['nid']);
135 $content .= '</p></div>';
136 $children = db_query("SELECT * FROM {family_individual} WHERE ancestor_group=%d", $family['nid']);
137 //Children info
138 if($children){
139 $content .= '<p>Children of '. family_make_name($nid,FALSE).' and '. $spousename .':</p>';
140 $content .= '<p><table width=100% border=1><tr><td>Name</td><td>Gender</td><td>Birth Date</td><td>Death Date</td></tr>';
141 while ($child = db_fetch_array($children)) {
142 $content .= "<tr><td>".family_make_name($child['nid'],TRUE)."</td><td>".$child['gender']."</td><td>".$child['birthdate']."</td><td>".$child['deathdate']."</td></tr>";
143 }
144 $content.="</table>";
145 }
146 }
147
148 }
149 $content .= '<hr />'; //Break before sources, biography, and comments
150
151 return($content);
152 }

  ViewVC Help
Powered by ViewVC 1.1.2