aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/batch_manager_global.php66
-rw-r--r--admin/themes/default/template/batch_manager_global.tpl105
2 files changed, 171 insertions, 0 deletions
diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php
index 11cafe02d..065fa318f 100644
--- a/admin/batch_manager_global.php
+++ b/admin/batch_manager_global.php
@@ -33,6 +33,15 @@ if (!defined('PHPWG_ROOT_PATH'))
}
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+prepare_upload_configuration();
+
+$upload_form_config = get_upload_form_config();
+foreach ($upload_form_config as $param_shortname => $param)
+{
+ $param_name = 'upload_form_'.$param_shortname;
+ $form_values[$param_shortname] = $conf[$param_name];
+}
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok |
@@ -394,6 +403,61 @@ SELECT id, path
);
}
+ if ('regenerateThumbnails' == $action)
+ {
+ if ($_POST['regenerateSuccess'] != '0')
+ array_push($page['infos'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateSuccess']));
+
+ if ($_POST['regenerateError'] != '0')
+ array_push($page['warnings'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateError']));
+
+ // Update configuration
+ $fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality');
+ $updates = array();
+ foreach ($fields as $field)
+ {
+ $value = null;
+ if (!empty($_POST[$field]))
+ {
+ $value = $_POST[$field];
+ }
+
+ if (preg_match($upload_form_config[$field]['pattern'], $value)
+ and $value >= $upload_form_config[$field]['min']
+ and $value <= $upload_form_config[$field]['max'])
+ {
+ $conf['upload_form_'.$field] = $value;
+ $updates[] = array(
+ 'param' => 'upload_form_'.$field,
+ 'value' => $value
+ );
+ }
+ else
+ {
+ $updates = null;
+ break;
+ }
+ $form_values[$field] = $value;
+ }
+ if (!empty($updates))
+ {
+ mass_updates(
+ CONFIG_TABLE,
+ array(
+ 'primary' => array('param'),
+ 'update' => array('value')
+ ),
+ $updates
+ );
+ }
+ function regenerateThumbnails_prefilter($content, $smarty)
+ {
+ return str_replace('{$thumbnail.TN_SRC}', '{$thumbnail.TN_SRC}?rand='.md5(uniqid(rand(), true)), $content);
+ }
+ $template->set_prefilter('batch_manager_global', 'regenerateThumbnails_prefilter');
+ $template->delete_compiled_templates();
+ }
+
trigger_action('element_set_global_action', $action, $collection);
}
@@ -430,6 +494,8 @@ $template->assign(
'prefilters' => $prefilters,
'filter' => $_SESSION['bulk_manager_filter'],
'selection' => $collection,
+ 'all_elements' => $page['cat_elements_id'],
+ 'upload_form_settings' => $form_values,
'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')),
'F_ACTION'=>$base_url.get_query_string_diff(array('cat')),
)
diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl
index cce2b74c8..e97a53ad6 100644
--- a/admin/themes/default/template/batch_manager_global.tpl
+++ b/admin/themes/default/template/batch_manager_global.tpl
@@ -6,6 +6,8 @@
{/literal}{/footer_script}
{combine_script id='jquery.fcbkcomplete' load='footer' require='jquery' path='themes/default/js/plugins/jquery.fcbkcomplete.js'}
+{combine_script id='jquery.progressBar' load='footer' path='plugins/regenerateThumbnails/js/jquery.progressbar.min.js'}
+{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
{footer_script require='jquery.fcbkcomplete'}{literal}
jQuery(document).ready(function() {
@@ -26,11 +28,20 @@ jQuery(document).ready(function() {
var nb_thumbs_page = {$nb_thumbs_page};
var nb_thumbs_set = {$nb_thumbs_set};
var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
+var elements = new Array();
+var all_elements = [{','|@implode:$all_elements}];
var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
var selectedMessage_all = "{'All %d photos are selected'|@translate}";
+var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}";
{literal}
+var queuedManagerThumbnails = $.manageAjax.create('queued', {
+ queue: true,
+ cacheResponse: false,
+ maxRequests: 3
+});
+
function str_repeat(i, m) {
for (var o = []; m > 0; o[--m] = i);
return o.join('');
@@ -78,6 +89,21 @@ function sprintf() {
return o.join('');
}
+function progress(val, max, success) {
+ jQuery('#progressBar').progressBar(val, {
+ max: max,
+ textFormat: 'fraction',
+ boxImage: 'themes/default/images/progressbar.gif',
+ barImage: 'themes/default/images/progressbg_orange.gif'
+ });
+ type = success ? 'regenerateSuccess': 'regenerateError'
+ s = jQuery('[name="'+type+'"]').val();
+ jQuery('[name="'+type+'"]').val(++s);
+
+ if (val == max)
+ jQuery('#applyAction').click();
+}
+
$(document).ready(function() {
function checkPermitAction() {
var nbSelected = 0;
@@ -300,6 +326,58 @@ $(document).ready(function() {
return false;
});
+ jQuery('#applyAction').click(function() {
+ if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') {
+ if (elements.length != 0)
+ return true;
+
+ if (jQuery('input[name="setSelected"]').attr('checked'))
+ elements = all_elements;
+ else
+ jQuery('input[name="selection[]"]').each(function() {
+ if (jQuery(this).attr('checked')) {
+ elements.push(jQuery(this).val());
+ }
+ });
+
+ maxwidth = jQuery('input[name="thumb_maxwidth"]').val();
+ maxheight = jQuery('input[name="thumb_maxheight"]').val();
+ progressBar_max = elements.length;
+ todo = 0;
+
+ jQuery('#thumb_config').hide();
+ jQuery('#applyActionBlock').hide();
+ jQuery('select[name="selectAction"]').hide();
+ jQuery('#regenerationMsg').show();
+ jQuery('#regenerationText').html(regenerateThumbnailsMessage);
+ 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<elements.length;i++) {
+ queuedManagerThumbnails.add({
+ type: 'GET',
+ url: 'ws.php',
+ data: {
+ method: 'pwg.images.resize',
+ type: 'thumbnail',
+ maxwidth: maxwidth,
+ maxheight: maxheight,
+ image_id: elements[i],
+ format: 'json'
+ },
+ dataType: 'json',
+ success: ( function(data) { progress(++todo, progressBar_max, data['result']) }),
+ error: ( function(data) { progress(++todo, progressBar_max, false) })
+ });
+ }
+ return false;
+ }
+ });
+
checkPermitAction()
});
@@ -473,6 +551,7 @@ jQuery(window).load(function() {
{else}
<option value="add_to_caddie">{'add to caddie'|@translate}</option>
{/if}
+ <option value="regenerateThumbnails">{'Regenerate Thumbnails'|@translate}</option>
{if !empty($element_set_global_plugins_actions)}
{foreach from=$element_set_global_plugins_actions item=action}
<option value="{$action.ID}">{$action.NAME}</option>
@@ -559,6 +638,32 @@ jQuery(window).load(function() {
<div id="action_metadata" class="bulkAction">
</div>
+ <!-- regenerate thumbnails -->
+ <div id="action_regenerateThumbnails" class="bulkAction">
+ <table style="margin-left:20px;" id="thumb_config">
+ <tr>
+ <th>{'Maximum Width'|@translate}</th>
+ <td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+ </tr>
+ <tr>
+ <th>{'Maximum Height'|@translate}</th>
+ <td><input type="text" name="thumb_maxheight" value="{$upload_form_settings.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+ </tr>
+ <tr>
+ <th>{'Image Quality'|@translate}</th>
+ <td><input type="text" name="thumb_quality" value="{$upload_form_settings.thumb_quality}" size="3" maxlength="3"> %</td>
+ </tr>
+ </table>
+ </div>
+
+ <!-- progress bar -->
+ <div id="regenerationMsg" style="display:none;">
+ <p id="regenerationText" style="margin-bottom:10px;"></p>
+ <span class="progressBar" id="progressBar"></span>
+ <input type="hidden" name="regenerateSuccess" value="0">
+ <input type="hidden" name="regenerateError" value="0">
+ </div>
+
<!-- plugins -->
{if !empty($element_set_global_plugins_actions)}
{foreach from=$element_set_global_plugins_actions item=action}