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 | |
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 '')
-rw-r--r-- | admin/batch_manager.php | 70 | ||||
-rw-r--r-- | admin/themes/default/template/batch_manager_global.tpl | 42 | ||||
-rw-r--r-- | language/en_UK/admin.lang.php | 4 |
3 files changed, 65 insertions, 51 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> diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index 7055d3e01..f75cd873a 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -429,7 +429,6 @@ $lang['Install'] = "Install"; $lang['Installed Languages'] = 'Installed Languages'; $lang['Installed Themes'] = "Installed Themes"; $lang['Instructions to use Piwigo'] = "Instructions to use Piwigo"; -$lang['Invalid dimension'] = 'Invalid dimension'; $lang['Invert'] = 'Invert'; $lang['IP'] = "IP"; $lang['iPhoto is the default photo manager on MacOSX. The Piwigo export plugin let you create new albums and export your photos directly from iPhoto to your Piwigo photo gallery.'] = 'iPhoto is the default photo manager on MacOSX. The Piwigo export plugin let you create new albums and export your photos directly from iPhoto to your Piwigo photo gallery.'; @@ -485,6 +484,7 @@ $lang['Manage this set of %d photos'] = 'Manage this set of %d photos'; $lang['Manage'] = "Manage"; $lang['manual order'] = 'manual order'; $lang['Manual order'] = 'Manual order'; +$lang['Maximum'] = 'Maximum'; $lang['Maximum file size: %sB.'] = 'Maximum file size: %sB.'; $lang['Maximum height'] = 'Maximum height'; $lang['Maximum width'] = 'Maximum width'; @@ -495,6 +495,7 @@ $lang['Merge tags'] = 'Merge tags'; $lang['Metadata synchronization results'] = "Metadata synchronization results"; $lang['Metadata synchronized from file'] = "Metadata synchronized from file"; $lang['middle'] = 'middle'; +$lang['Minimum'] = 'Minimum'; $lang['Minimum width'] = 'Minimum width'; $lang['Minimum height'] = 'Minimum height'; $lang['Minimum privacy level'] = "Minimum privacy level"; @@ -656,6 +657,7 @@ $lang['ranks'] = "ranks"; $lang['Rate date'] = "Rate date"; $lang['Rate'] = "Rate"; $lang['Rated %d times, score : %.2f'] = 'Rated %d times, score : %.2f'; +$lang['Ratio'] = "Ratio"; $lang['Rating by guests'] = "Rating by guests"; $lang['Rating'] = "Rating"; $lang['Read Piwigo Documentation'] = 'Read Piwigo Documentation'; |