Passed
Push — master ( 564764...ba995b )
by Michael
03:51
created

advanced.php (1 issue)

Labels
Severity
1
<?php
2
// -------------------------------------------------------------------------
3
4
use XoopsModules\Pedigree;
5
6
/** @var \XoopsModules\Pedigree\Helper $helper */
7
//require_once  dirname(dirname(__DIR__)) . '/mainfile.php';
8
require_once __DIR__ . '/header.php';
9
$moduleDirName = basename(__DIR__);
10
xoops_loadLanguage('main', $moduleDirName);
11
12
//needed for generation of pie charts
13
ob_start();
14
15
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_advanced.tpl';
16
17
include XOOPS_ROOT_PATH . '/header.php';
18
// Include any common code for this module.
19
require_once $helper->path('include/common.php');
20
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
21
$xoTheme->addScript($helper->url('assets/js/jquery.canvasjs.min.js'));
22
23
global $xoopsTpl, $xoopsDB;
24
$totpl = [];
25
$books = [];
26
//get module configuration
27
/** @var XoopsModuleHandler $moduleHandler */
28
$moduleHandler = xoops_getHandler('module');
29
$module = $moduleHandler->getByDirname($moduleDirName);
30
$configHandler = xoops_getHandler('config');
31
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
0 ignored issues
show
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

