aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2012-09-15 15:47:52 +0000
committermistic100 <mistic@piwigo.org>2012-09-15 15:47:52 +0000
commit0b7bd87646bd4e44474c7b2612a970b6afbbd235 (patch)
treef2875a980dc18a438101f1c8610da92a837ae897 /admin
parentff130a06af20d09e9ac19767714549f61974e0f8 (diff)
feature 2718: Add batch manager filters for photo dimensions
git-svn-id: http://piwigo.org/svn/trunk@17931 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/batch_manager.php51
-rw-r--r--admin/themes/default/template/batch_manager_global.tpl41
2 files changed, 88 insertions, 4 deletions
diff --git a/admin/batch_manager.php b/admin/batch_manager.php
index 71f3c72f6..7feb5a6a2 100644
--- a/admin/batch_manager.php
+++ b/admin/batch_manager.php
@@ -90,6 +90,19 @@ 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'] ]) )
+ {
+ array_push($page['errors'], l10n('Invalid dimension'));
+ }
+ else
+ {
+ $_SESSION['bulk_manager_filter']['dimension'] = $_POST['filter_dimension'];
+ $_SESSION['bulk_manager_filter']['dimension_'. $_POST['filter_dimension'] ] = $_POST['filter_dimension_'. $_POST['filter_dimension'] ];
+ }
+ }
}
if (isset($_GET['cat']))
@@ -327,6 +340,44 @@ if (!empty($_SESSION['bulk_manager_filter']['tags']))
);
}
+if (isset($_SESSION['bulk_manager_filter']['dimension']))
+{
+ switch ($_SESSION['bulk_manager_filter']['dimension'])
+ {
+ 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;
+ }
+ }
+
+ $query = '
+SELECT id
+ FROM '.IMAGES_TABLE.'
+ WHERE '.$where_clause.'
+ '.$conf['order_by'];
+
+ $filter_sets[] = array_from_query($query, 'id');
+}
+
$current_set = array_shift($filter_sets);
foreach ($filter_sets as $set)
{
diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl
index ac6e84623..a3e5c156d 100644
--- a/admin/themes/default/template/batch_manager_global.tpl
+++ b/admin/themes/default/template/batch_manager_global.tpl
@@ -391,6 +391,11 @@ $(document).ready(function() {
filter_enable(filter);
$(this).attr("value", -1);
});
+
+ $("select[name='filter_dimension']").change(function () {
+ $("span[id^='filter_dimension_']").hide();
+ $("span#filter_dimension_"+ $(this).attr("value")).show();
+ });
function filter_disable(filter) {
/* hide the filter line */
@@ -506,6 +511,7 @@ $(document).ready(function() {
{/foreach}
</select>
</li>
+
<li id="filter_category" {if !isset($filter.category)}style="display:none"{/if}>
<a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
<input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
@@ -515,6 +521,7 @@ $(document).ready(function() {
</select>
<label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
</li>
+
<li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}>
<a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
<input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
@@ -527,6 +534,7 @@ $(document).ready(function() {
<label><span><input type="radio" name="tag_mode" value="AND" {if !isset($filter.tag_mode) or $filter.tag_mode eq 'AND'}checked="checked"{/if}> {'All tags'|@translate}</span></label>
<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>
</li>
+
<li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
<a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
<input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
@@ -536,16 +544,41 @@ $(document).ready(function() {
</select>
<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>
</li>
+
+ <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>
+ </li>
</ul>
<p class="actionButtons">
<select id="addFilter">
<option value="-1">{'Add a filter'|@translate}</option>
<option disabled="disabled">------------------</option>
- <option value="filter_prefilter">{'Predefined filter'|@translate}</option>
- <option value="filter_category">{'Album'|@translate}</option>
- <option value="filter_tags">{'Tags'|@translate}</option>
- <option value="filter_level">{'Privacy level'|@translate}</option>
+ <option value="filter_prefilter" {if isset($filter.prefilter)}disabled="disabled"{/if}>{'Predefined filter'|@translate}</option>
+ <option value="filter_category" {if isset($filter.category)}disabled="disabled"{/if}>{'Album'|@translate}</option>
+ <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>
</select>
<!-- <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> -->
<a id="removeFilters" href="">{'Remove all filters'|@translate}</a>