This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits of |
||
4 | supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit |
||
6 | authors. |
||
7 | |||
8 | This program is distributed in the hope that it will be useful, but |
||
9 | WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | */ |
||
12 | |||
13 | /** |
||
14 | * Module: Pedigree |
||
15 | * |
||
16 | * @package XoopsModules\Pedigree |
||
17 | * @author XOOPS Module Development Team |
||
18 | * @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project} |
||
19 | * @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
||
20 | */ |
||
21 | |||
22 | use Xmf\Request; |
||
23 | use XoopsModules\Pedigree; |
||
24 | use XoopsModules\Pedigree\Constants; |
||
25 | |||
26 | require_once __DIR__ . '/header.php'; |
||
27 | |||
28 | /** @var XoopsModules\Pedigree\Helper $helper */ |
||
29 | $helper->loadLanguage('main'); |
||
30 | |||
31 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_virtual.tpl'; |
||
32 | include $GLOBALS['xoops']->path('/header.php'); |
||
33 | |||
34 | $GLOBALS['xoopsTpl']->assign('page_title', _MA_PEDIGREE_VIRTUAL_PAGETITLE); |
||
35 | |||
36 | $f = Request::getCmd('f', '', 'GET'); |
||
37 | |||
38 | switch ($f) { |
||
39 | case 'dam': |
||
40 | $pages = ''; |
||
41 | $st = Request::getString('st', 0, 'GET'); |
||
42 | $l = Request::getString('l', 'A', 'GET'); |
||
43 | $selsire = Request::getInt('selsire', 0, 'GET'); |
||
44 | |||
45 | $GLOBALS['xoopsTpl']->assign('sire', '1'); |
||
46 | //create list of males dog to select from |
||
47 | $perPage = $helper->getConfig('perpage', Constants::DEFAULT_PER_PAGE); |
||
48 | $perPage = (int)$perPage > 0 ? (int)$perPage : Constants::DEFAULT_PER_PAGE; // make sure $perPage is 'valid' |
||
49 | |||
50 | //Count total number of dogs |
||
51 | $numDog = 'SELECT COUNT(d.id) FROM ' |
||
52 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
53 | . ' d LEFT JOIN ' |
||
54 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
55 | . ' m ON m.id = d.mother LEFT JOIN ' |
||
56 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
57 | // . " 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.pname LIKE '" . $l . "%'"; |
||
58 | . " 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.pname LIKE '" |
||
59 | . $GLOBALS['xoopsDB']->escape($l) |
||
60 | . "%'"; |
||
61 | |||
62 | $numRes = $GLOBALS['xoopsDB']->query($numDog); |
||
63 | |||
64 | //total number of dogs the query will find |
||
65 | [$numResults] = $GLOBALS['xoopsDB']->fetchRow($numRes); |
||
66 | //total number of pages |
||
67 | $numPages = floor($numResults / $perPage) + 1; |
||
68 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||
69 | --$numPages; |
||
70 | } |
||
71 | //find current page |
||
72 | $currentPage = floor($st / $perPage) + 1; |
||
73 | |||
74 | //create the alphabet |
||
75 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=a") . "\">A</a> "; |
||
76 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=b") . "\">B</a> "; |
||
77 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=c") . "\">C</a> "; |
||
78 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=d") . "\">D</a> "; |
||
79 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=e") . "\">E</a> "; |
||
80 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=f") . "\">F</a> "; |
||
81 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=g") . "\">G</a> "; |
||
82 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=h") . "\">H</a> "; |
||
83 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=i") . "\">I</a> "; |
||
84 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=j") . "\">J</a> "; |
||
85 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=k") . "\">K</a> "; |
||
86 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=l") . "\">L</a> "; |
||
87 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=m") . "\">M</a> "; |
||
88 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=n") . "\">N</a> "; |
||
89 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=o") . "\">O</a> "; |
||
90 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=p") . "\">P</a> "; |
||
91 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=q") . "\">Q</a> "; |
||
92 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=r") . "\">R</a> "; |
||
93 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=s") . "\">S</a> "; |
||
94 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=t") . "\">T</a> "; |
||
95 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=u") . "\">U</a> "; |
||
96 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=v") . "\">V</a> "; |
||
97 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=w") . "\">W</a> "; |
||
98 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=x") . "\">X</a> "; |
||
99 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=y") . "\">Y</a> "; |
||
100 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=z") . "\">Z</a> "; |
||
101 | $pages .= "- "; |
||
102 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=Ã…") . "\">Ã…</a> "; |
||
103 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $selsire . "&st=0&l=Ö") . "\">Ö</a> "; |
||
104 | //create linebreak |
||
105 | $pages .= '<br>'; |
||
106 | //create previous button |
||
107 | if ($numPages > 1) { |
||
108 | if ($currentPage > 1) { |
||
109 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire={$selsire}&l={$l}&st=" . ($st - $perPage)) . "\">" . _MA_PEDIGREE_PREVIOUS . "</a>  "; |
||
110 | } |
||
111 | } |
||
112 | //create numbers |
||
113 | for ($x = 1; $x < ($numPages + 1); ++$x) { |
||
114 | //create line break after 20 number |
||
115 | if (0 == ($x % 20)) { |
||
116 | $pages .= '<br>'; |
||
117 | } |
||
118 | if ($x != $currentPage) { |
||
119 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire={$selsire}&l={$l}&st=" . ($perPage * ($x - 1))) . "\">{$x}</a> "; |
||
120 | } else { |
||
121 | $pages .= $x . '  '; |
||
122 | } |
||
123 | } |
||
124 | //create next button |
||
125 | if ($numPages > 1) { |
||
126 | if ($currentPage < $numPages) { |
||
127 | $pages .= "<a href=\"" . $helper->url("virtual.php?f=dam&selsire={$selsire}&l={$l}&st=" . ($st + $perPage)) . "\">" . _MA_PEDIGREE_NEXT . "</a>  "; |
||
128 | } |
||
129 | } |
||
130 | |||
131 | //query |
||
132 | $sql = 'SELECT d.*, d.id AS d_id, d.pname AS d_pname FROM ' |
||
133 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
134 | . ' d LEFT JOIN ' |
||
135 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
136 | . ' m ON m.id = d.mother LEFT JOIN ' |
||
137 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
138 | . " 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.pname LIKE '" |
||
139 | . $l |
||
140 | . "%' ORDER BY d.pname LIMIT " |
||
141 | . $st |
||
142 | . ', ' |
||
143 | . $perPage; |
||
144 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
145 | |||
146 | $animal = new Pedigree\Animal(); |
||
147 | //test to find out how many user fields there are... |
||
148 | $fields = $animal->getNumOfFields(); |
||
149 | $numOfColumns = 1; |
||
150 | $columns[] = ['columnname' => 'Name']; |
||
151 | foreach ($fields as $i => $iValue) { |
||
152 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||
153 | $fieldType = $userField->getSetting('fieldtype'); |
||
154 | $fieldObject = new $fieldType($userField, $animal); |
||
155 | //create empty string |
||
156 | $lookupValues = ''; |
||
157 | if ($userField->isActive() && $userField->inList()) { |
||
158 | if ($userField->hasLookup()) { |
||
159 | $lookupValues = $userField->lookupField($fields[$i]); |
||
160 | //debug information |
||
161 | //print_r($lookupValues); |
||
162 | } |
||
163 | $columns[] = [ |
||
164 | 'columnname' => $fieldObject->fieldname, |
||
165 | 'columnnumber' => $userField->getId(), |
||
166 | 'lookupval' => $lookupValues, |
||
167 | ]; |
||
168 | ++$numOfColumns; |
||
169 | unset($lookupValues); |
||
170 | } |
||
171 | } |
||
172 | |||
173 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
174 | //create picture information |
||
175 | if ('' != $row['foto']) { |
||
176 | $camera = ' <img src="' . PEDIGREE_UPLOAD_URL . '/images/dog-icon25.png">'; |
||
177 | } else { |
||
178 | $camera = ''; |
||
179 | } |
||
180 | $name = stripslashes($row['d_pname']) . $camera; |
||
181 | //empty array |
||
182 | unset($columnvalue); |
||
183 | //fill array |
||
184 | for ($i = 1; $i < $numOfColumns; ++$i) { |
||
185 | $x = $columns[$i]['columnnumber']; |
||
186 | //echo $x."columnnumber"; |
||
187 | if (is_array($columns[$i]['lookupval'])) { |
||
188 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||
189 | if ($keyValue['id'] == $row['user' . $x]) { |
||
190 | //echo "key:".$row['user5']."<br>"; |
||
191 | $value = $keyValue['value']; |
||
192 | } |
||
193 | } |
||
194 | //debug information |
||
195 | ///echo $columns[$i]['columnname']."is an array !"; |
||
196 | } //format value - cant use object because of query count |
||
197 | elseif (0 === strncmp($row['user' . $x], 'http://', 7)) { |
||
198 | $value = '<a href="' . $row['user' . $x] . '">' . $row['user' . $x] . '</a>'; |
||
199 | } else { |
||
200 | $value = $row['user' . $x]; |
||
201 | } |
||
202 | $columnvalue[] = ['value' => $value]; |
||
203 | unset($value); |
||
204 | } |
||
205 | $dogs[] = [ |
||
206 | 'id' => $row['d_id'], |
||
207 | 'name' => $name, |
||
208 | //@todo add alt and title tags |
||
209 | 'gender' => "<img src=\"" . PEDIGREE_IMAGE_URL . "/female.gif\">", |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
210 | 'link' => "<a href=\"" / $helper->url("virtual.php?f=check&selsire={$selsire}&seldam={$row['d_id']}") . "\">{$name}</a>", |
||
211 | 'colour' => '', |
||
212 | 'number' => '', |
||
213 | 'usercolumns' => isset($columnvalue) ? $columnvalue : 0, |
||
214 | ]; |
||
215 | } |
||
216 | |||
217 | //add data to smarty template |
||
218 | $GLOBALS['xoopsTpl']->assign([ |
||
219 | 'dogs' => $dogs, |
||
220 | 'columns' => $columns, |
||
221 | 'numofcolumns' => $numOfColumns, |
||
222 | 'tsarray' => Pedigree\Utility::sortTable($numOfColumns), |
||
223 | 'nummatch' => strtr(_MA_PEDIGREE_ADD_SELDAM, ['[mother]' => $helper->getConfig('mother')]), |
||
224 | 'pages' => $pages, |
||
225 | 'virtualtitle' => _MA_PEDIGREE_VIRUTALTIT, |
||
226 | 'virtualstory' => strtr(_MA_PEDIGREE_VIRUTALSTO, [ |
||
227 | '[mother]' => $helper->getConfig('mother'), |
||
228 | '[father]' => $helper->getConfig('father'), |
||
229 | '[children]' => $helper->getConfig('children'), |
||
230 | ]), |
||
231 | 'nextaction' => '<span style="font-weight: bold;">' . strtr(_MA_PEDIGREE_VIRT_DAM, ['[mother]' => $helper->getConfig('mother')]) . '</span>', |
||
232 | 'virtualsiretitle' => strtr(_MA_PEDIGREE_VIRTUALSTIT, ['[father]' => $helper->getConfig('father')]), |
||
233 | ]); |
||
234 | |||
235 | //Find Father |
||
236 | //@todo - this looks wrong, shouldn't this be looking at 'father' field, not 'id' |
||
237 | $sireArray = $treeHandler->get($selsire); |
||
238 | $vsire = $sireArray instanceof Pedigree\Tree ? $sireArray->getVar('pname') : ''; |
||
239 | /* |
||
240 | $query = 'SELECT id, pname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE id=' . $selsire; |
||
241 | $result = $GLOBALS['xoopsDB']->query($query); |
||
242 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
243 | $vsire = stripslashes($row['pname']); |
||
244 | } |
||
245 | */ |
||
246 | $GLOBALS['xoopsTpl']->assign('virtualsire', $vsire); |
||
247 | |||
248 | //mb ========= MOTHER LETTERS=============================== |
||
249 | $roft = 1; |
||
250 | $name = 'pname'; |
||
251 | $link = "virtual.php?r=1&st=0&l="; |
||
252 | |||
253 | $criteria = $helper->getHandler('Tree')->getActiveCriteria($roft); |
||
254 | //$criteria->setGroupby('UPPER(LEFT(' . $name . ',1))'); |
||
255 | |||
256 | $motherArray['letters'] = Pedigree\Utility::lettersChoice($helper, 'Tree', $criteria, $name, $link); |
||
257 | //$catarray['toolbar'] = pedigree_toolbar(); |
||
258 | $GLOBALS['xoopsTpl']->assign('motherArray', $motherArray); |
||
259 | break; |
||
260 | |||
261 | case 'check': |
||
262 | |||
263 | $selsire = Request::getInt('selsire', 0, 'GET'); |
||
264 | $seldam = Request::getInt('seldam', 0, 'GET'); |
||
265 | |||
266 | $treeHandler = $helper->getHandler('Tree'); |
||
267 | |||
268 | $GLOBALS['xoopsTpl']->assign([ |
||
269 | 'virtualtitle' => _MA_PEDIGREE_VIRUTALTIT, |
||
270 | 'virtualstory' => strtr(_MA_PEDIGREE_VIRUTALSTO, [ |
||
271 | '[mother]' => $helper->getConfig('mother'), |
||
272 | '[father]' => $helper->getConfig('father'), |
||
273 | '[children]' => $helper->getConfig('children'), |
||
274 | ]), |
||
275 | 'virtualsiretitle' => strtr(_MA_PEDIGREE_VIRTUALSTIT, ['[father]' => $helper->getConfig('father')]), |
||
276 | 'virtualdamtitle' => strtr(_MA_PEDIGREE_VIRTUALDTIT, ['[mother]' => $helper->getConfig('mother')]), |
||
277 | 'form' => "<a href=\"" . $helper->url("coi.php?s={$selsire}&d={$seldam}&dogid=&detail=1") . "\">" . _MA_PEDIGREE_VIRTUALBUT . "</a>", |
||
278 | ]); |
||
279 | //Find Father |
||
280 | //@todo - this looks wrong, shouldn't this be looking at 'father' field, not 'id' |
||
281 | $sireArray = $treeHandler->get($selsire); |
||
282 | $vsire = $sireArray instanceof Pedigree\Tree ? $sireArray->getVar('pname') : ''; |
||
283 | /* |
||
284 | $query = 'SELECT id, pname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE id=' . $selsire; |
||
285 | $result = $GLOBALS['xoopsDB']->query($query); |
||
286 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
287 | $vsire = stripslashes($row['pname']); |
||
288 | } |
||
289 | */ |
||
290 | $GLOBALS['xoopsTpl']->assign('virtualsire', $vsire); |
||
291 | |||
292 | //Find Mother |
||
293 | //@todo - this looks wrong, shouldn't this be looking at 'mother' field, not 'id' |
||
294 | $damArray = $treeHandler->get($seldam); |
||
295 | $vdam = $damArray instanceof Pedigree\Tree ? $damArray->getVar('pname') : ''; |
||
296 | /* |
||
297 | $query = 'SELECT id, pname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE id=' . $seldam; |
||
298 | $result = $GLOBALS['xoopsDB']->query($query); |
||
299 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
300 | $vdam = stripslashes($row['pname']); |
||
301 | } |
||
302 | */ |
||
303 | $GLOBALS['xoopsTpl']->assign('virtualdam', $vdam); |
||
304 | break; |
||
305 | |||
306 | default: |
||
307 | $st = Request::getInt('st', 0, 'GET'); |
||
308 | $l = Request::getString('l', 'a', 'GET'); |
||
309 | |||
310 | $GLOBALS['xoopsTpl']->assign('sire', '1'); |
||
311 | //create list of males dog to select from |
||
312 | $perPage = $helper->getConfig('perpage', Constants::DEFAULT_PER_PAGE); |
||
313 | $perPage = (int)$perPage > 0 ? (int)$perPage : Constants::DEFAULT_PER_PAGE; // make sure $perPage is 'valid' |
||
314 | //count total number of dogs |
||
315 | $numDog = 'SELECT COUNT(d.id) FROM ' |
||
316 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
317 | . ' d LEFT JOIN ' |
||
318 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
319 | . ' m ON m.id = d.mother LEFT JOIN ' |
||
320 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
321 | //. " 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.pname LIKE '" . $l . "%'"; |
||
322 | . " 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.pname LIKE '" |
||
323 | . $GLOBALS['xoopsDB']->escape($l) |
||
324 | . "%'"; |
||
325 | $numRes = $GLOBALS['xoopsDB']->query($numDog); |
||
326 | //total number of dogs the query will find |
||
327 | [$numResults] = $GLOBALS['xoopsDB']->fetchRow($numRes); |
||
328 | //total number of pages |
||
329 | $numPages = floor($numResults / $perPage) + 1; |
||
330 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||
331 | --$numPages; |
||
332 | } |
||
333 | //find current page |
||
334 | $currentPage = floor($st / $perPage) + 1; |
||
335 | //create alphabet |
||
336 | //@todo this needs to be refactored for non-English languages |
||
337 | $pages = ''; |
||
338 | for ($i = 65; $i <= 90; ++$i) { |
||
339 | if ($l == chr($i)) { |
||
340 | $pages .= "<span style=\"font-weight: bold;\"><a href=\"" . $helper->url("virtual.php?r=1&st=0&l=" . chr($i)) . "\">" . chr($i) . "</a></span> "; |
||
341 | } else { |
||
342 | $pages .= "<a href=\"" . $helper->url("virtual.php?r=1&st=0&l=" . chr($i)) . "\">" . chr($i) . "</a> "; |
||
343 | } |
||
344 | } |
||
345 | $pages .= '- '; |
||
346 | $pages .= "<a href=\"" . $helper->url("virtual.php?r=1&st=0&l=Ã…") . "\">Ã…</a> "; |
||
347 | $pages .= "<a href=\"" . $helper->url("virtual.php?r=1&st=0&l=Ö") . "\">Ö</a> "; |
||
348 | $pages .= "<br>\n"; |
||
349 | //create previous button |
||
350 | if (($numPages > 1) && ($currentPage > 1)) { |
||
351 | $pages .= "<a href=\"" . $helper->url("virtual.php?r=1&&l={$l}&st=" . ($st - $perPage)) . "\">" . _MA_PEDIGREE_PREVIOUS . "</a>  "; |
||
352 | } |
||
353 | //create numbers |
||
354 | $xLimit = $numPages + 1; |
||
355 | for ($x = 1; $x < $xLimit; ++$x) { |
||
356 | //create line break after 20 number |
||
357 | if (0 == ($x % 20)) { |
||
358 | $pages .= '<br>'; |
||
359 | } |
||
360 | if ($x != $currentPage) { |
||
361 | $pages .= "<a href=\"" . $helper->url("virtual.php?r=1&l={$l}&st=" . ($perPage * ($x - 1))) . "\">{$x}</a> "; |
||
362 | } else { |
||
363 | $pages .= $x . '  '; |
||
364 | } |
||
365 | } |
||
366 | //create next button |
||
367 | if ($numPages > 1) { |
||
368 | if ($currentPage < $numPages) { |
||
369 | $pages .= "<a href=\"" . $helper->url("virtual.php?r=1&l={$l}&st=" . ($st + $perPage)) . "\">" . _MA_PEDIGREE_NEXT . "</a>  "; |
||
370 | } |
||
371 | } |
||
372 | |||
373 | //query |
||
374 | $sql = 'SELECT d.*, d.id AS d_id, d.pname AS d_pname FROM ' |
||
375 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
376 | . ' d LEFT JOIN ' |
||
377 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
378 | . ' m ON m.id = d.mother LEFT JOIN ' |
||
379 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
380 | . " 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.pname LIKE '" |
||
381 | . $l |
||
382 | . "%' ORDER BY d.pname LIMIT " |
||
383 | . $st |
||
384 | . ', ' |
||
385 | . $perPage; |
||
386 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
387 | $animal = new Pedigree\Animal(); |
||
388 | //test to find out how many user fields there are... |
||
389 | $fields = $animal->getNumOfFields(); |
||
390 | $animalConfig = $animal->getConfig(); |
||
391 | $numOfColumns = 1; |
||
392 | $columns[] = ['columnname' => 'Name']; |
||
393 | foreach ($fields as $i => $iValue) { |
||
394 | $userField = new Pedigree\Field($fields[$i], $animalConfig); |
||
395 | $fieldType = $userField->getSetting('fieldtype'); |
||
396 | $fieldObject = new $fieldType($userField, $animal); |
||
397 | //create empty string |
||
398 | $lookupValues = ''; |
||
399 | if ($userField->isActive() && $userField->inList()) { |
||
400 | if ($userField->hasLookup()) { |
||
401 | $lookupValues = $userField->lookupField($fields[$i]); |
||
402 | //debug information |
||
403 | //print_r($lookupValues); |
||
404 | } |
||
405 | $columns[] = [ |
||
406 | 'columnname' => $fieldObject->fieldname, |
||
407 | 'columnnumber' => $userField->getId(), |
||
408 | 'lookupval' => $lookupValues, |
||
409 | ]; |
||
410 | ++$numOfColumns; |
||
411 | unset($lookupValues); |
||
412 | } |
||
413 | } |
||
414 | |||
415 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
416 | //create picture information |
||
417 | if ('' != $row['foto']) { |
||
418 | $camera = ' <img src="' . PEDIGREE_UPLOAD_URL . '/images/dog-icon25.png">'; |
||
419 | } else { |
||
420 | $camera = ''; |
||
421 | } |
||
422 | $name = stripslashes($row['d_pname']) . $camera; |
||
423 | //empty array |
||
424 | unset($columnvalue); |
||
425 | //fill array |
||
426 | for ($i = 1; $i < $numOfColumns; ++$i) { |
||
427 | $x = $columns[$i]['columnnumber']; |
||
428 | //echo $x."columnnumber"; |
||
429 | if (is_array($columns[$i]['lookupval'])) { |
||
430 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||
431 | if ($keyValue['id'] == $row['user' . $x]) { |
||
432 | //echo "key:".$row['user5']."<br>"; |
||
433 | $value = $keyValue['value']; |
||
434 | } |
||
435 | } |
||
436 | //debug information |
||
437 | ///echo $columns[$i]['columnname']."is an array !"; |
||
438 | } //format value - cant use object because of query count |
||
439 | elseif (0 === strncmp($row['user' . $x], 'http://', 7)) { //@todo need to make this so allows for https:// too |
||
440 | $value = '<a href="' . $row['user' . $x] . '">' . $row['user' . $x] . '</a>'; |
||
441 | } else { |
||
442 | $value = $row['user' . $x]; |
||
443 | } |
||
444 | $columnvalue[] = ['value' => $value]; |
||
445 | unset($value); |
||
446 | } |
||
447 | $dogs[] = [ |
||
448 | 'id' => $row['d_id'], |
||
449 | 'name' => $name, |
||
450 | //@todo add alt and title tags |
||
451 | 'gender' => "<img src=\"" . PEDIGREE_IMAGE_URL . "/male.gif\">", |
||
452 | 'link' => "<a href=\"" . $helper->url("virtual.php?f=dam&selsire=" . $row['d_id']) . "\">{$name}</a>", |
||
453 | 'colour' => '', |
||
454 | 'number' => '', |
||
455 | 'usercolumns' => isset($columnvalue) ? $columnvalue : 0, |
||
456 | ]; |
||
457 | } |
||
458 | |||
459 | //add data to smarty template |
||
460 | //assign dog |
||
461 | if (isset($dogs)) { |
||
462 | $GLOBALS['xoopsTpl']->assign('dogs', $dogs); |
||
463 | } |
||
464 | $GLOBALS['xoopsTpl']->assign([ |
||
465 | 'columns' => $columns, |
||
466 | 'numofcolumns' => $numOfColumns, |
||
467 | 'tsarray' => Pedigree\Utility::sortTable($numOfColumns), |
||
468 | 'nummatch' => strtr(_MA_PEDIGREE_ADD_SELSIRE, ['[father]' => $helper->getConfig('father')]), |
||
469 | 'pages' => $pages, |
||
470 | 'virtualtitle' => strtr(_MA_PEDIGREE_VIRUTALTIT, ['[mother]' => $helper->getConfig('mother')]), |
||
471 | 'virtualstory' => strtr(_MA_PEDIGREE_VIRUTALSTO, [ |
||
472 | '[mother]' => $helper->getConfig('mother'), |
||
473 | '[father]' => $helper->getConfig('father'), |
||
474 | '[children]' => $helper->getConfig('children'), |
||
475 | ]), |
||
476 | 'nextaction' => '<span style="font-weight: bold;">' . strtr(_MA_PEDIGREE_VIRT_SIRE, ['[father]' => $helper->getConfig('father')]) . '</span>', |
||
477 | ]); |
||
478 | |||
479 | //mb =========== FATHER LETTERS ============================= |
||
480 | $roft = 0; |
||
481 | $name = 'pname'; |
||
482 | $link = "virtual.php?r=1&st=0&l="; |
||
483 | $link2 = ''; |
||
484 | |||
485 | $criteria = $helper->getHandler('Tree')->getActiveCriteria($roft); |
||
486 | //$criteria = $helper->getHandler('Tree')->getActiveCriteria($roft); |
||
487 | //$criteria->setGroupby('UPPER(LEFT(' . $name . ',1))'); |
||
488 | |||
489 | $fatherArray['letters'] = Pedigree\Utility::lettersChoice($helper, 'Tree', $criteria, $name, $link, $link2); |
||
490 | //$catarray['toolbar'] = pedigree_toolbar(); |
||
491 | $GLOBALS['xoopsTpl']->assign('fatherArray', $fatherArray); |
||
492 | break; |
||
493 | } |
||
494 | |||
495 | //footer |
||
496 | include $GLOBALS['xoops']->path('footer.php'); |
||
497 |