Changeset 17931


Ignore:
Timestamp:
Sep 15, 2012, 5:47:52 PM (8 years ago)
Author:
mistic100
Message:

feature 2718: Add batch manager filters for photo dimensions

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r17765 r17931  
    9191    }
    9292  }
     93 
     94  if (isset($_POST['filter_dimension_use']))
     95  {
     96    if ( $_POST['filter_dimension'] != 'format' and !preg_match('#^[0-9]+$#', $_POST['filter_dimension_'. $_POST['filter_dimension'] ]) )
     97    {
     98      array_push($page['errors'], l10n('Invalid dimension'));
     99    }
     100    else
     101    {
     102      $_SESSION['bulk_manager_filter']['dimension'] = $_POST['filter_dimension'];
     103      $_SESSION['bulk_manager_filter']['dimension_'. $_POST['filter_dimension'] ] = $_POST['filter_dimension_'. $_POST['filter_dimension'] ];
     104    }
     105  }
    93106}
    94107
     
    328341}
    329342
     343if (isset($_SESSION['bulk_manager_filter']['dimension']))
     344{
     345  switch ($_SESSION['bulk_manager_filter']['dimension'])
     346  {
     347    case 'min_width':
     348      $where_clause = 'width >= '.$_SESSION['bulk_manager_filter']['dimension_min_width']; break;
     349    case 'max_width':
     350      $where_clause = 'width <= '.$_SESSION['bulk_manager_filter']['dimension_max_width']; break;
     351    case 'min_height':
     352      $where_clause = 'height >= '.$_SESSION['bulk_manager_filter']['dimension_min_height']; break;
     353    case 'max_height':
     354      $where_clause = 'height <= '.$_SESSION['bulk_manager_filter']['dimension_max_height']; break;
     355    case 'format':
     356    {
     357      switch ($_SESSION['bulk_manager_filter']['dimension_format'])
     358      {
     359        case 'portrait':
     360          $where_clause = 'width/height < 0.95'; break;
     361        case 'square':
     362          $where_clause = 'width/height >= 0.95 AND width/height <= 1.05'; break;
     363        case 'landscape':
     364          $where_clause = 'width/height > 1.05 AND width/height < 2.5'; break;
     365        case 'panorama':
     366          $where_clause = 'width/height >= 2.5'; break;
     367      }
     368      break;
     369    }
     370  }
     371 
     372  $query = '
     373SELECT id
     374  FROM '.IMAGES_TABLE.'
     375  WHERE '.$where_clause.'
     376  '.$conf['order_by'];
     377
     378  $filter_sets[] = array_from_query($query, 'id');
     379}
     380
    330381$current_set = array_shift($filter_sets);
    331382foreach ($filter_sets as $set)
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r17856 r17931  
    392392    $(this).attr("value", -1);
    393393  });
     394 
     395  $("select[name='filter_dimension']").change(function () {
     396    $("span[id^='filter_dimension_']").hide();
     397    $("span#filter_dimension_"+ $(this).attr("value")).show();
     398  });
    394399
    395400  function filter_disable(filter) {
     
    507512        </select>
    508513      </li>
     514     
    509515      <li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
    510516        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     
    516522        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
    517523      </li>
     524     
    518525      <li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}>
    519526        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     
    528535        <label><span><input type="radio" name="tag_mode" value="OR" {if isset($filter.tag_mode) and $filter.tag_mode eq 'OR'}checked="checked"{/if}> {'Any tag'|@translate}</span></label>
    529536      </li>
     537     
    530538      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
    531539        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     
    537545        <label><input type="checkbox" name="filter_level_include_lower" {if isset($filter.level_include_lower)}checked="checked"{/if}> {'include photos with lower privacy level'|@translate}</label>
    538546      </li>
     547     
     548      <li id="filter_dimension" {if !isset($filter.dimension)}style="display:none"{/if}>
     549        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     550        <input type="checkbox" name="filter_dimension_use" class="useFilterCheckbox" {if isset($filter.dimension)}checked="checked"{/if}>
     551        <select name="filter_dimension">
     552          <option value="min_width" {if $filter.dimension=='min_width'}selected="selected"{/if}>{'Minimum width'|@translate}</option>
     553          <option value="max_width" {if $filter.dimension=='max_width'}selected="selected"{/if}>{'Maximum width'|@translate}</option>
     554          <option value="min_height" {if $filter.dimension=='min_height'}selected="selected"{/if}>{'Minimum height'|@translate}</option>
     555          <option value="max_height" {if $filter.dimension=='max_height'}selected="selected"{/if}>{'Maximum height'|@translate}</option>
     556          <option value="format" {if $filter.dimension=='format'}selected="selected"{/if}>{'Format'|@translate}</option>
     557        </select>
     558        <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>
     559        <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>
     560        <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>
     561        <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>
     562        <span id="filter_dimension_format" {if !isset($filter.dimension_format)}style="display:none;"{/if}>
     563          <select name="filter_dimension_format">
     564            <option value="portrait" {if $filter.dimension_format=='portrait'}selected="selected"{/if}>{'Portrait'|@translate}</option>
     565            <option value="square" {if $filter.dimension_format=='square'}selected="selected"{/if}>{'square'|@translate}</option>
     566            <option value="landscape" {if $filter.dimension_format=='landscape'}selected="selected"{/if}>{'Landscape'|@translate}</option>
     567            <option value="panorama" {if $filter.dimension_format=='panorama'}selected="selected"{/if}>{'Panorama'|@translate}</option>
     568          </select>
     569        </span>
     570      </li>
    539571    </ul>
    540572
     
    543575        <option value="-1">{'Add a filter'|@translate}</option>
    544576        <option disabled="disabled">------------------</option>
    545         <option value="filter_prefilter">{'Predefined filter'|@translate}</option>
    546         <option value="filter_category">{'Album'|@translate}</option>
    547                                 <option value="filter_tags">{'Tags'|@translate}</option>
    548         <option value="filter_level">{'Privacy level'|@translate}</option>
     577        <option value="filter_prefilter" {if isset($filter.prefilter)}disabled="disabled"{/if}>{'Predefined filter'|@translate}</option>
     578        <option value="filter_category" {if isset($filter.category)}disabled="disabled"{/if}>{'Album'|@translate}</option>
     579        <option value="filter_tags" {if isset($filter.tags)}disabled="disabled"{/if}>{'Tags'|@translate}</option>
     580        <option value="filter_level" {if isset($filter.level)}disabled="disabled"{/if}>{'Privacy level'|@translate}</option>
     581        <option value="filter_dimension" {if isset($filter.dimension)}disabled="disabled"{/if}>{'Dimensions'|@translate}</option>
    549582      </select>
    550583<!--      <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
  • trunk/language/en_UK/admin.lang.php

    r17509 r17931  
    358358$lang['Forbidden'] = "Forbidden";
    359359$lang['Form'] = "Form";
     360$lang['Format'] = 'Format';
    360361$lang['FTP + Synchronization'] = 'FTP + Synchronization';
    361362$lang['Gallery title'] = "Gallery title";
     
    429430$lang['Installed Themes'] = "Installed Themes";
    430431$lang['Instructions to use Piwigo'] = "Instructions to use Piwigo";
     432$lang['Invalid dimension'] = 'Invalid dimension';
    431433$lang['Invert'] = 'Invert';
    432434$lang['IP'] = "IP";
     
    435437$lang['jump to photo'] = "jump to photo";
    436438$lang['Keep in touch with Piwigo project, subscribe to Piwigo Announcement Newsletter. You will receive emails when a new release is available (sometimes including a security bug fix, it\'s important to know and upgrade) and when major events happen to the project. Only a few emails a year.'] = "Keep in touch with Piwigo project, subscribe to Piwigo Announcement Newsletter. You will be sent emails when a new release is available (sometimes including a security bug fix, it is important to know and upgrade) and when major events happen to the project. Only a few emails a year.";
     439$lang['Landscape'] = 'Landscape';
    437440$lang['Language has been successfully installed'] = 'Language has been successfully installed';
    438441$lang['Languages which need upgrade'] = 'Languages which need upgrade';
     
    492495$lang['Metadata synchronized from file'] = "Metadata synchronized from file";
    493496$lang['middle'] = 'middle';
     497$lang['Minimum width'] = 'Minimum width';
     498$lang['Minimum height'] = 'Minimum height';
    494499$lang['Minimum privacy level'] = "Minimum privacy level";
    495500$lang['Miscellaneous'] = 'Miscellaneous';
     
    565570$lang['Page end'] = 'Page end';
    566571$lang['Pages seen'] = "Pages seen";
     572$lang['Panorama'] = 'Panorama';
    567573$lang['Parameter'] = "Settings";
    568574$lang['Parameters'] = "Parameters";
     
    622628$lang['Plugins which need upgrade'] = "Plugins to be upgraded";
    623629$lang['Plugins'] = "Plugins";
     630$lang['Portrait'] = 'Portrait';
    624631$lang['Position'] = "Position";
    625632$lang['Posted %s on %s'] = 'Posted %s on %s';
  • trunk/language/fr_FR/admin.lang.php

    r17509 r17931  
    928928$lang['Tag "%s" is now a duplicate of "%s"'] = "Le tag \"%s\" est désormais une copie de \"%s\"";
    929929$lang['Duplicate selected tags'] = 'Dupliquer les tags sélectionnés';
     930$lang['Invalid dimension'] = 'Dimension invalide';
     931$lang['Minimum width'] = 'Largeur minimale';
     932$lang['Minimum height'] = 'Hauteur minimale';
     933$lang['Format'] = 'Format';
     934$lang['Portrait'] = 'Portrait';
     935$lang['Landscape'] = 'Paysage';
     936$lang['Panorama'] = 'Panorama';
    930937?>
Note: See TracChangeset for help on using the changeset viewer.