Changeset 18988


Ignore:
Timestamp:
Nov 10, 2012, 9:10:01 PM (8 years ago)
Author:
mistic100
Message:

feature:2718 Add batch manager filters for photo dimensions, redesign with sliders

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r18758 r18988  
    101101      }
    102102    }
    103   }
    104  
    105   if (isset($_POST['filter_ratio_use']))
    106   {
    107     foreach (array('min','max') as $type)
    108     {
    109       if ( preg_match('#^[0-9\.,]+$#', $_POST['filter_ratio_'. $type ]) )
     103    foreach (array('min_ratio','max_ratio') as $type)
     104    {
     105      if ( preg_match('#^[0-9\.]+$#', $_POST['filter_dimension_'. $type ]) )
    110106      {
    111         $_SESSION['bulk_manager_filter']['ratio'][$type] = str_replace(',','.',$_POST['filter_ratio_'. $type ]);
     107        $_SESSION['bulk_manager_filter']['dimension'][$type] = $_POST['filter_dimension_'. $type ];
    112108      }
    113109    }
     
    350346}
    351347
    352 if (isset($_SESSION['bulk_manager_filter']['dimension']) or isset($_SESSION['bulk_manager_filter']['ratio']))
     348if (isset($_SESSION['bulk_manager_filter']['dimension']))
    353349{
    354350  $where_clauses = array();
     
    369365    $where_clause[] = 'height <= '.$_SESSION['bulk_manager_filter']['dimension']['max_height'];
    370366  }
    371   if (isset($_SESSION['bulk_manager_filter']['ratio']['min']))
    372   {
    373     $where_clause[] = 'width/height >= '.$_SESSION['bulk_manager_filter']['ratio']['min'];
    374   }
    375   if (isset($_SESSION['bulk_manager_filter']['ratio']['max']))
    376   {
    377     $where_clause[] = 'width/height <= '.$_SESSION['bulk_manager_filter']['ratio']['max'];
     367  if (isset($_SESSION['bulk_manager_filter']['dimension']['min_ratio']))
     368  {
     369    $where_clause[] = 'width/height >= '.$_SESSION['bulk_manager_filter']['dimension']['min_ratio'];
     370  }
     371  if (isset($_SESSION['bulk_manager_filter']['dimension']['max_ratio']))
     372  {
     373    $where_clause[] = 'width/height <= '.$_SESSION['bulk_manager_filter']['dimension']['max_ratio'];
    378374  }
    379375 
     
    444440
    445441// +-----------------------------------------------------------------------+
     442// |                              dimensions                               |
     443// +-----------------------------------------------------------------------+
     444$query = '
     445SELECT
     446    MIN(width) as min_width,
     447    MAX(width) as max_width,
     448    MIN(height) as min_height,
     449    MAX(height) as max_height,
     450    MIN(width/height) as min_ratio,
     451    MAX(width/height) as max_ratio
     452  FROM '.IMAGES_TABLE.'
     453;';
     454$dimensions['bounds'] = pwg_db_fetch_assoc(pwg_query($query));
     455$dimensions['bounds']['min_ratio'] = floor($dimensions['bounds']['min_ratio']*100)/100;
     456$dimensions['bounds']['max_ratio'] = ceil($dimensions['bounds']['max_ratio']*100)/100;
     457
     458foreach (array_keys($dimensions['bounds']) as $type)
     459{
     460  $dimensions['selected'][$type] = isset($_SESSION['bulk_manager_filter']['dimension'][$type]) ? $_SESSION['bulk_manager_filter']['dimension'][$type] : $dimensions['bounds'][$type];
     461}
     462$template->assign('dimensions', $dimensions);
     463
     464
     465// +-----------------------------------------------------------------------+
    446466// |                         open specific mode                            |
    447467// +-----------------------------------------------------------------------+
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r18758 r18988  
    33{include file='include/colorbox.inc.tpl'}
    44{include file='include/add_album.inc.tpl'}
     5{combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'}
     6{combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"}
    57
    68{footer_script}{literal}
     
    388390    $(this).attr("value", -1);
    389391  });
    390  
    391   $("select[name='filter_dimension']").change(function () {
    392     $("span[id^='filter_dimension_']").hide();
    393     $("span#filter_dimension_"+ $(this).attr("value")).show();
    394   });
    395  
    396   $("a.ratio-choice").click(function() {
    397     $("input[name='filter_ratio_min']").val($(this).data("min"));
    398     $("input[name='filter_ratio_max']").val($(this).data("max"));
    399   });
    400392
    401393  function filter_disable(filter) {
     
    494486        }
    495487
    496   checkPermitAction()
     488  checkPermitAction();
     489{/literal}
     490 
     491  /* dimensions sliders */
     492  $("#filter_dimension_width_slider").slider({ldelim}
     493    range: true,
     494    min: {$dimensions.bounds.min_width},
     495    max: {$dimensions.bounds.max_width},
     496    values: [{$dimensions.selected.min_width}, {$dimensions.selected.max_width}],
     497    slide: function(event, ui) {ldelim}
     498      $("input[name='filter_dimension_min_width']").val(ui.values[0]);
     499      $("input[name='filter_dimension_max_width']").val(ui.values[1]);
     500      $("#filter_dimension_width_info").html(sprintf("{'between %d and %d pixels'|@translate}", ui.values[0], ui.values[1]));
     501    },
     502    change: function(event, ui) {ldelim}
     503      $("input[name='filter_dimension_min_width']").val(ui.values[0]);
     504      $("input[name='filter_dimension_max_width']").val(ui.values[1]);
     505      $("#filter_dimension_width_info").html(sprintf("{'between %d and %d pixels'|@translate}", ui.values[0], ui.values[1]));
     506    }
     507  });
     508  $("#filter_dimension_height_slider").slider({ldelim}
     509    range: true,
     510    min: {$dimensions.bounds.min_height},
     511    max: {$dimensions.bounds.max_height},
     512    values: [{$dimensions.selected.min_height}, {$dimensions.selected.max_height}],
     513    slide: function(event, ui) {ldelim}
     514      $("input[name='filter_dimension_min_height']").val(ui.values[0]);
     515      $("input[name='filter_dimension_max_height']").val(ui.values[1]);
     516      $("#filter_dimension_height_info").html(sprintf("{'between %d and %d pixels'|@translate}", ui.values[0], ui.values[1]));
     517    },
     518    change: function(event, ui) {ldelim}
     519      $("input[name='filter_dimension_min_height']").val(ui.values[0]);
     520      $("input[name='filter_dimension_max_height']").val(ui.values[1]);
     521      $("#filter_dimension_height_info").html(sprintf("{'between %d and %d pixels'|@translate}", ui.values[0], ui.values[1]));
     522    }
     523  });
     524  $("#filter_dimension_ratio_slider").slider({ldelim}
     525    range: true,
     526    step: 0.01,
     527    min: {$dimensions.bounds.min_ratio},
     528    max: {$dimensions.bounds.max_ratio},
     529    values: [{$dimensions.selected.min_ratio}, {$dimensions.selected.max_ratio}],
     530    slide: function(event, ui) {ldelim}
     531      $("input[name='filter_dimension_min_ratio']").val(ui.values[0]);
     532      $("input[name='filter_dimension_max_ratio']").val(ui.values[1]);
     533      $("#filter_dimension_ratio_info").html(sprintf("{'between %.2f and %.2f'|@translate}", ui.values[0], ui.values[1]));
     534    },
     535    change: function(event, ui) {ldelim}
     536      $("input[name='filter_dimension_min_ratio']").val(ui.values[0]);
     537      $("input[name='filter_dimension_max_ratio']").val(ui.values[1]);
     538      $("#filter_dimension_ratio_info").html(sprintf("{'between %.2f and %.2f'|@translate}", ui.values[0], ui.values[1]));
     539    }
     540  });
     541 
     542  $("a.dimensions-choice").click(function() {ldelim}
     543    $("#filter_dimension_"+ $(this).data("type") +"_slider").slider("values", 0, $(this).data("min"));
     544    $("#filter_dimension_"+ $(this).data("type") +"_slider").slider("values", 1, $(this).data("max"));
     545  });
    497546});
    498547
    499 
    500 {/literal}{/footer_script}
     548{/footer_script}
    501549
    502550<div id="batchManagerGlobal">
     
    559607        <input type="checkbox" name="filter_dimension_use" class="useFilterCheckbox" {if isset($filter.dimension)}checked="checked"{/if}>
    560608        {'Dimensions'|@translate} :
    561         <label>{'Minimum width'|@translate} <input type="text" name="filter_dimension_min_width" value="{$filter.dimension.min_width}" size="4"></label> —
    562         <label>{'Maximum width'|@translate} <input type="text" name="filter_dimension_max_width" value="{$filter.dimension.max_width}" size="4"></label> —
    563         <label>{'Minimum height'|@translate} <input type="text" name="filter_dimension_min_height" value="{$filter.dimension.min_height}" size="4"></label>     —
    564         <label>{'Maximum height'|@translate} <input type="text" name="filter_dimension_max_height" value="{$filter.dimension.max_height}" size="4"></label>
    565       </li>
    566      
    567       <li id="filter_ratio" {if !isset($filter.ratio)}style="display:none"{/if}>
    568         <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
    569         <input type="checkbox" name="filter_ratio_use" class="useFilterCheckbox" {if isset($filter.ratio)}checked="checked"{/if}>
    570         {'Ratio'|@translate} :
    571         <label>{'Minimum'|@translate} <input type="text" name="filter_ratio_min" value="{$filter.ratio.min}" size="4"></label> —
    572         <label>{'Maximum'|@translate} <input type="text" name="filter_ratio_max" value="{$filter.ratio.max}" size="4"></label> —
    573         <a class="ratio-choice" data-min="" data-max="0.95">{'Portrait'|@translate}</a> |
    574         <a class="ratio-choice" data-min="0.95" data-max="1.05">{'square'|@translate}</a> |
    575         <a class="ratio-choice" data-min="1.05" data-max="2.5">{'Landscape'|@translate}</a> |
    576         <a class="ratio-choice" data-min="2.5" data-max="">{'Panorama'|@translate}</a>
     609       
     610        <blockquote>
     611          {'Width'|@translate} : <span id="filter_dimension_width_info">{'between %d and %d pixels'|@translate|sprintf:$dimensions.selected.min_width:$dimensions.selected.max_width}</span>
     612          | <a class="dimensions-choice" data-type="width" data-min="{$dimensions.bounds.min_width}" data-max="{$dimensions.bounds.max_width}">{'Reset'|@translate}</a>
     613          <div id="filter_dimension_width_slider"></div>
     614         
     615          {'Height'|@translate} : <span id="filter_dimension_height_info">{'between %d and %d pixels'|@translate|sprintf:$dimensions.selected.min_height:$dimensions.selected.max_height}</span>
     616          | <a class="dimensions-choice" data-type="height" data-min="{$dimensions.bounds.min_height}" data-max="{$dimensions.bounds.max_height}">{'Reset'|@translate}</a>
     617          <div id="filter_dimension_height_slider"></div>
     618         
     619          {'Ratio'|@translate} : <span id="filter_dimension_ratio_info">{'between %.2f and %.2f'|@translate|sprintf:$dimensions.selected.min_ratio:$dimensions.selected.max_ratio}</span>
     620          | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.bounds.min_ratio}" data-max="0.95">{'Portrait'|@translate}</a>
     621          | <a class="dimensions-choice" data-type="ratio" data-min="0.95" data-max="1.05">{'square'|@translate}</a>
     622          | <a class="dimensions-choice" data-type="ratio" data-min="1.05" data-max="2.5">{'Landscape'|@translate}</a>
     623          | <a class="dimensions-choice" data-type="ratio" data-min="2.5" data-max="{$dimensions.bounds.max_ratio}">{'Panorama'|@translate}</a>
     624          | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.bounds.min_ratio}" data-max="{$dimensions.bounds.max_ratio}">{'Reset'|@translate}</a>
     625          <div id="filter_dimension_ratio_slider"></div>
     626        </blockquote>
     627       
     628        <input type="hidden" name="filter_dimension_min_width" value="{$dimensions.selected.min_width}">
     629        <input type="hidden" name="filter_dimension_max_width" value="{$dimensions.selected.max_width}">
     630        <input type="hidden" name="filter_dimension_min_height" value="{$dimensions.selected.min_height}">
     631        <input type="hidden" name="filter_dimension_max_height" value="{$dimensions.selected.max_height}">
     632        <input type="hidden" name="filter_dimension_min_ratio" value="{$dimensions.selected.min_ratio}">
     633        <input type="hidden" name="filter_dimension_max_ratio" value="{$dimensions.selected.max_ratio}">
    577634      </li>
    578635    </ul>
     
    587644        <option value="filter_level" {if isset($filter.level)}disabled="disabled"{/if}>{'Privacy level'|@translate}</option>
    588645        <option value="filter_dimension" {if isset($filter.dimension)}disabled="disabled"{/if}>{'Dimensions'|@translate}</option>
    589         <option value="filter_ratio" {if isset($filter.ratio)}disabled="disabled"{/if}>{'Ratio'|@translate}</option>
    590646      </select>
    591647      <a id="removeFilters" href="">{'Remove all filters'|@translate}</a>
  • trunk/language/en_UK/admin.lang.php

    r18758 r18988  
    208208$lang['Batch Manager'] = 'Batch Manager';
    209209$lang['between'] = "between";
     210$lang['between %d and %d pixels'] = 'between %d and %d pixels';
     211$lang['between %.2f and %.2f'] = 'between %.2f and %.2f';
    210212$lang['bottom left corner'] = 'bottom left corner';
    211213$lang['bottom right corner'] = 'bottom right corner';
     
    358360$lang['Forbidden'] = "Forbidden";
    359361$lang['Form'] = "Form";
    360 $lang['Format'] = 'Format';
    361362$lang['FTP + Synchronization'] = 'FTP + Synchronization';
    362363$lang['Gallery title'] = "Gallery title";
     
    485486$lang['manual order'] = 'manual order';
    486487$lang['Manual order'] = 'Manual order';
    487 $lang['Maximum'] = 'Maximum';
    488488$lang['Maximum file size: %sB.'] = 'Maximum file size: %sB.';
    489489$lang['Maximum height'] = 'Maximum height';
     
    496496$lang['Metadata synchronized from file'] = "Metadata synchronized from file";
    497497$lang['middle'] = 'middle';
    498 $lang['Minimum'] = 'Minimum';
    499498$lang['Minimum width'] = 'Minimum width';
    500499$lang['Minimum height'] = 'Minimum height';
  • trunk/language/fr_FR/admin.lang.php

    r18759 r18988  
    931931$lang['Minimum width'] = 'Largeur minimale';
    932932$lang['Minimum height'] = 'Hauteur minimale';
    933 $lang['Format'] = 'Format';
    934933$lang['Portrait'] = 'Portrait';
    935934$lang['Landscape'] = 'Paysage';
     
    938937$lang['View in gallery'] = 'Voir dans la galerie';
    939938$lang['Number of albums per page'] = 'Nombre d\'albums par page';
    940 $lang['Maximum'] = 'Maximum';
    941 $lang['Minimum'] = 'Minimum';
    942939$lang['Ratio'] = 'Ratio';
     940$lang['between %d and %d pixels'] = 'entre %d et %d pixels';
     941$lang['between %.2f and %.2f'] = 'entre %.2f et %.2f';
    943942?>
Note: See TracChangeset for help on using the changeset viewer.