Changeset 5743


Ignore:
Timestamp:
Apr 9, 2010, 9:47:29 PM (10 years ago)
Author:
plg
Message:

feature 1591: smarter default categories in upload form. We use the most
recently added photo as reference.

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/photos_add_direct.php

    r5742 r5743  
    380380}
    381381
     382// categories
     383//
     384// we need to know the category in which the last photo was added
     385$selected_category = array();
     386$selected_parent = array();
     387
     388$query = '
     389SELECT
     390    category_id,
     391    id_uppercat
     392  FROM '.IMAGES_TABLE.' AS i
     393    JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id
     394    JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id
     395  ORDER BY i.id DESC
     396  LIMIT 1
     397;';
     398$result = pwg_query($query);
     399if (pwg_db_num_rows($result) > 0)
     400{
     401  $row = pwg_db_fetch_assoc($result);
     402 
     403  $selected_category = array($row['category_id']);
     404
     405  if (!empty($row['id_uppercat']))
     406  {
     407    $selected_parent = array($row['id_uppercat']);
     408  }
     409}
     410
     411// existing category
    382412$query = '
    383413SELECT id,name,uppercats,global_rank
     
    387417display_select_cat_wrapper(
    388418  $query,
    389   array(),
     419  $selected_category,
    390420  'category_options'
    391421  );
     422
     423// new category
     424display_select_cat_wrapper(
     425  $query,
     426  $selected_parent,
     427  'category_parent_options'
     428  );
     429
    392430
    393431// image level options
  • trunk/admin/themes/default/template/photos_add_direct.tpl

    r5742 r5743  
    173173      <div id="category_type_existing" style="display:none" class="category_selection">
    174174        <select class="categoryDropDown" name="category">
    175           {html_options options=$category_options}
     175          {html_options options=$category_options selected=$category_options_selected}
    176176        </select>
    177177      </div>
     
    184184              <select class="categoryDropDown" name="category_parent">
    185185                <option value="0">------------</option>
    186                 {html_options options=$category_options}
     186                {html_options options=$category_parent_options selected=$category_parent_options_selected}
    187187              </select>
    188188            </td>
Note: See TracChangeset for help on using the changeset viewer.