diff options
author | mistic100 <mistic@piwigo.org> | 2012-10-27 10:59:31 +0000 |
---|---|---|
committer | mistic100 <mistic@piwigo.org> | 2012-10-27 10:59:31 +0000 |
commit | 41c8a69ca2e6c754dc5e08c9362805a6b051bc82 (patch) | |
tree | 1abfcbda5fc46127c69c78f0c876acaba8c4056d /admin | |
parent | fe8330d14f762b05dbc213296f3b6866e58e0218 (diff) |
feature:2718 Add batch manager filters for photo dimensions, redisgn
git-svn-id: http://piwigo.org/svn/trunk@18758 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r-- | admin/batch_manager.php | 70 | ||||
-rw-r--r-- | admin/themes/default/template/batch_manager_global.tpl | 42 |
2 files changed, 62 insertions, 50 deletions
diff --git a/admin/batch_manager.php b/admin/batch_manager.php index e144731d8..8e7a48e0e 100644 --- a/admin/batch_manager.php +++ b/admin/batch_manager.php @@ -93,14 +93,23 @@ if (isset($_POST['submitFilter'])) if (isset($_POST['filter_dimension_use'])) { - if ( $_POST['filter_dimension'] != 'format' and !preg_match('#^[0-9]+$#', $_POST['filter_dimension_'. $_POST['filter_dimension'] ]) ) + foreach (array('min_width','max_width','min_height','max_height') as $type) { - array_push($page['errors'], l10n('Invalid dimension')); + if ( preg_match('#^[0-9]+$#', $_POST['filter_dimension_'. $type ]) ) + { + $_SESSION['bulk_manager_filter']['dimension'][$type] = $_POST['filter_dimension_'. $type ]; + } } - else + } + + if (isset($_POST['filter_ratio_use'])) + { + foreach (array('min','max') as $type) { - $_SESSION['bulk_manager_filter']['dimension'] = $_POST['filter_dimension']; - $_SESSION['bulk_manager_filter']['dimension_'. $_POST['filter_dimension'] ] = $_POST['filter_dimension_'. $_POST['filter_dimension'] ]; + if ( preg_match('#^[0-9\.,]+$#', $_POST['filter_ratio_'. $type ]) ) + { + $_SESSION['bulk_manager_filter']['ratio'][$type] = str_replace(',','.',$_POST['filter_ratio_'. $type ]); + } } } } @@ -340,39 +349,38 @@ if (!empty($_SESSION['bulk_manager_filter']['tags'])) ); } -if (isset($_SESSION['bulk_manager_filter']['dimension'])) +if (isset($_SESSION['bulk_manager_filter']['dimension']) or isset($_SESSION['bulk_manager_filter']['ratio'])) { - switch ($_SESSION['bulk_manager_filter']['dimension']) + $where_clauses = array(); + if (isset($_SESSION['bulk_manager_filter']['dimension']['min_width'])) { - case 'min_width': - $where_clause = 'width >= '.$_SESSION['bulk_manager_filter']['dimension_min_width']; break; - case 'max_width': - $where_clause = 'width <= '.$_SESSION['bulk_manager_filter']['dimension_max_width']; break; - case 'min_height': - $where_clause = 'height >= '.$_SESSION['bulk_manager_filter']['dimension_min_height']; break; - case 'max_height': - $where_clause = 'height <= '.$_SESSION['bulk_manager_filter']['dimension_max_height']; break; - case 'format': - { - switch ($_SESSION['bulk_manager_filter']['dimension_format']) - { - case 'portrait': - $where_clause = 'width/height < 0.95'; break; - case 'square': - $where_clause = 'width/height >= 0.95 AND width/height <= 1.05'; break; - case 'landscape': - $where_clause = 'width/height > 1.05 AND width/height < 2.5'; break; - case 'panorama': - $where_clause = 'width/height >= 2.5'; break; - } - break; - } + $where_clause[] = 'width >= '.$_SESSION['bulk_manager_filter']['dimension']['min_width']; + } + if (isset($_SESSION['bulk_manager_filter']['dimension']['max_width'])) + { + $where_clause[] = 'width <= '.$_SESSION['bulk_manager_filter']['dimension']['max_width']; + } + if (isset($_SESSION['bulk_manager_filter']['dimension']['min_height'])) + { + $where_clause[] = 'height >= '.$_SESSION['bulk_manager_filter']['dimension']['min_height']; + } + if (isset($_SESSION['bulk_manager_filter']['dimension']['max_height'])) + { + $where_clause[] = 'height <= '.$_SESSION['bulk_manager_filter']['dimension']['max_height']; + } + if (isset($_SESSION['bulk_manager_filter']['ratio']['min'])) + { + $where_clause[] = 'width/height >= '.$_SESSION['bulk_manager_filter']['ratio']['min']; + } + if (isset($_SESSION['bulk_manager_filter']['ratio']['max'])) + { + $where_clause[] = 'width/height <= '.$_SESSION['bulk_manager_filter']['ratio']['max']; } $query = ' SELECT id FROM '.IMAGES_TABLE.' - WHERE '.$where_clause.' + WHERE '.implode(' AND ',$where_clause).' '.$conf['order_by']; $filter_sets[] = array_from_query($query, 'id'); diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl index 5b031fc6b..154a19f20 100644 --- a/admin/themes/default/template/batch_manager_global.tpl +++ b/admin/themes/default/template/batch_manager_global.tpl @@ -392,6 +392,11 @@ $(document).ready(function() { $("span[id^='filter_dimension_']").hide(); $("span#filter_dimension_"+ $(this).attr("value")).show(); }); + + $("a.ratio-choice").click(function() { + $("input[name='filter_ratio_min']").val($(this).data("min")); + $("input[name='filter_ratio_max']").val($(this).data("max")); + }); function filter_disable(filter) { /* hide the filter line */ @@ -552,25 +557,23 @@ $(document).ready(function() { <li id="filter_dimension" {if !isset($filter.dimension)}style="display:none"{/if}> <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a> <input type="checkbox" name="filter_dimension_use" class="useFilterCheckbox" {if isset($filter.dimension)}checked="checked"{/if}> - <select name="filter_dimension"> - <option value="min_width" {if $filter.dimension=='min_width'}selected="selected"{/if}>{'Minimum width'|@translate}</option> - <option value="max_width" {if $filter.dimension=='max_width'}selected="selected"{/if}>{'Maximum width'|@translate}</option> - <option value="min_height" {if $filter.dimension=='min_height'}selected="selected"{/if}>{'Minimum height'|@translate}</option> - <option value="max_height" {if $filter.dimension=='max_height'}selected="selected"{/if}>{'Maximum height'|@translate}</option> - <option value="format" {if $filter.dimension=='format'}selected="selected"{/if}>{'Format'|@translate}</option> - </select> - <span id="filter_dimension_min_width" {if !isset($filter.dimension_min_width) and isset($filter.dimension)}style="display:none;"{/if}><input type="text" name="filter_dimension_min_width" value="{$filter.dimension_min_width}" size="4"> px</span> - <span id="filter_dimension_max_width" {if !isset($filter.dimension_max_width)}style="display:none;"{/if}><input type="text" name="filter_dimension_max_width" value="{$filter.dimension_max_width}" size="4"> px</span> - <span id="filter_dimension_min_height" {if !isset($filter.dimension_min_height)}style="display:none;"{/if}><input type="text" name="filter_dimension_min_height" value="{$filter.dimension_min_height}" size="4"> px</span> - <span id="filter_dimension_max_height" {if !isset($filter.dimension_max_height)}style="display:none;"{/if}><input type="text" name="filter_dimension_max_height" value="{$filter.dimension_max_height}" size="4"> px</span> - <span id="filter_dimension_format" {if !isset($filter.dimension_format)}style="display:none;"{/if}> - <select name="filter_dimension_format"> - <option value="portrait" {if $filter.dimension_format=='portrait'}selected="selected"{/if}>{'Portrait'|@translate}</option> - <option value="square" {if $filter.dimension_format=='square'}selected="selected"{/if}>{'square'|@translate}</option> - <option value="landscape" {if $filter.dimension_format=='landscape'}selected="selected"{/if}>{'Landscape'|@translate}</option> - <option value="panorama" {if $filter.dimension_format=='panorama'}selected="selected"{/if}>{'Panorama'|@translate}</option> - </select> - </span> + {'Dimensions'|@translate} : + <label>{'Minimum width'|@translate} <input type="text" name="filter_dimension_min_width" value="{$filter.dimension.min_width}" size="4"></label> — + <label>{'Maximum width'|@translate} <input type="text" name="filter_dimension_max_width" value="{$filter.dimension.max_width}" size="4"></label> — + <label>{'Minimum height'|@translate} <input type="text" name="filter_dimension_min_height" value="{$filter.dimension.min_height}" size="4"></label> — + <label>{'Maximum height'|@translate} <input type="text" name="filter_dimension_max_height" value="{$filter.dimension.max_height}" size="4"></label> + </li> + + <li id="filter_ratio" {if !isset($filter.ratio)}style="display:none"{/if}> + <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a> + <input type="checkbox" name="filter_ratio_use" class="useFilterCheckbox" {if isset($filter.ratio)}checked="checked"{/if}> + {'Ratio'|@translate} : + <label>{'Minimum'|@translate} <input type="text" name="filter_ratio_min" value="{$filter.ratio.min}" size="4"></label> — + <label>{'Maximum'|@translate} <input type="text" name="filter_ratio_max" value="{$filter.ratio.max}" size="4"></label> — + <a class="ratio-choice" data-min="" data-max="0.95">{'Portrait'|@translate}</a> | + <a class="ratio-choice" data-min="0.95" data-max="1.05">{'square'|@translate}</a> | + <a class="ratio-choice" data-min="1.05" data-max="2.5">{'Landscape'|@translate}</a> | + <a class="ratio-choice" data-min="2.5" data-max="">{'Panorama'|@translate}</a> </li> </ul> @@ -583,6 +586,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_ratio" {if isset($filter.ratio)}disabled="disabled"{/if}>{'Ratio'|@translate}</option> </select> <a id="removeFilters" href="">{'Remove all filters'|@translate}</a> </p> |