1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Publisher; |
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
|
|
|
* Publisher class |
17
|
|
|
* |
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
19
|
|
|
* @license https://www.fsf.org/copyleft/gpl.html GNU public license |
20
|
|
|
* @since 1.0 |
21
|
|
|
* @author trabis <[email protected]> |
22
|
|
|
* @author The SmartFactory <www.smartfactory.ca> |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use Xmf\Request; |
26
|
|
|
|
27
|
|
|
require_once \dirname(__DIR__) . '/include/common.php'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class MimetypesUtility |
31
|
|
|
*/ |
32
|
|
|
class MimetypesUtility |
33
|
|
|
{ |
34
|
|
|
public static function add(): void |
35
|
|
|
{ |
36
|
|
|
$helper = Helper::getInstance(); |
37
|
|
|
/** @var MimetypeHandler $mimetypeHandler */ |
38
|
|
|
$mimetypeHandler = $helper->getHandler('Mimetype'); |
39
|
|
|
global $limit, $start; |
40
|
|
|
$error = []; |
41
|
|
|
if (Request::getString('add_mime', '', 'POST')) { |
42
|
|
|
$hasErrors = false; |
43
|
|
|
$mimeExt = Request::getString('mime_ext', '', 'POST'); |
44
|
|
|
$mimeName = Request::getString('mime_name', '', 'POST'); |
45
|
|
|
$mimeTypes = Request::getText('mime_types', '', 'POST'); |
46
|
|
|
$mimeAdmin = Request::getInt('mime_admin', 0, 'POST'); |
47
|
|
|
$mimeUser = Request::getInt('mime_user', 0, 'POST'); |
48
|
|
|
|
49
|
|
|
//Validate Mimetype entry |
50
|
|
|
if ('' === \trim($mimeExt)) { |
51
|
|
|
$hasErrors = true; |
52
|
|
|
$error['mime_ext'][] = \_AM_PUBLISHER_VALID_ERR_MIME_EXT; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if ('' === \trim($mimeName)) { |
56
|
|
|
$hasErrors = true; |
57
|
|
|
$error['mime_name'][] = \_AM_PUBLISHER_VALID_ERR_MIME_NAME; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if ('' === \trim($mimeTypes)) { |
61
|
|
|
$hasErrors = true; |
62
|
|
|
$error['mime_types'][] = \_AM_PUBLISHER_VALID_ERR_MIME_TYPES; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if ($hasErrors) { |
66
|
|
|
$session = Session::getInstance(); |
67
|
|
|
$mime = []; |
68
|
|
|
$mime['mime_ext'] = $mimeExt; |
69
|
|
|
$mime['mime_name'] = $mimeName; |
70
|
|
|
$mime['mime_types'] = $mimeTypes; |
71
|
|
|
$mime['mime_admin'] = $mimeAdmin; |
72
|
|
|
$mime['mime_user'] = $mimeUser; |
73
|
|
|
$session->set('publisher_addMime', $mime); |
74
|
|
|
$session->set('publisher_addMimeErr', $error); |
75
|
|
|
\header('Location: ' . Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'add'], false)); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$mimeType = $mimetypeHandler->create(); |
79
|
|
|
$mimeType->setVar('mime_ext', $mimeExt); |
80
|
|
|
$mimeType->setVar('mime_name', $mimeName); |
81
|
|
|
$mimeType->setVar('mime_types', $mimeTypes); |
82
|
|
|
$mimeType->setVar('mime_admin', $mimeAdmin); |
83
|
|
|
$mimeType->setVar('mime_user', $mimeUser); |
84
|
|
|
|
85
|
|
|
if ($mimetypeHandler->insert($mimeType)) { |
86
|
|
|
self::clearAddSessionVars(); |
87
|
|
|
\header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=manage&limit=$limit&start=$start"); |
88
|
|
|
} else { |
89
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?op=manage&limit=$limit&start=$start", 3, \_AM_PUBLISHER_MESSAGE_ADD_MIME_ERROR); |
90
|
|
|
} |
91
|
|
|
} else { |
92
|
|
|
Utility::cpHeader(); |
93
|
|
|
//publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES); |
94
|
|
|
|
95
|
|
|
Utility::openCollapsableBar('mimemaddtable', 'mimeaddicon', \_AM_PUBLISHER_MIME_ADD_TITLE); |
96
|
|
|
|
97
|
|
|
$session = Session::getInstance(); |
98
|
|
|
$mimeType = $session->get('publisher_addMime'); |
99
|
|
|
$mimeErrors = $session->get('publisher_addMimeErr'); |
100
|
|
|
|
101
|
|
|
//Display any form errors |
102
|
|
|
if (false === !$mimeErrors) { |
103
|
|
|
Utility::renderErrors($mimeErrors, Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'clearAddSession'])); |
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
if (false === $mimeType) { |
107
|
|
|
$mimeExt = ''; |
108
|
|
|
$mimeName = ''; |
109
|
|
|
$mimeTypes = ''; |
110
|
|
|
$mimeAdmin = 1; |
111
|
|
|
$mimeUser = 1; |
112
|
|
|
} else { |
113
|
|
|
$mimeExt = $mimeType['mime_ext']; |
114
|
|
|
$mimeName = $mimeType['mime_name']; |
115
|
|
|
$mimeTypes = $mimeType['mime_types']; |
116
|
|
|
$mimeAdmin = $mimeType['mime_admin']; |
117
|
|
|
$mimeUser = $mimeType['mime_user']; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
// Display add form |
121
|
|
|
echo "<form action='mimetypes.php?op=add' method='post'>"; |
122
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
123
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
124
|
|
|
echo "<tr><th colspan='2'>" . \_AM_PUBLISHER_MIME_CREATEF . '</th></tr>'; |
125
|
|
|
echo "<tr valign='top'> |
126
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_EXTF . "</td> |
127
|
|
|
<td class='even'><input type='text' name='mime_ext' id='mime_ext' value='$mimeExt' size='5'></td> |
128
|
|
|
</tr>"; |
129
|
|
|
echo "<tr valign='top'> |
130
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_NAMEF . "</td> |
131
|
|
|
<td class='even'><input type='text' name='mime_name' id='mime_name' value='$mimeName'></td> |
132
|
|
|
</tr>"; |
133
|
|
|
echo "<tr valign='top'> |
134
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_TYPEF . "</td> |
135
|
|
|
<td class='even'><textarea name='mime_types' id='mime_types' cols='60' rows='5'>$mimeTypes</textarea></td> |
136
|
|
|
</tr>"; |
137
|
|
|
echo "<tr valign='top'> |
138
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_ADMINF . "</td> |
139
|
|
|
<td class='even'>"; |
140
|
|
|
echo "<input type='radio' name='mime_admin' value='1' " . (1 == $mimeAdmin ? 'checked' : '') . '>' . \_YES; |
141
|
|
|
echo "<input type='radio' name='mime_admin' value='0' " . (0 == $mimeAdmin ? 'checked' : '') . '>' . \_NO . ' |
142
|
|
|
</td> |
143
|
|
|
</tr>'; |
144
|
|
|
echo "<tr valign='top'> |
145
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_USERF . "</td> |
146
|
|
|
<td class='even'>"; |
147
|
|
|
echo "<input type='radio' name='mime_user' value='1'" . (1 == $mimeUser ? 'checked' : '') . '>' . \_YES; |
148
|
|
|
echo "<input type='radio' name='mime_user' value='0'" . (0 == $mimeUser ? 'checked' : '') . '>' . \_NO . ' |
149
|
|
|
</td> |
150
|
|
|
</tr>'; |
151
|
|
|
echo "<tr valign='top'> |
152
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_MANDATORY_FIELD . "</td> |
153
|
|
|
<td class='even'> |
154
|
|
|
<input type='submit' name='add_mime' id='add_mime' value='" . \_AM_PUBLISHER_BUTTON_SUBMIT . "' class='formButton'> |
155
|
|
|
<input type='button' name='cancel' value='" . \_AM_PUBLISHER_BUTTON_CANCEL . "' onclick='history.go(-1)' class='formButton'> |
156
|
|
|
</td> |
157
|
|
|
</tr>"; |
158
|
|
|
echo '</table></form>'; |
159
|
|
|
// end of add form |
160
|
|
|
|
161
|
|
|
// Find new mimetypes table |
162
|
|
|
echo "<form action='https://www.filext.com' method='post'>"; |
163
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
164
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
165
|
|
|
echo "<tr><th colspan='2'>" . \_AM_PUBLISHER_MIME_FINDMIMETYPE . '</th></tr>'; |
166
|
|
|
|
167
|
|
|
echo "<tr class='foot'> |
168
|
|
|
<td colspan='2'><input type='submit' name='find_mime' id='find_mime' value='" . \_AM_PUBLISHER_MIME_FINDIT . "' class='formButton'></td> |
169
|
|
|
</tr>"; |
170
|
|
|
|
171
|
|
|
echo '</table></form>'; |
172
|
|
|
|
173
|
|
|
Utility::closeCollapsableBar('mimeaddtable', 'mimeaddicon'); |
174
|
|
|
|
175
|
|
|
\xoops_cp_footer(); |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public static function delete(): void |
180
|
|
|
{ |
181
|
|
|
$helper = Helper::getInstance(); |
182
|
|
|
/** @var MimetypeHandler $mimetypeHandler */ |
183
|
|
|
$mimetypeHandler = $helper->getHandler('Mimetype'); |
184
|
|
|
global $start, $limit; |
185
|
|
|
$mimeId = 0; |
186
|
|
|
if (0 == Request::getInt('id', 0, 'GET')) { |
187
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, \_AM_PUBLISHER_MESSAGE_NO_ID); |
|
|
|
|
188
|
|
|
} else { |
189
|
|
|
$mimeId = Request::getInt('id', 0, 'GET'); |
190
|
|
|
} |
191
|
|
|
$mimeType = $mimetypeHandler->get($mimeId); // Retrieve mimetype object |
192
|
|
|
if ($mimetypeHandler->delete($mimeType, true)) { |
|
|
|
|
193
|
|
|
\header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=manage&limit=$limit&start=$start"); |
194
|
|
|
} else { |
195
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?op=manage&id=$mimeId&limit=$limit&start=$start", 3, \_AM_PUBLISHER_MESSAGE_DELETE_MIME_ERROR); |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
public static function edit(): void |
200
|
|
|
{ |
201
|
|
|
$helper = Helper::getInstance(); |
202
|
|
|
/** @var MimetypeHandler $mimetypeHandler */ |
203
|
|
|
$mimetypeHandler = $helper->getHandler('Mimetype'); |
204
|
|
|
global $start, $limit; |
205
|
|
|
$mimeId = 0; |
206
|
|
|
$error = []; |
207
|
|
|
$hasErrors = false; |
208
|
|
|
if (0 == Request::getInt('id', 0, 'GET')) { |
209
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, \_AM_PUBLISHER_MESSAGE_NO_ID); |
|
|
|
|
210
|
|
|
} else { |
211
|
|
|
$mimeId = Request::getInt('id', 0, 'GET'); |
212
|
|
|
} |
213
|
|
|
$mimeTypeObj = $mimetypeHandler->get($mimeId); // Retrieve mimetype object |
214
|
|
|
|
215
|
|
|
if (Request::getString('edit_mime', '', 'POST')) { |
216
|
|
|
$mimeAdmin = 0; |
217
|
|
|
$mimeUser = 0; |
218
|
|
|
if (1 == Request::getInt('mime_admin', 0, 'POST')) { |
219
|
|
|
$mimeAdmin = 1; |
220
|
|
|
} |
221
|
|
|
if (1 == Request::getInt('mime_user', 0, 'POST')) { |
222
|
|
|
$mimeUser = 1; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
//Validate Mimetype entry |
226
|
|
|
if ('' === Request::getString('mime_ext', '', 'POST')) { |
227
|
|
|
$hasErrors = true; |
228
|
|
|
$error['mime_ext'][] = \_AM_PUBLISHER_VALID_ERR_MIME_EXT; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
if ('' === Request::getString('mime_name', '', 'POST')) { |
232
|
|
|
$hasErrors = true; |
233
|
|
|
$error['mime_name'][] = \_AM_PUBLISHER_VALID_ERR_MIME_NAME; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
if ('' === Request::getString('mime_types', '', 'POST')) { |
237
|
|
|
$hasErrors = true; |
238
|
|
|
$error['mime_types'][] = \_AM_PUBLISHER_VALID_ERR_MIME_TYPES; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
if ($hasErrors) { |
242
|
|
|
$session = Session::getInstance(); |
243
|
|
|
$mime = []; |
244
|
|
|
$mime['mime_ext'] = Request::getString('mime_ext', '', 'POST'); |
245
|
|
|
$mime['mime_name'] = Request::getString('mime_name', '', 'POST'); |
246
|
|
|
$mime['mime_types'] = Request::getText('mime_types', '', 'POST'); |
247
|
|
|
$mime['mime_admin'] = $mimeAdmin; |
248
|
|
|
$mime['mime_user'] = $mimeUser; |
249
|
|
|
$session->set('publisher_editMime_' . $mimeId, $mime); |
250
|
|
|
$session->set('publisher_editMimeErr_' . $mimeId, $error); |
251
|
|
|
\header('Location: ' . Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'edit', 'id' => $mimeId], false)); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
$mimeTypeObj->setVar('mime_ext', Request::getString('mime_ext', '', 'POST')); |
255
|
|
|
$mimeTypeObj->setVar('mime_name', Request::getString('mime_name', '', 'POST')); |
256
|
|
|
$mimeTypeObj->setVar('mime_types', Request::getText('mime_types', '', 'POST')); |
257
|
|
|
$mimeTypeObj->setVar('mime_admin', $mimeAdmin); |
258
|
|
|
$mimeTypeObj->setVar('mime_user', $mimeUser); |
259
|
|
|
|
260
|
|
|
if ($mimetypeHandler->insert($mimeTypeObj, true)) { |
|
|
|
|
261
|
|
|
self::clearEditSessionVars($mimeId); |
262
|
|
|
\header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=manage&limit=$limit&start=$start"); |
263
|
|
|
} else { |
264
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?op=edit&id=$mimeId", 3, \_AM_PUBLISHER_MESSAGE_EDIT_MIME_ERROR); |
265
|
|
|
} |
266
|
|
|
} else { |
267
|
|
|
$session = Session::getInstance(); |
268
|
|
|
$mimeType = $session->get('publisher_editMime_' . $mimeId); |
269
|
|
|
$mimeErrors = $session->get('publisher_editMimeErr_' . $mimeId); |
270
|
|
|
|
271
|
|
|
// Display header |
272
|
|
|
Utility::cpHeader(); |
273
|
|
|
//publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES . " > " . _AM_PUBLISHER_BUTTON_EDIT); |
274
|
|
|
|
275
|
|
|
Utility::openCollapsableBar('mimemedittable', 'mimeediticon', \_AM_PUBLISHER_MIME_EDIT_TITLE); |
276
|
|
|
|
277
|
|
|
//Display any form errors |
278
|
|
|
if (false === !$mimeErrors) { |
279
|
|
|
Utility::renderErrors($mimeErrors, Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'clearEditSession', 'id' => $mimeId])); |
|
|
|
|
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
if (false === $mimeType) { |
283
|
|
|
$mimeExt = $mimeTypeObj->getVar('mime_ext'); |
284
|
|
|
$mimeName = $mimeTypeObj->getVar('mime_name', 'e'); |
285
|
|
|
$mimeTypes = $mimeTypeObj->getVar('mime_types', 'e'); |
286
|
|
|
$mimeAdmin = $mimeTypeObj->getVar('mime_admin'); |
287
|
|
|
$mimeUser = $mimeTypeObj->getVar('mime_user'); |
288
|
|
|
} else { |
289
|
|
|
$mimeExt = $mimeType['mime_ext']; |
290
|
|
|
$mimeName = $mimeType['mime_name']; |
291
|
|
|
$mimeTypes = $mimeType['mime_types']; |
292
|
|
|
$mimeAdmin = $mimeType['mime_admin']; |
293
|
|
|
$mimeUser = $mimeType['mime_user']; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
// Display edit form |
297
|
|
|
echo "<form action='mimetypes.php?op=edit&id=" . $mimeId . "' method='post'>"; |
298
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
299
|
|
|
echo "<input type='hidden' name='limit' value='" . $limit . "'>"; |
300
|
|
|
echo "<input type='hidden' name='start' value='" . $start . "'>"; |
301
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
302
|
|
|
echo "<tr><th colspan='2'>" . \_AM_PUBLISHER_MIME_MODIFYF . '</th></tr>'; |
303
|
|
|
echo "<tr valign='top'> |
304
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_EXTF . "</td> |
305
|
|
|
<td class='even'><input type='text' name='mime_ext' id='mime_ext' value='$mimeExt' size='5'></td> |
306
|
|
|
</tr>"; |
307
|
|
|
echo "<tr valign='top'> |
308
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_NAMEF . "</td> |
309
|
|
|
<td class='even'><input type='text' name='mime_name' id='mime_name' value='$mimeName'></td> |
310
|
|
|
</tr>"; |
311
|
|
|
echo "<tr valign='top'> |
312
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_TYPEF . "</td> |
313
|
|
|
<td class='even'><textarea name='mime_types' id='mime_types' cols='60' rows='5'>$mimeTypes</textarea></td> |
314
|
|
|
</tr>"; |
315
|
|
|
echo "<tr valign='top'> |
316
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_ADMINF . "</td> |
317
|
|
|
<td class='even'> |
318
|
|
|
<input type='radio' name='mime_admin' value='1' " . (1 == $mimeAdmin ? 'checked' : '') . '>' . \_YES . " |
319
|
|
|
<input type='radio' name='mime_admin' value='0' " . (0 == $mimeAdmin ? 'checked' : '') . '>' . \_NO . ' |
320
|
|
|
</td> |
321
|
|
|
</tr>'; |
322
|
|
|
echo "<tr valign='top'> |
323
|
|
|
<td class='head'>" . \_AM_PUBLISHER_MIME_USERF . "</td> |
324
|
|
|
<td class='even'> |
325
|
|
|
<input type='radio' name='mime_user' value='1' " . (1 == $mimeUser ? 'checked' : '') . '>' . \_YES . " |
326
|
|
|
<input type='radio' name='mime_user' value='0' " . (0 == $mimeUser ? 'checked' : '') . '>' . \_NO . ' |
327
|
|
|
</td> |
328
|
|
|
</tr>'; |
329
|
|
|
echo "<tr valign='top'> |
330
|
|
|
<td class='head'></td> |
331
|
|
|
<td class='even'> |
332
|
|
|
<input type='submit' name='edit_mime' id='edit_mime' value='" . \_AM_PUBLISHER_BUTTON_UPDATE . "' class='formButton'> |
333
|
|
|
<input type='button' name='cancel' value='" . \_AM_PUBLISHER_BUTTON_CANCEL . "' onclick='history.go(-1)' class='formButton'> |
334
|
|
|
</td> |
335
|
|
|
</tr>"; |
336
|
|
|
echo '</table></form>'; |
337
|
|
|
// end of edit form |
338
|
|
|
Utility::closeCollapsableBar('mimeedittable', 'mimeediticon'); |
339
|
|
|
// xoops_cp_footer(); |
340
|
|
|
require_once \dirname(__DIR__) . '/admin/admin_footer.php'; |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* @param $icons |
346
|
|
|
*/ |
347
|
|
|
public static function manage($icons): void |
348
|
|
|
{ |
349
|
|
|
$helper = Helper::getInstance(); |
350
|
|
|
$utility = new Utility(); |
|
|
|
|
351
|
|
|
/** @var MimetypeHandler $mimetypeHandler */ |
352
|
|
|
$mimetypeHandler = $helper->getHandler('Mimetype'); |
353
|
|
|
global $start, $limit, $aSortBy, $aOrderBy, $aLimitBy, $aSearchBy; |
354
|
|
|
|
355
|
|
|
if (Request::getString('deleteMimes', '', 'POST')) { |
356
|
|
|
$aMimes = Request::getArray('mimes', [], 'POST'); |
357
|
|
|
|
358
|
|
|
$crit = new \Criteria('mime_id', '(' . \implode(',', $aMimes) . ')', 'IN'); |
359
|
|
|
|
360
|
|
|
if ($mimetypeHandler->deleteAll($crit)) { |
361
|
|
|
\header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?limit=$limit&start=$start"); |
|
|
|
|
362
|
|
|
} else { |
363
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?limit=$limit&start=$start", 3, \_AM_PUBLISHER_MESSAGE_DELETE_MIME_ERROR); |
364
|
|
|
} |
365
|
|
|
} |
366
|
|
|
if (Request::getString('add_mime', '', 'POST')) { |
367
|
|
|
// header("Location: " . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=add&start=$start&limit=$limit"); |
368
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?op=add&start=$start&limit=$limit", 3, \_AM_PUBLISHER_MIME_CREATEF); |
369
|
|
|
} |
370
|
|
|
if (Request::getString('mime_search', '', 'POST')) { |
371
|
|
|
// header("Location: " . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=search"); |
372
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php?op=search', 3, \_AM_PUBLISHER_MIME_SEARCH); |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
Utility::cpHeader(); |
376
|
|
|
////publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES); |
377
|
|
|
Utility::openCollapsableBar('mimemanagetable', 'mimemanageicon', \_AM_PUBLISHER_MIME_MANAGE_TITLE, \_AM_PUBLISHER_MIME_INFOTEXT); |
378
|
|
|
$crit = new \CriteriaCompo(); |
379
|
|
|
$order = Request::getString('order', 'ASC', 'POST'); |
380
|
|
|
$sort = Request::getString('sort', 'mime_ext', 'POST'); |
381
|
|
|
|
382
|
|
|
$crit->setOrder($order); |
383
|
|
|
$crit->setStart($start); |
384
|
|
|
$crit->setLimit($limit); |
385
|
|
|
$crit->setSort($sort); |
386
|
|
|
$mimetypes = $mimetypeHandler->getObjects($crit); // Retrieve a list of all mimetypes |
387
|
|
|
$mimeCount = $mimetypeHandler->getCount(); |
388
|
|
|
$nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=manage&limit=$limit"); |
389
|
|
|
|
390
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
391
|
|
|
echo "<tr><td colspan='6' align='right'>"; |
392
|
|
|
echo "<form action='" . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; |
393
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
394
|
|
|
echo '<table>'; |
395
|
|
|
echo '<tr>'; |
396
|
|
|
echo "<td align='right'>" . \_AM_PUBLISHER_TEXT_SEARCH_BY . '</td>'; |
397
|
|
|
echo "<td align='left'><select name='search_by'>"; |
398
|
|
|
foreach ($aSearchBy as $value => $text) { |
399
|
|
|
($sort == $value) ? $selected = 'selected' : $selected = ''; |
400
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
401
|
|
|
} |
402
|
|
|
unset($value); |
403
|
|
|
echo '</select></td>'; |
404
|
|
|
echo "<td align='right'>" . \_AM_PUBLISHER_TEXT_SEARCH_TEXT . '</td>'; |
405
|
|
|
echo "<td align='left'><input type='text' name='search_text' id='search_text' value=''></td>"; |
406
|
|
|
echo "<td><input type='submit' name='mime_search' id='mime_search' value='" . \_AM_PUBLISHER_BUTTON_SEARCH . "'></td>"; |
407
|
|
|
echo '</tr></table></form></td></tr>'; |
408
|
|
|
|
409
|
|
|
echo "<tr><td colspan='6'>"; |
410
|
|
|
echo "<form action='" . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=manage' style='margin:0; padding:0;' method='post'>"; |
411
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
412
|
|
|
echo "<table width='100%'>"; |
413
|
|
|
echo "<tr><td align='right'>" . \_AM_PUBLISHER_TEXT_SORT_BY . " |
414
|
|
|
<select name='sort'>"; |
415
|
|
|
foreach ($aSortBy as $value => $text) { |
416
|
|
|
($sort == $value) ? $selected = 'selected' : $selected = ''; |
417
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
418
|
|
|
} |
419
|
|
|
unset($value); |
420
|
|
|
echo '</select> |
421
|
|
|
|
422
|
|
|
' . \_AM_PUBLISHER_TEXT_ORDER_BY . " |
423
|
|
|
<select name='order'>"; |
424
|
|
|
foreach ($aOrderBy as $value => $text) { |
425
|
|
|
($order == $value) ? $selected = 'selected' : $selected = ''; |
426
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
427
|
|
|
} |
428
|
|
|
unset($value); |
429
|
|
|
echo '</select> |
430
|
|
|
|
431
|
|
|
' . \_AM_PUBLISHER_TEXT_NUMBER_PER_PAGE . " |
432
|
|
|
<select name='limit'>"; |
433
|
|
|
foreach ($aLimitBy as $value => $text) { |
434
|
|
|
($limit == $value) ? $selected = 'selected' : $selected = ''; |
435
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
436
|
|
|
} |
437
|
|
|
unset($value); |
438
|
|
|
echo "</select> |
439
|
|
|
<input type='submit' name='mime_sort' id='mime_sort' value='" . \_AM_PUBLISHER_BUTTON_SUBMIT . "'> |
440
|
|
|
</td> |
441
|
|
|
</tr>"; |
442
|
|
|
echo '</table>'; |
443
|
|
|
echo '</td></tr>'; |
444
|
|
|
echo "<tr><th colspan='6'>" . \_AM_PUBLISHER_MIME_MANAGE_TITLE . '</th></tr>'; |
445
|
|
|
echo "<tr class='head'> |
446
|
|
|
<td>" . \_AM_PUBLISHER_MIME_ID . '</td> |
447
|
|
|
<td>' . \_AM_PUBLISHER_MIME_NAME . "</td> |
448
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MIME_EXT . "</td> |
449
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MIME_ADMIN . "</td> |
450
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MIME_USER . "</td> |
451
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MINDEX_ACTION . '</td> |
452
|
|
|
</tr>'; |
453
|
|
|
foreach ($mimetypes as $mime) { |
454
|
|
|
echo "<tr class='even'> |
455
|
|
|
<td><input type='checkbox' name='mimes[]' value='" . $mime->getVar('mime_id') . "'>" . $mime->getVar('mime_id') . '</td> |
456
|
|
|
<td>' . $mime->getVar('mime_name') . "</td> |
457
|
|
|
<td align='center'>" . $mime->getVar('mime_ext') . "</td> |
458
|
|
|
<td align='center'> |
459
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=updateMimeValue&id=' . $mime->getVar('mime_id') . '&mime_admin=' . $mime->getVar('mime_admin') . '&limit=' . $limit . '&start=' . $start . "'> |
460
|
|
|
" . ($mime->getVar('mime_admin') ? $icons['online'] : $icons['offline']) . "</a> |
461
|
|
|
</td> |
462
|
|
|
<td align='center'> |
463
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=updateMimeValue&id=' . $mime->getVar('mime_id') . '&mime_user=' . $mime->getVar('mime_user') . '&limit=' . $limit . '&start=' . $start . "'> |
464
|
|
|
" . ($mime->getVar('mime_user') ? $icons['online'] : $icons['offline']) . "</a> |
465
|
|
|
</td> |
466
|
|
|
<td align='center'> |
467
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=edit&id=' . $mime->getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons['edit'] . "</a> |
468
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=delete&id=' . $mime->getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons['delete'] . '</a> |
469
|
|
|
</td> |
470
|
|
|
</tr>'; |
471
|
|
|
} |
472
|
|
|
// unset($mime); |
473
|
|
|
echo "<tr class='foot'> |
474
|
|
|
<td colspan='6' valign='top'> |
475
|
|
|
<a href='https://www.filext.com' style='float: right;' target='_blank'>" . \_AM_PUBLISHER_MIME_FINDMIMETYPE . "</a> |
476
|
|
|
<input type='checkbox' name='checkAllMimes' value='0' onclick='selectAll(this.form,\"mimes[]\",this.checked);'> |
477
|
|
|
<input type='submit' name='deleteMimes' id='deleteMimes' value='" . \_AM_PUBLISHER_BUTTON_DELETE . "'> |
478
|
|
|
<input type='submit' name='add_mime' id='add_mime' value='" . \_AM_PUBLISHER_MIME_CREATEF . "' class='formButton'> |
479
|
|
|
</td> |
480
|
|
|
</tr>"; |
481
|
|
|
echo '</table>'; |
482
|
|
|
echo "<div id='staff_nav'>" . $nav->renderNav() . '</div><br>'; |
483
|
|
|
|
484
|
|
|
Utility::closeCollapsableBar('mimemanagetable', 'mimemanageicon'); |
485
|
|
|
|
486
|
|
|
// xoops_cp_footer(); |
487
|
|
|
require_once \dirname(__DIR__) . '/admin/admin_footer.php'; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
/** |
491
|
|
|
* @param array $icons |
492
|
|
|
*/ |
493
|
|
|
public static function search($icons): void |
494
|
|
|
{ |
495
|
|
|
$helper = Helper::getInstance(); |
496
|
|
|
/** @var MimetypeHandler $mimetypeHandler */ |
497
|
|
|
$mimetypeHandler = $helper->getHandler('Mimetype'); |
498
|
|
|
global $limit, $start, $aSearchBy, $aOrderBy, $aLimitBy, $aSortBy; |
499
|
|
|
|
500
|
|
|
if (Request::getString('deleteMimes', '', 'POST')) { |
501
|
|
|
$aMimes = Request::getArray('mimes', [], 'POST'); |
502
|
|
|
|
503
|
|
|
$crit = new \Criteria('mime_id', '(' . \implode(',', $aMimes) . ')', 'IN'); |
504
|
|
|
|
505
|
|
|
if ($mimetypeHandler->deleteAll($crit)) { |
506
|
|
|
\header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?limit=$limit&start=$start"); |
|
|
|
|
507
|
|
|
} else { |
508
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?limit=$limit&start=$start", 3, \_AM_PUBLISHER_MESSAGE_DELETE_MIME_ERROR); |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
if (Request::getString('add_mime', '', 'POST')) { |
512
|
|
|
// header("Location: " . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=add&start=$start&limit=$limit"); |
513
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?op=add&start=$start&limit=$limit", 3, \_AM_PUBLISHER_MIME_CREATEF); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
$order = Request::getString('order', 'ASC'); |
517
|
|
|
$sort = Request::getString('sort', 'mime_name'); |
518
|
|
|
|
519
|
|
|
Utility::cpHeader(); |
520
|
|
|
//publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES . " > " . _AM_PUBLISHER_BUTTON_SEARCH); |
521
|
|
|
|
522
|
|
|
Utility::openCollapsableBar('mimemsearchtable', 'mimesearchicon', \_AM_PUBLISHER_MIME_SEARCH); |
523
|
|
|
|
524
|
|
|
if (Request::hasVar('mime_search')) { |
525
|
|
|
$searchField = Request::getString('search_by', ''); |
526
|
|
|
$searchField = isset($aSearchBy[$searchField]) ? $searchField : 'mime_ext'; |
527
|
|
|
$searchText = Request::getString('search_text', ''); |
528
|
|
|
|
529
|
|
|
$crit = new \Criteria($searchField, '%' . $GLOBALS['xoopsDB']->escape($searchText) . '%', 'LIKE'); |
530
|
|
|
$crit->setSort($sort); |
531
|
|
|
$crit->setOrder($order); |
532
|
|
|
$crit->setLimit($limit); |
533
|
|
|
$crit->setStart($start); |
534
|
|
|
$mimeCount = $mimetypeHandler->getCount($crit); |
535
|
|
|
$mimetypes = $mimetypeHandler->getObjects($crit); |
536
|
|
|
$nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=search&limit=$limit&order=$order&sort=$sort&mime_search=1&search_by=$searchField&search_text=" . \htmlentities($searchText, \ENT_QUOTES | ENT_HTML5)); |
537
|
|
|
// Display results |
538
|
|
|
echo '<script type="text/javascript" src="' . PUBLISHER_URL . '/include/functions.js"></script>'; |
|
|
|
|
539
|
|
|
|
540
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
541
|
|
|
echo "<tr><td colspan='6' align='right'>"; |
542
|
|
|
echo "<form action='" . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; |
543
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
544
|
|
|
echo '<table>'; |
545
|
|
|
echo '<tr>'; |
546
|
|
|
echo "<td align='right'>" . \_AM_PUBLISHER_TEXT_SEARCH_BY . '</td>'; |
547
|
|
|
echo "<td align='left'><select name='search_by'>"; |
548
|
|
|
foreach ($aSearchBy as $value => $text) { |
549
|
|
|
($searchField == $value) ? $selected = 'selected' : $selected = ''; |
550
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
551
|
|
|
} |
552
|
|
|
unset($value); |
553
|
|
|
echo '</select></td>'; |
554
|
|
|
echo "<td align='right'>" . \_AM_PUBLISHER_TEXT_SEARCH_TEXT . '</td>'; |
555
|
|
|
echo "<td align='left'><input type='text' name='search_text' id='search_text' value='" . \htmlentities($searchText, \ENT_QUOTES | ENT_HTML5) . "'></td>"; |
556
|
|
|
echo "<td><input type='submit' name='mime_search' id='mime_search' value='" . \_AM_PUBLISHER_BUTTON_SEARCH . "'></td>"; |
557
|
|
|
echo '</tr></table></form></td></tr>'; |
558
|
|
|
|
559
|
|
|
echo "<tr><td colspan='6'>"; |
560
|
|
|
echo "<form action='" . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; |
561
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
562
|
|
|
echo "<table width='100%'>"; |
563
|
|
|
echo "<tr><td align='right'>" . \_AM_PUBLISHER_TEXT_SORT_BY . " |
564
|
|
|
<select name='sort'>"; |
565
|
|
|
foreach ($aSortBy as $value => $text) { |
566
|
|
|
($sort == $value) ? $selected = 'selected' : $selected = ''; |
567
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
568
|
|
|
} |
569
|
|
|
unset($value); |
570
|
|
|
echo '</select> |
571
|
|
|
|
572
|
|
|
' . \_AM_PUBLISHER_TEXT_ORDER_BY . " |
573
|
|
|
<select name='order'>"; |
574
|
|
|
foreach ($aOrderBy as $value => $text) { |
575
|
|
|
($order == $value) ? $selected = 'selected' : $selected = ''; |
576
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
577
|
|
|
} |
578
|
|
|
unset($value); |
579
|
|
|
echo '</select> |
580
|
|
|
|
581
|
|
|
' . \_AM_PUBLISHER_TEXT_NUMBER_PER_PAGE . " |
582
|
|
|
<select name='limit'>"; |
583
|
|
|
foreach ($aLimitBy as $value => $text) { |
584
|
|
|
($limit == $value) ? $selected = 'selected' : $selected = ''; |
585
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
586
|
|
|
} |
587
|
|
|
unset($value); |
588
|
|
|
echo "</select> |
589
|
|
|
<input type='submit' name='mime_sort' id='mime_sort' value='" . \_AM_PUBLISHER_BUTTON_SUBMIT . "'> |
590
|
|
|
<input type='hidden' name='mime_search' id='mime_search' value='1'> |
591
|
|
|
<input type='hidden' name='search_by' id='search_by' value='$searchField'> |
592
|
|
|
<input type='hidden' name='search_text' id='search_text' value='" . \htmlentities($searchText, \ENT_QUOTES | ENT_HTML5) . "'> |
593
|
|
|
</td> |
594
|
|
|
</tr>"; |
595
|
|
|
echo '</table>'; |
596
|
|
|
echo '</td></tr>'; |
597
|
|
|
if (\count($mimetypes) > 0) { |
598
|
|
|
echo "<tr><th colspan='6'>" . \_AM_PUBLISHER_TEXT_SEARCH_MIME . '</th></tr>'; |
599
|
|
|
echo "<tr class='head'> |
600
|
|
|
<td>" . \_AM_PUBLISHER_MIME_ID . '</td> |
601
|
|
|
<td>' . \_AM_PUBLISHER_MIME_NAME . "</td> |
602
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MIME_EXT . "</td> |
603
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MIME_ADMIN . "</td> |
604
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MIME_USER . "</td> |
605
|
|
|
<td align='center'>" . \_AM_PUBLISHER_MINDEX_ACTION . '</td> |
606
|
|
|
</tr>'; |
607
|
|
|
foreach ($mimetypes as $mime) { |
608
|
|
|
echo "<tr class='even'> |
609
|
|
|
<td><input type='checkbox' name='mimes[]' value='" . $mime->getVar('mime_id') . "'>" . $mime->getVar('mime_id') . '</td> |
610
|
|
|
<td>' . $mime->getVar('mime_name') . "</td> |
611
|
|
|
<td align='center'>" . $mime->getVar('mime_ext') . "</td> |
612
|
|
|
<td align='center'> |
613
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=updateMimeValue&id=' . $mime->getVar('mime_id') . '&mime_admin=' . $mime->getVar('mime_admin') . '&limit=' . $limit . '&start=' . $start . "'> |
614
|
|
|
" . ($mime->getVar('mime_admin') ? $icons['online'] : $icons['offline']) . "</a> |
615
|
|
|
</td> |
616
|
|
|
<td align='center'> |
617
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=updateMimeValue&id=' . $mime->getVar('mime_id') . '&mime_user=' . $mime->getVar('mime_user') . '&limit=' . $limit . '&start=' . $start . "'> |
618
|
|
|
" . ($mime->getVar('mime_user') ? $icons['online'] : $icons['offline']) . "</a> |
619
|
|
|
</td> |
620
|
|
|
<td align='center'> |
621
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=edit&id=' . $mime->getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons['edit'] . "</a> |
622
|
|
|
<a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=delete&id=' . $mime->getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons['delete'] . '</a> |
623
|
|
|
</td> |
624
|
|
|
</tr>'; |
625
|
|
|
} |
626
|
|
|
// unset($mime); |
627
|
|
|
echo "<tr class='foot'> |
628
|
|
|
<td colspan='6' valign='top'> |
629
|
|
|
<a href='https://www.filext.com' style='float: right;' target='_blank'>" . \_AM_PUBLISHER_MIME_FINDMIMETYPE . "</a> |
630
|
|
|
<input type='checkbox' name='checkAllMimes' value='0' onclick='selectAll(this.form,\"mimes[]\",this.checked);'> |
631
|
|
|
<input type='submit' name='deleteMimes' id='deleteMimes' value='" . \_AM_PUBLISHER_BUTTON_DELETE . "'> |
632
|
|
|
<input type='submit' name='add_mime' id='add_mime' value='" . \_AM_PUBLISHER_MIME_CREATEF . "' class='formButton'> |
633
|
|
|
</td> |
634
|
|
|
</tr>"; |
635
|
|
|
} else { |
636
|
|
|
echo '<tr><th>' . \_AM_PUBLISHER_TEXT_SEARCH_MIME . '</th></tr>'; |
637
|
|
|
echo "<tr class='even'> |
638
|
|
|
<td>" . \_AM_PUBLISHER_TEXT_NO_RECORDS . '</td> |
639
|
|
|
</tr>'; |
640
|
|
|
} |
641
|
|
|
echo '</table>'; |
642
|
|
|
echo "<div id='pagenav'>" . $nav->renderNav() . '</div>'; |
643
|
|
|
} else { |
644
|
|
|
echo "<form action='mimetypes.php?op=search' method='post'>"; |
645
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
646
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
647
|
|
|
echo "<tr><th colspan='2'>" . \_AM_PUBLISHER_TEXT_SEARCH_MIME . '</th></tr>'; |
648
|
|
|
echo "<tr><td class='head' width='20%'>" . \_AM_PUBLISHER_TEXT_SEARCH_BY . "</td> |
649
|
|
|
<td class='even'> |
650
|
|
|
<select name='search_by'>"; |
651
|
|
|
foreach ($aSortBy as $value => $text) { |
652
|
|
|
echo "<option value='$value'>$text</option>"; |
653
|
|
|
} |
654
|
|
|
unset($value); |
655
|
|
|
echo '</select> |
656
|
|
|
</td> |
657
|
|
|
</tr>'; |
658
|
|
|
echo "<tr><td class='head'>" . \_AM_PUBLISHER_TEXT_SEARCH_TEXT . "</td> |
659
|
|
|
<td class='even'> |
660
|
|
|
<input type='text' name='search_text' id='search_text' value=''> |
661
|
|
|
</td> |
662
|
|
|
</tr>"; |
663
|
|
|
echo "<tr class='foot'> |
664
|
|
|
<td colspan='2'> |
665
|
|
|
<input type='submit' name='mime_search' id='mime_search' value='" . \_AM_PUBLISHER_BUTTON_SEARCH . "'> |
666
|
|
|
</td> |
667
|
|
|
</tr>"; |
668
|
|
|
echo '</table></form>'; |
669
|
|
|
} |
670
|
|
|
Utility::closeCollapsableBar('mimesearchtable', 'mimesearchicon'); |
671
|
|
|
// require_once \dirname(__DIR__) . '/admin/admin_footer.php'; |
672
|
|
|
\xoops_cp_footer(); |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
/** |
676
|
|
|
* confirm update to mime access, resubmit as POST, including TOKEN |
677
|
|
|
*/ |
678
|
|
|
public static function updateMimeValue(): void |
679
|
|
|
{ |
680
|
|
|
// op=updateMimeValue&id=65&mime_admin=0&limit=15&start=0 |
681
|
|
|
Utility::cpHeader(); |
682
|
|
|
$hiddens = [ |
683
|
|
|
'id' => Request::getInt('id', 0, 'GET'), |
684
|
|
|
'start' => Request::getInt('start', 0, 'GET'), |
685
|
|
|
'limit' => Request::getInt('limit', 15, 'GET'), |
686
|
|
|
]; |
687
|
|
|
|
688
|
|
|
$helper = Helper::getInstance(); |
689
|
|
|
/** @var MimetypeHandler $mimetypeHandler */ |
690
|
|
|
$mimeTypeObj = $helper->getHandler('Mimetype') |
691
|
|
|
->get($hiddens['id']); |
692
|
|
|
if (Request::hasVar('mime_admin')) { |
693
|
|
|
$hiddens['mime_admin'] = Request::getInt('mime_admin', 0, 'GET'); |
694
|
|
|
$msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_ADMIN, $mimeTypeObj->getVar('mime_name')); |
|
|
|
|
695
|
|
|
} else { |
696
|
|
|
$hiddens['mime_user'] = Request::getInt('mime_user', 0, 'GET'); |
697
|
|
|
$msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_USER, $mimeTypeObj->getVar('mime_name')); |
698
|
|
|
} |
699
|
|
|
|
700
|
|
|
$action = PUBLISHER_ADMIN_URL . '/mimetypes.php?op=confirmUpdateMimeValue'; |
|
|
|
|
701
|
|
|
$submit = \_AM_PUBLISHER_MIME_ACCESS_CONFIRM; |
702
|
|
|
|
703
|
|
|
\xoops_confirm($hiddens, $action, $msg, $submit, true); |
704
|
|
|
\xoops_cp_footer(); |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
public static function confirmUpdateMimeValue(): void |
708
|
|
|
{ |
709
|
|
|
$helper = Helper::getInstance(); |
710
|
|
|
/** @var MimetypeHandler $mimetypeHandler */ |
711
|
|
|
$mimetypeHandler = $helper->getHandler('Mimetype'); |
712
|
|
|
$limit = Request::getInt('limit', 0, 'POST'); |
713
|
|
|
$start = Request::getInt('start', 0, 'POST'); |
714
|
|
|
$mimeId = Request::getInt('id', 0, 'POST'); |
715
|
|
|
if (0 === $mimeId) { |
716
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, \_AM_PUBLISHER_MESSAGE_NO_ID); |
|
|
|
|
717
|
|
|
} |
718
|
|
|
|
719
|
|
|
$mimeTypeObj = $mimetypeHandler->get($mimeId); |
720
|
|
|
|
721
|
|
|
if (-1 !== ($mimeAdmin = Request::getInt('mime_admin', -1, 'POST'))) { |
722
|
|
|
$mimeAdmin = self::changeMimeValue($mimeAdmin); |
723
|
|
|
$mimeTypeObj->setVar('mime_admin', $mimeAdmin); |
724
|
|
|
} elseif (-1 !== ($mimeUser = Request::getInt('mime_user', -1, 'POST'))) { |
725
|
|
|
$mimeUser = self::changeMimeValue($mimeUser); |
726
|
|
|
$mimeTypeObj->setVar('mime_user', $mimeUser); |
727
|
|
|
} |
728
|
|
|
if ($mimetypeHandler->insert($mimeTypeObj, true)) { |
|
|
|
|
729
|
|
|
\header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?limit=$limit&start=$start"); |
730
|
|
|
} else { |
731
|
|
|
\redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?limit=$limit&start=$start", 3); |
732
|
|
|
} |
733
|
|
|
} |
734
|
|
|
|
735
|
|
|
/** |
736
|
|
|
* @param $mimeValue |
737
|
|
|
* |
738
|
|
|
* @return int |
739
|
|
|
*/ |
740
|
|
|
protected static function changeMimeValue($mimeValue) |
741
|
|
|
{ |
742
|
|
|
if (1 === (int)$mimeValue) { |
743
|
|
|
$mimeValue = 0; |
744
|
|
|
} else { |
745
|
|
|
$mimeValue = 1; |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
return $mimeValue; |
749
|
|
|
} |
750
|
|
|
|
751
|
|
|
protected static function clearAddSessionVars(): void |
752
|
|
|
{ |
753
|
|
|
$session = Session::getInstance(); |
754
|
|
|
$session->del('publisher_addMime'); |
755
|
|
|
$session->del('publisher_addMimeErr'); |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
public static function clearAddSession(): void |
759
|
|
|
{ |
760
|
|
|
self::clearAddSessionVars(); |
761
|
|
|
\header('Location: ' . Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'add'], false)); |
|
|
|
|
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
/** |
765
|
|
|
* @param int $id |
766
|
|
|
*/ |
767
|
|
|
public static function clearEditSessionVars($id): void |
768
|
|
|
{ |
769
|
|
|
$id = (int)$id; |
770
|
|
|
$session = Session::getInstance(); |
771
|
|
|
$session->del("publisher_editMime_$id"); |
772
|
|
|
$session->del("publisher_editMimeErr_$id"); |
773
|
|
|
} |
774
|
|
|
|
775
|
|
|
public static function clearEditSession(): void |
776
|
|
|
{ |
777
|
|
|
$mimeid = Request::getInt('id', '', 'GET'); |
|
|
|
|
778
|
|
|
self::clearEditSessionVars($mimeid); |
779
|
|
|
\header('Location: ' . Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'edit', 'id' => $mimeid], false)); |
|
|
|
|
780
|
|
|
} |
781
|
|
|
} |
782
|
|
|
|