Passed
Branch master (465698)
by Michael
05:38
created

coi.php ➔ boucle()   F

Complexity

Conditions 16
Paths 1364

Size

Total Lines 53
Code Lines 35

Duplication

Lines 30
Ratio 56.6 %

Importance

Changes 0
Metric Value
cc 16
eloc 35
nc 1364
nop 2
dl 30
loc 53
rs 3.2679
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
ini_set('memory_limit', '32M');
3
4
require_once dirname(dirname(__DIR__)) . '/mainfile.php';
5
$moduleDirName = basename(__DIR__);
6
xoops_loadLanguage('main', $moduleDirName);
7
require_once(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php');
8
9
$xoopsOption['template_main'] = 'pedigree_coi.tpl';
10
include XOOPS_ROOT_PATH . '/header.php';
11
12
//get module configuration
13
$moduleHandler = xoops_getHandler('module');
14
$module        = $moduleHandler->getByDirname('pedigree');
0 ignored issues
show
Bug introduced by
The method getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
$module        = $moduleHandler->/** @scrutinizer ignore-call */ getByDirname('pedigree');
Loading history...
15
$configHandler = xoops_getHandler('config');
16
$moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
0 ignored issues
show
Bug introduced by
The method getConfigsByCat() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
$moduleConfig  = $configHandler->/** @scrutinizer ignore-call */ getConfigsByCat(0, $module->getVar('mid'));
Loading history...
17
18
global $xoopsTpl, $xoopsDB, $moduleConfig;
19
20
//start kinship.php code -- help !!
21
/* ************************************************************************************* */
22
/*
23
     This program calculates the coefficient of inbreeding (IC, or COI, or F)
24
     for the offspring of a couple of animals, given by their IDs (s=sire_ID&d=dam_ID),
25
     or for a given animal given by its ID (a=animal_ID).
26
27
     By default, all known ascendants are used.
28
     However, maximum count of distinct ascendants is limited to $nb_maxi (default=600)
29
              [higher values for $nb_maxi could lead to calculations ending in timeout],
30
              or depth of tree can be limited to $nb_gen generations (default = 8).
31
*/
32
/* ************************************************************************************* */
33
34
if (!isset($verbose)) {
35
    $verbose = 0;
36
} // don't display different steps of ICs calculation
37
if (!isset($detail)) {
38
    $detail = 1;
39
} // don't display detail results [faster]
40
if (!isset($nb_maxi)) {
41
    $nb_maxi = 600;
42
} // maximum count of distinct ascendants
43
if (!isset($nb_gen)) {
44
    $nb_gen = 8;
45
} // maximum count of generations of ascendants
46
if (!isset($pedigree)) {
47
    $pedigree = 0;
48
} // dont't display sketch pedigree [faster]
49
if (!isset($max_dist)) { // maximum length of implex loops
50
    if ($nb_gen > 9) {
51
        $max_dist = 14;
52
    } else {
53
        if ($nb_gen == 9) {
54
            $max_dist = 17;
55
        } else {
56
            if ($nb_gen == 8) {
57
                $max_dist = 18;
58
            } else {
59
                $max_dist = 99;
60
            }
61
        }
62
    }
63
}
64
65
$empty = array(); // an empty array
66
$sql1  = 'SELECT Id, father, mother, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE Id ';
67
68
// input data arrays:
69
$IDs     = $empty;
70
$fathers = $empty;
71
$mothers = $empty;
72
73
// working arrays:
74
$inds    = $empty;
75
$marked  = $empty;
76
$ICknown = $empty;
77
$deltaf  = $empty;
78
$pater   = $empty;
79
$mater   = $empty;
80
$chrono  = $empty;
81
82
// Coefficients of Inbreeding array (result):
83
$COIs = $empty;
84
85
/* ******************************  FUNCTIONS  ********************************* */
86
87
/**
88
 * @return int
89
 */
90
function chrono_sort()
91
{
92
    global $IDs, $inds, $fathers, $mothers, $chrono, $nl, $detail;
93
    $impr  = 0;
94
    $modif = 1;
95
    $nloop = 0;
96
    $nba   = count($IDs);
97
    // print_r ($IDs) ;
98
    // echo "<b>231 : $IDs[231] $fathers[231] $mothers[231] $chrono[231] $inds[231] </b><br />\n" ;
99
    foreach ($IDs as $i => $v) {
100
        $chrono[$i] = 1;
101
    } // initialize all chronological ranks to 1
102
    $chrono[0] = 0; // except animal #0 (at 0 rank).
103
    while ($modif && $nloop < 40) {
104
        $modif = 0;
105
        ++$nloop;
106
        for ($i = 1; $i < $nba; ++$i) {
107
            $s = $fathers[$i];
108
            if ($s) {
109
                $s = $inds[$s];
110
            }
111
            $d = $mothers[$i];
112
            if ($d) {
113
                $d = $inds[$d];
114
            }
115
            if ($s && $chrono[$s] <= $chrono[$i]) {
116
                $chrono[$s] = $chrono[$i] + 1;
117
                $modif      = 1;
118
            }
119
            if ($d && $chrono[$d] <= $chrono[$i]) {
120
                $chrono[$d] = $chrono[$i] + 1;
121
                $modif      = 1;
122
            }
123
        }
124
    }
125
    if ($nloop == 40) {
126
        die('Endless loop detected. Stopped.');
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
127
    }
128
    array_multisort($chrono, $IDs, $fathers, $mothers);
129
    $depth = $chrono[$nba - 1];
0 ignored issues
show
Unused Code introduced by
The assignment to $depth is dead and can be removed.
Loading history...
130
    //commentes out by JC
131
    //if ($detail) echo "<br />Chronological ranking done : Pedigree stretched over <b>$depth</b> generations.<br />$nl" ;
132
    if ($impr) {
133
        echo "</center><pre>$nl $nl";
134
        foreach ($chrono as $i => $val) {
135
            echo "<b>$i</b> : $val $IDs[$i] $fathers[$i] $mothers[$i] $nl";
136
        }
137
        echo "</pre>$nl";
138
        die('</html>');
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
139
    }
140
    $inds = array_flip($IDs);
141
142
    return 0;
143
}
144
145
/**
146
 * @param $s
147
 *
148
 * @return array
149
 */
150
function fetch_record($s)
151
{
152
    global $database;
153
    $r = mysqli_db_query($database, $s);
0 ignored issues
show
Bug introduced by
The function mysqli_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

153
    $r = /** @scrutinizer ignore-call */ mysqli_db_query($database, $s);
Loading history...
154
    $n = 0;
155
    if ($r) {
156
        $n = mysqli_num_rows($r);
157
    }
158
    if ($n == 0) {
159
        $record = array('0');
160
    } else {
161
        $record = $GLOBALS['xoopsDB']->fetchBoth($r);
162
    }
163
164
    return $record;
165
}
166
167
/**
168
 * @param $ind
169
 * @param $gen
170
 *
171
 * @return int
172
 */
173
function count_all($ind, $gen)
174
{
175
    global $inds, $nb_gen, $nb_all, $fathers, $mothers;
176
    if ($ind) {
177
        ++$nb_all;
178
    }
179
    $s = $fathers[$ind];
180
    $d = $mothers[$ind];
181
    if ($s && $gen < $nb_gen) {
182
        count_all($s, $gen + 1);
183
    }
184
    if ($d && $gen < $nb_gen) {
185
        count_all($d, $gen + 1);
186
    }
187
188
    return 0;
189
}
190
191
/**
192
 * @param $ch
193
 * @param $niv
194
 *
195
 * @return int
196
 */
197
function add_multi($ch, $niv)
198
{
199
    global $implx, $couls, $nl;
200
    reset($implx);
201
    $first = 1;
202
    foreach ($implx as $im => $impl) {
203
        if ($impl[0] == $ch || $impl[1] == $ch) {
204
            if ($niv > 1 && $first) {
205
                echo "<br />$nl";
206
            } else {
207
                echo '&nbsp;&nbsp;&nbsp;';
208
            }
209
            $i     = $im + 1;
210
            $j     = min($im, 6);
211
            $c     = $couls[$j];
212
            $first = 0;
213
            echo '<font color=' . $c . ' size="+2"><b>*' . $i . '*</b></font>';
214
        }
215
    }
216
217
    return 0;
218
}
219
220
/**
221
 * @param $ind
222
 * @param $gen
223
 * @param $class
224
 *
225
 * @return int
226
 */
227
function output_animal($ind, $gen, $class)
228
{
229
    global $depth, $IDs, $fathers, $mothers, $nl;
230
    if ($gen > $depth) {
231
        return 0;
232
    }
233
    $cell_content = '&Oslash;';
234
    if ($ind || $gen == 0) {
235
        $ID           = $IDs[$ind];
236
        $ani          = set_name($ID);
237
        $name         = $ani[1];
0 ignored issues
show
Unused Code introduced by
The assignment to $name is dead and can be removed.
Loading history...
238
        $name         = $ID;
239
        $cell_content = showParent($name) . $nl;
0 ignored issues
show
Bug introduced by
The function showParent was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

239
        $cell_content = /** @scrutinizer ignore-call */ showParent($name) . $nl;
Loading history...
240
    }
241
    $rowspan = 1 << ($depth - $gen);
242
    echo '<td rowspan=' . $rowspan . ' align="center" class="' . $class . '">' . $cell_content . "</td>$nl";
243
    if ($gen < $depth) {
244
        $sire = 0;
245
        if ($ind || $gen == 0) {
246
            $sire = $fathers[$ind];
247
        }
248
        output_animal($sire, $gen + 1, '0');
249
        $dam = 0;
250
        if ($ind || $gen == 0) {
251
            $dam = $mothers[$ind];
252
        }
253
        output_animal($dam, $gen + 1, '1');
254
    } else {
255
        echo "</tr><tr>$nl";
256
    }
257
258
    return 0;
259
}
260
261
/**
262
 * @return int
263
 */
264
function SKETCH_PEDIGREE()
265
{
266
    global $nl, $detail, $depth, $IDs;
267
    // print_r ($IDs) ;
268
    echo $nl . '<br />' . $nl . '<table border="3" cellpadding="4" width="85%"" cellpadding="0" cellspacing="0">' . $nl . '<tr><th colspan="10" align="center">SKETCH &nbsp; PEDIGREE &nbsp; OF COMMON PROGENY</th></tr>' . $nl . '<tr align="center" valign="middle"><th>Progeny</th><th>' . _('Sire / Dam') . '</th>';
269
    if ($depth >= 2) {
270
        echo '<th>' . _('Grandparents') . '</th>' . $nl;
271
    }
272
    if ($depth >= 3) {
273
        echo '<th>' . _('Great-Grandparents') . '</th>' . $nl;
274
    }
275
    if ($depth >= 4) {
276
        echo '<th>3xGr. P.</th>' . $nl;
277
    }
278
    if ($depth >= 5) {
279
        echo '<th>4xGr. P.</th>' . $nl;
280
    }
281
    if ($depth >= 6) {
282
        echo '<th>5xGr. P.</th>' . $nl;
283
    }
284
    if ($depth >= 7) {
285
        echo '<th>6xGr. P.</th>' . $nl;
286
    }
287
    echo '</tr><tr>';
288
    output_animal(0, 0, '0'); /* output the sketch pedigree */
289
    echo $nl . '</tr></table>' . $nl . '<p />' . $nl;
290
291
    return 0;
292
}
293
294
/**
295
 * @return int
296
 */
297
function GENEALOGY()
298
{
299
    global $IDs, $fathers, $mothers, $inds, $nb_gen, $nb_maxi, $nbani, $nl, $sql1;
300
    $impr       = 0;
301
    $fathers[0] = $IDs[1];
302
    $mothers[0] = $IDs[2];
303
    $fathers[1] = 0;
304
    $mothers[1] = 0;
305
    $fathers[2] = 0;
306
    $mothers[2] = 0;
307
    $last       = 2;
308
    if ($impr) {
309
        echo "<!-- genealogy 'de cujus' (gener. 0) : $IDs[0] = $IDs[1] x $IDs[2] -->$nl";
310
    }
311
    $generation = array($IDs[1], $IDs[2]); // starting with first generation (sire and dam)
312
    $nbtot      = 0; // count of total known ascendants within $nb_gen generations
313
    for ($nloop = 1, $tot = 2; $last <= $nb_maxi && $nloop <= $nb_gen; ++$nloop) {
314
        $nbtot += $tot; // count of total known ascendants within $nb_gen generations
315
        $nbani      = $last; // count of    distinct ascendants within $nb_gen generations
316
        $list       = implode(',', array_unique($generation));
317
        $generation = array();
318
        $tot        = 0;
319
        if ($impr) {
320
            echo "    [$list]$nl";
321
        }
322
323
        // HERE IS FETCHED EACH TRIPLET [ID, sire_ID, dam_ID] :
324
        $r = $GLOBALS['xoopsDB']->query("$sql1 IN ($list)");
325
        while (false !== ($rec = $GLOBALS['xoopsDB']->fetchBoth($r))) {
326
            $a = $rec[0] + 0;
327
            $s = $rec[1] + 0;
328
            $d = $rec[2] + 0;
329
            if (!$a) {
330
                echo "ERROR : $a = $s x $d for list = '$list'<br />\n";
331
            }
332
            if ($s) {
333
                ++$tot;
334
            }
335
            if ($d) {
336
                ++$tot;
337
            }
338
            $j           = array_keys($IDs, $a);
339
            $j           = $j[0];
340
            $fathers[$j] = $s;
341
            $mothers[$j] = $d;
342
            if ($s && !in_array($s, $IDs)) {
343
                $i           = ++$last;
344
                $IDs[$i]     = $s;
345
                $fathers[$i] = 0;
346
                $mothers[$i] = 0;
347
                if ($s) {
348
                    $generation[] = $s;
349
                }
350
            }
351
            if ($d && !in_array($d, $IDs)) {
352
                $i           = ++$last;
353
                $IDs[$i]     = $d;
354
                $fathers[$i] = 0;
355
                $mothers[$i] = 0;
356
                if ($s) {
357
                    $generation[] = $d;
358
                }
359
            }
360
            if ($impr) {
361
                echo "<pre>genealogy ascendant (gener. $nloop) : $a = $s x $d  [tot = $tot]$nl</pre>";
362
            }
363
        }
364
        if (!count($generation)) {
365
            break;
366
        }
367
    }
368
369
    if ($nloop <= $nb_gen) {
370
        $nb_gen = $nloop;
371
    } // tree cut by $nb_maxi !
372
373
    reset($IDs);
374
    $inds = array_flip($IDs);
375
376
    chrono_sort();
377
378
    return $nbtot;
379
}
380
381
/**
382
 * @param $p
383
 *
384
 * @return int
385
 */
386
function dist_p($p)
387
{
388
    global $IDs, $fathers, $mothers, $pater, $nb_gen, $detail, $nl;
389
    // Anim #P is the sire
390
    $listall   = array($p);
391
    $listnew   = array($p);
392
    $pater     = array();
393
    $pater[$p] = 1;
394
    for ($nloop = 2; $nloop < ($nb_gen + 1); ++$nloop) {
395
        $liste = array();
396
        foreach ($listnew as $i) {
397
            $s = $fathers[$i];
398
            $d = $mothers[$i];
399
            if ($s && !$pater[$s]) {
400
                $pater[$s] = $nloop;
401
            } // least distance from $s to sire's progeny
402
            if ($d && !$pater[$d]) {
403
                $pater[$d] = $nloop;
404
            } // least distance from $d to sire's progeny
405
            if ($s) {
406
                $liste[] = $s;
407
            }
408
            if ($d) {
409
                $liste[] = $d;
410
            }
411
        }
412
        if (!count($liste)) {
413
            break;
414
        }
415
        //commented pout by jc
416
        //if (in_array ($IDs[2], $liste) && !$detail)
417
        //{ echo "<p>DAM is an ascendant (at $nloop generations) of SIRE.  Stopped." ;
418
        // die ("</body></html>$nl") ; }
419
        $listnew = array_diff(array_unique($liste), $listall);
420
        /* $list1 = join (' ', $listall) ; $list2 = join ('+', $listnew) ;
421
             echo "<!-- P ($nloop) $list1/$list2 -->$nl" ; */
422
        $listall = array_merge($listall, $listnew);
423
    }
424
    // Here $pater array contains list of all distinct ascendants of #P (including P himself)
425
    // Values of $pater are minimum distances to #P (in generations) +1
426
    return 0;
427
}
428
429
/**
430
 * @param $m
431
 *
432
 * @return int
433
 */
434
function dist_m($m)
435
{
436
    global $IDs, $fathers, $mothers, $mater, $nb_gen, $detail, $nl;
437
    // Anim #M is the dam
438
    $listall   = array($m);
439
    $listnew   = array($m);
440
    $mater     = array();
441
    $mater[$m] = 1;
442
    for ($nloop = 2; $nloop <= ($nb_gen + 1); ++$nloop) {
443
        $liste = array();
444
        foreach ($listnew as $i) {
445
            $s = $fathers[$i];
446
            $d = $mothers[$i];
447
            if ($s && !$mater[$s]) {
448
                $mater[$s] = $nloop;
449
            } // least distance from $s to dam's progeny
450
            if ($d && !$mater[$d]) {
451
                $mater[$d] = $nloop;
452
            } // least distance from $d to dam's progeny
453
            // echo "I=" . $i . " MATER(I)=" . $mater[$i] . " NLOOP=" . $nloop . "<br />$nl" ;
454
            if ($s) {
455
                $liste[] = $s;
456
            }
457
            if ($d) {
458
                $liste[] = $d;
459
            }
460
        }
461
        if (!count($liste)) {
462
            break;
463
        }
464
        //commented out by jc
465
        //if (in_array ($IDs[1], $liste) && !$detail)
466
        // { echo "<p>SIRE is an ascendant (at $nloop generations) of DAM.  Stopped." ;
467
        //  die ("</body></html>$nl") ; }
468
        $listnew = array_diff(array_unique($liste), $listall);
469
        // $list1 = join (' ', $listall) ; $list2 = join ('+', $listnew) ; echo "M ($nloop) $list1/$list2 $nl" ;
470
        $listall = array_merge($listall, $listnew);
471
    }
472
    // Here $mater array contains list of all distinct ascendants of #M (including M herself)
473
    // Values of $mater are minimum distances to #M (in generations) +1
474
    return 0;
475
}
476
477
/**
478
 * @return array
479
 */
480
function calc_dist() /* Common Ascendants and their distances */
481
{
482
    global $IDs, $fathers, $mothers, $nbanims, $pater, $mater, $empty, $nb_gen, $nl;
483
    global $dmax, $detail, $nb_gen;
484
    $distan = array();
485
    // dist_m (2) ;   has already been called
486
    dist_p($fathers[0]);
487
    $dmax = 0;
488
    $impr = 0;
489
    $dmx  = 7;
490
    if ($detail) {
491
        $dmx += 2;
492
    }
493
    // ksort ($pater) ; print_r ($pater) ; echo "<br />$nl" ; ksort ($mater) ; print_r ($mater) ; echo "<br />$nl" ;
494
    foreach ($pater as $i => $p) {
495
        if ($p) {
496
            $m = $mater[$i];
497
            if ($m) {
498
                $di = $p + $m;
499
                if ($impr) {
500
                    echo " $i : $p + $m = $di <br />$nl";
501
                }
502
                if (!$dmax) {
503
                    $dmax = $dmx + $di - ceil($di / 2.);
504
                }
505
                if ($di > ($dmax + 2)) {
506
                    continue;
507
                }
508
                $distan[$i] = $di;
509
            }
510
        }
511
    }
512
    if (!$dmax) {
513
        $dmax = 2 * $nb_gen - 2;
514
    }
515
516
    return $distan;
517
}
518
519
/**
520
 * @param $p
521
 * @param $m
522
 * @param $a
523
 * @param $ndist
524
 *
525
 * @return int
526
 */
527
function mater_side($p, $m, $a, $ndist)
528
{
529
    global $fathers, $mothers, $marked, $COIs, $deltaf, $ICknown, $verbose, $nl, $chrono, $paternal_rank, $max_dist;
530
    if (!$m || $ndist > $max_dist) {
531
        return 0;
532
    }
533
    if ($p == $m) {
534
        /* IMPLEX FOUND (node of consanguinity) { for Anim #A */
535
        $already_known = $ICknown[$p];
536
    }
537
    if (!$already_known) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $already_known does not seem to be defined for all execution paths leading up to this point.
Loading history...
538
        CONSANG($p);
539
    } // MAIN RECURSION:
540
    $ICp = $COIs[$p]; // we need to know the IC of Parent for Wright's formula
541
    if ($verbose && !$already_known && $ICp > 0.001 * $verbose) {
542
        echo "IC of Animal $p is $ICp$nl";
543
    }
544
    $incr = 1.0 / (1 << $ndist) * (1. + $ICp); // ******** applying WRIGHT's formula ********
545
546
    // [Note:  1 << $ndist is equal to 2 power $ndist]
547
    $COIs[$a] += $incr; // incrementing the IC of AnimC
548
    if ($a == 0) {
549
        $deltaf[$p] += $incr;
550
    }
551
    /* contribution of Anim #P to IC of Anim #0 */
552
    // if ($verbose && $a == 0 && $incr > 0.0001*$verbose)
553
    //    echo "Animal $p is contributing for " . substr ($deltaf[$p], 0, 10) . " to the IC of Animal $a$nl" ;}
554
    else {
555
        if (!$marked[$m] && $chrono[$m] < $paternal_rank) {
556
            mater_side($p, $fathers[$m], $a, $ndist + 1);
557
        }
558
        mater_side($p, $mothers[$m], $a, $ndist + 1);
559
    }
560
561
    return 0;
562
}
563
564
/**
565
 * @param $p
566
 * @param $m
567
 * @param $a
568
 * @param $pdist
569
 *
570
 * @return int
571
 */
