Issues (519)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/Fields.php (13 issues)

1
<?php namespace XoopsModules\Tdmcreate;
2
3
use XoopsModules\Tdmcreate;
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
 * tdmcreatereate module.
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
20
 *
21
 * @since           2.5.7
22
 *
23
 * @author          Txmod Xoops <[email protected]> - <http://www.txmodxoops.org/>
24
 *
25
 * @version         $Id: 1.91 fields.php 12258 2014-01-02 09:33:29Z timgno $
26
 */
27
//include __DIR__.'/autoload.php';
28
29
/**
30
 * Class Fields.
31
 */
32
class Fields extends \XoopsObject
33
{
34
    /**
35
     *  @public function constructor class
36
     *
37
     *  @param null
38
     */
39
    public function __construct()
40
    {
41
        $this->initVar('field_id', XOBJ_DTYPE_INT);
42
        $this->initVar('field_mid', XOBJ_DTYPE_INT);
43
        $this->initVar('field_tid', XOBJ_DTYPE_INT);
44
        $this->initVar('field_order', XOBJ_DTYPE_INT);
45
        $this->initVar('field_name', XOBJ_DTYPE_TXTBOX);
46
        $this->initVar('field_type', XOBJ_DTYPE_TXTBOX);
47
        $this->initVar('field_value', XOBJ_DTYPE_TXTBOX);
48
        $this->initVar('field_attribute', XOBJ_DTYPE_TXTBOX);
49
        $this->initVar('field_null', XOBJ_DTYPE_TXTBOX);
50
        $this->initVar('field_default', XOBJ_DTYPE_TXTBOX);
51
        $this->initVar('field_key', XOBJ_DTYPE_TXTBOX);
52
        $this->initVar('field_element', XOBJ_DTYPE_TXTBOX);
53
        $this->initVar('field_parent', XOBJ_DTYPE_INT);
54
        $this->initVar('field_admin', XOBJ_DTYPE_INT);
55
        $this->initVar('field_inlist', XOBJ_DTYPE_INT);
56
        $this->initVar('field_inform', XOBJ_DTYPE_INT);
57
        $this->initVar('field_user', XOBJ_DTYPE_INT);
58
        $this->initVar('field_thead', XOBJ_DTYPE_INT);
59
        $this->initVar('field_tbody', XOBJ_DTYPE_INT);
60
        $this->initVar('field_tfoot', XOBJ_DTYPE_INT);
61
        $this->initVar('field_block', XOBJ_DTYPE_INT);
62
        $this->initVar('field_main', XOBJ_DTYPE_INT);
63
        $this->initVar('field_search', XOBJ_DTYPE_INT);
64
        $this->initVar('field_required', XOBJ_DTYPE_INT);
65
    }
66
67
    /**
68
     * @param string $method
69
     * @param array  $args
70
     *
71
     * @return mixed
72
     */
73
    public function __call($method, $args)
74
    {
75
        $arg = isset($args[0]) ? $args[0] : null;
76
77
        return $this->getVar($method, $arg);
78
    }
79
80
    /**
81
     * @static function getInstance
82
     *
83
     * @return Fields
84
     */
85
    public static function getInstance()
86
    {
87
        static $instance = false;
88
        if (!$instance) {
89
            $instance = new self();
90
        }
91
92
        return $instance;
93
    }
94
95
    /**
96
     * @private function getHeaderForm
97
     *
98
     * @param bool $action
99
     * @return Tdmcreate\Form\ThemeForm
100
     */
101
    private function getHeaderForm($action = false)
102
    {
103
        if (false === $action) {
104
            $action = $_SERVER['REQUEST_URI'];
105
        }
106
107
        $isNew = $this->isNew();
108
        $title = $isNew ? sprintf(_AM_TDMCREATE_FIELDS_NEW) : sprintf(_AM_TDMCREATE_FIELDS_EDIT);
109
110
        $form = new Tdmcreate\Form\ThemeForm(null, 'form', $action, 'post', true);
111
        $form->setExtra('enctype="multipart/form-data"');
112
113
        // New Object HtmlTable
114
        $form->addElement(new Tdmcreate\Html\FormLabel('<table cellspacing="1" class="outer width100">'));
115
        $form->addElement(new Tdmcreate\Html\FormLabel('<thead class="center">'));
116
        $form->addElement(new Tdmcreate\Html\FormLabel('<tr class="head"><th colspan="9">'.$title.'</th></tr>'));
117
        $form->addElement(new Tdmcreate\Html\FormLabel('<tr class="head width5">'));
118
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_ID.'</td>'));
119
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_NAME.'</td>'));
120
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_TYPE.'</td>'));
121
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_VALUE.'</th>'));
122
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_ATTRIBUTE.'</th>'));
123
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_NULL.'</th>'));
124
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_DEFAULT.'</th>'));
125
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_KEY.'</th>'));
126
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'._AM_TDMCREATE_FIELD_PARAMETERS.'</th>'));
127
        $form->addElement(new Tdmcreate\Html\FormLabel('</tr></thead>'));
