Passed
Push — master ( 6af1fb...f5fe55 )
by Michael
02:53 queued 10s
created

PicturesForm::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 43
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 43
rs 9.6
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Adslight\Form;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
 
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
*/
16
/**
17
 * Module: Adslight
18
 *
19
 * @category        Module
20
 * @author          XOOPS Development Team <https://xoops.org>
21
 * @copyright       {@link https://xoops.org/ XOOPS Project}
22
 * @license         GPL 2.0 or later
23
 */
24
25
use Xmf\Request;
26
use XoopsModules\Adslight;
27
28
29
require_once \dirname(dirname(__DIR__)) . '/include/common.php';
30
31
$moduleDirName = basename(dirname(__DIR__, 2));
32
//$helper = Adslight\Helper::getInstance();
33
$permHelper = new \Xmf\Module\Helper\Permission();
34
35
xoops_load('XoopsFormLoader');
36
/**
37
 * Class PicturesForm
38
 */
39
class PicturesForm extends \XoopsThemeForm
40
{
41
    public $targetObject;
42
    public $helper;
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() ? sprintf(AM_ADSLIGHT_PICTURES_ADD) : sprintf(AM_ADSLIGHT_PICTURES_EDIT);
54
        parent::__construct($title, 'form', xoops_getenv('SCRIPT_NAME'),'post', true);
55
        $this->setExtra('enctype="multipart/form-data"');
56
        
57
58
59
        //include ID field, it's needed so the module knows if it is a new form or an edited form
60
        
61
62
        $hidden = new \XoopsFormHidden('cod_img', $this->targetObject->getVar('cod_img'));
63
        $this->addElement($hidden);
64
        unset($hidden);
65
        
66
// Cod_img
67
            $this->addElement(new \XoopsFormLabel(AM_ADSLIGHT_PICTURES_COD_IMG, $this->targetObject->getVar('cod_img'), 'cod_img' ));
68
            // Title
69
        $this->addElement(new \XoopsFormText(AM_ADSLIGHT_PICTURES_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')), false);
70
        // Date_created
71
        $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

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