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