128
        $form->addElement(new Tdmcreate\Html\FormLabel('<tbody>'));
129
130
        return $form;
131
    }
132
133
    /**
134
     * @public function getFormNew
135
     *
136
     * @param null $fieldMid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fieldMid is correct as it would always require null to be passed?
Loading history...
137
     * @param null $fieldTid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fieldTid is correct as it would always require null to be passed?
Loading history...
138
     * @param null $fieldNumb
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fieldNumb is correct as it would always require null to be passed?
Loading history...
139
     * @param null $fieldName
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fieldName is correct as it would always require null to be passed?
Loading history...
140
     * @param bool $action
141
     * @return mixed
142
     */
143
    public function getFormNew($fieldMid = null, $fieldTid = null, $fieldNumb = null, $fieldName = null, $action = false)
144
    {
145
        $helper = Tdmcreate\Helper::getInstance();
146
        // Header function class
147
        $fieldsForm = self::getInstance();
148
        $form = $fieldsForm->getHeaderForm($action);
149
        // Get handler tables
150
        $tableObj = $helper->getHandler('Tables'); // Changed by goffy
151
        $tableAutoincrement = $tableObj->get($fieldTid)->getVar('table_autoincrement'); // Added by goffy
152
        // Loop for fields number
153
        $class = 'even';
154
        for ($i = 1; $i <= $fieldNumb; ++$i) {
155
            $class = ('even' === $class) ? 'odd' : 'even';
156
            // Replaced creation of new line by new function - goffy
157
            $this->getFormNewLine($form, $class, $i, $fieldMid, $fieldTid, $fieldName, $tableAutoincrement);
158
        }
159
160
        // Footer form
161
        return $fieldsForm->getFooterForm($form);
162
    }
163
164
    /**
165
     * @private function getFormNewLine
166
     *
167
     * @param $form
168
     * @param $class
169
     * @param $i
170
     * @param $fieldMid
171
     * @param $fieldTid
172
     * @param $fName
173
     * @param $tableAutoincrement
174
     */
175
    private function getFormNewLine($form, $class, $i, $fieldMid, $fieldTid, $fName, $tableAutoincrement)
176
    {
177
        $helper = Tdmcreate\Helper::getInstance();
178
        $form->addElement(new \XoopsFormHidden('field_id['.$i.']', 0));
179
        $form->addElement(new \XoopsFormHidden('field_mid', $fieldMid));
180
        $form->addElement(new \XoopsFormHidden('field_tid', $fieldTid));
181
182
        $form->addElement(new Tdmcreate\Html\FormLabel('<tr class="'.$class.'">'));
183
        // Index ID
184
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$i.'</td>'));
185
        // Field Name
186
        $thisFieldName = (!empty($fName) ? ((1 == $i) ? $fName.'_id' : $fName.'_') : '');
187
        $fieldName = new \XoopsFormText(_AM_TDMCREATE_FIELD_NAME, 'field_name['.$i.']', 15, 255, $thisFieldName);
188
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldName->render().'</td>'));
189
        // Field Type
