diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index 5453d447f..374041b9a 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -361,12 +361,13 @@ DELETE { if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion']) { - $deleted_count = delete_elements($collection, true); - if ($deleted_count > 0) + // now done with ajax calls, with blocks + // $deleted_count = delete_elements($collection, true); + if (count($collection) > 0) { $_SESSION['page_infos'][] = l10n_dec( '%d photo was deleted', '%d photos were deleted', - $deleted_count + count($collection) ); $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; diff --git a/admin/themes/default/js/batchManagerGlobal.js b/admin/themes/default/js/batchManagerGlobal.js index fc8d094ab..803402dbe 100644 --- a/admin/themes/default/js/batchManagerGlobal.js +++ b/admin/themes/default/js/batchManagerGlobal.js @@ -215,3 +215,108 @@ function selectDelDerivAll() { function selectDelDerivNone() { $("#action_delete_derivatives input[type=checkbox]").prop("checked", false); } + +/* delete photos by blocks, with progress bar */ +jQuery('#applyAction').click(function(e) { + if (typeof(elements) != "undefined") { + return true; + } + + if (jQuery('[name="selectAction"]').val() == 'delete') { + if (!jQuery("#action_delete input[name=confirm_deletion]").is(':checked')) { + jQuery("#action_delete span.errors").show(); + return false; + } + e.stopPropagation(); + } + else { + return true; + } + + jQuery('.bulkAction').hide(); + jQuery('#regenerationText').html(lang.deleteProgressMessage); + var maxRequests=1; + + var queuedManager = jQuery.manageAjax.create('queued', { + queue: true, + cacheResponse: false, + maxRequests: maxRequests + }); + + elements = Array(); + + if (jQuery('input[name=setSelected]').is(':checked')) { + elements = all_elements; + } + else { + jQuery('input[name="selection[]"]').filter(':checked').each(function() { + elements.push(jQuery(this).val()); + }); + } + + progressBar_max = elements.length; + var todo = 0; + var deleteBlockSize = Math.min( + Number((elements.length/2).toFixed()), + 1000 + ); + var image_ids = Array(); + + jQuery('#applyActionBlock').hide(); + jQuery('select[name="selectAction"]').hide(); + jQuery('#regenerationMsg').show(); + jQuery('#progressBar').progressBar(0, { + max: progressBar_max, + textFormat: 'fraction', + boxImage: 'themes/default/images/progressbar.gif', + barImage: 'themes/default/images/progressbg_orange.gif' + }); + + for (i=0;i
-

+

{* also used for "move" action *} diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index 1d9d0cbd4..b6647c8b5 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -1739,6 +1739,13 @@ function ws_images_delete($params, $service) include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); delete_elements($image_ids, true); invalidate_user_cache(); + + if ($params['return_details']) + { + return array( + 'nb_processed' => count($image_ids), + ); + } } /** @@ -1760,4 +1767,4 @@ function ws_images_checkUpload($params, $service) return $ret; } -?> \ No newline at end of file +?> diff --git a/ws.php b/ws.php index 1aff64897..16329635b 100644 --- a/ws.php +++ b/ws.php @@ -504,6 +504,7 @@ function ws_addDefaultMethods( $arr ) array( 'image_id' => array('flags'=>WS_PARAM_ACCEPT_ARRAY), 'pwg_token' => array(), + 'return_details' => array('default'=>false, 'type'=>WS_TYPE_BOOL), ), 'Deletes image(s).', $ws_functions_root . 'pwg.images.php', @@ -1024,4 +1025,4 @@ enabled_high, registration_date, registration_date_string, registration_date_sin ); } -?> \ No newline at end of file +?>