Skip to content

Commit

Permalink
feature:2718 Add batch manager filters for photo dimensions, small cl…
Browse files Browse the repository at this point in the history
…eaning in the code

git-svn-id: http://piwigo.org/svn/trunk@19121 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed Nov 21, 2012
1 parent f35e8cc commit ad4c9f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions admin/batch_manager.php
Expand Up @@ -370,7 +370,8 @@
}
if (isset($_SESSION['bulk_manager_filter']['dimension']['max_ratio']))
{
$where_clause[] = 'width/height <= '.sprintf('%.2f99', $_SESSION['bulk_manager_filter']['dimension']['max_ratio']);
// max_ratio is a floor value, so must be a bit increased
$where_clause[] = 'width/height < '.($_SESSION['bulk_manager_filter']['dimension']['max_ratio']+0.01);
}

$query = '
Expand Down Expand Up @@ -446,6 +447,7 @@
$heights = array();
$ratios = array();

// get all width, height and ratios
$query = '
SELECT
DISTINCT width, height
Expand All @@ -454,6 +456,7 @@
AND height IS NOT NULL
;';
$result = pwg_query($query);

while ($row = pwg_db_fetch_assoc($result))
{
$widths[] = $row['width'];
Expand All @@ -474,8 +477,6 @@
$dimensions['heights'] = implode(',', $heights);
$dimensions['ratios'] = implode(',', $ratios);

$dimensions['bounds'] = pwg_db_fetch_assoc(pwg_query($query));

$dimensions['bounds'] = array(
'min_width' => $widths[0],
'max_width' => $widths[count($widths)-1],
Expand All @@ -485,6 +486,7 @@
'max_ratio' => $ratios[count($ratios)-1],
);

// find ratio categories
$ratio_categories = array(
'portrait' => array(),
'square' => array(),
Expand All @@ -498,18 +500,15 @@
{
$ratio_categories['portrait'][] = $ratio;
}

if ($ratio >= 0.95 and $ratio < 1.05)
else if ($ratio >= 0.95 and $ratio <= 1.05)
{
$ratio_categories['square'][] = $ratio;
}

if ($ratio > 1.05 and $ratio <= 2.5)
else if ($ratio > 1.05 and $ratio < 2)
{
$ratio_categories['landscape'][] = $ratio;
}

if ($ratio > 2.5)
else if ($ratio >= 2)
{
$ratio_categories['panorama'][] = $ratio;
}
Expand All @@ -526,6 +525,7 @@
}
}

// selected=bound if nothing selected
foreach (array_keys($dimensions['bounds']) as $type)
{
$dimensions['selected'][$type] = isset($_SESSION['bulk_manager_filter']['dimension'][$type])
Expand Down
18 changes: 9 additions & 9 deletions admin/themes/default/template/batch_manager_global.tpl
Expand Up @@ -489,7 +489,7 @@ $(document).ready(function() {

/* dimensions sliders */
/**
* find the key from a value in the startStopValues array, for the hour slider
* find the key from a value in the startStopValues array
*/
function getSliderKeyFromValue(value, values) {
for (var key in values) {
Expand Down Expand Up @@ -603,13 +603,13 @@ $(document).ready(function() {
var min = jQuery(this).data("min");
var max = jQuery(this).data("max");

$("#filter_dimension_"+ type +"_slider").slider(
"values",
0,
$("#filter_dimension_"+ type +"_slider").slider("values", 0,
getSliderKeyFromValue(min, dimension_values[type])
);

$("#filter_dimension_"+type+"_slider").slider("values", 1, getSliderKeyFromValue(max, dimension_values[type]));
$("#filter_dimension_"+type+"_slider").slider("values", 1,
getSliderKeyFromValue(max, dimension_values[type])
);
});
});

Expand Down Expand Up @@ -685,16 +685,16 @@ $(document).ready(function() {
<div id="filter_dimension_height_slider"></div>

{'Ratio'|@translate} ({'Width'|@translate}/{'Height'|@translate}) <span id="filter_dimension_ratio_info">{'between %.2f and %.2f'|@translate|sprintf:$dimensions.selected.min_ratio:$dimensions.selected.max_ratio}</span>
{if isset($dimensions.ratio_portrait.min)}
{if isset($dimensions.ratio_portrait)}
| <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_portrait.min}" data-max="{$dimensions.ratio_portrait.max}">{'Portrait'|@translate}</a>
{/if}
{if isset($dimensions.ratio_square.min)}
{if isset($dimensions.ratio_square)}
| <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_square.min}" data-max="{$dimensions.ratio_square.max}">{'square'|@translate}</a>
{/if}
{if isset($dimensions.ratio_landscape.min)}
{if isset($dimensions.ratio_landscape)}
| <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_landscape.min}" data-max="{$dimensions.ratio_landscape.max}">{'Landscape'|@translate}</a>
{/if}
{if isset($dimensions.ratio_panorama.min)}
{if isset($dimensions.ratio_panorama)}
| <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_panorama.min}" data-max="{$dimensions.ratio_panorama.max}">{'Panorama'|@translate}</a>
{/if}
| <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.bounds.min_ratio}" data-max="{$dimensions.bounds.max_ratio}">{'Reset'|@translate}</a>
Expand Down

0 comments on commit ad4c9f9

Please sign in to comment.