-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelationship.php
More file actions
1031 lines (984 loc) · 38.1 KB
/
relationship.php
File metadata and controls
1031 lines (984 loc) · 38.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Calculates the relationship between two individuals in the gedcom
*
* phpGedView: Genealogy Viewer
* Copyright (C) 2002 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
*
* This Page Is Valid XHTML 1.0 Transitional! > 20 August 2005
*
* @package PhpGedView
* @subpackage Charts
* @version $Id: relationship.php 6879 2010-01-30 11:35:46Z fisharebest $
*/
define('PGV_SCRIPT_NAME', 'relationship.php');
require './config.php';
require_once PGV_ROOT.'includes/functions/functions_charts.php';
require_once PGV_ROOT.'includes/classes/class_person.php';
function getRelationshipSentence($node, $pid1, $pid2) {
global $pgv_lang, $lang_short_cut, $LANGUAGE, $path_to_find;
$relationshipDescription = false;
$sentence = false;
$started = false;
$finished = false;
$numberOfSiblings = 0;
$generationsOlder = 0;
$generationsYounger = 0;
$sosa = 1;
$bosa = 1;
$numberOfSpouses = 0;
$lastRelationshipIsSpouse = false;
$lastRelationshipIsSibling = false;
$lastRelationshipButOneIsSibling = false;
$checkFirstRelationship = false;
$firstRelationshipIsSpouse = false;
$siblingIsSister = false;
// sanity check - helps to prevent the possibility of recursing too deeply
if($pid1 == $pid2)
return false;
foreach($node["path"] as $index=>$pid) {
// only start looking for relationships from the first pid passed in
if($pid == $pid1) {
$started = true;
$checkFirstRelationship = true;
continue;
}
if($started) {
$lastRelationshipIsSpouse = false;
$lastRelationshipButOneIsSibling = $lastRelationshipIsSibling;
$lastRelationshipIsSibling = false;
// look to see if we can find a relationship
switch ($node["relations"][$index]) {
case "self":
break;
case "sister":
$siblingIsSister = true;
case "brother":
$numberOfSiblings++;
$lastRelationshipIsSibling = true;
break;
case "mother":
$generationsOlder++;
$sosa = $sosa * 2 + 1;
break;
case "father":
$generationsOlder++;
$sosa = $sosa * 2;
break;
case "son":
$generationsYounger++;
$bosa = $bosa * 2;
break;
case "daughter":
$generationsYounger++;
$bosa = $bosa * 2 + 1;
break;
case "husband":
case "wife":
$numberOfSpouses++;
$lastRelationshipIsSpouse = true;
if($checkFirstRelationship) {
$firstRelationshipIsSpouse = true;
}
break;
}
$checkFirstRelationship = false;
}
if($pid == $pid2) {
// we have found the second individual - look no further
$finished = true;
break;
}
}
// sanity check
if(!$started || !$finished) {
// passed in pid's are not found in the array!!!
return false;
}
$person1 = find_person_record($pid1, PGV_GED_ID);
$person2 = find_person_record($pid2, PGV_GED_ID);
$mf = "NN";
if (strpos($person2, "1 SEX F")!==false) $mf="F";
if (strpos($person2, "1 SEX M")!==false) $mf="M";
// now look to see if we can find some text to describe the relationship
//check if relationship is parent
if ($numberOfSpouses == 1 && $numberOfSiblings == 0 && $generationsOlder == 0 && $generationsYounger == 0) {
// check for spouse
if ($mf=="F") {
if (isset($pgv_lang["wife"]))
$relationshipDescription = $pgv_lang["wife"];
}
else {
if (isset($pgv_lang["husband"]))
$relationshipDescription = $pgv_lang["husband"];
}
}
//check if relationship is parent in law or step parent
else if ($numberOfSpouses == 1 && $numberOfSiblings == 0 && $generationsOlder == 1 && $generationsYounger == 0) {
// is this an in-law relationship?
if(!$lastRelationshipIsSpouse) {
if (isset($pgv_lang["mother_in_law"]) && $mf=="F") {
$relationshipDescription = $pgv_lang["mother_in_law"];
}
else if (isset($pgv_lang["father_in_law"])) {
$relationshipDescription = $pgv_lang["father_in_law"];
}
}
else {
// step relationship
if (isset($pgv_lang["stepmom"]) && $mf=="F") {
if (!empty($firstRelationshipIsSpouse) || $path_to_find>0) {
$relationshipDescription = $pgv_lang["sosa_3"];
}
else {
$relationshipDescription = $pgv_lang["stepmom"];
}
}
else if (isset($pgv_lang["stepdad"])) {
if (!empty($firstRelationshipIsSpouse) || $path_to_find>0) {
$relationshipDescription = $pgv_lang["sosa_2"];
}
else {
$relationshipDescription = $pgv_lang["stepdad"];
}
}
}
}
//checks for brother in law, sister in law realtionships
else if ($numberOfSpouses == 1 && $numberOfSiblings == 1 && $generationsYounger == 0 && $generationsOlder == 0) {
if (isset($pgv_lang["sister_in_law"]) && $mf=="F") {
if (in_arrayr("brother", $node)) {
$relationshipDescription = $pgv_lang["brothers_wife"];
}
else {
$relationshipDescription = $pgv_lang["sister_in_law"];
}
}
else if (isset($pgv_lang["brother_in_law"])) {
$relationshipDescription = $pgv_lang["brother_in_law"];
}
}
//check if relationship is child in law
else if ($numberOfSpouses == 1 && $numberOfSiblings == 0 && $generationsOlder == 0 && $generationsYounger == 1) {
// is this an in-law relationship?
if($lastRelationshipIsSpouse) {
if (isset($pgv_lang["daughter_in_law"]) && $mf=="F") {
$relationshipDescription = $pgv_lang["daughter_in_law"];
}
else if (isset($pgv_lang["son_in_law"])) {
$relationshipDescription = $pgv_lang["son_in_law"];
}
}
else {
// step relationship
if (isset($pgv_lang["step_daughter"]) && $mf=="F") {
$relationshipDescription = $pgv_lang["step_daughter"];
}
else if (isset($pgv_lang["step_son"])) {
$relationshipDescription = $pgv_lang["step_son"];
}
}
}
//checks for niece/nephew relationship
else if (($firstRelationshipIsSpouse || $numberOfSpouses == 0) && $numberOfSiblings == 1 && $generationsYounger >= 1 && $generationsOlder == 0) {
if($siblingIsSister) {
if (isset($pgv_lang["bosa_sisters_offspring_$bosa"])) {
$relationshipDescription = $pgv_lang["bosa_sisters_offspring_$bosa"];
}
else {
if ($mf=="F" && isset($pgv_lang["n_x_sisters_daughter"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_sisters_daughter"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
else if(isset($pgv_lang["n_x_sisters_son"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_sisters_son"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
}
}
else {
if (isset($pgv_lang["bosa_brothers_offspring_$bosa"])) {
$relationshipDescription = $pgv_lang["bosa_brothers_offspring_$bosa"];
}
else {
if ($mf=="F" && isset($pgv_lang["n_x_brothers_daughter"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_brothers_daughter"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
else if(isset($pgv_lang["n_x_brothers_son"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_brothers_son"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
}
}
}
// check for step siblings
else if($numberOfSpouses == 1 && $generationsYounger == 1 && $generationsOlder == 1 && !$firstRelationshipIsSpouse && !$lastRelationshipIsSpouse && $numberOfSiblings == 0 && $bosa <= 3) {
if ($node["length"]!=8 && isset($pgv_lang["stepsister"]) && $mf=="F") {
$relationshipDescription = $pgv_lang["stepsister"];
}
else if ($node["length"]!=8 && isset($pgv_lang["stepbrother"])) {
$relationshipDescription = $pgv_lang["stepbrother"];
}
}
//checks for aunt/uncle relationship by marriage
else if (($numberOfSiblings == 1) && ($generationsYounger == 0) && ($generationsOlder >= 1) && ($numberOfSpouses == 1) && $lastRelationshipIsSpouse && $lastRelationshipButOneIsSibling) {
if ($mf=="F" && isset($pgv_lang["sosa_aunt_bm_$sosa"])) {
$relationshipDescription = $pgv_lang["sosa_aunt_bm_$sosa"];
}
else if (isset($pgv_lang["sosa_uncle_bm_$sosa"])) {
$relationshipDescription = $pgv_lang["sosa_uncle_bm_$sosa"];
}
else {
// if line is through father
if(floor($sosa/pow(2,$generationsOlder-1)) == 2) {
if ($mf=="F" && isset($pgv_lang["n_x_paternal_aunt_bm"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_paternal_aunt_bm"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
else if(isset($pgv_lang["n_x_paternal_uncle_bm"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_paternal_uncle_bm"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
}
else {
if ($mf=="F" && isset($pgv_lang["n_x_maternal_aunt_bm"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_maternal_aunt_bm"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
else if(isset($pgv_lang["n_x_maternal_uncle_bm"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_maternal_uncle_bm"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
}
}
}
// from here on only check for blood relatives
else if($numberOfSpouses > 0) {
}
//check if relationship is parent or grandparent
else if ($numberOfSiblings == 0 && $generationsOlder > 0 && $generationsYounger == 0) {
// the get_sosa_name is probably the best way of getting this name
$relationshipDescription = get_sosa_name($sosa);
if(($relationshipDescription==(($sosa%2) ? $pgv_lang["mother"] : $pgv_lang["father"]) . " " . floor($sosa/2))&&($generationsOlder > 3)) {
// the sosa route didn't find a name - lets see if we can find a great grandparent this way
if (isset($pgv_lang["n_x_great_grandmother"]) && ($mf=="F")) {
$relationshipDescription = sprintf( $pgv_lang["n_x_great_grandmother"], $generationsOlder-2);
}
else if (isset($pgv_lang["n_x_great_grandfather"])) {
$relationshipDescription = sprintf( $pgv_lang["n_x_great_grandfather"], $generationsOlder-2);
}
}
}
//checks for son/daughter and grandson/granddaughter
else if ($numberOfSiblings == 0 && $generationsYounger > 0 && $generationsOlder == 0) {
if (isset($pgv_lang["bosa_$bosa"])) {
$relationshipDescription = $pgv_lang["bosa_$bosa"];
}
else {
// if line is through son
if(floor($bosa/pow(2,$generationsYounger-1)) == 2) {
if ($mf=="F" && isset($pgv_lang["n_x_granddaughter_from_son"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_granddaughter_from_son"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
else if(isset($pgv_lang["n_x_grandson_from_son"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_grandson_from_son"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
}
else {
if ($mf=="F" && isset($pgv_lang["n_x_granddaughter_from_daughter"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_granddaughter_from_daughter"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
else if(isset($pgv_lang["n_x_grandson_from_daughter"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_grandson_from_daughter"], $generationsYounger, $generationsYounger-1, $generationsYounger-2);
}
}
}
}
//checks for sibling realtionships
else if ($numberOfSiblings == 1 && $generationsYounger == 0 && $generationsOlder == 0) {
if ($mf=="F") {
if (isset($pgv_lang["sister"])) {
$relationshipDescription = $pgv_lang["sister"];
}
}
else {
if (isset($pgv_lang["brother"])) {
$relationshipDescription = $pgv_lang["brother"];
}
}
}
//checks for blood aunt/uncle relationship
else if (($numberOfSiblings == 1 && $generationsYounger == 0 && $generationsOlder >= 1) && $lastRelationshipIsSibling) {
if ($mf=="F" && isset($pgv_lang["sosa_aunt_$sosa"])) {
$relationshipDescription = $pgv_lang["sosa_aunt_$sosa"];
}
else if (isset($pgv_lang["sosa_uncle_$sosa"])) {
$relationshipDescription = $pgv_lang["sosa_uncle_$sosa"];
}
else {
// if line is through father
if(floor($sosa/pow(2,$generationsOlder-1)) == 2) {
if ($mf=="F" && isset($pgv_lang["n_x_paternal_aunt"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_paternal_aunt"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
else if(isset($pgv_lang["n_x_paternal_uncle"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_paternal_uncle"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
}
else {
if ($mf=="F" && isset($pgv_lang["n_x_maternal_aunt"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_maternal_aunt"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
else if(isset($pgv_lang["n_x_maternal_uncle"])) {
$relationshipDescription = sprintf($pgv_lang["n_x_maternal_uncle"], $generationsOlder, $generationsOlder-1, $generationsOlder-2);
}
}
}
}
//checks for nth cousin
else if ($numberOfSiblings == 1 && $generationsYounger > 0 && $generationsOlder > 0 && ($generationsYounger == $generationsOlder)) {
$degree = $generationsYounger;
if ($mf=="F") {
if(isset($pgv_lang["female_cousin_" . $degree]) && ($pgv_lang["female_cousin_" . $degree] != "")) {
$relationshipDescription = $pgv_lang["female_cousin_" . $degree];
}
else if(isset($pgv_lang["female_cousin_n"]) && ($pgv_lang["female_cousin_n"] != "")) {
$relationshipDescription = sprintf($pgv_lang["female_cousin_n"], $degree);
}
}
else {
// treat unknown gender as male
if(isset($pgv_lang["male_cousin_" . $degree]) && ($pgv_lang["male_cousin_" . $degree] != "")) {
$relationshipDescription = $pgv_lang["male_cousin_" . $degree];
}
else if(isset($pgv_lang["male_cousin_n"]) && ($pgv_lang["male_cousin_n"] != "")) {
$relationshipDescription = sprintf($pgv_lang["male_cousin_n"], $degree);
}
}
}
// Check for half sibling relationships
else if($numberOfSpouses == 0 && $generationsYounger == 1 && $generationsOlder == 1 && $numberOfSiblings == 0) {
if ($path_to_find==0) {
if (isset($pgv_lang["halfsister"]) && $mf=="F") {
$relationshipDescription = $pgv_lang["halfsister"];
}
else if (isset($pgv_lang["halfbrother"])) {
$relationshipDescription = $pgv_lang["halfbrother"];
}
}
else {
if (isset($pgv_lang["sister"]) && $mf=="F") {
$relationshipDescription = $pgv_lang["sister"];
}
else if (isset($pgv_lang["brother"])) {
$relationshipDescription = $pgv_lang["brother"];
}
}
}
$langStr = str_replace("-", "_", $lang_short_cut[$LANGUAGE]);
// check for language specific override of relationship
$getLanguageSpecificRelationship = "getRelationshipText_" . $langStr;
if(function_exists($getLanguageSpecificRelationship)) {
$relationshipDescription = $getLanguageSpecificRelationship($relationshipDescription, $node, $pid1, $pid2);
}
// check for language specific override of relationship
// functions to get locale specific names (eg Finnish genitive)
$getLanguageSpecificName = "getFirstRelationsName_" . $langStr;
if(function_exists($getLanguageSpecificName)) {
$pid1Name = PrintReady($getLanguageSpecificName($pid1));
}
else {
$person = Person::getInstance($pid1);
$pid1Name = PrintReady($person->getFullName());
}
$getLanguageSpecificName = "getSecondRelationsName_" . $langStr;
if(function_exists($getLanguageSpecificName)) {
$pid2Name = PrintReady($getLanguageSpecificName($pid2));
}
else {
$person = Person::getInstance($pid2);
$pid2Name = PrintReady($person->getFullName());
}
if($relationshipDescription != false) {
if(($mf=="F") && isset($pgv_lang["relationship_female_1_is_the_2_of_3"])) {
$sentence = sprintf($pgv_lang["relationship_female_1_is_the_2_of_3"], $pid2Name, $relationshipDescription, $pid1Name);
}
else if(isset($pgv_lang["relationship_male_1_is_the_2_of_3"])) {
$sentence = sprintf($pgv_lang["relationship_male_1_is_the_2_of_3"], $pid2Name, $relationshipDescription, $pid1Name);
}
}
else if(($pid1 == $node["path"][0]) && ($pid2 == $node["path"][count($node["path"])-1]) && $firstRelationshipIsSpouse) {
// if no relationship was found it may be nice to check if this is a spouses relation
$firstRelationPid = $node["path"][1];
//get their relationship
$sentence1 = getRelationshipSentence($node, $pid1, $firstRelationPid);
// get the relationship beteeen them and %pid2
$sentence2 = getRelationshipSentence($node, $firstRelationPid, $pid2);
// if both the above gave strings then concatenate
if(($sentence1 != false)&&($sentence2 != false)) {
$sentence = $sentence1 . "<br/>" . $sentence2;
}
}
return $sentence;
}
$show_full=$PEDIGREE_FULL_DETAILS;
if (isset($_REQUEST['show_full'])) $show_full = $_REQUEST['show_full'];
if (!isset($_REQUEST['path_to_find'])) {
$path_to_find = 0;
$pretty = 1;
unset($_SESSION["relationships"]);
}
else $path_to_find = $_REQUEST['path_to_find'];
if ($path_to_find == -1) {
$path_to_find = 0;
unset($_SESSION["relationships"]);
}
//-- previously these variables were set in theme.php, now they are no longer required to be set there
$Dbasexoffset = 0;
$Dbaseyoffset = 0;
if ($show_full==false) {
$Dbheight=25;
$Dbwidth-=40;
}
$bwidth = $Dbwidth;
$bheight = $Dbheight;
$title_string = "";
$pid1=safe_GET_xref('pid1');
$pid2=safe_GET_xref('pid2');
if (!isset($_REQUEST['followspouse'])) $followspouse = 0;
else $followspouse = $_REQUEST['followspouse'];
if (!isset($_REQUEST['pretty'])) $pretty = 0;
else $pretty = $_REQUEST['pretty'];
if (!isset($_REQUEST['asc'])) $asc=1;
else $asc = $_REQUEST['asc'];
if ($asc=="") $asc=1;
if (empty($pid1)) {
$followspouse = 1;
$pretty = 1;
}
$check_node = true;
$disp = true;
$title_string .= $pgv_lang["relationship_chart"];
// -- print html header information
print_header($title_string);
if ($ENABLE_AUTOCOMPLETE) require PGV_ROOT.'js/autocomplete.js.htm';
// Lbox additions if installed ---------------------------------------------------------------------------------------------
if (PGV_USE_LIGHTBOX) {
require PGV_ROOT.'modules/lightbox/lb_defaultconfig.php';
require_once PGV_ROOT.'modules/lightbox/functions/lb_call_js.php';
}
// ------------------------------------------------------------------------------------------------------------------------------
if ($pid1) {
//-- check if the id is valid
$indirec = Person::getInstance($pid1);
// Allow entry of i123 instead of I123
if (!$indirec && $pid1!=strtoupper($pid1)) {
$pid1=strtoupper($pid1);
$indirec=Person::getInstance($pid1);
}
// Allow user to specify person without the prefix
if (!$indirec && $GEDCOM_ID_PREFIX) {
$pid1=$GEDCOM_ID_PREFIX.$pid1;
$indirec=Person::getInstance($pid1);
}
if ($indirec) {
$title_string.=':<br />'.$indirec->getFullName();
} else {
$pid1='';
}
if (!empty($_SESSION["pid1"]) && ($_SESSION["pid1"]!=$pid1)) {
unset($_SESSION["relationships"]);
$path_to_find=0;
}
}
if ($pid2) {
//-- check if the id is valid
$indirec = Person::getInstance($pid2);
// Allow entry of i123 instead of I123
if (!$indirec && $pid2!=strtoupper($pid2)) {
$pid1=strtoupper($pid2);
$indirec=Person::getInstance($pid2);
}
// Allow user to specify person without the prefix
if (!$indirec && $GEDCOM_ID_PREFIX) {
$pid2=$GEDCOM_ID_PREFIX.$pid2;
$indirec = Person::getInstance($pid2);
}
if ($indirec) {
$title_string.=' '.$pgv_lang['and'].' '.$indirec->getFullName();
} else {
$pid2='';
}
if (!empty($_SESSION["pid2"]) && ($_SESSION["pid2"]!=$pid2)) {
unset($_SESSION["relationships"]);
$path_to_find=0;
}
}
// print_help_link("relationship_help", "page_help");
?>
<script language="JavaScript" type="text/javascript">
var pastefield;
function paste_id(value) {
pastefield.value=value;
}
</script>
<div id="relationship_chart_options<?php print ($TEXT_DIRECTION=="ltr")?"":"_rtl";?>" style="position: relative; z-index:90; width:98%;">
<h2><?php print PrintReady($title_string);?></h2><br />
<!-- // Print the form to change the number of displayed generations -->
<?php
if ($view!="preview") {
$Dbaseyoffset += 110; ?>
<form name="people" method="get" action="relationship.php">
<input type="hidden" name="path_to_find" value="<?php print $path_to_find ?>" />
<table class="list_table <?php print $TEXT_DIRECTION ?>" style="align:<?php print ($TEXT_DIRECTION=="ltr"?"left":"right");?>; margin:0;">
<!-- // Relationship header -->
<tr><td colspan="2" class="topbottombar center">
<?php print $pgv_lang["relationship_chart"]?>
</td>
<!-- // Empty space -->
<td> </td>
<!-- // Options header -->
<td colspan="2" class="topbottombar center">
<?php print $pgv_lang["options"]?>
</td></tr>
<!-- // Person 1 -->
<tr><td class="descriptionbox">
<?php
print_help_link("relationship_id_help", "qm");
print $pgv_lang["person1"]?>
</td>
<td class="optionbox vmiddle">
<input tabindex="1" class="pedigree_form" type="text" name="pid1" id="pid1" size="3" value="<?php print $pid1 ?>" />
<?php
print_findindi_link("pid1","");?>
</td>
<!-- // Empty space -->
<td></td>
<!-- // Show details -->
<td class="descriptionbox">
<?php
print_help_link("show_full_help", "qm");
print $pgv_lang["show_details"];?>
</td>
<td class="optionbox vmiddle">
<input type="hidden" name="show_full" value="<?php print $show_full ?>" />
<?php
if (!$pretty && $asc==-1) print "<input type=\"hidden\" name=\"asc\" value=\"$asc\" />";
print "<input tabindex=\"3\" type=\"checkbox\" name=\"showfull\" value=\"0\"";
if ($show_full) print " checked=\"checked\"";
print " onclick=\"document.people.show_full.value='".(!$show_full)."';\" />";?>
</td></tr>
<!-- // Person 2 -->
<tr><td class="descriptionbox">
<?php
print_help_link("relationship_id_help", "qm");
print $pgv_lang["person2"]?>
</td>
<td class="optionbox vmiddle">
<input tabindex="2" class="pedigree_form" type="text" name="pid2" id="pid2" size="3" value="<?php print $pid2 ?>" />
<?php
print_findindi_link("pid2","");?>
</td>
<!-- // Empty space -->
<td> </td>
<!-- // Line up generations -->
<td class="descriptionbox">
<?php
print_help_link("line_up_generations_help", "qm");
print $pgv_lang["line_up_generations"]?>
</td>
<td class="optionbox">
<input tabindex="5" type="checkbox" name="pretty" value="2"
<?php
if ($pretty) print " checked=\"checked\"";
print " onclick=\"expand_layer('oldtop1'); expand_layer('oldtop2');\"" ?> />
</td></tr>
<!-- // Empty line -->
<tr><td class="descriptionbox"> </td>
<td class="optionbox"> </td>
<!-- // Empty space -->
<td> </td>
<!-- // Show oldest top -->
<td class="descriptionbox">
<div id="oldtop1" style="display:
<?php
if ($pretty) print "block";
else print "none";
?>">
<?php
print_help_link("oldest_top_help", "qm");
print $pgv_lang["oldest_top"];
?>
</div>
</td><td class="optionbox">
<div id="oldtop2" style="display:
<?php
if ($pretty) print "block";
else print "none";?>">
<input tabindex="4" type="checkbox" name="asc" value="-1"
<?php
if ($asc==-1) print " checked=\"checked\"";?>
/>
</div></td></tr>
<!-- // Show path -->
<tr><td class="descriptionbox">
<?php $pass = false;
if ((isset($_SESSION["relationships"]))&&((!empty($pid1))&&(!empty($pid2)))) {
$pass = true;
$i=0;
$new_path=true;
if (isset($_SESSION["relationships"][$path_to_find])) $node = $_SESSION["relationships"][$path_to_find];
else $node = get_relationship($pid1, $pid2, $followspouse, 0, true, $path_to_find);
if (!$node) {
$path_to_find--;
$check_node=$node;
}
foreach($_SESSION["relationships"] as $indexval => $node) {
if ($i==0) print $pgv_lang["show_path"].": </td><td class=\"list_value\" style=\"padding: 3px;\">";
if ($i>0) print " | ";
if ($i==$path_to_find){
print "<span class=\"error\" style=\"valign: middle\">".($i+1)."</span>";
$new_path=false;
}
else {
print "<a href=\"".encode_url("relationship.php?pid1={$pid1}&pid2={$pid2}&path_to_find={$i}&followspouse={$followspouse}&pretty={$pretty}&show_full={$show_full}&asc={$asc}")."\">".($i+1)."</a>\n";
}
$i++;
}
if (($new_path)&&($path_to_find<$i+1)&&($check_node)) print " | <span class=\"error\">".($i+1)."</span>";
print "</td>";
} else {
if ((!empty($pid1))&&(!empty($pid2))) {
if ((!displayDetailsById($pid1))&&(!showLivingNameById($pid1))) {
$disp = false;
} elseif ((!displayDetailsById($pid2))&&(!showLivingNameById($pid2))) {
$disp = false;
}
if ($disp) {
echo $pgv_lang["show_path"], ": </td>";
echo "\n\t\t<td class=\"optionbox\">";
echo " <span class=\"error vmmiddle\">";
$check_node = get_relationship($pid1, $pid2, $followspouse, 0, true, $path_to_find);
echo $check_node ? "1" : " ".$pgv_lang["no_results"], "</span></td>";
$prt = true;
}
}
if (!isset($prt)) {
echo " </td><td class=\"optionbox\"> </td>";
}
}
?>
<!-- // Empty space -->
<td></td>
<!-- // Check relationships by marriage -->
<td class="descriptionbox">
<?php
print_help_link("follow_spouse_help", "qm");
print $pgv_lang["follow_spouse"];?>
</td>
<td class="optionbox" id="followspousebox">
<input tabindex="6" type="checkbox" name="followspouse" value="1"
<?php
if ($followspouse) {
echo " checked=\"checked\"";
}
echo " onclick=\"document.people.path_to_find.value='-1';\""?> />
</td>
<?php
if ((!empty($pid1))&&(!empty($pid2))&&($disp)) {
echo "</tr><tr>";
if (($disp)&&(!$check_node)) {
echo "<td class=\"topbottombar wrap vmiddle center\" colspan=\"2\">";
if (isset($_SESSION["relationships"])) {
if ($path_to_find==0) {
echo "<span class=\"error\">", $pgv_lang["no_link_found"], "</span><br />";
} else {
echo "<span class=\"error\">", $pgv_lang["no_other_link_found"], "</span><br />";
}
}
if (!$followspouse) {
?>
<script language="JavaScript" type="text/javascript">
document.getElementById("followspousebox").className='facts_valuered';
</script>
<?php
echo "<input class=\"error\" type=\"submit\" value=\"", $pgv_lang["follow_spouse"], "\" onclick=\"people.followspouse.checked='checked';\"/>";
}
echo "</td>";
} else {
echo "<td class=\"topbottombar vmiddle center\" colspan=\"2\"><input type=\"submit\" value=\"", $pgv_lang["next_path"], "\" onclick=\"document.people.path_to_find.value='", $path_to_find+1, "';\" /></td>\n";
}
$pass = true;
}
if ($pass == false) echo "</tr><tr><td colspan=\"2\" class=\"topbottombar wrap\"> </td>";?>
<!-- // Empty space -->
<td></td>
<!-- // View button -->
<td class="topbottombar vmiddle center" colspan="2">
<input tabindex="7" type="submit" value="<?php print $pgv_lang["view"]?>" />
</td></tr>
</table></form>
<?php
}
else {
$Dbaseyoffset=55;
$Dbasexoffset=10;
}
?>
</div>
<?php
if ($show_full==0) {
echo '<br /><span class="details2">', $pgv_lang['charts_click_box'], '</span><br />';
}
?>
<div id="relationship_chart<?php print ($TEXT_DIRECTION=="ltr")?"":"_rtl";?>" style="position:relative; z-index:1; width:98%;">
<?php
$maxyoffset = $Dbaseyoffset;
if ((!empty($pid1))&&(!empty($pid2))) {
if (!$disp) {
print "<br /><br />";
print_privacy_error($CONTACT_EMAIL);
}
else {
if (isset($_SESSION["relationships"][$path_to_find])) $node = $_SESSION["relationships"][$path_to_find];
else $node = get_relationship($pid1, $pid2, $followspouse, 0, true, $path_to_find);
if ($node!==false) {
$_SESSION["pid1"] = $pid1;
$_SESSION["pid2"] = $pid2;
if (!isset($_SESSION["relationships"])) $_SESSION["relationships"] = array();
$_SESSION["relationships"][$path_to_find] = $node;
$yoffset = $Dbaseyoffset + 20;
$xoffset = $Dbasexoffset;
$colNum = 0;
$rowNum = 0;
$boxNum = 0;
$previous="";
$previous2="";
$xs = $Dbxspacing+70;
$ys = $Dbyspacing+50;
// step1 = tree depth calculation
if ($pretty) {
$dmin=0;
$dmax=0;
$depth=0;
foreach($node["path"] as $index=>$pid) {
if (($node["relations"][$index]=="father")||($node["relations"][$index]=="mother")) {
$depth++;
if ($depth>$dmax) $dmax=$depth;
if ($asc==0) $asc=1; // the first link is a parent link
}
if ($node["relations"][$index]=="child") {
$depth--;
if ($depth<$dmin) $dmin=$depth;
if ($asc==0) $asc=-1; // the first link is a child link
}
}
$depth=$dmax+$dmin;
// need more yoffset before the first box ?
if ($asc==1) $yoffset -= $dmin*($Dbheight+$ys);
if ($asc==-1) $yoffset += $dmax*($Dbheight+$ys);
$rowNum = ($asc==-1) ? $depth : 0;
}
$maxxoffset = -1*$Dbwidth-20;
$maxyoffset = $yoffset;
if ($TEXT_DIRECTION=="ltr") {
$rArrow = $PGV_IMAGES["rarrow"]["other"];
$lArrow = $PGV_IMAGES["larrow"]["other"];
} else {
$rArrow = $PGV_IMAGES["larrow"]["other"];
$lArrow = $PGV_IMAGES["rarrow"]["other"];
}
foreach($node["path"] as $index=>$pid) {
print "\r\n\r\n<!-- Node:{$index} -->\r\n";
$linex = $xoffset;
$liney = $yoffset;
$mfstyle = "NN";
$indirec = find_person_record($pid, PGV_GED_ID);
if (strpos($indirec, "1 SEX F")!==false) $mfstyle="F";
if (strpos($indirec, "1 SEX M")!==false) $mfstyle="";
$arrow_img = $PGV_IMAGE_DIR."/".$PGV_IMAGES["darrow"]["other"];
if (($node["relations"][$index]=="father")||($node["relations"][$index]=="mother")) {
$line = $PGV_IMAGES["vline"]["other"];
$liney += $Dbheight;
$linex += $Dbwidth/2;
$lh = 54;
$lw = 3;
//check for paternal grandparent relationship
if ($pretty) {
if ($asc==0) $asc=1;
if ($asc==-1) $arrow_img = $PGV_IMAGE_DIR."/".$PGV_IMAGES["uarrow"]["other"];
$lh=$ys;
$linex=$xoffset+$Dbwidth/2;
// put the box up or down ?
$yoffset += $asc*($Dbheight+$lh);
$rowNum += $asc;
if ($asc==1) $liney = $yoffset-$lh; else $liney = $yoffset+$Dbheight;
// need to draw a joining line ?
if ($previous=="child" and $previous2!="parent") {
$joinh = 3;
$joinw = $xs/2+2;
$xoffset += $Dbwidth+$xs;
$colNum ++;
//$rowNum is inherited from the box immediately to the left
$linex = $xoffset-$xs/2;
if ($asc==-1) $liney=$yoffset+$Dbheight; else $liney=$yoffset-$lh;
$joinx = $xoffset-$xs;
$joiny = $liney-2-($asc-1)/2*$lh;
echo "<div id=\"joina", $index, "\" style=\"position:absolute; ", $TEXT_DIRECTION=="ltr"?"left":"right", ":", $joinx + $Dbxspacing, "px; top:", $joiny + $Dbyspacing, "px; z-index:-100; \" align=\"center\"><img src=\"", $PGV_IMAGE_DIR, "/", $PGV_IMAGES["hline"]["other"], "\" align=\"left\" width=\"", $joinw, "\" height=\"", $joinh, "\" alt=\"\" /></div>\n";
$joinw = $xs/2+2;
$joinx = $joinx+$xs/2;
$joiny = $joiny+$asc*$lh;
echo "<div id=\"joinb", $index, "\" style=\"position:absolute; ", $TEXT_DIRECTION=="ltr"?"left":"right", ":", $joinx + $Dbxspacing, "px; top:", $joiny + $Dbyspacing, "px; z-index:-100; \" align=\"center\"><img src=\"", $PGV_IMAGE_DIR, "/", $PGV_IMAGES["hline"]["other"], "\" align=\"left\" width=\"", $joinw, "\" height=\"", $joinh, "\" alt=\"\" /></div>\n";
}
$previous2=$previous;
$previous="parent";
}
else $yoffset += $Dbheight+$Dbyspacing+50;
}
if ($node["relations"][$index]=="sibling") {
$arrow_img = $PGV_IMAGE_DIR."/".$rArrow;
if ($mfstyle=="F") $node["relations"][$index]="sister";
if ($mfstyle=="") $node["relations"][$index]="brother";
$xoffset += $Dbwidth+$Dbxspacing+70;
$colNum ++;
//$rowNum is inherited from the box immediately to the left
$line = $PGV_IMAGES["hline"]["other"];
$linex += $Dbwidth;
$liney += $Dbheight/2;
$lh = 3;
$lw = 70;
if ($pretty) {
$lw = $xs;
$linex = $xoffset-$lw;
$liney = $yoffset+$Dbheight/4;
$previous2=$previous;
$previous="";
}
}
if ($node["relations"][$index]=="spouse") {
$arrow_img = $PGV_IMAGE_DIR."/".$rArrow;
if ($mfstyle=="F") $node["relations"][$index]="wife";
if ($mfstyle=="") $node["relations"][$index]="husband";
$xoffset += $Dbwidth+$Dbxspacing+70;
$colNum ++;
//$rowNum is inherited from the box immediately to the left
$line = $PGV_IMAGES["hline"]["other"];
$linex += $Dbwidth;
$liney += $Dbheight/2;
$lh = 3;
$lw = 70;
if ($pretty) {
$lw = $xs;
$linex = $xoffset-$lw;
$liney = $yoffset+$Dbheight/4;
$previous2=$previous;
$previous="";
}
}
if ($node["relations"][$index]=="child") {
if ($mfstyle=="F") $node["relations"][$index]="daughter";
if ($mfstyle=="") $node["relations"][$index]="son";
$line = $PGV_IMAGES["vline"]["other"];
$liney += $Dbheight;
$linex += $Dbwidth/2;
$lh = 54;
$lw = 3;
if ($pretty) {
if ($asc==0) $asc=-1;
if ($asc==1) $arrow_img = $PGV_IMAGE_DIR."/".$PGV_IMAGES["uarrow"]["other"];
$lh=$ys;
$linex = $xoffset+$Dbwidth/2;
// put the box up or down ?
$yoffset -= $asc*($Dbheight+$lh);
$rowNum -= $asc;
if ($asc==-1) $liney = $yoffset-$lh; else $liney = $yoffset+$Dbheight;
// need to draw a joining line ?
if ($previous=="parent" and $previous2!="child") {
$joinh = 3;
$joinw = $xs/2+2;
$xoffset += $Dbwidth+$xs;
$colNum ++;
//$rowNum is inherited from the box immediately to the left
$linex = $xoffset-$xs/2;
if ($asc==1) $liney=$yoffset+$Dbheight; else $liney=$yoffset-($lh+$Dbyspacing);
$joinx = $xoffset-$xs;
$joiny = $liney-2+($asc+1)/2*$lh;
print "<div id=\"joina$index\" style=\"position:absolute; ".($TEXT_DIRECTION=="ltr"?"left":"right").":".($joinx+$Dbxspacing)."px; top:".($joiny+$Dbyspacing)."px; z-index:-100; \" align=\"center\"><img src=\"".$PGV_IMAGE_DIR."/".$PGV_IMAGES["hline"]["other"]."\" align=\"left\" width=\"".$joinw."\" height=\"".$joinh."\" alt=\"\" /></div>\n";
$joinw = $xs/2+2;
$joinx = $joinx+$xs/2;
$joiny = $joiny-$asc*$lh;
print "<div id=\"joinb$index\" style=\"position:absolute; ".($TEXT_DIRECTION=="ltr"?"left":"right").":".($joinx+$Dbxspacing)."px; top:".($joiny+$Dbyspacing)."px; z-index:-100; \" align=\"center\"><img src=\"".$PGV_IMAGE_DIR."/".$PGV_IMAGES["hline"]["other"]."\" align=\"left\" width=\"".$joinw."\" height=\"".$joinh."\" alt=\"\" /></div>\n";
}
$previous2=$previous;
$previous="child";
}
else $yoffset += $Dbheight+$Dbyspacing+50;
}
if ($yoffset > $maxyoffset) $maxyoffset = $yoffset;
$plinex = $linex;
$pxoffset = $xoffset;
// Adjust all box positions for proper placement with respect to other page elements
if ($BROWSERTYPE=="mozilla" && $TEXT_DIRECTION=="rtl") $pxoffset += 10;
else $pxoffset -= 3;
$pyoffset = $yoffset - 2;
if ($index>0) {
if ($TEXT_DIRECTION=="rtl" && $line!=$PGV_IMAGES["hline"]["other"]) {
print "<div id=\"line$index\" dir=\"ltr\" style=\"background:none; position:absolute; right:".($plinex+$Dbxspacing)."px; top:".($liney+$Dbyspacing)."px; width:".($lw+$lh*2)."px; z-index:-100; \" align=\"right\">";
print "<img src=\"$PGV_IMAGE_DIR/$line\" align=\"right\" width=\"$lw\" height=\"$lh\" alt=\"\" />\n";
print "<br />";
print $pgv_lang[$node["relations"][$index]]."\n";
print "<img src=\"$arrow_img\" border=\"0\" align=\"middle\" alt=\"\" />\n";
}
else {
print "<div id=\"line$index\" style=\"background:none; position:absolute; ".($TEXT_DIRECTION=="ltr"?"left":"right").":".($plinex+$Dbxspacing)."px; top:".($liney+$Dbyspacing)."px; width:".($lw+$lh*2)."px; z-index:-100; \" align=\"".($lh==3?"center":"left")."\"><img src=\"$PGV_IMAGE_DIR/$line\" align=\"left\" width=\"$lw\" height=\"$lh\" alt=\"\" />\n";
print "<br />";
print "<img src=\"$arrow_img\" border=\"0\" align=\"middle\" alt=\"\" />\n";
if ($lh == 3) print "<br />"; // note: $lh==3 means horiz arrow
print $pgv_lang[$node["relations"][$index]]."\n";
}
print "</div>\n";
}
// Determine the z-index for this box
$boxNum ++;
if ($TEXT_DIRECTION=="rtl" && $BROWSERTYPE=="mozilla") {
if ($pretty) $zIndex = ($colNum * $depth - $rowNum + $depth);
else $zIndex = $boxNum;
} else {
if ($pretty) $zIndex = 200 - ($colNum * $depth + $rowNum);
else $zIndex = 200 - $boxNum;
}