diff options
author | plegall <plg@piwigo.org> | 2010-04-09 19:47:29 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2010-04-09 19:47:29 +0000 |
commit | e39b4c4a0c4fe6f5a146a55f5119d01abe09bcb7 (patch) | |
tree | 11779c177a99b77c500de75153ca4294fa6b193f | |
parent | fce10ca2d46e0cdc86f2c4b76209ce5af692f32c (diff) |
feature 1591: smarter default categories in upload form. We use the most
recently added photo as reference.
git-svn-id: http://piwigo.org/svn/trunk@5743 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | admin/photos_add_direct.php | 40 | ||||
-rw-r--r-- | admin/themes/default/template/photos_add_direct.tpl | 4 |
2 files changed, 41 insertions, 3 deletions
diff --git a/admin/photos_add_direct.php b/admin/photos_add_direct.php index 0c24fc6ef..ec7235ad7 100644 --- a/admin/photos_add_direct.php +++ b/admin/photos_add_direct.php @@ -379,6 +379,36 @@ if (isset($page['thumbnails'])) } } +// categories +// +// we need to know the category in which the last photo was added +$selected_category = array(); +$selected_parent = array(); + +$query = ' +SELECT + category_id, + id_uppercat + FROM '.IMAGES_TABLE.' AS i + JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id + JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id + ORDER BY i.id DESC + LIMIT 1 +;'; +$result = pwg_query($query); +if (pwg_db_num_rows($result) > 0) +{ + $row = pwg_db_fetch_assoc($result); + + $selected_category = array($row['category_id']); + + if (!empty($row['id_uppercat'])) + { + $selected_parent = array($row['id_uppercat']); + } +} + +// existing category $query = ' SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' @@ -386,10 +416,18 @@ SELECT id,name,uppercats,global_rank display_select_cat_wrapper( $query, - array(), + $selected_category, 'category_options' ); +// new category +display_select_cat_wrapper( + $query, + $selected_parent, + 'category_parent_options' + ); + + // image level options $tpl_options = array(); foreach (array_reverse($conf['available_permission_levels']) as $level) diff --git a/admin/themes/default/template/photos_add_direct.tpl b/admin/themes/default/template/photos_add_direct.tpl index 1200a049e..f75ad2493 100644 --- a/admin/themes/default/template/photos_add_direct.tpl +++ b/admin/themes/default/template/photos_add_direct.tpl @@ -172,7 +172,7 @@ var buttonText = 'Browse'; <div id="category_type_existing" style="display:none" class="category_selection"> <select class="categoryDropDown" name="category"> - {html_options options=$category_options} + {html_options options=$category_options selected=$category_options_selected} </select> </div> @@ -183,7 +183,7 @@ var buttonText = 'Browse'; <td> <select class="categoryDropDown" name="category_parent"> <option value="0">------------</option> - {html_options options=$category_options} + {html_options options=$category_parent_options selected=$category_parent_options_selected} </select> </td> </tr> |