mambax7 /
pedigree
| 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 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_virtual.tpl'; |
||||||
| 18 | include $GLOBALS['xoops']->path('/header.php'); |
||||||
| 19 | |||||||
| 20 | $xoopsTpl->assign('page_title', 'Pedigree database - Virtual Mating'); |
||||||
| 21 | |||||||
| 22 | //create function variable from url |
||||||
| 23 | //if (isset($_GET['f'])) { |
||||||
| 24 | // $f = $_GET['f']; |
||||||
| 25 | //} |
||||||
| 26 | //if (!isset($f)) { |
||||||
| 27 | $f = Request::getString('f', '', 'GET'); |
||||||
| 28 | |||||||
| 29 | if (empty($f)) { |
||||||
| 30 | virt(); |
||||||
| 31 | } elseif ('dam' === $f) { |
||||||
| 32 | dam(); |
||||||
| 33 | } elseif ('check' === $f) { |
||||||
| 34 | check(); |
||||||
| 35 | } |
||||||
| 36 | |||||||
| 37 | function virt() |
||||||
| 38 | { |
||||||
| 39 | global $xoopsTpl; |
||||||
| 40 | $moduleDirName = basename(__DIR__); |
||||||
| 41 | //get module configuration |
||||||
| 42 | /** @var XoopsModuleHandler $moduleHandler */ |
||||||
| 43 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 44 | $module = $moduleHandler->getByDirname($moduleDirName); |
||||||
| 45 | $configHandler = xoops_getHandler('config'); |
||||||
| 46 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
The method
getConfigsByCat() 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
Loading history...
|
|||||||
| 47 | $helper = Pedigree\Helper::getInstance(); |
||||||
| 48 | |||||||
| 49 | // if (isset($_GET['st'])) { |
||||||
| 50 | // $st = $_GET['st']; |
||||||
| 51 | // } else { |
||||||
| 52 | // $st = 0; |
||||||
| 53 | // } |
||||||
| 54 | // if (isset($_GET['l'])) { |
||||||
| 55 | // $l = $_GET['l']; |
||||||
| 56 | // } else { |
||||||
| 57 | // $l = 'A'; |
||||||
| 58 | // } |
||||||
| 59 | $st = Request::getInt('st', 0, 'GET'); |
||||||
| 60 | $l = Request::getString('l', 'A', 'GET'); |
||||||
| 61 | |||||||
| 62 | $xoopsTpl->assign('sire', '1'); |
||||||
| 63 | //create list of males dog to select from |
||||||
| 64 | $perPage = $helper->getConfig('perpage'); |
||||||
| 65 | //count total number of dogs |
||||||
| 66 | $numDog = 'SELECT COUNT(d.id) FROM ' |
||||||
| 67 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 68 | . ' d LEFT JOIN ' |
||||||
| 69 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 70 | . ' m ON m.id = d.mother LEFT JOIN ' |
||||||
| 71 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 72 | // . " 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 . "%'"; |
||||||
| 73 | . " 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 '" |
||||||
| 74 | . $GLOBALS['xoopsDB']->escape($l) |
||||||
| 75 | . "%'"; |
||||||
| 76 | $numRes = $GLOBALS['xoopsDB']->query($numDog); |
||||||
| 77 | //total number of dogs the query will find |
||||||
| 78 | list($numResults) = $GLOBALS['xoopsDB']->fetchRow($numRes); |
||||||
| 79 | //total number of pages |
||||||
| 80 | $numPages = floor($numResults / $perPage) + 1; |
||||||
| 81 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||||||
| 82 | --$numPages; |
||||||
| 83 | } |
||||||
| 84 | //find current page |
||||||
| 85 | $currentPage = floor($st / $perPage) + 1; |
||||||
| 86 | //create alphabet |
||||||
| 87 | $pages = ''; |
||||||
| 88 | for ($i = 65; $i <= 90; ++$i) { |
||||||
| 89 | if ($l == chr($i)) { |
||||||
| 90 | $pages .= '<b><a href="virtual.php?r=1&st=0&l=' . chr($i) . '">' . chr($i) . '</a></b> '; |
||||||
| 91 | } else { |
||||||
| 92 | $pages .= '<a href="virtual.php?r=1&st=0&l=' . chr($i) . '">' . chr($i) . '</a> '; |
||||||
| 93 | } |
||||||
| 94 | } |
||||||
| 95 | $pages .= '- '; |
||||||
| 96 | $pages .= '<a href="virtual.php?r=1&st=0&l=Ã…">Ã…</a> '; |
||||||
| 97 | $pages .= '<a href="virtual.php?r=1&st=0&l=Ö">Ö</a> '; |
||||||
| 98 | $pages .= '<br>'; |
||||||
| 99 | //create previous button |
||||||
| 100 | if (($numPages > 1) && ($currentPage > 1)) { |
||||||
| 101 | $pages .= '<a href="virtual.php?r=1&&l=' . $l . 'st=' . ($st - $perPage) . '">' . _MA_PEDIGREE_PREVIOUS . '</a>  '; |
||||||
| 102 | } |
||||||
| 103 | //create numbers |
||||||
| 104 | $xLimit = $numPages + 1; |
||||||
| 105 | for ($x = 1; $x < $xLimit; ++$x) { |
||||||
| 106 | //create line break after 20 number |
||||||
| 107 | if (0 == ($x % 20)) { |
||||||
| 108 | $pages .= '<br>'; |
||||||
| 109 | } |
||||||
| 110 | if ($x != $currentPage) { |
||||||
| 111 | $pages .= '<a href="virtual.php?r=1&l=' . $l . '&st=' . ($perPage * ($x - 1)) . '">' . $x . '</a> '; |
||||||
| 112 | } else { |
||||||
| 113 | $pages .= $x . '  '; |
||||||
| 114 | } |
||||||
| 115 | } |
||||||
| 116 | //create next button |
||||||
| 117 | if ($numPages > 1) { |
||||||
| 118 | if ($currentPage < $numPages) { |
||||||
| 119 | $pages .= '<a href="virtual.php?r=1&l=' . $l . '&st=' . ($st + $perPage) . '">' . _MA_PEDIGREE_NEXT . '</a>  '; |
||||||
| 120 | } |
||||||
| 121 | } |
||||||
| 122 | |||||||
| 123 | //query |
||||||
| 124 | $queryString = 'SELECT d.*, d.id AS d_id, d.naam AS d_naam FROM ' |
||||||
| 125 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 126 | . ' d LEFT JOIN ' |
||||||
| 127 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 128 | . ' m ON m.id = d.mother LEFT JOIN ' |
||||||
| 129 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 130 | . " 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 '" |
||||||
| 131 | . $l |
||||||
| 132 | . "%' ORDER BY d.naam LIMIT " |
||||||
| 133 | . $st |
||||||
| 134 | . ', ' |
||||||
| 135 | . $perPage; |
||||||
| 136 | $result = $GLOBALS['xoopsDB']->query($queryString); |
||||||
| 137 | |||||||
| 138 | $animal = new Pedigree\Animal(); |
||||||
| 139 | //test to find out how many user fields there are... |
||||||
| 140 | $fields = $animal->getNumOfFields(); |
||||||
| 141 | $numofcolumns = 1; |
||||||
| 142 | $columns[] = ['columnname' => 'Name']; |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 143 | foreach ($fields as $i => $iValue) { |
||||||
| 144 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||||||
| 145 | $fieldType = $userField->getSetting('FieldType'); |
||||||
| 146 | $fieldObject = new $fieldType($userField, $animal); |
||||||
| 147 | //create empty string |
||||||
| 148 | $lookupValues = ''; |
||||||
| 149 | if ($userField->isActive() && $userField->inList()) { |
||||||
| 150 | if ($userField->hasLookup()) { |
||||||
| 151 | $lookupValues = $userField->lookupField($fields[$i]); |
||||||
| 152 | //debug information |
||||||
| 153 | //print_r($lookupValues); |
||||||
| 154 | } |
||||||
| 155 | $columns[] = [ |
||||||
| 156 | 'columnname' => $fieldObject->fieldname, |
||||||
| 157 | 'columnnumber' => $userField->getId(), |
||||||
| 158 | 'lookupval' => $lookupValues |
||||||
| 159 | ]; |
||||||
| 160 | ++$numofcolumns; |
||||||
| 161 | unset($lookupValues); |
||||||
| 162 | } |
||||||
| 163 | } |
||||||
| 164 | |||||||
| 165 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
| 166 | //create picture information |
||||||
| 167 | if ('' != $row['foto']) { |
||||||
| 168 | $camera = ' <img src="' . PEDIGREE_UPLOAD_URL . '/images/dog-icon25.png">'; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 169 | } else { |
||||||
| 170 | $camera = ''; |
||||||
| 171 | } |
||||||
| 172 | $name = stripslashes($row['d_naam']) . $camera; |
||||||
| 173 | //empty array |
||||||
| 174 | unset($columnvalue); |
||||||
| 175 | //fill array |
||||||
| 176 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
| 177 | $x = $columns[$i]['columnnumber']; |
||||||
| 178 | //echo $x."columnnumber"; |
||||||
| 179 | if (is_array($columns[$i]['lookupval'])) { |
||||||
| 180 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||||||
| 181 | if ($keyValue['id'] == $row['user' . $x]) { |
||||||
| 182 | //echo "key:".$row['user5']."<br>"; |
||||||
| 183 | $value = $keyValue['value']; |
||||||
| 184 | } |
||||||
| 185 | } |
||||||
| 186 | //debug information |
||||||
| 187 | ///echo $columns[$i]['columnname']."is an array !"; |
||||||
| 188 | } //format value - cant use object because of query count |
||||||
| 189 | elseif (0 === strncmp($row['user' . $x], 'http://', 7)) { |
||||||
| 190 | $value = '<a href="' . $row['user' . $x] . '">' . $row['user' . $x] . '</a>'; |
||||||
| 191 | } else { |
||||||
| 192 | $value = $row['user' . $x]; |
||||||
| 193 | } |
||||||
| 194 | $columnvalue[] = ['value' => $value]; |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 195 | unset($value); |
||||||
| 196 | } |
||||||
| 197 | $dogs[] = [ |
||||||
| 198 | 'id' => $row['d_id'], |
||||||
| 199 | 'name' => $name, |
||||||
| 200 | 'gender' => '<img src="assets/images/male.gif">', |
||||||
| 201 | 'link' => '<a href="virtual.php?f=dam&selsire=' . $row['d_id'] . '">' . $name . '</a>', |
||||||
| 202 | 'colour' => '', |
||||||
| 203 | 'number' => '', |
||||||
| 204 | 'usercolumns' => isset($columnvalue) ? $columnvalue : 0 |
||||||
| 205 | ]; |
||||||
| 206 | } |
||||||
| 207 | |||||||
| 208 | //add data to smarty template |
||||||
| 209 | //assign dog |
||||||
| 210 | if (isset($dogs)) { |
||||||
| 211 | $xoopsTpl->assign('dogs', $dogs); |
||||||
| 212 | } |
||||||
| 213 | $xoopsTpl->assign('columns', $columns); |
||||||
| 214 | $xoopsTpl->assign('numofcolumns', $numofcolumns); |
||||||
| 215 | $xoopsTpl->assign('tsarray', Pedigree\Utility::sortTable($numofcolumns)); |
||||||
| 216 | $xoopsTpl->assign('nummatch', strtr(_MA_PEDIGREE_ADD_SELSIRE, ['[father]' => $helper->getConfig('father')])); |
||||||
| 217 | $xoopsTpl->assign('pages', $pages); |
||||||
| 218 | |||||||
| 219 | $xoopsTpl->assign('virtualtitle', strtr(_MA_PEDIGREE_VIRUTALTIT, ['[mother]' => $helper->getConfig('mother')])); |
||||||
| 220 | $xoopsTpl->assign('virtualstory', strtr(_MA_PEDIGREE_VIRUTALSTO, [ |
||||||
| 221 | '[mother]' => $helper->getConfig('mother'), |
||||||
| 222 | '[father]' => $helper->getConfig('father'), |
||||||
| 223 | '[children]' => $helper->getConfig('children') |
||||||
| 224 | ])); |
||||||
| 225 | $xoopsTpl->assign('nextaction', '<b>' . strtr(_MA_PEDIGREE_VIRT_SIRE, ['[father]' => $helper->getConfig('father')]) . '</b>'); |
||||||
| 226 | // break; |
||||||
| 227 | |||||||
| 228 | //mb =========== FATHER LETTERS ============================= |
||||||
| 229 | $myObject = Pedigree\Helper::getInstance(); |
||||||
| 230 | $roft = 0; |
||||||
| 231 | // $criteria = $myObject->getHandler('Tree')->getActiveCriteria($roft); |
||||||
| 232 | $activeObject = 'Tree'; |
||||||
| 233 | $name = 'naam'; |
||||||
| 234 | $number1 = '1'; |
||||||
| 235 | $number2 = '0'; |
||||||
| 236 | // $link = "virtual.php?r={$number1}&st={$number2}&l="; |
||||||
| 237 | $link = "virtual.php?r={$number1}&st={$number2}&l="; |
||||||
| 238 | |||||||
| 239 | // http://localhost/257belgi/modules/pedigree/virtual.php?f=dam&selsire=35277 |
||||||
| 240 | |||||||
| 241 | $link2 = ''; |
||||||
| 242 | |||||||
| 243 | $criteria = $myObject->getHandler('Tree')->getActiveCriteria($roft); |
||||||
|
0 ignored issues
–
show
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
Loading history...
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
Loading history...
|
|||||||
| 244 | // $criteria->setGroupby('UPPER(LEFT(' . $name . ',1))'); |
||||||
| 245 | |||||||
| 246 | $fatherArray['letters'] = Pedigree\Utility::lettersChoice($myObject, $activeObject, $criteria, $name, $link, $link2); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 247 | //$catarray['toolbar'] = pedigree_toolbar(); |
||||||
| 248 | $xoopsTpl->assign('fatherArray', $fatherArray); |
||||||
| 249 | |||||||
| 250 | //mb ======================================== |
||||||
| 251 | } |
||||||
| 252 | |||||||
| 253 | function dam() |
||||||
| 254 | { |
||||||
| 255 | global $xoopsTpl; |
||||||
| 256 | $pages = ''; |
||||||
| 257 | |||||||
| 258 | //get module configuration |
||||||
| 259 | /** @var XoopsModuleHandler $moduleHandler */ |
||||||
| 260 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 261 | $module = $moduleHandler->getByDirname($moduleDirName); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 262 | $configHandler = xoops_getHandler('config'); |
||||||
| 263 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||||||
| 264 | |||||||
| 265 | $st = Request::getString('st', 0, 'GET'); |
||||||
| 266 | $l = Request::getString('l', 'A', 'GET'); |
||||||
| 267 | |||||||
| 268 | // if (isset($_GET['st'])) { |
||||||
| 269 | // $st = $_GET['st']; |
||||||
| 270 | // } else { |
||||||
| 271 | // $st = 0; |
||||||
| 272 | // } |
||||||
| 273 | // if (isset($_GET['l'])) { |
||||||
| 274 | // $l = $_GET['l']; |
||||||
| 275 | // } else { |
||||||
| 276 | // $l = 'A'; |
||||||
| 277 | // } |
||||||
| 278 | |||||||
| 279 | $selsire = $_GET['selsire']; |
||||||
| 280 | |||||||
| 281 | $xoopsTpl->assign('sire', '1'); |
||||||
| 282 | //create list of males dog to select from |
||||||
| 283 | $perPage = $helper->getConfig('perpage'); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 284 | //count total number of dogs |
||||||
| 285 | $numDog = 'SELECT COUNT(d.id) FROM ' |
||||||
| 286 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 287 | . ' d LEFT JOIN ' |
||||||
| 288 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 289 | . ' m ON m.id = d.mother LEFT JOIN ' |
||||||
| 290 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 291 | // . " 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 . "%'"; |
||||||
| 292 | . " 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 '" |
||||||
| 293 | . $GLOBALS['xoopsDB']->escape($l) |
||||||
| 294 | . "%'"; |
||||||
| 295 | |||||||
| 296 | $numRes = $GLOBALS['xoopsDB']->query($numDog); |
||||||
| 297 | //total number of dogs the query will find |
||||||
| 298 | list($numResults) = $GLOBALS['xoopsDB']->fetchRow($numRes); |
||||||
| 299 | //total number of pages |
||||||
| 300 | $numPages = floor($numResults / $perPage) + 1; |
||||||
| 301 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||||||
| 302 | --$numPages; |
||||||
| 303 | } |
||||||
| 304 | //find current page |
||||||
| 305 | $currentPage = floor($st / $perPage) + 1; |
||||||
| 306 | //create the alphabet |
||||||
| 307 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=a">A</a> '; |
||||||
| 308 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=b">B</a> '; |
||||||
| 309 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=c">C</a> '; |
||||||
| 310 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=d">D</a> '; |
||||||
| 311 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=e">E</a> '; |
||||||
| 312 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=f">F</a> '; |
||||||
| 313 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=g">G</a> '; |
||||||
| 314 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=h">H</a> '; |
||||||
| 315 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=i">I</a> '; |
||||||
| 316 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=j">J</a> '; |
||||||
| 317 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=k">K</a> '; |
||||||
| 318 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=l">L</a> '; |
||||||
| 319 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=m">M</a> '; |
||||||
| 320 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=n">N</a> '; |
||||||
| 321 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=o">O</a> '; |
||||||
| 322 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=p">P</a> '; |
||||||
| 323 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=q">Q</a> '; |
||||||
| 324 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=r">R</a> '; |
||||||
| 325 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=s">S</a> '; |
||||||
| 326 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=t">T</a> '; |
||||||
| 327 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=u">U</a> '; |
||||||
| 328 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=v">V</a> '; |
||||||
| 329 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=w">W</a> '; |
||||||
| 330 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=x">X</a> '; |
||||||
| 331 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=y">Y</a> '; |
||||||
| 332 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=z">Z</a> '; |
||||||
| 333 | $pages .= '- '; |
||||||
| 334 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=Ã…">Ã…</a> '; |
||||||
| 335 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&st=0&l=Ö">Ö</a> '; |
||||||
| 336 | //create linebreak |
||||||
| 337 | $pages .= '<br>'; |
||||||
| 338 | //create previous button |
||||||
| 339 | if ($numPages > 1) { |
||||||
| 340 | if ($currentPage > 1) { |
||||||
| 341 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&l=' . $l . '&st=' . ($st - $perPage) . '">' . _MA_PEDIGREE_PREVIOUS . '</a>  '; |
||||||
| 342 | } |
||||||
| 343 | } |
||||||
| 344 | //create numbers |
||||||
| 345 | for ($x = 1; $x < ($numPages + 1); ++$x) { |
||||||
| 346 | //create line break after 20 number |
||||||
| 347 | if (0 == ($x % 20)) { |
||||||
| 348 | $pages .= '<br>'; |
||||||
| 349 | } |
||||||
| 350 | if ($x != $currentPage) { |
||||||
| 351 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&l=' . $l . '&st=' . ($perPage * ($x - 1)) . '">' . $x . '</a> '; |
||||||
| 352 | } else { |
||||||
| 353 | $pages .= $x . '  '; |
||||||
| 354 | } |
||||||
| 355 | } |
||||||
| 356 | //create next button |
||||||
| 357 | if ($numPages > 1) { |
||||||
| 358 | if ($currentPage < $numPages) { |
||||||
| 359 | $pages .= '<a href="virtual.php?f=dam&selsire=' . $selsire . '&l=' . $l . '&st=' . ($st + $perPage) . '">' . _MA_PEDIGREE_NEXT . '</a>  '; |
||||||
| 360 | } |
||||||
| 361 | } |
||||||
| 362 | |||||||
| 363 | //query |
||||||
| 364 | $queryString = 'SELECT d.*, d.id AS d_id, d.naam AS d_naam FROM ' |
||||||
| 365 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 366 | . ' d LEFT JOIN ' |
||||||
| 367 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 368 | . ' m ON m.id = d.mother LEFT JOIN ' |
||||||
| 369 | . $GLOBALS['xoopsDB']->prefix('pedigree_tree') |
||||||
| 370 | . " 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 '" |
||||||
| 371 | . $l |
||||||
| 372 | . "%' ORDER BY d.naam LIMIT " |
||||||
| 373 | . $st |
||||||
| 374 | . ', ' |
||||||
| 375 | . $perPage; |
||||||
| 376 | $result = $GLOBALS['xoopsDB']->query($queryString); |
||||||
| 377 | |||||||
| 378 | $animal = new Pedigree\Animal(); |
||||||
| 379 | //test to find out how many user fields there are... |
||||||
| 380 | $fields = $animal->getNumOfFields(); |
||||||
| 381 | $numofcolumns = 1; |
||||||
| 382 | $columns[] = ['columnname' => 'Name']; |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 383 | foreach ($fields as $i => $iValue) { |
||||||
| 384 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||||||
| 385 | $fieldType = $userField->getSetting('FieldType'); |
||||||
| 386 | $fieldObject = new $fieldType($userField, $animal); |
||||||
| 387 | //create empty string |
||||||
| 388 | $lookupValues = ''; |
||||||
| 389 | if ($userField->isActive() && $userField->inList()) { |
||||||
| 390 | if ($userField->hasLookup()) { |
||||||
| 391 | $lookupValues = $userField->lookupField($fields[$i]); |
||||||
| 392 | //debug information |
||||||
| 393 | //print_r($lookupValues); |
||||||
| 394 | } |
||||||
| 395 | $columns[] = [ |
||||||
| 396 | 'columnname' => $fieldObject->fieldname, |
||||||
| 397 | 'columnnumber' => $userField->getId(), |
||||||
| 398 | 'lookupval' => $lookupValues |
||||||
| 399 | ]; |
||||||
| 400 | ++$numofcolumns; |
||||||
| 401 | unset($lookupValues); |
||||||
| 402 | } |
||||||
| 403 | } |
||||||
| 404 | |||||||
| 405 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
| 406 | //create picture information |
||||||
| 407 | if ('' != $row['foto']) { |
||||||
| 408 | $camera = ' <img src="' . PEDIGREE_UPLOAD_URL . '/images/dog-icon25.png">'; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 409 | } else { |
||||||
| 410 | $camera = ''; |
||||||
| 411 | } |
||||||
| 412 | $name = stripslashes($row['d_naam']) . $camera; |
||||||
| 413 | //empty array |
||||||
| 414 | unset($columnvalue); |
||||||
| 415 | //fill array |
||||||
| 416 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
| 417 | $x = $columns[$i]['columnnumber']; |
||||||
| 418 | //echo $x."columnnumber"; |
||||||
| 419 | if (is_array($columns[$i]['lookupval'])) { |
||||||
| 420 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||||||
| 421 | if ($keyValue['id'] == $row['user' . $x]) { |
||||||
| 422 | //echo "key:".$row['user5']."<br>"; |
||||||
| 423 | $value = $keyValue['value']; |
||||||
| 424 | } |
||||||
| 425 | } |
||||||
| 426 | //debug information |
||||||
| 427 | ///echo $columns[$i]['columnname']."is an array !"; |
||||||
| 428 | } //format value - cant use object because of query count |
||||||
| 429 | elseif (0 === strncmp($row['user' . $x], 'http://', 7)) { |
||||||
| 430 | $value = '<a href="' . $row['user' . $x] . '">' . $row['user' . $x] . '</a>'; |
||||||
| 431 | } else { |
||||||
| 432 | $value = $row['user' . $x]; |
||||||
| 433 | } |
||||||
| 434 | $columnvalue[] = ['value' => $value]; |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 435 | unset($value); |
||||||
| 436 | } |
||||||
| 437 | $dogs[] = [ |
||||||
| 438 | 'id' => $row['d_id'], |
||||||
| 439 | 'name' => $name, |
||||||
| 440 | 'gender' => '<img src="assets/images/female.gif">', |
||||||
| 441 | 'link' => '<a href="virtual.php?f=check&selsire=' . $selsire . '&seldam=' . $row['d_id'] . '">' . $name . '</a>', |
||||||
| 442 | 'colour' => '', |
||||||
| 443 | 'number' => '', |
||||||
| 444 | 'usercolumns' => isset($columnvalue) ? $columnvalue : 0 |
||||||
| 445 | ]; |
||||||
| 446 | } |
||||||
| 447 | |||||||
| 448 | //add data to smarty template |
||||||
| 449 | //assign dog |
||||||
| 450 | $xoopsTpl->assign('dogs', $dogs); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 451 | $xoopsTpl->assign('columns', $columns); |
||||||
| 452 | $xoopsTpl->assign('numofcolumns', $numofcolumns); |
||||||
| 453 | $xoopsTpl->assign('tsarray', Pedigree\Utility::sortTable($numofcolumns)); |
||||||
| 454 | $xoopsTpl->assign('nummatch', strtr(_MA_PEDIGREE_ADD_SELDAM, ['[mother]' => $helper->getConfig('mother')])); |
||||||
| 455 | $xoopsTpl->assign('pages', $pages); |
||||||
| 456 | |||||||
| 457 | $xoopsTpl->assign('virtualtitle', _MA_PEDIGREE_VIRUTALTIT); |
||||||
| 458 | $xoopsTpl->assign('virtualstory', strtr(_MA_PEDIGREE_VIRUTALSTO, [ |
||||||
| 459 | '[mother]' => $helper->getConfig('mother'), |
||||||
| 460 | '[father]' => $helper->getConfig('father'), |
||||||
| 461 | '[children]' => $helper->getConfig('children') |
||||||
| 462 | ])); |
||||||
| 463 | $xoopsTpl->assign('nextaction', '<b>' . strtr(_MA_PEDIGREE_VIRT_DAM, ['[mother]' => $helper->getConfig('mother')]) . '</b>'); |
||||||
| 464 | |||||||
| 465 | //find father |
||||||
| 466 | $query = 'SELECT id, naam FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id=' . $selsire; |
||||||
| 467 | $result = $GLOBALS['xoopsDB']->query($query); |
||||||
| 468 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
| 469 | $vsire = stripslashes($row['naam']); |
||||||
| 470 | } |
||||||
| 471 | $xoopsTpl->assign('virtualsiretitle', strtr(_MA_PEDIGREE_VIRTUALSTIT, ['[father]' => $moduleConfig['father']])); |
||||||
| 472 | $xoopsTpl->assign('virtualsire', $vsire); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 473 | |||||||
| 474 | //mb ========= MOTHER LETTERS=============================== |
||||||
| 475 | $myObject = Pedigree\Helper::getInstance(); |
||||||
| 476 | $roft = 1; |
||||||
| 477 | // $criteria = $myObject->getHandler('Tree')->getActiveCriteria($roft); |
||||||
| 478 | $activeObject = 'Tree'; |
||||||
| 479 | $name = 'naam'; |
||||||
| 480 | $number1 = '1'; |
||||||
| 481 | $number2 = '0'; |
||||||
| 482 | $link = "virtual.php?r={$number1}&st={$number2}&l="; |
||||||
| 483 | |||||||
| 484 | $criteria = $myObject->getHandler('Tree')->getActiveCriteria($roft); |
||||||
| 485 | // $criteria->setGroupby('UPPER(LEFT(' . $name . ',1))'); |
||||||
| 486 | |||||||
| 487 | $motherArray['letters'] = Pedigree\Utility::lettersChoice($myObject, $activeObject, $criteria, $name, $link); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 488 | //$catarray['toolbar'] = pedigree_toolbar(); |
||||||
| 489 | $xoopsTpl->assign('motherArray', $motherArray); |
||||||
| 490 | |||||||
| 491 | //mb ======================================== |
||||||
| 492 | } |
||||||
| 493 | |||||||
| 494 | function check() |
||||||
| 495 | { |
||||||
| 496 | global $xoopsTpl; |
||||||
| 497 | |||||||
| 498 | //get module configuration |
||||||
| 499 | /** @var XoopsModuleHandler $moduleHandler */ |
||||||
| 500 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 501 | $module = $moduleHandler->getByDirname($moduleDirName); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 502 | $configHandler = xoops_getHandler('config'); |
||||||
| 503 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 504 | |||||||
| 505 | $selsire = Request::getInt('selsire', 0, 'GET'); |
||||||
| 506 | $seldam = Request::getInt('seldam', 0, 'GET'); |
||||||
| 507 | /* |
||||||
| 508 | if (isset($_GET['selsire'])) { |
||||||
| 509 | $selsire = $_GET['selsire']; |
||||||
| 510 | } |
||||||
| 511 | if (isset($_GET['seldam'])) { |
||||||
| 512 | $seldam = $_GET['seldam']; |
||||||
| 513 | } |
||||||
| 514 | */ |
||||||
| 515 | |||||||
| 516 | $xoopsTpl->assign('virtualtitle', _MA_PEDIGREE_VIRUTALTIT); |
||||||
| 517 | $xoopsTpl->assign('virtualstory', strtr(_MA_PEDIGREE_VIRUTALSTO, [ |
||||||
| 518 | '[mother]' => $helper->getConfig('mother'), |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 519 | '[father]' => $helper->getConfig('father'), |
||||||
| 520 | '[children]' => $helper->getConfig('children') |
||||||
| 521 | ])); |
||||||
| 522 | //find father |
||||||
| 523 | $query = 'SELECT id, naam FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id=' . $selsire; |
||||||
| 524 | $result = $GLOBALS['xoopsDB']->query($query); |
||||||
| 525 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
| 526 | $vsire = stripslashes($row['naam']); |
||||||
| 527 | } |
||||||
| 528 | $xoopsTpl->assign('virtualsiretitle', strtr(_MA_PEDIGREE_VIRTUALSTIT, ['[father]' => $helper->getConfig('father')])); |
||||||
| 529 | $xoopsTpl->assign('virtualsire', $vsire); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 530 | //find mother |
||||||
| 531 | $query = 'SELECT id, naam FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id=' . $seldam; |
||||||
| 532 | $result = $GLOBALS['xoopsDB']->query($query); |
||||||
| 533 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
| 534 | $vdam = stripslashes($row['naam']); |
||||||
| 535 | } |
||||||
| 536 | $xoopsTpl->assign('virtualdamtitle', strtr(_MA_PEDIGREE_VIRTUALDTIT, ['[mother]' => $helper->getConfig('mother')])); |
||||||
| 537 | $xoopsTpl->assign('virtualdam', $vdam); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 538 | |||||||
| 539 | $xoopsTpl->assign('form', '<a href="coi.php?s=' . $selsire . '&d=' . $seldam . '&dogid=&detail=1">' . _MA_PEDIGREE_VIRTUALBUT . '</a>'); |
||||||
| 540 | } |
||||||
| 541 | |||||||
| 542 | //footer |
||||||
| 543 | include $GLOBALS['xoops']->path('footer.php'); |
||||||
| 544 |