572
function pater_side($p, $m, $a, $pdist)
573
{
574
    global $mater, $fathers, $mothers, $marked, $chrono, $paternal_rank;
575
    if (!$p) {
576
        return 0;
577
    }
578
    $paternal_rank = $chrono[$p];
579
    $marked[$p]    = 1; /* cut paternal side */
580
    if ($mater[$p] || $a) {
581
        mater_side($p, $m, $a, $pdist);
582
    }
583
    pater_side($fathers[$p], $m, $a, $pdist + 1);
584
    pater_side($mothers[$p], $m, $a, $pdist + 1);
585
    $marked[$p] = 0; /* free paternal side */
586
587
    return 0;
588
}
589
590
/**
591
 * @param $a
592
 *
593
 * @return int
594
 */
595
function CONSANG($a)
596
{
597
    global $fathers, $mothers, $ICknown, $COIs, $nl;
598
    if (!$a || $ICknown[$a]) {
599
        return 0;
600
    }
601
    if ($a == -1) {
602
        $a = 0;
603
    } // particular case : a= -1 means Anim #0 (to bypass above test)
604
    $IC_if_deadend = 0.0; // 0.0 means taht deadends are deemed to be total outcrosses...
605
    // if IC was already stored in the database for Aminal #A, it should be used here instead of 0.0
606
    $p = $fathers[$a];
607
    $m = $mothers[$a];
608
    if (!$p || !$m) {
609
        $COIs[$a]    = $IC_if_deadend;
610
        $ICknown[$a] = 2;
611
612
        return 0;
613
    }
614
615
    if ($verbose) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $verbose seems to be never defined.
Loading history...
616
        echo "</center><pre>$nl";
617
    }
