|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Wfdownloads; |
|
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
|
|
|
* Wfdownloads module |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
20
|
|
|
* @package wfdownload |
|
21
|
|
|
* @since 3.23 |
|
22
|
|
|
* @author Xoops Development Team |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
use XoopsModules\Wfdownloads; |
|
26
|
|
|
|
|
27
|
|
|
/* |
|
28
|
|
|
CREATE TABLE wfdownloads_mimetypes ( |
|
29
|
|
|
mime_id int(11) NOT NULL auto_increment, |
|
30
|
|
|
mime_ext varchar(60) NOT NULL default '', |
|
31
|
|
|
mime_types text NOT NULL, |
|
32
|
|
|
mime_name varchar(255) NOT NULL default '', |
|
33
|
|
|
mime_admin int(1) NOT NULL default '1', |
|
34
|
|
|
mime_user int(1) NOT NULL default '0', |
|
35
|
|
|
KEY mime_id (mime_id) |
|
36
|
|
|
) ENGINE=MyISAM; |
|
37
|
|
|
*/ |
|
38
|
|
|
|
|
39
|
|
|
require_once \dirname(__DIR__) . '/include/common.php'; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Class Mimetype |
|
43
|
|
|
*/ |
|
44
|
|
|
class Mimetype extends \XoopsObject |
|
45
|
|
|
{ |
|
46
|
|
|
/** |
|
47
|
|
|
* @access public |
|
48
|
|
|
*/ |
|
49
|
|
|
public $helper; |
|
50
|
|
|
public $db; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param int|null $id |
|
54
|
|
|
*/ |
|
55
|
|
|
public function __construct($id = null) |
|
56
|
|
|
{ |
|
57
|
|
|
/** @var \XoopsModules\Wfdownloads\Helper $this ->helper */ |
|
58
|
|
|
$this->helper = Helper::getInstance(); |
|
|
|
|
|
|
59
|
|
|
$this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
|
|
|
|
|
60
|
|
|
$this->initVar('mime_id', \XOBJ_DTYPE_INT); |
|
|
|
|
|
|
61
|
|
|
$this->initVar('mime_ext', \XOBJ_DTYPE_TXTBOX, ''); |
|
62
|
|
|
$this->initVar('mime_types', \XOBJ_DTYPE_TXTAREA, ''); |
|
63
|
|
|
$this->initVar('mime_name', \XOBJ_DTYPE_TXTBOX, ''); |
|
64
|
|
|
$this->initVar('mime_admin', \XOBJ_DTYPE_INT, true); // boolean |
|
65
|
|
|
$this->initVar('mime_user', \XOBJ_DTYPE_INT, false); // boolean |
|
66
|
|
|
|
|
67
|
|
|
if (null !== $id) { |
|
68
|
|
|
$item = $this->helper->getHandler('Item')->get($id); |
|
69
|
|
|
foreach ($item->vars as $k => $v) { |
|
70
|
|
|
$this->assignVar($k, $v['value']); |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param bool $action |
|
77
|
|
|
* |
|
78
|
|
|
* @return \XoopsThemeForm |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getForm($action = false) |
|
81
|
|
|
{ |
|
82
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
83
|
|
|
|
|
84
|
|
|
if (!$action) { |
|
85
|
|
|
$action = $_SERVER['REQUEST_URI']; |
|
86
|
|
|
} |
|
87
|
|
|
$title = $this->isNew() ? \_AM_WFDOWNLOADS_MIME_CREATEF : \_AM_WFDOWNLOADS_MIME_MODIFYF; |
|
88
|
|
|
|
|
89
|
|
|
$form = new \XoopsThemeForm($title, 'form_error', $action, 'post', true); |
|
90
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
91
|
|
|
// mime_ext |
|
92
|
|
|
$mime_ext_text = new \XoopsFormText(\_AM_WFDOWNLOADS_MIME_EXTF, 'mime_ext', 5, 60, $this->getVar('mime_ext', 'e')); |
|
|
|
|
|
|
93
|
|
|
$mime_ext_text->setDescription(\_AM_WFDOWNLOADS_MIME_EXTF_DESC); |
|
94
|
|
|
$form->addElement($mime_ext_text, true); |
|
95
|
|
|
// mime_name |
|
96
|
|
|
$mime_name_text = new \XoopsFormText(\_AM_WFDOWNLOADS_MIME_NAMEF, 'mime_name', 50, 255, $this->getVar('mime_name', 'e')); |
|
97
|
|
|
$mime_name_text->setDescription(\_AM_WFDOWNLOADS_MIME_NAMEF_DESC); |
|
98
|
|
|
$form->addElement($mime_name_text, true); |
|
99
|
|
|
// mime_type |
|
100
|
|
|
$mime_type_textarea = new \XoopsFormTextArea(\_AM_WFDOWNLOADS_MIME_TYPEF, 'mime_type', $this->getVar('mime_types', 'e')); |
|
|
|
|
|
|
101
|
|
|
$mime_type_textarea->setDescription(\_AM_WFDOWNLOADS_MIME_TYPEF_DESC); |
|
102
|
|
|
$form->addElement($mime_type_textarea, 7, 60); |
|
|
|
|
|
|
103
|
|
|
// mime_admin |
|
104
|
|
|
$madmin_radio = new \XoopsFormRadioYN(\_AM_WFDOWNLOADS_MIME_ADMINF, 'mime_admin', $this->getVar('mime_admin', 'e')); |
|
|
|
|
|
|
105
|
|
|
$form->addElement($madmin_radio); |
|
106
|
|
|
// mime_user |
|
107
|
|
|
$muser_radio = new \XoopsFormRadioYN(\_AM_WFDOWNLOADS_MIME_USERF, 'mime_user', $this->getVar('mime_user', 'e')); |
|
108
|
|
|
$form->addElement($muser_radio); |
|
109
|
|
|
// op |
|
110
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
111
|
|
|
// buttons |
|
112
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
|
113
|
|
|
if ($this->isNew()) { |
|
114
|
|
|
$butt_create = new \XoopsFormButton('', '', \_AM_WFDOWNLOADS_MIME_CREATE, 'submit'); |
|
115
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'mimetype.save\'"'); |
|
116
|
|
|
$buttonTray->addElement($butt_create); |
|
117
|
|
|
$butt_clear = new \XoopsFormButton('', '', \_AM_WFDOWNLOADS_MIME_CLEAR, 'reset'); |
|
118
|
|
|
$buttonTray->addElement($butt_clear); |
|
119
|
|
|
$butt_cancel = new \XoopsFormButton('', '', \_AM_WFDOWNLOADS_MIME_CANCEL, 'button'); |
|
120
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
|
121
|
|
|
$buttonTray->addElement($butt_cancel); |
|
122
|
|
|
} else { |
|
123
|
|
|
$form->addElement(new \XoopsFormHidden('mime_id', $this->getVar('mime_id'))); |
|
|
|
|
|
|
124
|
|
|
$butt_create = new \XoopsFormButton('', '', \_AM_WFDOWNLOADS_MIME_MODIFY, 'submit'); |
|
125
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'mimetype.save\'"'); |
|
126
|
|
|
$buttonTray->addElement($butt_create); |
|
127
|
|
|
$butt_cancel = new \XoopsFormButton('', '', \_AM_WFDOWNLOADS_MIME_CANCEL, 'button'); |
|
128
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
|
129
|
|
|
$buttonTray->addElement($butt_cancel); |
|
130
|
|
|
} |
|
131
|
|
|
$form->addElement($buttonTray); |
|
132
|
|
|
|
|
133
|
|
|
return $form; |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|