boucle()   F
last analyzed

Complexity

Conditions 16
Paths 1364

Size

Total Lines 54
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 16
eloc 34
nc 1364
nop 2
dl 0
loc 54
rs 1.4
c 2
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
/*
3
 You may not change or alter any portion of this comment or credits of
4
 supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit
6
 authors.
7
8
 This program is distributed in the hope that it will be useful, but
9
 WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * Module: Pedigree
15
 *
16
 * @package   XoopsModules\Pedigree
17
 * @author    XOOPS Module Development Team
18
 * @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project}
19
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
20
 */
21
22
use Xmf\Request;
23
use XoopsModules\Pedigree;
24
25
ini_set('memory_limit', '32M');
26
27
//require_once  \dirname(__DIR__, 2) . '/mainfile.php';
28
require_once __DIR__ . '/header.php';
29
$moduleDirName = basename(__DIR__);
30
xoops_loadLanguage('main', $moduleDirName);
31
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php';
32
33
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_coi.tpl';
34
require XOOPS_ROOT_PATH . '/header.php';
35
36
//get module configuration
37
/** @var XoopsModuleHandler $moduleHandler */
38
$moduleHandler = xoops_getHandler('module');
39
$module        = $moduleHandler->getByDirname($moduleDirName);
40
$configHandler = xoops_getHandler('config');
41
$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

41
$moduleConfig  = $configHandler->/** @scrutinizer ignore-call */ getConfigsByCat(0, $module->getVar('mid'));
Loading history...
42
43
global $xoopsTpl, $xoopsDB, $moduleConfig;
44
45
//start kinship.php code -- help !!
46
/* ************************************************************************************* */
47
/*
48
     This program calculates the coefficient of inbreeding (IC, or COI, or F)
49
     for the offspring of a couple of animals, given by their IDs (s=sire_ID&d=dam_ID),
50
     or for a given animal given by its ID (a=animal_ID).
51
52
     By default, all known ascendants are used.
53
     However, maximum count of distinct ascendants is limited to $nb_maxi (default=600)
54
              [higher values for $nb_maxi could lead to calculations ending in timeout],
55
              or depth of tree can be limited to $nb_gen generations (default = 8).
56
*/
57
/* ************************************************************************************* */
58
59
if (!isset($verbose)) {
60
    $verbose = 0;
61
} // don't display different steps of ICs calculation
62
if (!isset($detail)) {
63
    $detail = 1;
64
} // don't display detail results [faster]
65
if (!isset($nb_maxi)) {
66
    $nb_maxi = 600;
67
} // maximum count of distinct ascendants
68
if (!isset($nb_gen)) {
69
    $nb_gen = 8;
70
} // maximum count of generations of ascendants
71
if (!isset($pedigree)) {
72
    $pedigree = 0;
73
} // dont't display sketch pedigree [faster]
74
if (!isset($max_dist)) { // maximum length of implex loops
75
    if ($nb_gen > 9) {
76
        $max_dist = 14;
77
    } else {
78
        if (9 == $nb_gen) {
79
            $max_dist = 17;
80
        } else {
81
            if (8 == $nb_gen) {
82
                $max_dist = 18;
83
            } else {
84
                $max_dist = 99;
85
            }
86
        }
87
    }
88
}
89
90
$empty = []; // an empty array
91
$sql1  = 'SELECT id, father, mother, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE id ';
92
93
// input data arrays:
94
$IDs     = $empty;
95
$fathers = $empty;
96
$mothers = $empty;
97
98
// working arrays:
99
$inds    = $empty;
100
$marked  = $empty;
101
$ICknown = $empty;
102
$deltaf  = $empty;
103
$pater   = $empty;
104
$mater   = $empty;
105
$chrono  = $empty;
106
107
// Coefficients of Inbreeding array (result):
108
$COIs = $empty;
109
110
/* ******************************  FUNCTIONS  ********************************* */
111
112
/**
113
 * @return int
114
 */
115
function chrono_sort()
116
{
117
    global $IDs, $inds, $fathers, $mothers, $chrono, $nl, $detail;
118
    $impr  = 0;
119
    $modif = 1;
120
    $nloop = 0;
121
    $nba   = count($IDs);
122
    // print_r ($IDs) ;
123
    // echo "<b>231 : $IDs[231] $fathers[231] $mothers[231] $chrono[231] $inds[231] </b><br>\n" ;
124
    foreach ($IDs as $i => $v) {
125
        $chrono[$i] = 1;
126
    } // initialize all chronological ranks to 1
127
    $chrono[0] = 0; // except animal #0 (at 0 rank).
128
    while ($modif && $nloop < 40) {
129
        $modif = 0;
130
        ++$nloop;
131
        for ($i = 1; $i < $nba; ++$i) {
132
            $s = $fathers[$i];
133
            if ($s) {
134
                $s = $inds[$s];
135
            }
136
            $d = $mothers[$i];
137
            if ($d) {
138
                $d = $inds[$d];
139
            }
140
            if ($s && $chrono[$s] <= $chrono[$i]) {
141
                $chrono[$s] = $chrono[$i] + 1;
142
                $modif      = 1;
143
            }
144
            if ($d && $chrono[$d] <= $chrono[$i]) {
145
                $chrono[$d] = $chrono[$i] + 1;
146
                $modif      = 1;
147
            }
148
        }
149
    }
150
    if (40 == $nloop) {
151
        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...
152
    }
153
    array_multisort($chrono, $IDs, $fathers, $mothers);
154
    $depth = $chrono[$nba - 1];
0 ignored issues
show
Unused Code introduced by
The assignment to $depth is dead and can be removed.
Loading history...
155
    //commentes out by JC
156
    //if ($detail) echo "<br>Chronological ranking done : Pedigree stretched over <b>$depth</b> generations.<br>$nl" ;
157
    if ($impr) {
158
        echo "</center><pre>$nl $nl";
159
        foreach ($chrono as $i => $val) {
160
            echo "<b>$i</b> : $val $IDs[$i] $fathers[$i] $mothers[$i] $nl";
161
        }
162
        echo "</pre>$nl";
163
        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...
164
    }
165
    $inds = array_flip($IDs);
166
167
    return 0;
168
}
169
170
/**
171
 * @param $s
172
 *
173
 * @return array
174
 */