618
    pater_side($p, $m, $a, 1); // launch tree exploration
619
    if ($verbose) {
620
        echo "</pre><center>$nl";
621
    }
622
623
    $ICknown[$a] = 1;
624
    $p           = $fathers[$a];
625
    $m           = $mothers[$a];
626
    foreach ($fathers as $i => $pere) {/* siblings share the same COI value */
627
        if ($i <> $a && $pere == $p && $mothers[$i] == $m) {
628
            $COIs[$i]    = $COIs[$a];
629
            $ICknown[$i] = 1;
630
        }
631
    }
632
    // echo "<!-- COI($a) = $COIs[$a] $IDs[$a] ($fathers[$a] x $mothers[$a])-->$nl" ;
633
    return 0;
634
}
635
636
/**
637
 * @param $nb_gen
638
 * @param $nloop
639
 *
640
 * @return int
641
 */
642
function boucle($nb_gen, $nloop)
643
{
644
    global $fathers, $mothers, $nbanims, $listing, $nl, $IDs;
645
    $nbtot   = 0;
646
    $listing = '';
647
    if ($nloop < ($nb_gen + 20)) {
648
        $nloop = $nb_gen + 20;
649
    }
650
    $list = array(0 => 1); /* initialize list with Anim0 (rank = 1) */
651
    for ($j = 1; $j < $nloop; ++$j) {
652
        $new = 0;
653
        foreach ($list as $i => $rank) {
654
            if (false !== ($s = $fathers[$i])) {
655
                if (!$list[$s]) {
656
                    $new = 1;
657
                    if ($j < $nb_gen) {
658
                        ++$nbtot;
659
                    }
660
                }
661
                $list[$s] = $rank + 1;
662
                if ($j < $nb_gen) {
663
                    ++$nbtot;
664
                }
665
                if ($j > $nloop - 10) {
666
                    $listing .= "Loop $j: Animal #$s " . $IDs[$s] . $nl;
667
                }
668
            }
669
            if (false !== ($d = $mothers[$i])) {
670
                if (!$list[$d]) {
671
                    $new = 1;
672
                    if ($j < $nb_gen) {
673
                        ++$nbtot;
674
                    }
675
                }
676
                $list[$d] = $rank + 1;
677
                if ($j < $nb_gen) {
678
                    ++$nbtot;
679
                }
680
                if ($j > $nloop - 10) {
681
                    $listing .= "Loop $j: Animal #$d " . $IDs[$d] . $nl;
682
                }
683
            }
684
        }
685
        if (!$new) {
686
            break;
687
        }
688
    }
689
    if ($new) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $new does not seem to be defined for all execution paths leading up to this point.
Loading history...
690
        $nbtot = 0;
691
    } /* Endless loop detected (see listing) */
