Passed
Push — master ( 8b5e26...f79285 )
by Michael
04:32
created

FieldsForm   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 36
dl 0
loc 72
rs 10
c 1
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 63 5
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
0 ignored issues
show
Bug introduced by
The type XoopsModules\Pedigree\Form\XoopsThemeForm was not found. Did you mean XoopsThemeForm? If so, make sure to prefix the type with \.
Loading history...
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;
0 ignored issues
show
Bug Best Practice introduced by
The property helper does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
58
        $this->targetObject = $target;
59
60
        $title = $this->targetObject->isNew() ? \sprintf(AM_PEDIGREE_FIELDS_ADD) : \sprintf(AM_PEDIGREE_FIELDS_EDIT);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Form\AM_PEDIGREE_FIELDS_EDIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant XoopsModules\Pedigree\Form\AM_PEDIGREE_FIELDS_ADD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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'));
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Form\AM_PEDIGREE_FIELDS_ID was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
72
        // Isactive
73
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_ISACTIVE, 'isactive', 50, 255, $this->targetObject->getVar('isactive')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...EDIGREE_FIELDS_ISACTIVE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
74
        // Fieldname
75
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_FIELDNAME, 'fieldname', 50, 255, $this->targetObject->getVar('fieldname')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...DIGREE_FIELDS_FIELDNAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
76
        // Fieldtype
77
        $fieldtype    = new \XoopsFormSelect(AM_PEDIGREE_FIELDS_FIELDTYPE, 'fieldtype', $this->targetObject->getVar('fieldtype'));
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...DIGREE_FIELDS_FIELDTYPE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...GREE_FIELDS_LOOKUPTABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
88
        // Defaultvalue
89
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_DEFAULTVALUE, 'defaultvalue', 50, 255, $this->targetObject->getVar('defaultvalue')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...REE_FIELDS_DEFAULTVALUE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
90
        // Fieldexplanation
91
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_FIELDEXPLANATION, 'fieldexplanation', 50, 255, $this->targetObject->getVar('fieldexplanation')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...FIELDS_FIELDEXPLANATION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
92
        // Hassearch
93
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_HASSEARCH, 'hassearch', 50, 255, $this->targetObject->getVar('hassearch')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...DIGREE_FIELDS_HASSEARCH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
94
        // Litter
95
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_LITTER, 'litter', 50, 255, $this->targetObject->getVar('litter')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo..._PEDIGREE_FIELDS_LITTER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
96
        // Generallitter
97
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_GENERALLITTER, 'generallitter', 50, 255, $this->targetObject->getVar('generallitter')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...EE_FIELDS_GENERALLITTER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
98
        // Searchname
99
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_SEARCHNAME, 'searchname', 50, 255, $this->targetObject->getVar('searchname')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...IGREE_FIELDS_SEARCHNAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
100
        // Searchexplanation
101
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_SEARCHEXPLANATION, 'searchexplanation', 50, 255, $this->targetObject->getVar('searchexplanation')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...IELDS_SEARCHEXPLANATION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
102
        // Viewinpedigree
103
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINPEDIGREE, 'viewinpedigree', 50, 255, $this->targetObject->getVar('viewinpedigree')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...E_FIELDS_VIEWINPEDIGREE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
104
        // Viewinadvanced
105
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINADVANCED, 'viewinadvanced', 50, 255, $this->targetObject->getVar('viewinadvanced')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...E_FIELDS_VIEWINADVANCED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
106
        // Viewinpie
107
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINPIE, 'viewinpie', 50, 255, $this->targetObject->getVar('viewinpie')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...DIGREE_FIELDS_VIEWINPIE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
108
        // Viewinlist
109
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_VIEWINLIST, 'viewinlist', 50, 255, $this->targetObject->getVar('viewinlist')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...IGREE_FIELDS_VIEWINLIST was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
110
        // Locked
111
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_LOCKED, 'locked', 50, 255, $this->targetObject->getVar('locked')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo..._PEDIGREE_FIELDS_LOCKED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
112
        // Order
113
        $this->addElement(new \XoopsFormText(AM_PEDIGREE_FIELDS_ORDER, 'order', 50, 255, $this->targetObject->getVar('order')), false);
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Pedigree\Fo...M_PEDIGREE_FIELDS_ORDER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
114
115
        $this->addElement(new \XoopsFormHidden('op', 'save'));
116
        $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
117
    }
118
}
119