190
        $value = (1 == $i) && (1 == $tableAutoincrement) ? '2' : '';
191
        $fieldTypeSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_type['.$i.']', $value);
192
        $fieldTypeSelect->addOptionArray($helper->getHandler('Fieldtype')->getList());
0 ignored issues
show
The method getList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsImageHandler or XoopsRankHandler or XoopsCommentHandler or XoopsTplsetHandler or XoopsAvatarHandler or XoopsBlockHandler or XoopsImagesetHandler or XoopsPersistableObjectHandler or XoopsImagecategoryHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

192
        $fieldTypeSelect->addOptionArray($helper->getHandler('Fieldtype')->/** @scrutinizer ignore-call */ getList());
Loading history...
193
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldTypeSelect->render().'</td>'));
194
        // Field Value
195
        $value = (1 == $i) && (1 == $tableAutoincrement) ? '8' : '';
196
        $fieldValue = new \XoopsFormText(_AM_TDMCREATE_FIELD_VALUE, 'field_value['.$i.']', 10, 200, $value);
197
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldValue->render().'</td>'));
198
        // Field Attributes
199
        $value = (1 == $i) && (1 == $tableAutoincrement) ? '3' : '';
200
        $fieldAttributesSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_attribute['.$i.']', $value);
201
        $fieldAttributesSelect->addOptionArray($helper->getHandler('Fieldattributes')->getList());
202
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldAttributesSelect->render().'</td>'));
203
        // Field Null
204
        $value = (1 == $i) && (1 == $tableAutoincrement) ? '2' : '2';
205
        $fieldNullSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_NULL, 'field_null['.$i.']', $value);
206
        $fieldNullSelect->addOptionArray($helper->getHandler('Fieldnull')->getList());
207
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldNullSelect->render().'</td>'));
208
        // Field Default
209
        $fieldDefault = new \XoopsFormText(_AM_TDMCREATE_FIELD_DEFAULT, 'field_default['.$i.']', 15, 25);
210
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldDefault->render().'</td>'));
211
        // Field Key
212
        $value = (1 == $i) && (1 == $tableAutoincrement) ? '2' : '';
213
        $fieldKeySelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_KEY, 'field_key['.$i.']', $value);
214
        $fieldKeySelect->addOptionArray($helper->getHandler('Fieldkey')->getList());
215
        $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldKeySelect->render().'</td>'));
216
        // Field Void
217
        if ((1 == $i) && (1 == $tableAutoincrement)) {
218
            $form->addElement(new Tdmcreate\Html\FormLabel('<td>&nbsp;</td></tr>'));
219
        } else {
220
            // Box header row
221
            $parametersTray = new \XoopsFormElementTray('', '<br>');
222
            // Field Elements
223
            $crElement = new \CriteriaCompo();
224
            $crElement->add(new \Criteria('fieldelement_tid', 0));
225
            $crTable = new \CriteriaCompo();
226
            $crTable->add(new \Criteria('fieldelement_mid', $fieldMid));
227
            $fieldElementsSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element['.$i.']');
228
            $fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crElement));
229
            $fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crTable));
230
            unset($crElement, $crTable);
231
            $parametersTray->addElement($fieldElementsSelect);
232
233
            $field_parent = 0;
234
            $checkFieldParent = new \XoopsFormCheckBox(' ', 'field_parent['.$i.']', $field_parent);
235
            $checkFieldParent->addOption(1, _AM_TDMCREATE_FIELD_PARENT);
236
            $parametersTray->addElement($checkFieldParent);
237
238
            $field_admin = 0;
239
            $checkFieldAdmin = new \XoopsFormCheckBox(' ', 'field_admin['.$i.']', $field_admin);
240
            $checkFieldAdmin->addOption(1, _AM_TDMCREATE_FIELD_ADMIN);
241
            $parametersTray->addElement($checkFieldAdmin);
242
243
            $field_inlist = 0;
244
            $checkFieldInList = new \XoopsFormCheckBox(' ', 'field_inlist['.$i.']', $field_inlist);
