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
|
|
|
|
22
|
|
|
use Xmf\Request; |
23
|
|
|
use XoopsModules\Pedigree; |
24
|
|
|
|
25
|
|
|
require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
26
|
|
|
require_once __DIR__ . '/header.php'; |
27
|
|
|
//xoops_cp_header(); |
28
|
|
|
$helper->loadLanguage('main'); |
29
|
|
|
|
30
|
|
|
//require_once __DIR__ . '/header.php'; |
31
|
|
|
|
32
|
|
|
// Include any common code for this module. |
33
|
|
|
require_once $helper->path('include/common.php'); |
34
|
|
|
//require_once XOOPS_ROOT_PATH ."/modules/" . $xoopsModule->dirname() . "/include/css.php"; |
35
|
|
|
|
36
|
|
|
// This page uses smarty templates. Set "$xoopsOption['template_main']" before including header |
37
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_pedigree.tpl'; |
38
|
|
|
include $GLOBALS['xoops']->path('/header.php'); |
39
|
|
|
|
40
|
|
|
$GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js'); |
41
|
|
|
$GLOBALS['xoTheme']->addScript("browse.php?modules/{$moduleDirName}/assets/js/jquery.magnific-popup.min.js"); |
42
|
|
|
$GLOBALS['xoTheme']->addStylesheet("browse.php?modules/{$moduleDirName}/assets/css/style.css"); |
43
|
|
|
$GLOBALS['xoTheme']->addStylesheet("browse.php?modules/{$moduleDirName}/assets/css/magnific-popup.css"); |
44
|
|
|
|
45
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
46
|
|
|
|
47
|
|
|
// |
48
|
|
|
// Displays the "Main" tab of the module |
49
|
|
|
// |
50
|
|
|
$id = Request::getInt('pedid', 1, 'GET'); |
51
|
|
|
//$animal = new Pedigree\Animal($id); |
52
|
|
|
//test to find out how many user fields there are. |
53
|
|
|
//$fields = $animal->getNumOfFields(); |
54
|
|
|
//$fieldsCount = count($fields); |
55
|
|
|
|
56
|
|
|
$qarray = ['d', 'f', 'm', 'ff', 'mf', 'fm', 'mm', 'fff', 'ffm', 'fmf', 'fmm', 'mmf', 'mff', 'mfm', 'mmm']; |
57
|
|
|
|
58
|
|
|
$querystring = 'SELECT '; |
59
|
|
|
|
60
|
|
|
foreach ($qarray as $key) { |
61
|
|
|
$querystring .= $key . '.id as ' . $key . '_id, '; |
62
|
|
|
$querystring .= $key . '.pname as ' . $key . '_pname, '; |
63
|
|
|
$querystring .= $key . '.mother as ' . $key . '_mother, '; |
64
|
|
|
$querystring .= $key . '.father as ' . $key . '_father, '; |
65
|
|
|
$querystring .= $key . '.roft as ' . $key . '_roft, '; |
66
|
|
|
$querystring .= $key . '.foto as ' . $key . '_foto, '; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$querystring .= 'mmm.coi as mmm_coi FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' d |
70
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' f ON d.father = f.id |
71
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' m ON d.mother = m.id |
72
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' ff ON f.father = ff.id |
73
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' fff ON ff.father = fff.id |
74
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' ffm ON ff.mother = ffm.id |
75
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' mf ON m.father = mf.id |
76
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' mff ON mf.father = mff.id |
77
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' mfm ON mf.mother = mfm.id |
78
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' fm ON f.mother = fm.id |
79
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' fmf ON fm.father = fmf.id |
80
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' fmm ON fm.mother = fmm.id |
81
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' mm ON m.mother = mm.id |
82
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' mmf ON mm.father = mmf.id |
83
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " mmm ON mm.mother = mmm.id |
84
|
|
|
WHERE d.id={$id}"; |
85
|
|
|
|
86
|
|
|
$result = $GLOBALS['xoopsDB']->query($querystring); |
87
|
|
|
|
88
|
|
|
$dogs = []; // initialize dogs array |
89
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
90
|
|
|
//create array for animal (and all parents) |
91
|
|
|
foreach ($qarray as $key) { |
92
|
|
|
$dogs[$key] = [ |
93
|
|
|
'id' => $row[$key . '_id'], |
94
|
|
|
'name' => stripslashes($row[$key . '_pname']), |
95
|
|
|
'mother' => $row[$key . '_mother'], |
96
|
|
|
'father' => $row[$key . '_father'], |
97
|
|
|
'roft' => $row[$key . '_roft'], |
98
|
|
|
'nhsb' => '', |
99
|
|
|
]; |
100
|
|
|
if ((3 != mb_strlen($key) || (0 != $helper->getConfig('lastimage'))) && ('' !== $row[$key . '_foto'])) { |
101
|
|
|
//show image in last row of pedigree if image exists |
102
|
|
|
$dogs[$key]['photo'] = PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $row[$key . '_foto'] . '_150.jpeg'; |
103
|
|
|
$dogs[$key]['photoBig'] = PEDIGREE_UPLOAD_URL . '/images/' . $row[$key . '_foto'] . '.jpeg'; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
$dogs[$key]['overig'] = ''; |
107
|
|
|
// $pedidata to hold viewable data to be shown in pedigree |
108
|
|
|
$pedidata = ''; |
109
|
|
|
|
110
|
|
|
if (0 !== $dogs[$key]['id']) { |
111
|
|
|
//if exists create animal object |
112
|
|
|
$animal = new Pedigree\Animal($dogs[$key]['id']); |
113
|
|
|
$fields = $animal->getNumOfFields(); |
114
|
|
|
} |
115
|
|
|
foreach ($fields as $i => $iValue) { |
116
|
|
|
$userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
117
|
|
|
if ($userField->isActive() && $userField->inPedigree()) { |
118
|
|
|
$fieldType = $userField->getSetting('fieldtype'); |
119
|
|
|
$fieldObj = new $fieldType($userField, $animal); |
120
|
|
|
$pedidata .= $fieldObj->showField() . '<br>'; |
121
|
|
|
} |
122
|
|
|
$dogs[$key]['hd'] = $pedidata; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
//add data to smarty template |
128
|
|
|
$GLOBALS['xoopsTpl']->assign([ |
129
|
|
|
'page_title' => stripslashes($row['d_pname']), |
130
|
|
|
'd' => $dogs, //assign dogs array |
131
|
|
|
//assign config options |
132
|
|
|
'male' => "<img src=\"" . PEDIGREE_IMAGE_URL . "/male.gif\" alt=\"" . _MA_PEDIGREE_FLD_MALE . "\" title=\"" . _MA_PEDIGREE_FLD_MALE . "\">", |
|
|
|
|
133
|
|
|
'female' => "<img src=\"" . PEDIGREE_IMAGE_URL . "/female.gif\" alt=\"" . _MA_PEDIGREE_FLD_FEMA . "\" title=\"" . _MA_PEDIGREE_FLD_FEMA . "\">", |
134
|
|
|
//assign extra display options |
135
|
|
|
'unknown' => _MA_PEDIGREE_UNKNOWN, |
136
|
|
|
'SD' => _MA_PEDIGREE_SD, |
137
|
|
|
'PA' => _MA_PEDIGREE_PA, |
138
|
|
|
'GP' => _MA_PEDIGREE_GP, |
139
|
|
|
'GGP' => _MA_PEDIGREE_GGP, |
140
|
|
|
]); |
141
|
|
|
|
142
|
|
|
require __DIR__ . '/footer.php'; |
143
|
|
|
|