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

virtual.php ➔ virt()   F

Complexity

Conditions 24
Paths > 20000

Size

Total Lines 162
Code Lines 95

Duplication

Lines 62
Ratio 38.27 %

Importance

Changes 0
Metric Value
cc 24
eloc 95
nc 45360
nop 0
dl 62
loc 162
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
2
// -------------------------------------------------------------------------
3
4
require_once dirname(dirname(__DIR__)) . '/mainfile.php';
5
6
$moduleDirName = basename(__DIR__);
7
xoops_loadLanguage('main', $moduleDirName);
8
xoops_load('PedigreeAnimal', $moduleDirName);
9
xoops_load('XoopsRequest');
10
11
// Include any common code for this module.
12
require_once XOOPS_ROOT_PATH . "/modules/{$moduleDirName}/include/common.php";
13
14
$pedigree = PedigreePedigree::getInstance(false);
15
16
$xoopsOption['template_main'] = 'pedigree_virtual.tpl';
17
18
include $GLOBALS['xoops']->path('/header.php');
19
$xoopsTpl->assign('page_title', 'Pedigree database - Virtual Mating');
20
21
//create function variable from url
22
//if (isset($_GET['f'])) {
23
//    $f = $_GET['f'];
24
//}
25
//if (!isset($f)) {
26
$f = XoopsRequest::getString('f', '', 'get');
27
switch ($f) {
28
    default: // virt
29
/*
30
        //get module configuration
31
        $moduleHandler = xoops_getHandler('module');
32
        $module        = $moduleHandler->getByDirname('pedigree');
33
        $configHandler = xoops_getHandler('config');
34
        $moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
35
*/
36
        //    if (isset($_GET['st'])) {
37
        //        $st = $_GET['st'];
38
        //    } else {
39
        //        $st = 0;
40
        //    }
41
        //    if (isset($_GET['l'])) {
42
        //        $l = $_GET['l'];
43
        //    } else {
44
        //        $l = 'A';
45
        //    }
46
        $st = XoopsRequest::getInt('st', 0, 'get');
47
        $l  = XoopsRequest::getString('l', 'a', 'get');
48
49
        $xoopsTpl->assign('sire', '1');
50
        //create list of males dog to select from
51
        $perp = $pedigree->getConfig('perpage');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $perp is correct as $pedigree->getConfig('perpage') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
52
        //count total number of dogs
53
        $numdog = 'SELECT COUNT(d.Id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON m.Id = d.mother LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') //            . " f ON f.id = d.father WHERE d.roft = '0' and d.mother != '0' and d.father != '0' and m.mother != '0' and m.father != '0' and f.mother != '0' and f.father != '0' and d.NAAM LIKE '" . $l . "%'";
54
                  . " f ON f.Id = d.father WHERE d.roft = '0' AND d.mother != '0' AND d.father != '0' AND m.mother != '0' AND m.father != '0' AND f.mother != '0' AND f.father != '0' AND d.NAAM LIKE '" . $GLOBALS['xoopsDB']->escape($l) . "%'";
55
        $numres = $GLOBALS['xoopsDB']->query($numdog);
56
        //total number of dogs the query will find
57
        list($numresults) = $GLOBALS['xoopsDB']->fetchRow($numres);
58
        //total number of pages
59
        $numpages = floor($numresults / $perp) + 1;
60
        if (($numpages * $perp) == ($numresults + $perp)) {
61
            --$numpages;
62
        }
63
        //find current page
64
        $cpage = floor($st / $perp) + 1;
65
        //create alphabet
66
        $pages = '';
67
        for ($i = 65; $i <= 90; ++$i) {
68
            if ($l == chr($i)) {
69
                $pages .= "<b><a href=\"virtual.php?r=1&st=0&l=" . chr($i) . "\">" . chr($i) . '</a></b>&nbsp;';
70
            } else {
71
                $pages .= "<a href=\"virtual.php?r=1&st=0&l=" . chr($i) . "\">" . chr($i) . '</a>&nbsp;';
72
            }
73
        }