175
function fetch_record($s)
176
{
177
    global $database;
178
    $r = $GLOBALS['xoopsDB']->queryF($database, $s);
179
    $n = 0;
180
    if ($r) {
181
        $n = $GLOBALS['xoopsDB']->getRowsNum($r);
182
    }
183
    if (0 == $n) {
184
        $record = ['0'];
185
    } else {
186
        $record = $GLOBALS['xoopsDB']->fetchBoth($r);
187
    }
188
189
    return $record;
190
}
191
192
/**
193
 * @param $ind
194
 * @param $gen
195
 *
196
 * @return int
197
 */
198
function count_all($ind, $gen)
199
{
200
    global $inds, $nb_gen, $nb_all, $fathers, $mothers;
201
    if ($ind) {
202
        ++$nb_all;
203
    }
204
    $s = $fathers[$ind];
205
    $d = $mothers[$ind];
206
    if ($s && $gen < $nb_gen) {
207
        count_all($s, $gen + 1);
208
    }
209
    if ($d && $gen < $nb_gen) {
210
        count_all($d, $gen + 1);
211
    }
212
213
    return 0;
214
}
215
216
/**
217
 * @param $ch
218
 * @param $niv
219
 *
220
 * @return int
221
 */
222
function add_multi($ch, $niv)
223
{
224
    global $implx, $couls, $nl;
225
    reset($implx);
226
    $first = 1;
227
    foreach ($implx as $im => $impl) {
228
        if ($impl[0] == $ch || $impl[1] == $ch) {
229
            if ($niv > 1 && $first) {
230
                echo "<br>$nl";
231
            } else {
232
                echo '&nbsp;&nbsp;&nbsp;';
233
            }
234
            $i     = $im + 1;
235
            $j     = min($im, 6);
236
            $c     = $couls[$j];
237
            $first = 0;
238
            echo '<span color=' . $c . ' size="+2"><b>*' . $i . '*</b></span>';
239
        }
240
    }
241
242
    return 0;
243
}
244
245
/**
246
 * @param $ind
247
 * @param $gen
248
 * @param $class
249
 *
250
 * @return int
251
 */
252
function output_animal($ind, $gen, $class)
253
{
254
    global $depth, $IDs, $fathers, $mothers, $nl;
255
    if ($gen > $depth) {
256
        return 0;
257
    }
258
    $cell_content = '&Oslash;';
259
    if ($ind || 0 == $gen) {
260
        $ID           = $IDs[$ind];
261
        $ani          = set_name($ID);
262
        $name         = $ani[1];
0 ignored issues
show
Unused Code introduced by
The assignment to $name is dead and can be removed.
Loading history...
263
        $name         = $ID;
264
        $cell_content = Pedigree\Utility::showParent($name) . $nl;
265
    }
266
    $rowspan = 1 << ($depth - $gen);
267
    echo '<td rowspan=' . $rowspan . ' align="center" class="' . $class . '">' . $cell_content . "</td>$nl";
268
    if ($gen < $depth) {
269
        $sire = 0;
270
        if ($ind || 0 == $gen) {
271
            $sire = $fathers[$ind];
272
        }
273
        output_animal($sire, $gen + 1, '0');
274
        $dam = 0;
275
        if ($ind || 0 == $gen) {
276
            $dam = $mothers[$ind];
277
        }
278
        output_animal($dam, $gen + 1, '1');
279
    } else {
280
        echo "</tr><tr>$nl";
281
    }
282
283
    return 0;
284
}
285
286
/**
287
 * @return int
288
 */
289
function SKETCH_PEDIGREE()
290
{
291
    global $nl, $detail, $depth, $IDs;
292
    // print_r ($IDs) ;
293
    echo $nl
294
         . '<br>'
295
         . $nl
296
         . '<table border="3" cellpadding="4" width="85%"" cellpadding="0" cellspacing="0">'
297
         . $nl
298
         . '<tr><th colspan="10" align="center">SKETCH &nbsp; PEDIGREE &nbsp; OF COMMON PROGENY</th></tr>'
299
         . $nl
300
         . '<tr align="center" valign="middle"><th>Progeny</th><th>'
301
         . _('Sire / Dam')
302
         . '</th>';
303
    if ($depth >= 2) {
304
        echo '<th>' . _('Grandparents') . '</th>' . $nl;
305
    }
306
    if ($depth >= 3) {
307
        echo '<th>' . _('Great-Grandparents') . '</th>' . $nl;
308
    }
309
    if ($depth >= 4) {
310
        echo '<th>3xGr. P.</th>' . $nl;
311
    }
312
    if ($depth >= 5) {
313
        echo '<th>4xGr. P.</th>' . $nl;
314
    }
315
    if ($depth >= 6) {
316
        echo '<th>5xGr. P.</th>' . $nl;
317
    }
318
    if ($depth >= 7) {
319
        echo '<th>6xGr. P.</th>' . $nl;
320
    }
321
    echo '</tr><tr>';
322
    output_animal(0, 0, '0'); /* output the sketch pedigree */
323
    echo $nl . '</tr></table>' . $nl . '<p>' . $nl;
324
325
    return 0;
326
}
327
328
/**
329
 * @return int
330
 */
