Passed
Pull Request — master (#81)
by Michael
02:55
created

VideoForm   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 43
dl 0
loc 99
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 87 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Yogurt\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
/**
18
 * @category        Module
19
 * @package         yogurt
20
 * @copyright       {@link https://xoops.org/ XOOPS Project}
21
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
22
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
23
 */
24
25
use Xmf\Module\Helper\Permission;
26
use XoopsFormButton;
27
use XoopsFormHidden;
28
use XoopsFormLabel;
29
use XoopsFormSelectUser;
30
use XoopsFormText;
31
use XoopsFormTextArea;
32
use XoopsModules\Yogurt;
33
use XoopsThemeForm;
34
35
require_once \dirname(__DIR__, 2) . '/include/common.php';
36
37
$moduleDirName = \basename(\dirname(__DIR__, 2));
38
//$helper = Yogurt\Helper::getInstance();
39
$permHelper = new Permission();
40
41
\xoops_load('XoopsFormLoader');
42
43
/**
44
 * Class VideoForm
45
 */
46
class VideoForm extends XoopsThemeForm
47
{
48
    public $targetObject;
49
50
    public $helper;
51
52
    /**
53
     * Constructor
54
     *
55
     * @param $target
56
     */
57
58
    public function __construct($target)
59
    {
60
        $this->helper = $target->helper;
61
62
        $this->targetObject = $target;
63
64
        $title = $this->targetObject->isNew() ? \sprintf(\AM_YOGURT_VIDEO_ADD) : \sprintf(\AM_YOGURT_VIDEO_EDIT);
65
66
        parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true);
67
68
        $this->setExtra('enctype="multipart/form-data"');
69
70
        //include ID field, it's needed so the module knows if it is a new form or an edited form
71
72
        $hidden = new XoopsFormHidden(
73
            'video_id', $this->targetObject->getVar(
74
            'video_id'
75
        )
76
        );
77
78
        $this->addElement($hidden);
79
80
        unset($hidden);
81
82
        // Video_id
83
84
        $this->addElement(
85
            new XoopsFormLabel(\AM_YOGURT_VIDEO_VIDEO_ID, $this->targetObject->getVar('video_id'), 'video_id')
86
        );
87
88
        // Uid_owner
89
90
        $this->addElement(
91
            new XoopsFormSelectUser(
92
                \AM_YOGURT_VIDEO_UID_OWNER, 'uid_owner', false, $this->targetObject->getVar(
93
                'uid_owner'
94
            ), 1, false
95
            ),
96
            false
97
        );
98
99
        // Video_desc
100
101
        $this->addElement(
102
            new XoopsFormTextArea(
103
                \AM_YOGURT_VIDEO_VIDEO_DESC, 'video_desc', $this->targetObject->getVar(
104
                'video_desc'
105
            ), 4, 47
106
            ),
107
            false
108
        );
109
110
        // Youtube_code
111
112
        $this->addElement(
113
            new XoopsFormText(
114
                \AM_YOGURT_VIDEO_YOUTUBE_CODE, 'youtube_code', 50, 255, $this->targetObject->getVar(
115
                'youtube_code'
116
            )
117
            ),
118
            false
119
        );
120
121
        // Main_video
122
123
        $this->addElement(
124
            new XoopsFormText(
125
                \AM_YOGURT_VIDEO_MAIN_VIDEO, 'main_video', 50, 255, $this->targetObject->getVar(
126
                'main_video'
127
            )
128
            ),
129
            false
130
        );
131
132
        // Data_creation
133
134
        $this->addElement(new \XoopsFormTextDateSelect(\AM_YOGURT_VIDEO_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

134
        $this->addElement(new \XoopsFormTextDateSelect(\AM_YOGURT_VIDEO_DATE_CREATED, 'date_created', 0, /** @scrutinizer ignore-type */ \formatTimestamp($this->targetObject->getVar('date_created'), 's')));
Loading history...
135
136
        $this->addElement(
137
            new \XoopsFormTextDateSelect(
138
                \AM_YOGURT_VIDEO_DATE_UPDATED, 'date_updated', 0, \formatTimestamp($this->targetObject->getVar('date_updated'), 's')
139
            )
140
        );
141
142
        $this->addElement(new XoopsFormHidden('op', 'save'));
143
144
        $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit'));
145
    }
146
}
147