PicturesForm::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 39
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 39
rs 9.6
cc 2
nc 2
nop 1
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Adslight\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: Adslight
17
 *
18
 * @category        Module
19
 * @author          XOOPS Development Team <https://xoops.org>
20
 * @copyright       {@link https://xoops.org/ XOOPS Project}
21
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
22
 */
23
24
use Xmf\Request;
25
use XoopsModules\Adslight;
26
27
require_once \dirname(__DIR__, 2) . '/include/common.php';
28
29
$moduleDirName = \basename(\dirname(__DIR__, 2));
30
//$helper = Adslight\Helper::getInstance();
31
$permHelper = new \Xmf\Module\Helper\Permission();
32
33
\xoops_load('XoopsFormLoader');
34
35
/**
36
 * Class PicturesForm
37
 */
38
class PicturesForm extends \XoopsThemeForm
39
{
40
    public $targetObject;
41
    public $helper;
42
43
    /**
44
     * Constructor
45
     *
46
     * @param $target
47
     */
48
    public function __construct($target)
49
    {
50
        $this->helper       = $target->helper;
51
        $this->targetObject = $target;
52
53
        $title = $this->targetObject->isNew() ? \AM_ADSLIGHT_PICTURES_ADD : \AM_ADSLIGHT_PICTURES_EDIT;
54
        parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true);
55
        $this->setExtra('enctype="multipart/form-data"');
56
57
        //include ID field, it's needed so the module knows if it is a new form or an edited form
58
59
        $hidden = new \XoopsFormHidden('cod_img', $this->targetObject->getVar('cod_img'));
60
        $this->addElement($hidden);
61
        unset($hidden);
62
63
        // Cod_img
64
        $this->addElement(new \XoopsFormLabel(\AM_ADSLIGHT_PICTURES_COD_IMG, $this->targetObject->getVar('cod_img'), 'cod_img'));
65
        // Title
66
        $this->addElement(new \XoopsFormText(\AM_ADSLIGHT_PICTURES_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')), false);
67
        // Date_created
68
        $this->addElement(new \XoopsFormTextDateSelect(\AM_ADSLIGHT_PICTURES_DATE_CREATED, 'date_created', 0, \formatTimestamp($this->targetObject->getVar('date_created'), 's')));
0 ignored issues
show
Bug introduced by
formatTimestamp($this->t...r('date_created'), 's') of type string is incompatible with the type integer expected by parameter $value 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

68
        $this->addElement(new \XoopsFormTextDateSelect(\AM_ADSLIGHT_PICTURES_DATE_CREATED, 'date_created', 0, /** @scrutinizer ignore-type */ \formatTimestamp($this->targetObject->getVar('date_created'), 's')));
Loading history...
69
        // Date_updated
70
        $this->addElement(new \XoopsFormTextDateSelect(\AM_ADSLIGHT_PICTURES_DATE_UPDATED, 'date_updated', 0, \formatTimestamp($this->targetObject->getVar('date_updated'), 's')));
71
        // Lid
72
        //$listingHandler = $this->helper->getHandler('Listing');
73
        //$db     = \XoopsDatabaseFactory::getDatabaseConnection();
74
        /** @var \XoopsPersistableObjectHandler $listingHandler */
75
        $listingHandler = $this->helper->getHandler('Listing');
76
77
        $listing_id_select = new \XoopsFormSelect(\AM_ADSLIGHT_PICTURES_LID, 'lid', $this->targetObject->getVar('lid'));
78
        $listing_id_select->addOptionArray($listingHandler->getList());
79
        $this->addElement($listing_id_select, false);
80
        // Uid_owner
81
        $this->addElement(new \XoopsFormSelectUser(\AM_ADSLIGHT_PICTURES_UID_OWNER, 'uid_owner', false, $this->targetObject->getVar('uid_owner'), 1, false), false);
82
        // Url
83
        $this->addElement(new \XoopsFormTextArea(\AM_ADSLIGHT_PICTURES_URL, 'url', $this->targetObject->getVar('url'), 4, 47), false);
84
85
        $this->addElement(new \XoopsFormHidden('op', 'save'));
86
        $this->addElement(new \XoopsFormButton('', 'submit', \_SUBMIT, 'submit'));
87
    }
88
}
89