331
function GENEALOGY()
332
{
333
    global $IDs, $fathers, $mothers, $inds, $nb_gen, $nb_maxi, $nbani, $nl, $sql1;
334
    $impr       = 0;
335
    $fathers[0] = $IDs[1];
336
    $mothers[0] = $IDs[2];
337
    $fathers[1] = 0;
338
    $mothers[1] = 0;
339
    $fathers[2] = 0;
340
    $mothers[2] = 0;
341
    $last       = 2;
342
    if ($impr) {
343
        echo "<!-- genealogy 'de cujus' (gener. 0) : $IDs[0] = $IDs[1] x $IDs[2] -->$nl";
344
    }
345
    $generation = [$IDs[1], $IDs[2]]; // starting with first generation (sire and dam)
346
    $nbtot      = 0; // count of total known ascendants within $nb_gen generations
347
    for ($nloop = 1, $tot = 2; $last <= $nb_maxi && $nloop <= $nb_gen; ++$nloop) {
348
        $nbtot      += $tot; // count of total known ascendants within $nb_gen generations
349
        $nbani      = $last; // count of    distinct ascendants within $nb_gen generations
350
        $list       = implode(',', array_unique($generation));
351
        $generation = [];
352
        $tot        = 0;
353
        if ($impr) {
354
            echo "    [$list]$nl";
355
        }
356
357
        // HERE IS FETCHED EACH TRIPLET [ID, sire_ID, dam_ID] :
358
        $r = $GLOBALS['xoopsDB']->queryF("$sql1 IN ($list)");
359
        while (false !== ($rec = $GLOBALS['xoopsDB']->fetchBoth($r))) {
360
            $a = $rec[0] + 0;
361
            $s = $rec[1] + 0;
362
            $d = $rec[2] + 0;
363
            if (!isset($a)) {
364
                echo "ERROR : $a = $s x $d for list = '$list'<br>\n";
365
            }
366
            if ($s) {
367
                ++$tot;
368
            }
369
            if ($d) {
370
                ++$tot;
371
            }
372
            $j           = array_keys($IDs, $a);
373
            $j           = $j[0];
374
            $fathers[$j] = $s;
375
            $mothers[$j] = $d;
376
            if ($s && !in_array($s, $IDs)) {
377
                $i           = ++$last;
378
                $IDs[$i]     = $s;
379
                $fathers[$i] = 0;
380
                $mothers[$i] = 0;
381
                if ($s) {
382
                    $generation[] = $s;
383
                }
384
            }
385
            if ($d && !in_array($d, $IDs)) {
386
                $i           = ++$last;
387
                $IDs[$i]     = $d;
388
                $fathers[$i] = 0;
389
                $mothers[$i] = 0;
390
                if ($s) {
391
                    $generation[] = $d;
392
                }
393
            }
394
            if ($impr) {
395
                echo "<pre>genealogy ascendant (gener. $nloop) : $a = $s x $d  [tot = $tot]$nl</pre>";
396
            }
397
        }
398
        if (!count($generation)) {
399
            break;
400
        }
401
    }
402
403
    if ($nloop <= $nb_gen) {
404
        $nb_gen = $nloop;
405
    } // tree cut by $nb_maxi !
406
407
    reset($IDs);
408
    $inds = array_flip($IDs);
409
410
    chrono_sort();
411
412
    return $nbtot;
413
}
414
415
/**
416
 * @param $p
417
 *
418
 * @return int
419
 */
420
function dist_p($p)
421
{
422
    global $IDs, $fathers, $mothers, $pater, $nb_gen, $detail, $nl;
423
    // Anim #P is the sire
424
    $listall   = [$p];
425
    $listnew   = [$p];
426
    $pater     = [];
427
    $pater[$p] = 1;
428
    for ($nloop = 2; $nloop < ($nb_gen + 1); ++$nloop) {
429
        $liste = [];
430
        foreach ($listnew as $i) {
431
            $s = $fathers[$i];
432
            $d = $mothers[$i];
433
            if ($s && !$pater[$s]) {
434
                $pater[$s] = $nloop;
435
            } // least distance from $s to sire's progeny
436
            if ($d && !$pater[$d]) {
437
                $pater[$d] = $nloop;
438
            } // least distance from $d to sire's progeny
439
            if ($s) {
440
                $liste[] = $s;
441
            }
442
            if ($d) {
443
                $liste[] = $d;
444
            }
445
        }
446
        if (!count($liste)) {
447
            break;
448
        }
449
        //commented pout by jc
450
        //if (in_array ($IDs[2], $liste) && !$detail)
451
        //{ echo "<p>DAM is an ascendant (at $nloop generations) of SIRE.  Stopped." ;
452
        // die ("</body></html>$nl") ; }
453
        $listnew = array_diff(array_unique($liste), $listall);
454
        /* $list1 = join (' ', $listall) ; $list2 = join ('+', $listnew) ;
455
             echo "<!-- P ($nloop) $list1/$list2 -->$nl" ; */
456
        //        $listall = array_merge($listall, $listnew);
457
        $listall[] = $listnew;
458
    }
459
    //    $listall = call_user_func_array('array_merge', $listall);
460
    $listall = array_merge(...$listall);
0 ignored issues
show
Unused Code introduced by
The assignment to $listall is dead and can be removed.
Loading history...
461
462
    // Here $pater array contains list of all distinct ascendants of #P (including P himself)
463
    // Values of $pater are minimum distances to #P (in generations) +1
464
    return 0;
465
}
466
467
/**
468
 * @param $m
469
 *
470
 * @return int
471
 */
472
function dist_m($m)
473
{
474
    global $IDs, $fathers, $mothers, $mater, $nb_gen, $detail, $nl;
475
    // Anim #M is the dam
476
    $listall   = [$m];
477
    $listnew   = [$m];
478
    $mater     = [];
479
    $mater[$m] = 1;
480
    for ($nloop = 2; $nloop <= ($nb_gen + 1); ++$nloop) {
481
        $liste = [];
482
        foreach ($listnew as $i) {
483
            $s = $fathers[$i];
484
            $d = $mothers[$i];
485
            if ($s && !isset($mater[$s])) {
486
                $mater[$s] = $nloop;
487
            } // least distance from $s to dam's progeny
488
            if ($d && !isset($mater[$d])) {
489
                $mater[$d] = $nloop;
490
            } // least distance from $d to dam's progeny
491
            // echo "I=" . $i . " MATER(I)=" . $mater[$i] . " NLOOP=" . $nloop . "<br>$nl" ;
492
            if ($s) {
493
                $liste[] = $s;
494
            }
495
            if ($d) {
496
                $liste[] = $d;
497
            }
498
        }
499
        if (!count($liste)) {
500
            break;
501
        }
502
        //commented out by jc
503
        //if (in_array ($IDs[1], $liste) && !$detail)
504
        // { echo "<p>SIRE is an ascendant (at $nloop generations) of DAM.  Stopped." ;
505
        //  die ("</body></html>$nl") ; }
506
        $listnew = array_diff(array_unique($liste), $listall);
507
        // $list1 = join (' ', $listall) ; $list2 = join ('+', $listnew) ; echo "M ($nloop) $list1/$list2 $nl" ;
508
        //        $listall = array_merge($listall, $listnew);
509
        $listall[] = $listnew;
510
    }
511
    //    $listall = call_user_func_array('array_merge', $listall);
512
    $listall = array_merge(...$listall);
0 ignored issues
show
Unused Code introduced by
The assignment to $listall is dead and can be removed.
Loading history...
513
514
    // Here $mater array contains list of all distinct ascendants of #M (including M herself)
515
    // Values of $mater are minimum distances to #M (in generations) +1
516
    return 0;
517
}
518
519
/**
520
 * @return array
521
 */
