Passed
Push — master ( 81a617...f7060c )
by Goffy
02:56 queued 52s
created

Downloads   B

Complexity

Total Complexity 52

Size/Duplication

Total Lines 334
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 224
dl 0
loc 334
rs 7.44
c 0
b 0
f 0
wmc 52

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 27 1
A getNewEnreg() 0 9 2
F getForm() 0 281 49

How to fix   Complexity   

Complex Class

Complex classes like Downloads often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Downloads, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace XoopsModules\Tdmdownloads;
4
5
use XoopsModules\Tag\FormTag;
6
7
/**
8
 * TDMDownload
9
 *
10
 * You may not change or alter any portion of this comment or credits
11
 * of supporting developers from this source code or any supporting source code
12
 * which is considered copyrighted (c) material of the original comment or credit authors.
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 *
17
 * @copyright   Gregory Mage (Aka Mage)
18
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
19
 * @author      Gregory Mage (Aka Mage)
20
 */
21
defined('XOOPS_ROOT_PATH') || die('Restricted access');
22
23
/**
24
 * Class Downloads
25
 * @package XoopsModules\Tdmdownloads
26
 */
27
class Downloads extends \XoopsObject
28
{
29
    // constructor
30
    public function __construct()
31
    {
32
        $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11);
33
        $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5);
34
        $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false);
35
        $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, false);
36
        $this->initVar('homepage', XOBJ_DTYPE_TXTBOX, null, false);
37
        $this->initVar('version', XOBJ_DTYPE_TXTBOX, null, false);
38
        $this->initVar('size', XOBJ_DTYPE_TXTBOX, null, false);
39
        $this->initVar('platform', XOBJ_DTYPE_TXTBOX, null, false);
40
        $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false);
41
        // Pour autoriser le html
42
        $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false);
43
        $this->initVar('logourl', XOBJ_DTYPE_TXTBOX, null, false);
44
        $this->initVar('submitter', XOBJ_DTYPE_INT, null, false, 11);
45
        $this->initVar('status', XOBJ_DTYPE_INT, null, false, 2);
46
        $this->initVar('date', XOBJ_DTYPE_INT, null, false, 10);
47
        $this->initVar('hits', XOBJ_DTYPE_INT, null, false, 10);
48
        $this->initVar('rating', XOBJ_DTYPE_OTHER, null, false, 10);
49
        $this->initVar('votes', XOBJ_DTYPE_INT, null, false, 11);
50
        $this->initVar('comments', XOBJ_DTYPE_INT, null, false, 11);
51
        $this->initVar('top', XOBJ_DTYPE_INT, null, false, 2);
52
        $this->initVar('paypal', XOBJ_DTYPE_TXTBOX, null, false);
53
54
        //pour les jointures:
55
        $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX, null, false);
56
        $this->initVar('cat_imgurl', XOBJ_DTYPE_TXTBOX, null, false);
57
    }
58
59
    /**
60
     * @param null $db
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $db is correct as it would always require null to be passed?
Loading history...
61
     * @return int
62
     */
63
    public function getNewEnreg($db = null)
64
    {
65
        $newEnreg = 0;
66
        /** @var \XoopsMySQLDatabase $db */
67
        if (null !== $db) {
68
            $newEnreg = $db->getInsertId();
69
        }
70
71
        return $newEnreg;
72
    }
73
74
    /**
75
     * @param array $donnee
76
     * @param bool  $erreur
77
     * @param bool  $action
78
     * @return \XoopsThemeForm
79
     */
80
    public function getForm($donnee = [], $erreur = false, $action = false)
