diff options
author | mistic100 <mistic@piwigo.org> | 2012-02-06 20:22:13 +0000 |
---|---|---|
committer | mistic100 <mistic@piwigo.org> | 2012-02-06 20:22:13 +0000 |
commit | 1411c5bf52b6122a2b9e01984a9e4ca97bf0fba9 (patch) | |
tree | f31e7a50198ca92dec32374608ba2e9ac6493f48 | |
parent | b5c0e17822cc58f7052c92ecc34ba054c6aeff44 (diff) |
merge r12872 from trunk
bug:2540 When default photos order is only by rank, failure outside albums
git-svn-id: http://piwigo.org/svn/branches/2.3@13037 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/configuration.php | 14 | ||||
-rw-r--r-- | admin/themes/default/template/configuration.tpl | 38 |
2 files changed, 41 insertions, 11 deletions
diff --git a/admin/configuration.php b/admin/configuration.php index 53916199f..8488aa489 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -134,15 +134,18 @@ if (isset($_POST['submit'])) { $order_by = array(); $order_by_inside_category = array(); + for ($i=0; $i<count($_POST['order_by_field']); $i++) { - if ($i>5) continue; - if ($_POST['order_by_field'][$i] == '') + if ( $i >= (count($sort_fields)-1) ) break; // limit to the number of available parameters + if ( empty($_POST['order_by_field'][$i]) ) { array_push($page['errors'], l10n('No field selected')); + break; } else { + // there is no rank outside categories if ($_POST['order_by_field'][$i] != 'rank') { $order_by[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i]; @@ -150,8 +153,15 @@ if (isset($_POST['submit'])) $order_by_inside_category[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i]; } } + // must define a default order_by if user want to order by rank only + if ( count($order_by) == 0 ) + { + $order_by = array('id ASC'); + } + $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by); $_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category); + unset($_POST['order_by_field']); } } diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl index 205d5ffb0..c0070b1a5 100644 --- a/admin/themes/default/template/configuration.tpl +++ b/admin/themes/default/template/configuration.tpl @@ -115,24 +115,44 @@ </li> {if !$ORDER_BY_IS_CUSTOM} -{footer_script require='jquery'}{literal} +{footer_script require='jquery'} +// counters for displaying of addFilter link +fields = {$main.order_by|@count}; max_fields = {$main.order_field_options|@count}; max_fields--; + +{literal} +function updateAddFilterLink() { + if (fields >= max_fields) { + $('.addFilter').css('display', 'none'); + } else { + $('.addFilter').css('display', ''); + } +} + +function updateRemoveFilterTrigger() { + $(".removeFilter").click(function () { + $(this).parent('span.filter').remove(); + fields--; + updateAddFilterLink(); + }); +} + jQuery(document).ready(function () { $('.addFilter').click(function() { rel = $(this).attr('rel'); $(this).prev('span.filter').clone().insertBefore($(this)); $(this).prev('span.filter').children('select[name="order_by_field[]"]').val(''); $(this).prev('span.filter').children('select[name="order_by_direction[]"]').val('ASC'); - - $(".removeFilter").click(function () { - $(this).parent('span.filter').remove(); - }); + + fields++; + updateAddFilterLink(); + updateRemoveFilterTrigger(); }); - $(".removeFilter").click(function () { - $(this).parent('span.filter').remove(); - }); + updateRemoveFilterTrigger(); + updateAddFilterLink(); }); -{/literal}{/footer_script} +{/literal} +{/footer_script} {/if} </ul> </fieldset> |