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