692
693
    return $nbtot;
694
}
695
696
if (!function_exists('html_accents')) {
697
    /**
698
     * @param $string
699
     * @return mixed
700
     */
701
    function html_accents($string)
702
    {
703
        return $string;
704
    }
705
}
706
707
/**
708
 * @param $ID
709
 *
710
 * @return array
711
 */
712
function set_name($ID)
713
{
714
    global $sql2, $sql2bis, $xoopsDB;
715
    $name = ' ';
0 ignored issues
show
Unused Code introduced by
The assignment to $name is dead and can be removed.
Loading history...
716
    $ID = (int)$ID;
717
    $ani  = array();
718
    if ($ID) {
719
        $sqlquery    = 'SELECT Id, NAAM, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE Id = '$ID'";
720
        $queryresult = $GLOBALS['xoopsDB']->query($sqlquery);
721
        $ani         = $GLOBALS['xoopsDB']->fetchBoth($queryresult);
722
        $name        = $ani[1];
723
        if ($sql2bis) { // true for E.R.o'S. only
724
            $name = html_accents($name);
725
            //$affx = $ani[5] ;  // affix-ID
726
            if ($affx) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $affx does not exist. Did you maybe mean $affix?
Loading history...
727
                $affix  = fetch_record("$sql2bis '$affx'");
728
                $type   = $affix[1];
729
                $affixe = html_accents($affix[0]);
730
                if ($type[0] === 'P') {
731
                    $name = '<i>' . $affixe . '</i>&nbsp;' . $name;
732
                }
733
                if ($type[0] === 'S') {
734
                    $name = $name . '&nbsp;<i>' . $affixe . '</i>';
735
                }
736
            }
737
            $ani[1] = $name;
738
        }
739
    }
