From 1d5af70e5e762a911dce3d5ddd413bcdc41dbde1 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Fri, 30 Apr 2004 17:11:25 +0000 Subject: bug 26 : When categories tree has category ids not in ascending order, the order of display still uses ids order. Corrected using categories.uppercats order git-svn-id: http://piwigo.org/svn/branches/release-1_3@412 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_category.inc.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index ec7d97a51..044158715 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -287,17 +287,26 @@ function get_cat_info( $id ) } $cat['comment'] = nl2br( $cat['comment'] ); - $cat['name'] = array(); + // first, we retrieve the names of upper categories in the default order + // (not the correct one automatically) + $buffers_name = array(); - $query = 'SELECT name'; + $query = 'SELECT id, name'; $query.= ' FROM '.PREFIX_TABLE.'categories'; $query.= ' WHERE id IN ('.$cat['uppercats'].')'; - $query.= ' ORDER BY id ASC'; $query.= ';'; $result = mysql_query( $query ); while( $row = mysql_fetch_array( $result ) ) { - array_push( $cat['name'], $row['name'] ); + $buffer_names[$row['id']] = $row['name']; + } + + // then we reorder the names with the order given in the + // categories.uppercats database field + $cat['name'] = array(); + + foreach ( explode( ',', $cat['uppercats'] ) as $id_uppercat ) { + array_push( $cat['name'], $buffer_names[$id_uppercat] ); } return $cat; -- cgit v1.2.3