Passed
Push — master ( 4761c2...696f77 )
by
unknown
05:50 queued 19s
created

class/Form/AudioForm.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Suico\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         suico
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 XoopsFormEditor;
28
use XoopsFormHidden;
29
use XoopsFormLabel;
30
use XoopsFormSelectUser;
31
use XoopsFormText;
32
use XoopsFormTextDateSelect;
33
use XoopsModules\Suico;
34
use XoopsThemeForm;
35
36
require_once \dirname(__DIR__, 2) . '/include/common.php';
37
$moduleDirName = \basename(\dirname(__DIR__, 2));
38
//$helper = Suico\Helper::getInstance();
39
$permHelper = new Permission();
40
\xoops_load('XoopsFormLoader');
41
42
/**
43
 * Class AudioForm
44
 */
45
class AudioForm extends XoopsThemeForm
46
{
47
    public $targetObject;
48
    public $helper;
49
50
    /**
51
     * Constructor
52
     *
53
     * @param $target
54
     */
55
    public function __construct($target)
56
    {
57
        $this->helper       = $target->helper;
58
        $this->targetObject = $target;
59
        $title              = $this->targetObject->isNew() ? \sprintf(\AM_SUICO_AUDIO_ADD) : \sprintf(\AM_SUICO_AUDIO_EDIT);
60
        parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true);
61
        $this->setExtra('enctype="multipart/form-data"');
62
        //include ID field, it's needed so the module knows if it is a new form or an edited form
63
        $hidden = new XoopsFormHidden(
64
            'audio_id', $this->targetObject->getVar(
65
            'audio_id'
66
        )
67
        );
68
        $this->addElement($hidden);
69
        unset($hidden);
70
        // Audio_id
71
        $this->addElement(
72
            new XoopsFormLabel(\AM_SUICO_AUDIO_AUDIO_ID, $this->targetObject->getVar('audio_id'), 'audio_id')
73
        );
74
        // Uid_owner
75
        $this->addElement(
76
            new XoopsFormSelectUser(
77
                \AM_SUICO_AUDIO_UID_OWNER, 'uid_owner', false, $this->targetObject->getVar(
78
                'uid_owner'
79
            ), 1, false
80
            ),
81
            false
82
        );
83
        // Title
84
        $this->addElement(
85
            new XoopsFormText(\AM_SUICO_AUDIO_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')),
86
            false
87
        );
88
        // Author
89
        $this->addElement(
90
            new XoopsFormText(\AM_SUICO_AUDIO_AUTHOR, 'author', 50, 255, $this->targetObject->getVar('author')),
91
            false
92
        );
93
        // Description
94
        if (\class_exists('XoopsFormEditor')) {
95
            $editorOptions           = [];
96
            $editorOptions['name']   = 'description';
97
            $editorOptions['value']  = $this->targetObject->getVar('description', 'e');
98
            $editorOptions['rows']   = 5;
99
            $editorOptions['cols']   = 40;
100
            $editorOptions['width']  = '100%';
101
            $editorOptions['height'] = '400px';
102
            //$editorOptions['editor'] = xoops_getModuleOption('suico_editor', 'suico');
103
            //$this->addElement( new \XoopsFormEditor(AM_SUICO_AUDIO_DESCRIPTION, 'description', $editorOptions), false  );
104
            if ($this->helper->isUserAdmin()) {
105
                $descEditor = new XoopsFormEditor(
106
                    \AM_SUICO_AUDIO_DESCRIPTION, $this->helper->getConfig(
107
                    'suicoEditorAdmin'
108
                ), $editorOptions, $nohtml = false, $onfailure = 'textarea'
109
                );
110
            } else {
111
                $descEditor = new XoopsFormEditor(
112
                    \AM_SUICO_AUDIO_DESCRIPTION, $this->helper->getConfig(
113
                    'suicoEditorUser'
114
                ), $editorOptions, $nohtml = false, $onfailure = 'textarea'
115
                );
116
            }
117
        } else {
118
            $descEditor = new \XoopsFormDhtmlTextArea(
119
                \AM_SUICO_AUDIO_DESCRIPTION, 'description', $this->targetObject->getVar(
120
                'description',
121
                'e'
122
            ), 5, 50
123
            );
124
        }
125
        $this->addElement($descEditor);
126
        // Url
127
        $this->addElement(new \XoopsFormFile(\AM_SUICO_AUDIO_URL, 'filename', $this->helper->getConfig('maxsize')), false);
128
        // Data_creation
129
        $this->addElement(
130
            new XoopsFormTextDateSelect(
131
                \AM_SUICO_AUDIO_DATE_CREATED, 'date_created', 0, \formatTimestamp($this->targetObject->getVar('date_created'), 's')
0 ignored issues
show
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

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