Changeset 13544 for trunk/admin
- Timestamp:
- Mar 13, 2012, 10:13:17 PM (12 years ago)
- Location:
- trunk/admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/batch_manager_global.php
r13457 r13544 412 412 } 413 413 414 if ('regenerateThumbnails' == $action) 414 if ('delete_derivatives' == $action) 415 { 416 $query='SELECT path,representative_ext FROM '.IMAGES_TABLE.' 417 WHERE id IN ('.implode(',', $collection).')'; 418 $result = pwg_query($query); 419 while ($info = pwg_db_fetch_assoc($result)) 420 { 421 foreach( $_POST['del_derivatives_type'] as $type) 422 { 423 delete_element_derivatives($info, $type); 424 } 425 } 426 } 427 428 if ('generate_derivatives' == $action) 415 429 { 416 430 if ($_POST['regenerateSuccess'] != '0') 417 array_push($page['infos'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateSuccess']));431 array_push($page['infos'], sprintf(l10n('%s photos were generated'), $_POST['regenerateSuccess'])); 418 432 419 433 if ($_POST['regenerateError'] != '0') 420 array_push($page['warnings'], sprintf(l10n('%s thumbnails can not be regenerated'), $_POST['regenerateError'])); 421 422 $update_fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality', 'thumb_crop', 'thumb_follow_orientation'); 423 } 424 425 if ('regenerateWebsize' == $action) 426 { 427 if ($_POST['regenerateSuccess'] != '0') 428 array_push($page['infos'], sprintf(l10n('%s photos have been regenerated'), $_POST['regenerateSuccess'])); 429 430 if ($_POST['regenerateError'] != '0') 431 array_push($page['warnings'], sprintf(l10n('%s photos can not be regenerated'), $_POST['regenerateError'])); 432 433 $update_fields = array('websize_maxwidth', 'websize_maxheight', 'websize_quality'); 434 } 435 436 if (!empty($update_fields)) 437 { 438 // Update upload configuration 439 $updates = array(); 440 foreach ($update_fields as $field) 441 { 442 $value = !empty($_POST[$field]) ? $_POST[$field] : null; 443 $form_values[$field] = $value; 444 $updates[$field] = $value; 445 } 446 save_upload_form_config($updates); 434 array_push($page['warnings'], sprintf(l10n('%s photos were not generated'), $_POST['regenerateError'])); 435 447 436 } 448 437 … … 673 662 ); 674 663 664 //derivatives 665 $del_deriv_map = array(); 666 foreach(ImageStdParams::get_defined_type_map() as $params) 667 { 668 $del_deriv_map[$params->type] = l10n($params->type); 669 } 670 $template->assign( 671 array( 672 'del_derivatives_types' => $del_deriv_map, 673 'generate_derivatives_types' => $del_deriv_map, 674 ) 675 ); 676 675 677 // +-----------------------------------------------------------------------+ 676 678 // | global mode thumbnails | … … 757 759 { 758 760 $nb_thumbs_page++; 759 $src = DerivativeImage::thumb_url($row);761 $src_image = new SrcImage($row); 760 762 761 763 $title = render_element_name($row); … … 769 771 array( 770 772 'ID' => $row['id'], 771 'TN_SRC' => $src,773 'TN_SRC' => DerivativeImage::url(IMG_THUMB, $src_image), 772 774 'FILE' => $row['file'], 773 775 'TITLE' => $title, 774 776 'LEVEL' => $row['level'], 775 'FILE_SRC' => $row['path'],777 'FILE_SRC' => DerivativeImage::url(IMG_LARGE, $src_image), 776 778 'U_EDIT' => get_root_url().'admin.php?page=photo-'.$row['id'], 777 779 ) -
trunk/admin/themes/default/template/batch_manager_global.tpl
r13066 r13544 95 95 var nb_thumbs_set = {$nb_thumbs_set}; 96 96 var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}"; 97 var elements = new Array();97 var elements = []; 98 98 var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}]; 99 var generate_derivatives_done=false; 99 100 100 101 var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}"; 101 102 var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}"; 102 103 var selectedMessage_all = "{'All %d photos are selected'|@translate}"; 103 var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}";104 var regenerateWebsizeMessage = "{'Photos generation in progress...'|@translate}";105 104 106 105 var width_str = '{'Width'|@translate}'; … … 163 162 barImage: 'themes/default/images/progressbg_orange.gif' 164 163 }); 165 type = success ? 'regenerateSuccess': 'regenerateError' 166 s = jQuery('[name="'+type+'"]').val(); 167 jQuery('[name="'+type+'"]').val(++s); 168 169 if (val == max) 170 jQuery('#applyAction').click(); 164 if (success !== undefined) { 165 var type = success ? 'regenerateSuccess': 'regenerateError', 166 s = jQuery('[name="'+type+'"]').val(); 167 jQuery('[name="'+type+'"]').val(++s); 168 } 169 170 if (val == max) { 171 generate_derivatives_done = true; 172 jQuery('#applyAction').click(); 173 } 171 174 } 172 175 … … 403 406 404 407 jQuery('#applyAction').click(function() { 405 if (elements.length != 0) 406 { 407 return true; 408 } 409 else if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') 410 { 411 resizeMethod = 'pwg.images.resizeThumbnail'; 412 maxRequests = 3; 413 maxwidth = jQuery('input[name="thumb_maxwidth"]').val(); 414 maxheight = jQuery('input[name="thumb_maxheight"]').val(); 415 regenerationText = regenerateThumbnailsMessage; 416 crop = jQuery('input[name="thumb_crop"]').is(':checked'); 417 follow_orientation = jQuery('input[name="thumb_follow_orientation"]').is(':checked'); 418 } 419 else if(jQuery('[name="selectAction"]').val() == 'regenerateWebsize') 420 { 421 resizeMethod = 'pwg.images.resizeWebsize'; 422 maxRequests = 1; 423 maxwidth = jQuery('input[name="websize_maxwidth"]').val(); 424 maxheight = jQuery('input[name="websize_maxheight"]').val(); 425 regenerationText = regenerateWebsizeMessage; 426 crop = false; 427 follow_orientation = false; 428 } 429 else return true; 430 431 jQuery('.bulkAction').hide(); 432 jQuery('#regenerationText').html(regenerationText); 433 434 var queuedManager = jQuery.manageAjax.create('queued', { 435 queue: true, 436 cacheResponse: false, 437 maxRequests: maxRequests 438 }); 439 440 if (jQuery('input[name="setSelected"]').attr('checked')) 441 elements = all_elements; 442 else 443 jQuery('input[name="selection[]"]').each(function() { 444 if (jQuery(this).attr('checked')) { 445 elements.push(jQuery(this).val()); 446 } 447 }); 448 449 progressBar_max = elements.length; 450 todo = 0; 451 452 jQuery('#applyActionBlock').hide(); 453 jQuery('select[name="selectAction"]').hide(); 454 jQuery('#regenerationMsg').show(); 455 456 jQuery('#progressBar').progressBar(0, { 457 max: progressBar_max, 458 textFormat: 'fraction', 459 boxImage: 'themes/default/images/progressbar.gif', 460 barImage: 'themes/default/images/progressbg_orange.gif' 461 }); 462 463 for (i=0;i<elements.length;i++) { 464 queuedManager.add({ 465 type: 'GET', 466 url: 'ws.php', 467 data: { 468 method: resizeMethod, 469 maxwidth: maxwidth, 470 maxheight: maxheight, 471 crop: crop, 472 follow_orientation: follow_orientation, 473 image_id: elements[i], 474 format: 'json' 475 }, 476 dataType: 'json', 477 success: ( function(data) { progress(++todo, progressBar_max, data['result']) }), 478 error: ( function(data) { progress(++todo, progressBar_max, false) }) 479 }); 480 } 481 return false; 482 }); 483 484 function toggleCropFields(prefix) { 485 if (jQuery("#"+prefix+"_crop").is(':checked')) { 486 jQuery("#"+prefix+"_width_th").text(width_str); 487 jQuery("#"+prefix+"_height_th").text(height_str); 488 jQuery("#"+prefix+"_follow_orientation_tr").show(); 489 } 490 else { 491 jQuery("#"+prefix+"_width_th").text(max_width_str); 492 jQuery("#"+prefix+"_height_th").text(max_height_str); 493 jQuery("#"+prefix+"_follow_orientation_tr").hide(); 494 } 495 } 496 497 toggleCropFields("thumb"); 498 jQuery("#thumb_crop").click(function () {toggleCropFields("thumb")}); 408 if (jQuery('[name="selectAction"]').val() != 'generate_derivatives') 409 { 410 return true; 411 } 412 if (generate_derivatives_done) 413 { 414 return true; 415 } 416 417 jQuery('.bulkAction').hide(); 418 419 var queuedManager = jQuery.manageAjax.create('queued', { 420 queue: true, 421 cacheResponse: false, 422 maxRequests: 1 423 }); 424 425 if (jQuery('input[name="setSelected"]').attr('checked')) 426 elements = all_elements; 427 else 428 jQuery('input[name="selection[]"]').each(function() { 429 if (jQuery(this).attr('checked')) { 430 elements.push(jQuery(this).val()); 431 } 432 }); 433 434 progressBar_max = 0; 435 todo = 0; 436 437 jQuery('#applyActionBlock').hide(); 438 jQuery('select[name="selectAction"]').hide(); 439 jQuery('#regenerationMsg').show(); 440 441 jQuery('#progressBar').progressBar(0, { 442 max: progressBar_max, 443 textFormat: 'fraction', 444 boxImage: 'themes/default/images/progressbar.gif', 445 barImage: 'themes/default/images/progressbg_orange.gif' 446 }); 447 448 getDerivativeUrls(); 449 return false; 450 }); 451 452 function getDerivativeUrls() { 453 if (elements.length==0) 454 return; 455 var ids = elements.splice(0, 500); 456 var params = {max_urls: 100000, ids: ids, types: []}; 457 jQuery("#action_generate_derivatives input").each( function(i, t) { 458 if ($(t).attr("checked")) 459 params.types.push( t.value ); 460 } ); 461 462 jQuery.ajax( { 463 type: "POST", 464 url: 'ws.php?format=json&method=pwg.getMissingDerivatives', 465 data: params, 466 dataType: "json", 467 success: function(data) { 468 if (!data.stat || data.stat != "ok") { 469 return; 470 } 471 progressBar_max += data.result.urls.length; 472 progress(todo, progressBar_max); 473 for (var i=0; i < data.result.urls.length; i++) { 474 jQuery.manageAjax.add("queued", { 475 type: 'GET', 476 url: data.result.urls[i] + "&ajaxload=true", 477 dataType: 'json', 478 success: ( function(data) { progress(++todo, progressBar_max, true) }), 479 error: ( function(data) { progress(++todo, progressBar_max, false) }) 480 }); 481 } 482 } 483 } ); 484 } 499 485 500 486 checkPermitAction() … … 502 488 503 489 jQuery(window).load(function() { 504 var max_dim = 0; 505 $(".thumbnails img").each(function () { 506 max_dim = Math.max(max_dim, $(this).height(), $(this).width() ); 507 }); 508 max_dim += 35; 509 $("ul.thumbnails span, ul.thumbnails label").css('width', max_dim+'px').css('height', max_dim+'px'); 510 $('ul.thumbnails').enableShiftClick(); 490 var max_w=0, max_h=0; 491 $(".thumbnails img").each(function () { 492 max_w = Math.max(max_w, $(this).width() ); 493 max_h = Math.max(max_h, $(this).height() ); 494 }); 495 max_w += 10; 496 max_h += 35; 497 $("ul.thumbnails span, ul.thumbnails label").css('width', max_w+'px').css('height', max_h+'px'); 498 $('ul.thumbnails').enableShiftClick(); 511 499 }); 512 500 {/literal}{/footer_script} … … 604 592 605 593 <ul class="thumbnails"> 606 {foreach from=$thumbnails item=thumbnail} 607 {if in_array($thumbnail.ID, $selection)} 608 {assign var='isSelected' value=true} 609 {else} 610 {assign var='isSelected' value=false} 611 {/if} 612 613 <li> 614 <span class="wrap1"> 615 <label> 616 <span class="wrap2{if $isSelected} thumbSelected{/if}"> 617 <div class="actions"><a href="{$thumbnail.FILE_SRC}" class="preview-box">{'Zoom'|@translate}</a> · <a href="{$thumbnail.U_EDIT}" target="_blank">{'Edit'|@translate}</a></div> 618 {if $thumbnail.LEVEL > 0} 619 <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em> 620 <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em> 621 {/if} 622 <span> 623 <img src="{$thumbnail.TN_SRC}" 624 alt="{$thumbnail.FILE}" 625 title="{$thumbnail.TITLE|@escape:'html'}" 626 class="thumbnail"> 627 </span> 628 </span> 629 <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}> 630 </label> 631 </span> 632 </li> 594 {foreach from=$thumbnails item=thumbnail} 595 {if in_array($thumbnail.ID, $selection)} 596 {assign var='isSelected' value=true} 597 {else} 598 {assign var='isSelected' value=false} 599 {/if} 600 <li> 601 <span class="wrap1"> 602 <label> 603 <span class="wrap2{if $isSelected} thumbSelected{/if}"> 604 <div class="actions"><a href="{$thumbnail.FILE_SRC}" class="preview-box">{'Zoom'|@translate}</a> · <a href="{$thumbnail.U_EDIT}" target="_blank">{'Edit'|@translate}</a></div> 605 {if $thumbnail.LEVEL > 0} 606 <em class="levelIndicatorB">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em> 607 <em class="levelIndicatorF" title="{'Who can see these photos?'|@translate} : ">{$pwg->l10n($pwg->sprintf('Level %d',$thumbnail.LEVEL))}</em> 608 {/if} 609 <span> 610 <img src="{$thumbnail.TN_SRC}" alt="{$thumbnail.FILE}" title="{$thumbnail.TITLE|@escape:'html'}" class="thumbnail"> 611 </span> 612 </span> 613 <input type="checkbox" name="selection[]" value="{$thumbnail.ID}" {if $isSelected}checked="checked"{/if}> 614 </label> 615 </span> 616 </li> 633 617 {/foreach} 634 618 </ul> … … 687 671 <option value="add_to_caddie">{'Add to caddie'|@translate}</option> 688 672 {/if} 689 <option value="regenerateThumbnails">{'Regenerate Thumbnails'|@translate}</option>690 <option value="regenerateWebsize">{'Regenerate Websize Photos'|@translate}</option>673 <option value="delete_derivatives">{'Delete multiple size images'|@translate}</option> 674 <option value="generate_derivatives">{'Generate multiple size images'|@translate}</option> 691 675 {if !empty($element_set_global_plugins_actions)} 692 676 {foreach from=$element_set_global_plugins_actions item=action} … … 785 769 </div> 786 770 787 <!-- regenerate thumbnails --> 788 <div id="action_regenerateThumbnails" class="bulkAction"> 789 <table style="margin-left:20px;"> 790 <tr> 791 <th><label for="thumb_crop">{'Crop'|@translate}</label></th> 792 <td><input type="checkbox" name="thumb_crop" id="thumb_crop" {if $upload_form_settings.thumb_crop}checked="checked"{/if}></td> 793 </tr> 794 <tr id="thumb_follow_orientation_tr"> 795 <th><label for="thumb_follow_orientation">{'Follow Orientation'|@translate}</label></th> 796 <td><input type="checkbox" name="thumb_follow_orientation" id="thumb_follow_orientation" {if $upload_form_settings.thumb_follow_orientation}checked="checked"{/if}></td> 797 </tr> 798 <tr> 799 <th id="thumb_width_th">{'Maximum Width'|@translate}</th> 800 <td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td> 801 </tr> 802 <tr> 803 <th id="thumb_height_th">{'Maximum Height'|@translate}</th> 804 <td><input type="text" name="thumb_maxheight" value="{$upload_form_settings.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td> 805 </tr> 806 <tr> 807 <th>{'Image Quality'|@translate}</th> 808 <td><input type="text" name="thumb_quality" value="{$upload_form_settings.thumb_quality}" size="3" maxlength="3"> %</td> 809 </tr> 810 </table> 811 </div> 812 813 <!-- regenerate websize --> 814 <div id="action_regenerateWebsize" class="bulkAction"> 815 <p> 816 <img src="admin/themes/default/icon/warning.png" alt="!" style="vertical-align:middle;"> 817 {'By default, Piwigo will create a new websize from the HD (high definition) version of your photo.'|@translate} 818 {'If no HD is available and if the current websize is bigger than resize dimensions, Piwigo will move it as HD and create a downsized websize photo from it.'|@translate} 819 </p> 820 821 <table style="margin:10px 20px;"> 822 <tr> 823 <th>{'Maximum Width'|@translate}</th> 824 <td><input type="text" name="websize_maxwidth" value="{$upload_form_settings.websize_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td> 825 </tr> 826 <tr> 827 <th>{'Maximum Height'|@translate}</th> 828 <td><input type="text" name="websize_maxheight" value="{$upload_form_settings.websize_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td> 829 </tr> 830 <tr> 831 <th>{'Image Quality'|@translate}</th> 832 <td><input type="text" name="websize_quality" value="{$upload_form_settings.websize_quality}" size="3" maxlength="3"> %</td> 833 </tr> 834 </table> 835 </div> 836 771 <!-- generate derivatives --> 772 <div id="action_generate_derivatives" class="bulkAction"> 773 <a href="javascript:selectGenerateDerivAll()">{'All'|@translate}</a>, 774 <a href="javascript:selectGenerateDerivNone()">{'None'|@translate}</a> 775 <br> 776 {foreach from=$generate_derivatives_types key=type item=disp} 777 <label><input type="checkbox" name="generate_derivatives_type[]" value="{$type}"> {$disp}</label> 778 {/foreach} 779 {footer_script} 780 function selectGenerateDerivAll() {ldelim} 781 $("#action_generate_derivatives input[type=checkbox]").attr("checked", true); 782 } 783 function selectGenerateDerivNone() {ldelim} 784 $("#action_generate_derivatives input[type=checkbox]").attr("checked", false); 785 } 786 {/footer_script} 787 </div> 788 789 <!-- delete derivatives --> 790 <div id="action_delete_derivatives" class="bulkAction"> 791 <a href="javascript:selectDelDerivAll()">{'All'|@translate}</a>, 792 <a href="javascript:selectDelDerivNone()">{'None'|@translate}</a> 793 <br> 794 {foreach from=$del_derivatives_types key=type item=disp} 795 <label><input type="checkbox" name="del_derivatives_type[]" value="{$type}"> {$disp}</label> 796 {/foreach} 797 {footer_script} 798 function selectDelDerivAll() {ldelim} 799 $("#action_delete_derivatives input[type=checkbox]").attr("checked", true); 800 } 801 function selectDelDerivNone() {ldelim} 802 $("#action_delete_derivatives input[type=checkbox]").attr("checked", false); 803 } 804 {/footer_script} 805 </div> 806 837 807 <!-- progress bar --> 838 <div id="regenerationMsg" class="bulkAction" >839 <p id="regenerationText" style="margin-bottom:10px;"> </p>808 <div id="regenerationMsg" class="bulkAction" style="display:none"> 809 <p id="regenerationText" style="margin-bottom:10px;">{'Generate multiple size images'|@translate}</p> 840 810 <span class="progressBar" id="progressBar"></span> 841 811 <input type="hidden" name="regenerateSuccess" value="0"> -
trunk/admin/themes/default/template/maintenance.tpl
r13074 r13544 35 35 <li><a href="{$U_MAINT_SEARCH}"onclick="return confirm('{'Purge search history'|@translate|@escape:'javascript'}');">{'Purge search history'|@translate}</a></li> 36 36 <li><a href="{$U_MAINT_COMPILED_TEMPLATES}">{'Purge compiled templates'|@translate}</a></li> 37 <li>{' Purge derivative image cache'|@translate}:37 <li>{'Delete multiple size images'|@translate}: 38 38 {foreach from=$purge_derivatives key=name item=url name=loop}{if !$smarty.foreach.loop.first}, {/if}<a href="{$url}">{$name}</a>{/foreach} 39 39 </li>
Note: See TracChangeset
for help on using the changeset viewer.