mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-20 16:42:59 +02:00
bug:2540 When default photos order is only by rank, failure outside albums
define a default order_by + some javascript for limit number of fields git-svn-id: http://piwigo.org/svn/trunk@12872 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
+12
-2
@@ -135,15 +135,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];
|
||||
@@ -151,8 +154,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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user