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