1 | <?php |
---|
2 | /** |
---|
3 | * @package Dotclear |
---|
4 | * @subpackage Backend |
---|
5 | * |
---|
6 | * @copyright Olivier Meunier & Association Dotclear |
---|
7 | * @copyright GPL-2.0-only |
---|
8 | */ |
---|
9 | |
---|
10 | require dirname(__FILE__) . '/../inc/admin/prepend.php'; |
---|
11 | |
---|
12 | dcPage::check('media,media_admin'); |
---|
13 | |
---|
14 | $post_id = !empty($_REQUEST['post_id']) ? (integer) $_REQUEST['post_id'] : null; |
---|
15 | if ($post_id) { |
---|
16 | $post = $core->blog->getPosts(array('post_id' => $post_id, 'post_type' => '')); |
---|
17 | if ($post->isEmpty()) { |
---|
18 | $post_id = null; |
---|
19 | } |
---|
20 | $post_title = $post->post_title; |
---|
21 | $post_type = $post->post_type; |
---|
22 | unset($post); |
---|
23 | } |
---|
24 | $d = isset($_REQUEST['d']) ? $_REQUEST['d'] : null; |
---|
25 | $plugin_id = isset($_REQUEST['plugin_id']) ? html::sanitizeURL($_REQUEST['plugin_id']) : ''; |
---|
26 | $dir = null; |
---|
27 | |
---|
28 | // Attachement type if any |
---|
29 | $link_type = !empty($_REQUEST['link_type']) ? html::escapeHTML($_REQUEST['link_type']) : null; |
---|
30 | |
---|
31 | $page = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; |
---|
32 | $nb_per_page = (integer) ($core->auth->user_prefs->interface->media_by_page ?: 30); |
---|
33 | |
---|
34 | # We are on home not comming from media manager |
---|
35 | if ($d === null && isset($_SESSION['media_manager_dir'])) { |
---|
36 | # We get session information |
---|
37 | $d = $_SESSION['media_manager_dir']; |
---|
38 | } |
---|
39 | |
---|
40 | if (!isset($_GET['page']) && isset($_SESSION['media_manager_page'])) { |
---|
41 | $page = $_SESSION['media_manager_page']; |
---|
42 | } |
---|
43 | |
---|
44 | # We set session information about directory, page and display mode |
---|
45 | if ($d) { |
---|
46 | $_SESSION['media_manager_dir'] = $d; |
---|
47 | } else { |
---|
48 | unset($_SESSION['media_manager_dir']); |
---|
49 | } |
---|
50 | if ($page != 1) { |
---|
51 | $_SESSION['media_manager_page'] = $page; |
---|
52 | } else { |
---|
53 | unset($_SESSION['media_manager_page']); |
---|
54 | } |
---|
55 | |
---|
56 | # Get query if any |
---|
57 | $q = isset($_REQUEST['q']) ? html::escapeHTML($_REQUEST['q']) : null; |
---|
58 | |
---|
59 | # Sort combo |
---|
60 | $sort_combo = array( |
---|
61 | __('By names, in ascending order') => 'name-asc', |
---|
62 | __('By names, in descending order') => 'name-desc', |
---|
63 | __('By dates, in ascending order') => 'date-asc', |
---|
64 | __('By dates, in descending order') => 'date-desc' |
---|
65 | ); |
---|
66 | |
---|
67 | if (!empty($_GET['file_mode'])) { |
---|
68 | $_SESSION['media_file_mode'] = $_GET['file_mode']; |
---|
69 | } |
---|
70 | $file_mode = !empty($_SESSION['media_file_mode']) ? $_SESSION['media_file_mode'] : 'grid'; |
---|
71 | |
---|
72 | $file_sort = null; |
---|
73 | if (!empty($_GET['file_sort'])) { |
---|
74 | $file_sort = $_SESSION['media_file_sort'] = $_GET['file_sort']; |
---|
75 | setcookie('dc_media_sort', json_encode($file_sort)); |
---|
76 | } elseif (isset($_COOKIE['dc_media_sort'])) { |
---|
77 | $file_sort = json_decode($_COOKIE['dc_media_sort']); |
---|
78 | } elseif (!empty($_SESSION['media_file_sort'])) { |
---|
79 | $file_sort = $_SESSION['media_file_sort']; |
---|
80 | } |
---|
81 | $file_sort = in_array($file_sort, $sort_combo) ? $file_sort : null; |
---|
82 | |
---|
83 | $nb_per_page = !empty($_SESSION['nb_per_page']) ? (integer) $_SESSION['nb_per_page'] : $nb_per_page; |
---|
84 | if (!empty($_GET['nb_per_page']) && (integer) $_GET['nb_per_page'] > 0) { |
---|
85 | $nb_per_page = (integer) $_GET['nb_per_page']; |
---|
86 | $_SESSION['nb_per_page'] = $nb_per_page; |
---|
87 | } |
---|
88 | |
---|
89 | $popup = (integer) !empty($_REQUEST['popup']); |
---|
90 | $select = !empty($_REQUEST['select']) ? (integer) $_REQUEST['select'] : 0; // 0 : none, 1 : single media, >1 : multiple medias |
---|
91 | |
---|
92 | $page_url_params = new ArrayObject(array('popup' => $popup, 'select' => $select, 'post_id' => $post_id, 'link_type' => $link_type)); |
---|
93 | if ($d) { |
---|
94 | $page_url_params['d'] = $d; |
---|
95 | } |
---|
96 | if ($plugin_id != '') { |
---|
97 | $page_url_params['plugin_id'] = $plugin_id; |
---|
98 | } |
---|
99 | if ($q) { |
---|
100 | $page_url_params['q'] = $q; |
---|
101 | } |
---|
102 | |
---|
103 | $core->callBehavior('adminMediaURLParams', $page_url_params); |
---|
104 | $page_url_params = (array) $page_url_params; |
---|
105 | |
---|
106 | if ($popup) { |
---|
107 | $open_f = array('dcPage', 'openPopup'); |
---|
108 | $close_f = array('dcPage', 'closePopup'); |
---|
109 | } else { |
---|
110 | $open_f = array('dcPage', 'open'); |
---|
111 | $close_f = function () { |
---|
112 | dcPage::helpBlock('core_media'); |
---|
113 | dcPage::close(); |
---|
114 | }; |
---|
115 | } |
---|
116 | |
---|
117 | $core_media_writable = false; |
---|
118 | try { |
---|
119 | $core->media = new dcMedia($core); |
---|
120 | if ($file_sort) { |
---|
121 | $core->media->setFileSort($file_sort); |
---|
122 | } |
---|
123 | $query = false; |
---|
124 | if ($q) { |
---|
125 | $query = $core->media->searchMedia($q); |
---|
126 | } |
---|
127 | if (!$query) { |
---|
128 | $try_d = $d; |
---|
129 | // Reset current dir |
---|
130 | $d = null; |
---|
131 | // Change directory (may cause an exception if directory doesn't exist) |
---|
132 | $core->media->chdir($try_d); |
---|
133 | // Restore current dir variable |
---|
134 | $d = $try_d; |
---|
135 | $core->media->getDir(); |
---|
136 | } else { |
---|
137 | $d = null; |
---|
138 | $core->media->chdir($d); |
---|
139 | } |
---|
140 | $core_media_writable = $core->media->writable(); |
---|
141 | $dir = &$core->media->dir; |
---|
142 | if (!$core_media_writable) { |
---|
143 | // throw new Exception('you do not have sufficient permissions to write to this folder: '); |
---|
144 | } |
---|
145 | } catch (Exception $e) { |
---|
146 | $core->error->add($e->getMessage()); |
---|
147 | } |
---|
148 | |
---|
149 | // Local functions |
---|
150 | |
---|
151 | $mediaItemLine = function ($f, $i, $query, $table = false) { |
---|
152 | global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params, $link_type; |
---|
153 | |
---|
154 | $fname = $f->basename; |
---|
155 | $file = $query ? $f->relname : $f->basename; |
---|
156 | |
---|
157 | $class = $table ? '' : 'media-item media-col-' . ($i % 2); |
---|
158 | |
---|
159 | if ($f->d) { |
---|
160 | // Folder |
---|
161 | $link = $core->adminurl->get('admin.media', array_merge($page_url_params, array('d' => html::sanitizeURL($f->relname)))); |
---|
162 | if ($f->parent) { |
---|
163 | $fname = '..'; |
---|
164 | $class .= ' media-folder-up'; |
---|
165 | } else { |
---|
166 | $class .= ' media-folder'; |
---|
167 | } |
---|
168 | } else { |
---|
169 | // Item |
---|
170 | $params = new ArrayObject( |
---|
171 | array( |
---|
172 | 'id' => $f->media_id, |
---|
173 | 'plugin_id' => $plugin_id, |
---|
174 | 'popup' => $popup, |
---|
175 | 'select' => $select, |
---|
176 | 'post_id' => $post_id, |
---|
177 | 'link_type' => $link_type |
---|
178 | ) |
---|
179 | ); |
---|
180 | $core->callBehavior('adminMediaURLParams', $params); |
---|
181 | $params = (array) $params; |
---|
182 | $link = $core->adminurl->get( |
---|
183 | 'admin.media.item', $params |
---|
184 | ); |
---|
185 | } |
---|
186 | |
---|
187 | $maxchars = 36; |
---|
188 | if (strlen($fname) > $maxchars) { |
---|
189 | $fname = substr($fname, 0, $maxchars - 4) . '...' . ($f->d ? '' : files::getExtension($fname)); |
---|
190 | } |
---|
191 | |
---|
192 | $act = ''; |
---|
193 | if (!$f->d) { |
---|
194 | if ($select > 0) { |
---|
195 | if ($select == 1) { |
---|
196 | // Single media selection button |
---|
197 | $act .= '<a href="' . $link . '"><img src="images/plus.png" alt="' . __('Select this file') . '" ' . |
---|
198 | 'title="' . __('Select this file') . '" /></a> '; |
---|
199 | } else { |
---|
200 | // Multiple media selection checkbox |
---|
201 | $act .= form::checkbox(array('medias[]', 'media_' . rawurlencode($file)), $file); |
---|
202 | } |
---|
203 | } else { |
---|
204 | // Item |
---|
205 | if ($post_id) { |
---|
206 | // Media attachment button |
---|
207 | $act .= |
---|
208 | '<a class="attach-media" title="' . __('Attach this file to entry') . '" href="' . |
---|
209 | $core->adminurl->get("admin.post.media", |
---|
210 | array('media_id' => $f->media_id, 'post_id' => $post_id, 'attach' => 1, 'link_type' => $link_type)) . |
---|
211 | '">' . |
---|
212 | '<img src="images/plus.png" alt="' . __('Attach this file to entry') . '"/>' . |
---|
213 | '</a>'; |
---|
214 | } |
---|
215 | if ($popup) { |
---|
216 | // Media insertion button |
---|
217 | $act .= '<a href="' . $link . '"><img src="images/plus.png" alt="' . __('Insert this file into entry') . '" ' . |
---|
218 | 'title="' . __('Insert this file into entry') . '" /></a> '; |
---|
219 | } |
---|
220 | } |
---|
221 | } |
---|
222 | if ($f->del) { |
---|
223 | // Deletion button or checkbox |
---|
224 | if (!$popup && !$f->d) { |
---|
225 | if ($select < 2) { |
---|
226 | // Already set for multiple media selection |
---|
227 | $act .= form::checkbox(array('medias[]', 'media_' . rawurlencode($file)), $file); |
---|
228 | } |
---|
229 | } else { |
---|
230 | $act .= '<a class="media-remove" ' . |
---|
231 | 'href="' . html::escapeURL($page_url) . |
---|
232 | '&plugin_id=' . $plugin_id . |
---|
233 | '&d=' . rawurlencode($GLOBALS['d']) . |
---|
234 | '&q=' . rawurlencode($GLOBALS['q']) . |
---|
235 | '&remove=' . rawurlencode($file) . '">' . |
---|
236 | '<img src="images/trash.png" alt="' . __('Delete') . '" title="' . __('delete') . '" /></a>'; |
---|
237 | } |
---|
238 | } |
---|
239 | |
---|
240 | $file_type = explode('/', $f->type); |
---|
241 | $class_open = 'class="modal-' . $file_type[0] . '" '; |
---|
242 | |
---|
243 | // Render markup |
---|
244 | if (!$table) { |
---|
245 | $res = |
---|
246 | '<div class="' . $class . '"><p><a class="media-icon media-link" href="' . rawurldecode($link) . '">' . |
---|
247 | '<img src="' . $f->media_icon . '" alt="" />' . ($query ? $file : $fname) . '</a></p>'; |
---|
248 | |
---|
249 | $lst = ''; |
---|
250 | if (!$f->d) { |
---|
251 | $lst .= |
---|
252 | '<li>' . $f->media_title . '</li>' . |
---|
253 | '<li>' . |
---|
254 | $f->media_dtstr . ' - ' . |
---|
255 | files::size($f->size) . ' - ' . |
---|
256 | '<a ' . $class_open . 'href="' . $f->file_url . '">' . __('open') . '</a>' . |
---|
257 | '</li>'; |
---|
258 | } |
---|
259 | $lst .= ($act != '' ? '<li class="media-action"> ' . $act . '</li>' : ''); |
---|
260 | |
---|
261 | // Show player if relevant |
---|
262 | if ($file_type[0] == 'audio') { |
---|
263 | $lst .= '<li>' . dcMedia::audioPlayer($f->type, $f->file_url, $core->adminurl->get("admin.home", array('pf' => 'player_mp3.swf')), null, $core->blog->settings->system->media_flash_fallback, false) . '</li>'; |
---|
264 | } |
---|
265 | |
---|
266 | $res .= ($lst != '' ? '<ul>' . $lst . '</ul>' : ''); |
---|
267 | $res .= '</div>'; |
---|
268 | } else { |
---|
269 | $res = '<tr class="' . $class . '">'; |
---|
270 | $res .= '<td class="media-action">' . $act . '</td>'; |
---|
271 | $res .= '<td class="maximal" scope="row"><a class="media-flag media-link" href="' . rawurldecode($link) . '">' . |
---|
272 | '<img src="' . $f->media_icon . '" alt="" />' . ($query ? $file : $fname) . '</a>' . |
---|
273 | '<br />' . ($f->d ? '' : $f->media_title) . '</td>'; |
---|
274 | $res .= '<td class="nowrap count">' . ($f->d ? '' : $f->media_dtstr) . '</td>'; |
---|
275 | $res .= '<td class="nowrap count">' . ($f->d ? '' : files::size($f->size) . ' - ' . |
---|
276 | '<a ' . $class_open . 'href="' . $f->file_url . '">' . __('open') . '</a>') . '</td>'; |
---|
277 | $res .= '</tr>'; |
---|
278 | } |
---|
279 | |
---|
280 | return $res; |
---|
281 | }; |
---|
282 | |
---|
283 | // Actions |
---|
284 | |
---|
285 | # Zip download |
---|
286 | if (!empty($_GET['zipdl']) && $core->auth->check('media_admin', $core->blog->id)) { |
---|
287 | try |
---|
288 | { |
---|
289 | if (strpos(realpath($core->media->root . '/' . $d), realpath($core->media->root)) === 0) { |
---|
290 | // Media folder or one of it's sub-folder(s) |
---|
291 | @set_time_limit(300); |
---|
292 | $fp = fopen('php://output', 'wb'); |
---|
293 | $zip = new fileZip($fp); |
---|
294 | $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#'); |
---|
295 | $zip->addDirectory($core->media->root . '/' . $d, '', true); |
---|
296 | |
---|
297 | header('Content-Disposition: attachment;filename=' . date('Y-m-d') . '-' . $core->blog->id . '-' . ($d ?: 'media') . '.zip'); |
---|
298 | header('Content-Type: application/x-zip'); |
---|
299 | $zip->write(); |
---|
300 | unset($zip); |
---|
301 | exit; |
---|
302 | } else { |
---|
303 | $d = null; |
---|
304 | $core->media->chdir($d); |
---|
305 | throw new Exception(__('Not a valid directory')); |
---|
306 | } |
---|
307 | } catch (Exception $e) { |
---|
308 | $core->error->add($e->getMessage()); |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | # Cope with fav/unfav dir |
---|
313 | $fav_dirs = null; |
---|
314 | if (!empty($_GET['fav'])) { |
---|
315 | if (!$q) { |
---|
316 | // Ignore search results |
---|
317 | $fav_dir = rtrim($d, '/'); |
---|
318 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
319 | $nb_last_dirs = (integer) ($core->auth->user_prefs->interface->media_nb_last_dirs); |
---|
320 | if ($nb_last_dirs > 0) { |
---|
321 | $fav_dirs = $core->auth->user_prefs->interface->media_fav_dirs; |
---|
322 | if (!is_array($fav_dirs)) { |
---|
323 | $fav_dirs = array(); |
---|
324 | } |
---|
325 | if (!in_array($fav_dir, $fav_dirs) && $_GET['fav'] == 'y') { |
---|
326 | // Add directory in favorites |
---|
327 | array_unshift($fav_dirs, $fav_dir); |
---|
328 | } elseif (in_array($fav_dir, $fav_dirs) && $_GET['fav'] == 'n') { |
---|
329 | // Remove directory from favorites |
---|
330 | unset($fav_dirs[array_search($fav_dir, $fav_dirs)]); |
---|
331 | } |
---|
332 | // Store new list |
---|
333 | $core->auth->user_prefs->interface->put('media_fav_dirs', $fav_dirs, 'array'); |
---|
334 | $core->adminurl->redirect('admin.media', $page_url_params); |
---|
335 | } |
---|
336 | } |
---|
337 | } |
---|
338 | |
---|
339 | # Recent media dirs |
---|
340 | $last_dirs = null; |
---|
341 | if (!$q) { |
---|
342 | // Ignore search results |
---|
343 | $recent_dir = rtrim($d, '/'); |
---|
344 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
345 | $nb_last_dirs = (integer) ($core->auth->user_prefs->interface->media_nb_last_dirs); |
---|
346 | if ($nb_last_dirs > 0) { |
---|
347 | $last_dirs = $core->auth->user_prefs->interface->media_last_dirs; |
---|
348 | if (!is_array($last_dirs)) { |
---|
349 | $last_dirs = array(); |
---|
350 | } |
---|
351 | if (!in_array($recent_dir, $last_dirs)) { |
---|
352 | // Add new dir at the top of the list |
---|
353 | array_unshift($last_dirs, $recent_dir); |
---|
354 | // Remove oldest dir(s) |
---|
355 | while (count($last_dirs) > $nb_last_dirs) { |
---|
356 | array_pop($last_dirs); |
---|
357 | } |
---|
358 | } else { |
---|
359 | // Move current dir at the top of list |
---|
360 | unset($last_dirs[array_search($recent_dir, $last_dirs)]); |
---|
361 | array_unshift($last_dirs, $recent_dir); |
---|
362 | } |
---|
363 | // Store new list |
---|
364 | $core->auth->user_prefs->interface->put('media_last_dirs', $last_dirs, 'array'); |
---|
365 | } |
---|
366 | } |
---|
367 | |
---|
368 | # New directory |
---|
369 | if ($dir && !empty($_POST['newdir'])) { |
---|
370 | try { |
---|
371 | $core->media->makeDir($_POST['newdir']); |
---|
372 | dcPage::addSuccessNotice(sprintf( |
---|
373 | __('Directory "%s" has been successfully created.'), |
---|
374 | html::escapeHTML($_POST['newdir'])) |
---|
375 | ); |
---|
376 | $core->adminurl->redirect('admin.media', $page_url_params); |
---|
377 | } catch (Exception $e) { |
---|
378 | $core->error->add($e->getMessage()); |
---|
379 | } |
---|
380 | } |
---|
381 | |
---|
382 | # Adding a file |
---|
383 | if ($dir && !empty($_FILES['upfile'])) { |
---|
384 | // only one file per request : @see option singleFileUploads in admin/js/jsUpload/jquery.fileupload |
---|
385 | $upfile = array('name' => $_FILES['upfile']['name'][0], |
---|
386 | 'type' => $_FILES['upfile']['type'][0], |
---|
387 | 'tmp_name' => $_FILES['upfile']['tmp_name'][0], |
---|
388 | 'error' => $_FILES['upfile']['error'][0], |
---|
389 | 'size' => $_FILES['upfile']['size'][0], |
---|
390 | 'title' => html::escapeHTML($_FILES['upfile']['name'][0]) |
---|
391 | ); |
---|
392 | |
---|
393 | if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
---|
394 | header('Content-type: application/json'); |
---|
395 | $message = array(); |
---|
396 | |
---|
397 | try { |
---|
398 | files::uploadStatus($upfile); |
---|
399 | $new_file_id = $core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $upfile['title']); |
---|
400 | |
---|
401 | $message['files'][] = array( |
---|
402 | 'name' => $upfile['name'], |
---|
403 | 'size' => $upfile['size'], |
---|
404 | 'html' => $mediaItemLine($core->media->getFile($new_file_id), 1, $query) |
---|
405 | ); |
---|
406 | } catch (Exception $e) { |
---|
407 | $message['files'][] = array('name' => $upfile['name'], |
---|
408 | 'size' => $upfile['size'], |
---|
409 | 'error' => $e->getMessage() |
---|
410 | ); |
---|
411 | } |
---|
412 | echo json_encode($message); |
---|
413 | exit(); |
---|
414 | } else { |
---|
415 | try { |
---|
416 | files::uploadStatus($upfile); |
---|
417 | |
---|
418 | $f_title = (isset($_POST['upfiletitle']) ? html::escapeHTML($_POST['upfiletitle']) : ''); |
---|
419 | $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false); |
---|
420 | |
---|
421 | $core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $f_title, $f_private); |
---|
422 | |
---|
423 | dcPage::addSuccessNotice(__('Files have been successfully uploaded.')); |
---|
424 | $core->adminurl->redirect('admin.media', $page_url_params); |
---|
425 | } catch (Exception $e) { |
---|
426 | $core->error->add($e->getMessage()); |
---|
427 | } |
---|
428 | } |
---|
429 | } |
---|
430 | |
---|
431 | # Removing items |
---|
432 | if ($dir && !empty($_POST['medias']) && !empty($_POST['delete_medias'])) { |
---|
433 | try { |
---|
434 | foreach ($_POST['medias'] as $media) { |
---|
435 | $core->media->removeItem(rawurldecode($media)); |
---|
436 | } |
---|
437 | dcPage::addSuccessNotice( |
---|
438 | sprintf(__('Successfully delete one media.', |
---|
439 | 'Successfully delete %d medias.', |
---|
440 | count($_POST['medias']) |
---|
441 | ), |
---|
442 | count($_POST['medias']) |
---|
443 | ) |
---|
444 | ); |
---|
445 | $core->adminurl->redirect('admin.media', $page_url_params); |
---|
446 | } catch (Exception $e) { |
---|
447 | $core->error->add($e->getMessage()); |
---|
448 | } |
---|
449 | } |
---|
450 | |
---|
451 | # Removing item from popup only |
---|
452 | if ($dir && !empty($_POST['rmyes']) && !empty($_POST['remove'])) { |
---|
453 | $_POST['remove'] = rawurldecode($_POST['remove']); |
---|
454 | |
---|
455 | try { |
---|
456 | if (is_dir(path::real($core->media->getPwd() . '/' . path::clean($_POST['remove'])))) { |
---|
457 | $msg = __('Directory has been successfully removed.'); |
---|
458 | } else { |
---|
459 | $msg = __('File has been successfully removed.'); |
---|
460 | } |
---|
461 | $core->media->removeItem($_POST['remove']); |
---|
462 | dcPage::addSuccessNotice($msg); |
---|
463 | $core->adminurl->redirect('admin.media', $page_url_params); |
---|
464 | } catch (Exception $e) { |
---|
465 | $core->error->add($e->getMessage()); |
---|
466 | } |
---|
467 | } |
---|
468 | |
---|
469 | # Rebuild directory |
---|
470 | if ($dir && $core->auth->isSuperAdmin() && !empty($_POST['rebuild'])) { |
---|
471 | try { |
---|
472 | $core->media->rebuild($d); |
---|
473 | |
---|
474 | dcPage::success(sprintf( |
---|
475 | __('Directory "%s" has been successfully rebuilt.'), |
---|
476 | html::escapeHTML($d)) |
---|
477 | ); |
---|
478 | $core->adminurl->redirect('admin.media', $page_url_params); |
---|
479 | } catch (Exception $e) { |
---|
480 | $core->error->add($e->getMessage()); |
---|
481 | } |
---|
482 | } |
---|
483 | |
---|
484 | # DISPLAY confirm page for rmdir & rmfile |
---|
485 | if ($dir && !empty($_GET['remove']) && empty($_GET['noconfirm'])) { |
---|
486 | call_user_func($open_f, __('Media manager'), '', |
---|
487 | dcPage::breadcrumb( |
---|
488 | array( |
---|
489 | html::escapeHTML($core->blog->name) => '', |
---|
490 | __('Media manager') => '', |
---|
491 | __('confirm removal') => '' |
---|
492 | ), |
---|
493 | array('home_link' => !$popup) |
---|
494 | ) |
---|
495 | ); |
---|
496 | |
---|
497 | echo |
---|
498 | '<form action="' . html::escapeURL($core->adminurl->get('admin.media')) . '" method="post">' . |
---|
499 | '<p>' . sprintf(__('Are you sure you want to remove %s?'), |
---|
500 | html::escapeHTML($_GET['remove'])) . '</p>' . |
---|
501 | '<p><input type="submit" value="' . __('Cancel') . '" /> ' . |
---|
502 | ' <input type="submit" name="rmyes" value="' . __('Yes') . '" />' . |
---|
503 | form::hidden('d', $d) . |
---|
504 | form::hidden('q', $q) . |
---|
505 | $core->adminurl->getHiddenFormFields('admin.media', $page_url_params) . |
---|
506 | $core->formNonce() . |
---|
507 | form::hidden('remove', html::escapeHTML($_GET['remove'])) . '</p>' . |
---|
508 | '</form>'; |
---|
509 | |
---|
510 | call_user_func($close_f); |
---|
511 | exit; |
---|
512 | } |
---|
513 | |
---|
514 | /* DISPLAY Main page |
---|
515 | -------------------------------------------------------- */ |
---|
516 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
517 | $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; |
---|
518 | |
---|
519 | if (!isset($core->media)) { |
---|
520 | $breadcrumb = dcPage::breadcrumb( |
---|
521 | array( |
---|
522 | html::escapeHTML($core->blog->name) => '', |
---|
523 | __('Media manager') => '' |
---|
524 | ), |
---|
525 | array('home_link' => !$popup) |
---|
526 | ); |
---|
527 | } else { |
---|
528 | $home_params = $page_url_params; |
---|
529 | $home_params['d'] = ''; |
---|
530 | $home_params['q'] = ''; |
---|
531 | if ($query || (!$query && $q)) { |
---|
532 | $count = $query ? count($dir['files']) : 0; |
---|
533 | $breadcrumb = dcPage::breadcrumb( |
---|
534 | array( |
---|
535 | html::escapeHTML($core->blog->name) => '', |
---|
536 | __('Media manager') => $core->adminurl->get('admin.media', $home_params), |
---|
537 | __('Search:') . ' ' . $q . ' (' . sprintf(__('%s file found', '%s files found', $count), $count) . ')' => '' |
---|
538 | ), |
---|
539 | array('home_link' => !$popup) |
---|
540 | ); |
---|
541 | } else { |
---|
542 | $temp_params = $page_url_params; |
---|
543 | $temp_params['d'] = '%s'; |
---|
544 | $bc_template = $core->adminurl->get('admin.media', $temp_params, '&', true); |
---|
545 | $breadcrumb_media = $core->media->breadCrumb($bc_template, '<span class="page-title">%s</span>'); |
---|
546 | if ($breadcrumb_media == '') { |
---|
547 | $breadcrumb = dcPage::breadcrumb( |
---|
548 | array( |
---|
549 | html::escapeHTML($core->blog->name) => '', |
---|
550 | __('Media manager') => $core->adminurl->get('admin.media', $home_params) |
---|
551 | ), |
---|
552 | array('home_link' => !$popup) |
---|
553 | ); |
---|
554 | } else { |
---|
555 | $home_params = $page_url_params; |
---|
556 | $home_params['d'] = ''; |
---|
557 | |
---|
558 | $breadcrumb = dcPage::breadcrumb( |
---|
559 | array( |
---|
560 | html::escapeHTML($core->blog->name) => '', |
---|
561 | __('Media manager') => $core->adminurl->get('admin.media', $home_params), |
---|
562 | $breadcrumb_media => '' |
---|
563 | ), |
---|
564 | array( |
---|
565 | 'home_link' => !$popup, |
---|
566 | 'hl' => false |
---|
567 | ) |
---|
568 | ); |
---|
569 | } |
---|
570 | } |
---|
571 | } |
---|
572 | |
---|
573 | // Recent media folders |
---|
574 | $last_folders = ''; |
---|
575 | $last_folders_item = ''; |
---|
576 | $fav_url = ''; |
---|
577 | $fav_img = ''; |
---|
578 | $fav_alt = ''; |
---|
579 | $nb_last_dirs = (integer) ($core->auth->user_prefs->interface->media_nb_last_dirs); |
---|
580 | if ($nb_last_dirs > 0) { |
---|
581 | // Favorites directories |
---|
582 | $fav_dirs = $core->auth->user_prefs->interface->media_fav_dirs; |
---|
583 | if (!is_array($fav_dirs)) { |
---|
584 | $fav_dirs = array(); |
---|
585 | } |
---|
586 | foreach ($fav_dirs as $ld) { |
---|
587 | // Add favorites dirs on top of combo |
---|
588 | $ld_params = $page_url_params; |
---|
589 | $ld_params['d'] = $ld; |
---|
590 | $ld_params['q'] = ''; // Reset search |
---|
591 | $last_folders_item .= |
---|
592 | '<option value="' . urldecode($core->adminurl->get('admin.media', $ld_params)) . '"' . |
---|
593 | ($ld == rtrim($d, '/') ? ' selected="selected"' : '') . '>' . |
---|
594 | '/' . $ld . '</option>' . "\n"; |
---|
595 | if ($ld == rtrim($d, '/')) { |
---|
596 | // Current directory is a favorite → button will un-fav |
---|
597 | $ld_params['fav'] = 'n'; |
---|
598 | $fav_url = urldecode($core->adminurl->get('admin.media', $ld_params)); |
---|
599 | unset($ld_params['fav']); |
---|
600 | $fav_img = 'images/fav-on.png'; |
---|
601 | $fav_alt = __('Remove this folder from your favorites'); |
---|
602 | } |
---|
603 | } |
---|
604 | if ($last_folders_item != '') { |
---|
605 | // add a separator between favorite dirs and recent dirs |
---|
606 | $last_folders_item .= '<option disabled>_________</option>'; |
---|
607 | } |
---|
608 | // Recent directories |
---|
609 | if (!is_array($last_dirs)) { |
---|
610 | $last_dirs = $core->auth->user_prefs->interface->media_last_dirs; |
---|
611 | } |
---|
612 | if (is_array($last_dirs)) { |
---|
613 | foreach ($last_dirs as $ld) { |
---|
614 | if (!in_array($ld, $fav_dirs)) { |
---|
615 | $ld_params = $page_url_params; |
---|
616 | $ld_params['d'] = $ld; |
---|
617 | $ld_params['q'] = ''; // Reset search |
---|
618 | $last_folders_item .= |
---|
619 | '<option value="' . urldecode($core->adminurl->get('admin.media', $ld_params)) . '"' . |
---|
620 | ($ld == rtrim($d, '/') ? ' selected="selected"' : '') . '>' . |
---|
621 | '/' . $ld . '</option>' . "\n"; |
---|
622 | if ($ld == rtrim($d, '/')) { |
---|
623 | // Current directory is not a favorite → button will fav |
---|
624 | $ld_params['fav'] = 'y'; |
---|
625 | $fav_url = urldecode($core->adminurl->get('admin.media', $ld_params)); |
---|
626 | unset($ld_params['fav']); |
---|
627 | $fav_img = 'images/fav-off.png'; |
---|
628 | $fav_alt = __('Add this folder to your favorites'); |
---|
629 | } |
---|
630 | } |
---|
631 | } |
---|
632 | } |
---|
633 | if ($last_folders_item != '') { |
---|
634 | $last_folders = |
---|
635 | '<p class="media-recent hidden-if-no-js">' . |
---|
636 | '<label class="classic" for="switchfolder">' . __('Goto recent folder:') . '</label> ' . |
---|
637 | '<select name="switchfolder" id="switchfolder">' . |
---|
638 | $last_folders_item . |
---|
639 | '</select>' . |
---|
640 | '<script type="text/javascript">var urlmenu = document.getElementById(\'switchfolder\'); |
---|
641 | urlmenu.onchange = function() { window.location = this.options[this.selectedIndex].value; }; |
---|
642 | </script>' . |
---|
643 | ' <a id="media-fav-dir" href="' . $fav_url . '" title="' . $fav_alt . '"><img src="' . $fav_img . '" alt="' . $fav_alt . '" /></a>' . |
---|
644 | '</p>'; |
---|
645 | } |
---|
646 | } |
---|
647 | |
---|
648 | call_user_func($open_f, __('Media manager'), |
---|
649 | dcPage::jsModal() . |
---|
650 | dcPage::jsLoad('js/_media.js') . |
---|
651 | ($core_media_writable ? dcPage::jsUpload(array('d=' . $d)) : ''), |
---|
652 | $breadcrumb |
---|
653 | ); |
---|
654 | |
---|
655 | if ($popup) { |
---|
656 | // Display notices |
---|
657 | echo dcPage::notices(); |
---|
658 | } |
---|
659 | |
---|
660 | if (!$core_media_writable) { |
---|
661 | dcPage::warning(__('You do not have sufficient permissions to write to this folder.')); |
---|
662 | } |
---|
663 | |
---|
664 | if (!empty($_GET['mkdok'])) { |
---|
665 | dcPage::success(__('Directory has been successfully created.')); |
---|
666 | } |
---|
667 | |
---|
668 | if (!empty($_GET['upok'])) { |
---|
669 | dcPage::success(__('Files have been successfully uploaded.')); |
---|
670 | } |
---|
671 | |
---|
672 | if (!empty($_GET['rmfok'])) { |
---|
673 | dcPage::success(__('File has been successfully removed.')); |
---|
674 | } |
---|
675 | |
---|
676 | if (!empty($_GET['rmdok'])) { |
---|
677 | dcPage::success(__('Directory has been successfully removed.')); |
---|
678 | } |
---|
679 | |
---|
680 | if (!empty($_GET['rebuildok'])) { |
---|
681 | dcPage::success(__('Directory has been successfully rebuilt.')); |
---|
682 | } |
---|
683 | |
---|
684 | if (!empty($_GET['unzipok'])) { |
---|
685 | dcPage::success(__('Zip file has been successfully extracted.')); |
---|
686 | } |
---|
687 | |
---|
688 | if (!$dir) { |
---|
689 | call_user_func($close_f); |
---|
690 | exit; |
---|
691 | } |
---|
692 | |
---|
693 | if ($select) { |
---|
694 | // Select mode (popup or not) |
---|
695 | echo '<div class="' . ($popup ? 'form-note ' : '') . 'info"><p>'; |
---|
696 | if ($select == 1) { |
---|
697 | echo sprintf(__('Select a file by clicking on %s'), '<img src="images/plus.png" alt="' . __('Select this file') . '" />'); |
---|
698 | } else { |
---|
699 | echo sprintf(__('Select files and click on <strong>%s</strong> button'), __('Choose selected medias')); |
---|
700 | } |
---|
701 | if ($core_media_writable) { |
---|
702 | echo ' ' . __('or') . ' ' . sprintf('<a href="#fileupload">%s</a>', __('upload a new file')); |
---|
703 | } |
---|
704 | echo '</p></div>'; |
---|
705 | } else { |
---|
706 | if ($post_id) { |
---|
707 | echo '<div class="form-note info"><p>' . sprintf(__('Choose a file to attach to entry %s by clicking on %s'), |
---|
708 | '<a href="' . $core->getPostAdminURL($post_type, $post_id) . '">' . html::escapeHTML($post_title) . '</a>', |
---|
709 | '<img src="images/plus.png" alt="' . __('Attach this file to entry') . '" />'); |
---|
710 | if ($core_media_writable) { |
---|
711 | echo ' ' . __('or') . ' ' . sprintf('<a href="#fileupload">%s</a>', __('upload a new file')); |
---|
712 | } |
---|
713 | echo '</p></div>'; |
---|
714 | } |
---|
715 | if ($popup) { |
---|
716 | echo '<div class="info"><p>' . sprintf(__('Choose a file to insert into entry by clicking on %s'), |
---|
717 | '<img src="images/plus.png" alt="' . __('Attach this file to entry') . '" />'); |
---|
718 | if ($core_media_writable) { |
---|
719 | echo ' ' . __('or') . ' ' . sprintf('<a href="#fileupload">%s</a>', __('upload a new file')); |
---|
720 | } |
---|
721 | echo '</p></div>'; |
---|
722 | } |
---|
723 | } |
---|
724 | |
---|
725 | // Remove hidden directories (unless DC_SHOW_HIDDEN_DIRS is set to true) |
---|
726 | if (!defined('DC_SHOW_HIDDEN_DIRS') || (DC_SHOW_HIDDEN_DIRS == false)) { |
---|
727 | for ($i = count($dir['dirs']) - 1; $i >= 0; $i--) { |
---|
728 | if ($dir['dirs'][$i]->d) { |
---|
729 | if (strpos($dir['dirs'][$i]->relname, '.') !== false) { |
---|
730 | unset($dir['dirs'][$i]); |
---|
731 | } |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | $items = array_values(array_merge($dir['dirs'], $dir['files'])); |
---|
736 | |
---|
737 | $fmt_form_media = '<form action="' . $core->adminurl->get("admin.media") . '" method="post" id="form-medias">' . |
---|
738 | '<div class="files-group">%s</div>' . |
---|
739 | '<p class="hidden">' . $core->formNonce() . |
---|
740 | form::hidden(array('d'), $d) . |
---|
741 | form::hidden(array('q'), $q) . |
---|
742 | form::hidden(array('popup'), $popup) . |
---|
743 | form::hidden(array('select'), $select) . |
---|
744 | form::hidden(array('plugin_id'), $plugin_id) . |
---|
745 | form::hidden(array('post_id'), $post_id) . |
---|
746 | form::hidden(array('link_type'), $link_type) . |
---|
747 | '</p>'; |
---|
748 | |
---|
749 | if (!$popup || $select > 1) { |
---|
750 | // Checkboxes and action |
---|
751 | $fmt_form_media .= |
---|
752 | '<div class="' . (!$popup ? 'medias-delete' : '') . ' ' . ($select > 1 ? 'medias-select' : '') . '">' . |
---|
753 | '<p class="checkboxes-helpers"></p>' . |
---|
754 | '<p>'; |
---|
755 | if ($select > 1) { |
---|
756 | $fmt_form_media .= |
---|
757 | '<input type="submit" class="select" id="select_medias" name="select_medias" value="' . __('Choose selected medias') . '"/> '; |
---|
758 | } |
---|
759 | if (!$popup) { |
---|
760 | $fmt_form_media .= |
---|
761 | '<input type="submit" class="delete" id="delete_medias" name="delete_medias" value="' . __('Remove selected medias') . '"/>'; |
---|
762 | } |
---|
763 | $fmt_form_media .= |
---|
764 | '</p>' . |
---|
765 | '</div>'; |
---|
766 | } |
---|
767 | $fmt_form_media .= |
---|
768 | '</form>'; |
---|
769 | |
---|
770 | echo '<div class="media-list">'; |
---|
771 | echo $last_folders; |
---|
772 | echo // Search form |
---|
773 | '<form action="' . $core->adminurl->get("admin.media") . '" method="get" id="search-form">' . |
---|
774 | '<p><label for="search" class="classic">' . __('Search:') . '</label> ' . |
---|
775 | form::field('q', 20, 255, $q) . ' ' . |
---|
776 | '<input type="submit" value="' . __('OK') . '" />' . ' ' . |
---|
777 | '<span class="form-note">' . __('Will search into media filename (including path), title and description') . '</span>' . |
---|
778 | form::hidden(array('popup'), $popup) . |
---|
779 | form::hidden(array('select'), $select) . |
---|
780 | form::hidden(array('plugin_id'), $plugin_id) . |
---|
781 | form::hidden(array('post_id'), $post_id) . |
---|
782 | form::hidden(array('link_type'), $link_type) . |
---|
783 | '</p>' . |
---|
784 | '</form>'; |
---|
785 | |
---|
786 | if (count($items) == 0) { |
---|
787 | echo |
---|
788 | '<p>' . __('No file.') . '</p>' . |
---|
789 | sprintf($fmt_form_media, '', ' hide'); // need for jsUpload to append new media |
---|
790 | } else { |
---|
791 | $pager = new dcPager($page, count($items), $nb_per_page, 10); |
---|
792 | $nbItems = count($items) - ($d ? 1 : 0); |
---|
793 | $nbFolders = count(array_filter($items, function ($i) {return ($i->d);})) - ($d ? 1 : 0); |
---|
794 | $nbFiles = $nbItems - $nbFolders; |
---|
795 | |
---|
796 | echo |
---|
797 | '<form action="' . $core->adminurl->get("admin.media") . '" method="get" id="filters-form">' . |
---|
798 | '<span class="media-file-mode">' . |
---|
799 | '<a href="' . $core->adminurl->get("admin.media", array_merge($page_url_params, array('file_mode' => 'grid'))) . '" title="' . __('Grid display mode') . '">' . |
---|
800 | '<img src="images/grid-' . ($file_mode == 'grid' ? 'on' : 'off') . '.png" alt="' . __('Grid display mode') . '" />' . |
---|
801 | '</a>' . |
---|
802 | '<a href="' . $core->adminurl->get("admin.media", array_merge($page_url_params, array('file_mode' => 'list'))) . '" title="' . __('List display mode') . '">' . |
---|
803 | '<img src="images/list-' . ($file_mode == 'list' ? 'on' : 'off') . '.png" alt="' . __('List display mode') . '" />' . |
---|
804 | '</a>' . |
---|
805 | '</span>' . |
---|
806 | '<p class="three-boxes"><label for="file_sort" class="classic">' . __('Sort files:') . '</label> ' . |
---|
807 | form::combo('file_sort', $sort_combo, $file_sort) . '</p>' . |
---|
808 | '<p class="three-boxes"><label for="nb_per_page" class="classic">' . __('Number of elements displayed per page:') . '</label> ' . |
---|
809 | form::number('nb_per_page', 0, 999, $nb_per_page) . ' ' . |
---|
810 | '<input type="submit" value="' . __('OK') . '" />' . |
---|
811 | form::hidden(array('popup'), $popup) . |
---|
812 | form::hidden(array('select'), $select) . |
---|
813 | form::hidden(array('plugin_id'), $plugin_id) . |
---|
814 | form::hidden(array('post_id'), $post_id) . |
---|
815 | form::hidden(array('link_type'), $link_type) . |
---|
816 | form::hidden(array('q'), $q) . |
---|
817 | '</p>' . |
---|
818 | '</form>' . |
---|
819 | $pager->getLinks(); |
---|
820 | |
---|
821 | if ($file_mode == 'list') { |
---|
822 | $table = |
---|
823 | '<div class="table-outer">' . |
---|
824 | '<table>' . |
---|
825 | '<caption class="hidden">' . __('Media list') . '</caption>' . |
---|
826 | '<tr>' . |
---|
827 | '<th colspan="2" class="first">' . __('Name') . '</th>' . |
---|
828 | '<th scope="col">' . __('Date') . '</th>' . |
---|
829 | '<th scope="col">' . __('Size') . '</th>' . |
---|
830 | '</tr>'; |
---|
831 | |
---|
832 | $dlist = ''; |
---|
833 | $flist = ''; |
---|
834 | for ($i = $pager->index_start, $j = 0; $i <= $pager->index_end; $i++, $j++) { |
---|
835 | if ($items[$i]->d) { |
---|
836 | $dlist .= $mediaItemLine($items[$i], $j, $query, true); |
---|
837 | } else { |
---|
838 | $flist .= $mediaItemLine($items[$i], $j, $query, true); |
---|
839 | } |
---|
840 | } |
---|
841 | $table .= $dlist . $flist; |
---|
842 | |
---|
843 | $table .= |
---|
844 | '</table></div>'; |
---|
845 | echo sprintf($fmt_form_media, $table, ''); |
---|
846 | } else { |
---|
847 | $dgroup = ''; |
---|
848 | $fgroup = ''; |
---|
849 | for ($i = $pager->index_start, $j = 0; $i <= $pager->index_end; $i++, $j++) { |
---|
850 | if ($items[$i]->d) { |
---|
851 | $dgroup .= $mediaItemLine($items[$i], $j, $query); |
---|
852 | } else { |
---|
853 | $fgroup .= $mediaItemLine($items[$i], $j, $query); |
---|
854 | } |
---|
855 | } |
---|
856 | echo |
---|
857 | ($dgroup != '' ? '<div class="folders-group">' . $dgroup . '</div>' : '') . |
---|
858 | sprintf($fmt_form_media, $fgroup, ''); |
---|
859 | } |
---|
860 | |
---|
861 | echo $pager->getLinks(); |
---|
862 | |
---|
863 | // Statistics |
---|
864 | echo '<div class="media-stats"><p class="form-stats">' . |
---|
865 | ($nbFiles && $nbFolders ? |
---|
866 | sprintf(__('Nb of items: %d → %d folder(s) + %d file(s)'), $nbItems, $nbFolders, $nbFiles) : |
---|
867 | sprintf(__('Nb of items: %d'), $nbItems)) . |
---|
868 | '</p></div>'; |
---|
869 | } |
---|
870 | if (!isset($pager)) { |
---|
871 | echo |
---|
872 | '<p class="clear"></p>'; |
---|
873 | } |
---|
874 | echo |
---|
875 | '</div>'; |
---|
876 | |
---|
877 | $core_media_archivable = $core->auth->check('media_admin', $core->blog->id) && |
---|
878 | !(count($items) == 0 || (count($items) == 1 && $items[0]->parent)); |
---|
879 | |
---|
880 | if ((!$query) && ($core_media_writable || $core_media_archivable)) { |
---|
881 | echo |
---|
882 | '<div class="vertical-separator">' . |
---|
883 | '<h3 class="out-of-screen-if-js">' . sprintf(__('In %s:'), ($d == '' ? '“' . __('Media manager') . '”' : '“' . $d . '”')) . '</h3>'; |
---|
884 | } |
---|
885 | |
---|
886 | if ((!$query) && ($core_media_writable || $core_media_archivable)) { |
---|
887 | echo |
---|
888 | '<div class="two-boxes odd">'; |
---|
889 | |
---|
890 | # Create directory |
---|
891 | if ($core_media_writable) { |
---|
892 | echo |
---|
893 | '<form action="' . $core->adminurl->getBase('admin.media') . '" method="post" class="fieldset">' . |
---|
894 | '<div id="new-dir-f">' . |
---|
895 | '<h4 class="pretty-title">' . __('Create new directory') . '</h4>' . |
---|
896 | $core->formNonce() . |
---|
897 | '<p><label for="newdir">' . __('Directory Name:') . '</label>' . |
---|
898 | form::field('newdir', 35, 255) . '</p>' . |
---|
899 | '<p><input type="submit" value="' . __('Create') . '" />' . |
---|
900 | $core->adminurl->getHiddenFormFields('admin.media', $page_url_params) . |
---|
901 | '</p>' . |
---|
902 | '</div>' . |
---|
903 | '</form>'; |
---|
904 | } |
---|
905 | |
---|
906 | # Get zip directory |
---|
907 | if ($core_media_archivable && !$popup) { |
---|
908 | echo |
---|
909 | '<div class="fieldset">' . |
---|
910 | '<h4 class="pretty-title">' . sprintf(__('Backup content of %s'), ($d == '' ? '“' . __('Media manager') . '”' : '“' . $d . '”')) . '</h4>' . |
---|
911 | '<p><a class="button submit" href="' . $core->adminurl->get('admin.media', |
---|
912 | array_merge($page_url_params, array('zipdl' => 1))) . '">' . __('Download zip file') . '</a></p>' . |
---|
913 | '</div>'; |
---|
914 | } |
---|
915 | |
---|
916 | echo |
---|
917 | '</div>'; |
---|
918 | } |
---|
919 | |
---|
920 | if (!$query && $core_media_writable) { |
---|
921 | echo |
---|
922 | '<div class="two-boxes fieldset even">'; |
---|
923 | if ($user_ui_enhanceduploader) { |
---|
924 | echo |
---|
925 | '<div class="enhanced_uploader">'; |
---|
926 | } else { |
---|
927 | echo |
---|
928 | '<div>'; |
---|
929 | } |
---|
930 | |
---|
931 | echo |
---|
932 | '<h4>' . __('Add files') . '</h4>' . |
---|
933 | '<p class="more-info">' . __('Please take care to publish media that you own and that are not protected by copyright.') . '</p>' . |
---|
934 | '<form id="fileupload" action="' . html::escapeURL($core->adminurl->get('admin.media', $page_url_params)) . '" method="post" enctype="multipart/form-data" aria-disabled="false">' . |
---|
935 | '<p>' . form::hidden(array('MAX_FILE_SIZE'), DC_MAX_UPLOAD_SIZE) . |
---|
936 | $core->formNonce() . '</p>' . |
---|
937 | '<div class="fileupload-ctrl"><p class="queue-message"></p><ul class="files"></ul></div>'; |
---|
938 | |
---|
939 | echo |
---|
940 | '<div class="fileupload-buttonbar clear">'; |
---|
941 | |
---|
942 | echo |
---|
943 | '<p><label for="upfile">' . '<span class="add-label one-file">' . __('Choose file') . '</span>' . '</label>' . |
---|
944 | '<button class="button choose_files">' . __('Choose files') . '</button>' . |
---|
945 | '<input type="file" id="upfile" name="upfile[]"' . ($user_ui_enhanceduploader ? ' multiple="mutiple"' : '') . ' data-url="' . html::escapeURL($core->adminurl->get('admin.media', $page_url_params)) . '" /></p>'; |
---|
946 | |
---|
947 | echo |
---|
948 | '<p class="max-sizer form-note"> ' . __('Maximum file size allowed:') . ' ' . files::size(DC_MAX_UPLOAD_SIZE) . '</p>'; |
---|
949 | |
---|
950 | echo |
---|
951 | '<p class="one-file"><label for="upfiletitle">' . __('Title:') . '</label>' . form::field('upfiletitle', 35, 255) . '</p>' . |
---|
952 | '<p class="one-file"><label for="upfilepriv" class="classic">' . __('Private') . '</label> ' . |
---|
953 | form::checkbox('upfilepriv', 1) . '</p>'; |
---|
954 | |
---|
955 | if (!$user_ui_enhanceduploader) { |
---|
956 | echo |
---|
957 | '<p class="one-file form-help info">' . __('To send several files at the same time, you can activate the enhanced uploader in') . |
---|
958 | ' <a href="' . $core->adminurl->get("admin.user.preferences", array('tab' => 'user-options')) . '">' . __('My preferences') . '</a></p>'; |
---|
959 | } |
---|
960 | |
---|
961 | echo |
---|
962 | '<p class="clear"><button class="button clean">' . __('Refresh') . '</button>' . |
---|
963 | '<input class="button cancel one-file" type="reset" value="' . __('Clear all') . '"/>' . |
---|
964 | '<input class="button start" type="submit" value="' . __('Upload') . '"/></p>' . |
---|
965 | '</div>'; |
---|
966 | |
---|
967 | echo |
---|
968 | '<p style="clear:both;">' . |
---|
969 | form::hidden(array('d'), $d) . |
---|
970 | form::hidden(array('q'), $q) . |
---|
971 | form::hidden(array('popup'), $popup) . |
---|
972 | form::hidden(array('select'), $select) . |
---|
973 | form::hidden(array('plugin_id'), $plugin_id) . |
---|
974 | form::hidden(array('post_id'), $post_id) . |
---|
975 | form::hidden(array('link_type'), $link_type) . |
---|
976 | '</p>' . |
---|
977 | '</form>' . |
---|
978 | '</div>' . |
---|
979 | '</div>'; |
---|
980 | } |
---|
981 | |
---|
982 | # Empty remove form (for javascript actions) |
---|
983 | echo |
---|
984 | '<form id="media-remove-hide" action="' . html::escapeURL($core->adminurl->get('admin.media', $page_url_params)) . '" method="post" class="hidden">' . |
---|
985 | '<div>' . |
---|
986 | form::hidden('rmyes', 1) . |
---|
987 | form::hidden('d', html::escapeHTML($d)) . |
---|
988 | form::hidden(array('q'), $q) . |
---|
989 | form::hidden(array('popup'), $popup) . |
---|
990 | form::hidden(array('select'), $select) . |
---|
991 | form::hidden(array('plugin_id'), $plugin_id) . |
---|
992 | form::hidden(array('post_id'), $post_id) . |
---|
993 | form::hidden(array('link_type'), $link_type) . |
---|
994 | form::hidden('remove', '') . |
---|
995 | $core->formNonce() . |
---|
996 | '</div>' . |
---|
997 | '</form>'; |
---|
998 | |
---|
999 | if ((!$query) && ($core_media_writable || $core_media_archivable)) { |
---|
1000 | echo |
---|
1001 | '</div>'; |
---|
1002 | } |
---|
1003 | |
---|
1004 | if (!$popup) { |
---|
1005 | echo '<div class="info"><p>' . sprintf(__('Current settings for medias and images are defined in %s'), |
---|
1006 | '<a href="' . $core->adminurl->get("admin.blog.pref") . '#medias-settings">' . __('Blog parameters') . '</a>') . '</p></div>'; |
---|
1007 | } |
---|
1008 | |
---|
1009 | call_user_func($close_f); |
---|