Changeset 10389 for trunk/admin
- Timestamp:
- Apr 15, 2011, 5:40:23 PM (14 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/batch_manager_global.php
r10380 r10389 34 34 35 35 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 36 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 37 prepare_upload_configuration(); 38 39 $upload_form_config = get_upload_form_config(); 40 foreach ($upload_form_config as $param_shortname => $param) 41 { 42 $param_name = 'upload_form_'.$param_shortname; 43 $form_values[$param_shortname] = $conf[$param_name]; 44 } 36 45 37 46 // +-----------------------------------------------------------------------+ … … 395 404 } 396 405 406 if ('regenerateThumbnails' == $action) 407 { 408 if ($_POST['regenerateSuccess'] != '0') 409 array_push($page['infos'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateSuccess'])); 410 411 if ($_POST['regenerateError'] != '0') 412 array_push($page['warnings'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateError'])); 413 414 // Update configuration 415 $fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality'); 416 $updates = array(); 417 foreach ($fields as $field) 418 { 419 $value = null; 420 if (!empty($_POST[$field])) 421 { 422 $value = $_POST[$field]; 423 } 424 425 if (preg_match($upload_form_config[$field]['pattern'], $value) 426 and $value >= $upload_form_config[$field]['min'] 427 and $value <= $upload_form_config[$field]['max']) 428 { 429 $conf['upload_form_'.$field] = $value; 430 $updates[] = array( 431 'param' => 'upload_form_'.$field, 432 'value' => $value 433 ); 434 } 435 else 436 { 437 $updates = null; 438 break; 439 } 440 $form_values[$field] = $value; 441 } 442 if (!empty($updates)) 443 { 444 mass_updates( 445 CONFIG_TABLE, 446 array( 447 'primary' => array('param'), 448 'update' => array('value') 449 ), 450 $updates 451 ); 452 } 453 function regenerateThumbnails_prefilter($content, $smarty) 454 { 455 return str_replace('{$thumbnail.TN_SRC}', '{$thumbnail.TN_SRC}?rand='.md5(uniqid(rand(), true)), $content); 456 } 457 $template->set_prefilter('batch_manager_global', 'regenerateThumbnails_prefilter'); 458 $template->delete_compiled_templates(); 459 } 460 397 461 trigger_action('element_set_global_action', $action, $collection); 398 462 } … … 431 495 'filter' => $_SESSION['bulk_manager_filter'], 432 496 'selection' => $collection, 497 'all_elements' => $page['cat_elements_id'], 498 'upload_form_settings' => $form_values, 433 499 'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')), 434 500 'F_ACTION'=>$base_url.get_query_string_diff(array('cat')), -
trunk/admin/themes/default/template/batch_manager_global.tpl
r10380 r10389 7 7 8 8 {combine_script id='jquery.fcbkcomplete' load='footer' require='jquery' path='themes/default/js/plugins/jquery.fcbkcomplete.js'} 9 {combine_script id='jquery.progressBar' load='footer' path='plugins/regenerateThumbnails/js/jquery.progressbar.min.js'} 10 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 9 11 10 12 {footer_script require='jquery.fcbkcomplete'}{literal} … … 27 29 var nb_thumbs_set = {$nb_thumbs_set}; 28 30 var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}"; 31 var elements = new Array(); 32 var all_elements = [{','|@implode:$all_elements}]; 29 33 30 34 var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}"; 31 35 var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}"; 32 36 var selectedMessage_all = "{'All %d photos are selected'|@translate}"; 37 var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}"; 33 38 {literal} 39 var queuedManagerThumbnails = $.manageAjax.create('queued', { 40 queue: true, 41 cacheResponse: false, 42 maxRequests: 3 43 }); 44 34 45 function str_repeat(i, m) { 35 46 for (var o = []; m > 0; o[--m] = i); … … 79 90 } 80 91 92 function progress(val, max, success) { 93 jQuery('#progressBar').progressBar(val, { 94 max: max, 95 textFormat: 'fraction', 96 boxImage: 'themes/default/images/progressbar.gif', 97 barImage: 'themes/default/images/progressbg_orange.gif' 98 }); 99 type = success ? 'regenerateSuccess': 'regenerateError' 100 s = jQuery('[name="'+type+'"]').val(); 101 jQuery('[name="'+type+'"]').val(++s); 102 103 if (val == max) 104 jQuery('#applyAction').click(); 105 } 106 81 107 $(document).ready(function() { 82 108 function checkPermitAction() { … … 299 325 }); 300 326 return false; 327 }); 328 329 jQuery('#applyAction').click(function() { 330 if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') { 331 if (elements.length != 0) 332 return true; 333 334 if (jQuery('input[name="setSelected"]').attr('checked')) 335 elements = all_elements; 336 else 337 jQuery('input[name="selection[]"]').each(function() { 338 if (jQuery(this).attr('checked')) { 339 elements.push(jQuery(this).val()); 340 } 341 }); 342 343 maxwidth = jQuery('input[name="thumb_maxwidth"]').val(); 344 maxheight = jQuery('input[name="thumb_maxheight"]').val(); 345 progressBar_max = elements.length; 346 todo = 0; 347 348 jQuery('#thumb_config').hide(); 349 jQuery('#applyActionBlock').hide(); 350 jQuery('select[name="selectAction"]').hide(); 351 jQuery('#regenerationMsg').show(); 352 jQuery('#regenerationText').html(regenerateThumbnailsMessage); 353 jQuery('#progressBar').progressBar(0, { 354 max: progressBar_max, 355 textFormat: 'fraction', 356 boxImage: 'themes/default/images/progressbar.gif', 357 barImage: 'themes/default/images/progressbg_orange.gif' 358 }); 359 360 for (i=0;i<elements.length;i++) { 361 queuedManagerThumbnails.add({ 362 type: 'GET', 363 url: 'ws.php', 364 data: { 365 method: 'pwg.images.resize', 366 type: 'thumbnail', 367 maxwidth: maxwidth, 368 maxheight: maxheight, 369 image_id: elements[i], 370 format: 'json' 371 }, 372 dataType: 'json', 373 success: ( function(data) { progress(++todo, progressBar_max, data['result']) }), 374 error: ( function(data) { progress(++todo, progressBar_max, false) }) 375 }); 376 } 377 return false; 378 } 301 379 }); 302 380 … … 474 552 <option value="add_to_caddie">{'add to caddie'|@translate}</option> 475 553 {/if} 554 <option value="regenerateThumbnails">{'Regenerate Thumbnails'|@translate}</option> 476 555 {if !empty($element_set_global_plugins_actions)} 477 556 {foreach from=$element_set_global_plugins_actions item=action} … … 560 639 </div> 561 640 641 <!-- regenerate thumbnails --> 642 <div id="action_regenerateThumbnails" class="bulkAction"> 643 <table style="margin-left:20px;" id="thumb_config"> 644 <tr> 645 <th>{'Maximum Width'|@translate}</th> 646 <td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td> 647 </tr> 648 <tr> 649 <th>{'Maximum Height'|@translate}</th> 650 <td><input type="text" name="thumb_maxheight" value="{$upload_form_settings.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td> 651 </tr> 652 <tr> 653 <th>{'Image Quality'|@translate}</th> 654 <td><input type="text" name="thumb_quality" value="{$upload_form_settings.thumb_quality}" size="3" maxlength="3"> %</td> 655 </tr> 656 </table> 657 </div> 658 659 <!-- progress bar --> 660 <div id="regenerationMsg" style="display:none;"> 661 <p id="regenerationText" style="margin-bottom:10px;"></p> 662 <span class="progressBar" id="progressBar"></span> 663 <input type="hidden" name="regenerateSuccess" value="0"> 664 <input type="hidden" name="regenerateError" value="0"> 665 </div> 666 562 667 <!-- plugins --> 563 668 {if !empty($element_set_global_plugins_actions)}
Note: See TracChangeset
for help on using the changeset viewer.