81
    {
82
        global $xoopsModule, $xoopsUser;
83
        /** @var \XoopsModules\Tdmdownloads\Helper $helper */
84
        $helper = \XoopsModules\Tdmdownloads\Helper::getInstance();
85
        /** @var \XoopsModules\Tdmdownloads\Utility $utility */
86
        $utility       = new \XoopsModules\Tdmdownloads\Utility();
87
        $moduleDirName = basename(dirname(__DIR__));
88
        if (false === $action) {
89
            $action = $_SERVER['REQUEST_URI'];
90
        }
91
        //permission pour uploader
92
        /** @var \XoopsGroupPermHandler $grouppermHandler */
93
        $grouppermHandler = xoops_getHandler('groupperm');
94
        $groups           = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
95
        if ($xoopsUser) {
96
            $perm_upload = true;
97
            if (!$xoopsUser->isAdmin($xoopsModule->mid())) {
98
                $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false;
99
            }
100
        } else {
101
            $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false;
102
        }
103
        //nom du formulaire selon l'action (editer ou ajouter):
104
        $title = $this->isNew() ? sprintf(_AM_TDMDOWNLOADS_FORMADD) : sprintf(_AM_TDMDOWNLOADS_FORMEDIT);
105
106
        //création du formulaire
107
        $form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
108
        $form->setExtra('enctype="multipart/form-data"');
109
        //titre
110
        $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'title', 50, 255, $this->getVar('title')), true);
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('title') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() 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

110
        $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'title', 50, 255, /** @scrutinizer ignore-type */ $this->getVar('title')), true);
Loading history...
111
        // fichier
112
        $fichier = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMFILE, '<br><br>');
113
        $url     = $this->isNew() ? 'http://' : $this->getVar('url');
114
        $formurl = new \XoopsFormText(_AM_TDMDOWNLOADS_FORMURL, 'url', 75, 255, $url);
115
        $fichier->addElement($formurl, false);
116
        if (true === $perm_upload) {
117
            $fichier->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxuploadsize')), false);
118
        }
119
        $form->addElement($fichier);
120
121
        //catégorie
122
        /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */
123
        $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category');
124
        $categories      = $utility->getItemIds('tdmdownloads_submit', $moduleDirName);
125
        $criteria        = new \CriteriaCompo();
126
        $criteria->setSort('cat_weight ASC, cat_title');
127
        $criteria->setOrder('ASC');
128
        if ($xoopsUser) {
129
            if (!$xoopsUser->isAdmin($xoopsModule->mid())) {
130
                $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN'));
131
            }
132
        } else {
133
            $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN'));
134
        }
135
        $downloadscatArray = $categoryHandler->getAll($criteria);
136
        if (0 === count($downloadscatArray)) {
137
            redirect_header('index.php', 2, _NOPERM);
138
        }
139
        $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid');
140
        $form->addElement($mytree->makeSelectElement('cid', 'cat_title', '--', $this->getVar('cid'), true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true);
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('cid') can also be of type array and array; however, parameter $selected of XoopsObjectTree::makeSelectElement() 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

140
        $form->addElement($mytree->makeSelectElement('cid', 'cat_title', '--', /** @scrutinizer ignore-type */ $this->getVar('cid'), true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true);
Loading history...
141
142
        //affichage des champs
143
        /** @var \XoopsModules\Tdmdownloads\FieldHandler $fieldHandler */
144
        $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field');
145
        $criteria     = new \CriteriaCompo();
146
        $criteria->setSort('weight ASC, title');
147
        $criteria->setOrder('ASC');
148
        /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_field */
149
        $downloads_field = $fieldHandler->getAll($criteria);
150
        foreach (array_keys($downloads_field) as $i) {
151
            /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */
152
            if (1 == $downloads_field[$i]->getVar('status_def')) {
153
                if (1 == $downloads_field[$i]->getVar('fid')) {
154
                    //page d'accueil
155
                    if (1 == $downloads_field[$i]->getVar('status')) {
156
                        $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMHOMEPAGE, 'homepage', 50, 255, $this->getVar('homepage')));
157
                    } else {
158
                        $form->addElement(new \XoopsFormHidden('homepage', ''));
159
                    }
160
                }
161
                if (2 == $downloads_field[$i]->getVar('fid')) {
162
                    //version
163
                    if (1 == $downloads_field[$i]->getVar('status')) {
164
                        $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMVERSION, 'version', 10, 255, $this->getVar('version')));
165
                    } else {
166
                        $form->addElement(new \XoopsFormHidden('version', ''));
167
                    }
168
                }
