Completed
Push — master ( 871d94...af939e )
by Michael
03:14
created

mpedigree.php ➔ pedigree_main()   F

Complexity

Conditions 35
Paths > 20000

Size

Total Lines 284
Code Lines 126

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 35
eloc 126
nc 4294967295
nop 1
dl 0
loc 284
rs 2
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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 38 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
// -------------------------------------------------------------------------
3
4
require_once dirname(dirname(__DIR__)) . '/mainfile.php';
5
6
$moduleDirName = basename(__DIR__);
7
xoops_loadLanguage('main', $moduleDirName);
8
9
// Include any common code for this module.
10
require_once(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php');
11
xoops_load('XoopsRequest');
12
13
$xoopsOption['template_main'] = 'pedigree_mpedigree.tpl';
14
15
include $GLOBALS['xoops']->path('/header.php');
16
17
//get module configuration
18
$moduleHandler = xoops_getHandler('module');
19
$module        = $moduleHandler->getByDirname('pedigree');
20
$configHandler = xoops_getHandler('config');
21
$moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
22
23
//always start with Anika
24
$pedId = XoopsRequest::getInt('pedid', 0, 'GET');
25
//$pedId = $_GET['pedid'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
//draw pedigree
27
pedigree_main($pedId);
28
29
//comments and footer
30
include $GLOBALS['xoops']->path('/footer.php');
31
32
//
33
// Displays the "Main" tab of the module
34
//
35
/**
36
 * @param $ID
37
 */
38
function pedigree_main($ID)
0 ignored issues
show
Coding Style introduced by
pedigree_main uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
39
{
40
    global $moduleConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
41
42
    $queryString = '
43
    SELECT d.id as d_id,
44
    d.naam as d_naam,
45
    d.roft as d_roft,
46
    f.id as f_id,
47
    f.naam as f_naam,
48
    m.id as m_id,
49
    m.naam as m_naam,
50
    ff.id as ff_id,
51
    ff.naam as ff_naam,
52
    mf.id as mf_id,
53
    mf.naam as mf_naam,
54
    fm.id as fm_id,
55
    fm.naam as fm_naam,
56
    mm.id as mm_id,
57
    mm.naam as mm_naam,
58
    fff.id as fff_id,
59
    fff.naam as fff_naam,
60
    ffm.id as ffm_id,
61
    ffm.naam as ffm_naam,
62
    fmf.id as fmf_id,
63
    fmf.naam as fmf_naam,
64
    fmm.id as fmm_id,
65
    fmm.naam as fmm_naam,
66
    mmf.id as mmf_id,
67
    mmf.naam as mmf_naam,
68
    mff.id as mff_id,
69
    mff.naam as mff_naam,
70
    mfm.id as mfm_id,
71
    mfm.naam as mfm_naam,
72
    mmm.id as mmm_id,
73
    mmm.naam as mmm_naam,
74
    ffff.id as ffff_id,
75
    ffff.naam as ffff_naam,
76
    ffmf.id as ffmf_id,
77
    ffmf.naam as ffmf_naam,
78
    fmff.id as fmff_id,
79
    fmff.naam as fmff_naam,
80
    fmmf.id as fmmf_id,
81
    fmmf.naam as fmmf_naam,
82
    mmff.id as mmff_id,
83
    mmff.naam as mmff_naam,
84
    mfff.id as mfff_id,
85
    mfff.naam as mfff_naam,
86
    mfmf.id as mfmf_id,
87
    mfmf.naam as mfmf_naam,
88
    mmmf.id as mmmf_id,
89
    mmmf.naam as mmmf_naam,
90
    fffm.id as fffm_id,
91
    fffm.naam as fffm_naam,
92
    ffmm.id as ffmm_id,
93
    ffmm.naam as ffmm_naam,
94
    fmfm.id as fmfm_id,
95
    fmfm.naam as fmfm_naam,
96
    fmmm.id as fmmm_id,
97
    fmmm.naam as fmmm_naam,
98
    mmfm.id as mmfm_id,
99
    mmfm.naam as mmfm_naam,
100
    mffm.id as mffm_id,
101
    mffm.naam as mffm_naam,
102
    mfmm.id as mfmm_id,
103
    mfmm.naam as mfmm_naam,
104
    mmmm.id as mmmm_id,
105
    mmmm.naam as mmmm_naam
106
    FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d
107
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' f ON d.father = f.id
108
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON d.mother = m.id
109
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ff ON f.father = ff.id
110
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fff ON ff.father = fff.id
111
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ffm ON ff.mother = ffm.id
112
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mf ON m.father = mf.id
113
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mff ON mf.father = mff.id
114
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mfm ON mf.mother = mfm.id
115
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fm ON f.mother = fm.id
116
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmf ON fm.father = fmf.id
117
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmm ON fm.mother = fmm.id
118
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mm ON m.mother = mm.id
119
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mmf ON mm.father = mmf.id
120
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mmm ON mm.mother = mmm.id
121
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ffff ON fff.father = ffff.id
122
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ffmf ON ffm.father = ffmf.id
123
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmff ON fmf.father = fmff.id
124
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmmf ON fmm.father = fmmf.id
125
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mmff ON mmf.father = mmff.id
126
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mfff ON mff.father = mfff.id
127
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mfmf ON mfm.father = mfmf.id
128
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mmmf ON mmm.father = mmmf.id
129
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fffm ON fff.mother = fffm.id
130
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ffmm ON ffm.mother = ffmm.id
131
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmfm ON fmf.mother = fmfm.id
132
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmmm ON fmm.mother = fmmm.id
133
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mmfm ON mmf.mother = mmfm.id
134
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mffm ON mff.mother = mffm.id
135
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mfmm ON mfm.mother = mfmm.id
136
    LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " mmmm ON mmm.mother = mmmm.id
137
    where d.id=$ID";
138
139
    $result = $GLOBALS['xoopsDB']->query($queryString);
140
141
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
142
        //crete array to count frequency (to select colour)
143
        count_item($freq, $row['d_id']);
144
        count_item($freq, $row['f_id']);
145
        count_item($freq, $row['m_id']);
146
        count_item($freq, $row['ff_id']);
147
        count_item($freq, $row['fm_id']);
148
        count_item($freq, $row['mf_id']);
149
        count_item($freq, $row['mm_id']);
150
        count_item($freq, $row['fff_id']);
151
        count_item($freq, $row['ffm_id']);
152
        count_item($freq, $row['fmf_id']);
153
        count_item($freq, $row['fmm_id']);
154
        count_item($freq, $row['mff_id']);
155
        count_item($freq, $row['mfm_id']);
156
        count_item($freq, $row['mmf_id']);
157
        count_item($freq, $row['mmm_id']);
158
        count_item($freq, $row['ffff_id']);
159
        count_item($freq, $row['ffmf_id']);
160
        count_item($freq, $row['fmff_id']);
161
        count_item($freq, $row['fmmf_id']);
162
        count_item($freq, $row['mfff_id']);
163
        count_item($freq, $row['mfmf_id']);
164
        count_item($freq, $row['mmff_id']);
165
        count_item($freq, $row['mmmf_id']);
166
        count_item($freq, $row['fffm_id']);
167
        count_item($freq, $row['ffmm_id']);
168
        count_item($freq, $row['fmfm_id']);
169
        count_item($freq, $row['fmmm_id']);
170
        count_item($freq, $row['mffm_id']);
171
        count_item($freq, $row['mfmm_id']);
172
        count_item($freq, $row['mmfm_id']);
173
        count_item($freq, $row['mmmm_id']);
174
175
        //create array for dog (and all parents)
176
        //selected dog
177
        $d['d']['name'] = stripslashes($row['d_naam']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$d was never initialized. Although not strictly required by PHP, it is generally a good practice to add $d = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
178
        $d['d']['id']   = $row['d_id'];
179
        $d['d']['roft'] = $row['d_roft'];
180
        $d['d']['col']  = 'transparant';
181
        //father
182
        $d['f']['name'] = stripslashes($row['f_naam']);
183
        $d['f']['id']   = $row['f_id'];
184
        $d['f']['col']  = crcolour('f', $freq[$row['f_id']]);
185
        //mother
186
        $d['m']['name'] = stripslashes($row['m_naam']);
187
        $d['m']['id']   = $row['m_id'];
188
        $d['m']['col']  = crcolour('m', $freq[$row['m_id']]);
189
        //grandparents
190
        //father father
191
        $d['ff']['name'] = stripslashes($row['ff_naam']);
192
        $d['ff']['id']   = $row['ff_id'];
193
        $d['ff']['col']  = crcolour('f', $freq[$row['ff_id']]);
194
        //father mother
195
        $d['fm']['name'] = stripslashes($row['fm_naam']);
196
        $d['fm']['id']   = $row['fm_id'];
197
        $d['fm']['col']  = crcolour('m', $freq[$row['fm_id']]);
198
        //mother father
199
        $d['mf']['name'] = stripslashes($row['mf_naam']);
200
        $d['mf']['id']   = $row['mf_id'];
201
        $d['mf']['col']  = crcolour('f', $freq[$row['mf_id']]);
202
        //mother mother
203
        $d['mm']['name'] = stripslashes($row['mm_naam']);
204
        $d['mm']['id']   = $row['mm_id'];
205
        $d['mm']['col']  = crcolour('m', $freq[$row['mm_id']]);
206
        //great-grandparents
207
        //father father father
208
        $d['fff']['name'] = stripslashes($row['fff_naam']);
209
        $d['fff']['id']   = $row['fff_id'];
210
        $d['fff']['col']  = crcolour('f', $freq[$row['fff_id']]);
211
        //father father mother
212
        $d['ffm']['name'] = stripslashes($row['ffm_naam']);
213
        $d['ffm']['id']   = $row['ffm_id'];
214
        $d['ffm']['col']  = crcolour('m', $freq[$row['ffm_id']]);
215
        //father mother father
216
        $d['fmf']['name'] = stripslashes($row['fmf_naam']);
217
        $d['fmf']['id']   = $row['fmf_id'];
218
        $d['fmf']['col']  = crcolour('f', $freq[$row['fmf_id']]);
219
        //father mother mother
220
        $d['fmm']['name'] = stripslashes($row['fmm_naam']);
221
        $d['fmm']['id']   = $row['fmm_id'];
222
        $d['fmm']['col']  = crcolour('m', $freq[$row['fmm_id']]);
223
        //mother father father
224
        $d['mff']['name'] = stripslashes($row['mff_naam']);
225
        $d['mff']['id']   = $row['mff_id'];
226
        $d['mff']['col']  = crcolour('f', $freq[$row['mff_id']]);
227
        //mother father mother
228
        $d['mfm']['name'] = stripslashes($row['mfm_naam']);
229
        $d['mfm']['id']   = $row['mfm_id'];
230
        $d['mfm']['col']  = crcolour('m', $freq[$row['mfm_id']]);
231
        //mother mother father
232
        $d['mmf']['name'] = stripslashes($row['mmf_naam']);
233
        $d['mmf']['id']   = $row['mmf_id'];
234
        $d['mmf']['col']  = crcolour('f', $freq[$row['mmf_id']]);
235
        //mother mother mother
236
        $d['mmm']['name'] = stripslashes($row['mmm_naam']);
237
        $d['mmm']['id']   = $row['mmm_id'];
238
        $d['mmm']['col']  = crcolour('m', $freq[$row['mmm_id']]);
239
        //great-great-grandparents (fathers)
240
        //father father father
241
        $d['ffff']['name'] = stripslashes($row['ffff_naam']);
242
        $d['ffff']['id']   = $row['ffff_id'];
243
        $d['ffff']['col']  = crcolour('f', $freq[$row['ffff_id']]);
244
        //father father mother
245
        $d['ffmf']['name'] = stripslashes($row['ffmf_naam']);
246
        $d['ffmf']['id']   = $row['ffmf_id'];
247
        $d['ffmf']['col']  = crcolour('f', $freq[$row['ffmf_id']]);
248
        //father mother father
249
        $d['fmff']['name'] = stripslashes($row['fmff_naam']);
250
        $d['fmff']['id']   = $row['fmff_id'];
251
        $d['fmff']['col']  = crcolour('f', $freq[$row['fmff_id']]);
252
        //father mother mother
253
        $d['fmmf']['name'] = stripslashes($row['fmmf_naam']);
254
        $d['fmmf']['id']   = $row['fmmf_id'];
255
        $d['fmmf']['col']  = crcolour('f', $freq[$row['fmmf_id']]);
256
        //mother father father
257
        $d['mfff']['name'] = stripslashes($row['mfff_naam']);
258
        $d['mfff']['id']   = $row['mfff_id'];
259
        $d['mfff']['col']  = crcolour('f', $freq[$row['mfff_id']]);
260
        //mother father mother
261
        $d['mfmf']['name'] = stripslashes($row['mfmf_naam']);
262
        $d['mfmf']['id']   = $row['mfmf_id'];
263
        $d['mfmf']['col']  = crcolour('f', $freq[$row['mfmf_id']]);
264
        //mother mother father
265
        $d['mmff']['name'] = stripslashes($row['mmff_naam']);
266
        $d['mmff']['id']   = $row['mmff_id'];
267
        $d['mmff']['col']  = crcolour('f', $freq[$row['mmff_id']]);
268
        //mother mother mother
269
        $d['mmmf']['name'] = stripslashes($row['mmmf_naam']);
270
        $d['mmmf']['id']   = $row['mmmf_id'];
271
        $d['mmmf']['col']  = crcolour('f', $freq[$row['mmmf_id']]);
272
        //great-great-grandparents (mothers)
273
        //father father father
274
        $d['fffm']['name'] = stripslashes($row['fffm_naam']);
275
        $d['fffm']['id']   = $row['fffm_id'];
276
        $d['fffm']['col']  = crcolour('m', $freq[$row['fffm_id']]);
277
        //father father mother
278
        $d['ffmm']['name'] = stripslashes($row['ffmm_naam']);
279
        $d['ffmm']['id']   = $row['ffmm_id'];
280
        $d['ffmm']['col']  = crcolour('m', $freq[$row['ffmm_id']]);
281
        //father mother father
282
        $d['fmfm']['name'] = stripslashes($row['fmfm_naam']);
283
        $d['fmfm']['id']   = $row['fmfm_id'];
284
        $d['fmfm']['col']  = crcolour('m', $freq[$row['fmfm_id']]);
285
        //father mother mother
286
        $d['fmmm']['name'] = stripslashes($row['fmmm_naam']);
287
        $d['fmmm']['id']   = $row['fmmm_id'];
288
        $d['fmmm']['col']  = crcolour('m', $freq[$row['fmmm_id']]);
289
        //mother father father
290
        $d['mffm']['name'] = stripslashes($row['mffm_naam']);
291
        $d['mffm']['id']   = $row['mffm_id'];
292
        $d['mffm']['col']  = crcolour('m', $freq[$row['mffm_id']]);
293
        //mother father mother
294
        $d['mfmm']['name'] = stripslashes($row['mfmm_naam']);
295
        $d['mfmm']['id']   = $row['mfmm_id'];
296
        $d['mfmm']['col']  = crcolour('m', $freq[$row['mfmm_id']]);
297
        //mother mother father
298
        $d['mmfm']['name'] = stripslashes($row['mmfm_naam']);
299
        $d['mmfm']['id']   = $row['mmfm_id'];
300
        $d['mmfm']['col']  = crcolour('m', $freq[$row['mmfm_id']]);
301
        //mother mother mother
302
        $d['mmmm']['name'] = stripslashes($row['mmmm_naam']);
303
        $d['mmmm']['id']   = $row['mmmm_id'];
304
        $d['mmmm']['col']  = crcolour('m', $freq[$row['mmmm_id']]);
305
    }
306
307
    //add data to smarty template
308
    $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $d['d']['name'] . ' -- mega pedigree');
0 ignored issues
show
Bug introduced by
The variable $d does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
309
    //assign dog(s)
310
    $GLOBALS['xoopsTpl']->assign('d', $d);
311
    $GLOBALS['xoopsTpl']->assign('male', "<img src=\"assets/images/male.gif\">");
312
    $GLOBALS['xoopsTpl']->assign('female', "<img src=\"assets/images/female.gif\">");
313
    //assign extra display options
314
    $GLOBALS['xoopsTpl']->assign('unknown', 'Unknown');
315
    $GLOBALS['xoopsTpl']->assign('f2', strtr(_MA_PEDIGREE_MPED_F2, array('[animalType]' => $moduleConfig['animalType'])));
316
    $GLOBALS['xoopsTpl']->assign('f3', strtr(_MA_PEDIGREE_MPED_F3, array('[animalType]' => $moduleConfig['animalType'])));
317
    $GLOBALS['xoopsTpl']->assign('f4', strtr(_MA_PEDIGREE_MPED_F4, array('[animalType]' => $moduleConfig['animalType'])));
318
    $GLOBALS['xoopsTpl']->assign('m2', strtr(_MA_PEDIGREE_MPED_M2, array('[animalType]' => $moduleConfig['animalType'])));
319
    $GLOBALS['xoopsTpl']->assign('m3', strtr(_MA_PEDIGREE_MPED_M3, array('[animalType]' => $moduleConfig['animalType'])));
320
    $GLOBALS['xoopsTpl']->assign('m4', strtr(_MA_PEDIGREE_MPED_M4, array('[animalType]' => $moduleConfig['animalType'])));
321
}
322
323
/**
324
 * @param $sex
325
 * @param $item
326
 *
327
 * @return string
328
 */
329
function crcolour($sex, $item)
330
{
331
    if ($item == '1') {
332
        $col = 'transparant';
333
    } elseif ($item == '2' && $sex === 'f') {
334
        $col = '#C8C8FF';
335
    } elseif ($item == 3 && $sex === 'f') {
336
        $col = '#6464FF';
337
    } elseif ($item == '4' && $sex === 'f') {
338
        $col = '#0000FF';
339
    } elseif ($item == '2' && $sex === 'm') {
340
        $col = '#FFC8C8';
341
    } elseif ($item == '3' && $sex === 'm') {
342
        $col = '#FF6464';
343
    } elseif ($item == '4' && $sex === 'm') {
344
        $col = '#FF0000';
345
    } else {
346
        $col = 'transparant';
347
    }
348
349
    return $col;
350
}
351
352
/**
353
 * @param     $freq
354
 * @param     $item
355
 * @param int $inc
356
 *
357
 * @return bool
358
 */
359
function count_item(&$freq, $item, $inc = 1)
360
{
361
    if (!is_array($freq)) {
362
        $freq = array();
363
    }
364
    $freq[$item] = (isset($freq[$item]) ? ($freq[$item] += $inc) : $inc);
365
366
    return true;
367
}
368