mambax7 /
pedigree
| 1 | <?php |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * animal module for xoops |
||
| 14 | * |
||
| 15 | * @package XoopsModules\Pedigree |
||
| 16 | * @copyright {@link http://sourceforge.net/projects/thmod/ The TXMod XOOPS Project} |
||
| 17 | * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
||
| 18 | * @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
||
| 19 | * @author XOOPS Module Development Team |
||
| 20 | */ |
||
| 21 | use Xmf\Request; |
||
| 22 | use XoopsModules\Pedigree; |
||
| 23 | |||
| 24 | require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
| 25 | require_once __DIR__ . '/header.php'; |
||
| 26 | //xoops_cp_header(); |
||
| 27 | $helper->loadLanguage('main'); |
||
| 28 | |||
| 29 | //require_once __DIR__ . '/header.php'; |
||
| 30 | |||
| 31 | // Include any common code for this module. |
||
| 32 | require_once $helper->path('include/common.php'); |
||
| 33 | //require_once(XOOPS_ROOT_PATH ."/modules/" . $xoopsModule->dirname() . "/include/css.php"); |
||
| 34 | |||
| 35 | // This page uses smarty templates. Set "$xoopsOption['template_main']" before including header |
||
| 36 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_pedigree.tpl'; |
||
| 37 | include $GLOBALS['xoops']->path('/header.php'); |
||
| 38 | |||
| 39 | $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
| 40 | $GLOBALS['xoTheme']->addScript("browse.php?modules/{$moduleDirName}/assets/js/jquery.magnific-popup.min.js"); |
||
| 41 | $GLOBALS['xoTheme']->addStylesheet("browse.php?modules/{$moduleDirName}/assets/css/style.css"); |
||
| 42 | $GLOBALS['xoTheme']->addStylesheet("browse.php?modules/{$moduleDirName}/assets/css/magnific-popup.css"); |
||
| 43 | |||
| 44 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||
| 45 | |||
| 46 | // |
||
| 47 | // Displays the "Main" tab of the module |
||
| 48 | // |
||
| 49 | $id = Request::getInt('pedid', 1, 'GET'); |
||
| 50 | //$animal = new Pedigree\Animal($id); |
||
| 51 | //test to find out how many user fields there are. |
||
| 52 | //$fields = $animal->getNumOfFields(); |
||
| 53 | //$fieldsCount = count($fields); |
||
| 54 | |||
| 55 | $qarray = ['d', 'f', 'm', 'ff', 'mf', 'fm', 'mm', 'fff', 'ffm', 'fmf', 'fmm', 'mmf', 'mff', 'mfm', 'mmm']; |
||
| 56 | |||
| 57 | $querystring = 'SELECT '; |
||
| 58 | |||
| 59 | foreach ($qarray as $key) { |
||
| 60 | $querystring .= $key . '.id as ' . $key . '_id, '; |
||
| 61 | $querystring .= $key . '.naam as ' . $key . '_naam, '; |
||
| 62 | $querystring .= $key . '.mother as ' . $key . '_mother, '; |
||
| 63 | $querystring .= $key . '.father as ' . $key . '_father, '; |
||
| 64 | $querystring .= $key . '.roft as ' . $key . '_roft, '; |
||
| 65 | $querystring .= $key . '.foto as ' . $key . '_foto, '; |
||
| 66 | } |
||
| 67 | |||
| 68 | $querystring .= 'mmm.coi as mmm_coi FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d |
||
| 69 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' f ON d.father = f.id |
||
| 70 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON d.mother = m.id |
||
| 71 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ff ON f.father = ff.id |
||
| 72 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fff ON ff.father = fff.id |
||
| 73 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ffm ON ff.mother = ffm.id |
||
| 74 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mf ON m.father = mf.id |
||
| 75 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mff ON mf.father = mff.id |
||
| 76 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mfm ON mf.mother = mfm.id |
||
| 77 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fm ON f.mother = fm.id |
||
| 78 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmf ON fm.father = fmf.id |
||
| 79 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fmm ON fm.mother = fmm.id |
||
| 80 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mm ON m.mother = mm.id |
||
| 81 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mmf ON mm.father = mmf.id |
||
| 82 | LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " mmm ON mm.mother = mmm.id |
||
| 83 | WHERE d.id={$id}"; |
||
| 84 | |||
| 85 | $result = $GLOBALS['xoopsDB']->query($querystring); |
||
| 86 | |||
| 87 | $dogs = []; // initialize dogs array |
||
| 88 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 89 | //create array for animal (and all parents) |
||
| 90 | foreach ($qarray as $key) { |
||
| 91 | $dogs[$key] = [ |
||
| 92 | 'id' => $row[$key . '_id'], |
||
| 93 | 'name' => stripslashes($row[$key . '_naam']), |
||
| 94 | 'mother' => $row[$key . '_mother'], |
||
| 95 | 'father' => $row[$key . '_father'], |
||
| 96 | 'roft' => $row[$key . '_roft'], |
||
| 97 | 'nhsb' => '', |
||
| 98 | ]; |
||
| 99 | if ((3 != mb_strlen($key) || (0 != $helper->getConfig['lastimage'])) && ('' !== $row[$key . '_foto'])) { |
||
| 100 | //show image in last row of pedigree if image exists |
||
| 101 | $dogs[$key]['photo'] = PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $row[$key . '_foto'] . '_150.jpeg'; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 102 | $dogs[$key]['photoBig'] = PEDIGREE_UPLOAD_URL . '/images/' . $row[$key . '_foto'] . '.jpeg'; |
||
| 103 | } |
||
| 104 | |||
| 105 | $dogs[$key]['overig'] = ''; |
||
| 106 | // $pedidata to hold viewable data to be shown in pedigree |
||
| 107 | $pedidata = ''; |
||
| 108 | |||
| 109 | if (0 !== $dogs[$key]['id']) { |
||
| 110 | //if exists create animal object |
||
| 111 | $animal = new Pedigree\Animal($dogs[$key]['id']); |
||
| 112 | $fields = $animal->getNumOfFields(); |
||
| 113 | } |
||
| 114 | foreach ($fields as $i => $iValue) { |
||
| 115 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||
| 116 | if ($userField->isActive() && $userField->inPedigree()) { |
||
| 117 | $fieldType = $userField->getSetting('FieldType'); |
||
| 118 | $fieldObj = new $fieldType($userField, $animal); |
||
| 119 | $pedidata .= $fieldObj->showField() . '<br>'; |
||
| 120 | } |
||
| 121 | $dogs[$key]['hd'] = $pedidata; |
||
| 122 | } |
||
| 123 | } |
||
| 124 | } |
||
| 125 | |||
| 126 | //add data to smarty template |
||
| 127 | $GLOBALS['xoopsTpl']->assign([ |
||
| 128 | 'page_title' => stripslashes($row['d_naam']), |
||
| 129 | 'd' => $dogs, //assign dogs array |
||
| 130 | //assign config options |
||
| 131 | 'male' => '<img src="assets/images/male.gif" alt="_MA_PEDIGREE_FLD_MALE" title="_MA_PEDIGREE_FLD_MALE">', |
||
| 132 | 'female' => '<img src="assets/images/female.gif" alt="_MA_PEDIGREE_FLD_FEMA" title="_MA_PEDIGREE_FLD_FEMA">', |
||
| 133 | //assign extra display options |
||
| 134 | 'unknown' => _MA_PEDIGREE_UNKNOWN, |
||
| 135 | 'SD' => _MA_PEDIGREE_SD, |
||
| 136 | 'PA' => _MA_PEDIGREE_PA, |
||
| 137 | 'GP' => _MA_PEDIGREE_GP, |
||
| 138 | 'GGP' => _MA_PEDIGREE_GGP, |
||
| 139 | ]); |
||
| 140 | |||
| 141 | include __DIR__ . '/footer.php'; |
||
| 142 |