74
        $pages .= '-&nbsp;';
75
        $pages .= "<a href=\"virtual.php?r=1&st=0&l=Ã…\">Ã…</a>&nbsp;";
76
        $pages .= "<a href=\"virtual.php?r=1&st=0&l=Ö\">Ö</a>&nbsp;";
77
        $pages .= '<br />';
78
        //create previous button
79
        if (($numpages > 1) && ($cpage > 1)) {
80
            $pages .= "<a href=\"virtual.php?r=1&&l=" . $l . 'st=' . ($st - $perp) . "\">" . _MA_PEDIGREE_PREVIOUS . '</a>&nbsp;&nbsp';
81
        }
82
        //create numbers
83
        $xLimit = $numpages + 1;
84
        for ($x = 1; $x < $xLimit; ++$x) {
85
            //create line break after 20 number
86
            if (($x % 20) == 0) {
87
                $pages .= '<br />';
88
            }
89
            if ($x != $cpage) {
90
                $pages .= "<a href=\"virtual.php?r=1&l=" . $l . '&st=' . ($perp * ($x - 1)) . "\">" . $x . '</a>&nbsp;&nbsp;';
91
            } else {
92
                $pages .= $x . '&nbsp;&nbsp';
93
            }
94
        }
95
        //create next button
96
        if ($numpages > 1) {
97
            if ($cpage < $numpages) {
98
                $pages .= "<a href=\"virtual.php?r=1&l=" . $l . '&st=' . ($st + $perp) . "\">" . _MA_PEDIGREE_NEXT . '</a>&nbsp;&nbsp';
99
            }
100
        }
101
102
        //query
103
        $queryString = 'SELECT d.*, d.Id AS d_id, d.NAAM AS d_naam FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON m.Id = d.mother LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " f ON f.Id = d.father WHERE d.roft = '0' AND d.mother != '0' AND d.father != '0' AND m.mother != '0' AND m.father != '0' AND f.mother != '0' AND f.father != '0' AND d.NAAM LIKE '" . $l . "%' ORDER BY d.NAAM LIMIT " . $st . ', ' . $perp;
104
        $result      = $GLOBALS['xoopsDB']->query($queryString);
105
106
        $animal = new PedigreeAnimal();
107
        //test to find out how many user fields there are...
108
        $fields       = $animal->getNumOfFields();
109
        $numofcolumns = 1;
110
        $columns[]    = array('columnname' => 'Name');
111
        for ($i = 0, $iMax = count($fields); $i < $iMax; ++$i) {
112
            $userField   = new Field($fields[$i], $animal->getConfig());
113
            $fieldType   = $userField->getSetting('fieldtype');
114
            $fieldObject = new $fieldType($userField, $animal);
115
            //create empty string
116
            $lookupvalues = '';
117
            if ($userField->isActive() && $userField->inList()) {
118
                if ($userField->hasLookup()) {
119
                    $lookupvalues = $userField->lookupField($fields[$i]);
120
                    //debug information
121
                    //print_r($lookupvalues);
122
                }
123
                $columns[] = array('columnname' => $fieldObject->fieldname, 'columnnumber' => $userField->getId(), 'lookupval' => $lookupvalues);
124
                ++$numofcolumns;
125
                unset($lookupvalues);
126
            }
127
        }
128
129
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
130
            //create picture information
131
            if ($row['foto'] != '') {
132
                $camera = " <img src=\"assets/images/dog-icon25.png\">";
133
            } else {
134
                $camera = '';
135
            }
136
            $name = stripslashes($row['d_naam']) . $camera;
137
            //empty array
138
            unset($columnvalue);
139
            //fill array