245
            $checkFieldInList->addOption(1, _AM_TDMCREATE_FIELD_INLIST);
246
            $parametersTray->addElement($checkFieldInList);
247
248
            $field_inform = 0;
249
            $checkFieldInForm = new \XoopsFormCheckBox(' ', 'field_inform['.$i.']', $field_inform);
250
            $checkFieldInForm->addOption(1, _AM_TDMCREATE_FIELD_INFORM);
251
            $parametersTray->addElement($checkFieldInForm);
252
253
            $field_user = 0;
254
            $checkFieldUser = new \XoopsFormCheckBox(' ', 'field_user['.$i.']', $field_user);
255
            $checkFieldUser->addOption(1, _AM_TDMCREATE_FIELD_USER);
256
            $parametersTray->addElement($checkFieldUser);
257
258
            $field_thead = 0;
259
            $checkFieldThead = new \XoopsFormCheckBox(' ', 'field_thead['.$i.']', $field_thead);
260
            $checkFieldThead->addOption(1, _AM_TDMCREATE_FIELD_THEAD);
261
            $parametersTray->addElement($checkFieldThead);
262
263
            $field_tbody = 0;
264
            $checkFieldTbody = new \XoopsFormCheckBox(' ', 'field_tbody['.$i.']', $field_tbody);
265
            $checkFieldTbody->addOption(1, _AM_TDMCREATE_FIELD_TBODY);
266
            $parametersTray->addElement($checkFieldTbody);
267
268
            $field_tfoot = 0;
269
            $checkFieldTfoot = new \XoopsFormCheckBox(' ', 'field_tfoot['.$i.']', $field_tfoot);
270
            $checkFieldTfoot->addOption(1, _AM_TDMCREATE_FIELD_TFOOT);
271
            $parametersTray->addElement($checkFieldTfoot);
272
273
            $field_block = 0;
274
            $checkFieldBlock = new \XoopsFormCheckBox('', 'field_block['.$i.']', $field_block);
275
            $checkFieldBlock->addOption(1, _AM_TDMCREATE_FIELD_BLOCK);
276
            $parametersTray->addElement($checkFieldBlock);
277
278
            $field_search = 0;
279
            $check_field_search = new \XoopsFormCheckBox(' ', 'field_search['.$i.']', $field_search);
280
            $check_field_search->addOption(1, _AM_TDMCREATE_FIELD_SEARCH);
281
            $parametersTray->addElement($check_field_search);
282
283
            $field_required = 0;
284
            $checkFieldRequired = new \XoopsFormCheckBox(' ', 'field_required['.$i.']', $field_required);
285
            $checkFieldRequired->addOption(1, _AM_TDMCREATE_FIELD_REQUIRED);
286
            $parametersTray->addElement($checkFieldRequired);
287
288
            $fieldMain = (1 == $tableAutoincrement) ? 2 : 1;
289
            $checkFieldMain = new Tdmcreate\Form\FormRadio('', 'field_main', $fieldMain);
290
            $checkFieldMain->addOption($i, _AM_TDMCREATE_FIELD_MAIN);
291
            $parametersTray->addElement($checkFieldMain);
292
293
            $form->addElement(new Tdmcreate\Html\FormLabel('<td><div class="portlet"><div class="portlet-header">'._AM_TDMCREATE_FIELD_PARAMETERS_LIST.'</div><div class="portlet-content">'.$parametersTray->render().'</div></div></td></tr>'));
294
        }
295
    }
296
297
    /**
298
     * @public function getFormEdit
299
     *
300
     * @param null $fieldMid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fieldMid is correct as it would always require null to be passed?
Loading history...
301
     * @param null $fieldTid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fieldTid is correct as it would always require null to be passed?
Loading history...
302
     * @param bool $action
303
     * @return mixed
304
     */
305
    public function getFormEdit($fieldMid = null, $fieldTid = null, $action = false)