522
function calc_dist() /* Common Ascendants and their distances */
523
{
524
    global $IDs, $fathers, $mothers, $nbanims, $pater, $mater, $empty, $nb_gen, $nl;
525
    global $dmax, $detail, $nb_gen;
526
    $distan = [];
527
    // dist_m (2) ;   has already been called
528
    dist_p($fathers[0]);
529
    $dmax = 0;
530
    $impr = 0;
531
    $dmx  = 7;
532
    if ($detail) {
533
        $dmx += 2;
534
    }
535
    // ksort ($pater) ; print_r ($pater) ; echo "<br>$nl" ; ksort ($mater) ; print_r ($mater) ; echo "<br>$nl" ;
536
    foreach ($pater as $i => $p) {
537
        if ($p) {
538
            $m = $mater[$i];
539
            if ($m) {
540
                $di = $p + $m;
541
                if ($impr) {
542
                    echo " $i : $p + $m = $di <br>$nl";
543
                }
544
                if (!$dmax) {
545
                    $dmax = $dmx + $di - ceil($di / 2.);
546
                }
547
                if ($di > ($dmax + 2)) {
548
                    continue;
549
                }
550
                $distan[$i] = $di;
551
            }
552
        }
553
    }
554
    if (!$dmax) {
555
        $dmax = 2 * $nb_gen - 2;
556
    }
557
558
    return $distan;
559
}
560
561
/**
562
 * @param $p
563
 * @param $m
564
 * @param $a
565
 * @param $ndist
566
 *
567
 * @return int
568
 */
569
function mater_side($p, $m, $a, $ndist)
570
{
571
    global $fathers, $mothers, $marked, $COIs, $deltaf, $ICknown, $verbose, $nl, $chrono, $paternal_rank, $max_dist;
572
    if (!$m || $ndist > $max_dist) {
573
        return 0;
574
    }
575
    if ($p == $m) {
576
        /* IMPLEX FOUND (node of consanguinity) { for Anim #A */
577
        $already_known = $ICknown[$p];
578
    }
579
    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...
580
        CONSANG($p);
581
    } // MAIN RECURSION:
582
    $ICp = $COIs[$p]; // we need to know the IC of Parent for Wright's formula
583
    if ($verbose && !$already_known && $ICp > 0.001 * $verbose) {
584
        echo "IC of Animal $p is $ICp$nl";
585
    }
586
587
    $incr = 1.0 / (1 << $ndist) * (1. + $ICp); // ******** applying WRIGHT's formula ********
588
589
    // [Note:  1 << $ndist is equal to 2 power $ndist]
590
    $COIs[$a] += $incr; // incrementing the IC of AnimC
591
    if (0 == $a) {
592
        $deltaf[$p] += $incr;
593
        /* contribution of Anim #P to IC of Anim #0 */ // if ($verbose && $a == 0 && $incr > 0.0001*$verbose)
594
        //    echo "Animal $p is contributing for " . substr ($deltaf[$p], 0, 10) . " to the IC of Animal $a$nl" ;
595
    } else {
596
        if (!$marked[$m] && $chrono[$m] < $paternal_rank) {
597
            mater_side($p, $fathers[$m], $a, $ndist + 1);
598
            mater_side($p, $mothers[$m], $a, $ndist + 1);
599
        }
600
    }
601
602
    return 0;
603
}
604
605
/**
606
 * @param $p
607
 * @param $m
608
 * @param $a
609
 * @param $pdist
610
 * @return int
611
 */
612
function pater_side($p, $m, $a, $pdist)
613
{
614
    global $mater, $fathers, $mothers, $marked, $chrono, $paternal_rank;
615
    if (!$p) {
616
        return 0;
617
    }
618
    $paternal_rank = $chrono[$p];
619
    $marked[$p]    = 1; /* cut paternal side */
620
    if ($a || isset($mater[$p])) {
621
        mater_side($p, $m, $a, $pdist);
622
    }
623
    pater_side($fathers[$p], $m, $a, $pdist + 1);
624
    pater_side($mothers[$p], $m, $a, $pdist + 1);
625
    $marked[$p] = 0; /* free paternal side */
626
627
    return 0;
628
}
629
630
/**
631
 * @param $a
632
 *
633
 * @return int
634
 */
635
function CONSANG($a)
636
{
637
    global $fathers, $mothers, $ICknown, $COIs, $nl;
638
    if (!$a || $ICknown[$a]) {
639
        return 0;
640
    }
641
    if (-1 == $a) {
642
        $a = 0;
643
    } // particular case : a= -1 means Anim #0 (to bypass above test)
644
    $IC_if_deadend = 0.0; // 0.0 means taht deadends are deemed to be total outcrosses...
645
    // if IC was already stored in the database for Aminal #A, it should be used here instead of 0.0
646
    $p = $fathers[$a];
647
    $m = $mothers[$a];
648
    if (!$p || !$m) {
649
        $COIs[$a]    = $IC_if_deadend;
650
        $ICknown[$a] = 2;
651
652
        return 0;
653
    }
654
655
    if ($verbose) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $verbose seems to be never defined.
Loading history...
656
        echo "</center><pre>$nl";
657
    }
658
    pater_side($p, $m, $a, 1); // launch tree exploration
659
    if ($verbose) {
660
        echo "</pre><div style=\"text-align: center;\">$nl";
661
    }
662
663
    $ICknown[$a] = 1;
664
    $p           = $fathers[$a];
665
    $m           = $mothers[$a];