140
            for ($i = 1; $i < $numofcolumns; ++$i) {
141
                $x = $columns[$i]['columnnumber'];
142
                //echo $x."columnnumber";
143
                if (is_array($columns[$i]['lookupval'])) {
144
                    foreach ($columns[$i]['lookupval'] as $key => $keyvalue) {
145
                        if ($keyvalue['id'] == $row['user' . $x]) {
146
                            //echo "key:".$row['user5']."<br />";
147
                            $value = $keyvalue['value'];
148
                        }
149
                    }
150
                    //debug information
151
                    ///echo $columns[$i]['columnname']."is an array !";
152
                } //format value - cant use object because of query count
153
                elseif (0 === strpos($row['user' . $x], 'http://')) {
154
                    $value = "<a href=\"" . $row['user' . $x] . "\">" . $row['user' . $x] . '</a>';
155
                } else {
156
                    $value = $row['user' . $x];
157
                }
158
                $columnvalue[] = array('value' => $value);
159
                unset($value);
160
            }
161
            $dogs[] = array(
162
                'id'          => $row['d_id'],
163
                'name'        => $name,
164
                'gender'      => "<img src=\"assets/images/male.gif\" alt=\"" . _MA_PEDIGREE_FEMALE . "\">",
165
                'link'        => "<a href=\"virtual.php?f=dam&selsire=" . $row['d_id'] . "\">" . $name . '</a>',
166
                'colour'      => '',
167
                'number'      => '',
168
                'usercolumns' => isset($columnvalue) ? $columnvalue : 0
169
            );
170
        }
171
172
        //add data to smarty template
173
        //assign dog
174
        if (isset($dogs)) {
175
            $xoopsTpl->assign('dogs', $dogs);
176
        }
177
        $xoopsTpl->assign('columns', $columns);
178
        $xoopsTpl->assign('numofcolumns', $numofcolumns);
179
        $xoopsTpl->assign('tsarray', PedigreeUtilities::sortTable($numofcolumns));