306
    {
307
        $helper = Tdmcreate\Helper::getInstance();
308
        // Header function class
309
        $fieldsForm = self::getInstance();
310
        $form = $fieldsForm->getHeaderForm($action);
311
312
        $class = 'even';
313
        // Get the number of fields - goffy
314
        $tablesHandler =& $helper->getHandler('Tables');
315
        $tables = $tablesHandler->get($fieldTid);
316
        $tableAutoincrement = $tables->getVar('table_autoincrement');
317
        $fieldNumb = $tables->getVar('table_nbfields');
318
        $fName = $tables->getVar('table_fieldname');
319
320
        // Get the list of fields
321
        $cr = new \CriteriaCompo();
322
        $cr->add(new \Criteria('field_mid', $fieldMid));
323
        $cr->add(new \Criteria('field_tid', $fieldTid));
324
        $cr->setSort('field_order'); //added by goffy
325
        $fields = $helper->getHandler('Fields')->getObjects($cr);
0 ignored issues
show
The method getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

325
        $fields = $helper->getHandler('Fields')->/** @scrutinizer ignore-call */ getObjects($cr);
Loading history...
326
        unset($cr);
327
        $id = 1;
328
        foreach ($fields as $field) {
329
            $class = ('even' === $class) ? 'odd' : 'even';
330
            $fieldId = (int)$field->getVar('field_id');
331
            if ($id > $fieldNumb) {   // delete additional fields, if number of fields is reduced - goffy
332
                $fieldsObj =& $helper->getHandler('Fields')->get($fieldId);
333
                $helper->getHandler('Fields')->delete($fieldsObj, true);
0 ignored issues
show
The call to XoopsObjectHandler::delete() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

333
                $helper->getHandler('Fields')->/** @scrutinizer ignore-call */ delete($fieldsObj, true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
334
            } else {
335
                // show field with settings
336
                $form->addElement(new \XoopsFormHidden('field_id['.$id.']', $fieldId));
337
338
                $form->addElement(new Tdmcreate\Html\FormLabel('<tr class="'.$class.'">'));
339
                // Index ID
340
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$id.'</td>'));
341
                // Field Name
342
                $fieldName = new \XoopsFormText(_AM_TDMCREATE_FIELD_NAME, 'field_name['.$id.']', 15, 255, $field->getVar('field_name'));
343
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldName->render().'</td>'));
344
                // Field Type
345
                $fieldTypeSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_type['.$id.']', $field->getVar('field_type'));
346
                $fieldTypeSelect->addOptionArray($helper->getHandler('Fieldtype')->getList());
347
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldTypeSelect->render().'</td>'));
348
                // Field Value
349
                $fieldValue = new \XoopsFormText(_AM_TDMCREATE_FIELD_VALUE, 'field_value['.$id.']', 10, 200, $field->getVar('field_value'));
350
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldValue->render().'</td>'));
351
                // Field Attributes
352
                $fieldAttributesSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_attribute['.$id.']', $field->getVar('field_attribute'));
353
                $fieldAttributesSelect->addOptionArray($helper->getHandler('Fieldattributes')->getList());
354
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldAttributesSelect->render().'</td>'));
355
                // Field Null
356
                $fieldNullSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_NULL, 'field_null['.$id.']', $field->getVar('field_null'));
357
                $fieldNullSelect->addOptionArray($helper->getHandler('Fieldnull')->getList());
358
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldNullSelect->render().'</td>'));
359
                // Field Default
360
                $fieldDefault = new \XoopsFormText(_AM_TDMCREATE_FIELD_DEFAULT, 'field_default['.$id.']', 15, 25, $field->getVar('field_default'));
361
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldDefault->render().'</td>'));
362
                // Field Key
363
                $fieldKeySelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_KEY, 'field_key['.$id.']', $field->getVar('field_key'));
364
                $fieldKeySelect->addOptionArray($helper->getHandler('Fieldkey')->getList());
365
                $form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">'.$fieldKeySelect->render().'</td>'));
366
                // Field Void