666
    foreach ($fathers as $i => $pere) {/* siblings share the same COI value */
667
        if ($i != $a && $pere == $p && $mothers[$i] == $m) {
668
            $COIs[$i]    = $COIs[$a];
669
            $ICknown[$i] = 1;
670
        }
671
    }
672
673
    // echo "<!-- COI($a) = $COIs[$a] $IDs[$a] ($fathers[$a] x $mothers[$a])-->$nl" ;
674
    return 0;
675
}
676
677
/**
678
 * @param $nb_gen
679
 * @param $nloop
680
 *
681
 * @return int
682
 */
683
function boucle($nb_gen, $nloop)
684
{
685
    global $fathers, $mothers, $nbanims, $listing, $nl, $IDs;
686
    $nbtot   = 0;
687
    $listing = '';
688
    if ($nloop < ($nb_gen + 20)) {
689
        $nloop = $nb_gen + 20;
690
    }
691
    $list = [0 => 1];
692
    //print_r($list);
693
    /* initialize list with Anim0 (rank = 1) */
694
    for ($j = 1; $j < $nloop; ++$j) {
695
        $new = 0;
696
        foreach ($list as $i => $rank) {
697
            if (false !== ($s = $fathers[$i])) {
698
                if (!$list[$s]) {
699
                    $new = 1;
700
                    if ($j < $nb_gen) {
701
                        ++$nbtot;
702
                    }
703
                }
704
                $list[$s] = $rank + 1;
705
                if ($j < $nb_gen) {
706
                    ++$nbtot;
707
                }
708
                if ($j > $nloop - 10) {
709
                    $listing .= "Loop $j: Animal #$s " . $IDs[$s] . $nl;
710
                }
711
            }
712
            if (false !== ($d = $mothers[$i])) {
713
                if (!$list[$d]) {
714
                    $new = 1;
715
                    if ($j < $nb_gen) {
716
                        ++$nbtot;
717
                    }
718
                }
719
                $list[$d] = $rank + 1;
720
                if ($j < $nb_gen) {
721
                    ++$nbtot;
722
                }
723
                if ($j > $nloop - 10) {
724
                    $listing .= "Loop $j: Animal #$d " . $IDs[$d] . $nl;
725
                }
726
            }
727
        }
728
        if (!$new) {
729
            break;
730
        }
731
    }
732
    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...
733
        $nbtot = 0;
734
    } /* Endless loop detected (see listing) */
735
736
    return $nbtot;
737
}
738
739
if (!function_exists('html_accents')) {
740
    /**
741
     * @param $string
742
     * @return mixed
743
     */
744
    function html_accents($string)
745
    {
746
        return $string;
747
    }
748
}
749
750
/**
751
 * @param $ID
752
 *
753
 * @return array
754
 */
755
function set_name($ID)
756
{
757
    //    global $sql2, $sql2bis, $xoopsDB;
758
    $name = ' ';
0 ignored issues
show
Unused Code introduced by
The assignment to $name is dead and can be removed.
Loading history...
759
    $ID   = (int)$ID;
760
    $ani  = [];
761
    if ($ID) {
762
        $sqlQuery    = 'SELECT id, pname, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id = '$ID'";
763
        $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery);
764
        $ani         = $GLOBALS['xoopsDB']->fetchBoth($queryResult);
765
        /*
766
        $name        = $ani[1];
767
        if ($sql2bis) { // true for E.R.o'S. only
768
            $name = html_accents($name);
769
            //$affx = $ani[5] ;  // affix-ID
770
            if ($affx) {
771
                $affix  = fetch_record("$sql2bis '$affx'");
772
                $type   = $affix[1];
773
                $affixe = html_accents($affix[0]);
774
                if ($type[0] === 'P') {
775
                    $name = '<i>' . $affixe . '</i>&nbsp;' . $name;
776
                }
777
                if ($type[0] === 'S') {
778
                    $name = $name . '&nbsp;<i>' . $affixe . '</i>';
779
                }
780
            }
781
            $ani[1] = $name;
782
        }
783
               */
784
    }
785
786
    return $ani;
787
}
788
789
/**
790
 * @param $ems
791
 *
792
 * @return string
793
 */
794
function Ems_($ems)
795
{
796
    if (function_exists('Ems')) {
797
        return Ems($ems);
798
    }
799
    if (!$ems) {
800
        return '&nbsp;';
801
    }
802
    $e   = str_replace(' ', '+', $ems);
803
    $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>";
804
805
    return $res;
806
}
807
808
/**
809
 * @param $ID
810
 *
811
 * @return string
812
 */
813
function one_animal($ID)
814
{
815
    global $xoopsDB;
816
    global $sex, $val, $sosa, $detail, $sql3;
817
    $content = '';
818
    $sosa    = 12;
819
    // echo '<div style="position:relative;float:right;width=2.0em;color=white;">' . $sosa . '</div>' ;
820
    $animal = set_name($ID);
821
822
    if (is_array($animal)) {
0 ignored issues
show
introduced by
The condition is_array($animal) is always true.
Loading history...
823
        [$ID, $name, $sex, $hd, $ems] = $animal;
824
    }
825
    $sqlQuery    = 'SELECT SQL_CACHE COUNT(id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " where father = '$ID' or mother = '$ID'";
826
    $queryResult = $GLOBALS['xoopsDB']->queryF($sqlQuery);
827
    $nb          = $GLOBALS['xoopsDB']->fetchBoth($queryResult);
828
    $nb_children = $nb[0];
829
    if (0 == $nb_children) {
830
        $nb_children = _MA_PEDIGREE_COI_NO;
831
    }
832
    //$dogid = $animal[0];
833
    $content .= '<tr><td><a href="dog.php?id=' . $ID . '">' . stripslashes($name) . '</a>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $name does not seem to be defined for all execution paths leading up to this point.
Loading history...
834
    // if ($nb_enf == 0) echo ' &oslash;' ;
835
    if ($val) {
836
        $content .= $val;
837
    }
838
    if (1 == $sex) {
839
        $geslacht = '<img src="assets/images/female.gif">';
840
    }
841
    if (0 == $sex) {
842
        $geslacht = '<img src="assets/images/male.gif">';
843
    }
844
    $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...
845
846
    return $content;
847
}
848
849
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  MAIN  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
850
851
$nl = "\n"; // the newline character
852
853
//edit by jc
854
//$link = @mysqli_pconnect ($host, $database, $password)
855
//   or   die ("<html><body>Connection to database failed.</body></html>") ;
856
857
//$a = '';
858
$s      = Request::getInt('s', 0, 'GET'); //_GET['s'];
859
$d      = Request::getInt('d', 0, 'GET'); //$_GET['d'];
860
$detail = Request::getString('detail', '', 'GET'); //$_GET['detail'];
861
862
if (isset($si)) {
863
    $s = Pedigree\Utility::findId($si);
864
}
865
if (isset($da)) {
866
    $d = Pedigree\Utility::findId($da);
867
}
868
//test for variables
869
//echo "si=".$si." da=".$da." s=".$s." d=".$d;
870
$utils = $GLOBALS['xoopsDB']->queryF("SELECT user(), date_format(now(),'%d-%b-%Y')");
871
[$who, $jourj] = $GLOBALS['xoopsDB']->fetchBoth($utils);
872
873
if (isset($IC)) {
874
    $detail = -1;
875
    $a      = $IC;
876
}
877
878
if (!isset($detail)) {
879
    $detail = 0;
880
}
881
882
if (!isset($a)) {
883
    if (isset($s) && !isset($d)) {
884
        $a = $s;
885
        $s = '';
886
    }
887
    if (isset($d) && !isset($s)) {
888
        $a = $d;
889
        $d = '';
890
    }
891
}
892
893
if (isset($a)) {
894
    $sqlQuery    = 'SELECT id, father, mother, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id  = '$a'";
895
    $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery);
