From 067b4c567cf4dec8af200caa227d4d39aa0f96e2 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Tue, 25 Jun 2013 11:37:44 +0000 Subject: 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 --- index.php | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'index.php') 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 -- cgit v1.2.3