367
                if ((1 == $id) && (1 == $tableAutoincrement)) {
368
                    $form->addElement(new Tdmcreate\Html\FormLabel('<td>&nbsp;</td></tr>'));
369
                } else {
370
                    // Box header row
371
                    $parametersTray = new \XoopsFormElementTray('', '<br>');
372
                    // Field Elements
373
                    $crElement = new \CriteriaCompo();
374
                    $crElement->add(new \Criteria('fieldelement_tid', 0));
375
                    $crTable = new \CriteriaCompo();
376
                    $crTable->add(new \Criteria('fieldelement_mid', $fieldMid));
377
                    $fieldElementsSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element['.$id.']', $field->getVar('field_element'));
378
                    $fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crElement));
379
                    $fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crTable));
380
                    unset($crElement, $crTable);
381
                    $parametersTray->addElement($fieldElementsSelect);
382
383
                    $checkFieldParent = new \XoopsFormCheckBox(' ', 'field_parent['.$id.']', $field->getVar('field_parent'));
384
                    $checkFieldParent->addOption(1, _AM_TDMCREATE_FIELD_PARENT);
385
                    $parametersTray->addElement($checkFieldParent);
386
387
                    $checkFieldAdmin = new \XoopsFormCheckBox(' ', 'field_admin['.$id.']', $field->getVar('field_admin'));
388
                    $checkFieldAdmin->addOption(1, _AM_TDMCREATE_FIELD_ADMIN);
389
                    $parametersTray->addElement($checkFieldAdmin);
390
391
                    $checkFieldInList = new \XoopsFormCheckBox(' ', 'field_inlist['.$id.']', $field->getVar('field_inlist'));
392
                    $checkFieldInList->addOption(1, _AM_TDMCREATE_FIELD_INLIST);
393
                    $parametersTray->addElement($checkFieldInList);
394
395
                    $checkFieldInForm = new \XoopsFormCheckBox(' ', 'field_inform['.$id.']', $field->getVar('field_inform'));
396
                    $checkFieldInForm->addOption(1, _AM_TDMCREATE_FIELD_INFORM);
397
                    $parametersTray->addElement($checkFieldInForm);
398
399
                    $checkFieldUser = new \XoopsFormCheckBox(' ', 'field_user['.$id.']', $field->getVar('field_user'));
400
                    $checkFieldUser->addOption(1, _AM_TDMCREATE_FIELD_USER);
401
                    $parametersTray->addElement($checkFieldUser);
402
403
                    $checkFieldThead = new \XoopsFormCheckBox(' ', 'field_thead['.$id.']', $field->getVar('field_thead'));
404
                    $checkFieldThead->addOption(1, _AM_TDMCREATE_FIELD_THEAD);
405
                    $parametersTray->addElement($checkFieldThead);
406
407
                    $checkFieldTbody = new \XoopsFormCheckBox(' ', 'field_tbody['.$id.']', $field->getVar('field_tbody'));
408
                    $checkFieldTbody->addOption(1, _AM_TDMCREATE_FIELD_TBODY);
409
                    $parametersTray->addElement($checkFieldTbody);
410
411
                    $checkFieldTfoot = new \XoopsFormCheckBox(' ', 'field_tfoot['.$id.']', $field->getVar('field_tfoot'));
412
                    $checkFieldTfoot->addOption(1, _AM_TDMCREATE_FIELD_TFOOT);
413
                    $parametersTray->addElement($checkFieldTfoot);
414
415
                    $checkFieldBlock = new \XoopsFormCheckBox('', 'field_block['.$id.']', $field->getVar('field_block'));
416
                    $checkFieldBlock->addOption(1, _AM_TDMCREATE_FIELD_BLOCK);
417
                    $parametersTray->addElement($checkFieldBlock);
418
419
                    $check_field_search = new \XoopsFormCheckBox(' ', 'field_search['.$id.']', $field->getVar('field_search'));
420
                    $check_field_search->addOption(1, _AM_TDMCREATE_FIELD_SEARCH);
421
                    $parametersTray->addElement($check_field_search);
422
423
                    $checkFieldRequired = new \XoopsFormCheckBox(' ', 'field_required['.$id.']', $field->getVar('field_required'));
