Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mistic100 committed Jun 25, 2013
1 parent 1c7ecb9 commit 067b4c5
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions index.php
Expand Up @@ -243,33 +243,51 @@
}
}


// 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
Expand Down

0 comments on commit 067b4c5

Please sign in to comment.