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
This commit is contained in:
mistic100
2013-06-25 11:37:44 +00:00
parent 1c7ecb93e5
commit 067b4c567c
+29 -11
View File
@@ -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