740
741
    return $ani;
742
}
743
744
/**
745
 * @param $ems
746
 *
747
 * @return string
748
 */
749
function Ems_($ems)
750
{
751
    if (function_exists('Ems')) {
752
        return Ems($ems);
753
    }
754
    if (!$ems) {
755
        return '&nbsp;';
756
    }
757
    $e   = str_replace(' ', '+', $ems);
758
    $res = '<a href="#" style="text-decoration:none;" onClick="' . "window.open('http://www.somali.asso.fr/eros/decode_ems.php?$e'," . "'', 'resizable=no,width=570,height=370')" . '"' . "><b>$ems</b></a>";
759
760
    return $res;
761
}
762
763
/**
764
 * @param $ID
765
 *
766
 * @return string
767
 */
768
function one_animal($ID)
769
{
770
    global $xoopsDB;
771
    global $sex, $val, $sosa, $detail, $sql3;
772
    $sosa = 12;
773
    // echo '<div style="position:relative;float:right;width=2.0em;color=white;">' . $sosa . '</div>' ;
774
    $animal = set_name($ID);
775
    list($ID, $name, $sex, $hd, $ems) = $animal;
776
    $sqlquery    = 'SELECT SQL_CACHE COUNT(Id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " where father = '$ID' or mother = '$ID'";
777
    $queryresult = $GLOBALS['xoopsDB']->query($sqlquery);
778
    $nb          = $GLOBALS['xoopsDB']->fetchBoth($queryresult);
779
    $nb_children = $nb[0];
780
    if ($nb_children == 0) {
781
        $nb_children = _MA_PEDIGREE_COI_NO;
782
    }
783
    //$dogid = $animal[0];
784
    $content .= "<tr><td><a href=\"dog.php?Id=" . $ID . "\">" . stripslashes($name) . '</a>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $content seems to be never defined.
Loading history...
785
    // if ($nb_enf == 0) echo ' &oslash;' ;
786
    if ($val) {
787
        $content .= $val;
788
    }
789
    if ($sex == 1) {
790
        $geslacht = "<img src=\"assets/images/female.gif\">";
791
    }
792
    if ($sex == 0) {
793
        $geslacht = "<img src=\"assets/images/male.gif\">";
794
    }
795
    $content .= '</td><td>' . $geslacht . '</td><td>' . $nb_children . _MA_PEDIGREE_COI_OFF . '</td></tr>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $geslacht does not seem to be defined for all execution paths leading up to this point.
Loading history...
796
797
    return $content;
798
}
799
800
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  MAIN  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
801
802
$nl = "\n"; // the newline character
803
804
//edit by jc
805
//$link = @mysqli_pconnect ($host, $database, $password)
806
//   or   die ("<html><body>Connection to database failed.</body></html>") ;
807
$s      = $_GET['s'];
808
$d      = $_GET['d'];
809
$detail = $_GET['detail'];
810
811
if (isset($si)) {
812
    $s = findId($si);
0 ignored issues
show
Bug introduced by
The function findId was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

812
    $s = /** @scrutinizer ignore-call */ findId($si);
Loading history...
813
}
814
if (isset($da)) {
815
    $d = findId($da);
816
}
817
//test for variables
818
//echo "si=".$si." da=".$da." s=".$s." d=".$d;
819
$utils = $GLOBALS['xoopsDB']->query("SELECT user(), date_format(now(),'%d-%b-%Y')");
820
list($who, $jourj) = $GLOBALS['xoopsDB']->fetchBoth($utils);
821
822
if (isset($IC)) {
823
    $detail = -1;
824
    $a      = $IC;
825
}
826
827
if (!isset($detail)) {
828
    $detail = 0;
829
}
830
831
if (!isset($a)) {
832
    if ($s && !isset($d)) {
833
        $a = $s;
834
        $s = '';
835
    }
836
    if ($d && !isset($s)) {
837
        $a = $d;
838
        $d = '';
839
    }
840
}
841
842
if (isset($a)) {
843
    $sqlquery    = 'SELECT Id, father, mother, roft from ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE Id  = '$a'";
844
    $queryresult = $GLOBALS['xoopsDB']->query($sqlquery);
845
    $rowhond     = $GLOBALS['xoopsDB']->fetchBoth($queryresult);
846
    $a           = $rowhond['Id'];
847
    $s           = $rowhond['father'];
848
    $d           = $rowhond['mother'];
849
}
850
$a += 0;
851
$s += 0;
852
$d += 0; // [IDs are numbers]
853
854
$xoopsTpl->assign('ptitle', _MA_PEDIGREE_COI_CKRI);
855
$xoopsTpl->assign('pcontent', strtr(_MA_PEDIGREE_COI_CKRI_CT, array('[animalType]' => $moduleConfig['animalType'])));
856
857
if (!$s && !$d) {
858
    $error = _MA_PEDIGREE_COI_SPANF1 . $a . _MA_PEDIGREE_COI_SPANF2;
859
    $xoopsTpl->assign('COIerror', $error);
860
}
861
862
$maxn_ = 1000;
863
$maxr_ = 9;
864
865
$maxn     = $maxn_;
866
$maxr     = $maxr_;
867
$cinnamon = 0;
868
$chocolat = 0;
869
$dilution = 0;
870
$sexlred  = 0;
871
872
$nivomin = -$maxr; /* Maximal depth of recursion (-10) */
873
$codec   = 0;
874
$gens    = 4; /* 4 gens. for both pedigrees of couple */
875
$litter  = 0;
876
877
// echo "s:".$s."<br />";
878
// echo "d:".$d."<br />";
879
880
$codec1 = $d;
881
$codec2 = $s;
882
$val    = '';
883
884
if (!$s && $d) {
885
    $codec1 = $d;
886
    $codec2 = 0;
887
}
888
if ($codec1 == $codec2) {
889
    $codec2 = 0;
890
}
891
892
$sqlquery    = 'SELECXT father, mother, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE Id  = '$codec1'";
893
$queryresult = $GLOBALS['xoopsDB']->query($sqlquery);
894
$rowhond     = $GLOBALS['xoopsDB']->fetchBoth($queryresult);
895
$a1          = $rowhond['Id'];
896
$s1          = $rowhond['father'];
897
$d1          = $rowhond['mother'];
898
$sex1        = $rowhond['roft'];
899
900
// echo "sqlquery:".$sqlquery."<br />";
901
902
$sqlquery    = 'SELECT father, mother, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE Id  = '$codec2'";
903
$queryresult = $GLOBALS['xoopsDB']->query($sqlquery);
904
$rowhond     = $GLOBALS['xoopsDB']->fetchBoth($queryresult);
905
$a2          = $rowhond['Id'];
906
$s2          = $rowhond['father'];
907
$d2          = $rowhond['mother'];
908
$sex2        = $rowhond['roft'];
909
910
// echo "sqlquery:".$sqlquery."<br />";
911
912
//if ($sex1 == '0' && $sex2 == '1') { $a3 = $a1 ; $a1 = $a2 ; $a2 = $a3 ; }   /* permute dam and sire */
913
$codec1 = $a1;
914
$codec2 = $a2;
915
if (!isset($s1) || !isset($d1) || !isset($s2) || !isset($d2)) {
916
    $xoopsTpl->assign('COIerror', _MA_PEDIGREE_COI_SGPU);
917
}
918
919
$title   = strtr(_MA_PEDIGREE_FLD_FATH, array('[father]' => $moduleConfig['father'])) . ' (' . stripslashes(showParent($codec2)) . ')' . _MA_PEDIGREE_COI_AND . strtr(_MA_PEDIGREE_FLD_MOTH, array('[mother]' => $moduleConfig['mother'])) . ' (' . stripslashes(showParent($codec1)) . ')';
0 ignored issues
show
Bug introduced by
The function showParent was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

