|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Pedigree\Form; |
|
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
|
|
|
* Module: Pedigree |
|
17
|
|
|
* |
|
18
|
|
|
* @category Module |
|
19
|
|
|
* @package pedigree |
|
20
|
|
|
* @author XOOPS Development Team <https://xoops.org> |
|
21
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
22
|
|
|
* @license GPL 2.0 or later |
|
23
|
|
|
* @link https://xoops.org/ |
|
24
|
|
|
* @since 1.0.0 |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
use RuntimeException; |
|
28
|
|
|
use Xmf\Module\Helper\Permission; |
|
29
|
|
|
use XoopsModules\Pedigree\{ |
|
30
|
|
|
Helper, |
|
31
|
|
|
Utility |
|
32
|
|
|
}; |
|
33
|
|
|
|
|
34
|
|
|
require_once \dirname(__DIR__, 2) . '/include/common.php'; |
|
35
|
|
|
|
|
36
|
|
|
$moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
37
|
|
|
//$helper = Helper::getInstance(); |
|
38
|
|
|
$permHelper = new Permission(); |
|
39
|
|
|
|
|
40
|
|
|
\xoops_load('XoopsFormLoader'); |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Class FieldsForm |
|
44
|
|
|
*/ |
|
45
|
|
|
class FieldsForm extends XoopsThemeForm |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
public $targetObject; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Constructor |
|
51
|
|
|
* |
|
52
|
|
|
* @param $target |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct($target) |
|
55
|
|
|
{ |
|
56
|
|
|
// global $helper; |
|
57
|
|
|
$this->helper = $target->helper; |
|
|
|
|
|
|
58
|
|
|
$this->targetObject = $target; |
|
59
|
|
|
|
|
60
|
|
|
$title = $this->targetObject->isNew() ? \sprintf(AM_PEDIGREE_FIELDS_ADD) : \sprintf(AM_PEDIGREE_FIELDS_EDIT); |
|
|
|
|
|
|
61
|
|
|
parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); |
|
62
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
|
63
|
|
|
|
|
64
|
|
|
//include ID field, it's needed so the module knows if it is a new form or an edited form |
|
65
|
|
|
|
|
66
|
|
|
$hidden = new \XoopsFormHidden('id', $this->targetObject->getVar('id')); |
|
67
|
|
|
$this->addElement($hidden); |
|
68
|
|
|
unset($hidden); |
|
69
|
|
|
|
|
70
|
|
|
// Id |
|
71
|
|
|
$this->addElement(new \XoopsFormLabel(AM_PEDIGREE_FIELDS_ID, $this->targetObject->getVar('id'), 'id')); |
|
|
|
|
|
|
72
|
|
|
// Isactive |
|
73
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_ISACTIVE, 'isactive', 50, 255, $this->targetObject->getVar('isactive')), false); |
|
|
|
|
|
|
74
|
|
|
// Fieldname |
|
75
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_FIELDNAME, 'fieldname', 50, 255, $this->targetObject->getVar('fieldname')), false); |
|
|
|
|
|
|
76
|
|
|
// Fieldtype |
|
77
|
|
|
$fieldtype = new \XoopsFormSelect(AM_PEDIGREE_FIELDS_FIELDTYPE, 'fieldtype', $this->targetObject->getVar('fieldtype')); |
|
|
|
|
|
|
78
|
|
|
$optionsArray = Utility::enumerate('pedigree_fields', 'fieldtype'); |
|
79
|
|
|
if (!\is_array($optionsArray)) { |
|
80
|
|
|
throw new RuntimeException($optionsArray . ' must be an array.'); |
|
81
|
|
|
} |
|
82
|
|
|
foreach ($optionsArray as $enum) { |
|
83
|
|
|
$fieldtype->addOption($enum, (\defined($enum) ? \constant($enum) : $enum)); |
|
84
|
|
|
} |
|
85
|
|
|
$this->addElement($fieldtype, false); |
|
86
|
|
|
// Lookuptable |
|
87
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_LOOKUPTABLE, 'lookuptable', 50, 255, $this->targetObject->getVar('lookuptable')), false); |
|
|
|
|
|
|
88
|
|
|
// Defaultvalue |
|
89
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_DEFAULTVALUE, 'defaultvalue', 50, 255, $this->targetObject->getVar('defaultvalue')), false); |
|
|
|
|
|
|
90
|
|
|
// Fieldexplanation |
|
91
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_FIELDEXPLANATION, 'fieldexplanation', 50, 255, $this->targetObject->getVar('fieldexplanation')), false); |
|
|
|
|
|
|
92
|
|
|
// Hassearch |
|
93
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_HASSEARCH, 'hassearch', 50, 255, $this->targetObject->getVar('hassearch')), false); |
|
|
|
|
|
|
94
|
|
|
// Litter |
|
95
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_LITTER, 'litter', 50, 255, $this->targetObject->getVar('litter')), false); |
|
|
|
|
|
|
96
|
|
|
// Generallitter |
|
97
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_GENERALLITTER, 'generallitter', 50, 255, $this->targetObject->getVar('generallitter')), false); |
|
|
|
|
|
|
98
|
|
|
// Searchname |
|
99
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_SEARCHNAME, 'searchname', 50, 255, $this->targetObject->getVar('searchname')), false); |
|
|
|
|
|
|
100
|
|
|
// Searchexplanation |
|
101
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_SEARCHEXPLANATION, 'searchexplanation', 50, 255, $this->targetObject->getVar('searchexplanation')), false); |
|
|
|
|
|
|
102
|
|
|
// Viewinpedigree |
|
103
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINPEDIGREE, 'viewinpedigree', 50, 255, $this->targetObject->getVar('viewinpedigree')), false); |
|
|
|
|
|
|
104
|
|
|
// Viewinadvanced |
|
105
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINADVANCED, 'viewinadvanced', 50, 255, $this->targetObject->getVar('viewinadvanced')), false); |
|
|
|
|
|
|
106
|
|
|
// Viewinpie |
|
107
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINPIE, 'viewinpie', 50, 255, $this->targetObject->getVar('viewinpie')), false); |
|
|
|
|
|
|
108
|
|
|
// Viewinlist |
|
109
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINLIST, 'viewinlist', 50, 255, $this->targetObject->getVar('viewinlist')), false); |
|
|
|
|
|
|
110
|
|
|
// Locked |
|
111
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_LOCKED, 'locked', 50, 255, $this->targetObject->getVar('locked')), false); |
|
|
|
|
|
|
112
|
|
|
// Order |
|
113
|
|
|
$this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_ORDER, 'order', 50, 255, $this->targetObject->getVar('order')), false); |
|
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
$this->addElement(new \XoopsFormHidden('op', 'save')); |
|
116
|
|
|
$this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|