aboutsummaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-06-25 11:37:44 +0000
committermistic100 <mistic@piwigo.org>2013-06-25 11:37:44 +0000
commit067b4c567cf4dec8af200caa227d4d39aa0f96e2 (patch)
tree9b5c7846be2dca4d1de224783efbf5067554b281 /index.php
parent1c7ecb93e52d7c1f0d9db5d33161d2f8f35adb4b (diff)
bug:2931 photos sort order, "default" is meaningless
check the first criteria if available git-svn-id: http://piwigo.org/svn/trunk@23533 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'index.php')
-rw-r--r--index.php40
1 files changed, 29 insertions, 11 deletions
diff --git a/index.php b/index.php
index 65c19bd69..a79f90166 100644
--- a/index.php
+++ b/index.php
@@ -243,33 +243,51 @@ if ( empty($page['is_external']) or !$page['is_external'] )
}
}
-
+ // image order
if ( $conf['index_sort_order_input']
and count($page['items']) > 0
and $page['section'] != 'most_visited'
and $page['section'] != 'best_rated')
{
- // image order
+ $preferred_image_orders = get_category_preferred_image_orders();
$order_idx = pwg_get_session_var( 'image_order', 0 );
-
+
+ // get first order field and direction
+ $first_order = substr($conf['order_by'], 9);
+ if (($pos = strpos($first_order, ',')) !== false)
+ {
+ $first_order = substr($first_order, 0, $pos);
+ }
+ $first_order = trim($first_order);
+
$url = add_url_params(
duplicate_index_url(),
array('image_order' => '')
);
- foreach (get_category_preferred_image_orders() as $order_id => $order)
+ $tpl_orders = array();
+ $order_selected = false;
+
+ foreach ($preferred_image_orders as $order_id => $order)
{
if ($order[2])
{
- $template->append(
- 'image_orders',
- array(
- 'DISPLAY' => $order[0],
- 'URL' => $url.$order_id,
- 'SELECTED' => ($order_idx == $order_id ? true:false),
- )
+ // force select if the field is the first field of order_by
+ if (!$order_selected && $order[1]==$first_order)
+ {
+ $order_idx = $order_id;
+ $order_selected = true;
+ }
+
+ $tpl_orders[ $order_id ] = array(
+ 'DISPLAY' => $order[0],
+ 'URL' => $url.$order_id,
+ 'SELECTED' => $order_idx==$order_id,
);
}
}
+
+ $tpl_orders[0]['SELECTED'] = !$order_selected; // unselect "Default" if another one is selected
+ $template->assign('image_orders', $tpl_orders);
}
// category comment