aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2014-08-21 17:10:15 +0000
committerplegall <plg@piwigo.org>2014-08-21 17:10:15 +0000
commit83ed6f8009cb99be29aeb17f848e76bb4d52ff8f (patch)
treed8adcbcdaaead909a2f1d828e705b01702f853e2 /admin
parentb1c6c5624932e6204cf82ae9b5336167552f3fa5 (diff)
feature 2791: batch manager, filter by filesize
git-svn-id: http://piwigo.org/svn/trunk@29238 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/batch_manager.php83
-rw-r--r--admin/themes/default/template/batch_manager_global.tpl53
-rw-r--r--admin/themes/default/theme.css4
3 files changed, 138 insertions, 2 deletions
diff --git a/admin/batch_manager.php b/admin/batch_manager.php
index c34ee7406..e00364367 100644
--- a/admin/batch_manager.php
+++ b/admin/batch_manager.php
@@ -132,6 +132,17 @@ if (isset($_POST['submitFilter']))
}
}
+ if (isset($_POST['filter_filesize_use']))
+ {
+ foreach (array('min','max') as $type)
+ {
+ if ( preg_match('#^[0-9\.]+$#', $_POST['filter_filesize_'. $type ]) )
+ {
+ $_SESSION['bulk_manager_filter']['filesize'][$type] = $_POST['filter_filesize_'. $type ];
+ }
+ }
+ }
+
if (isset($_POST['filter_search_use']))
{
$_SESSION['bulk_manager_filter']['search']['q'] = $_POST['q'];
@@ -412,6 +423,29 @@ SELECT id
$filter_sets[] = query2array($query, null, 'id');
}
+if (isset($_SESSION['bulk_manager_filter']['filesize']))
+{
+ $where_clauses = array();
+
+ if (isset($_SESSION['bulk_manager_filter']['filesize']['min']))
+ {
+ $where_clause[] = 'filesize >= '.$_SESSION['bulk_manager_filter']['filesize']['min']*1024;
+ }
+
+ if (isset($_SESSION['bulk_manager_filter']['filesize']['max']))
+ {
+ $where_clause[] = 'filesize <= '.$_SESSION['bulk_manager_filter']['filesize']['max']*1024;
+ }
+
+ $query = '
+SELECT id
+ FROM '.IMAGES_TABLE.'
+ WHERE '.implode(' AND ',$where_clause).'
+ '.$conf['order_by'];
+
+ $filter_sets[] = query2array($query, null, 'id');
+}
+
if (isset($_SESSION['bulk_manager_filter']['search']))
{
include_once( PHPWG_ROOT_PATH .'include/functions_search.inc.php' );
@@ -579,6 +613,55 @@ foreach (array_keys($dimensions['bounds']) as $type)
$template->assign('dimensions', $dimensions);
+// +-----------------------------------------------------------------------+
+// | filesize |
+// +-----------------------------------------------------------------------+
+
+$filesizes = array();
+
+$query = '
+SELECT
+ filesize
+ FROM '.IMAGES_TABLE.'
+ WHERE filesize IS NOT NULL
+ GROUP BY filesize
+;';
+$result = pwg_query($query);
+
+while ($row = pwg_db_fetch_assoc($result))
+{
+ $filesizes[] = sprintf('%.1f', $row['filesize']/1024);
+}
+
+if (empty($filesizes))
+{ // arbitrary values, only used when no photos on the gallery
+ $filesizes = array(0, 1, 2, 5, 8, 15);
+}
+
+$filesizes = array_unique($filesizes);
+sort($filesizes);
+
+// add 0.1MB to the last value, to make sure the heavier photo will be in
+// the result
+$filesizes[count($filesizes)-1]+= 0.1;
+
+$filesize['list'] = implode(',', $filesizes);
+
+$filesize['bounds'] = array(
+ 'min' => $filesizes[0],
+ 'max' => $filesizes[count($filesizes)-1],
+ );
+
+// selected=bound if nothing selected
+foreach (array_keys($filesize['bounds']) as $type)
+{
+ $filesize['selected'][$type] = isset($_SESSION['bulk_manager_filter']['filesize'][$type])
+ ? $_SESSION['bulk_manager_filter']['filesize'][$type]
+ : $filesize['bounds'][$type]
+ ;
+}
+
+$template->assign('filesize', $filesize);
// +-----------------------------------------------------------------------+
// | open specific mode |
diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl
index 94adb98be..6ee116408 100644
--- a/admin/themes/default/template/batch_manager_global.tpl
+++ b/admin/themes/default/template/batch_manager_global.tpl
@@ -353,6 +353,43 @@ $(document).ready(function() {
.slider("values", 1, getSliderKeyFromValue(max, dimension_values[type]) );
});
+ {* filesize, copied from dimensions filter and modified, to be moved in a plugin later *}
+ var filesize_values = [{$filesize.list}];
+
+ function filesize_onSliderChange(ui, pattern) {
+ $("input[name='filter_filesize_min']").val(filesize_values[ui.values[0]]);
+ $("input[name='filter_filesize_max']").val(filesize_values[ui.values[1]]);
+
+ $("#filter_filesize_info").html(sprintf(
+ pattern,
+ filesize_values[ui.values[0]],
+ filesize_values[ui.values[1]]
+ ));
+ }
+
+ $("#filter_filesize_slider").slider({
+ range: true,
+ min: 0,
+ max: filesize_values.length - 1,
+ values: [
+ getSliderKeyFromValue({$filesize.selected.min}, filesize_values),
+ getSliderKeyFromValue({$filesize.selected.max}, filesize_values)
+ ],
+ slide: function(event, ui) {
+ filesize_onSliderChange(ui, "{'between %s and %s MB'|translate|escape:'javascript'}");
+ },
+ change: function(event, ui) {
+ filesize_onSliderChange(ui, "{'between %s and %s MB'|translate|escape:'javascript'}");
+ }
+ });
+
+ $("a.filesize-choice").click(function() {
+ $("#filter_filesize_slider")
+ .slider("values", 0, 0)
+ .slider("values", 1, filesize_values.length - 1);
+ });
+
+
jQuery("select[name=filter_prefilter]").change(function() {
jQuery("#empty_caddie").toggle(jQuery(this).val() == "caddie");
});
@@ -460,6 +497,21 @@ $(document).ready(function() {
{combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'}
<a href="admin/popuphelp.php?page=quick_search" onclick="popuphelp(this.href);return false;" title="{'Help'|@translate}"><span class="icon-help-circled"></span></a>
</li>
+
+ <li id="filter_filesize" {if !isset($filter.filesize)}style="display:none"{/if}>
+ <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
+ <input type="checkbox" name="filter_filesize_use" class="useFilterCheckbox" {if isset($filter.filesize)}checked="checked"{/if}>
+ {'Filesize'|@translate}
+
+ <blockquote>
+ <span id="filter_filesize_info">{'between %s and %s MB'|@translate:$filesize.selected.min:$filesize.selected.max}</span>
+ | <a class="filesize-choice">{'Reset'|@translate}</a>
+ <div id="filter_filesize_slider"></div>
+ </blockquote>
+
+ <input type="hidden" name="filter_filesize_min" value="{$filesize.selected.min}">
+ <input type="hidden" name="filter_filesize_max" value="{$filesize.selected.max}">
+ </li>
</ul>
<p class="actionButtons">
@@ -471,6 +523,7 @@ $(document).ready(function() {
<option value="filter_tags" {if isset($filter.tags)}disabled="disabled"{/if}>{'Tags'|@translate}</option>
<option value="filter_level" {if isset($filter.level)}disabled="disabled"{/if}>{'Privacy level'|@translate}</option>
<option value="filter_dimension" {if isset($filter.dimension)}disabled="disabled"{/if}>{'Dimensions'|@translate}</option>
+ <option value="filter_filesize" {if isset($filter.filesize)}disabled="disabled"{/if}>{'Filesize'|@translate}</option>
<option value="filter_search"{if isset($filter.search)} disabled="disabled"{/if}>{'Search'|@translate}</option>
</select>
<a id="removeFilters">{'Remove all filters'|@translate}</a>
diff --git a/admin/themes/default/theme.css b/admin/themes/default/theme.css
index 05f7282f0..1dd29258f 100644
--- a/admin/themes/default/theme.css
+++ b/admin/themes/default/theme.css
@@ -978,8 +978,8 @@ LEGEND {
#batchManagerGlobal #applyFilterBlock {margin-top:20px;}
#batchManagerGlobal .useFilterCheckbox {display:none;}
-#batchManagerGlobal #filter_dimension blockquote {margin:5px 0 20px 15px;}
-#batchManagerGlobal #filter_dimension .ui-slider-horizontal {width:650px;margin:5px 0 10px 0;}
+#batchManagerGlobal blockquote {margin:5px 0 20px 15px;}
+#batchManagerGlobal .ui-slider-horizontal {width:650px;margin:5px 0 10px 0;}
#order_filters a.addFilter {font-weight:normal;margin-left:20px;}
#order_filters a.removeFilter {font-weight:normal;}