896
    $rowhond     = $GLOBALS['xoopsDB']->fetchBoth($queryResult);
897
    $a           = $rowhond['id'];
898
    $s           = $rowhond['father'];
899
    $d           = $rowhond['mother'];
900
}
901
$a += 0;
902
$s += 0;
903
$d += 0; // [IDs are numbers]
904
905
$xoopsTpl->assign('ptitle', _MA_PEDIGREE_COI_CKRI);
906
$xoopsTpl->assign('pcontent', strtr(_MA_PEDIGREE_COI_CKRI_CT, ['[animalType]' => $moduleConfig['animalType']]));
907
908
if (!$s && !$d) {
909
    $error = _MA_PEDIGREE_COI_SPANF1 . $a . _MA_PEDIGREE_COI_SPANF2;
910
    $xoopsTpl->assign('COIerror', $error);
911
}
912
913
$maxn_ = 1000;
914
$maxr_ = 9;
915
916
$maxn     = $maxn_;
917
$maxr     = $maxr_;
918
$cinnamon = 0;
919
$chocolat = 0;
920
$dilution = 0;
921
$sexlred  = 0;
922
923
$nivomin = -$maxr; /* Maximal depth of recursion (-10) */
924
$codec   = 0;
925
$gens    = 4; /* 4 gens. for both pedigrees of couple */
926
$litter  = 0;
927
928
// echo "s:".$s."<br>";
929
// echo "d:".$d."<br>";
930
931
$codec1 = $d;
932
$codec2 = $s;
933
$val    = '';
934
935
if (!$s && $d) {
936
    $codec1 = $d;
937
    $codec2 = 0;
938
}
939
if ($codec1 == $codec2) {
940
    $codec2 = 0;
941
}
942
943
$sqlQuery    = 'SELECT father, mother, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id  = '$codec1'";
944
$queryResult = $GLOBALS['xoopsDB']->query($sqlQuery);
945
$rowhond     = $GLOBALS['xoopsDB']->fetchBoth($queryResult);
946
$a1          = $rowhond['id'];
947
$s1          = $rowhond['father'];
948
$d1          = $rowhond['mother'];
949
$sex1        = $rowhond['roft'];
950
951
// echo "sqlquery:".$sqlQuery."<br>";
952
953
$sqlQuery    = 'SELECT father, mother, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id  = '$codec2'";
954
$queryResult = $GLOBALS['xoopsDB']->query($sqlQuery);
955
$rowhond     = $GLOBALS['xoopsDB']->fetchBoth($queryResult);
956
$a2          = $rowhond['id'];
957
$s2          = $rowhond['father'];
958
$d2          = $rowhond['mother'];
959
$sex2        = $rowhond['roft'];
960
961
// echo "sqlquery:".$sqlQuery."<br>";
962
963
//if ($sex1 == '0' && $sex2 == '1') { $a3 = $a1 ; $a1 = $a2 ; $a2 = $a3 ; }   /* permute dam and sire */
964
$codec1 = $a1;
965
$codec2 = $a2;
966
if (!isset($s1) || !isset($d1) || !isset($s2) || !isset($d2)) {
967
    $xoopsTpl->assign('COIerror', _MA_PEDIGREE_COI_SGPU);
968
}
969
970
$title   = strtr(_MA_PEDIGREE_FLD_FATH, ['[father]' => $moduleConfig['father']]) . ' (' . stripslashes(Pedigree\Utility::showParent($codec2)) . ')' . _MA_PEDIGREE_COI_AND . strtr(_MA_PEDIGREE_FLD_MOTH, ['[mother]' => $moduleConfig['mother']]) . ' (' . stripslashes(
971
        Pedigree\Utility::showParent($codec1)
972
    ) . ')';
973
$content = stripslashes(one_animal($codec2));
974
$content .= stripslashes(one_animal($codec1));
975
$val     = '';
976
$xoopsTpl->assign('SADtitle', $title);
977
$xoopsTpl->assign('SADcontent', $content);
978
$xoopsTpl->assign(
979
    'SADexplain',
980
    strtr(_MA_PEDIGREE_COI_SDEX, [
981
        '[animalType]'  => $moduleConfig['animalType'],
982
        '[animalTypes]' => $moduleConfig['animalTypes'],
983
        '[children]'    => $moduleConfig['children'],
984
    ])
985
);
986
987
$de_cujus = 0;
988
$sire_ID  = Request::getInt('s', 0, 'GET'); //$_GET['s'];
989
$dam_ID   = Request::getInt('d', 0, 'GET'); //$_GET['d'];
990
991
$rec     = 'SELECT id FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE father = '" . $sire_ID . "' AND mother = '" . $dam_ID . "' ORDER BY pname";
992
$result  = $GLOBALS['xoopsDB']->query($rec);
993
$content = '';
994
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
995
    $content .= one_animal($row['id']);
