|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Pedigree; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* You may not change or alter any portion of this comment or credits |
|
7
|
|
|
* of supporting developers from this source code or any supporting source code |
|
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @package XoopsModules\Pedigree |
|
17
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
18
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
19
|
|
|
* @author XOOPS Module Dev Team |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
use XoopsModules\Pedigree\{ |
|
23
|
|
|
Helper |
|
24
|
|
|
}; |
|
25
|
|
|
|
|
26
|
|
|
\defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class Pedigree\Temp |
|
30
|
|
|
*/ |
|
31
|
|
|
class Temp extends \XoopsObject |
|
32
|
|
|
{ |
|
33
|
|
|
//Constructor |
|
34
|
|
|
|
|
35
|
|
|
public function __construct() |
|
36
|
|
|
{ |
|
37
|
|
|
parent::__construct(); |
|
38
|
|
|
$this->initVar('id', \XOBJ_DTYPE_INT, null, false); |
|
39
|
|
|
$this->initVar('pname', \XOBJ_DTYPE_TXTAREA, null, true); |
|
40
|
|
|
$this->initVar('id_owner', \XOBJ_DTYPE_INT, null, false); |
|
41
|
|
|
$this->initVar('id_breeder', \XOBJ_DTYPE_INT, null, false); |
|
42
|
|
|
$this->initVar('user', \XOBJ_DTYPE_TXTBOX, null, false, 25); |
|
43
|
|
|
$this->initVar('roft', \XOBJ_DTYPE_TXTAREA, null, false); |
|
44
|
|
|
$this->initVar('mother', \XOBJ_DTYPE_INT, null, false); |
|
45
|
|
|
$this->initVar('father', \XOBJ_DTYPE_INT, null, false); |
|
46
|
|
|
$this->initVar('foto', \XOBJ_DTYPE_TXTBOX, null, false, 255); |
|
47
|
|
|
$this->initVar('coi', \XOBJ_DTYPE_TXTBOX, null, false, 10); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* |
|
52
|
|
|
* @return string name |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __toString() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->getVar('pname'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param bool $action |
|
61
|
|
|
* |
|
62
|
|
|
* @return \XoopsThemeForm |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getForm($action = false) |
|
65
|
|
|
{ |
|
66
|
|
|
if (false === $action) { |
|
67
|
|
|
$action = $_SERVER['REQUEST_URI']; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
$title = $this->isNew() ? \sprintf(\_AM_PEDIGREE_PEDIGREE_TEMP_ADD) : \sprintf(\_AM_PEDIGREE_PEDIGREE_TEMP_EDIT); |
|
71
|
|
|
|
|
72
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
73
|
|
|
|
|
74
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
75
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
76
|
|
|
$form->addElement(new \XoopsFormTextArea(\_AM_PEDIGREE_PEDIGREE_TEMP_PNAME, 'pname', $this->getVar('pname'), 10, 47), true); |
|
77
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_TEMP_ID_OWNER, 'id_owner', 10, 11, $this->getVar('id_owner')), false); |
|
78
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_TEMP_ID_BREEDER, 'id_breeder', 10, 11, $this->getVar('id_breeder')), false); |
|
79
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_TEMP_USER, 'user', 25, 25, $this->getVar('user')), false); |
|
80
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_TEMP_ROFT, 'roft', 2, 1, $this->getVar('roft')), false); |
|
81
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_TEMP_MOTHER, 'mother', 5, 5, $this->getVar('mother')), false); |
|
82
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_TEMP_FATHER, 'father', 5, 5, $this->getVar('father')), false); |
|
83
|
|
|
$form->addElement(new \XoopsFormText(\_AM_PEDIGREE_PEDIGREE_TEMP_FOTO, 'foto', 25, 255, $this->getVar('foto')), false); |
|
84
|
|
|
|
|
85
|
|
|
//$Handler = xoops_getModuleHandler("animal_", $xoopsModule->getVar("dirname")); |
|
86
|
|
|
$tempHandler = Helper::getInstance()->getHandler('Temp'); |
|
87
|
|
|
$criteria = new \Criteria(); |
|
88
|
|
|
$criteria->setSort('id'); |
|
89
|
|
|
$criteria->order = 'ASC'; |
|
90
|
|
|
$tempObjArr = $tempHandler->getAll(); |
|
|
|
|
|
|
91
|
|
|
//@todo - the keys below aren't right for XoopsObjectTree. _id should be id, then need to determine which lineage (father/mother) |
|
92
|
|
|
// and then use the appropriate key ('father', 'mother'). Can't really do a "combined" tree using XoopsObjectTree only. |
|
93
|
|
|
//$mytree = new \XoopsObjectTree($tmpObjArr, '_id', '_pid'); |
|
94
|
|
|
//$form->addElement(new \XoopsFormLabel(\_AM_PEDIGREE_PEDIGREE_TEMP_COI, $mytree->makeSelBox('_pid', '_title', '--', $this->getVar('_pid'), false))); |
|
95
|
|
|
$mytree = new \XoopsObjectTree($tmpObjArr, 'id', 'coi'); |
|
96
|
|
|
$form->addElement($mytree->makeSelectElement(\_AM_PEDIGREE_PEDIGREE_TEMP_COI, 'coi', '--', $this->getVar('coi'), false)); |
|
97
|
|
|
|
|
98
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save_pedigree_temp')); |
|
99
|
|
|
|
|
100
|
|
|
//Submit buttons |
|
101
|
|
|
$buttonTray - new \XoopsFormButtonTray('submit', _SUBMIT, 'submit', null); |
|
102
|
|
|
/* |
|
103
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
|
104
|
|
|
$submit_button = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
105
|
|
|
$buttonTray->addElement($submit_button); |
|
106
|
|
|
|
|
107
|
|
|
$cancel_button = new \XoopsFormButton('', '', _CANCEL, 'cancel'); |
|
108
|
|
|
$cancel_button->setExtra('onclick="history.go(-1)"'); |
|
109
|
|
|
$buttonTray->addElement($cancel_button); |
|
110
|
|
|
*/ |
|
111
|
|
|
$form->addElement($buttonTray); |
|
112
|
|
|
|
|
113
|
|
|
return $form; |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|