From 9064686d9990b6830c0cd6a00d95745d3841eb9e Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 5 Dec 2004 21:28:40 +0000 Subject: - on picture.php, related categories under the element are displayed in global_rank order - when adding a new virtual category, initializes its global_rank - bug fixed : in admin/cat_list, false next rank - in admin/cat_modify, complete directory is calculated only if category is not virtual - admin/picture_modify rewritten : graphically nearer to admin/cat_modify, virtual associations are back - update_category partially rewritten : take an array of categories in parameter, becomes optionnaly recursive, use the set_random_representant function, set a random representant for categories with elements and no representant - bug fixed : on a search results screen, elements belonging to more than 1 category were shown more than once - bug fixed : in admin/cat_modify, changing a value in a textefield and hitting enter was setting a new random representant git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/cat_list.php | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'admin/cat_list.php') diff --git a/admin/cat_list.php b/admin/cat_list.php index 2914901b5..72862b484 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.php @@ -62,16 +62,7 @@ else if (isset($_POST['submit'])) $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL'; // As we don't create a virtual category every day, let's do (far) too // much queries - if ($parent_id != 'NULL') - { - $query = ' -SELECT uppercats - FROM '.CATEGORIES_TABLE.' - WHERE id = '.$parent_id.' -;'; - $parent_uppercats = array_pop(mysql_fetch_array(pwg_query($query))); - } - + // we have then to add the virtual category $query = ' INSERT INTO '.CATEGORIES_TABLE.' @@ -87,16 +78,41 @@ SELECT MAX(id) FROM '.CATEGORIES_TABLE.' ;'; $my_id = array_pop(mysql_fetch_array(pwg_query($query))); + + if ($parent_id != 'NULL') + { + $query = ' +SELECT uppercats, global_rank + FROM '.CATEGORIES_TABLE.' + WHERE id = '.$parent_id.' +;'; + $result = pwg_query($query); + $row = mysql_fetch_array($result); + + $parent_uppercats = $row['uppercats']; + $parent_global_rank = $row['global_rank']; + } $query = ' UPDATE '.CATEGORIES_TABLE.' - SET uppercats = \''; +'; if (!empty($parent_uppercats)) { - $query.= $parent_uppercats.','; + $query.= " SET uppercats = CONCAT('".$parent_uppercats."',',',id)"; + } + else + { + $query.= ' SET uppercats = id'; + } + if (!empty($parent_global_rank)) + { + $query.= " , global_rank = CONCAT('".$parent_global_rank."','.',rank)"; + } + else + { + $query.= ' , uppercats = id'; } - $query.= $my_id; - $query.= '\' + $query.= ' WHERE id = '.$my_id.' ;'; pwg_query($query); @@ -276,9 +292,16 @@ reset($categories); // +-----------------------------------------------------------------------+ $template->set_filenames(array('categories'=>'admin/cat_list.tpl')); +$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; +if (isset($_GET['parent_id'])) +{ + $form_action.= '&parent_id='.$_GET['parent_id']; +} + $template->assign_vars(array( 'CATEGORIES_NAV'=>$navigation, - 'NEXT_RANK'=>count($categories)+1, + 'NEXT_RANK'=>max(array_keys($categories))+1, + 'F_ACTION'=>$form_action, 'L_ADD_VIRTUAL'=>$lang['cat_add'], 'L_SUBMIT'=>$lang['submit'], -- cgit v1.2.3