169
                if (3 == $downloads_field[$i]->getVar('fid')) {
170
                    //taille du fichier
171
                    if (1 == $downloads_field[$i]->getVar('status')) {	
172
						$size_value_arr = explode(' ', $this->getVar('size'));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('size') can also be of type array and array; however, parameter $string of explode() 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

172
						$size_value_arr = explode(' ', /** @scrutinizer ignore-type */ $this->getVar('size'));
Loading history...
173
						$aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, '');
174
						$aff_size->addElement(new \XoopsFormText('', 'sizeValue', 13, 13, $size_value_arr[0]));
175
						if (array_key_exists (1, $size_value_arr) == false){
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
176
							$size_value_arr[1] = 'K';
177
						}
178
						$type     = new \XoopsFormSelect('', 'sizeType', $size_value_arr[1]);
179
						$typeArray = [
180
							'B' => _AM_TDMDOWNLOADS_BYTES,
181
							'K' => _AM_TDMDOWNLOADS_KBYTES,
182
							'M' => _AM_TDMDOWNLOADS_KBYTES,
183
							'G' => _AM_TDMDOWNLOADS_GBYTES,
184
							'T' => _AM_TDMDOWNLOADS_TBYTES
185
						];
186
						$type->addOptionArray($typeArray);
187
						$aff_size->addElement($type);
188
						$form->addElement($aff_size);
189
                    } else {
190
                        $form->addElement(new \XoopsFormHidden('size', ''));
191
                        $form->addElement(new \XoopsFormHidden('type_size', ''));
192
                    }
193
                }
194
                if (4 == $downloads_field[$i]->getVar('fid')) {
195
                    //plateforme
196
                    if (1 == $downloads_field[$i]->getVar('status')) {
197
                        $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', explode('|', $this->getVar('platform')), 5, true);
198
                        $platformArray = explode('|', $helper->getConfig('platform'));
199
                        foreach ($platformArray as $platform) {
200
                            $platformselect->addOption((string)$platform, $platform);
201
                        }
202
                        $form->addElement($platformselect, false);
203
                    } else {
204
                        $form->addElement(new \XoopsFormHidden('platform', ''));
205
                    }
206
                }
207
            } else {
208
                $contenu        = '';
209
                $contenu_iddata = '';
210
                $fieldName      = 'champ' . $downloads_field[$i]->getVar('fid');
211
                /** @var \XoopsModules\Tdmdownloads\FielddataHandler $fielddataHandler */
212
                $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata');
213
                $criteria         = new \CriteriaCompo();
214
                $criteria->add(new \Criteria('lid', $this->getVar('lid')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('lid') can also be of type array and array; however, parameter $value of Criteria::__construct() 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

214
                $criteria->add(new \Criteria('lid', /** @scrutinizer ignore-type */ $this->getVar('lid')));
Loading history...
215
                $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid')));
216
                $downloadsfielddata = $fielddataHandler->getAll($criteria);
217
                foreach (array_keys($downloadsfielddata) as $j) {
218
                    /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */
219
                    if (true === $erreur) {
220
                        $contenu = $donnee[$fieldName];
221
                    } else {
222
                        if (!$this->isNew()) {
223
                            $contenu = $downloadsfielddata[$j]->getVar('data');
224
                        }
225
                    }
226
                    $contenu_iddata = $downloadsfielddata[$j]->getVar('iddata');
227
                }
228
                $iddata = 'iddata' . $downloads_field[$i]->getVar('fid');
229
                if (!$this->isNew()) {
230
                    $form->addElement(new \XoopsFormHidden($iddata, $contenu_iddata));
231
                }
232
                if (1 == $downloads_field[$i]->getVar('status')) {
233
                    $form->addElement(new \XoopsFormText($downloads_field[$i]->getVar('title'), $fieldName, 50, 255, $contenu));
0 ignored issues
show
Bug introduced by
It seems like $downloads_field[$i]->getVar('title') can also be of type array and array; however, parameter $caption of XoopsFormText::__construct() 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

233
                    $form->addElement(new \XoopsFormText(/** @scrutinizer ignore-type */ $downloads_field[$i]->getVar('title'), $fieldName, 50, 255, $contenu));
Loading history...
234
                } else {
235
                    $form->addElement(new \XoopsFormHidden($fieldName, ''));
236
                }
237
            }
238
        }
239
        //description
240
        $editorConfigs           = [];
241
        $editorConfigs['name']   = 'description';
242
        $editorConfigs['value']  = $this->getVar('description', 'e');
243
        $editorConfigs['rows']   = 20;
244
        $editorConfigs['cols']   = 100;
245
        $editorConfigs['width']  = '100%';
246
        $editorConfigs['height'] = '400px';
247
        $editorConfigs['editor'] = $helper->getConfig('editor');
248
        $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS, 'description', $editorConfigs), true);