919
$title   = strtr(_MA_PEDIGREE_FLD_FATH, array('[father]' => $moduleConfig['father'])) . ' (' . stripslashes(/** @scrutinizer ignore-call */ showParent($codec2)) . ')' . _MA_PEDIGREE_COI_AND . strtr(_MA_PEDIGREE_FLD_MOTH, array('[mother]' => $moduleConfig['mother'])) . ' (' . stripslashes(showParent($codec1)) . ')';
Loading history...
920
$content = stripslashes(one_animal($codec2));
921
$content .= stripslashes(one_animal($codec1));
922
$val = '';
923
$xoopsTpl->assign('SADtitle', $title);
924
$xoopsTpl->assign('SADcontent', $content);
925
$xoopsTpl->assign('SADexplain', strtr(_MA_PEDIGREE_COI_SDEX, array('[animalType]' => $moduleConfig['animalType'], '[animalTypes]' => $moduleConfig['animalTypes'], '[children]' => $moduleConfig['children'])));
926
927
$de_cujus = 0;
928
$sire_ID = XoopsRequest::getInt('s', 0, 'GET');
929
$dam_ID  = XoopsRequest::getInt('d', 0, 'GET');
930
//$sire_ID  = $_GET['s'];
931
//$dam_ID   = $_GET['d'];
932
$rec      = 'SELECT Id FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE father = '" . $sire_ID . "' and mother = '" . $dam_ID . "' ORDER BY NAAM";
933
$result   = $GLOBALS['xoopsDB']->query($rec);
934
$content  = '';
935
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
936
    $content .= one_animal($row['Id']);
