1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * animal module for xoops |
||
14 | * |
||
15 | * @copyright {@link http://sourceforge.net/projects/thmod/ The TXMod XOOPS Project} |
||
16 | * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
||
17 | * @license GPL 2.0 or later |
||
18 | * @package pedigree |
||
19 | * @author XOOPS Mod Development Team |
||
20 | */ |
||
21 | |||
22 | use Xmf\Request; |
||
23 | use XoopsModules\Pedigree; |
||
24 | |||
25 | |||
26 | $rootPath = dirname(dirname(__DIR__)); |
||
27 | //$moduleDirName = basename(__DIR__); |
||
28 | $mydirpath = dirname(__DIR__); |
||
29 | |||
30 | require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
31 | require_once __DIR__ . '/header.php'; |
||
32 | //require_once $rootPath . '/include/cp_functions.php'; |
||
33 | //require_once $rootPath . '/include/cp_header.php'; |
||
34 | //require_once $rootPath . '/class/xoopsformloader.php'; |
||
35 | |||
36 | //require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
37 | //xoops_cp_header(); |
||
38 | |||
39 | xoops_loadLanguage('main', $moduleDirName); |
||
40 | |||
41 | //require_once __DIR__ . '/header.php'; |
||
42 | |||
43 | // Include any common code for this module. |
||
44 | require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
||
45 | //require_once(XOOPS_ROOT_PATH ."/modules/" . $xoopsModule->dirname() . "/include/css.php"); |
||
46 | |||
47 | // Get all HTTP post or get parameters into global variables that are prefixed with "param_" |
||
48 | //import_request_variables("gp", "param_"); |
||
49 | //extract($_GET, EXTR_PREFIX_ALL, "param"); |
||
50 | //extract($_POST, EXTR_PREFIX_ALL, "param"); |
||
51 | |||
52 | // This page uses smarty templates. Set "$xoopsOption['template_main']" before including header |
||
53 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_pedigree.tpl'; |
||
54 | |||
55 | include $GLOBALS['xoops']->path('/header.php'); |
||
56 | |||
57 | $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
58 | $GLOBALS['xoTheme']->addScript("browse.php?modules/{$moduleDirName}/assets/js/jquery.magnific-popup.min.js"); |
||
59 | $GLOBALS['xoTheme']->addStylesheet("browse.php?modules/{$moduleDirName}/assets/css/style.css"); |
||
60 | $GLOBALS['xoTheme']->addStylesheet("browse.php?modules/{$moduleDirName}/assets/css/magnific-popup.css"); |
||
61 | |||
62 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||
63 | |||
64 | //get module configuration |
||
65 | /** @var XoopsModuleHandler $moduleHandler */ |
||
66 | $moduleHandler = xoops_getHandler('module'); |
||
67 | $module = $moduleHandler->getByDirname($moduleDirName); |
||
68 | $configHandler = xoops_getHandler('config'); |
||
69 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
70 | |||
71 | //draw pedigree |
||
72 | |||
73 | // |
||
74 | // Displays the "Main" tab of the module |
||
75 | // |
||
76 | $id = Request::getInt('pedid', 1, 'GET'); |
||
77 | $animal = new Pedigree\Animal($id); |
||
78 | //test to find out how many user fields there are. |
||
79 | $fields = $animal->getNumOfFields(); |
||
80 | $fieldsCount = count($fields); |
||
81 | |||
82 | $qarray = ['d', 'f', 'm', 'ff', 'mf', 'fm', 'mm', 'fff', 'ffm', 'fmf', 'fmm', 'mmf', 'mff', 'mfm', 'mmm']; |
||
83 | |||
84 | $querystring = 'SELECT '; |
||
85 | |||
86 | foreach ($qarray as $key) { |
||
87 | $querystring .= $key . '.id as ' . $key . '_id, '; |
||
88 | $querystring .= $key . '.naam as ' . $key . '_naam, '; |
||
89 | $querystring .= $key . '.mother as ' . $key . '_mother, '; |
||
90 | $querystring .= $key . '.father as ' . $key . '_father, '; |
||
91 | $querystring .= $key . '.roft as ' . $key . '_roft, '; |
||
92 | $querystring .= $key . '.foto as ' . $key . '_foto, '; |
||
93 | } |
||
94 | |||
95 | $querystring .= 'mmm.coi as mmm_coi FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d |
||
96 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' f ON d.father = f.id |
||
97 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON d.mother = m.id |
||
98 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ff ON f.father = ff.id |
||
99 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fff ON ff.father = fff.id |
||
100 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ffm ON ff.mother = ffm.id |
||
101 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mf ON m.father = mf.id |
||
102 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mff ON mf.father = mff.id |
||
103 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mfm ON mf.mother = mfm.id |
||
104 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fm ON f.mother = fm.id |
||
105 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmf ON fm.father = fmf.id |
||
106 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmm ON fm.mother = fmm.id |
||
107 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mm ON m.mother = mm.id |
||
108 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mmf ON mm.father = mmf.id |
||
109 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " mmm ON mm.mother = mmm.id |
||
110 | WHERE d.id={$id}"; |
||
111 | |||
112 | $result = $GLOBALS['xoopsDB']->query($querystring); |
||
113 | global $moduleConfig; |
||
114 | |||
115 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
116 | //create array for animal (and all parents) |
||
117 | foreach ($qarray as $key) { |
||
118 | $d[$key] = [ |
||
119 | 'id' => $row[$key . '_id'], |
||
120 | 'name' => stripslashes($row[$key . '_naam']), |
||
121 | 'mother' => $row[$key . '_mother'], |
||
122 | 'father' => $row[$key . '_father'], |
||
123 | 'roft' => $row[$key . '_roft'], |
||
124 | 'nhsb' => '' |
||
125 | ]; |
||
126 | if ((3 != strlen($key) || (0 != $helper->getConfig['lastimage'])) && ('' !== $row[$key . '_foto'])) { |
||
127 | //show image in last row of pedigree if image exists |
||
128 | $d[$key]['photo'] = PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $row[$key . '_foto'] . '_150.jpeg'; |
||
129 | $d[$key]['photoBig'] = PEDIGREE_UPLOAD_URL . '/images/' . $row[$key . '_foto'] . '.jpeg'; |
||
130 | } |
||
131 | |||
132 | $d[$key]['overig'] = ''; |
||
133 | // $pedidata to hold viewable data to be shown in pedigree |
||
134 | $pedidata = ''; |
||
135 | |||
136 | if ('' == !$d[$key]['id']) { |
||
137 | //if exists create animal object |
||
138 | $animal = new Pedigree\Animal($d[$key]['id']); |
||
139 | $fields = $animal->getNumOfFields(); |
||
140 | } |
||
141 | foreach ($fields as $i => $iValue) { |
||
142 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||
143 | if ($userField->isActive() && $userField->inPedigree()) { |
||
144 | $fieldType = $userField->getSetting('FieldType'); |
||
145 | $fieldObj = new $fieldType($userField, $animal); |
||
146 | $pedidata .= $fieldObj->showField() . '<br>'; |
||
147 | } |
||
148 | $d[$key]['hd'] = $pedidata; |
||
149 | } |
||
150 | } |
||
151 | } |
||
152 | |||
153 | //add data to smarty template |
||
154 | $GLOBALS['xoopsTpl']->assign([ |
||
155 | 'page_title' => stripslashes($row['d_naam']), |
||
156 | 'd' => $d, //assign dog |
||
157 | //assign config options |
||
158 | 'male' => '<img src="assets/images/male.gif" alt="_MA_PEDIGREE_FLD_MALE" title="_MA_PEDIGREE_FLD_MALE">', |
||
159 | 'female' => '<img src="assets/images/female.gif" alt="_MA_PEDIGREE_FLD_FEMA" title="_MA_PEDIGREE_FLD_FEMA">', |
||
160 | //assign extra display options |
||
161 | 'unknown' => _MA_PEDIGREE_UNKNOWN, |
||
162 | 'SD' => _MA_PEDIGREE_SD, |
||
163 | 'PA' => _MA_PEDIGREE_PA, |
||
164 | 'GP' => _MA_PEDIGREE_GP, |
||
165 | 'GGP' => _MA_PEDIGREE_GGP |
||
166 | ]); |
||
167 | |||
168 | //include XOOPS_ROOT_PATH . "/footer.php"; |
||
169 | include __DIR__ . '/footer.php'; |
||
170 |