forked from pceres/GVExport
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions_dot.php
1598 lines (1425 loc) · 52.3 KB
/
functions_dot.php
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
/**
* DOT file generating functions for GraphViz module
*
* Based on script made by Nick J <nickpj At The Host Called gmail.com> - http://nickj.org/
*
* phpGedView: Genealogy Viewer
* Copyright (C) 2002 to 2007 John Finlay and Others
*
* 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
*
* @package PhpGedView
* @subpackage Modules, GVExport
* @version 0.8.3
* @author Ferenc Kurucz <[email protected]>
* @license GPL v2 or later
*/
namespace vendor\WebtreesModules\gvexport;
// Load the config file
require_once(dirname(__FILE__)."/config.php");
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Log;
use Fisharebest\Webtrees\I18n;
/**
* Main class for managing the DOT file
*
*/
class Dot {
var $individuals = array();
var $families = array();
var $indi_search_method = array("ance" => FALSE, "desc" => FALSE, "spou" => FALSE, "sibl" => FALSE, "cous" => FALSE);
var $font_size;
var $colors = array();
var $settings = array();
var $pagesize = array();
/**
* Constructor of Dot class
*/
function __construct() {
global $GVE_CONFIG;
// Load settings from config file
// Load font size
$this->font_size = $GVE_CONFIG["dot"]["fontsize"];
$this->settings["fontname"] = $GVE_CONFIG["default_fontname"];
// Load colors
$this->colors["colorm"] = $GVE_CONFIG["dot"]["colorm"];
$this->colors["colorf"] = $GVE_CONFIG["dot"]["colorf"];
$this->colors["coloru"] = $GVE_CONFIG["dot"]["coloru"];
$this->colors["colorm_nr"] = $GVE_CONFIG["dot"]["colorm_nr"];
$this->colors["colorf_nr"] = $GVE_CONFIG["dot"]["colorf_nr"];
$this->colors["coloru_nr"] = $GVE_CONFIG["dot"]["coloru_nr"];
$this->colors["colorfam"] = $GVE_CONFIG["dot"]["colorfam"];
// Default settings
$this->settings["diagram_type"] = "simple";
$this->settings["indi"] = "ALL";
$this->settings["multi_indi"] = FALSE;
$this->settings["use_pagesize"] = "";
$this->settings["page_margin"] = $GVE_CONFIG["default_margin"];
$this->settings["mark_not_validated"] = FALSE;
$this->settings["show_lt_editor"] = FALSE;
$this->settings["mark_not_related"] = FALSE;
$this->settings["graph_dir"] = $GVE_CONFIG["default_direction"];
$default_mclimit = $GVE_CONFIG["default_mclimit"];
$this->settings["mclimit"] = $GVE_CONFIG["mclimit"][$default_mclimit];
$this->settings["show_by"] = FALSE;
$this->settings["show_bp"] = FALSE;
$this->settings["show_dy"] = FALSE;
$this->settings["show_dp"] = FALSE;
$this->settings["show_my"] = FALSE;
$this->settings["show_mp"] = FALSE;
$this->settings["show_pid"] = FALSE;
$this->settings["show_fid"] = FALSE;
$this->settings["show_url"] = FALSE;
$this->settings["no_fams"] = FALSE;
$this->settings["use_abbr_place"] = $GVE_CONFIG["settings"]["use_abbr_place"];
$this->settings["media_dir"] = $GVE_CONFIG["settings"]["media_dir"];
$this->settings["debug"] = $GVE_CONFIG["debug"];
$this->settings["ance_level"] = $GVE_CONFIG["settings"]["ance_level"];
$this->settings["desc_level"] = $GVE_CONFIG["settings"]["desc_level"];
$this->settings["birth_text"] = $GVE_CONFIG["custom"]["birth_text"];
$this->settings["death_text"] = $GVE_CONFIG["custom"]["death_text"];
$this->settings["dpi"] = $GVE_CONFIG["settings"]["dpi"];
$this->settings["ranksep"] = $GVE_CONFIG["settings"]["ranksep"];
$this->settings["nodesep"] = $GVE_CONFIG["settings"]["nodesep"];
}
function setPageSize($pagesize, $size_x = FALSE, $size_y = FALSE) {
global $GVE_CONFIG;
if ($pagesize == "Custom" && isset($size_x) && isset($size_y)) {
$this->pagesize["x"] = $size_x;
$this->pagesize["y"] = $size_y;
} elseif (!empty($pagesize) && isset($GVE_CONFIG["pagesize"][$pagesize]["x"]) && isset($GVE_CONFIG["pagesize"][$pagesize]["y"])) {
$this->pagesize["x"] = $GVE_CONFIG["pagesize"][$pagesize]["x"];
$this->pagesize["y"] = $GVE_CONFIG["pagesize"][$pagesize]["y"];
} else {
$pagesize = $GVE_CONFIG["default_pagesize"];
$this->pagesize["x"] = $GVE_CONFIG["pagesize"][$pagesize]["x"];
$this->pagesize["y"] = $GVE_CONFIG["pagesize"][$pagesize]["y"];
}
}
/**
* Function to set settings
*
* @param string $setting
* @param mixed $value
*/
function setSettings($setting, $value) {
$this->settings[$setting] = $value;
}
/**
* Function to set gender and family colors
*
* @param string $color_type
* @param string $color
*/
function setColor($color_type, $color) {
$this->colors[$color_type] = $color;
}
/**
* Function to set font size
*
* @param string $font_size
*/
function setFontSize($font_size) {
$this->font_size = $font_size;
}
/**
* Sets the method used during the search of individuals
*
* The method could be:
* "ance" - search for ancestors
* "desc" - search for descendants
* "spou" - search for spouses
* "sibl" - search for siblings
*
* @param string $method
*/
function setIndiSearchMethod($method) {
$this->indi_search_method[$method] = TRUE;
}
function getDOTDump() {
$out = "";
// --- DEBUG ---
if ($this->settings["debug"]) {
print("<pre>");
}
// -------------
$out .= $this->createDOTDump();
// --- DEBUG ---
if ($this->settings["debug"]) {
print("</pre>");
}
// -------------
return $out;
}
function createIndiList () {
// Full tree
if ($this->settings["indi"] == "ALL") {
$indis = WT_Query_Name::individuals(false, false, false, true, false, WT_GED_ID);
foreach ($indis as $pid=>$indi) {
if (get_class($indi ) != "Individual") { #ESL!!! 20090208 Fix for PGV 4.2
$this->addIndiToList($pid);
} else {
$this->addIndiToList($indi->getXref()); #ESL!!! 20090208 Fix for PGV 4.2
}
}
}
// Partial tree
else if (!empty($this->settings["indi"])) {
// -- DEBUG ---
// echo "INDI: " . $this->settings["indi"];
if ($this->settings["multi_indi"] == FALSE) {
$this->addIndiToList($this->settings["indi"], $this->indi_search_method["ance"], $this->indi_search_method["desc"], $this->indi_search_method["spou"], $this->indi_search_method["sibl"], TRUE, 0, $this->settings["ance_level"], $this->settings["desc_level"]);
} else {
// if multiple indis are defined
$indis = explode(",", $this->settings["indi"]);
for ($i=0;$i<count($indis);$i++) {
$this->addIndiToList($indis[$i], $this->indi_search_method["ance"], $this->indi_search_method["desc"], $this->indi_search_method["spou"], $this->indi_search_method["sibl"], TRUE, 0, $this->settings["ance_level"], $this->settings["desc_level"]);
}
}
}
}
function createFamList () {
// Full tree
if ($this->settings["indi"] == "ALL") {
$fams = WT_Query_Name::families(false, false, false, false, WT_GED_ID);
foreach ($fams as $fid=>$fam) {
if (get_class($fam ) != "Family") {
$this->addFamToList($fid);
} else {
$this->addFamToList($fam->getXref());
}
}
}
// Partial tree (families will be added during INDI processing)
else if (!empty($this->settings["indi"])) {
}
}
function createDOTDump() {
global $pgv_lang, $LANGUAGE, $lang_short_cut, $GVE_CONFIG, $GEDCOM, $pgv_changes;
// Create the individuals list
$this->createIndiList();
// Create the families list
$this->createFamList();
$out = "";
$out .= $this->printDOTHeader();
// ### Print the individuals list ###
if ($this->settings["diagram_type"] == "combined") {
// Do nothing, print only families
} else {
foreach ($this->individuals as $pid) {
$out .= $this->printPerson($pid['pid'], $pid['rel']);
}
}
// ### Print the families list ###
// If no_fams option is not checked then we print the families
if ($this->settings["no_fams"] == FALSE) {
foreach ($this->families as $fid=>$fam_data) {
if ($this->settings["diagram_type"] == "combined") {
// We do not show those families which has no parents and children in case of "combined" view;
if ((isset($this->families[$fid]["has_children"]) && $this->families[$fid]["has_children"] == TRUE)
|| (isset($this->families[$fid]["has_parents"]) && $this->families[$fid]["has_parents"] == TRUE)
|| ($this->settings["indi"] == "ALL")) { #ESL!!! Fix for 4.2
$out .= $this->printFamily($fid);
}
} elseif ($this->settings["diagram_type"] != "combined") {
$out .= $this->printFamily($fid);
}
}
}
// ### Print the connections ###
// If no_fams option is not checked
if ($this->settings["no_fams"] == FALSE) {
foreach ($this->families as $fid=>$set) {
// COMBINED type diagram
if ($this->settings["diagram_type"] == "combined") {
if (substr($fid, 0, 2) == "F_") {
// In case of dummy family do nothing, because it has no children
//$this->families[$fid]["has_children"] = FALSE;
} else {
// Get the family data
$f = $this->getUpdatedFamily($fid);
// Draw an arrow from FAM to each CHIL
foreach ($f->getChildren() as $child) {
if (!empty($child) && (isset($this->individuals[$child->getXref()]))) {
//$this->families[$fid]["has_children"] = TRUE;
foreach ($this->individuals[$child->getXref()]["fams"] as $fam_nr=>$fam) {
$out .= $this->convertID($fid) . " -> " . $this->convertID($fam) . ":" . $this->convertID($child->getXref()) . "\n";
}
}
}
}
} else {
// Get the family data
$f = $this->getUpdatedFamily($fid);
// Get the husband & wife ID
$h = $f->getHusband();
$w = $f->getWife();
if($h)
$husb_id = $h->getXref();
else
$husb_id = null;
if($w)
$wife_id = $w->getXref();
else
$wife_id = null;
// Draw an arrow from HUSB to FAM
if (!empty($husb_id) && (isset($this->individuals[$husb_id]))) {
$out .= $this->convertID($husb_id) . " -> " . $this->convertID($fid) ."\n";
}
// Draw an arrow from WIFE to FAM
if (!empty($wife_id) && (isset($this->individuals[$wife_id]))) {
$out .= $this->convertID($wife_id) . " -> ". $this->convertID($fid) ."\n";
}
// Draw an arrow from FAM to each CHIL
foreach ($f->getChildren() as $child) {
if (!empty($child) && (isset($this->individuals[$child->getXref()]))) {
$out .= $this->convertID($fid) . " -> " . $this->convertID($child->getXref()) . "\n";
}
}
}
}
} else {
// If no_fams option is checked then we do not print the families
foreach ($this->families as $fid=>$set) {
if ($this->settings["diagram_type"] == "combined") {
/*
*/
} else {
$f = $this->getUpdatedFamily($fid);
// Draw an arrow from HUSB and WIFE to FAM
$husb_id = empty($f->getHusband()) ? null : $f->getHusband()->getXref();
$wife_id = empty($f->getWife()) ? null : $f->getWife()->getXref();
// Draw an arrow from FAM to each CHIL
foreach ($f->getChildren() as $child) {
if (!empty($child) && (isset($this->individuals[$child->getXref()]))) {
if (!empty($husb_id) && (isset($this->individuals[$husb_id]))) {
$out .= $this->convertID($husb_id) . " -> " . $this->convertID($child->getXref()) ."\n";
}
if (!empty($wife_id) && (isset($this->individuals[$wife_id]))) {
$out .= $this->convertID($wife_id) . " -> ". $this->convertID($child->getXref()) ."\n";
}
}
}
}
}
}
$out .= $this->printDOTFooter();
return $out;
}
/**
* Returns a chopped version of the PLAC string.
*
* @param string Place string in long format (Town,County,State/Region,Country)
* @return string The first and last chunk of the above string (Town, Country)
*/
function getFormattedPlace($place_long) {
$place_chunks = explode(",", $place_long);
$place = "";
$chunk_count = count($place_chunks);
/* We need only the first and last place name (city and country name) */
if (!empty($place_chunks[0])) {
$place .= trim($place_chunks[0]);
}
if (!empty($place_chunks[$chunk_count - 1]) && ($chunk_count > 1)) {
if (!empty($place)) {
$place .= ", ";
}
$place .= trim($place_chunks[$chunk_count - 1]);
}
return $place;
}
/**
* Gets the colour associated with the given gender
*
* If a custom colour was used then this function will pull it from the form
* otherwise it will use the default colours in the config file
*
* @param char $gender (F/M/U)
* @param boolean $related (TRUE/FALSE) Person is blood-related
* @return string $colour (#RRGGBB)
*/
function getGenderColour($gender, $related = TRUE) {
global $GVE_CONFIG;
// Determine the fill color
if ($gender == 'F') {
if ($related) {
$fillcolor = $this->colors["colorf"];
} else {
$fillcolor = $this->colors["colorf_nr"];
}
} elseif ($gender == 'M'){
if ($related) {
$fillcolor = $this->colors["colorm"];
} else {
$fillcolor = $this->colors["colorm_nr"];
}
} else {
if ($related) {
$fillcolor = $this->colors["coloru"];
} else {
$fillcolor = $this->colors["coloru_nr"];
}
}
return $fillcolor;
}
/**
* Gets the colour associated with the families
*
* If a custom colour was used then this function will pull it from the form
* otherwise it will use the default colours in the config file
*
* @return string colour (#RRGGBB)
*/
function getFamilyColour() {
global $GVE_CONFIG;
// Determine the fill color
$fillcolor = $this->colors["colorfam"];
return $fillcolor;
}
/**
* Prints DOT header string.
*
* @return string DOT header text
*/
function printDOTHeader() {
$out = "";
$out .= "digraph WT_Graph {\n";
// Using pagebreak
if (!empty($this->settings["use_pagesize"])) {
$out .= "ratio=\"auto\"\n";
//$out .= "/* PAGESIZE: " . $this->settings["use_pagesize"] . " */";
// Size of the page
$out .= "page=\"" . $this->pagesize["x"] . "," . $this->pagesize["y"] . "\"\n";
// Size of the drawing (pagesize - 1 inch)
$out .= "size=\"" . ($this->pagesize["x"] - $this->settings["page_margin"]) . "," . ($this->pagesize["y"] - $this->settings["page_margin"]) . "\"\n";
//$out .= "size=\"50, 50\"\n";
}
/*
if ($this->settings["diagram_type"] == "combined") {
$out .= "ranksep=\"0.50 equally\"\n";
} else {
$out .= "ranksep=\"0.30 equally\"\n";
}
$out .= "nodesep=\"0.30\"\n";
*/
$out .= "ranksep=\"" . $this->settings["ranksep"] . " equally\"\n";
$out .= "nodesep=\"" . $this->settings["nodesep"] . "\"\n";
$out .= "dpi=\"" . $this->settings["dpi"] . "\"\n";
$out .= "mclimit=\"" . $this->settings["mclimit"] . "\"\n";
$out .= "rankdir=\"" . $this->settings["graph_dir"] . "\"\n";
$out .= "pagedir=\"LT\"\n";
$out .= "edge [ style=solid, arrowhead=normal arrowtail=none];\n";
// I need Arial font because of UTF-8 characters - feel free to change it
if ($this->settings["diagram_type"] == "simple") {
$out .= "node [ shape=box, style=filled fontsize=\"" . $this->font_size ."\" fontname=\"" . $this->settings["fontname"] ."\"];\n";
} else {
$out .= "node [ shape=plaintext fontsize=\"" . $this->font_size ."\" fontname=\"" . $this->settings["fontname"] ."\"];\n";
}
return $out;
}
/**
* Prints DOT footer string.
*
* @return string DOT header text
*/
function printDOTFooter() {
$out = "";
$out .= "}\n";
return $out;
}
/**
* Gives back a text with HTML special chars
*
* @param string $text String to convert
* @return string Converted string
*/
function convertToHTMLSC($text) {
$out = htmlspecialchars($text, ENT_QUOTES, "UTF-8");
return $out;
}
/**
* Prints the line for a single person.
*
* @param integer $pid Person ID
*/
function printPerson($pid, $related = TRUE) {
global $GVE_CONFIG, $pgv_changes, $GEDCOM, $pgv_lang;
$out = "";
$out .= $this->convertID($pid); // Convert the ID, so linked GEDCOMs are displayed properly
$out .= " [ ";
if ($this->settings["diagram_type"] == "simple") {
// Simple output
$out .= $this->printPersonLabel($pid, $related);
} else {
// HTML style output
$out .= "label=<";
$out .= $this->printPersonLabel($pid, $related);
$out .= ">";
}
$out .= "];\n";
return $out;
}
/**
* Prints the data for a single person.
*
* @param integer $pid Person ID
*/
function printPersonLabel($pid, $related = TRUE) {
global $GVE_CONFIG, $pgv_changes, $lang_short_cut, $LANGUAGE, $GEDCOM, $pgv_lang;
$out = "";
// Get the personal data
$i = $this->getUpdatedPerson($pid);
$isdead = $i->isDead();
// --- Background color & last editor's data ---
// if ($i->getChanged()) {
// // The INDI's data has been changed and not accepted yet
// $fillcolor = $GVE_CONFIG["dot"]["colorch"]; // Backround color is set to specified
// if ($this->settings["show_lt_editor"]) {
// // Show last editor
// // Hack is needed for compatibility for PGV revisions < 1661
// if (method_exists($i, "LastchangeUser")) {
// $editor = $pgv_lang["last_change_user"] . ": " . $i->LastchangeUser();
// } else {
// $editor = $pgv_lang["last_change_user"] . ": " . $i->getLastchangeUser();
// }
// } else {
// $editor = "";
// }
// } else {
// The INDI's data is up-to-date
$fillcolor = $this->getGenderColour($i->getSex(), $related); // Backround color is set to specified
$editor = "";
// }
$bordercolor = "#606060"; // Border color of the INDI's box
$link = $i->getHtmlUrl();
// --- Birth data ---
if ($this->settings["show_by"]) {
$birthdate_var = $i->getBirthDate(FALSE);
$q1=$birthdate_var->qual1;
$d1=$birthdate_var->minimumDate()->format(I18N::dateFormat());
$dy=$birthdate_var->minimumDate()->format("%Y");
$q2=$birthdate_var->qual2;
if ($birthdate_var->minimumDate() == $birthdate_var->maximumDate())
$d2='';
else
$d2=$birthdate_var->maximumDate()->format(I18N::dateFormat());
$q3='';
if ($this->settings["bd_type"] == "gedcom") {
// Show full GEDCOM date
if (is_object($birthdate_var)) {
// Workaround for PGV 4.1.5 SVN, it gives back an object not a string
$birthdate = trim("{$q1} {$d1} {$q2} {$d2} {$q3}");
} else {
$birthdate = $birthdate_var;
}
} else {
// Show birth year only
if (is_object($birthdate_var)) {
// Workaround for PGV 4.1.5 SVN, it gives back an object not a string
$birthdate = trim("{$q1} {$dy}");
} else {
$birthdate = substr($birthdate_var, -4, 4);
}
}
} else {
$birthdate = "";
}
if ($this->settings["show_bp"]) {
// Show birth place
if ($this->settings["use_abbr_place"]) {
$birthplace = $this->getFormattedPlace($i->getBirthPlace());
} else {
$birthplace = $i->getBirthPlace();
}
} else {
$birthplace = "";
}
// --- Death data ---
if ($this->settings["show_dy"]) {
$deathdate_var = $i->getDeathDate(FALSE);
$q1=$deathdate_var->qual1;
$d1=$deathdate_var->minimumDate()->format(I18N::dateFormat());
$dy=$deathdate_var->minimumDate()->format("%Y");
$q2=$deathdate_var->qual2;
if ($deathdate_var->minimumDate() == $deathdate_var->maximumDate())
$d2='';
else
$d2=$deathdate_var->maximumDate()->format(I18N::dateFormat());
$q3='';
if ($this->settings["dd_type"] == "gedcom") {
// Show full GEDCOM date
if (is_object($deathdate_var)) {
// Workaround for PGV 4.1.5 SVN, it gives back an object not a string
$deathdate = trim("{$q1} {$d1} {$q2} {$d2} {$q3}");
} else {
$deathdate = $deathdate_var;
}
} else {
// Show death year only
if (is_object($deathdate_var)) {
// Workaround for PGV 4.1.5 SVN, it gives back an object not a string
$deathdate = trim("{$q1} {$dy}");
} else {
$deathdate = substr($deathdate_var, -4, 4);
}
}
} else {
$deathdate = "";
}
if ($this->settings["show_dp"]) {
// Show death place
if ($this->settings["use_abbr_place"]) {
$deathplace = $this->getFormattedPlace($i->getDeathPlace());
} else {
$deathplace = $i->getDeathPlace();
}
} else {
$deathplace = "";
}
// --- Name ---
if (method_exists($i,'getName')) {
$name = strip_tags($i->getName());
} else {
/*foreach ($i->getAllNames() as $n=>$nm) {
if ($nm['type']=='NAME') {
//var_dump($nm);
$name=$nm['fullNN'];
break;
}
}*/
$name = $i->getFullName();//@@ Meliza Amity
$addname = $i->getAddName();//@@ Meliza Amity
if (!empty($addname)) {
if ($this->settings["diagram_type"] == "simple")
$name .= '\n' . $addname;//@@ Meliza Amity
else
$name .= '<BR />' . $addname;//@@ Meliza Amity
}
$name = strip_tags($name);
}
//@@ $name = str_replace(array('<span class="starredname">','</span>'), array('_','_'), $name); //@@ replace starredname by <u> and </u>
//@@ replace starredname by <u> and </u>
//@@ $name = str_replace(array('<span class="starredname">','</span>'), array('<U>','</U>'), $name); //@@ replace starredname by <u> and </u>
//$name = str_replace(array('<span class="starredname">','</span>'), array("",""), $name); //@@ replace starredname by null till graphviz supports underline
//$name = strip_tags($name);
if ($this->settings["diagram_type"] == "simple") { //@@ Meliza Amity
$name = str_replace(array('<span class="starredname">','</span>'), array('\"','\"'), $name);
//$name = str_replace('"', '\"', $name); //@@ Meliza Amity Handle double quotes of nick-names in simple tree ...
} else {
$name = str_replace(array('<span class="starredname">','</span>'), array('<FONT face="' . $this->settings["fontname"] . ' italic">','</FONT>'), $name);
}
if ($this->settings["show_pid"]) {
// Show INDI id
$name = $name . " (" . $pid . ")";
}
//$name = str_replace('"', '', $name); // To remove double quotes
// --- Printing the INDI details ---
if ($this->settings["diagram_type"] == "simple") {
if ($this->settings["show_url"]) {
// substr($_SERVER['QUERY_STRING'], 0, strrpos($_SERVER['QUERY_STRING'], '/'))
$out .= "color=\"" . $bordercolor . "\", fillcolor=\"" . $fillcolor . "\", target=\"_blank\", href=\"" . $this->convertToHTMLSC($link) . "\" label="; #ESL!!! 20090213 without convertToHTMLSC the dot file has invalid data
} else {
$out .= "color=\"" . $bordercolor . "\", fillcolor=\"" . $fillcolor . "\", label=";
}
$out .= '"';
$out .= str_replace('"','\"',$name) . '\n' . $this->settings["birth_text"] . $birthdate . " " . (empty($birthplace)?'':'('.$birthplace.')') . '\l';
if ($isdead) {
$out .= $this->settings["death_text"] . $deathdate . " " . (empty($deathplace)?'':'('.$deathplace.')');
} else {
$out .= " ";
}
$out .= '\l';
if (!empty($editor)) {
$out .= '\n' . strip_tags($editor);
}
$out .= '"';
} else {
// Convert birth & death place to get rid of characters which mess up the HTML output
$birthplace = $this->convertToHTMLSC($birthplace);
$deathplace = $this->convertToHTMLSC($deathplace);
// Draw table
if ($this->settings["diagram_type"] == "combined") {
$out .= "<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" BGCOLOR=\"#F0F0F0\">";
} else {
$out .= "<TABLE BORDER=\"1\" CELLBORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" BGCOLOR=\"#F0F0F0\">";
}
// First row (photo & name)
$out .= "<TR>";
// Show photo
if (($this->settings["diagram_type"] == "deco-photo" || $this->settings["diagram_type_combined_with_photo"]) && isset($this->individuals[$pid]["pic"]) && !empty($this->individuals[$pid]["pic"])) { #ESL!!! 20090213 deco-photo not used anymore
$out .= "<TD ROWSPAN=\"2\" CELLPADDING=\"1\" PORT=\"pic\" WIDTH=\"" . ($this->font_size * 5) . "\" HEIGHT=\"" . ($this->font_size * 6) . "\" FIXEDSIZE=\"true\"><IMG SCALE=\"true\" SRC=\"" . $this->individuals[$pid]["pic"] . "\" /></TD>";
}
// Show name
if ($this->settings["show_url"]) {
$out .= "<TD CELLPADDING=\"2\" BGCOLOR=\"$fillcolor\" TARGET=\"_blank\" HREF=\"" . $this->convertToHTMLSC($link) . "\" PORT=\"nam\"><FONT POINT-SIZE=\"" . ($this->font_size + 2) ."\">" . $name . "</FONT></TD>";
} else {
$out .= "<TD CELLPADDING=\"2\" BGCOLOR=\"$fillcolor\" PORT=\"nam\"><FONT POINT-SIZE=\"" . ($this->font_size + 2) ."\">" . $name . "</FONT></TD>";
}
$out .= "</TR>";
// Second row (birth & death data)
$out .= "<TR>";
$out .= "<TD ALIGN=\"LEFT\" BALIGN=\"LEFT\" PORT=\"dat\">" . $this->settings["birth_text"] . " $birthdate " . (empty($birthplace)?"":"($birthplace)");
$out .= "<BR />";
if ($isdead) {
$out .= $this->settings["death_text"] . " $deathdate " . (empty($deathplace)?"":"($deathplace)");
} else {
$out .= " ";
}
if (!empty($editor)) {
$out .= "<BR/>" . $editor;
}
$out .= "</TD>";
$out .= "</TR>";
// Close table
$out .= "</TABLE>";
}
return $out;
}
/**
* Prints the line for drawing a box for a family.
*
* @param integer $fid Family ID
*/
function printFamily($fid) {
global $GVE_CONFIG, $pgv_changes, $lang_short_cut, $LANGUAGE, $GEDCOM, $pgv_lang;
$out = "";
$out .= $this->convertID($fid);
$out .= " [ ";
// Showing the ID of the family, if set
if ($this->settings["show_fid"]) {
$family = " (" . $fid . ")";
} else {
$family = "";
}
// by wooc
$func="date_localisation_{$lang_short_cut[$LANGUAGE]}";
if (!function_exists($func))
$func="DefaultDateLocalisation";
// --- Data collection ---
// If a "dummy" family is set (begins with "F_"), then there is no marriage & family data, so no need for querying PGV...
if (substr($fid, 0, 2) == "F_") {
$fillcolor = $this->getFamilyColour();
$marriageyear = "";
$marriageplace = "";
$husb_id = $this->families[$fid]["husb_id"];
$wife_id = $this->families[$fid]["wife_id"];
if (!empty($this->families[$fid]["unkn_id"])) {
$unkn_id = $this->families[$fid]["unkn_id"];
}
$link = "#";
// Querying PGV for the data of a FAM object
} else {
$f = $this->getUpdatedFamily($fid);
$fillcolor = $this->getFamilyColour();
$link = $f->getHtmlUrl();
// Show marriage year
if ($this->settings["show_my"]) {
$marrdate_var = $f->getMarriageDate(FALSE);
$q1=$marrdate_var->qual1;
$d1=$marrdate_var->minimumDate()->format(I18N::dateFormat());
$dy=$marrdate_var->minimumDate()->format("%Y");
$q2=$marrdate_var->qual2;
if ($marrdate_var->minimumDate() == $marrdate_var->maximumDate())
$d2='';
else
$d2=$marrdate_var->maximumDate()->format(I18N::dateFormat());
$q3='';
if ($this->settings["md_type"] == "gedcom") {
// Show full GEDCOM date
if (is_object($marrdate_var)) {
// Workaround for PGV 4.1.5 SVN, it gives back an object not a string
$marriagedate = trim("{$q1} {$d1} {$q2} {$d2} {$q3}");
} else {
$marriagedate = $marrdate_var;
}
} else {
// Show birth year only
if (is_object($marrdate_var)) {
// Workaround for PGV 4.1.5 SVN, it gives back an object not a string
$marriagedate = trim("{$q1} {$dy}");
} else {
$marriagedate = substr($marrdate_var, -4, 4);
}
}
} else {
$marriagedate = "";
}
// Show marriage place
if ($this->settings["show_mp"] && !empty($f->getMarriage()) && !empty($f->getMarriagePlace())) {
if ($this->settings["use_abbr_place"]) {
$marriageplace = $this->getFormattedPlace($f->getMarriagePlace()->getGedcomName());
} else {
$marriageplace = $f->getMarriagePlace()->getGedcomName();
}
} else {
$marriageplace = "";
}
// Get the husband's and wife's id from PGV
//$husb_id = $f->getHusbId();
//$wife_id = $f->getWifeId();
if (isset($this->families[$fid]["husb_id"])) {
$husb_id = $this->families[$fid]["husb_id"];
} else {
$husb_id = "";
}
if (isset($this->families[$fid]["wife_id"])) {
$wife_id = $this->families[$fid]["wife_id"];
} else {
$wife_id = "";
}
}
// --- Printing ---
// "Combined" type
if ($this->settings["diagram_type"] == "combined") {
$out .= "label=<";
// --- Print table ---
$out .= "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"0\">";
// --- Print couple ---
$out .= "<TR>";
if (!empty($unkn_id)) {
// Print unknown gender INDI
if (isset($this->individuals[$unkn_id]['rel']) && ($this->individuals[$unkn_id]['rel'] == FALSE)) {
$related = FALSE;
} else {
$related = TRUE;
}
$out .= "<TD CELLPADDING=\"0\" PORT=\"" . $unkn_id . "\">";
$out .= $this->printPersonLabel($unkn_id, $related);
$out .= "</TD>";
} else {
// Print husband
//$husb_id = $f->getHusbId();
if (!empty($husb_id)) {
if (isset($this->individuals[$husb_id]['rel']) && ($this->individuals[$husb_id]['rel'] == FALSE)) {
$related = FALSE;
} else {
$related = TRUE;
}
$out .= "<TD CELLPADDING=\"0\" PORT=\"" . $husb_id . "\">";
$out .= $this->printPersonLabel($husb_id, $related);
$out .= "</TD>";
}
// Print wife
//$wife_id = $f->getWifeId();
if (!empty($wife_id)) {
if (isset($this->individuals[$wife_id]['rel']) && ($this->individuals[$wife_id]['rel'] == FALSE)) {
$related = FALSE;
} else {
$related = TRUE;
}
$out .= "<TD CELLPADDING=\"0\" PORT=\"" . $wife_id . "\">";
$out .= $this->printPersonLabel($wife_id, $related);
$out .= "</TD>";
}
}
$out .= "</TR>";
// --- Print marriage ---
if (substr($fid, 0, 2) == "F_") {
// If it is a dummy FAM, then do nothing
} else {
$out .= "<TR>";
if ($this->settings["show_url"]) {
$out .= "<TD COLSPAN=\"2\" CELLPADDING=\"0\" PORT=\"marr\" TARGET=\"_BLANK\" HREF=\"" . $this->convertToHTMLSC($link) . "\" BGCOLOR=\"" . $fillcolor . "\">"; #ESL!!! 20090213 without convertToHTMLSC the dot file has invalid data
} else {
$out .= "<TD COLSPAN=\"2\" CELLPADDING=\"0\" PORT=\"marr\" BGCOLOR=\"" . $fillcolor . "\">";
}
$out .= (empty($marriagedate)?".":$marriagedate) . "<BR />" . (empty($marriageplace)?"":"(".$marriageplace.")") . $family;
$out .= "</TD>";
$out .= "</TR>";
}
$out .= "</TABLE>";
$out .= ">";
} else {
// Non-combined type
if ($this->settings["show_url"]) {
$out .= "color=\"#606060\",fillcolor=\"" . $fillcolor . "\", href=\"" . $this->convertToHTMLSC($link) . "\", target=\"_blank\", shape=ellipse, style=filled"; #ESL!!! 20090213 without convertToHTMLSC the dot file has invalid data
} else {
$out .= "color=\"#606060\",fillcolor=\"" . $fillcolor . "\", shape=ellipse, style=filled";
}
$out .= ", label=" . '"' . (empty($marriagedate)?'':$marriagedate) . '\n' . (empty($marriageplace)?'':'('.$marriageplace.')') . $family . '"';
}
$out .= "];\n";
return $out;
}
/**
* Adds an individual to the indi list
*
* @param string $pid
* @param boolean $ance
* @param boolean $desc
* @param boolean $spou
* @param boolean $sibl
* @param boolean $rel
*/
function addIndiToList($pid, $ance = FALSE, $desc = FALSE, $spou = FALSE, $sibl = FALSE, $rel = TRUE, $ind = 0, $ance_level = 0, $desc_level = 0) {
global $GVE_CONFIG, $pgv_changes, $GEDCOM;
$this->individuals[$pid]['pid'] = $pid;
// --- DEBUG ---
if ($this->settings["debug"]) {
$this->printDebug("--- #$pid# ---\n", $ind);
$this->printDebug("{\n", $ind);
$ind++;
$this->printDebug("($pid) - INDI added to list\n", $ind);
$this->printDebug("($pid) - ANCE: $ance, DESC: $desc, SPOU: $spou, SIBL: $sibl, REL: $rel, IND: $ind, A_LEV: $ance_level, D_LEV: $desc_level\n", $ind);
}
// -------------
// Overwrite the 'related' status if it was not set before or its 'false' (for those people who are added as both related and non-related)
if (!isset($this->individuals[$pid]['rel']) || ($this->individuals[$pid]['rel'] == FALSE)) {
$this->individuals[$pid]['rel'] = $rel;
}
// Add photo
if ($this->settings["diagram_type"] == "deco-photo" || $this->settings["diagram_type_combined_with_photo"]) { #ESL!!! 20090213 deco-photo not used anymore
$this->individuals[$pid]["pic"] = $this->addPhotoToIndi($pid);
}
// Get updated INDI data
$i = $this->getUpdatedPerson($pid);
// Add the family nr which he/she belongs to as spouse (needed when "combined" mode is used)
if ($this->settings["diagram_type"] == "combined") {
$fams = $i->getSpouseFamilies();
if (!empty($fams)) {
// --- DEBUG ---
if ($this->settings["debug"]) {
$this->printDebug("($pid) - /COMBINED MODE/ adding FAMs where INDI is marked as spouse:\n", $ind);
}
// -------------
foreach ($fams as $fam) {
$fid = $fam->getXref();
$this->individuals[$pid]["fams"][$fid] = $fid;