937
}
938
939
$xoopsTpl->assign('COMtitle', strtr(_MA_PEDIGREE_COI_COMTIT, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother'])));
940
$xoopsTpl->assign('COMexplain', strtr(_MA_PEDIGREE_COI_COMEX, array('[animalType]' => $moduleConfig['animalType'], '[children]' => $moduleConfig['children'])));
941
$xoopsTpl->assign('COMcontent', $content);
942
943
if (!isset($nb_gen)) {
944
    $nb_gen = 7;
945
    if ($detail) {
946
        $nb_gen = 9;
947
    }
948
} elseif ($nb_gen < $pedigree) {
949
    $nb_gen = $pedigree;
950
}
951
952
$IDs = array($de_cujus + 0, $codec1 + 0, $codec2 + 0); /* Structuring animal IDs into memory */
953
954
$nbanims = GENEALOGY(); // ************************************************************* //
955
956
for ($i = 0; $i <= $nbanims; ++$i) {
957
    $empty[$i] = 0;
958
}
959
960
foreach ($fathers as $i => $a) {
961
    if ($a) {
962
        $fathers[$i] = $inds[$a];
963
    }
964
} /* Replace parents codes */
965
foreach ($mothers as $i => $a) {
966
    if ($a) {
967
        $mothers[$i] = $inds[$a];
968
    }
969
} /*   by  their  indices  */
970
971
dist_m($mothers[0]); // set "$mater" array (list of all maternal ascendants), for Anim #0
972
973
/* Calculating CONSANGUINITY by dual (paternal & maternal) path method */
974
$f       = $empty;
975
$ICknown = $empty;
976
$deltaf  = $empty;
977
$marked  = $empty;
978
979
/******************  LAUNCHING ALL RECURSIONS  ********************/
980
/*                                                                */
981
CONSANG(-1); /* [-1 is standing for de_cujus]
982
/*                                                                */
983
/******************************************************************/
984
985
$nf = ceil(100 * $COIs[0]);
986
if ($nf >= 55) {
987
    $w = _MA_PEDIGREE_COI_HUGE;
988
} else {
989
    if ($nf >= 35) {
990
        $w = _MA_PEDIGREE_COI_VHIG;
991
    } else {
992
        if ($nf >= 20) {
993
            $w = _MA_PEDIGREE_COI_HIGH;
994
        } else {
995
            if ($nf >= 10) {
996
                $w = _MA_PEDIGREE_COI_MEDI;
997
            } else {
998
                if ($nf >= 05) {
999
                    $w = _MA_PEDIGREE_COI_LOW;
1000
                } else {
1001
                    if ($nf >= 02) {
1002
                        $w = _MA_PEDIGREE_COI_VLOW;
1003
                    } else {
1004
                        if ($nf >= 01) {
1005
                            $w = _MA_PEDIGREE_COI_VVLO;
1006
                        } else {
1007
                            $w = _MA_PEDIGREE_COI_TLTB;
1008
                        }
1009
                    }
1010
                }
1011
            }
1012
        }
1013
    }
1014
}
1015
$w = _MA_PEDIGREE_COI_TVI . ' ' . $w;
1016
1017
$nb_all = 0;
1018
count_all(0, 0); // count all ascendants in flat tree
1019
1020
$nbmax  = (2 << $nb_gen) - 2;
1021
$asctc  = _MA_PEDIGREE_COI_ASTC . $nb_gen . _MA_PEDIGREE_COI_ASTCGEN . $nbmax . ')';
1022
$ascuni = _MA_PEDIGREE_COI_ASDKA . $nb_gen . _MA_PEDIGREE_COI_ASGEN;
1023
$xoopsTpl->assign('ASCtitle', _MA_PEDIGREE_COI_ACTIT);
1024
$xoopsTpl->assign('ASCtc', $asctc);
1025
$xoopsTpl->assign('ASCuni', $ascuni);
1026
$xoopsTpl->assign('ASCall', $nb_all);
1027
$xoopsTpl->assign('ASCani', $nbani);
1028
$xoopsTpl->assign('ASCexplain', _MA_PEDIGREE_COI_ACEX);
1029
1030
$f0 = substr($COIs[0], 0, 8);
1031
if (!$f0) {
1032
    $f0 = 'n.a.';
1033
}
1034
$f1 = 100 * $f0;
1035
1036
$xoopsTpl->assign('COItitle', strtr(_MA_PEDIGREE_COI_COITIT, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother'])));
1037
$xoopsTpl->assign('COIperc', $w);
1038
$xoopsTpl->assign('COIval', $f1);
1039
$xoopsTpl->assign('COIexplain', strtr(_MA_PEDIGREE_COI_COIEX, array('[animalType]' => $moduleConfig['animalType'], '[animalTypes]' => $moduleConfig['animalTypes'], '[children]' => $moduleConfig['children'])));
1040
$xoopsTpl->assign('COIcoi', _MA_PEDIGREE_COI_COI);
1041
$dogid = XoopsRequest::getInt('dogid', 0, 'get');
1042
$query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' SET coi=' . $f1 . ' WHERE Id = ' . $dogid;
1043
$GLOBALS['xoopsDB']->queryF($query);
1044
arsort($deltaf);
1045
$j = 1;
1046
foreach ($deltaf as $i => $v) {
1047
    if ($j > 12) {
1048
        break;
1049
    }
1050
    ++$j;
1051
    $code   = $IDs[$i];
1052
    $v      = substr($v, 0, 7);
1053
    $animal = set_name($IDs[$i]);
1054
    $name   = $animal[1];
1055
    if (!$name) {
1056
        $name = $i . ' [' . $IDs[$i] . ']';
1057
    }
1058
    if ($v > 0.0001 && $v < 1.0) {
1059
        $dogs[] = array('id' => $code, 'name' => stripslashes($name), 'coi' => 100 * $v);
1060
    }
1061
}
1062
1063
$xoopsTpl->assign('TCAtitle', _MA_PEDIGREE_COI_TCATIT);
1064
$xoopsTpl->assign('TCApib', _MA_PEDIGREE_COI_TCApib);
1065
$xoopsTpl->assign('dogs', $dogs);
1066
$xoopsTpl->assign('TCAexplain', strtr(_MA_PEDIGREE_COI_TCAEX, array(
1067
    '[animalType]'  => $moduleConfig['animalType'],
1068
    '[animalTypes]' => $moduleConfig['animalTypes'],
1069
    '[children]'    => $moduleConfig['children'],
1070
    '[mother]'      => $moduleConfig['mother'],
1071
    '[father]'      => $moduleConfig['father']
1072
)));
1073
1074
if ($detail) {
1075
    if ($verbose) {
1076
        $verbose = 0;
1077
    }
1078
    if (count($COIs) > 1) {
1079
        $ICs = $COIs;
1080
        arsort($ICs);
1081
        $j = 1;
1082
        foreach ($ICs as $i => $ic) {
1083
            if ($j > 12) {
1084
                break;
1085
            }
1086
            ++$j;
1087
            $ID   = $IDs[$i];
1088
            $ani  = set_name($ID);
1089
            $name = $ani[1];
1090
            $ic   = substr($ic, 0, 6);
1091
            if ($ic > 0.125 && $i) {
1092
                $mia[] = array('id' => $ID, 'name' => stripslashes($name), 'coi' => 100 * $ic);
1093
            }
1094
        }
1095
    }
1096
    $xoopsTpl->assign('MIAtitle', _MA_PEDIGREE_COI_MIATIT);
1097
    $xoopsTpl->assign('mia', $mia);
1098
    $xoopsTpl->assign('MIAexplain', strtr(_MA_PEDIGREE_COI_MIAEX, array('[animalType]' => $moduleConfig['animalType'])));
1099
1100
    if (!$ICknown[1]) {
1101
        $marked = $empty;
1102
        CONSANG(1);
1103
    } // Sire
1104
    if (!$ICknown[2]) {
1105
        $marked = $empty;
1106
        CONSANG(2);
1107
    } // Dam
1108
    $COR = 2.0 * $COIs[0] / sqrt((1. + $COIs[1]) * (1. + $COIs[2]));
1109
    $COR = substr($COR, 0, 8);
1110
    if (!$COR) {
1111
        $COR = 'n.a.';
1112
    }
1113
    $f1 = substr($COIs[1], 0, 8);
1114
    $f2 = substr($COIs[2], 0, 8);
1115
    if (!$f1) {
1116
        $f1 = 'n.a.';
1117
    }
1118
    if (!$f2) {
1119
        $f2 = 'n.a.';
1120
    }
1121
    $SSDcor  = (100 * $COR);
1122
    $SSDsire = (100 * $f2);
1123
    $SSDdam  = (100 * $f1);
1124
}
1125
1126
$xoopsTpl->assign('SSDtitle', strtr(_MA_PEDIGREE_COI_SSDTIT, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother'])));
1127
$xoopsTpl->assign('SSDcortit', _MA_PEDIGREE_COI_SSDcor);
1128
$xoopsTpl->assign('SSDbsd', strtr(_MA_PEDIGREE_COI_SDDbsd, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother'])));
1129
$xoopsTpl->assign('SSDcor', $SSDcor);
1130
1131
$xoopsTpl->assign('SSDS', _MA_PEDIGREE_COI_COI . _MA_PEDIGREE_FROM . strtr(_MA_PEDIGREE_FLD_FATH, array('[father]' => $moduleConfig['father'])));
1132
$xoopsTpl->assign('SSDsire', $SSDsire);
1133
$xoopsTpl->assign('SSDM', _MA_PEDIGREE_COI_COI . _MA_PEDIGREE_FROM . strtr(_MA_PEDIGREE_FLD_MOTH, array('[mother]' => $moduleConfig['mother'])));
1134
$xoopsTpl->assign('SSDdam', $SSDdam);
1135
1136
// echo "SSDsire : ".$SSDsire."<br />";
1137
// echo "SSDdam : ".$SSDdam."<br />";
1138
// print_r($COIs);
1139
1140
$xoopsTpl->assign('SSDexplain', strtr(_MA_PEDIGREE_COI_SSDEX, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother'], '[animalType]' => $moduleConfig['animalTypes'])));
1141
$xoopsTpl->assign('TNXtitle', _MA_PEDIGREE_COI_TNXTIT);
1142
$xoopsTpl->assign('TNXcontent', _MA_PEDIGREE_COI_TNXCON);
1143
$xoopsTpl->assign('Name', _MA_PEDIGREE_FLD_NAME);
1144
$xoopsTpl->assign('Gender', _MA_PEDIGREE_FLD_GEND);
1145
$xoopsTpl->assign('Children', strtr(_MA_PEDIGREE_FLD_PUPS, array('[children]' => $moduleConfig['children'])));
1146
1147
//add data to smarty template
1148
$xoopsTpl->assign('explain', _MA_PEDIGREE_EXPLAIN);
1149
1150
//comments and footer
1151
include XOOPS_ROOT_PATH . '/footer.php';
1152