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
|
|
|
* Module: Yogurt |
19
|
|
|
* |
20
|
|
|
* @category Module |
21
|
|
|
* @package yogurt |
22
|
|
|
* @author XOOPS Development Team <https://xoops.org> |
23
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
24
|
|
|
* @license GPL 2.0 or later |
25
|
|
|
* @link https://xoops.org/ |
26
|
|
|
* @since 1.0.0 |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
use Xmf\Module\Helper\Permission; |
30
|
|
|
use XoopsFormButton; |
31
|
|
|
use XoopsFormDateTime; |
32
|
|
|
use XoopsFormEditor; |
33
|
|
|
use XoopsFormHidden; |
34
|
|
|
use XoopsFormLabel; |
35
|
|
|
use XoopsFormSelectUser; |
36
|
|
|
use XoopsFormText; |
37
|
|
|
use XoopsFormTextDateSelect; |
38
|
|
|
use XoopsModules\Yogurt; |
39
|
|
|
use XoopsThemeForm; |
40
|
|
|
|
41
|
|
|
require_once \dirname(__DIR__, 2) . '/include/common.php'; |
42
|
|
|
|
43
|
|
|
$moduleDirName = \basename(\dirname(__DIR__, 2)); |
44
|
|
|
//$helper = Yogurt\Helper::getInstance(); |
45
|
|
|
$permHelper = new Permission(); |
46
|
|
|
|
47
|
|
|
\xoops_load('XoopsFormLoader'); |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Class AudioForm |
51
|
|
|
*/ |
52
|
|
|
class AudioForm extends XoopsThemeForm |
53
|
|
|
{ |
54
|
|
|
public $targetObject; |
55
|
|
|
|
56
|
|
|
public $helper; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Constructor |
60
|
|
|
* |
61
|
|
|
* @param $target |
62
|
|
|
*/ |
63
|
|
|
public function __construct($target) |
64
|
|
|
{ |
65
|
|
|
$this->helper = $target->helper; |
66
|
|
|
$this->targetObject = $target; |
67
|
|
|
|
68
|
|
|
$title = $this->targetObject->isNew() ? \sprintf(\AM_YOGURT_AUDIO_ADD) : \sprintf(\AM_YOGURT_AUDIO_EDIT); |
69
|
|
|
parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); |
70
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
71
|
|
|
|
72
|
|
|
//include ID field, it's needed so the module knows if it is a new form or an edited form |
73
|
|
|
|
74
|
|
|
$hidden = new XoopsFormHidden( |
75
|
|
|
'audio_id', $this->targetObject->getVar( |
76
|
|
|
'audio_id' |
77
|
|
|
) |
78
|
|
|
); |
79
|
|
|
$this->addElement($hidden); |
80
|
|
|
unset($hidden); |
81
|
|
|
|
82
|
|
|
// Audio_id |
83
|
|
|
$this->addElement( |
84
|
|
|
new XoopsFormLabel(\AM_YOGURT_AUDIO_AUDIO_ID, $this->targetObject->getVar('audio_id'), 'audio_id') |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
// Uid_owner |
88
|
|
|
$this->addElement( |
89
|
|
|
new XoopsFormSelectUser( |
90
|
|
|
\AM_YOGURT_AUDIO_UID_OWNER, 'uid_owner', false, $this->targetObject->getVar( |
91
|
|
|
'uid_owner' |
92
|
|
|
), 1, false |
93
|
|
|
), |
94
|
|
|
false |
95
|
|
|
); |
96
|
|
|
// Title |
97
|
|
|
$this->addElement( |
98
|
|
|
new XoopsFormText(\AM_YOGURT_AUDIO_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')), |
99
|
|
|
false |
100
|
|
|
); |
101
|
|
|
// Author |
102
|
|
|
$this->addElement( |
103
|
|
|
new XoopsFormText(\AM_YOGURT_AUDIO_AUTHOR, 'author', 50, 255, $this->targetObject->getVar('author')), |
104
|
|
|
false |
105
|
|
|
); |
106
|
|
|
|
107
|
|
|
// Description |
108
|
|
|
if (\class_exists('XoopsFormEditor')) { |
109
|
|
|
$editorOptions = []; |
110
|
|
|
$editorOptions['name'] = 'description'; |
111
|
|
|
$editorOptions['value'] = $this->targetObject->getVar('description', 'e'); |
112
|
|
|
$editorOptions['rows'] = 5; |
113
|
|
|
$editorOptions['cols'] = 40; |
114
|
|
|
$editorOptions['width'] = '100%'; |
115
|
|
|
$editorOptions['height'] = '400px'; |
116
|
|
|
//$editorOptions['editor'] = xoops_getModuleOption('yogurt_editor', 'yogurt'); |
117
|
|
|
//$this->addElement( new \XoopsFormEditor(AM_YOGURT_AUDIO_DESCRIPTION, 'description', $editorOptions), false ); |
118
|
|
|
if ($this->helper->isUserAdmin()) { |
119
|
|
|
$descEditor = new XoopsFormEditor( |
120
|
|
|
\AM_YOGURT_AUDIO_DESCRIPTION, $this->helper->getConfig( |
121
|
|
|
'yogurtEditorAdmin' |
122
|
|
|
), $editorOptions, $nohtml = false, $onfailure = 'textarea' |
123
|
|
|
); |
124
|
|
|
} else { |
125
|
|
|
$descEditor = new XoopsFormEditor( |
126
|
|
|
\AM_YOGURT_AUDIO_DESCRIPTION, $this->helper->getConfig( |
127
|
|
|
'yogurtEditorUser' |
128
|
|
|
), $editorOptions, $nohtml = false, $onfailure = 'textarea' |
129
|
|
|
); |
130
|
|
|
} |
131
|
|
|
} else { |
132
|
|
|
$descEditor = new XoopsFormDhtmlTextArea( |
|
|
|
|
133
|
|
|
\AM_YOGURT_AUDIO_DESCRIPTION, 'description', $this->targetObject->getVar( |
134
|
|
|
'description', |
135
|
|
|
'e' |
136
|
|
|
), 5, 50 |
137
|
|
|
); |
138
|
|
|
} |
139
|
|
|
$this->addElement($descEditor); |
140
|
|
|
// Url |
141
|
|
|
$this->addElement(new \XoopsFormFile(\AM_YOGURT_AUDIO_URL, 'filename', $this->helper->getConfig('maxsize')), false); |
142
|
|
|
|
143
|
|
|
// Data_creation |
144
|
|
|
$this->addElement( |
145
|
|
|
new XoopsFormTextDateSelect( |
146
|
|
|
\AM_YOGURT_AUDIO_DATE_CREATED, 'date_created', 0, formatTimestamp($this->targetObject->getVar('date_created'), 's') |
|
|
|
|
147
|
|
|
) |
148
|
|
|
); |
149
|
|
|
|
150
|
|
|
$this->addElement( |
151
|
|
|
new XoopsFormTextDateSelect( |
152
|
|
|
\AM_YOGURT_AUDIO_DATE_UPDATED, 'date_updated', 0, formatTimestamp($this->targetObject->getVar('date_updated'), 's') |
153
|
|
|
) |
154
|
|
|
); |
155
|
|
|
|
156
|
|
|
$this->addElement(new XoopsFormHidden('op', 'save')); |
157
|
|
|
$this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|