diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index 48b6ddced..4c4f8f74e 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -395,8 +395,7 @@ DELETE // synchronize metadata else if ('metadata' == $action) { - sync_metadata($collection); - $page['infos'][] = l10n('Metadata synchronized from file'); + $page['infos'][] = l10n('Metadata synchronized from file').' '.count($collection).''; } else if ('delete_derivatives' == $action && !empty($_POST['del_derivatives_type'])) diff --git a/admin/themes/default/js/batchManagerGlobal.js b/admin/themes/default/js/batchManagerGlobal.js index 8a593d9dd..88e8405fa 100644 --- a/admin/themes/default/js/batchManagerGlobal.js +++ b/admin/themes/default/js/batchManagerGlobal.js @@ -218,12 +218,81 @@ function selectDelDerivNone() { $("#action_delete_derivatives input[type=checkbox]").prop("checked", false); } -/* delete photos by blocks, with progress bar */ +/* sync metadatas or delete photos by blocks, with progress bar */ jQuery('#applyAction').click(function(e) { if (typeof(elements) != "undefined") { return true; } + if (jQuery('[name="selectAction"]').val() == 'metadata') { + e.stopPropagation(); + jQuery('.bulkAction').hide(); + jQuery('#regenerationText').html(lang.syncProgressMessage); + + 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 syncBlockSize = 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 count($params['image_id']) + ); +} + /** * API method * Deletes orphan photos, by block. Returns how many orphans were deleted and how many are remaining. diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index 6028f3804..4f3882e3a 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -1014,3 +1014,4 @@ $lang['%d checksums were added'] = '%d checksums were added'; $lang['With no checksum'] = 'With no checksum'; $lang['Compute %d missing checksums'] = 'Compute %d missing checksums'; $lang['checksums to add'] = 'checksums to add'; +$lang['Synchronization in progress'] = 'Synchronization in progress'; diff --git a/ws.php b/ws.php index b0fcfdb3d..3c79803e3 100644 --- a/ws.php +++ b/ws.php @@ -510,17 +510,31 @@ function ws_addDefaultMethods( $arr ) array('admin_only'=>true, 'post_only'=>true) ); - $service->addMethod( - 'pwg.images.setMd5sum', - 'ws_images_setMd5sum', - array( - 'block_size' => array('default'=>1000, 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), - 'pwg_token' => array(), - ), - 'Set md5sum column, by blocks. Returns how many md5sums were added and how many are remaining.', - $ws_functions_root . 'pwg.images.php', - array('admin_only'=>true, 'post_only'=>true) - ); + $service->addMethod( + 'pwg.images.setMd5sum', + 'ws_images_setMd5sum', + array( + 'block_size' => array('default'=>1000, 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), + 'pwg_token' => array(), + ), + 'Set md5sum column, by blocks. Returns how many md5sums were added and how many are remaining.', + $ws_functions_root . 'pwg.images.php', + array('admin_only'=>true, 'post_only'=>true) + ); + + $service->addMethod( + 'pwg.images.syncMetadata', + 'ws_images_syncMetadata', + array( + 'image_id' => array('default'=>null, + 'type'=>WS_TYPE_ID|WS_TYPE_POSITIVE, + 'flags'=>WS_PARAM_FORCE_ARRAY), + 'pwg_token' => array(), + ), + 'Sync metadatas, by blocks. Returns how many images were synchronized', + $ws_functions_root . 'pwg.images.php', + array('admin_only'=>true, 'post_only'=>true) + ); $service->addMethod( 'pwg.images.deleteOrphans',