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