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 | * Pedigree module for XOOPS |
||
13 | * |
||
14 | * @package \XoopsModules\Pedigree |
||
15 | * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
||
16 | * @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
||
17 | * @author XOOPS Module Dev Team (https://xoops.org) |
||
18 | */ |
||
19 | use Xmf\Request; |
||
20 | use XoopsModules\Pedigree; |
||
21 | |||
22 | require_once __DIR__ . '/admin_header.php'; |
||
23 | |||
24 | xoops_cp_header(); |
||
25 | /** |
||
26 | * @var Xmf\Module\Admin $adminObject |
||
27 | * @var XoopsModules\Pedigree\Helper $helper |
||
28 | * @var XoopsModules\Pedigree\TreeHandler $treeHandler |
||
29 | */ |
||
30 | $helper = Pedigree\Helper::getInstance(); |
||
31 | $treeHandler = $helper->getHandler('Tree'); |
||
32 | |||
33 | //It recovered the value of argument op in URL$ |
||
34 | $op = Request::getCmd('op', 'list'); |
||
35 | switch ($op) { |
||
36 | case 'list': |
||
37 | default: |
||
38 | $adminObject->displayNavigation(basename(__FILE__)); |
||
39 | $adminObject->addItemButton(_AM_PEDIGREE_NEWPEDIGREE, $helper->url('admin/pedigree.php?op=new_pedigree'), 'add'); |
||
40 | $adminObject->displayButton('left'); |
||
41 | $criteria = new \CriteriaCompo(); |
||
42 | $criteria->setSort('id'); |
||
43 | $criteria->setOrder('ASC'); |
||
44 | $numrows = $treeHandler->getCount(); |
||
45 | $pedigree_arr = $treeHandler->getAll($criteria); |
||
46 | |||
47 | //Table view |
||
48 | if ($numrows > 0) { |
||
49 | echo "<table class=\"width100 outer\" cellspacing=\"1\">\n" |
||
50 | . " <tr>\n" |
||
51 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_NAAM . "</th>\n" |
||
52 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_ID_OWNER . "</th>\n" |
||
53 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_ID_BREEDER . "</th>\n" |
||
54 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_USER . "</th>\n" |
||
55 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_ROFT . "</th>\n" |
||
56 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_MOTHER . "</th>\n" |
||
57 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_FATHER . "</th>\n" |
||
58 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_FOTO . "</th>\n" |
||
59 | . ' <th class="center">' . _AM_PEDIGREE_PEDIGREE_COI . "</th>\n" |
||
60 | . ' <th class="center width10">' . _AM_PEDIGREE_FORMACTION . "</th>\n" |
||
61 | . " </tr>\n"; |
||
62 | |||
63 | $class = 'even'; |
||
64 | |||
65 | /** @var XoopsModules\Pedigree\Tree $treeObj */ |
||
66 | foreach ($pedigree_arr as $i => $treeObj) { |
||
67 | if (0 == $treeObj->getVar('pedigree_pid')) { |
||
68 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
69 | echo " <tr class=\"{$class}\">\n" |
||
70 | . ' <td class="center">' . $treeObj->getVar('naam') . "</td>\n" |
||
71 | . ' <td class="center">' . $treeObj->getVar('id_owner') . "</td>\n" |
||
72 | . ' <td class="center">' . $treeObj->getVar('id_breeder') . "</td>\n" |
||
73 | . ' <td class="center">' . $treeObj->getVar('user') . "</td>\n" |
||
74 | . ' <td class="center">' . $treeObj->getVar('roft') . "</td>\n" |
||
75 | . ' <td class="center">' . $treeObj->getVar('mother') . "</td>\n" |
||
76 | . ' <td class="center">' . $treeObj->getVar('father') . "</td>\n" |
||
77 | . ' <td class="center">' . $treeObj->getVar('foto') . "</td>\n" |
||
78 | . ' <td class="center">' . $treeObj->getVar('coi') . "</td>\n" |
||
79 | . " <td class=\"center width10\">\n" |
||
80 | . ' <a href="' . $_SERVER['SCRIPT_NAME'] . '?op=edit_pedigree&id=' . $treeObj->getVar('id') . "\"><img src=\"{$pathIcon16}/edit.png\" alt=\"" . _EDIT . '" title="' . _EDIT . "\"></a>\n" |
||
81 | . ' <a href=' . $helper->url('delete.php?id=' . $treeObj->getVar('id')) . "><img src=\"{$pathIcon16}/delete.png\" alt=\"" . _DELETE . '" title="' . _DELETE . "\"></a>\n" |
||
82 | . " </td>\n" |
||
83 | . " </tr>\n"; |
||
84 | } |
||
85 | } |
||
86 | echo "</table><br><br>\n"; |
||
87 | } //@todo should add 'else' here to display "nothing here" message |
||
88 | |||
89 | break; |
||
90 | case 'new_pedigree': |
||
91 | $adminObject->displayNavigation(basename(__FILE__)); |
||
92 | $adminObject->addItemButton(_AM_PEDIGREE_PEDIGREELIST, $helper->url('pedigree.php?op=list'), 'list'); |
||
93 | $adminObject->displayButton('left'); |
||
94 | |||
95 | /** |
||
96 | * @var XoopsModules\Pedigree\Tree $treeObj |
||
97 | * @var \XoopsThemeForm $form |
||
98 | */ |
||
99 | $treeObj = $treeHandler->create(); |
||
100 | $form = $treeObj->getForm(); |
||
101 | $form->display(); |
||
102 | break; |
||
103 | case 'save_pedigree': |
||
104 | /** @var \XoopsSecurity $GLOBALS['xoopsSecurity'] */ |
||
105 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
106 | $helper->redirect('admin/pedigree.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
107 | } |
||
108 | |||
109 | /** @var XoopsModules\Pedigree\Tree $treeObj */ |
||
110 | $id = Request::getInt('id', null, 'post'); |
||
111 | $treeObj = $treeHandler->get($id); |
||
112 | |||
113 | $varArray = [ |
||
114 | 'naam' => Request::getString('naam', '', 'post'), |
||
115 | 'id_owner' => Request::getInt('id_owner', 0, 'post'), |
||
116 | 'id_breeder' => Request::getInt('id_breeder', 0, 'post'), |
||
117 | 'user' => Request::getString('user', '', 'post'), |
||
118 | 'roft' => Request::getInt('roft', 0, 'post'), |
||
119 | 'mother' => Request::getInt('mother', 0, 'post'), |
||
120 | 'father' => Request::getInt('father', 0, 'post'), |
||
121 | 'foto' => Request::getString('foto', '', 'post'), |
||
122 | 'coi' => Request::getString('coi', '', 'post'), |
||
123 | ]; |
||
124 | |||
125 | $treeObj->setVars($varArray); |
||
126 | if ($treeHandler->insert($treeObj)) { |
||
127 | $helper->redirect('admin/pedigree.php?op=list', 2, _AM_PEDIGREE_FORMOK); |
||
128 | } |
||
129 | |||
130 | echo $treeObj->getHtmlErrors(); |
||
131 | /** @var \XoopsThemeForm $form */ |
||
132 | $form = $treeObj->getForm(); |
||
133 | $form->display(); |
||
134 | break; |
||
135 | case 'edit_pedigree': |
||
136 | $adminObject->displayNavigation(basename(__FILE__)); |
||
137 | $adminObject->addItemButton(_AM_PEDIGREE_NEWPEDIGREE, $helper->url('admin/pedigree.php?op=new_pedigree'), 'add'); |
||
138 | $adminObject->addItemButton(_AM_PEDIGREE_PEDIGREELIST, $helper->url('admin/pedigree.php?op=list'), 'list'); |
||
139 | $adminObject->displayButton('left'); |
||
140 | |||
141 | /** |
||
142 | * @var XoopsModules\Pedigree\Tree $treeObj |
||
143 | * @var XoopsThemeForm $form |
||
144 | */ |
||
145 | $id = Request::getInt('id', 0); |
||
146 | $treeObj = $treeHandler->get($id); |
||
147 | $form = $treeObj->getForm(); |
||
148 | $form->display(); |
||
149 | break; |
||
150 | case 'delete_pedigree': |
||
151 | /** @var XoopsModules\Pedigree\Tree $treeObj */ |
||
152 | $id = Request::getInt('id', 0); |
||
153 | $treeObj = $treeHandler->get($id); |
||
154 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
||
155 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
156 | $helper->redirect('admin/pedigree.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
157 | } |
||
158 | if ($treeHandler->delete($obj)) { |
||
159 | $helper->redirect('admin/pedigree.php', 3, _AM_PEDIGREE_FORMDELOK); |
||
160 | } else { |
||
161 | echo $treeObj->getHtmlErrors(); |
||
162 | } |
||
163 | } else { |
||
164 | xoops_confirm(['ok' => 1, 'id' => $id, 'op' => 'delete_pedigree'], $_SERVER['REQUEST_URI'], sprintf(_AM_PEDIGREE_FORMSUREDEL, $treeObj->getVar('pedigree'))); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
165 | } |
||
166 | break; |
||
167 | } |
||
168 | require_once __DIR__ . '/admin_footer.php'; |
||
169 |