249
        //tag
250
251
        if ((1 == $helper->getConfig('usetag')) && class_exists(FormTag::class)) {
252
            $tagId = $this->isNew() ? 0 : $this->getVar('lid');
253
            if (true === $erreur) {
254
                $tagId = $donnee['TAG'];
255
            }
256
            $form->addElement(new \XoopsModules\Tag\FormTag('tag', 60, 255, $tagId, 0));
257
        }
258
259
        //image
260
        if ($helper->getConfig('useshots')) {
261
            $uploaddir        = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $this->getVar('logourl');
262
            $categoryImage = $this->getVar('logourl') ?: 'blank.gif';
263
            if (!is_file($uploaddir)) {
264
                $categoryImage = 'blank.gif';
265
            }
266
            $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots';
267
            $imgtray        = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '<br>');
268
            $imgpath        = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory);
269
            $imageselect    = new \XoopsFormSelect($imgpath, 'logo_img', $categoryImage);
270
            $topics_array   = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory);
271
            foreach ($topics_array as $image) {
272
                $imageselect->addOption((string)$image, $image);
273
            }
274
            $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"logo_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'");
275
            $imgtray->addElement($imageselect, false);
276
            $imgtray->addElement(new \XoopsFormLabel('', "<br><img src='" . XOOPS_URL . '/' . $uploadirectory . '/' . $categoryImage . "' name='image3' id='image3' alt=''>"));
277
            $fileseltray = new \XoopsFormElementTray('', '<br>');
278
            if (true === $perm_upload) {
279
                $fileseltray->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedimage', $helper->getConfig('maxuploadsize')), false);
280
            }
281
            $imgtray->addElement($fileseltray);
282
            $form->addElement($imgtray);
283
        }
284
        // pour changer de poster et pour ne pas mettre à jour la date:
