Completed
Push — master ( c8eead...62889a )
by Michael
04:13
created

advanced.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
// -------------------------------------------------------------------------
3
4
require_once dirname(dirname(__DIR__)) . '/mainfile.php';
5
6
/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
7
if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php")) {
8
    require_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php";
9
} else {
10
    include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/english/main.php";
11
}
12
*/
13
14
xoops_loadLanguage('main', basename(dirname(__DIR__)));
15
16
//needed for generation of pie charts
17
ob_start();
18
include(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/class_eq_pie.php");
19
require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/class_field.php");
20
21
$xoopsOption['template_main'] = "pedigree_advanced.tpl";
22
23
include XOOPS_ROOT_PATH . '/header.php';
24
// Include any common code for this module.
25
require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php");
26
27
global $xoopsTpl, $xoopsDB;
28
$totpl = array();
29
$books = array();
30
//get module configuration
31
$module_handler =& xoops_gethandler('module');
32
$module         =& $module_handler->getByDirname("pedigree");
33
$config_handler =& xoops_gethandler('config');
34
$moduleConfig   =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
35
36
//colour variables
37
$colors  = explode(";", $moduleConfig['colourscheme']);
38
$actlink = $colors[0];
39
$even    = $colors[1];
40
$odd     = $colors[2];
41
$text    = $colors[3];
42
$hovlink = $colors[4];
43
$head    = $colors[5];
44
$body    = $colors[6];
45
$title   = $colors[7];
46
47
//query to count male dogs
48
$result = $xoopsDB->query("select count(id) from " . $xoopsDB->prefix("pedigree_tree") . " where roft='0'");
49
list($countmales) = $xoopsDB->fetchRow($result);
50
51
//query to count female dogs
52
$result = $xoopsDB->query("select count(id) from " . $xoopsDB->prefix("pedigree_tree") . " where roft='1'");
53
list($countfemales) = $xoopsDB->fetchRow($result);
54
55
//create pie for number of males/females
56
//construct new pie
57
$numbers_pie = new eq_pie;
58
$data[0][0]  = strtr(_MA_PEDIGREE_FLD_MALE, array('[male]' => $moduleConfig['male']));
59
$data[0][1]  = $countmales;
60
$data[0][2]  = "#C8C8FF";
61
62
$data[1][0] = strtr(_MA_PEDIGREE_FLD_FEMA, array('[female]' => $moduleConfig['female']));
63
$data[1][1] = $countfemales;
64
$data[1][2] = "#FFC8C8";
65
66
$numbers_pie->MakePie('assets/images/numbers.png', '200', '200', '10', $odd, $data, '1');
67
68
//create animal object
69
70
$animal = new Animal();
71
//test to find out how many user fields there are...
72
$fields = $animal->numoffields();
73
74
for ($i = 0; $i < count($fields); ++$i) {
75
    $userfield   = new Field($fields[$i], $animal->getconfig());
76
    $fieldType   = $userfield->getSetting("FieldType");
77
    $fieldobject = new $fieldType($userfield, $animal);
78
    if ($userfield->active() && $userfield->inadvanced()) {
79
        $queryString
80
                  = "select count(p.user" . $fields[$i] . ") as X, p.user" . $fields[$i] . " as p_user" . $fields[$i] . ", b.ID as b_id, b.value as b_value from " . $xoopsDB->prefix("pedigree_tree")
81
            . " p LEFT JOIN " . $xoopsDB->prefix("pedigree_lookup" . $fields[$i]) . " b ON p.user" . $fields[$i] . " = b.ID GROUP BY p.user" . $fields[$i] . " ORDER BY X DESC";
82
        $result   = $xoopsDB->query($queryString);
83
        $piecount = 0;
84
        unset($data);
85
        unset($books);
86
87
        while ($row = $xoopsDB->fetchArray($result)) {
88
            $data[$piecount][0] = $row['b_value'];
89
            $data[$piecount][1] = $row['X'];
90
            $data[$piecount][2] = "#" . hexdec(rand(255, 1)) . hexdec(rand(255, 1)) . hexdec(rand(255, 1));
91
            if ($row['p_user' . $fields[$i]] == "0") {
92
                $whe = "zero";
93
            } else {
94
                $whe = $row['p_user' . $fields[$i]];
95
            }
96
            $books[] = array(
97
                'book'    => "<a href=\"result.php?f=user" . $fields[$i] . "&w=" . $whe . "&o=NAAM\">" . $row['X'] . "</a>",
98
                'country' => $row['b_value']
99
            );
100
            ++$piecount;
101
        }
102
        if ($userfield->inpie()) {
103
            $pie = new eq_pie;
104
            if ($piecount % 2 == 0) {
105
                $back = $even;
106
            } else {
107
                $back = $odd;
108
            }
109
            if (isset($data)) {
110
                $pie->MakePie('images/user' . $fields[$i] . '.png', '200', '200', '10', $back, $data, '1');
111
                unset($pie);
112
            }
113
            $books[] = array('book' => "Chart", 'country' => '<img src="images/user' . $fields[$i] . '.png">');
114
        }
115
        $totpl[] = array('title' => $userfield->getSetting("FieldName"), 'content' => $books);
116
    }
117
}
118
//strtr(_MA_PEDIGREE_FLD_MALE, array( '[male]' => $moduleConfig['male'] ))
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
119
//strtr(_MA_PEDIGREE_ADV_ORPMUM, array( '[mother]' => $moduleConfig['mother'], '[animalTypes]' => $moduleConfig['animalTypes'] ))
120
if ($moduleConfig['proversion'] == '1') {
121
    $xoopsTpl->assign("pro", true);
122
}
123
$xoopsTpl->assign("title", strtr(_MA_PEDIGREE_ADV_VTMF, array('[male]' => $moduleConfig['male'], '[female]' => $moduleConfig['female'])));
124
$xoopsTpl->assign("topmales", "<a href=\"topstud.php?com=father\">" . strtr(_MA_PEDIGREE_ADV_STUD, array('[male]' => $moduleConfig['male'], '[children]' => $moduleConfig['children'])) . "</a>");
125
$xoopsTpl->assign("topfemales", "<a href=\"topstud.php?com=mother\">" . strtr(_MA_PEDIGREE_ADV_BITC, array('[female]' => $moduleConfig['female'], '[children]' => $moduleConfig['children'])) . "</a>");
126
$xoopsTpl->assign("tnmftitle", strtr(_MA_PEDIGREE_ADV_TNMFTIT, array('[male]' => $moduleConfig['male'], '[female]' => $moduleConfig['female'])));
127
$xoopsTpl->assign(
128
    "countmales",
129
    "<img src=\"assets/images/male.gif\"> " . strtr(_MA_PEDIGREE_ADV_TCMA, array('[male]' => $moduleConfig['male'], '[female]' => $moduleConfig['female']))
130
    . " : <a href=\"result.php?f=roft&w=zero&o=NAAM\">" . $countmales . "</a>"
131
);
132
$xoopsTpl->assign(
133
    "countfemales",
134
    "<img src=\"assets/images/female.gif\"> " . strtr(_MA_PEDIGREE_ADV_TCFE, array('[male]' => $moduleConfig['male'], '[female]' => $moduleConfig['female']))
135
    . " : <a href=\"result.php?f=roft&w=1&o=NAAM\">" . $countfemales
136
) . "</a>";
137
$xoopsTpl->assign("pienumber", "<img src=\"assets/images/numbers.png\">");
138
$xoopsTpl->assign("totpl", $totpl);
139
$xoopsTpl->assign("books", $books);
140
141
$xoopsTpl->assign("orptitle", _MA_PEDIGREE_ADV_ORPTIT);
142
$xoopsTpl->assign("orpall", "<a href=\"result.php?f=father=0 and mother&w=zero&o=NAAM\">" . strtr(_MA_PEDIGREE_ADV_ORPALL, array('[animalTypes]' => $moduleConfig['animalTypes'])) . "</a>");
143
$xoopsTpl->assign(
144
    "orpdad",
145
    "<a href=\"result.php?f=mother!=0 and father&w=zero&o=NAAM\">" . strtr(_MA_PEDIGREE_ADV_ORPDAD, array('[father]' => $moduleConfig['father'], '[animalTypes]' => $moduleConfig['animalTypes']))
146
    . "</a>"
147
);
148
$xoopsTpl->assign(
149
    "orpmum",
150
    "<a href=\"result.php?f=father!=0 and mother&w=zero&o=NAAM\">" . strtr(_MA_PEDIGREE_ADV_ORPMUM, array('[mother]' => $moduleConfig['mother'], '[animalTypes]' => $moduleConfig['animalTypes']))
151
    . "</a>"
152
);
153
$xoopsTpl->assign("position", _MA_PEDIGREE_M50_POS);
154
$xoopsTpl->assign("numdogs", _MA_PEDIGREE_M50_NUMD);
155
//comments and footer
156
include XOOPS_ROOT_PATH . "/footer.php";
157