Changeset 1144:4af82896ca3d
- Timestamp:
- 06/04/13 22:51:35 (12 years ago)
- Branch:
- default
- Files:
-
- 9 added
- 4 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/_media.js
r1140 r1144 1 1 $(function() { 2 // Replace remove links by a POST on hidden form 3 fileRemoveAct(); 4 5 function fileRemoveAct() { 6 $('a.media-remove').click(function() { 7 var m_name = $(this).parents('ul').find('li:first>a').text(); 8 if (window.confirm(dotclear.msg.confirm_delete_media.replace('%s',m_name))) { 9 var f = $('#media-remove-hide').get(0); 10 f.elements['remove'].value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/,'$2'); 11 this.href = ''; 12 f.submit(); 13 } 14 return false; 15 }); 16 } 17 18 if (!$.browser.opera) { 19 var upldr = $('<a href="#" id="cu-enable">' + dotclear.msg.activate_enhanced_uploader + '</a>').click( function() { 20 candyUploadInit(); 21 return false; 22 }); 23 $('#media-upload').append($('<div></div>').append(upldr)); 24 if ((dotclear.candyUpload_force_init == '1') || (($.cookie('dc_candy_upl') == 1))) { 25 candyUploadInit(); 26 } 27 } 28 29 function candyUploadInit() 30 { 31 var candy_upload_success = false; 32 var candy_upload_form_url = $('#media-upload').attr('action') + '&file_sort=date-desc&d=' + $('#media-upload input[name=d]').val(); 33 var candy_upload_limit = $('#media-upload input[name=MAX_FILE_SIZE]').val(); 34 $('#media-upload').candyUpload({ 35 upload_url: dotclear.candyUpload.base_url + '/media.php', 36 flash_movie: dotclear.candyUpload.movie_url, 37 file_size_limit: candy_upload_limit + 'b', 38 params: 'swfupload=1&' + dotclear.candyUpload.params, 39 40 callbacks: { 41 createControls: function() { 42 var _this = this; 43 this.ctrl.btn_browse.hide(); 44 this.ctrl.msg.html(dotclear.msg.load_enhanced_uploader); 45 var l = $('<a href="#">' + dotclear.msg.disable_enhanced_uploader + '</a>').click(function() { 46 _this.upldr.destroy(); 47 _this.ctrl.block.empty().remove(); 48 $('#media-upload').show(); 49 delete _this; 50 $.cookie('dc_candy_upl','',{expires:-1}); 51 return false; 52 }); 53 this.ctrl.disable = $('<div class="cu-disable"></div>').append(l).appendTo(this.ctrl.block); 54 }, 55 flashReady: function() { 56 var _this = this; 57 this.ctrl.msg.fadeOut('fast',function() { 58 $(this).text(_this.locales.no_file_in_queue).fadeIn('fast'); 59 _this.ctrl.btn_browse.fadeIn('fast',function() { 60 _this.upldr.container.children().css({ 61 width: $('.cu-btn-browse').width(), 62 height: $('.cu-btn-browse').height() 63 }); 64 }); 65 }); 66 }, 67 uploadSuccess: function(o,data) { 68 if (data == 'ok') { 69 candy_upload_success = true; 70 this.fileMsg(o.id,this.locales.file_uploaded); 71 } else { 72 this.fileErrorMsg(o.id,data); 73 } 74 75 // uploads finished and at least one success 76 if (candy_upload_success && $('div.cu-file:has(span.cu-filecancel a)',this.ctrl.files).length == 0) { 77 $.cookie('dc_candy_upl','1',{expires: 30}); 78 $.get(candy_upload_form_url,function(data) { 79 var media = $('div.media-list'); 80 media.after($('div.media-list',data)).remove(); 81 fileRemoveAct(); 82 }); 83 } 84 }, 85 fileQueued: function() { 86 ; 87 } 88 } 89 }); 90 } 2 $('#fileupload') 3 .fileupload({ 4 url: $('#fileupload').attr('action'), 5 autoUpload: false 6 }); 7 8 // Load existing files: 9 $('#fileupload').addClass('fileupload-processing'); 10 $.ajax({ 11 url: $('#fileupload').fileupload('option', 'url'), 12 dataType: 'json', 13 context: $('#fileupload')[0] 14 }).always(function (result) { 15 $(this).removeClass('fileupload-processing'); 16 }).done(function (result) { 17 $(this).fileupload('option', 'done') 18 .call(this, null, {result: result}); 19 }); 20 21 // Replace remove links by a POST on hidden form 22 fileRemoveAct(); 23 24 function fileRemoveAct() { 25 $('a.media-remove').click(function() { 26 var m_name = $(this).parents('ul').find('li:first>a').text(); 27 if (window.confirm(dotclear.msg.confirm_delete_media.replace('%s',m_name))) { 28 var f = $('#media-remove-hide').get(0); 29 f.elements['remove'].value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/,'$2'); 30 this.href = ''; 31 f.submit(); 32 } 33 return false; 34 }); 35 } 91 36 }); -
admin/js/jquery/jquery-ui.custom.js
- Property exe deleted
-
admin/js/jquery/jquery.js
- Property exe deleted
-
admin/media.php
r1039 r1144 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 13 /* Upload backend14 -------------------------------------------------------- */15 if (!empty($_POST['swfupload']))16 {17 header('content-type: text/plain');18 try19 {20 if (empty($_POST['sess_id']) || empty($_POST['sess_uid'])) {21 throw new Exception('No credentials.');22 }23 define('DC_AUTH_SESS_ID',$_POST['sess_id']);24 define('DC_AUTH_SESS_UID',$_POST['sess_uid']);25 26 require dirname(__FILE__).'/../inc/admin/prepend.php';27 28 if (!$core->auth->check('media,media_admin',$core->blog->id)) {29 throw new Exception('Permission denied.');30 }31 32 $d = isset($_POST['d']) ? $_POST['d'] : null;33 $core->media = new dcMedia($core);34 $core->media->chdir($d);35 $core->media->getDir();36 $dir =& $core->media->dir;37 38 if (empty($_FILES['Filedata'])) {39 throw new Exception('No file to upload.');40 }41 42 files::uploadStatus($_FILES['Filedata']);43 $core->media->uploadFile($_FILES['Filedata']['tmp_name'],$_FILES['Filedata']['name']);44 45 echo 'ok';46 }47 catch (Exception $e) {48 echo __('Error:').' '.__($e->getMessage());49 }50 exit;51 }52 53 12 54 13 /* HTML page … … 175 134 if ($dir && !empty($_FILES['upfile'])) 176 135 { 177 try 178 { 179 files::uploadStatus($_FILES['upfile']); 180 181 $f_title = (isset($_POST['upfiletitle']) ? $_POST['upfiletitle'] : ''); 182 $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false); 183 184 $core->media->uploadFile($_FILES['upfile']['tmp_name'],$_FILES['upfile']['name'],$f_title,$f_private); 185 http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1'); 186 } 187 catch (Exception $e) 188 { 189 $core->error->add($e->getMessage()); 190 } 191 } 192 136 $upfile = array('name' => $_FILES['upfile']['name'][0], 137 'type' => $_FILES['upfile']['type'][0], 138 'tmp_name' => $_FILES['upfile']['tmp_name'][0], 139 'error' => $_FILES['upfile']['error'][0], 140 'size' => $_FILES['upfile']['size'][0] 141 ); 142 143 try { 144 files::uploadStatus($upfile); 145 146 $core->media->uploadFile($upfile['tmp_name'],$upfile['name']); 147 148 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { 149 header('Content-type: application/json'); 150 $message = array(); 151 $message['files'][] = array('name' => $upfile['name']); 152 153 echo json_encode($message); 154 exit(); 155 } else { 156 http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1'); 157 } 158 } catch (Exception $e) { 159 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { 160 header('Content-type: application/json'); 161 $message = array(); 162 $message['files'][] = array('name' => $upfile['name'], 163 'error' => $e->getMessage() 164 ); 165 echo json_encode($message); 166 exit(); 167 } else { 168 $core->error->add($e->getMessage()); 169 } 170 } 171 } 193 172 194 173 # Removing item … … 215 194 } 216 195 } 217 218 196 219 197 # DISPLAY confirm page for rmdir & rmfile … … 245 223 246 224 call_user_func($open_f,__('Media manager'), 247 '<script type="text/javascript">'."\n".248 "//<![CDATA["."\n".249 dcPage::jsVar('dotclear.candyUpload_force_init',$user_ui_enhanceduploader)."\n".250 "//]]>".251 "</script>".252 225 dcPage::jsLoad('js/_media.js'). 253 ($core_media_writable ? dcPage::js CandyUpload(array('d='.$d)) : '')226 ($core_media_writable ? dcPage::jsUpload(array('d='.$d)) : '') 254 227 ); 255 228 … … 339 312 } 340 313 314 341 315 if ($core_media_writable) 342 316 { … … 344 318 345 319 echo 346 '<div class="col">'. 347 '<fieldset id="add-file-f"><legend>'.__('Add files').'</legend>'. 348 '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. 349 '<form id="media-upload" class="clear" action="'.html::escapeURL($page_url).'" method="post" enctype="multipart/form-data">'. 350 '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). 351 $core->formNonce().'</div>'. 352 '<p><label for="upfile">'.__('Choose a file:'). 353 ' ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')'. 354 '<input type="file" id="upfile" name="upfile" size="20" />'. 355 '</label></p>'. 356 '<p><label for="upfiletitle">'.__('Title:').form::field(array('upfiletitle','upfiletitle'),35,255).'</label></p>'. 357 '<p><label for="upfilepriv" class="classic">'.form::checkbox(array('upfilepriv','upfilepriv'),1).' '. 358 __('Private').'</label></p>'; 359 if (!$user_ui_enhanceduploader) { 360 echo 361 '<p class="form-help info">'.__('To send several files at the same time, you can activate the enhanced uploader in'). 362 ' <a href="preferences.php?tab=user-options">'.__('My preferences').'</a></p>'; 363 } 364 echo 365 '<p><input type="submit" value="'.__('Send').'" />'. 366 form::hidden(array('d'),$d).'</p>'. 367 '</fieldset>'. 368 '</form>'. 369 '</div>'; 320 '<div class="col">'. 321 '<fieldset id="add-file-f"><legend>'.__('Add files').'</legend>'. 322 '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. 323 ' <form id="fileupload" action="'.html::escapeURL($page_url).'" method="POST" enctype="multipart/form-data">'. 324 '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). 325 $core->formNonce().'</div>'. 326 '<div class="fileupload-buttonbar">'. 327 '<span class="button-add button"><label for="upfile">'.__('Add files').'</label>'. 328 '<input type="file" id="upfile" name="upfile[]" size="20" multiple="multiple" data-url="'.html::escapeURL($page_url).'" />'. 329 '</span>'. 330 '<button type="submit" class="button start"><span>'.__('Send').'</span></button>'. 331 '</div>'. 332 '<table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>'. 333 form::hidden(array('d'),$d).'</p>'. 334 '</fieldset>'. 335 '</form>'. 336 '</div>'; 370 337 371 338 echo -
inc/admin/lib.dc.page.php
r1142 r1144 52 52 { 53 53 global $core; 54 54 55 55 # List of user's blogs 56 56 if ($core->auth->blog_count == 1 || $core->auth->blog_count > 20) … … 673 673 } 674 674 675 public static function js CandyUpload($params=array(),$base_url=null)675 public static function jsUpload($params=array(),$base_url=null) 676 676 { 677 677 if (!$base_url) { … … 686 686 687 687 return 688 '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n". 689 self::jsLoad('js/jquery/jquery.candyUpload.js'). 688 '<link rel="stylesheet" type="text/css" href="style/jsUpload/style.css" />'."\n". 689 690 '<script id="template-upload" type="text/x-tmpl"> 691 {% for (var i=0, file; file=o.files[i]; i++) { %} 692 <tr class="template-upload fade"> 693 <td> 694 <span class="preview"></span> 695 </td> 696 <td> 697 <p class="name">{%=file.name%}</p> 698 {% if (file.error) { %} 699 <div><span class="label label-important">'.__('Error:').'</span> {%=file.error%}</div> 700 {% } %} 701 </td> 702 <td> 703 <p class="size">{%=o.formatFileSize(file.size)%}</p> 704 {% if (!o.files.error) { %} 705 <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div> 706 {% } %} 707 </td> 708 <td> 709 {% if (!o.files.error && !i && !o.options.autoUpload) { %} 710 <button class="btn btn-primary start"> 711 <i class="icon-upload icon-white"></i> 712 <span>'.__('Send').'</span> 713 </button> 714 {% } %} 715 </td> 716 </tr> 717 {% } %} 718 </script> 719 <!-- The template to display files available for download --> 720 <script id="template-download" type="text/x-tmpl"> 721 {% for (var i=0, file; file=o.files[i]; i++) { %} 722 <tr class="template-download fade"> 723 <td> 724 <span class="preview"> 725 {% if (file.thumbnail_url) { %} 726 <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a> 727 {% } %} 728 </span> 729 </td> 730 <td> 731 <p class="name">{%=file.name%}</p> 732 {% if (file.error) { %} 733 <div><span class="label label-important">'.__('Error:').'</span> {%=file.error%}</div> 734 {% } %} 735 </td> 736 <td> 737 <span class="size">{%=o.formatFileSize(file.size)%}</span> 738 </td> 739 </tr> 740 {% } %} 741 </script>'. 742 743 self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). 744 self::jsLoad('js/jsUpload/tmpl.js'). 745 self::jsLoad('js/jsUpload/load-image.js'). 746 self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). 747 self::jsLoad('js/jsUpload/jquery.fileupload.js'). 748 self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). 749 self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). 750 self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'). 690 751 691 752 '<script type="text/javascript">'."\n". 692 753 "//<![CDATA[\n". 693 "dotclear.candyUpload = {};\n". 694 self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Temporarily activate enhanced uploader')). 695 self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Temporarily disable enhanced uploader')). 696 self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')). 697 self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')). 698 self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')). 699 self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')). 700 self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')). 701 self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')). 702 self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')). 703 self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')). 704 self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')). 705 self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')). 706 self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')). 707 self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')). 708 self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')). 709 self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')). 710 self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')). 711 self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')). 712 self::jsVar('dotclear.candyUpload.base_url',$base_url). 713 self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf'). 714 self::jsVar('dotclear.candyUpload.params',implode('&',$params)). 754 "dotclear.jsUpload = {};\n". 755 "dotclear.jsUpload.msg = {};\n". 756 self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). 757 self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). 758 self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). 759 self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). 760 self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). 761 self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). 762 self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). 763 self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). 764 self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 765 self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 766 self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 767 self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 768 self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). 769 self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). 770 self::jsVar('dotclear.jsUpload.base_url',$base_url). 715 771 "\n//]]>\n". 716 772 "</script>\n";
Note: See TracChangeset
for help on using the changeset viewer.