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