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
|
<?php
// View for the pedigree tree.
//
// webtrees: Web based Family History software
// Copyright (C) 2012 webtrees development team.
//
// Derived from PhpGedView
// 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
//
// $Id$
define('WT_SCRIPT_NAME', 'pedigree.php');
require './includes/session.php';
require WT_ROOT.'includes/functions/functions_edit.php';
$controller=new WT_Controller_Pedigree();
$controller
->pageHeader()
->addInlineJavaScript('var pastefield; function paste_id(value) { pastefield.value=value; }'); // For the "find indi" link
if ($ENABLE_AUTOCOMPLETE) {
require WT_ROOT.'js/autocomplete.js.htm';
}
if (WT_USE_LIGHTBOX) {
require WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lb_call_js.php';
}
?>
<table>
<tr>
<td valign="middle">
<h2><?php echo $controller->getPageTitle(); ?></h2>
</td>
<td width="50px"> </td>
<td>
<form name="people" id="people" method="get" action="?">
<input type="hidden" name="show_full" value="<?php echo $controller->show_full; ?>">
<table class="list_table" width="500" align="center">
<tr>
<td class="descriptionbox wrap">
<?php echo WT_I18N::translate('Individual'); ?>
</td>
<td class="descriptionbox wrap">
<?php echo WT_I18N::translate('Generations'); ?>
</td>
<td class="descriptionbox wrap">
<?php echo WT_I18N::translate('Layout'); ?>
</td>
<td class="descriptionbox wrap">
<?php echo WT_I18N::translate('Show Details'); ?>
</td>
<td rowspan="2" class="facts_label03">
<input type="submit" value="<?php echo WT_I18N::translate('View'); ?>">
</td>
</tr>
<tr>
<td class="optionbox">
<input class="pedigree_form" type="text" id="rootid" name="rootid" size="3" value="<?php echo $controller->rootid; ?>">
<?php print_findindi_link("rootid", ""); ?>
</td>
<td class="optionbox">
<select name="PEDIGREE_GENERATIONS">
<?php
for ($i=3; $i<=$MAX_PEDIGREE_GENERATIONS; $i++) {
echo "<option value=\"", $i, "\"" ;
if ($i == $controller->PEDIGREE_GENERATIONS) echo " selected=\"selected\"";
echo ">", $i, "</option>";
}
?>
</select>
</td>
<td class="optionbox">
<?php echo select_edit_control('talloffset', array(0=>WT_I18N::translate('Portrait'), 1=>WT_I18N::translate('Landscape'), 2=>WT_I18N::translate('Oldest at top'), 3=>WT_I18N::translate('Oldest at bottom')), null, $talloffset); ?>
</td>
<td class="optionbox">
<input type="checkbox" value="<?php
if ($controller->show_full) echo "1\" checked=\"checked\" onclick=\"document.people.show_full.value='0';";
else echo "0\" onclick=\"document.people.show_full.value='1';"; ?>">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
if ($controller->error_message) {
echo '<p class="ui-state-error">', $controller->error_message, '</p>';
exit;
}
?>
<div id="pedigree_chart">
<?php
//-- echo the boxes
$curgen = 1;
$lastvlength = 0; // -- used to save the last vertical line length where child had both father and mother
$linexoffset = 0;
$vlength = 0;
$xoffset = 0;
$yoffset = 0; // -- used to offset the position of each box as it is generated
$prevxoffset = 0; // -- used to track the horizontal x position of the previous box
$prevyoffset = 0; // -- used to track the vertical y position of the previous box
$maxyoffset = 0;
$linesize = 3;
if (!isset($brborder)) $brborder = 1; // Avoid errors from old custom themes
for ($i=($controller->treesize-1); $i>=0; $i--) {
// -- check to see if we have moved to the next generation
if ($i < floor($controller->treesize / (pow(2, $curgen)))) {
$curgen++;
}
$prevxoffset = $xoffset;
$prevyoffset = $yoffset;
if ($talloffset < 2) { // Portrate 0 Landscape 1 top 2 bottom 3
$xoffset = $controller->offsetarray[$i]["x"];
$yoffset = $controller->offsetarray[$i]["y"];
} else {
$xoffset = $controller->offsetarray[$i]["y"];
$yoffset = $controller->offsetarray[$i]["x"];
}
// -- if we are in the middle generations then we need to draw the connecting lines
if (($curgen > 0 && $talloffset > 1) || (($curgen > $talloffset) && ($curgen < $controller->PEDIGREE_GENERATIONS))) {
if ($i%2==1) {
if ($SHOW_EMPTY_BOXES || ($controller->treeid[$i]) || ($controller->treeid[$i+1])) {
if ($talloffset < 2) {
$vlength = $prevyoffset-$yoffset;
$lastvlength = $vlength;
// If no father then adjust lines
if (!$controller->treeid[$i] && (!$SHOW_EMPTY_BOXES)) {
$vlength = ($lastvlength/2);
if ($talloffset == 0 && $show_full==1) $yoffset = $yoffset+$controller->pbheight+50;
if ($talloffset == 0 && $show_full==0) $yoffset = $yoffset+$controller->pbheight+30;
if ($talloffset == 1) $yoffset = $yoffset+$controller->pbheight+5;
}
}
else {
$vlength = $prevxoffset-$xoffset;
}
if (!$SHOW_EMPTY_BOXES && (empty($controller->treeid[$i+1]))) {
$parent = ceil(($i-1)/2);
$vlength = $controller->offsetarray[$parent]["y"]-$yoffset;
}
$linexoffset = $xoffset;
if ($talloffset < 2) {
echo '<div id="line', $i, '" dir="';
if ($TEXT_DIRECTION=="rtl") {
echo 'rtl" style="position:absolute; right:';
} else {
echo 'ltr" style="position:absolute; left:';
}
echo ($linexoffset-2), 'px; top:', ($yoffset+1+$controller->pbheight/2), 'px; z-index: 0;">'; // vertical line joining boxes
echo '<img src="', $WT_IMAGES['vline'], '" width="', $linesize, '" height="', ($vlength-1), '" alt="" >'; // vertical line joining boxes
echo '</div>';
} else {
echo '<div id="vline', $i, '" dir="';
if ($TEXT_DIRECTION=="rtl") {
echo 'rtl" style="position:absolute; right:';
} else {
echo 'ltr" style="position:absolute; left:';
}
if ($talloffset > 2) {
echo ($linexoffset-2+$controller->pbwidth/2+$vlength/2), 'px; top:', ($yoffset+1-$controller->pbheight/2+10), 'px; z-index: 0;">';
echo '<img src="', $WT_IMAGES['vline'], '" width="', $linesize, '" height="', ($controller->pbheight), '" alt="" >';
} else {
echo ($linexoffset-1+$controller->pbwidth/2+$vlength/2), 'px; top:', ($yoffset+1+$controller->pbheight/2+10), 'px; z-index: 0;">';
echo '<img src="', $WT_IMAGES['vline'], '" width="', $linesize, '" height="', ($controller->pbheight), '" alt="" >';
}
echo '</div>';
echo '<div id="line', $i, '" dir="';
if ($TEXT_DIRECTION=="rtl") {
echo 'rtl" style="position:absolute; right:';
} else {
echo 'ltr" style="position:absolute; left:';
}
echo ($linexoffset+$controller->pbwidth), 'px; top:', ($yoffset+1+$controller->pbheight/2), 'px; z-index: 0;\">';
echo '<img src="', $WT_IMAGES['hline'], '" width="', ($vlength-$controller->pbwidth), '" height="', $linesize, '" alt="">';
echo '</div>';
}
} else { // here if no parents and no empty boxes
$vlength = $prevxoffset-$xoffset;
$linexoffset = $xoffset;
}
}
}
// -- draw the box
if (!empty($controller->treeid[$i]) || $SHOW_EMPTY_BOXES) {
// Work around a bug in FireFox that mis-places some boxes in Portrait RTL, resulting in
// vertical lines that themselves appear to be mis-placed.
if ($TEXT_DIRECTION=="rtl") {
$xoffset += $brborder; // Account for thickness of right box border
}
if ($yoffset>$maxyoffset) {
$maxyoffset=$yoffset;
}
$widthadd = 0;
if ($i==0) {
$iref = rand();
} else {
$iref = $i;
}
// Can we go back to an earlier generation?
$can_go_back=$curgen==1 && WT_Person::getInstance($controller->treeid[$i]) && WT_Person::getInstance($controller->treeid[$i])->getChildFamilies();
if ($can_go_back) {
$widthadd = 20;
} elseif ($curgen >2 && $curgen < $controller->PEDIGREE_GENERATIONS) {
$widthadd = 10;
}
if ($talloffset == 2) {
echo '<div id="uparrow" dir="';
if ($TEXT_DIRECTION=="rtl") {
echo 'rtl" style="position:absolute; right:';
} else {
echo 'ltr" style="position:absolute; left:';
}
echo ($xoffset+$controller->pbwidth/2-5), 'px; top:', ($yoffset-20), 'px; width:10px; height:10px;">';
if ($can_go_back) {
$did = 1;
if ($i > ($controller->treesize/2) + ($controller->treesize/4)-1) {
$did++;
}
echo '<a href=pedigree.php?PEDIGREE_GENERATIONS=', $controller->PEDIGREE_GENERATIONS, '&rootid=', $controller->treeid[$did], '&show_full=', $controller->show_full, '&talloffset=', $controller->talloffset, ' ';
echo "onmouseover=\"swap_image('arrow$i', 2);\" onmouseout=\"swap_image('arrow$i', 2);\">";
echo '<img id="arrow', $i, '" class="noprint" src="', $WT_IMAGES['uarrow'], '" alt="">';
echo '</a>';
}
echo "</div>";
}
// beginning of box setup and display
echo "<div id=\"box";
if (empty($controller->treeid[$i])) {
echo "$iref";
} else {
echo $controller->treeid[$i];
}
if ($TEXT_DIRECTION=="rtl") {
echo ".1.$iref\" style=\"position:absolute; right:";
} else {
echo ".1.$iref\" style=\"position:absolute; left:";
}
if ($talloffset == 2) {
$zindex = $PEDIGREE_GENERATIONS-$curgen;
} else {
$zindex = 0;
}
//Correct box spacing for Oldest on bottom
if (($talloffset == 3) && ($curgen ==1)) {
$yoffset +=25;
}
if (($talloffset == 3) && ($curgen ==2)) {
$yoffset +=10;
}
echo $xoffset, "px; top:", ($yoffset-1), "px; width:", ($controller->pbwidth+$widthadd), "px; height:", $controller->pbheight, "px; ";
echo "z-index: ", $zindex, ";\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" dir=\"$TEXT_DIRECTION\">";
if (($talloffset < 2) && ($curgen > $talloffset) && ($curgen < $controller->PEDIGREE_GENERATIONS)) {
echo "<tr><td>";
echo "<img src=\"", $WT_IMAGES["hline"], "\" align=\"left\" alt=\"\">";
echo "</td><td width=\"100%\">";
} else {
echo "<tr><td width=\"100%\">";
}
if (!isset($controller->treeid[$i])) {
$controller->treeid[$i] = false;
}
print_pedigree_person(WT_Person::getInstance($controller->treeid[$i]), 1, $iref, 1);
if ($can_go_back) {
$did = 1;
if ($i > ($controller->treesize/2) + ($controller->treesize/4)-1) {
$did++;
}
if ($talloffset==3) {
echo "</td></tr><tr><td align=\"center\">";
echo "<a href=\"pedigree.php?PEDIGREE_GENERATIONS={$controller->PEDIGREE_GENERATIONS}&rootid={$controller->treeid[$did]}&show_full={$controller->show_full}&talloffset={$controller->talloffset}\" ";
echo "onmouseover=\"swap_image('arrow$i', 3);\" onmouseout=\"swap_image('arrow$i', 3);\">";
echo '<img id="arrow', $i, '" class="noprint" src="', $WT_IMAGES['darrow'], '" alt="">';
} elseif ($talloffset < 2) {
echo "</td><td valign=\"middle\">";
echo "<a href=\"pedigree.php?PEDIGREE_GENERATIONS={$controller->PEDIGREE_GENERATIONS}&rootid={$controller->treeid[$did]}&show_full={$controller->show_full}&talloffset={$talloffset}\" ";
if ($TEXT_DIRECTION=="rtl") {
echo "onmouseover=\"swap_image('arrow$i', 0);\" onmouseout=\"swap_image('arrow$i', 0);\">";
echo '<img id="arrow', $i, '" class="noprint" src="', $WT_IMAGES['larrow'], '" alt="">';
} else {
echo "onmouseover=\"swap_image('arrow$i', 1);\" onmouseout=\"swap_image('arrow$i', 1);\">";
echo '<img id="arrow', $i, '" class="noprint" src="', $WT_IMAGES['rarrow'], '" alt="">';
}
echo "</a>";
}
}
echo "</td></tr></table></div>";
}
}
// -- echo left arrow for decendants so that we can move down the tree
$yoffset += ($controller->pbheight / 2)-10;
$famids = $controller->root->getSpouseFamilies();
//-- make sure there is more than 1 child in the family with parents
$cfamids = $controller->root->getChildFamilies();
if (count($famids)>0) {
echo "<div id=\"childarrow\" dir=\"";
if ($TEXT_DIRECTION=="rtl") {
echo "rtl\" style=\"position:absolute; right:";
} else {
echo "ltr\" style=\"position:absolute; left:";
}
switch ($talloffset) {
case 0:
if ($PEDIGREE_GENERATIONS<6) {
$addxoffset = 60*(5-$PEDIGREE_GENERATIONS);
} else {
$addxoffset = 0;
}
echo $addxoffset, "px; top:", $yoffset, "px; width:10px; height:10px;\">";
if ($TEXT_DIRECTION=="rtl") {
echo "<a href=\"#\" onclick=\"togglechildrenbox(); return false;\" onmouseover=\"swap_image('arrow0', 1);\" onmouseout=\"swap_image('arrow0', 1);\">";
echo '<img id="arrow0" class="noprint" src="', $WT_IMAGES['rarrow'], '" alt="">';
} else {
echo "<a href=\"#\" onclick=\"togglechildrenbox(); return false;\" onmouseover=\"swap_image('arrow0', 0);\" onmouseout=\"swap_image('arrow0', 0);\">";
echo '<img id="arrow0" class="noprint" src="', $WT_IMAGES['larrow'], '" alt="">';
}
break;
case 1:
if ($PEDIGREE_GENERATIONS<4) $basexoffset += 60;
echo $basexoffset, "px; top:", $yoffset, "px; width:10px; height:10px;\">";
if ($TEXT_DIRECTION=="rtl") {
echo "<a href=\"#\" onclick=\"togglechildrenbox(); return false;\" onmouseover=\"swap_image('arrow0', 1);\" onmouseout=\"swap_image('arrow0', 1);\">";
echo '<img id="arrow0" class="noprint" src="', $WT_IMAGES['rarrow'], '" alt="">';
} else {
echo "<a href=\"#\" onclick=\"togglechildrenbox(); return false;\" onmouseover=\"swap_image('arrow0', 0);\" onmouseout=\"swap_image('arrow0', 0);\">";
echo '<img id="arrow0" class="noprint" src="', $WT_IMAGES['larrow'], '" alt="">';
}
break;
case 2:
echo ($linexoffset-10+$controller->pbwidth/2+$vlength/2), "px; top:", ($yoffset+$controller->pbheight/2+10), "px; width:10px; height:10px;\">";
echo "<a href=\"#\" onclick=\"togglechildrenbox(); return false;\" onmouseover=\"swap_image('arrow0', 3);\" onmouseout=\"swap_image('arrow0', 3);\">";
echo '<img id="arrow0" class="noprint" src="', $WT_IMAGES['darrow'], '" alt="">';
break;
case 3:
echo ($linexoffset-10+$controller->pbwidth/2+$vlength/2), "px; top:", ($yoffset-$controller->pbheight/2-10), "px; width:10px; height:10px;\">";
echo "<a href=\"#\" onclick=\"togglechildrenbox(); return false;\" onmouseover=\"swap_image('arrow0', 2);\" onmouseout=\"swap_image('arrow0', 2);\">";
echo '<img id="arrow0" class="noprint" src="', $WT_IMAGES['uarrow'], '" alt="">';
break;
}
echo "</a>";
echo "</div>";
$yoffset += ($controller->pbheight / 2)+10;
echo "<div id=\"childbox\" dir=\"";
if ($TEXT_DIRECTION=="rtl") {
echo "rtl\" style=\"position:absolute; right:";
} else {
echo "ltr\" style=\"position:absolute; left:";
}
echo $xoffset, "px; top:", $yoffset, "px; width:", $controller->pbwidth, "px; height:", $controller->pbheight, "px; visibility: hidden;\">";
echo "<table class=\"person_box\"><tr><td>";
foreach ($famids as $family) {
$spouse=$family->getSpouse($controller->root);
if ($spouse) {
echo "<a href=\"pedigree.php?PEDIGREE_GENERATIONS={$controller->PEDIGREE_GENERATIONS}&rootid=".$spouse->getXref()."&show_full={$controller->show_full}&talloffset={$talloffset}\"><span ";
$name = $spouse->getFullName();
if (hasRTLText($name)) {
echo 'class="name2">';
} else {
echo 'class="name1">';
}
echo $name;
echo '<br></span></a>';
}
$children = $family->getChildren();
foreach ($children as $child) {
echo " <a href=\"pedigree.php?PEDIGREE_GENERATIONS={$controller->PEDIGREE_GENERATIONS}&rootid=".$child->getXref()."&show_full={$controller->show_full}&talloffset={$talloffset}\"><span ";
$name = $child->getFullName();
if (hasRTLText($name)) {
echo "class=\"name2\">< ";
} else {
echo "class=\"name1\">< ";
}
echo $name;
echo '<br></span></a>';
}
}
//-- echo the siblings
foreach ($cfamids as $family) {
if ($family!=null) {
$children = $family->getChildren();
if (count($children)>2) {
echo '<span class="name1"><br>', WT_I18N::translate('Siblings'), '<br></span>';
}
if (count($children)==2) {
echo '<span class="name1"><br>', WT_I18N::translate('Sibling'), '<br></span>';
}
foreach ($children as $child) {
if (!$controller->root->equals($child) && !is_null($child)) {
echo " <a href=\"pedigree.php?PEDIGREE_GENERATIONS={$controller->PEDIGREE_GENERATIONS}&rootid=".$child->getXref()."&show_full={$controller->show_full}&talloffset={$talloffset}\"><span ";
$name = $child->getFullName();
if (hasRTLText($name)) {
echo 'class="name2"> ';
} else {
echo 'class="name1"> ';
}
echo $name;
echo '<br></span></a>';
}
}
}
}
echo "</td></tr></table>";
echo "</div>";
}
// -- print html footer
$maxyoffset+=30;
?>
</div>
<script type="text/javascript">
content_div = document.getElementById("content");
if (content_div) {
content_div.style.height = <?php echo $maxyoffset; ?> + "px";
}
</script>
|