31
$moduleConfig = $configHandler->/** @scrutinizer ignore-call */ getConfigsByCat(0, $module->getVar('mid'));
Loading history...
32
33
//get colour variables
34
list($actlink, $even, $odd, $text, $hovlink, $head, $body, $title) = Pedigree\Utility::getColourScheme();
35
/*
36
$actlink = $colors[0];
37
$even    = $colors[1];
38
$odd     = $colors[2];
39
$text    = $colors[3];
40
$hovlink = $colors[4];
41
$head    = $colors[5];
42
$body    = $colors[6];
43
$title   = $colors[7];
44
*/
45
//@todo convert to use Object CRUD using \Criteria instead of SQL call
46
//query to count male dogs
47
$result = $GLOBALS['xoopsDB']->query('SELECT count(id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE roft='0'");
48
list($countmales) = $GLOBALS['xoopsDB']->fetchRow($result);
49
50
//query to count female dogs
51
$result = $GLOBALS['xoopsDB']->query('SELECT count(id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE roft='1'");
52
list($countfemales) = $GLOBALS['xoopsDB']->fetchRow($result);
53
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
$totaldogs = $countmales + $countfemales;
63
$perc_mdogs = (($totaldogs > 0) && ($countmales > 0)) ? round(100 / $totaldogs * $countmales, 1) : 0;
64
// to eliminate rounding errors
65
$perc_fdogs = $totaldogs - $perc_mdogs;
66
//$perc_fdogs = round(100 / $totaldogs * $countfemales, 1);
67
/*
68
$data[1][0] = strtr(_MA_PEDIGREE_FLD_FEMA, array('[female]' => $moduleConfig['female']));
69
$data[1][1] = $countfemales;
70
$data[1][2] = '#FFC8C8';
71
72
$numbers_pie->MakePie('assets/images/numbers.png', '200', '200', '10', $odd, $data, '1');
73
74
//create animal object
75
76
$animal = new Pedigree\Animal();
77
//test to find out how many user fields there are...
78
$fields = $animal->getNumOfFields();
79
80
for ($i = 0, $iMax = count($fields); $i < $iMax; ++$i) {
81
    $userField   = new Pedigree\Field($fields[$i], $animal->getConfig());
82
    $fieldType   = $userField->getSetting('FieldType');
83
    $fieldObject = new $fieldType($userField, $animal);
84
    if ($userField->isActive() && $userField->inAdvanced()) {
85
        $queryString =
86
            '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 ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' p LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $fields[$i]) . ' b ON p.user'
87
            . $fields[$i] . ' = b.ID GROUP BY p.user' . $fields[$i] . ' ORDER BY X DESC';
88
        $result      = $GLOBALS['xoopsDB']->query($queryString);
89
        $piecount    = 0;
90
        unset($data, $books);
91
92
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
93
            $data[$piecount][0] = $row['b_value'];
94
            $data[$piecount][1] = $row['X'];
95
            $data[$piecount][2] = '#' . hexdec(mt_rand(255, 1)) . hexdec(mt_rand(255, 1)) . hexdec(mt_rand(255, 1));
96
            if ($row['p_user' . $fields[$i]] == '0') {
97
                $whe = 'zero';
98
            } else {
99
                $whe = $row['p_user' . $fields[$i]];
100
            }
101
            $books[] = array(
102
                'book'    => "<a href=\"result.php?f=user" . $fields[$i] . '&w=' . $whe . "&o=naam\">" . $row['X'] . '</a>',
103
                'country' => $row['b_value']
104
            );
105
            ++$piecount;
106
        }
107
        if ($userField->inPie()) {
108
            $pie = new eq_pie;
109
            if ($piecount % 2 == 0) {
110
                $back = $even;
111
            } else {
112
                $back = $odd;
113
            }
114
            $pie->MakePie('assets/images/user' . $fields[$i] . '.png', '200', '200', '10', $back, $data, '1');
115
            unset($pie);
116
            $books[] = array('book' => 'Chart', 'country' => '<img src="assets/images/user' . $fields[$i] . '.png">');
117
        }
118
        $totpl[] = array('title' => $userField->getSetting('FieldName'), 'content' => $books);
119
    }
120
}
121
*/
122
//strtr(_MA_PEDIGREE_FLD_MALE, array( '[male]' => $moduleConfig['male'] ))
123
//strtr(_MA_PEDIGREE_ADV_ORPMUM, array( '[mother]' => $moduleConfig['mother'], '[animalTypes]' => $moduleConfig['animalTypes'] ))
124
if ('1' == $moduleConfig['proversion']) {
125
    $xoopsTpl->assign('pro', true);
126
}
127
$xoopsTpl->assign('title', strtr(_MA_PEDIGREE_ADV_VTMF, ['[male]' => $moduleConfig['male'], '[female]' => $moduleConfig['female']]));
128
$xoopsTpl->assign('topmales', '<a href="topstud.php?com=father">' . strtr(_MA_PEDIGREE_ADV_STUD, [
129
                                '[male]' => $moduleConfig['male'],
130
                                '[children]' => $moduleConfig['children'],
131
                            ]) . '</a>');
132
$xoopsTpl->assign('topfemales', '<a href="topstud.php?com=mother">' . strtr(_MA_PEDIGREE_ADV_BITC, [
133
                                  '[female]' => $moduleConfig['female'],
134
                                  '[children]' => $moduleConfig['children'],
135
                              ]) . '</a>');
136
$xoopsTpl->assign('tnmftitle', strtr(_MA_PEDIGREE_ADV_TNMFTIT, ['[male]' => $moduleConfig['male'], '[female]' => $moduleConfig['female']]));
137
$xoopsTpl->assign('countmales', '<img src="assets/images/male.gif"> ' . strtr(_MA_PEDIGREE_ADV_TCMA, [
138
                                  '[male]' => $moduleConfig['male'],
139
                                  '[female]' => $moduleConfig['female'],
140
                              ]) . ' : <a href="result.php?f=roft&w=zero&o=naam">' . $countmales . '</a>');
141
$xoopsTpl->assign('countfemales', '<img src="assets/images/female.gif"> ' . strtr(_MA_PEDIGREE_ADV_TCFE, [
142
                                    '[male]' => $moduleConfig['male'],
143
                                    '[female]' => $moduleConfig['female'],
144
                                ]) . ' : <a href="result.php?f=roft&w=1&o=naam">' . $countfemales) . '</a>';
145
$xoopsTpl->assign('pienumber', '<img src="assets/images/numbers.png">');
146
$xoopsTpl->assign('totpl', $totpl);
147
$xoopsTpl->assign('books', $books);
148
149
$xoopsTpl->assign('orptitle', _MA_PEDIGREE_ADV_ORPTIT);
150
$xoopsTpl->assign('orpall', '<a href="result.php?f=father=0 and mother&w=zero&o=naam">' . strtr(_MA_PEDIGREE_ADV_ORPALL, ['[animalTypes]' => $moduleConfig['animalTypes']]) . '</a>');
151
$xoopsTpl->assign('orpdad', '<a href="result.php?f=mother!=0 and father&w=zero&o=naam">' . strtr(_MA_PEDIGREE_ADV_ORPDAD, [
152
                              '[father]' => $moduleConfig['father'],
153
                              '[animalTypes]' => $moduleConfig['animalTypes'],
154
                          ]) . '</a>');
155
$xoopsTpl->assign('orpmum', '<a href="result.php?f=father!=0 and mother&w=zero&o=naam">' . strtr(_MA_PEDIGREE_ADV_ORPMUM, [
156
                              '[mother]' => $moduleConfig['mother'],
157
                              '[animalTypes]' => $moduleConfig['animalTypes'],
158
                          ]) . '</a>');
159
$xoopsTpl->assign('position', _MA_PEDIGREE_M50_POS);
160
$xoopsTpl->assign('numdogs', _MA_PEDIGREE_M50_NUMD);
161
$xoopsTpl->assign('maledogs', $perc_mdogs);
162
$xoopsTpl->assign('femaledogs', $perc_fdogs);
163
//comments and footer
164
include XOOPS_ROOT_PATH . '/footer.php';
165