424
                    $checkFieldRequired->addOption(1, _AM_TDMCREATE_FIELD_REQUIRED);
425
                    $parametersTray->addElement($checkFieldRequired);
426
427
                    $fieldMain = (1 == $field->getVar('field_main')) ? $id : 1;
428
                    $checkFieldMain = new Tdmcreate\Form\FormRadio('', 'field_main', $fieldMain);
429
                    $checkFieldMain->addOption($id, _AM_TDMCREATE_FIELD_MAIN);
430
                    $parametersTray->addElement($checkFieldMain);
431
432
                    $form->addElement(new Tdmcreate\Html\FormLabel('<td><div class="portlet"><div class="portlet-header">'._AM_TDMCREATE_FIELD_PARAMETERS_LIST.'</div><div class="portlet-content">'.$parametersTray->render().'</div></div></td></tr>'));
433
                }
434
            }
435
            ++$id;
436
        }
437
        // If you change number fields in tables,
438
        // adding missing fields or delete unnecessary fields
439
        // By goffy
440
        for ($i = $id; $i <= $fieldNumb; ++$i) {
441
            $class = ('even' === $class) ? 'odd' : 'even';
442
            $this->getFormNewLine($form, $class, $i, $fieldMid, $fieldTid, $fName, $tableAutoincrement);
443
        }
444
        unset($id);
445
446
        // Footer form
447
        return $fieldsForm->getFooterForm($form);
448
    }
449
450
    /**
451
     * @private function getFooterForm
452
     *
453
     * @param $form
454
     *
455
     * @return mixed
456
     */
457
    private function getFooterForm($form)
458
    {
459
        // Send Form Data
460
        $form->addElement(new Tdmcreate\Html\FormLabel('</tbody>'));
461
        $form->addElement(new Tdmcreate\Html\FormLabel('<tfoot><tr>'));
462
        $formHidden = new \XoopsFormHidden('op', 'save');
463
        $formButton = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
464
        $form->addElement(new Tdmcreate\Html\FormLabel('<td colspan="8">'.$formHidden->render().'</td>'));
465
        $form->addElement(new Tdmcreate\Html\FormLabel('<td>'.$formButton->render().'</td>'));
466
        $form->addElement(new Tdmcreate\Html\FormLabel('</tr></tfoot></table>'));
467
468
        return $form;
469
    }
470
471
    /**
472
     * Get Values.
473
     * @param null $keys
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $keys is correct as it would always require null to be passed?
Loading history...
474
     * @param null $format
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $format is correct as it would always require null to be passed?
Loading history...
475
     * @param null $maxDepth
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $maxDepth is correct as it would always require null to be passed?
Loading history...
476
     * @return array
477
     */
478
    public function getValuesFields($keys = null, $format = null, $maxDepth = null)
479
    {
480
        $ret = $this->getValues($keys, $format, $maxDepth);
481
        $ret['id'] = $this->getVar('field_id');
482
        $ret['mid'] = $this->getVar('field_mid');
483
        $ret['tid'] = $this->getVar('field_tid');
484
        $ret['order'] = $this->getVar('field_order');
485
        $ret['name'] = str_replace('_', ' ', ucfirst($this->getVar('field_name')));
0 ignored issues
show
It seems like $this->getVar('field_name') can also be of type array and array; however, parameter $str of ucfirst() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

485
        $ret['name'] = str_replace('_', ' ', ucfirst(/** @scrutinizer ignore-type */ $this->getVar('field_name')));
Loading history...
486
        $ret['parent'] = $this->getVar('field_parent');
487
        $ret['inlist'] = $this->getVar('field_inlist');
488
        $ret['inform'] = $this->getVar('field_inform');
489
        $ret['admin'] = $this->getVar('field_admin');
490
        $ret['user'] = $this->getVar('field_user');
491
        $ret['block'] = $this->getVar('field_block');
492
        $ret['main'] = $this->getVar('field_main');
493
        $ret['search'] = $this->getVar('field_search');
494
        $ret['required'] = $this->getVar('field_required');
495
496
        return $ret;
497
    }
498
}
499