996
}
997
998
$xoopsTpl->assign(
999
    'COMtitle',
1000
    strtr(_MA_PEDIGREE_COI_COMTIT, [
1001
        '[father]' => $moduleConfig['father'],
1002
        '[mother]' => $moduleConfig['mother'],
1003
    ])
1004
);
1005
$xoopsTpl->assign(
1006
    'COMexplain',
1007
    strtr(_MA_PEDIGREE_COI_COMEX, [
1008
        '[animalType]' => $moduleConfig['animalType'],
1009
        '[children]'   => $moduleConfig['children'],
1010
    ])
1011
);
1012
$xoopsTpl->assign('COMcontent', $content);
1013
1014
if (!isset($nb_gen)) {
1015
    $nb_gen = 7;
1016
    if ($detail) {
1017
        $nb_gen = 9;
1018
    }
1019
} elseif ($nb_gen < $pedigree) {
1020
    $nb_gen = $pedigree;
1021
}
1022
1023
$IDs = [$de_cujus + 0, $codec1 + 0, $codec2 + 0]; /* Structuring animal IDs into memory */
1024
1025
$nbanims = GENEALOGY(); // ************************************************************* //
1026
1027
for ($i = 0; $i <= $nbanims; ++$i) {
1028
    $empty[$i] = 0;
1029
}
1030
1031
foreach ($fathers as $i => $a) {
1032
    if ($a) {
1033
        $fathers[$i] = $inds[$a];
1034
    }
1035
} /* Replace parents codes */
1036
foreach ($mothers as $i => $a) {
1037
    if ($a) {
1038
        $mothers[$i] = $inds[$a];
1039
    }
1040
} /*   by  their  indices  */
1041
1042
dist_m($mothers[0]); // set "$mater" array (list of all maternal ascendants), for Anim #0
1043
1044
/* Calculating CONSANGUINITY by dual (paternal & maternal) path method */
1045
$f       = $empty;
1046
$ICknown = $empty;
1047
$deltaf  = $empty;
1048
$marked  = $empty;
1049
$SSDcor  = $SSDsire = $SSDdam = '';
1050
1051
/******************  LAUNCHING ALL RECURSIONS  ********************/
1052
/*                                                                */
1053
CONSANG(-1); /* [-1 is standing for de_cujus]
1054
/*                                                                */
1055
/******************************************************************/
1056
1057
$nf = ceil(100 * $COIs[0]);
1058
if ($nf >= 55) {
1059
    $w = _MA_PEDIGREE_COI_HUGE;
1060
} else {
1061
    if ($nf >= 35) {
1062
        $w = _MA_PEDIGREE_COI_VHIG;
1063
    } else {
1064
        if ($nf >= 20) {
1065
            $w = _MA_PEDIGREE_COI_HIGH;
1066
        } else {
1067
            if ($nf >= 10) {
1068
                $w = _MA_PEDIGREE_COI_MEDI;
1069
            } else {
1070
                if ($nf >= 05) {
1071
                    $w = _MA_PEDIGREE_COI_LOW;
1072
                } else {
1073
                    if ($nf >= 02) {
1074
                        $w = _MA_PEDIGREE_COI_VLOW;
1075
                    } else {
1076
                        if ($nf >= 01) {
1077
                            $w = _MA_PEDIGREE_COI_VVLO;
1078
                        } else {
1079
                            $w = _MA_PEDIGREE_COI_TLTB;
1080
                        }
1081
                    }
1082
                }
1083
            }
1084
        }
1085
    }
1086
}
1087
$w = _MA_PEDIGREE_COI_TVI . ' ' . $w;
1088
1089
$nb_all = 0;
1090
count_all(0, 0); // count all ascendants in flat tree
1091
1092
$nbmax  = (2 << $nb_gen) - 2;
1093
$asctc  = _MA_PEDIGREE_COI_ASTC . $nb_gen . _MA_PEDIGREE_COI_ASTCGEN . $nbmax . ')';
1094
$ascuni = _MA_PEDIGREE_COI_ASDKA . $nb_gen . _MA_PEDIGREE_COI_ASGEN;
1095
$xoopsTpl->assign('ASCtitle', _MA_PEDIGREE_COI_ACTIT);
1096
$xoopsTpl->assign('ASCtc', $asctc);
1097
$xoopsTpl->assign('ASCuni', $ascuni);
1098
$xoopsTpl->assign('ASCall', $nb_all);
1099
$xoopsTpl->assign('ASCani', $nbani);
1100
$xoopsTpl->assign('ASCexplain', _MA_PEDIGREE_COI_ACEX);
1101
1102
$f0 = mb_substr($COIs[0], 0, 8);
1103
if (!$f0) {
1104
    $f0 = 'n.a.';
1105
}
1106
$f1 = 100 * $f0;
1107
1108
$xoopsTpl->assign(
1109
    'COItitle',
1110
    strtr(_MA_PEDIGREE_COI_COITIT, [
1111
        '[father]' => $moduleConfig['father'],
1112
        '[mother]' => $moduleConfig['mother'],
1113
    ])
1114
);
1115
$xoopsTpl->assign('COIperc', $w);
1116
$xoopsTpl->assign('COIval', $f1);
1117
$xoopsTpl->assign(
1118
    'COIexplain',
1119
    strtr(_MA_PEDIGREE_COI_COIEX, [
1120
        '[animalType]'  => $moduleConfig['animalType'],
1121
        '[animalTypes]' => $moduleConfig['animalTypes'],
1122
        '[children]'    => $moduleConfig['children'],
1123
    ])
1124
);
1125
$xoopsTpl->assign('COIcoi', _MA_PEDIGREE_COI_COI);
1126
$dogid = Request::getInt('dogid', 0, 'GET');
1127
$query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' SET coi=' . $f1 . ' WHERE id = ' . $dogid;
1128
$GLOBALS['xoopsDB']->queryF($query);
1129
arsort($deltaf);
1130
$j = 1;
1131
foreach ($deltaf as $i => $v) {
1132
    if ($j > 12) {
1133
        break;
1134
    }
1135
    ++$j;
1136
    $code   = $IDs[$i];
1137
    $v      = mb_substr($v, 0, 7);
1138
    $animal = set_name($IDs[$i]);
1139
    $name   = $animal[1];
1140
    if (!$name) {
1141
        $name = $i . ' [' . $IDs[$i] . ']';
1142
    }
1143
    if ($v > 0.0001 && $v < 1.0) {
1144
        $dogs[] = ['id' => $code, 'name' => stripslashes($name), 'coi' => 100 * $v];
1145
    }
1146
}
1147
1148
$xoopsTpl->assign('TCAtitle', _MA_PEDIGREE_COI_TCATIT);
1149
$xoopsTpl->assign('TCApib', _MA_PEDIGREE_COI_TCApib);
1150
$xoopsTpl->assign('dogs', $dogs);
1151
$xoopsTpl->assign(
1152
    'TCAexplain',
1153
    strtr(_MA_PEDIGREE_COI_TCAEX, [
1154
        '[animalType]'  => $moduleConfig['animalType'],
1155
        '[animalTypes]' => $moduleConfig['animalTypes'],
1156
        '[children]'    => $moduleConfig['children'],
1157
        '[mother]'      => $moduleConfig['mother'],
1158
        '[father]'      => $moduleConfig['father'],
1159
    ])
1160
);
1161
1162
if ($detail) {
1163
    if ($verbose) {
1164
        $verbose = 0;
1165
    }
1166
    if (count($COIs) > 1) {
1167
        $ICs = $COIs;
1168
        arsort($ICs);
1169
        $j = 1;
1170
        foreach ($ICs as $i => $ic) {
1171
            if ($j > 12) {
1172
                break;
1173
            }
1174
            ++$j;
1175
            $ID   = $IDs[$i];
1176
            $ani  = set_name($ID);
1177
            $name = $ani[1];
1178
            $ic   = mb_substr($ic, 0, 6);
1179
            if ($ic > 0.125 && $i) {
1180
                $mia[] = ['id' => $ID, 'name' => stripslashes($name), 'coi' => 100 * $ic];
1181
            }
1182
        }
1183
    }
1184
    $xoopsTpl->assign('MIAtitle', _MA_PEDIGREE_COI_MIATIT);
1185
    $xoopsTpl->assign('mia', $mia);
1186
    $xoopsTpl->assign('MIAexplain', strtr(_MA_PEDIGREE_COI_MIAEX, ['[animalType]' => $moduleConfig['animalType']]));
1187
1188
    if (!$ICknown[1]) {
1189
        $marked = $empty;
1190
        CONSANG(1);
1191
    } // Sire
1192
    if (!$ICknown[2]) {
1193
        $marked = $empty;
1194
        CONSANG(2);
1195
    } // Dam
1196
    $COR = 2.0 * $COIs[0] / sqrt((1. + $COIs[1]) * (1. + $COIs[2]));
1197
    $COR = mb_substr($COR, 0, 8);
1198
    if (!$COR) {
1199
        $COR = 'n.a.';
1200
    }
1201
    $f1 = mb_substr($COIs[1], 0, 8);
1202
    $f2 = mb_substr($COIs[2], 0, 8);
1203
    if (!$f1) {
1204
        $f1 = 'n.a.';
1205
    }
1206
    if (!$f2) {
1207
        $f2 = 'n.a.';
1208
    }
1209
    $SSDcor  = (100 * $COR);
1210
    $SSDsire = (100 * $f2);
1211
    $SSDdam  = (100 * $f1);
1212
}
1213
1214
$xoopsTpl->assign(
1215
    'SSDtitle',
1216
    strtr(_MA_PEDIGREE_COI_SSDTIT, [
1217
        '[father]' => $moduleConfig['father'],
1218
        '[mother]' => $moduleConfig['mother'],
1219
    ])
1220
);
1221
$xoopsTpl->assign('SSDcortit', _MA_PEDIGREE_COI_SSDcor);
1222
$xoopsTpl->assign('SSDbsd', strtr(_MA_PEDIGREE_COI_SDDbsd, ['[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother']]));
1223
$xoopsTpl->assign('SSDcor', $SSDcor);
1224
1225
$xoopsTpl->assign('SSDS', _MA_PEDIGREE_COI_COI . _MA_PEDIGREE_FROM . strtr(_MA_PEDIGREE_FLD_FATH, ['[father]' => $moduleConfig['father']]));
1226
$xoopsTpl->assign('SSDsire', $SSDsire);
1227
$xoopsTpl->assign('SSDM', _MA_PEDIGREE_COI_COI . _MA_PEDIGREE_FROM . strtr(_MA_PEDIGREE_FLD_MOTH, ['[mother]' => $moduleConfig['mother']]));
1228
$xoopsTpl->assign('SSDdam', $SSDdam);
1229
1230
// echo "SSDsire : ".$SSDsire."<br>";
1231
// echo "SSDdam : ".$SSDdam."<br>";
1232
// print_r($COIs);
1233
1234
$xoopsTpl->assign(
1235
    'SSDexplain',
1236
    strtr(_MA_PEDIGREE_COI_SSDEX, [
1237
        '[father]'     => $moduleConfig['father'],
1238
        '[mother]'     => $moduleConfig['mother'],
1239
        '[animalType]' => $moduleConfig['animalTypes'],
1240
    ])
1241
);
1242
$xoopsTpl->assign('TNXtitle', _MA_PEDIGREE_COI_TNXTIT);
1243
$xoopsTpl->assign('TNXcontent', _MA_PEDIGREE_COI_TNXCON);
1244
$xoopsTpl->assign('Name', _MA_PEDIGREE_FLD_NAME);
1245
$xoopsTpl->assign('Gender', _MA_PEDIGREE_FLD_GEND);
1246
$xoopsTpl->assign('Children', strtr(_MA_PEDIGREE_FLD_PUPS, ['[children]' => $moduleConfig['children']]));
1247
1248
//add data to smarty template
1249
$xoopsTpl->assign('explain', _MA_PEDIGREE_EXPLAIN);
1250
1251
//comments and footer
1252
require XOOPS_ROOT_PATH . '/footer.php';
1253