Dotclear

source: admin/media_item.php @ 2799:b62c278ef730

Revision 2799:b62c278ef730, 22.2 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

Add an option to not leave date alone in media title

Line 
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
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('media,media_admin');
16
17$tab = empty($_REQUEST['tab']) ? '' : $_REQUEST['tab'];
18
19$post_id = !empty($_GET['post_id']) ? (integer) $_GET['post_id'] : null;
20if ($post_id) {
21     $post = $core->blog->getPosts(array('post_id'=>$post_id));
22     if ($post->isEmpty()) {
23          $post_id = null;
24     }
25     $post_title = $post->post_title;
26     unset($post);
27}
28
29$file = null;
30$popup = (integer) !empty($_GET['popup']);
31$plugin_id = isset($_REQUEST['plugin_id']) ? html::sanitizeURL($_REQUEST['plugin_id']) : '';
32$page_url = $core->adminurl->get("admin.media.item",array('popup' => $popup,'post_id' => $post_id));
33$media_page_url = $core->adminurl->get("admin.media",array('popup' => $popup,'post_id' => $post_id));
34
35$id = !empty($_REQUEST['id']) ? (integer) $_REQUEST['id'] : '';
36
37if ($popup) {
38     $open_f = array('dcPage','openPopup');
39     $close_f = array('dcPage','closePopup');
40} else {
41     $open_f = array('dcPage','open');
42     $close_f = create_function('',"dcPage::helpBlock('core_media'); dcPage::close();");
43}
44
45$core_media_writable = false;
46try
47{
48     $core->media = new dcMedia($core);
49
50     if ($id) {
51          $file = $core->media->getFile($id);
52     }
53
54     if ($file === null) {
55          throw new Exception(__('Not a valid file'));
56     }
57
58     $core->media->chdir(dirname($file->relname));
59     $core_media_writable = $core->media->writable();
60
61     # Prepare directories combo box
62     $dirs_combo = array();
63     foreach ($core->media->getDBDirs() as $v) {
64          $dirs_combo['/'.$v] = $v;
65     }
66     # Add parent and direct childs directories if any
67     $core->media->getFSDir();
68     foreach ($core->media->dir['dirs'] as $k => $v) {
69          $dirs_combo['/'.$v->relname] = $v->relname;
70     }
71     ksort($dirs_combo);
72}
73catch (Exception $e)
74{
75     $core->error->add($e->getMessage());
76}
77
78# Upload a new file
79if ($file && !empty($_FILES['upfile']) && $file->editable && $core_media_writable)
80{
81     try {
82          files::uploadStatus($_FILES['upfile']);
83          $core->media->uploadFile($_FILES['upfile']['tmp_name'],$file->basename,null,false,true);
84
85          dcPage::addSuccessNotice(__('File has been successfully updated.'));
86          http::redirect($page_url.'&id='.$id.'&plugin_id='.$plugin_id);
87     } catch (Exception $e) {
88          $core->error->add($e->getMessage());
89     }
90}
91
92# Update file
93if ($file && !empty($_POST['media_file']) && $file->editable && $core_media_writable)
94{
95     $newFile = clone $file;
96
97     $newFile->basename = $_POST['media_file'];
98
99     if ($_POST['media_path']) {
100          $newFile->dir = $_POST['media_path'];
101          $newFile->relname = $_POST['media_path'].'/'.$newFile->basename;
102     } else {
103          $newFile->dir = '';
104          $newFile->relname = $newFile->basename;
105     }
106     $newFile->media_title = $_POST['media_title'];
107     $newFile->media_dt = strtotime($_POST['media_dt']);
108     $newFile->media_dtstr = $_POST['media_dt'];
109     $newFile->media_priv = !empty($_POST['media_private']);
110
111     try {
112          $core->media->updateFile($file,$newFile);
113
114          dcPage::addSuccessNotice(__('File has been successfully updated.'));
115          http::redirect($page_url.'&id='.$id.'&plugin_id='.$plugin_id.'&tab=media-details-tab');
116     } catch (Exception $e) {
117          $core->error->add($e->getMessage());
118     }
119}
120
121# Update thumbnails
122if (!empty($_POST['thumbs']) && $file->media_type == 'image' && $file->editable && $core_media_writable)
123{
124     try {
125          $foo = null;
126          $core->media->mediaFireRecreateEvent($file);
127
128          dcPage::addSuccessNotice(__('Thumbnails have been successfully updated.'));
129          http::redirect($page_url.'&id='.$id.'&plugin_id='.$plugin_id.'&tab=media-details-tab');
130     } catch (Exception $e) {
131          $core->error->add($e->getMessage());
132     }
133}
134
135# Unzip file
136if (!empty($_POST['unzip']) && $file->type == 'application/zip' && $file->editable && $core_media_writable)
137{
138     try {
139          $unzip_dir = $core->media->inflateZipFile($file,$_POST['inflate_mode'] == 'new');
140
141          dcPage::addSuccessNotice(__('Zip file has been successfully extracted.'));
142          http::redirect($media_page_url.'&d='.$unzip_dir.'&plugin_id='.$plugin_id);
143     } catch (Exception $e) {
144          $core->error->add($e->getMessage());
145     }
146}
147
148# Save media insertion settings for the blog
149if (!empty($_POST['save_blog_prefs']))
150{
151     if (!empty($_POST['pref_src'])) {
152          foreach (array_reverse($file->media_thumb) as $s => $v) {
153               if ($v == $_POST['pref_src']) {
154                    $core->blog->settings->system->put('media_img_default_size',$s);
155                    break;
156               }
157          }
158     }
159     if (!empty($_POST['pref_alignment'])) {
160          $core->blog->settings->system->put('media_img_default_alignment',$_POST['pref_alignment']);
161     }
162     if (!empty($_POST['pref_insertion'])) {
163          $core->blog->settings->system->put('media_img_default_link',($_POST['pref_insertion'] == 'link'));
164     }
165
166     dcPage::addSuccessNotice(__('Default media insertion settings have been successfully updated.'));
167     http::redirect($page_url.'&id='.$id.'&plugin_id='.$plugin_id);
168}
169
170# Function to get image title based on meta
171function dcGetImageTitle($file,$pattern,$dto_first=false,$no_date_alone=false)
172{
173     $res = array();
174     $pattern = preg_split('/\s*;;\s*/',$pattern);
175     $sep = ', ';
176     $dates = 0;
177     $items = 0;
178
179     foreach ($pattern as $v) {
180          if ($v == 'Title') {
181               if ($file->media_title != '') {
182                    $res[] = $file->media_title;
183               }
184               $items++;
185          } elseif ($file->media_meta->{$v}) {
186               if ((string) $file->media_meta->{$v} != '') {
187                    $res[] = (string) $file->media_meta->{$v};
188               }
189               $items++;
190          } elseif (preg_match('/^Date\((.+?)\)$/u',$v,$m)) {
191               if ($dto_first && ($file->media_meta->DateTimeOriginal != 0)) {
192                    $res[] = dt::dt2str($m[1],(string) $file->media_meta->DateTimeOriginal);
193               } else {
194                    $res[] = dt::str($m[1],$file->media_dt);
195               }
196               $items++;
197               $dates++;
198          } elseif (preg_match('/^DateTimeOriginal\((.+?)\)$/u',$v,$m) && $file->media_meta->DateTimeOriginal) {
199               $res[] = dt::dt2str($m[1],(string) $file->media_meta->DateTimeOriginal);
200               $items++;
201               $dates++;
202          } elseif (preg_match('/^separator\((.*?)\)$/u',$v,$m)) {
203               $sep = $m[1];
204          }
205     }
206     if ($no_date_alone && $dates == count($res) && $dates < $items) {
207          // On ne laisse pas les dates seules, sauf si ce sont les seuls items du pattern (hors séparateur)
208          return '';
209     }
210     return implode($sep,$res);
211}
212
213/* DISPLAY Main page
214-------------------------------------------------------- */
215$starting_scripts =
216     '<script type="text/javascript">'."\n".
217     "//<![CDATA["."\n".
218     dcPage::jsVar('dotclear.msg.confirm_delete_media',__('Are you sure to delete this media?'))."\n".
219     "//]]>".
220     "</script>".
221     dcPage::jsLoad('js/_media_item.js');
222if ($popup && !empty($plugin_id)) {
223     $starting_scripts .= $core->callBehavior('adminPopupMedia', $plugin_id);
224}
225call_user_func($open_f,__('Media manager'),
226     $starting_scripts.
227     dcPage::jsDatePicker().
228     ($popup ? dcPage::jsPageTabs($tab) : ''),
229     dcPage::breadcrumb(
230          array(
231               html::escapeHTML($core->blog->name) => '',
232               __('Media manager') => html::escapeURL($media_page_url).'&amp;d=',
233               $core->media->breadCrumb(html::escapeURL($media_page_url).'&amp;d=%s').'<span class="page-title">'.$file->basename.'</span>' => ''
234          ),
235          array(
236               'home_link' => !$popup,
237               'hl' => false
238          )
239     )
240);
241
242if ($popup) {
243     // Display notices
244     echo dcPage::notices();
245}
246
247if ($file === null) {
248     call_user_func($close_f);
249     exit;
250}
251
252if (!empty($_GET['fupd']) || !empty($_GET['fupl'])) {
253     dcPage::success(__('File has been successfully updated.'));
254}
255if (!empty($_GET['thumbupd'])) {
256     dcPage::success(__('Thumbnails have been successfully updated.'));
257}
258if (!empty($_GET['blogprefupd'])) {
259     dcPage::success(__('Default media insertion settings have been successfully updated.'));
260}
261
262# Get major file type (first part of mime type)
263$file_type = explode('/',$file->type);
264
265# Insertion popup
266if ($popup)
267{
268     $media_desc = $file->media_title;
269
270     echo
271     '<div id="media-insert" class="multi-part" title="'.__('Insert media item').'">'.
272     '<h3>'.__('Insert media item').'</h3>'.
273     '<form id="media-insert-form" action="" method="get">';
274
275     $media_img_default_size = $core->blog->settings->system->media_img_default_size;
276     if ($media_img_default_size == '') {
277          $media_img_default_size = 'm';
278     }
279     $media_img_default_alignment = $core->blog->settings->system->media_img_default_alignment;
280     if ($media_img_default_alignment == '') {
281          $media_img_default_alignment = 'none';
282     }
283     $media_img_default_link = (boolean)$core->blog->settings->system->media_img_default_link;
284
285     if ($file->media_type == 'image')
286     {
287          $media_type = 'image';
288          $media_desc = dcGetImageTitle($file,
289               $core->blog->settings->system->media_img_title_pattern,
290               $core->blog->settings->system->media_img_use_dto_first,
291               $core->blog->settings->system->media_img_no_date_alone);
292          if ($media_desc == $file->basename) {
293               $media_desc = '';
294          }
295
296          echo
297          '<h3>'.__('Image size:').'</h3> ';
298
299          $s_checked = false;
300          echo '<p>';
301          foreach (array_reverse($file->media_thumb) as $s => $v) {
302               $s_checked = ($s == $media_img_default_size);
303               echo '<label class="classic">'.
304               form::radio(array('src'),html::escapeHTML($v),$s_checked).' '.
305               $core->media->thumb_sizes[$s][2].'</label><br /> ';
306          }
307          $s_checked = (!isset($file->media_thumb[$media_img_default_size]));
308          echo '<label class="classic">'.
309          form::radio(array('src'),$file->file_url,$s_checked).' '.__('original').'</label><br /> ';
310          echo '</p>';
311
312          echo
313          '<div class="two-boxes">'.
314          '<h3>'.__('Image alignment').'</h3>';
315          $i_align = array(
316               'none' => array(__('None'),($media_img_default_alignment == 'none' ? 1 : 0)),
317               'left' => array(__('Left'),($media_img_default_alignment == 'left' ? 1 : 0)),
318               'right' => array(__('Right'),($media_img_default_alignment == 'right' ? 1 : 0)),
319               'center' => array(__('Center'),($media_img_default_alignment == 'center' ? 1 : 0))
320          );
321
322          echo '<p>';
323          foreach ($i_align as $k => $v) {
324               echo '<label class="classic">'.
325               form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> ';
326          }
327          echo '</p>';
328          echo '</div>';
329
330          echo
331          '<div class="two-boxes">'.
332          '<h3>'.__('Image insertion').'</h3>'.
333          '<p>'.
334          '<label for="insert1" class="classic">'.form::radio(array('insertion','insert1'),'simple',!$media_img_default_link).
335          __('As a single image').'</label><br />'.
336          '<label for="insert2" class="classic">'.form::radio(array('insertion','insert2'),'link',$media_img_default_link).
337          __('As a link to the original image').'</label>'.
338          '</p>'.
339          '</div>';
340     }
341     elseif ($file_type[0] == 'audio')
342     {
343          $media_type = 'mp3';
344
345          echo
346          '<div class="two-boxes">'.
347          '<h3>'.__('MP3 disposition').'</h3>';
348          dcPage::message(__("Please note that you cannot insert mp3 files with visual editor."),false);
349
350          $i_align = array(
351               'none' => array(__('None'),($media_img_default_alignment == 'none' ? 1 : 0)),
352               'left' => array(__('Left'),($media_img_default_alignment == 'left' ? 1 : 0)),
353               'right' => array(__('Right'),($media_img_default_alignment == 'right' ? 1 : 0)),
354               'center' => array(__('Center'),($media_img_default_alignment == 'center' ? 1 : 0))
355          );
356
357          echo '<p>';
358          foreach ($i_align as $k => $v) {
359               echo '<label class="classic">'.
360               form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> ';
361          }
362
363          $public_player_style = unserialize($core->blog->settings->themes->mp3player_style);
364          $public_player = dcMedia::audioPlayer($file->type,$file->file_url,$core->blog->getQmarkURL().'pf=player_mp3.swf',$public_player_style);
365          echo form::hidden('public_player',html::escapeHTML($public_player));
366          echo '</p>';
367          echo '</div>';
368     }
369     elseif ($file_type[0] == 'video')
370     {
371          $media_type = 'flv';
372
373          dcPage::message(__("Please note that you cannot insert video files with visual editor."),false);
374
375          echo
376          '<div class="two-boxes">'.
377          '<h3>'.__('Video size').'</h3>'.
378          '<p><label for="video_w" class="classic">'.__('Width:').'</label> '.
379          form::field('video_w',3,4,400).'  '.
380          '<label for="video_h" class="classic">'.__('Height:').'</label> '.
381          form::field('video_h',3,4,300).
382          '</p>'.
383          '</div>';
384
385
386          echo
387          '<div class="two-boxes">'.
388          '<h3>'.__('Video disposition').'</h3>';
389
390          $i_align = array(
391               'none' => array(__('None'),($media_img_default_alignment == 'none' ? 1 : 0)),
392               'left' => array(__('Left'),($media_img_default_alignment == 'left' ? 1 : 0)),
393               'right' => array(__('Right'),($media_img_default_alignment == 'right' ? 1 : 0)),
394               'center' => array(__('Center'),($media_img_default_alignment == 'center' ? 1 : 0))
395          );
396
397          echo '<p>';
398          foreach ($i_align as $k => $v) {
399               echo '<label class="classic">'.
400               form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> ';
401          }
402
403          $public_player_style = unserialize($core->blog->settings->themes->flvplayer_style);
404          $public_player = dcMedia::videoPlayer($file->type,$file->file_url,$core->blog->getQmarkURL().'pf=player_flv.swf',$public_player_style);
405          echo form::hidden('public_player',html::escapeHTML($public_player));
406          echo '</p>';
407          echo '</div>';
408     }
409     else
410     {
411          $media_type = 'default';
412          echo '<p>'.__('Media item will be inserted as a link.').'</p>';
413     }
414
415     echo
416     '<p>'.
417     '<a id="media-insert-ok" class="button submit" href="#">'.__('Insert').'</a> '.
418     '<a id="media-insert-cancel" class="button" href="#">'.__('Cancel').'</a>'.
419     form::hidden(array('type'),html::escapeHTML($media_type)).
420     form::hidden(array('title'),html::escapeHTML($file->media_title)).
421     form::hidden(array('description'),html::escapeHTML($media_desc)).
422     form::hidden(array('url'),$file->file_url).
423     '</p>';
424
425     echo '</form>';
426
427     if ($media_type != 'default') {
428          echo
429          '<div class="border-top">'.
430          '<form id="save_settings" action="'.html::escapeURL($page_url).'" method="post">'.
431          '<p>'.__('Make current settings as default').' '.
432          '<input class="reset" type="submit" name="save_blog_prefs" value="'.__('OK').'" />'.
433          form::hidden(array('pref_src'),'').
434          form::hidden(array('pref_alignment'),'').
435          form::hidden(array('pref_insertion'),'').
436          form::hidden(array('id'),$id).
437          form::hidden(array('plugin_id'),$plugin_id).
438          $core->formNonce().'</p>'.
439          '</form>'.'</div>';
440     }
441
442     echo '</div>';
443}
444
445if ($popup) {
446     echo
447     '<div class="multi-part" title="'.__('Media details').'" id="media-details-tab">';
448} else {
449     echo '<h3 class="out-of-screen-if-js">'.__('Media details').'</h3>';
450}
451echo
452'<p id="media-icon"><img src="'.$file->media_icon.'?'.time()*rand().'" alt="" /></p>';
453
454echo
455'<div id="media-details">'.
456'<div class="near-icon">';
457
458if ($file->media_image)
459{
460     $thumb_size = !empty($_GET['size']) ? $_GET['size'] : 's';
461
462     if (!isset($core->media->thumb_sizes[$thumb_size]) && $thumb_size != 'o') {
463          $thumb_size = 's';
464     }
465
466     if (isset($file->media_thumb[$thumb_size])) {
467          echo '<p><img src="'.$file->media_thumb[$thumb_size].'?'.time()*rand().'" alt="" /></p>';
468     } elseif ($thumb_size == 'o') {
469          $S = getimagesize($file->file);
470          $class = ($S[1] > 500) ? ' class="overheight"' : '';
471          unset($S);
472          echo '<p id="media-original-image"'.$class.'><img src="'.$file->file_url.'?'.time()*rand().'" alt="" /></p>';
473     }
474
475     echo '<p>'.__('Available sizes:').' ';
476     foreach (array_reverse($file->media_thumb) as $s => $v)
477     {
478          $strong_link = ($s == $thumb_size) ? '<strong>%s</strong>' : '%s';
479          printf($strong_link,'<a href="'.html::escapeURL($page_url).
480          '&amp;id='.$id.'&amp;plugin_id='.$plugin_id.'&amp;size='.$s.'&amp;tab=media-details-tab">'.$core->media->thumb_sizes[$s][2].'</a> | ');
481     }
482     echo '<a href="'.html::escapeURL($page_url).'&amp;id='.$id.'&amp;plugin_id='.$plugin_id.'&amp;size=o&amp;tab=media-details-tab">'.__('original').'</a>';
483     echo '</p>';
484}
485
486// Show player if relevant
487if ($file_type[0] == 'audio')
488{
489     echo dcMedia::audioPlayer($file->type,$file->file_url,$core->adminurl->get("admin.home",array('pf' => 'player_mp3.swf')));
490}
491if ($file_type[0] == 'video')
492{
493     echo dcMedia::videoPlayer($file->type,$file->file_url,$core->adminurl->get("admin.home",array('pf' => 'player_flv.swf')));
494}
495
496echo
497'<h3>'.__('Media details').'</h3>'.
498'<ul>'.
499     '<li><strong>'.__('File owner:').'</strong> '.$file->media_user.'</li>'.
500     '<li><strong>'.__('File type:').'</strong> '.$file->type.'</li>'.
501     '<li><strong>'.__('File size:').'</strong> '.files::size($file->size).'</li>'.
502     '<li><strong>'.__('File URL:').'</strong> <a href="'.$file->file_url.'">'.$file->file_url.'</a></li>'.
503'</ul>';
504
505if (empty($_GET['find_posts']))
506{
507     echo
508     '<p><a class="button" href="'.html::escapeHTML($page_url).'&amp;id='.$id.'&plugin_id='.$plugin_id.'&amp;find_posts=1&amp;tab=media-details-tab">'.
509     __('Show entries containing this media').'</a></p>';
510}
511else
512{
513     echo '<h3>'.__('Entries containing this media').'</h3>';
514     $params = array(
515          'post_type' => '',
516          'from' => 'LEFT OUTER JOIN '.$core->prefix.'post_media PM ON P.post_id = PM.post_id ',
517          'sql' => 'AND ('.
518               'PM.media_id = '.(integer) $id.' '.
519               "OR post_content_xhtml LIKE '%".$core->con->escape($file->relname)."%' ".
520               "OR post_excerpt_xhtml LIKE '%".$core->con->escape($file->relname)."%' "
521     );
522
523     if ($file->media_image)
524     { # We look for thumbnails too
525          if (preg_match('#^http(s)?://#',$core->blog->settings->system->public_url)) {
526               $media_root = $core->blog->settings->system->public_url;
527          } else {
528               $media_root = $core->blog->host.path::clean($core->blog->settings->system->public_url).'/';
529          }
530          foreach ($file->media_thumb as $v) {
531               $v = preg_replace('/^'.preg_quote($media_root,'/').'/','',$v);
532               $params['sql'] .= "OR post_content_xhtml LIKE '%".$core->con->escape($v)."%' ";
533               $params['sql'] .= "OR post_excerpt_xhtml LIKE '%".$core->con->escape($v)."%' ";
534          }
535     }
536
537     $params['sql'] .= ') ';
538
539     $rs = $core->blog->getPosts($params);
540
541     if ($rs->isEmpty())
542     {
543          echo '<p>'.__('No entry seems contain this media.').'</p>';
544     }
545     else
546     {
547          echo '<ul>';
548          while ($rs->fetch()) {
549               $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
550               switch ($rs->post_status) {
551                    case 1:
552                         $img_status = sprintf($img,__('published'),'check-on.png');
553                         break;
554                    case 0:
555                         $img_status = sprintf($img,__('unpublished'),'check-off.png');
556                         break;
557                    case -1:
558                         $img_status = sprintf($img,__('scheduled'),'scheduled.png');
559                         break;
560                    case -2:
561                         $img_status = sprintf($img,__('pending'),'check-wrn.png');
562                         break;
563               }
564               echo '<li>'.$img_status.' '.'<a href="'.$core->getPostAdminURL($rs->post_type,$rs->post_id).'">'.
565                    $rs->post_title.'</a>'.
566                    ($rs->post_type != 'post' ? ' ('.html::escapeHTML($rs->post_type).')' : '').
567                    ' - '.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->post_dt).'</li>';
568          }
569          echo '</ul>';
570     }
571}
572
573if ($file->type == 'image/jpeg')
574{
575     echo '<h3>'.__('Image details').'</h3>';
576
577     $details = '';
578     if (count($file->media_meta) > 0)
579     {
580          foreach ($file->media_meta as $k => $v)
581          {
582               if ((string) $v) {
583                    $details .= '<li><strong>'.$k.':</strong> '.html::escapeHTML($v).'</li>';
584               }
585          }
586     }
587     if ($details) {
588          echo '<ul>'.$details.'</ul>';
589     } else {
590          echo '<p>'.__('No detail').'</p>';
591     }
592}
593
594echo '</div>';
595
596echo '<h3>'.__('Updates and modifications').'</h3>';
597
598if ($file->editable && $core_media_writable)
599{
600     if ($file->media_type == 'image')
601     {
602          echo
603          '<form class="clear fieldset" action="'.html::escapeURL($page_url).'" method="post">'.
604          '<h4>'.__('Update thumbnails').'</h4>'.
605          '<p>'.__('This will create or update thumbnails for this image.').'</p>'.
606          '<p><input type="submit" name="thumbs" value="'.__('Update thumbnails').'" />'.
607          form::hidden(array('id'),$id).
608          form::hidden(array('plugin_id'),$plugin_id).
609          $core->formNonce().'</p>'.
610          '</form>';
611     }
612
613     if ($file->type == 'application/zip')
614     {
615          $inflate_combo = array(
616               __('Extract in a new directory') => 'new',
617               __('Extract in current directory') => 'current'
618          );
619
620          echo
621          '<form class="clear fieldset" id="file-unzip" action="'.html::escapeURL($page_url).'" method="post">'.
622          '<h4>'.__('Extract archive').'</h4>'.
623          '<ul>'.
624          '<li><strong>'.__('Extract in a new directory').'</strong> : '.
625          __('This will extract archive in a new directory that should not exist yet.').'</li>'.
626          '<li><strong>'.__('Extract in current directory').'</strong> : '.
627          __('This will extract archive in current directory and will overwrite existing files or directory.').'</li>'.
628          '</ul>'.
629          '<p><label for="inflate_mode" class="classic">'.__('Extract mode:').'</label> '.
630          form::combo('inflate_mode',$inflate_combo,'new').
631          '<input type="submit" name="unzip" value="'.__('Extract').'" />'.
632          form::hidden(array('id'),$id).
633          form::hidden(array('plugin_id'),$plugin_id).
634          $core->formNonce().'</p>'.
635          '</form>';
636     }
637
638     echo
639     '<form class="clear fieldset" action="'.html::escapeURL($page_url).'" method="post">'.
640     '<h4>'.__('Change media properties').'</h4>'.
641     '<p><label for="media_file">'.__('File name:').'</label>'.
642     form::field('media_file',30,255,html::escapeHTML($file->basename)).'</p>'.
643     '<p><label for="media_title">'.__('File title:').'</label>'.
644     form::field('media_title',30,255,html::escapeHTML($file->media_title)).'</p>'.
645     '<p><label for="media_dt">'.__('File date:').'</label>'.
646     form::field('media_dt',16,16,html::escapeHTML($file->media_dtstr)).'</p>'.
647     '<p><label for="media_private" class="classic">'.form::checkbox('media_private',1,$file->media_priv).' '.
648     __('Private').'</label></p>'.
649     '<p><label for="media_path">'.__('New directory:').'</label>'.
650     form::combo('media_path',$dirs_combo,dirname($file->relname)).'</p>'.
651     '<p><input type="submit" accesskey="s" value="'.__('Save').'" />'.
652     form::hidden(array('id'),$id).
653     form::hidden(array('plugin_id'),$plugin_id).
654     $core->formNonce().'</p>'.
655     '</form>';
656
657     echo
658     '<form class="clear fieldset" action="'.html::escapeURL($page_url).'" method="post" enctype="multipart/form-data">'.
659     '<h4>'.__('Change file').'</h4>'.
660     '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE).'</div>'.
661     '<p><label for="upfile">'.__('Choose a file:').
662     ' ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).') '.
663     '<input type="file" id="upfile" name="upfile" size="35" />'.
664     '</label></p>'.
665     '<p><input type="submit" value="'.__('Send').'" />'.
666     form::hidden(array('id'),$id).
667     form::hidden(array('plugin_id'),$plugin_id).
668     $core->formNonce().'</p>'.
669     '</form>';
670
671     if ($file->del) {
672          echo
673          '<form id="delete-form" method="post" action="'.html::escapeURL($media_page_url).
674          '&amp;d='.rawurlencode(dirname($file->relname)).
675          '&amp;plugin_id='.$plugin_id.
676          '&amp;remove='.rawurlencode($file->basename).'">'.
677          '<p><input name="delete" type="submit" class="delete" value="'.__('Delete this media').'" />'.
678          form::hidden('remove',rawurlencode($file->basename)).
679          form::hidden('rmyes',1).
680          $core->formNonce().'</p>'.
681          '</form>';
682     }
683
684
685     # --BEHAVIOR-- adminMediaItemForm
686     $core->callBehavior('adminMediaItemForm',$file);
687}
688
689echo
690'</div>';
691if ($popup) {
692     echo
693     '</div>';
694}
695
696call_user_func($close_f);
Note: See TracBrowser for help on using the repository browser.

Sites map