1 | <?php |
||||||
2 | // ------------------------------------------------------------------------- |
||||||
3 | |||||||
4 | use Xmf\Request; |
||||||
5 | use XoopsModules\Pedigree; |
||||||
6 | |||||||
7 | //require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||||||
8 | require_once __DIR__ . '/header.php'; |
||||||
9 | |||||||
10 | $moduleDirName = basename(__DIR__); |
||||||
11 | xoops_loadLanguage('main', $moduleDirName); |
||||||
12 | xoops_load('Pedigree\Animal', $moduleDirName); |
||||||
13 | |||||||
14 | // Include any common code for this module. |
||||||
15 | require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
||||||
16 | |||||||
17 | /* |
||||||
18 | // Get all HTTP post or get parameters into global variables that are prefixed with "param_" |
||||||
19 | //import_request_variables("gp", "param_"); |
||||||
20 | extract($_GET, EXTR_PREFIX_ALL, "param"); |
||||||
21 | extract($_POST, EXTR_PREFIX_ALL, "param"); |
||||||
22 | */ |
||||||
23 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_sel.tpl'; |
||||||
24 | |||||||
25 | include $GLOBALS['xoops']->path('/header.php'); |
||||||
26 | |||||||
27 | //get module configuration |
||||||
28 | /** @var XoopsModuleHandler $moduleHandler */ |
||||||
29 | $moduleHandler = xoops_getHandler('module'); |
||||||
30 | $module = $moduleHandler->getByDirname($moduleDirName); |
||||||
31 | $configHandler = xoops_getHandler('config'); |
||||||
32 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
33 | |||||||
34 | $st = Request::getInt('st', 0, 'GET'); |
||||||
35 | $gend = Request::getInt('gend', 0, 'GET'); |
||||||
36 | $curval = Request::getInt('curval', 0, 'GET'); |
||||||
37 | |||||||
38 | /* @todo: default value of 'a' assumes english, this should be defined in language file */ |
||||||
39 | $letter = Request::getString('letter', 'A', 'GET'); |
||||||
40 | |||||||
41 | $perPage = $moduleConfig['perpage']; |
||||||
42 | |||||||
43 | $GLOBALS['xoopsTpl']->assign('page_title', _MI_PEDIGREE_TITLE); |
||||||
44 | |||||||
45 | //count total number of dogs |
||||||
46 | $numDog = 'SELECT id FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE naam LIKE '{$letter}%' AND roft = '{$gend}'"; |
||||||
47 | $numRes = $GLOBALS['xoopsDB']->query($numDog); |
||||||
48 | //total number of dogs the query will find |
||||||
49 | $numResults = $GLOBALS['xoopsDB']->getRowsNum($numRes); |
||||||
50 | //total number of pages |
||||||
51 | $numPages = floor($numResults / $perPage) + 1; |
||||||
52 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||||||
53 | --$numPages; |
||||||
54 | } |
||||||
55 | //find current page |
||||||
56 | $currentPage = floor($st / $perPage) + 1; |
||||||
57 | /* @todo: change this to use letters() from mylinks or similar module - this routine assumes english */ |
||||||
58 | //create alphabet |
||||||
59 | $pages = ''; |
||||||
60 | for ($i = 65; $i <= 90; ++$i) { |
||||||
61 | if ($letter == chr($i)) { |
||||||
62 | $pages .= "<b><a href='seldog.php?gend={$gend}&curval={$curval}&letter=" . chr($i) . "'>" . chr($i) . '</a></b> '; |
||||||
63 | } else { |
||||||
64 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter=" . chr($i) . "'>" . chr($i) . '</a> '; |
||||||
65 | } |
||||||
66 | } |
||||||
67 | $pages .= '- '; |
||||||
68 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter=Ã…\">Ã…</a> "; |
||||||
69 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter=Ö\">Ö</a> "; |
||||||
70 | //create linebreak |
||||||
71 | $pages .= '<br>'; |
||||||
72 | //create previous button |
||||||
73 | if (($numPages > 1) && ($currentPage > 1)) { |
||||||
74 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter={$letter}&st=" . ($st - $perPage) . "'>" . _MA_PEDIGREE_PREVIOUS . '</a>  '; |
||||||
75 | } |
||||||
76 | //create numbers |
||||||
77 | for ($x = 1; $x < ($numPages + 1); ++$x) { |
||||||
78 | //create line break after 20 number |
||||||
79 | if (0 == ($x % 20)) { |
||||||
80 | $pages .= '<br>'; |
||||||
81 | } |
||||||
82 | if ($x != $currentPage) { |
||||||
83 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter={$letter}&st=" . ($perPage * ($x - 1)) . "'>{$x}</a>  "; |
||||||
84 | } else { |
||||||
85 | $pages .= "{$x}  "; |
||||||
86 | } |
||||||
87 | } |
||||||
88 | //create next button |
||||||
89 | if (($numPages > 1) && ($currentPage < $numPages)) { |
||||||
90 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter={$letter}&st=" . ($st + $perPage) . "'>" . _MA_PEDIGREE_NEXT . '</a>  '; |
||||||
91 | } |
||||||
92 | |||||||
93 | //query |
||||||
94 | $queryString = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " WHERE naam LIKE '{$letter}%' AND roft = '{$gend}' ORDER BY naam LIMIT {$st}, {$perPage}"; |
||||||
95 | $result = $GLOBALS['xoopsDB']->query($queryString); |
||||||
96 | |||||||
97 | $animal = new Pedigree\Animal(); |
||||||
98 | //test to find out how many user fields there are... |
||||||
99 | $fields = $animal->getNumOfFields(); |
||||||
100 | $fieldsCount = count($fields); |
||||||
101 | $numofcolumns = 1; |
||||||
102 | $columns[] = ['columnname' => 'Name']; |
||||||
103 | foreach ($fields as $i => $iValue) { |
||||||
104 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||||||
105 | $fieldType = $userField->getSetting('FieldType'); |
||||||
106 | $fieldObj = new $fieldType($userField, $animal); |
||||||
107 | //create empty string |
||||||
108 | if ($userField->isActive() && $userField->inList()) { |
||||||
109 | if ($userField->hasLookup()) { |
||||||
110 | $lookupValues = $userField->lookupField($fields[$i]); |
||||||
111 | //debug information |
||||||
112 | //print_r($lookupValues); |
||||||
113 | } else { |
||||||
114 | $lookupValues = ''; |
||||||
115 | } |
||||||
116 | $columns[] = [ |
||||||
117 | 'columnname' => $fieldObj->fieldname, |
||||||
118 | 'columnnumber' => $userField->getId(), |
||||||
119 | 'lookupval' => $lookupValues |
||||||
120 | ]; |
||||||
121 | ++$numofcolumns; |
||||||
122 | unset($lookupValues); |
||||||
123 | } |
||||||
124 | } |
||||||
125 | |||||||
126 | $empty = array_fill(0, $numofcolumns, ['value' => '']); |
||||||
127 | /* |
||||||
128 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
129 | $empty[] = array('value' => ""); |
||||||
130 | } |
||||||
131 | */ |
||||||
132 | if (0 == $gend) { |
||||||
133 | $dogs [] = [ |
||||||
134 | 'id' => '0', |
||||||
135 | 'name' => '', |
||||||
136 | 'gender' => '', |
||||||
137 | 'link' => "<a href='updatepage.php?gend={$gend}&curval={$curval}&thisid=0'>" . strtr(_MA_PEDIGREE_ADD_SIREUNKNOWN, ['[father]' => $moduleConfig['father']]) . '</a>', |
||||||
138 | 'colour' => '', |
||||||
139 | 'number' => '', |
||||||
140 | 'usercolumns' => $empty |
||||||
141 | ]; |
||||||
142 | } else { |
||||||
143 | $dogs [] = [ |
||||||
144 | 'id' => '0', |
||||||
145 | 'name' => '', |
||||||
146 | 'gender' => '', |
||||||
147 | 'link' => "<a href='updatepage.php?gend={$gend}&curval={$curval}&thisid=0'>" . strtr(_MA_PEDIGREE_ADD_DAMUNKNOWN, ['[mother]' => $moduleConfig['mother']]) . '</a>', |
||||||
148 | 'colour' => '', |
||||||
149 | 'number' => '', |
||||||
150 | 'usercolumns' => $empty |
||||||
151 | ]; |
||||||
152 | } |
||||||
153 | |||||||
154 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
155 | //create picture information |
||||||
156 | $camera = ('' != $row['foto']) ? ' <img src="assets/images/camera.png">' : ''; |
||||||
157 | $name = stripslashes($row['naam']) . $camera; |
||||||
158 | //empty array |
||||||
159 | unset($columnvalue); |
||||||
160 | //fill array |
||||||
161 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
162 | $x = 'user' . $columns[$i]['columnnumber']; |
||||||
163 | if (is_array($columns[$i]['lookupval'])) { |
||||||
164 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||||||
165 | if ($key == $row[$x]) { |
||||||
166 | $value = $keyValue['value']; |
||||||
167 | } |
||||||
168 | } |
||||||
169 | //debug information |
||||||
170 | ///echo $columns[$i]['columnname']."is an array !"; |
||||||
171 | } //format value - cant use object because of query count |
||||||
172 | elseif (0 === strncmp($row[$x], 'http://', 7)) { |
||||||
173 | $value = "<a href='{$row[$x]}'>{$row[$x]}</a>"; |
||||||
174 | } else { |
||||||
175 | $value = $row[$x]; |
||||||
176 | } |
||||||
177 | $columnvalue[] = ['value' => $value]; |
||||||
178 | } |
||||||
179 | if (0 == $gend) { |
||||||
180 | $dogs[] = [ |
||||||
181 | 'id' => $row['id'], |
||||||
182 | 'name' => $name, |
||||||
183 | 'gender' => '<img src="assets/images/male.gif">', |
||||||
184 | 'link' => "<a href='updatepage.php?gend={$gend}&curval={$curval}&thisid={$row['id']}'>{$name}</a>", |
||||||
185 | 'colour' => '', |
||||||
186 | 'number' => '', |
||||||
187 | 'usercolumns' => isset($columnvalue) ?: [] |
||||||
188 | ]; |
||||||
189 | } else { |
||||||
190 | $dogs[] = [ |
||||||
191 | 'id' => $row['id'], |
||||||
192 | 'name' => $name, |
||||||
193 | 'gender' => '<img src="assets/images/female.gif">', |
||||||
194 | 'link' => "<a href='updatepage.php?gend={$gend}&curval={$curval}&thisid={$row['id']}'>{$name}</a>", |
||||||
195 | 'colour' => '', |
||||||
196 | 'number' => '', |
||||||
197 | 'usercolumns' => isset($columnvalue) ?: [] |
||||||
198 | ]; |
||||||
199 | } |
||||||
200 | } |
||||||
201 | |||||||
202 | //add data to smarty template |
||||||
203 | //assign dog |
||||||
204 | $GLOBALS['xoopsTpl']->assign([ |
||||||
205 | 'dogs' => $dogs, |
||||||
206 | 'columns' => $columns, |
||||||
207 | 'numofcolumns' => $numofcolumns, |
||||||
208 | 'tsarray' => Pedigree\Utility::sortTable($numofcolumns) |
||||||
209 | ]); |
||||||
210 | //add data to smarty template |
||||||
211 | if (0 == $gend) { |
||||||
212 | $selTtlParent = strtr(_MA_PEDIGREE_FLD_FATH, ['[father]' => $moduleConfig['father']]); |
||||||
213 | } else { |
||||||
214 | $selTtlParent = strtr(_MA_PEDIGREE_FLD_MOTH, ['[mother]' => $moduleConfig['mother']]); |
||||||
215 | } |
||||||
216 | $seltitle = _MA_PEDIGREE_SEL . $selTtlParent . _MA_PEDIGREE_FROM . Pedigree\Utility::getName($curval); |
||||||
217 | |||||||
218 | $GLOBALS['xoopsTpl']->assign('seltitle', $seltitle); |
||||||
219 | |||||||
220 | //find last shown number |
||||||
221 | $lastshown = (($st + $perPage) > $numResults) ? $numResults : $st + $perPage; |
||||||
222 | |||||||
223 | //create string |
||||||
224 | /* @todo: move hard coded language string to language files */ |
||||||
225 | $matches = strtr(_MA_PEDIGREE_MATCHES, ['[animalTypes]' => $moduleConfig['animalTypes']]); |
||||||
226 | $nummatchstr = "{$numResults}{$matches}" . ($st + 1) . " - {$lastshown} ({$numPages} pages)"; |
||||||
227 | $GLOBALS['xoopsTpl']->assign([ |
||||||
228 | 'nummatch' => $nummatchstr, |
||||||
229 | 'pages' => $pages, |
||||||
230 | 'curval' => $curval |
||||||
231 | ]); |
||||||
232 | |||||||
233 | //mb ========= MOTHER LETTERS=============================== |
||||||
234 | $myObject = Pedigree\Helper::getInstance(); |
||||||
235 | $roft = $gend; |
||||||
236 | // $criteria = $myObject->getHandler('Tree')->getActiveCriteria($roft); |
||||||
237 | $activeObject = 'Tree'; |
||||||
238 | $name = 'naam'; |
||||||
239 | $number1 = '1'; |
||||||
240 | $number2 = '0'; |
||||||
241 | $link = "seldog.php?gend={$gend}&curval={$curval}&letter="; |
||||||
242 | |||||||
243 | $criteria = $myObject->getHandler('Tree')->getActiveCriteria($roft); |
||||||
0 ignored issues
–
show
The method
getActiveCriteria() 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
![]() The method
getActiveCriteria() does not exist on XoopsPersistableObjectHandler . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
244 | $criteria->setGroupby('UPPER(LEFT(' . $name . ',1))'); |
||||||
245 | |||||||
246 | $motherArray['letters'] = Pedigree\Utility::lettersChoice($myObject, $activeObject, $criteria, $name, $link); |
||||||
247 | //$catarray['toolbar'] = pedigree_toolbar(); |
||||||
248 | $xoopsTpl->assign('motherArray', $motherArray); |
||||||
249 | |||||||
250 | //mb ======================================== |
||||||
251 | |||||||
252 | include $GLOBALS['xoops']->path('footer.php'); |
||||||
253 |