1 | <?php |
||
2 | // ------------------------------------------------------------------------- |
||
3 | |||
4 | use XoopsModules\Pedigree; |
||
5 | |||
6 | /** @var \XoopsModules\Pedigree\Helper $helper */ |
||
7 | require_once __DIR__ . '/header.php'; |
||
8 | $helper->loadLanguage('main'); |
||
9 | |||
10 | // Get all HTTP post or get parameters into global variables that are prefixed with "param_" |
||
11 | //import_request_variables("gp", "param_"); |
||
12 | extract($_GET, EXTR_PREFIX_ALL, 'param'); |
||
13 | extract($_POST, EXTR_PREFIX_ALL, 'param'); |
||
14 | |||
15 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_breeder.tpl'; |
||
16 | include XOOPS_ROOT_PATH . '/header.php'; |
||
17 | |||
18 | // Include common modlue code |
||
19 | require_once $helper->path('include/common.php'); |
||
20 | //require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
||
21 | |||
22 | //@todo move hard coded language string to language file(s) |
||
23 | $GLOBALS['xoopsTpl']->assign('page_title', 'Pedigree database - View owner/breeder'); |
||
24 | |||
25 | // Breadcrumb |
||
26 | $breadcrumb = new Pedigree\Breadcrumb(); |
||
27 | $breadcrumb->addLink($helper->getModule()->getVar('name'), $helper->url()); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
28 | $GLOBALS['xoopsTpl']->assign('module_home', $helper->getDirname()); // this definition is not removed for backward compatibility issues |
||
29 | $GLOBALS['xoopsTpl']->assign('pedigree_breadcrumb', $breadcrumb->render()); |
||
30 | |||
31 | //get module configuration |
||
32 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
33 | $moduleHandler = xoops_getHandler('module'); |
||
34 | $module = $moduleHandler->getByDirname($moduleDirName); |
||
35 | $configHandler = xoops_getHandler('config'); |
||
36 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
37 | |||
38 | /** @internal Code below replaced in v1.32 Alpha 1 (Oct 20, 2019)- code didn't take into account |
||
39 | * that 'extract' command above adds 'param' prefix to 'incoming' variables. |
||
40 | */ |
||
41 | /* |
||
42 | if (!isset($f)) { |
||
43 | $f = 'lastname'; |
||
44 | } |
||
45 | //find letter on which to start else set to 'a' |
||
46 | if (isset($_GET['l'])) { |
||
47 | $l = $_GET['l']; |
||
48 | } else { |
||
49 | $l = 'a'; |
||
50 | } |
||
51 | $w = $l . '%'; |
||
52 | if (1 == $l) { |
||
53 | $l = 'LIKE'; |
||
54 | } |
||
55 | if (!isset($o)) { |
||
56 | $o = 'lastname'; |
||
57 | } |
||
58 | if (!isset($d)) { |
||
59 | $d = 'ASC'; |
||
60 | } |
||
61 | if (!isset($st)) { |
||
62 | $st = 0; |
||
63 | } |
||
64 | */ |
||
65 | $f = Request::getString('f', 'lastname'); |
||
0 ignored issues
–
show
The type
Request was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
66 | //find letter on which to start else set to 'a' |
||
67 | $l = Request::getString('l', 'a', 'get'); |
||
68 | $w = $l . '%'; |
||
69 | if ('1' === $l) { |
||
70 | $l = 'LIKE'; |
||
71 | } |
||
72 | $o = Request::getString('o', 'lastname'); |
||
73 | $d = Request::getString('d', 'ASC'); |
||
74 | $st = Request::getInt('st', 0); |
||
75 | /** @internal end of code replacement from v1.32 Alpha 1 */ |
||
76 | |||
77 | $perPage = $helper->getConfig('perpage'); |
||
78 | //$perPage = $moduleConfig['perpage']; |
||
79 | |||
80 | //iscurrent user a module admin ? |
||
81 | $modAdmin = $helper->isUserAdmin(); |
||
82 | /* |
||
83 | $modAdmin = false; |
||
84 | $xoopsModule = \XoopsModule::getByDirname($moduleDirName); |
||
85 | if (!empty($GLOBALS['xoopsUser'])) { |
||
86 | if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
||
87 | $modAdmin = true; |
||
88 | } |
||
89 | } |
||
90 | */ |
||
91 | //count total number of owners |
||
92 | $numowner = 'SELECT count(id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE ' . $f . " LIKE '" . $w . "'"; |
||
93 | $numRes = $GLOBALS['xoopsDB']->query($numowner); |
||
94 | //total number of owners the query will find |
||
95 | list($numResults) = $GLOBALS['xoopsDB']->fetchRow($numRes); |
||
96 | //total number of pages |
||
97 | $numPages = floor($numResults / $perPage) + 1; |
||
98 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||
99 | ++$numPages; |
||
100 | } |
||
101 | //find current page |
||
102 | $currentPage = floor($st / $perPage) + 1; |
||
103 | //create alphabet |
||
104 | $pages = ''; |
||
105 | /* |
||
106 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=a\">A</a> "; |
||
107 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=b\">B</a> "; |
||
108 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=c\">C</a> "; |
||
109 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=d\">D</a> "; |
||
110 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=e\">E</a> "; |
||
111 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=f\">F</a> "; |
||
112 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=g\">G</a> "; |
||
113 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=h\">H</a> "; |
||
114 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=i\">I</a> "; |
||
115 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=j\">J</a> "; |
||
116 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=k\">K</a> "; |
||
117 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=l\">L</a> "; |
||
118 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=m\">M</a> "; |
||
119 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=n\">N</a> "; |
||
120 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=o\">O</a> "; |
||
121 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=p\">P</a> "; |
||
122 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=q\">Q</a> "; |
||
123 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=r\">R</a> "; |
||
124 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=s\">S</a> "; |
||
125 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=t\">T</a> "; |
||
126 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=u\">U</a> "; |
||
127 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=v\">V</a> "; |
||
128 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=w\">W</a> "; |
||
129 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=x\">X</a> "; |
||
130 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=y\">Y</a> "; |
||
131 | $pages .= "<a href=\"breeder.php?f=" . $f . '&o=' . $o . '&d=' . $d . "&st=0&l=z\">Z</a> "; |
||
132 | //create linebreak |
||
133 | $pages .= '<br>'; |
||
134 | */ |
||
135 | //create previous button |
||
136 | if ($numPages > 1) { |
||
137 | if ($currentPage > 1) { |
||
138 | $pages .= "<a href=\"" . $helper->url("breeder.php?f={$f}&o={$o}&d={$d}&l={$l}&st=" . ($st - $perPage)) . "\">" . _MA_PEDIGREE_PREVIOUS . "</a> "; |
||
139 | } |
||
140 | |||
141 | // create numbers |
||
142 | for ($x = 1; $x < ($numPages + 1); ++$x) { |
||
143 | //create line break after 20 number |
||
144 | if (0 == ($x % 20)) { |
||
145 | $pages .= '<br>'; |
||
146 | } |
||
147 | if ($x != $currentPage) { |
||
148 | $pages .= "<a href=\"" . $helper->url("breeder.php?f={$f}&o={$o}&d={$d}&l={$l}&st=" . ($perPage * ($x - 1))) . "\">{$x}</a> "; |
||
149 | } else { |
||
150 | $pages .= $x . '  '; |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 | |||
155 | //create next button |
||
156 | if ($numPages > 1) { |
||
157 | if ($currentPage < $numPages) { |
||
158 | $pages .= "<a href=\"" . $helper->url("breeder.php?f={$f}&o={$o}&d={$d}&l={$l}&st=" . ($st + $perPage)) . "\">" . _MA_PEDIGREE_NEXT . "</a> "; |
||
159 | } |
||
160 | } |
||
161 | |||
162 | //query |
||
163 | $queryString = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE ' . $f . " LIKE '" . $w . "' ORDER BY " . $o . ' ' . $d . ' LIMIT ' . $st . ', ' . $perPage; |
||
164 | $result = $GLOBALS['xoopsDB']->query($queryString); |
||
165 | |||
166 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
167 | //check for access |
||
168 | $access = ''; |
||
169 | if (!empty($xoopsUser)) { |
||
170 | if (true === $modAdmin || $row['user'] == $xoopsUser->getVar('uid')) { |
||
171 | //$access = "<a href=\"dog.php?id=".$row['id']."\"><img src=\"assets/images/edit.png\" alt="._EDIT."></a>"; |
||
172 | $access .= "<a href=\"" . $helper->url("deletebreeder.php?id={$row['id']}") . "\"><img src=\"" . $pathIcon16 . "/delete.png\" title=\"" . _DELETE . "\" alt=\"" . _DELETE . "\"</a>"; |
||
173 | } else { |
||
174 | $access = ''; |
||
175 | } |
||
176 | } |
||
177 | //make names |
||
178 | $name = $access . "<a href=\"" . $helper->url("owner.php?ownid={$row['id']}") . "\">" . stripslashes($row['lastname']) . ', ' . stripslashes($row['firstname']) . "</a>"; |
||
179 | //create array for owners |
||
180 | $dogs[] = [ |
||
181 | 'id' => $row['id'], |
||
182 | 'name' => $name, |
||
183 | 'city' => $row['city'] |
||
184 | ]; |
||
185 | } |
||
186 | |||
187 | //add data to smarty template |
||
188 | //assign dog |
||
189 | if (isset($dogs)) { |
||
190 | $GLOBALS['xoopsTpl']->assign('dogs', $dogs); |
||
191 | } |
||
192 | //assign links |
||
193 | if ('ASC' === $d) { |
||
194 | $nl = "<a href=\"" . $helper->url("breeder.php?f={$f}&o=lastname&d=DESC") . "\">" . _MA_PEDIGREE_OWN_NAME . "</a>"; |
||
195 | $cl = "<a href=\"" . $helper->url("breeder.php?f={$f}&o=city&d=DESC") . "\">" . _MA_PEDIGREE_OWN_CITY . "</a>"; |
||
196 | } else { |
||
197 | $nl = "<a href=\"" . $helper->url("breeder.php?f={$f}&o=lastname&d=ASC") . "\">" . _MA_PEDIGREE_OWN_NAME . "</a>"; |
||
198 | $cl = "<a href=\"" . $helper->url("breeder.php?f={$f}&o=city&d=ASC") . "\">" . _MA_PEDIGREE_OWN_CITY . "</a>"; |
||
199 | } |
||
200 | $GLOBALS['xoopsTpl']->assign('namelink', $nl); |
||
201 | $GLOBALS['xoopsTpl']->assign('colourlink', $cl); |
||
202 | |||
203 | //find last shown number |
||
204 | $lastshown = ($st + $perPage) > $numResults ? $numResults : $st + $perPage; |
||
205 | |||
206 | //create string |
||
207 | $matches = _MA_PEDIGREE_MATCHESB; |
||
208 | $nummatchstr = $numResults . $matches . ($st + 1) . '-' . $lastshown . ' (' . $numPages . ' pages)'; |
||
209 | $GLOBALS['xoopsTpl']->assign('nummatch', $nummatchstr); |
||
210 | $GLOBALS['xoopsTpl']->assign('pages', $pages); |
||
211 | |||
212 | $criteria = $helper->getHandler('Tree')->getActiveCriteria(); |
||
213 | $activeObject = 'owner'; |
||
214 | $name = 'lastname'; |
||
215 | $link = $helper->url("breeder.php?f={$name}&o={$name}&d=ASC&st=0&l="); |
||
216 | $link2 = ''; |
||
217 | |||
218 | $breederArray['letters'] = Pedigree\Utility::lettersChoice($helper, $activeObject, $criteria, $name, $link, $link2); |
||
219 | //$catarray['toolbar'] = pedigree_toolbar(); |
||
220 | |||
221 | $GLOBALS['xoopsTpl']->assign('breederArray', $breederArray); |
||
222 | $GLOBALS['xoopsTpl']->assign('pageTitle', _MA_PEDIGREE_BREEDER_PAGETITLE); |
||
223 | |||
224 | //comments and footer |
||
225 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
226 |