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 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
34 | $nb_per_page = ((integer) $core->auth->user_prefs->interface->media_by_page ? (integer) $core->auth->user_prefs->interface->media_by_page : 30); |
---|
35 | |
---|
36 | # We are on home not comming from media manager |
---|
37 | if ($d === null && isset($_SESSION['media_manager_dir'])) { |
---|
38 | # We get session information |
---|
39 | $d = $_SESSION['media_manager_dir']; |
---|
40 | } |
---|
41 | |
---|
42 | if (!isset($_GET['page']) && isset($_SESSION['media_manager_page'])) { |
---|
43 | $page = $_SESSION['media_manager_page']; |
---|
44 | } |
---|
45 | |
---|
46 | # We set session information about directory and page |
---|
47 | if ($d) { |
---|
48 | $_SESSION['media_manager_dir'] = $d; |
---|
49 | } else { |
---|
50 | unset($_SESSION['media_manager_dir']); |
---|
51 | } |
---|
52 | if ($page != 1) { |
---|
53 | $_SESSION['media_manager_page'] = $page; |
---|
54 | } else { |
---|
55 | unset($_SESSION['media_manager_page']); |
---|
56 | } |
---|
57 | |
---|
58 | # Sort combo |
---|
59 | $sort_combo = array( |
---|
60 | __('By names, in ascending order') => 'name-asc', |
---|
61 | __('By names, in descending order') => 'name-desc', |
---|
62 | __('By dates, in ascending order') => 'date-asc', |
---|
63 | __('By dates, in descending order') => 'date-desc' |
---|
64 | ); |
---|
65 | |
---|
66 | if (!empty($_GET['file_sort']) && in_array($_GET['file_sort'],$sort_combo)) { |
---|
67 | $_SESSION['media_file_sort'] = $_GET['file_sort']; |
---|
68 | } |
---|
69 | $file_sort = !empty($_SESSION['media_file_sort']) ? $_SESSION['media_file_sort'] : null; |
---|
70 | $nb_per_page = !empty($_SESSION['nb_per_page']) ? (integer)$_SESSION['nb_per_page'] : $nb_per_page; |
---|
71 | if (!empty($_GET['nb_per_page']) && (integer)$_GET['nb_per_page'] > 0) { |
---|
72 | $nb_per_page = $_SESSION['nb_per_page'] = (integer)$_GET['nb_per_page']; |
---|
73 | } |
---|
74 | |
---|
75 | $popup = (integer) !empty($_REQUEST['popup']); |
---|
76 | |
---|
77 | $page_url_params = new ArrayObject(array('popup' => $popup,'post_id' => $post_id)); |
---|
78 | if ($d) { |
---|
79 | $page_url_params['d'] = $d; |
---|
80 | } |
---|
81 | if ($plugin_id != '') { |
---|
82 | $page_url_params['plugin_id'] = $plugin_id; |
---|
83 | } |
---|
84 | |
---|
85 | $core->callBehavior('adminMediaURLParams',$page_url_params); |
---|
86 | $page_url_params = (array) $page_url_params; |
---|
87 | |
---|
88 | if ($popup) { |
---|
89 | $open_f = array('dcPage','openPopup'); |
---|
90 | $close_f = array('dcPage','closePopup'); |
---|
91 | } else { |
---|
92 | $open_f = array('dcPage','open'); |
---|
93 | $close_f = create_function('',"dcPage::helpBlock('core_media'); dcPage::close();"); |
---|
94 | } |
---|
95 | |
---|
96 | $core_media_writable = false; |
---|
97 | try { |
---|
98 | $core->media = new dcMedia($core); |
---|
99 | if ($file_sort) { |
---|
100 | $core->media->setFileSort($file_sort); |
---|
101 | } |
---|
102 | $core->media->chdir($d); |
---|
103 | $core->media->getDir(); |
---|
104 | $core_media_writable = $core->media->writable(); |
---|
105 | $dir =& $core->media->dir; |
---|
106 | if (!$core_media_writable) { |
---|
107 | // throw new Exception('you do not have sufficient permissions to write to this folder: '); |
---|
108 | } |
---|
109 | } catch (Exception $e) { |
---|
110 | $core->error->add($e->getMessage()); |
---|
111 | } |
---|
112 | |
---|
113 | # Zip download |
---|
114 | if (!empty($_GET['zipdl']) && $core->auth->check('media_admin',$core->blog->id)) |
---|
115 | { |
---|
116 | try |
---|
117 | { |
---|
118 | @set_time_limit(300); |
---|
119 | $fp = fopen('php://output','wb'); |
---|
120 | $zip = new fileZip($fp); |
---|
121 | $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#'); |
---|
122 | $zip->addDirectory($core->media->root.'/'.$d,'',true); |
---|
123 | |
---|
124 | header('Content-Disposition: attachment;filename='.($d ? $d : 'media').'.zip'); |
---|
125 | header('Content-Type: application/x-zip'); |
---|
126 | $zip->write(); |
---|
127 | unset($zip); |
---|
128 | exit; |
---|
129 | } |
---|
130 | catch (Exception $e) |
---|
131 | { |
---|
132 | $core->error->add($e->getMessage()); |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | # New directory |
---|
137 | if ($dir && !empty($_POST['newdir'])) |
---|
138 | { |
---|
139 | try { |
---|
140 | $core->media->makeDir($_POST['newdir']); |
---|
141 | dcPage::addSuccessNotice(sprintf( |
---|
142 | __('Directory "%s" has been successfully created.'), |
---|
143 | html::escapeHTML($_POST['newdir'])) |
---|
144 | ); |
---|
145 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
146 | } catch (Exception $e) { |
---|
147 | $core->error->add($e->getMessage()); |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | # Adding a file |
---|
152 | if ($dir && !empty($_FILES['upfile'])) { |
---|
153 | // only one file per request : @see option singleFileUploads in admin/js/jsUpload/jquery.fileupload |
---|
154 | $upfile = array('name' => $_FILES['upfile']['name'][0], |
---|
155 | 'type' => $_FILES['upfile']['type'][0], |
---|
156 | 'tmp_name' => $_FILES['upfile']['tmp_name'][0], |
---|
157 | 'error' => $_FILES['upfile']['error'][0], |
---|
158 | 'size' => $_FILES['upfile']['size'][0] |
---|
159 | ); |
---|
160 | |
---|
161 | if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
---|
162 | header('Content-type: application/json'); |
---|
163 | $message = array(); |
---|
164 | |
---|
165 | try { |
---|
166 | files::uploadStatus($upfile); |
---|
167 | $new_file_id = $core->media->uploadFile($upfile['tmp_name'], $upfile['name']); |
---|
168 | |
---|
169 | $message['files'][] = array( |
---|
170 | 'name' => $upfile['name'], |
---|
171 | 'size' => $upfile['size'], |
---|
172 | 'html' => mediaItemLine($core->media->getFile($new_file_id), 1) |
---|
173 | ); |
---|
174 | } catch (Exception $e) { |
---|
175 | $message['files'][] = array('name' => $upfile['name'], |
---|
176 | 'size' => $upfile['size'], |
---|
177 | 'error' => $e->getMessage() |
---|
178 | ); |
---|
179 | } |
---|
180 | echo json_encode($message); |
---|
181 | exit(); |
---|
182 | } else { |
---|
183 | try { |
---|
184 | files::uploadStatus($upfile); |
---|
185 | |
---|
186 | $f_title = (isset($_POST['upfiletitle']) ? $_POST['upfiletitle'] : ''); |
---|
187 | $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false); |
---|
188 | |
---|
189 | $core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $f_title, $f_private); |
---|
190 | |
---|
191 | dcPage::addSuccessNotice(__('Files have been successfully uploaded.')); |
---|
192 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
193 | } catch (Exception $e) { |
---|
194 | $core->error->add($e->getMessage()); |
---|
195 | } |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | # Removing items |
---|
200 | if ($dir && !empty($_POST['medias']) && !empty($_POST['delete_medias'])) { |
---|
201 | try { |
---|
202 | foreach ($_POST['medias'] as $media) { |
---|
203 | $core->media->removeItem(rawurldecode($media)); |
---|
204 | } |
---|
205 | dcPage::addSuccessNotice( |
---|
206 | sprintf(__('Successfully delete one media.', |
---|
207 | 'Successfully delete %d medias.', |
---|
208 | count($_POST['medias']) |
---|
209 | ), |
---|
210 | count($_POST['medias']) |
---|
211 | ) |
---|
212 | ); |
---|
213 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
214 | } catch (Exception $e) { |
---|
215 | $core->error->add($e->getMessage()); |
---|
216 | } |
---|
217 | } |
---|
218 | |
---|
219 | # Removing item from popup only |
---|
220 | if ($dir && !empty($_POST['rmyes']) && !empty($_POST['remove'])) |
---|
221 | { |
---|
222 | $_POST['remove'] = rawurldecode($_POST['remove']); |
---|
223 | |
---|
224 | try { |
---|
225 | if (is_dir(path::real($core->media->getPwd().'/'.path::clean($_POST['remove'])))) { |
---|
226 | $msg = __('Directory has been successfully removed.'); |
---|
227 | } else { |
---|
228 | $msg = __('File has been successfully removed.'); |
---|
229 | } |
---|
230 | $core->media->removeItem($_POST['remove']); |
---|
231 | dcPage::addSuccessNotice($msg); |
---|
232 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
233 | } catch (Exception $e) { |
---|
234 | $core->error->add($e->getMessage()); |
---|
235 | } |
---|
236 | } |
---|
237 | |
---|
238 | # Rebuild directory |
---|
239 | if ($dir && $core->auth->isSuperAdmin() && !empty($_POST['rebuild'])) |
---|
240 | { |
---|
241 | try { |
---|
242 | $core->media->rebuild($d); |
---|
243 | |
---|
244 | dcPage::success(sprintf( |
---|
245 | __('Directory "%s" has been successfully rebuilt.'), |
---|
246 | html::escapeHTML($d)) |
---|
247 | ); |
---|
248 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
249 | } catch (Exception $e) { |
---|
250 | $core->error->add($e->getMessage()); |
---|
251 | } |
---|
252 | } |
---|
253 | |
---|
254 | # DISPLAY confirm page for rmdir & rmfile |
---|
255 | if ($dir && !empty($_GET['remove']) && empty($_GET['noconfirm'])) |
---|
256 | { |
---|
257 | call_user_func($open_f,__('Media manager'),'', |
---|
258 | dcPage::breadcrumb( |
---|
259 | array( |
---|
260 | html::escapeHTML($core->blog->name) => '', |
---|
261 | __('Media manager') => '', |
---|
262 | __('confirm removal') => '' |
---|
263 | ), |
---|
264 | array('home_link' => !$popup) |
---|
265 | ) |
---|
266 | ); |
---|
267 | |
---|
268 | echo |
---|
269 | '<form action="'.html::escapeURL($core->adminurl->get('admin.media')).'" method="post">'. |
---|
270 | '<p>'.sprintf(__('Are you sure you want to remove %s?'), |
---|
271 | html::escapeHTML($_GET['remove'])).'</p>'. |
---|
272 | '<p><input type="submit" value="'.__('Cancel').'" /> '. |
---|
273 | ' <input type="submit" name="rmyes" value="'.__('Yes').'" />'. |
---|
274 | form::hidden('d',$d). |
---|
275 | $core->adminurl->getHiddenFormFields('admin.media',$page_url_params). |
---|
276 | $core->formNonce(). |
---|
277 | form::hidden('remove',html::escapeHTML($_GET['remove'])).'</p>'. |
---|
278 | '</form>'; |
---|
279 | |
---|
280 | call_user_func($close_f); |
---|
281 | exit; |
---|
282 | } |
---|
283 | |
---|
284 | /* DISPLAY Main page |
---|
285 | -------------------------------------------------------- */ |
---|
286 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
287 | $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; |
---|
288 | |
---|
289 | if (!isset($core->media)) { |
---|
290 | $breadcrumb = dcPage::breadcrumb( |
---|
291 | array( |
---|
292 | html::escapeHTML($core->blog->name) => '', |
---|
293 | __('Media manager') => '' |
---|
294 | ), |
---|
295 | array('home_link' => !$popup) |
---|
296 | ); |
---|
297 | } else { |
---|
298 | $temp_params = $page_url_params; |
---|
299 | $temp_params['d']='%s'; |
---|
300 | $bc_template = $core->adminurl->get('admin.media',$temp_params,'&',true); |
---|
301 | $breadcrumb_media = $core->media->breadCrumb($bc_template,'<span class="page-title">%s</span>'); |
---|
302 | if ($breadcrumb_media == '') { |
---|
303 | $breadcrumb = dcPage::breadcrumb( |
---|
304 | array( |
---|
305 | html::escapeHTML($core->blog->name) => '', |
---|
306 | __('Media manager') => '' |
---|
307 | ), |
---|
308 | array('home_link' => !$popup) |
---|
309 | ); |
---|
310 | } else { |
---|
311 | $home_params = $page_url_params; |
---|
312 | $home_params['d']=''; |
---|
313 | |
---|
314 | $breadcrumb = dcPage::breadcrumb( |
---|
315 | array( |
---|
316 | html::escapeHTML($core->blog->name) => '', |
---|
317 | __('Media manager') => $core->adminurl->get('admin.media',$home_params), |
---|
318 | $breadcrumb_media => '' |
---|
319 | ), |
---|
320 | array( |
---|
321 | 'home_link' => !$popup, |
---|
322 | 'hl' => false |
---|
323 | ) |
---|
324 | ); |
---|
325 | } |
---|
326 | } |
---|
327 | |
---|
328 | call_user_func($open_f,__('Media manager'), |
---|
329 | dcPage::jsLoad('js/_media.js'). |
---|
330 | ($core_media_writable ? dcPage::jsUpload(array('d='.$d)) : ''), |
---|
331 | $breadcrumb |
---|
332 | ); |
---|
333 | |
---|
334 | if ($popup) { |
---|
335 | // Display notices |
---|
336 | echo dcPage::notices(); |
---|
337 | } |
---|
338 | |
---|
339 | if (!$core_media_writable) { |
---|
340 | dcPage::warning(__('You do not have sufficient permissions to write to this folder.')); |
---|
341 | } |
---|
342 | |
---|
343 | if (!empty($_GET['mkdok'])) { |
---|
344 | dcPage::success(__('Directory has been successfully created.')); |
---|
345 | } |
---|
346 | |
---|
347 | if (!empty($_GET['upok'])) { |
---|
348 | dcPage::success(__('Files have been successfully uploaded.')); |
---|
349 | } |
---|
350 | |
---|
351 | if (!empty($_GET['rmfok'])) { |
---|
352 | dcPage::success(__('File has been successfully removed.')); |
---|
353 | } |
---|
354 | |
---|
355 | if (!empty($_GET['rmdok'])) { |
---|
356 | dcPage::success(__('Directory has been successfully removed.')); |
---|
357 | } |
---|
358 | |
---|
359 | if (!empty($_GET['rebuildok'])) { |
---|
360 | dcPage::success(__('Directory has been successfully rebuilt.')); |
---|
361 | } |
---|
362 | |
---|
363 | if (!empty($_GET['unzipok'])) { |
---|
364 | dcPage::success(__('Zip file has been successfully extracted.')); |
---|
365 | } |
---|
366 | |
---|
367 | if (!$dir) { |
---|
368 | call_user_func($close_f); |
---|
369 | exit; |
---|
370 | } |
---|
371 | |
---|
372 | if ($post_id) { |
---|
373 | echo '<div class="form-note info"><p>'.sprintf(__('Choose a file to attach to entry %s by clicking on %s.'), |
---|
374 | '<a href="'.$core->getPostAdminURL($post_type,$post_id).'">'.html::escapeHTML($post_title).'</a>', |
---|
375 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />').'</p></div>'; |
---|
376 | } |
---|
377 | if ($popup) { |
---|
378 | echo '<div class="info"><p>'.sprintf(__('Choose a file to insert into entry by clicking on %s.'), |
---|
379 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />').'</p></div>'; |
---|
380 | } |
---|
381 | |
---|
382 | // Remove hidden directories (unless DC_SHOW_HIDDEN_DIRS is set to true) |
---|
383 | if (!defined('DC_SHOW_HIDDEN_DIRS') || (DC_SHOW_HIDDEN_DIRS == false)) { |
---|
384 | for ($i = count($dir['dirs']) - 1; $i >= 0; $i--) { |
---|
385 | if ($dir['dirs'][$i]->d) { |
---|
386 | if (strpos($dir['dirs'][$i]->relname,'.') !== false) { |
---|
387 | unset($dir['dirs'][$i]); |
---|
388 | } |
---|
389 | } |
---|
390 | } |
---|
391 | } |
---|
392 | $items = array_values(array_merge($dir['dirs'],$dir['files'])); |
---|
393 | |
---|
394 | $fmt_form_media = '<form action="'.$core->adminurl->get("admin.media").'" method="post" id="form-medias">'. |
---|
395 | '<div class="files-group">%s</div>'. |
---|
396 | '<p class="hidden">'.$core->formNonce() . form::hidden(array('d'),$d).form::hidden(array('plugin_id'),$plugin_id).'</p>'; |
---|
397 | |
---|
398 | if (!$popup) { |
---|
399 | $fmt_form_media .= |
---|
400 | '<div class="medias-delete%s">'. |
---|
401 | '<p class="checkboxes-helpers"></p>'. |
---|
402 | '<p><input type="submit" class="delete" name="delete_medias" value="'.__('Remove selected medias').'"/></p>'. |
---|
403 | '</div>'; |
---|
404 | } |
---|
405 | $fmt_form_media .= |
---|
406 | '</form>'; |
---|
407 | |
---|
408 | echo '<div class="media-list">'; |
---|
409 | if (count($items) == 0) |
---|
410 | { |
---|
411 | echo |
---|
412 | '<p>'.__('No file.').'</p>'. |
---|
413 | sprintf($fmt_form_media,'',' hide'); // need for jsUpload to append new media |
---|
414 | } |
---|
415 | else |
---|
416 | { |
---|
417 | $pager = new dcPager($page,count($items),$nb_per_page,10); |
---|
418 | |
---|
419 | echo |
---|
420 | '<form action="'.$core->adminurl->get("admin.media").'" method="get" id="filters-form">'. |
---|
421 | '<p class="two-boxes"><label for="file_sort" class="classic">'.__('Sort files:').'</label> '. |
---|
422 | form::combo('file_sort',$sort_combo,$file_sort).'</p>'. |
---|
423 | '<p class="two-boxes"><label for="nb_per_page" class="classic">'.__('Number of elements displayed per page:').'</label> '. |
---|
424 | form::field('nb_per_page',5,3,(integer) $nb_per_page).' '. |
---|
425 | '<input type="submit" value="'.__('OK').'" />'. |
---|
426 | form::hidden(array('popup'),$popup). |
---|
427 | form::hidden(array('plugin_id'),$plugin_id). |
---|
428 | form::hidden(array('post_id'),$post_id). |
---|
429 | '</p>'. |
---|
430 | '</form>'. |
---|
431 | $pager->getLinks(); |
---|
432 | |
---|
433 | $dgroup = ''; |
---|
434 | $fgroup = ''; |
---|
435 | for ($i=$pager->index_start, $j=0; $i<=$pager->index_end; $i++,$j++) |
---|
436 | { |
---|
437 | if ($items[$i]->d) { |
---|
438 | $dgroup .= mediaItemLine($items[$i],$j); |
---|
439 | } else { |
---|
440 | $fgroup .= mediaItemLine($items[$i],$j); |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | echo |
---|
445 | ($dgroup != '' ? '<div class="folders-group">'.$dgroup.'</div>' : ''). |
---|
446 | sprintf($fmt_form_media,$fgroup,''); |
---|
447 | |
---|
448 | echo $pager->getLinks(); |
---|
449 | } |
---|
450 | if (!isset($pager)) { |
---|
451 | echo |
---|
452 | '<p class="clear"></p>'; |
---|
453 | } |
---|
454 | echo |
---|
455 | '</div>'; |
---|
456 | |
---|
457 | $core_media_archivable = $core->auth->check('media_admin',$core->blog->id) && |
---|
458 | !(count($items) == 0 || (count($items) == 1 && $items[0]->parent)); |
---|
459 | |
---|
460 | if ($core_media_writable || $core_media_archivable) { |
---|
461 | echo |
---|
462 | '<div class="vertical-separator">'. |
---|
463 | '<h3 class="out-of-screen-if-js">'.sprintf(__('In %s:'),($d == '' ? '“'.__('Media manager').'”' : '“'.$d.'”')).'</h3>'; |
---|
464 | } |
---|
465 | |
---|
466 | if ($core_media_writable || $core_media_archivable) { |
---|
467 | echo |
---|
468 | '<div class="two-boxes odd">'; |
---|
469 | |
---|
470 | # Create directory |
---|
471 | if ($core_media_writable) |
---|
472 | { |
---|
473 | echo |
---|
474 | '<form action="'.$core->adminurl->getBase('admin.media').'" method="post" class="fieldset">'. |
---|
475 | '<div id="new-dir-f">'. |
---|
476 | '<h4 class="pretty-title">'.__('Create new directory').'</h4>'. |
---|
477 | $core->formNonce(). |
---|
478 | '<p><label for="newdir">'.__('Directory Name:').'</label>'. |
---|
479 | form::field(array('newdir','newdir'),35,255).'</p>'. |
---|
480 | '<p><input type="submit" value="'.__('Create').'" />'. |
---|
481 | $core->adminurl->getHiddenFormFields('admin.media',$page_url_params). |
---|
482 | '</p>'. |
---|
483 | '</div>'. |
---|
484 | '</form>'; |
---|
485 | } |
---|
486 | |
---|
487 | # Get zip directory |
---|
488 | if ($core_media_archivable && !$popup) |
---|
489 | { |
---|
490 | echo |
---|
491 | '<div class="fieldset">'. |
---|
492 | '<h4 class="pretty-title">'.sprintf(__('Backup content of %s'),($d == '' ? '“'.__('Media manager').'”' : '“'.$d.'”')).'</h4>'. |
---|
493 | '<p><a class="button submit" href="'.$core->adminurl->get('admin.media', |
---|
494 | array_merge($page_url_params,array('zipdl' => 1))).'">'.__('Download zip file').'</a></p>'. |
---|
495 | '</div>'; |
---|
496 | } |
---|
497 | |
---|
498 | echo |
---|
499 | '</div>'; |
---|
500 | } |
---|
501 | |
---|
502 | if ($core_media_writable) |
---|
503 | { |
---|
504 | echo |
---|
505 | '<div class="two-boxes fieldset even">'; |
---|
506 | if ($user_ui_enhanceduploader) { |
---|
507 | echo |
---|
508 | '<div class="enhanced_uploader">'; |
---|
509 | } else { |
---|
510 | echo |
---|
511 | '<div>'; |
---|
512 | } |
---|
513 | |
---|
514 | echo |
---|
515 | '<h4>'.__('Add files').'</h4>'. |
---|
516 | '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. |
---|
517 | '<form id="fileupload" action="'.html::escapeURL($page_url).'" method="post" enctype="multipart/form-data" aria-disabled="false">'. |
---|
518 | '<p>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). |
---|
519 | $core->formNonce().'</p>'. |
---|
520 | '<div class="fileupload-ctrl"><p class="queue-message"></p><ul class="files"></ul></div>'; |
---|
521 | |
---|
522 | echo |
---|
523 | '<div class="fileupload-buttonbar clear">'; |
---|
524 | |
---|
525 | echo |
---|
526 | '<p><label for="upfile">'.'<span class="add-label one-file">'.__('Choose file').'</span>'.'</label>'. |
---|
527 | '<button class="button choose_files">'.__('Choose files').'</button>'. |
---|
528 | '<input type="file" id="upfile" name="upfile[]"'.($user_ui_enhanceduploader?' multiple="mutiple"':'').' data-url="'.html::escapeURL($page_url).'" /></p>'; |
---|
529 | |
---|
530 | echo |
---|
531 | '<p class="max-sizer form-note"> '.__('Maximum file size allowed:').' '.files::size(DC_MAX_UPLOAD_SIZE).'</p>'; |
---|
532 | |
---|
533 | echo |
---|
534 | '<p class="one-file"><label for="upfiletitle">'.__('Title:').'</label>'.form::field(array('upfiletitle','upfiletitle'),35,255).'</p>'. |
---|
535 | '<p class="one-file"><label for="upfilepriv" class="classic">'.__('Private').'</label> '. |
---|
536 | form::checkbox(array('upfilepriv','upfilepriv'),1).'</p>'; |
---|
537 | |
---|
538 | if (!$user_ui_enhanceduploader) { |
---|
539 | echo |
---|
540 | '<p class="one-file form-help info">'.__('To send several files at the same time, you can activate the enhanced uploader in'). |
---|
541 | ' <a href="'.$core->adminurl->get("admin.user.preferences",array('tab' => 'user-options')).'">'.__('My preferences').'</a></p>'; |
---|
542 | } |
---|
543 | |
---|
544 | echo |
---|
545 | '<p class="clear"><button class="button clean">'.__('Refresh').'</button>'. |
---|
546 | '<input class="button cancel one-file" type="reset" value="'.__('Clear all').'"/>'. |
---|
547 | '<input class="button start" type="submit" value="'.__('Upload').'"/></p>'. |
---|
548 | '</div>'; |
---|
549 | |
---|
550 | echo |
---|
551 | '<p style="clear:both;">'.form::hidden(array('d'),$d).'</p>'. |
---|
552 | '</form>'. |
---|
553 | '</div>'. |
---|
554 | '</div>'; |
---|
555 | } |
---|
556 | |
---|
557 | # Empty remove form (for javascript actions) |
---|
558 | echo |
---|
559 | '<form id="media-remove-hide" action="'.html::escapeURL($page_url).'" method="post" class="hidden">'. |
---|
560 | '<div>'. |
---|
561 | form::hidden('rmyes',1).form::hidden('d',html::escapeHTML($d)). |
---|
562 | form::hidden(array('plugin_id'),$plugin_id).form::hidden('remove',''). |
---|
563 | $core->formNonce(). |
---|
564 | '</div>'. |
---|
565 | '</form>'; |
---|
566 | |
---|
567 | if ($core_media_writable || $core_media_archivable) { |
---|
568 | echo |
---|
569 | '</div>'; |
---|
570 | } |
---|
571 | |
---|
572 | if (!$popup) { |
---|
573 | echo '<div class="info"><p>'.sprintf(__('Current settings for medias and images are defined in %s'), |
---|
574 | '<a href="'.$core->adminurl->get("admin.blog.pref").'#medias-settings">'.__('Blog parameters').'</a>').'</p></div>'; |
---|
575 | } |
---|
576 | |
---|
577 | call_user_func($close_f); |
---|
578 | |
---|
579 | /* ----------------------------------------------------- */ |
---|
580 | function mediaItemLine($f,$i) |
---|
581 | { |
---|
582 | global $core, $page_url, $popup, $post_id, $plugin_id,$page_url_params; |
---|
583 | |
---|
584 | $fname = $f->basename; |
---|
585 | |
---|
586 | $class = 'media-item media-col-'.($i%2); |
---|
587 | |
---|
588 | if ($f->d) { |
---|
589 | |
---|
590 | $link = $core->adminurl->get('admin.media',array_merge($page_url_params,array('d' => html::sanitizeURL($f->relname) ))); |
---|
591 | if ($f->parent) { |
---|
592 | $fname = '..'; |
---|
593 | $class .= ' media-folder-up'; |
---|
594 | } else { |
---|
595 | $class .= ' media-folder'; |
---|
596 | } |
---|
597 | } else { |
---|
598 | $params = new ArrayObject( |
---|
599 | array( |
---|
600 | 'id' => $f->media_id, |
---|
601 | 'plugin_id' => $plugin_id, |
---|
602 | 'popup' => $popup, |
---|
603 | 'post_id' => $post_id |
---|
604 | ) |
---|
605 | ); |
---|
606 | $core->callBehavior('adminMediaURLParams',$params); |
---|
607 | $params = (array) $params; |
---|
608 | $link = $core->adminurl->get( |
---|
609 | 'admin.media.item', $params |
---|
610 | ); |
---|
611 | } |
---|
612 | |
---|
613 | $maxchars = 36; |
---|
614 | if (strlen($fname) > $maxchars) { |
---|
615 | $fname = substr($fname, 0, $maxchars-4).'...'.($f->d ? '' : files::getExtension($fname)); |
---|
616 | } |
---|
617 | $res = |
---|
618 | '<div class="'.$class.'"><p><a class="media-icon media-link" href="'.rawurldecode($link).'">'. |
---|
619 | '<img src="'.$f->media_icon.'" alt="" />'.$fname.'</a></p>'; |
---|
620 | |
---|
621 | $lst = ''; |
---|
622 | |
---|
623 | if (!$f->d) { |
---|
624 | $lst .= |
---|
625 | '<li>'.$f->media_title.'</li>'. |
---|
626 | '<li>'. |
---|
627 | $f->media_dtstr.' - '. |
---|
628 | files::size($f->size).' - '. |
---|
629 | '<a href="'.$f->file_url.'">'.__('open').'</a>'. |
---|
630 | '</li>'; |
---|
631 | } |
---|
632 | |
---|
633 | $act = ''; |
---|
634 | |
---|
635 | if ($post_id && !$f->d) { |
---|
636 | $act .= |
---|
637 | '<a class="attach-media" title="'.__('Attach this file to entry').'" href="'. |
---|
638 | $core->adminurl->get("admin.post.media", array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1)). |
---|
639 | '">'. |
---|
640 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'. |
---|
641 | '</a>'; |
---|
642 | } |
---|
643 | |
---|
644 | if ($popup && !$f->d) { |
---|
645 | $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '. |
---|
646 | 'title="'.__('Insert this file into entry').'" /></a> '; |
---|
647 | } |
---|
648 | |
---|
649 | if ($f->del) { |
---|
650 | if (!$popup && !$f->d) { |
---|
651 | $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($f->basename)),rawurlencode($f->basename)); |
---|
652 | } else { |
---|
653 | $act .= '<a class="media-remove" '. |
---|
654 | 'href="'.html::escapeURL($page_url).'&plugin_id='.$plugin_id.'&d='. |
---|
655 | rawurlencode($GLOBALS['d']).'&remove='.rawurlencode($f->basename).'">'. |
---|
656 | '<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>'; |
---|
657 | } |
---|
658 | } |
---|
659 | |
---|
660 | $lst .= ($act != '' ? '<li class="media-action"> '.$act.'</li>' : ''); |
---|
661 | |
---|
662 | // Show player if relevant |
---|
663 | $file_type = explode('/',$f->type); |
---|
664 | if ($file_type[0] == 'audio') |
---|
665 | { |
---|
666 | $lst .= '<li>'.dcMedia::audioPlayer($f->type,$f->file_url,$core->adminurl->get("admin.home",array('pf' => 'player_mp3.swf'))).'</li>'; |
---|
667 | } |
---|
668 | |
---|
669 | $res .= ($lst != '' ? '<ul>'.$lst.'</ul>' : ''); |
---|
670 | |
---|
671 | $res .= '</div>'; |
---|
672 | |
---|
673 | return $res; |
---|
674 | } |
---|