285
286
        if ($xoopsUser) {
287
            if ($xoopsUser->isAdmin($xoopsModule->mid())) {
288
                // auteur
289
                if ($this->isNew()) {
290
                    $submitter             = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
291
                    $donnee['date_update'] = 0;
292
                } else {
293
                    $submitter = $this->getVar('submitter');
294
                    $v_date    = $this->getVar('date');
295
                }
296
                if (true === $erreur) {
297
                    $date_update = $donnee['date_update'];
298
                    $v_status    = $donnee['status'];
299
                    $submitter   = $donnee['submitter'];
300
                } else {
301
                    $date_update = 'N';
302
                    $v_status    = 1;
303
                }
304
                $form->addElement(new \XoopsFormSelectUser(_AM_TDMDOWNLOADS_FORMSUBMITTER, 'submitter', true, $submitter, 1, false), true);
305
306
                // date
307
                if (!$this->isNew()) {
308
                    $selection_date = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMDATEUPDATE);
309
                    $date           = new \XoopsFormRadio('', 'date_update', $date_update);
310
                    $options        = [
311
                        'N' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_NO . ' (' . formatTimestamp($v_date, 's') . ')',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $v_date does not seem to be defined for all execution paths leading up to this point.
Loading history...
312
                        'Y' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_YES,
313
                    ];
314
                    $date->addOptionArray($options);
315
                    $selection_date->addElement($date);
316
                    $selection_date->addElement(new \XoopsFormTextDateSelect('', 'date', '', time()));
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type integer expected by parameter $size of XoopsFormTextDateSelect::__construct(). ( Ignorable by Annotation )

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

316
                    $selection_date->addElement(new \XoopsFormTextDateSelect('', 'date', /** @scrutinizer ignore-type */ '', time()));
Loading history...
317
                    $form->addElement($selection_date);
318
                }
319
                $status = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMSTATUS, 'status', $v_status);
320
                $status->addOption(1, _AM_TDMDOWNLOADS_FORMSTATUS_OK);
321
                $form->addElement($status);
322
                //permissions pour télécharger
323
                if (2 == $helper->getConfig('permission_download')) {
324
                    /** @var \XoopsMemberHandler $memberHandler */
325
                    $memberHandler    = xoops_getHandler('member');
326
                    $group_list       = $memberHandler->getGroupList();
327
                    $grouppermHandler = xoops_getHandler('groupperm');
328
                    $full_list        = array_keys($group_list);
329
                    global $xoopsModule;
330
                    if (!$this->isNew()) {
331
                        $item_ids_download               = $grouppermHandler->getGroupIds('tdmdownloads_download_item', $this->getVar('lid'), $xoopsModule->getVar('mid'));
0 ignored issues
show
Bug introduced by
The method getGroupIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

331
                        /** @scrutinizer ignore-call */ 
332
                        $item_ids_download               = $grouppermHandler->getGroupIds('tdmdownloads_download_item', $this->getVar('lid'), $xoopsModule->getVar('mid'));
Loading history...
332
                        $item_ids_downloa                = array_values($item_ids_download);
0 ignored issues
show
Unused Code introduced by
The assignment to $item_ids_downloa is dead and can be removed.
Loading history...
333
                        $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $item_ids_download);
334
                    } else {
335
                        $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $full_list);
336
                    }
337
                    $item_news_can_download_checkbox->addOptionArray($group_list);
338
                    $form->addElement($item_news_can_download_checkbox);
339
                }
340
            }
341
        }
342
        //paypal
343
        if (true === $helper->getConfig('use_paypal')) {
344
            $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMPAYPAL, 'paypal', 50, 255, $this->getVar('paypal')), false);
345
        } else {
346
            $form->addElement(new \XoopsFormHidden('paypal', ''));
347
        }
348
        // captcha
349
        $form->addElement(new \XoopsFormCaptcha(), true);
350
        // pour passer "lid" si on modifie la catégorie
351
        if (!$this->isNew()) {
352
            $form->addElement(new \XoopsFormHidden('lid', $this->getVar('lid')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('lid') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() 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

352
            $form->addElement(new \XoopsFormHidden('lid', /** @scrutinizer ignore-type */ $this->getVar('lid')));
Loading history...
353
            $form->addElement(new \XoopsFormHidden('downloads_modified', true));
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type string expected by parameter $value of XoopsFormHidden::__construct(). ( Ignorable by Annotation )

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

353
            $form->addElement(new \XoopsFormHidden('downloads_modified', /** @scrutinizer ignore-type */ true));
Loading history...
354
        }
355
        //pour enregistrer le formulaire
356
        $form->addElement(new \XoopsFormHidden('op', 'save_downloads'));
357
        //bouton d'envoi du formulaire
358
        $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', 'submit', false));
359
360
        return $form;
361
    }
362
}
363