180
        $xoopsTpl->assign('nummatch', strtr(_MA_PEDIGREE_ADD_SELSIRE, array('[father]' => $pedigree->getConfig('father'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('father') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
181
        $xoopsTpl->assign('pages', $pages);
182
183
        $xoopsTpl->assign('virtualtitle', strtr(_MA_PEDIGREE_VIRUTALTIT, array('[mother]' => $pedigree->getConfig('mother'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('mother') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
184
        $xoopsTpl->assign('virtualstory', strtr(_MA_PEDIGREE_VIRUTALSTO, array('[mother]' => $pedigree->getConfig('mother'), '[father]' => $pedigree->getConfig('father'), '[children]' => $pedigree->getConfig('children'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('mother') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure the usage of $pedigree->getConfig('father') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure the usage of $pedigree->getConfig('children') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
185
        $xoopsTpl->assign('nextaction', '<b>' . strtr(_MA_PEDIGREE_VIRT_SIRE, array('[father]' => $pedigree->getConfig('father'))) . '</b>');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('father') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
186
        break;
187
188
    case 'dam':
189
        global $xoopsTpl;
190
        $pedigree = PedigreePedigree::getInstance(false);
191
        $pages = '';
192
/*
193
        //get module configuration
194
        $moduleHandler = xoops_getHandler('module');
195
        $module        = $moduleHandler->getByDirname('pedigree');
196
        $configHandler = xoops_getHandler('config');
197
        $moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
198
*/
199
        $st = XoopsRequest::getInt('st', 0, 'GET');
200
        $l  = XoopsRequest::getWord('l', 'A', 'GET');
201
        $selsire = XoopsRequest::getInt('selsire', 0, 'GET');
202
/*
203
        if (isset($_GET['st'])) {
204
            $st = $_GET['st'];
205
        } else {
206
            $st = 0;
207
        }
208
        if (isset($_GET['l'])) {
209
            $l = $_GET['l'];
210
        } else {
211
            $l = 'A';
212
        }
213
        $selsire = $_GET['selsire'];
214
*/
215
216
        $xoopsTpl->assign('sire', '1');
217
        //create list of males dog to select from
218
        $perp = $pedigree->getConfig('perpage');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $perp is correct as $pedigree->getConfig('perpage') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
219
        //count total number of dogs
220
        $numdog = 'SELECT COUNT(d.Id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON m.Id = d.mother LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') //  . " f ON f.id = d.father WHERE d.roft = '1' and d.mother != '0' and d.father != '0' and m.mother != '0' and m.father != '0' and f.mother != '0' and f.father != '0' and d.NAAM LIKE '" . $l . "%'";
221
                  . " f ON f.Id = d.father WHERE d.roft = '1' AND d.mother != '0' AND d.father != '0' AND m.mother != '0' AND m.father != '0' AND f.mother != '0' AND f.father != '0' AND d.NAAM LIKE '" . $GLOBALS['xoopsDB']->escape($l) . "%'";
222
223
        $numres = $GLOBALS['xoopsDB']->query($numdog);
224
        //total number of dogs the query will find
225
        list($numresults) = $GLOBALS['xoopsDB']->fetchRow($numres);
226
        //total number of pages
227
        $numpages = floor($numresults / $perp) + 1;
228
        if (($numpages * $perp) == ($numresults + $perp)) {
229
            --$numpages;
230
        }
231
        //find current page
232
        $cpage = floor($st / $perp) + 1;
233
        //create the alphabet
234
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=a\">A</a>&nbsp;";
235
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=b\">B</a>&nbsp;";
236
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=c\">C</a>&nbsp;";
237
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=d\">D</a>&nbsp;";
238
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=e\">E</a>&nbsp;";
239
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=f\">F</a>&nbsp;";
240
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=g\">G</a>&nbsp;";
241
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=h\">H</a>&nbsp;";
242
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=i\">I</a>&nbsp;";
243
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=j\">J</a>&nbsp;";
244
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=k\">K</a>&nbsp;";
245
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=l\">L</a>&nbsp;";
246
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=m\">M</a>&nbsp;";
247
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=n\">N</a>&nbsp;";
248
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=o\">O</a>&nbsp;";
249
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=p\">P</a>&nbsp;";
250
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=q\">Q</a>&nbsp;";
251
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=r\">R</a>&nbsp;";
252
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=s\">S</a>&nbsp;";
253
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=t\">T</a>&nbsp;";
254
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=u\">U</a>&nbsp;";
255
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=v\">V</a>&nbsp;";
256
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=w\">W</a>&nbsp;";
257
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=x\">X</a>&nbsp;";
258
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=y\">Y</a>&nbsp;";
259
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=z\">Z</a>&nbsp;";
260
        $pages .= '-&nbsp;';
261
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=Ã…\">Ã…</a>&nbsp;";
262
        $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=Ö\">Ö</a>&nbsp;";
263
        //create linebreak
264
        $pages .= '<br />';
265
        //create previous button
266
        if ($numpages > 1) {
267
            if ($cpage > 1) {
268
                $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . '&l=' . $l . '&st=' . ($st - $perp) . "\">" . _MA_PEDIGREE_PREVIOUS . '</a>&nbsp;&nbsp';
269
            }
270
        }
271
        //create numbers
272
        for ($x = 1; $x < ($numpages + 1); ++$x) {
273
            //create line break after 20 number
274
            if (($x % 20) == 0) {
275
                $pages .= '<br />';
276
            }
277
            if ($x != $cpage) {
278
                $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . '&l=' . $l . '&st=' . ($perp * ($x - 1)) . "\">" . $x . '</a>&nbsp;&nbsp;';
279
            } else {
280
                $pages .= $x . '&nbsp;&nbsp';
281
            }
282
        }
283
        //create next button
284
        if ($numpages > 1) {
285
            if ($cpage < $numpages) {
286
                $pages .= "<a href=\"virtual.php?f=dam&selsire=" . $selsire . '&l=' . $l . '&st=' . ($st + $perp) . "\">" . _MA_PEDIGREE_NEXT . '</a>&nbsp;&nbsp';
287
            }
288
        }
289
290
        //query
291
        $queryString = 'SELECT d.*, d.Id AS d_id, d.NAAM AS d_naam FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON m.Id = d.mother LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " f ON f.Id = d.father WHERE d.roft = '1' AND d.mother != '0' AND d.father != '0' AND m.mother != '0' AND m.father != '0' AND f.mother != '0' AND f.father != '0' AND d.NAAM LIKE '" . $l . "%' ORDER BY d.NAAM LIMIT " . $st . ', ' . $perp;
292
        $result      = $GLOBALS['xoopsDB']->query($queryString);
293
294
        $animal = new PedigreeAnimal();
295
        //test to find out how many user fields there are...
296
        $fields       = $animal->getNumOfFields();
297
        $numofcolumns = 1;
298
        $columns[]    = array('columnname' => 'Name');
299
        for ($i = 0, $iMax = count($fields); $i < $iMax; ++$i) {
300
            $userField   = new Field($fields[$i], $animal->getConfig());
301
            $fieldType   = $userField->getSetting('fieldtype');
302
            $fieldObject = new $fieldType($userField, $animal);
303
            //create empty string
304
            $lookupvalues = '';
305
            if ($userField->isActive() && $userField->inList()) {
306
                if ($userField->hasLookup()) {
307
                    $lookupvalues = $userField->lookupField($fields[$i]);
308
                    //debug information
309
                    //print_r($lookupvalues);
310
                }
311
                $columns[] = array('columnname' => $fieldObject->fieldname, 'columnnumber' => $userField->getId(), 'lookupval' => $lookupvalues);
312
                ++$numofcolumns;
313
                unset($lookupvalues);
314
            }
315
        }
316
317
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
318
            //create picture information
319
            if ($row['foto'] != '') {
320
                $camera = " <img src=\"assets/images/dog-icon25.png\">";
321
            } else {
322
                $camera = '';
323
            }
324
            $name = stripslashes($row['d_naam']) . $camera;
325
            //empty array
326
            unset($columnvalue);
327
            //fill array
328
            for ($i = 1; $i < $numofcolumns; ++$i) {
329
                $x = $columns[$i]['columnnumber'];
330
                //echo $x."columnnumber";
331
                if (is_array($columns[$i]['lookupval'])) {
332
                    foreach ($columns[$i]['lookupval'] as $key => $keyvalue) {
333
                        if ($keyvalue['id'] == $row['user' . $x]) {
334
                            //echo "key:".$row['user5']."<br />";
335
                            $value = $keyvalue['value'];
336
                        }
337
                    }
338
                    //debug information
339
                    ///echo $columns[$i]['columnname']."is an array !";
340
                } //format value - cant use object because of query count
341
                elseif (0 === strpos($row['user' . $x], 'http://')) {
342
                    $value = "<a href=\"" . $row['user' . $x] . "\">" . $row['user' . $x] . '</a>';
343
                } else {
344
                    $value = $row['user' . $x];
345
                }
346
                $columnvalue[] = array('value' => $value);
347
                unset($value);
348
            }
349
            $dogs[] = array(
350
                'id'          => $row['d_id'],
351
                'name'        => $name,
352
                'gender'      => "<img src=\"assets/images/female.gif\" alt=\"" . _MA_PEDIGREE_FEMALE . "\">",
353
                'link'        => "<a href=\"virtual.php?f=check&selsire=" . $selsire . '&seldam=' . $row['d_id'] . "\">" . $name . '</a>',
354
                'colour'      => '',
355
                'number'      => '',
356
                'usercolumns' => isset($columnvalue) ? $columnvalue : 0
357
            );
358
        }
359
360
        //add data to smarty template
361
        //assign dog
362
        $xoopsTpl->assign('dogs', $dogs);
363
        $xoopsTpl->assign('columns', $columns);
364
        $xoopsTpl->assign('numofcolumns', $numofcolumns);
365
        $xoopsTpl->assign('tsarray', PedigreeUtilities::sortTable($numofcolumns));
366
        $xoopsTpl->assign('nummatch', strtr(_MA_PEDIGREE_ADD_SELDAM, array('[mother]' => $pedigree->getConfig('mother'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('mother') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
367
        $xoopsTpl->assign('pages', $pages);
368
369
        $xoopsTpl->assign('virtualtitle', _MA_PEDIGREE_VIRUTALTIT);
370
        $xoopsTpl->assign('virtualstory', strtr(_MA_PEDIGREE_VIRUTALSTO, array('[mother]' => $pedigree->getConfig('mother'), '[father]' => $pedigree->getConfig('father'), '[children]' => $pedigree->getConfig('children'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('father') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure the usage of $pedigree->getConfig('mother') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure the usage of $pedigree->getConfig('children') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
371
        $xoopsTpl->assign('nextaction', '<b>' . strtr(_MA_PEDIGREE_VIRT_DAM, array('[mother]' => $pedigree->getConfig('mother'))) . '</b>');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('mother') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
372
373
        //find father
374
        $query  = 'SELECT Id, NAAM FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE Id=' . $selsire;
375
        $result = $GLOBALS['xoopsDB']->query($query);
376
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
377
            $vsire = stripslashes($row['NAAM']);
378
        }
379
        $xoopsTpl->assign('virtualsiretitle', strtr(_MA_PEDIGREE_VIRTUALSTIT, array('[father]' => $pedigree->getConfig('father'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('father') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
380
        $xoopsTpl->assign('virtualsire', $vsire);
381
        break;
382
383
    case 'check':
384
        $pedigree = PedigreePedigree::getInstance(false);
385
/*
386
        //get module configuration
387
        $moduleHandler = xoops_getHandler('module');
388
        $module        = $moduleHandler->getByDirname('pedigree');
389
        $configHandler = xoops_getHandler('config');
390
        $moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
391
*/
392
        $selsire = XoopsRequest::getInt('selsire', 0, 'GET');
393
        $seldam  = XoopsRequest::getInt('seldam', 0, 'GET');
394
/*
395
        if (isset($_GET['selsire'])) {
396
            $selsire = $_GET['selsire'];
397
        }
398
        if (isset($_GET['seldam'])) {
399
            $seldam = $_GET['seldam'];
400
        }
401
*/
402
        $xoopsTpl->assign('virtualtitle', _MA_PEDIGREE_VIRUTALTIT);
403
        $xoopsTpl->assign('virtualstory', strtr(_MA_PEDIGREE_VIRUTALSTO, array('[mother]' => $pedigree->getConfig('mother'), '[father]' => $pedigree->getConfig('father'), '[children]' => $pedigree->getConfig('children'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('children') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure the usage of $pedigree->getConfig('father') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure the usage of $pedigree->getConfig('mother') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
404
        //find father
405
        $query  = 'SELECT Id, NAAM FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE Id=' . $selsire;
406
        $result = $GLOBALS['xoopsDB']->query($query);
407
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
408
            $vsire = stripslashes($row['NAAM']);
409
        }
410
        $xoopsTpl->assign('virtualsiretitle', strtr(_MA_PEDIGREE_VIRTUALSTIT, array('[father]' => $pedigree->getConfig('father'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('father') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
411
        $xoopsTpl->assign('virtualsire', $vsire);
412
        //find mother
413
        $query  = 'SELECT Id, NAAM FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE Id=' . $seldam;
414
        $result = $GLOBALS['xoopsDB']->query($query);
415
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
416
            $vdam = stripslashes($row['NAAM']);
417
        }
418
        $xoopsTpl->assign('virtualdamtitle', strtr(_MA_PEDIGREE_VIRTUALDTIT, array('[mother]' => $pedigree->getConfig('mother'))));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $pedigree->getConfig('mother') targeting PedigreePedigree::getConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
419
        $xoopsTpl->assign('virtualdam', $vdam);
420
421
        $xoopsTpl->assign('form', "<a href=\"coi.php?s=" . $selsire . '&d=' . $seldam . "&dogid=&detail=1\">" . _MA_PEDIGREE_VIRTUALBUT . '</a>');
422
        break;
423
}
424
//footer
425
include $GLOBALS['xoops']->path('footer.php');
426