Ignore:
Timestamp:
Feb 10, 2012, 11:52:07 AM (13 years ago)
Author:
plg
Message:

feature 2564: redesign on photo administration screen.

  • one screen with several tabs (for now: properties + coi)
  • double select boxes for album associations and representation have been converted to simple multiple select boxes with jQuery Chosen
  • more details about the photo in an introduction text
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/picture_modify.php

    r13038 r13077  
    3737check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
    3838
     39// represent
     40$query = '
     41SELECT id
     42  FROM '.CATEGORIES_TABLE.'
     43  WHERE representative_picture_id = '.$_GET['image_id'].'
     44;';
     45$represent_options_selected = array_from_query($query, 'id');
     46
    3947// +-----------------------------------------------------------------------+
    4048// |                             delete photo                              |
     
    133141  }
    134142
    135   if (isset($_POST['date_creation_action']))
    136   {
    137     if ('set' == $_POST['date_creation_action'])
    138     {
    139       $data{'date_creation'} = $_POST['date_creation_year']
    140                                  .'-'.$_POST['date_creation_month']
    141                                  .'-'.$_POST['date_creation_day'];
    142     }
    143     else if ('unset' == $_POST['date_creation_action'])
    144     {
    145       $data{'date_creation'} = '';
    146     }
     143  if (!empty($_POST['date_creation_year']))
     144  {
     145    $data{'date_creation'} =
     146      $_POST['date_creation_year']
     147      .'-'.$_POST['date_creation_month']
     148      .'-'.$_POST['date_creation_day'];
     149  }
     150  else
     151  {
     152    $data{'date_creation'} = null;
    147153  }
    148154
     
    164170  set_tags($tag_ids, $_GET['image_id']);
    165171
     172  // association to albums
     173  move_images_to_categories(array($_GET['image_id']), $_POST['associate']);
     174
     175  // thumbnail for albums
     176  if (!isset($_POST['represent']))
     177  {
     178    $_POST['represent'] = array();
     179  }
     180 
     181  $no_longer_thumbnail_for = array_diff($represent_options_selected, $_POST['represent']);
     182  if (count($no_longer_thumbnail_for) > 0)
     183  {
     184    set_random_representant($no_longer_thumbnail_for);
     185  }
     186
     187  $new_thumbnail_for = array_diff($_POST['represent'], $represent_options_selected);
     188  if (count($new_thumbnail_for) > 0)
     189  {
     190    $query = '
     191UPDATE '.CATEGORIES_TABLE.'
     192  SET representative_picture_id = '.$_GET['image_id'].'
     193  WHERE id IN ('.implode(',', $new_thumbnail_for).')
     194;';
     195    pwg_query($query);
     196  }
     197
     198  $represent_options_selected = $_POST['represent'];
     199 
    166200  array_push($page['infos'], l10n('Photo informations updated'));
    167 }
    168 // associate the element to other categories than its storage category
    169 if (isset($_POST['associate'])
    170     and isset($_POST['cat_dissociated'])
    171     and count($_POST['cat_dissociated']) > 0
    172   )
    173 {
    174   associate_images_to_categories(
    175     array($_GET['image_id']),
    176     $_POST['cat_dissociated']
    177     );
    178 }
    179 // dissociate the element from categories (but not from its storage category)
    180 if (isset($_POST['dissociate'])
    181     and isset($_POST['cat_associated'])
    182     and count($_POST['cat_associated']) > 0
    183   )
    184 {
    185   $query = '
    186 DELETE FROM '.IMAGE_CATEGORY_TABLE.'
    187   WHERE image_id = '.$_GET['image_id'].'
    188     AND category_id IN ('.implode(',', $_POST['cat_associated']).')
    189 ';
    190   pwg_query($query);
    191 
    192   update_category($_POST['cat_associated']);
    193 }
    194 // elect the element to represent the given categories
    195 if (isset($_POST['elect'])
    196     and isset($_POST['cat_dismissed'])
    197     and count($_POST['cat_dismissed']) > 0
    198   )
    199 {
    200   $datas = array();
    201   foreach ($_POST['cat_dismissed'] as $category_id)
    202   {
    203     array_push($datas,
    204                array('id' => $category_id,
    205                      'representative_picture_id' => $_GET['image_id']));
    206   }
    207   $fields = array('primary' => array('id'),
    208                   'update' => array('representative_picture_id'));
    209   mass_updates(CATEGORIES_TABLE, $fields, $datas);
    210 }
    211 // dismiss the element as representant of the given categories
    212 if (isset($_POST['dismiss'])
    213     and isset($_POST['cat_elected'])
    214     and count($_POST['cat_elected']) > 0
    215   )
    216 {
    217   set_random_representant($_POST['cat_elected']);
    218201}
    219202
     
    263246  );
    264247
    265 $admin_url_start = get_root_url().'admin.php?page=picture_modify';
    266 $admin_url_start.= '&image_id='.$_GET['image_id'];
     248$admin_url_start = $admin_photo_base_url.'-properties';
    267249$admin_url_start.= isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : '';
    268250
     
    282264        stripslashes($_POST['name']) : @$row['name'],
    283265
     266    'TITLE' => render_element_name($row),
     267
    284268    'DIMENSIONS' => @$row['width'].' * '.@$row['height'],
    285269
     
    303287    )
    304288  );
     289
     290$added_by = 'N/A';
     291$query = '
     292SELECT '.$conf['user_fields']['username'].' AS username
     293  FROM '.USERS_TABLE.'
     294  WHERE '.$conf['user_fields']['id'].' = '.$row['added_by'].'
     295;';
     296$result = pwg_query($query);
     297while ($user_row = pwg_db_fetch_assoc($result))
     298{
     299  $added_by = $user_row['username'];
     300}
     301
     302$intro = sprintf(
     303  l10n('This photo was posted on %s by %s.'),
     304  format_date($row['date_available']),
     305  $added_by
     306  );
     307
     308$intro.= ' ';
     309
     310$intro.= sprintf(
     311  l10n('Original file is %s, %ux%u pixels, %.2fMB.'),
     312  $row['file'],
     313  $row['width'],
     314  $row['height'],
     315  $row['filesize']/1024
     316  );
     317
     318$intro.= ' ';
     319
     320$intro.= sprintf(
     321  l10n('%u visits'),
     322  $row['hit']
     323  );
     324
     325if ($conf['rate'] and !empty($row['rating_score']))
     326{
     327  $query = '
     328SELECT
     329    COUNT(*)
     330  FROM '.RATE_TABLE.'
     331  WHERE element_id = '.$_GET['image_id'].'
     332;';
     333  list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
     334 
     335  $intro.= sprintf(
     336    l10n(', %u rates, rating score %s'),
     337    $nb_rates,
     338    $row['rating_score']
     339    );
     340}
     341
     342$intro.= '. ';
     343
     344$intro.= sprintf(
     345  l10n('Numeric identifier is %u.'),
     346  $row['id']
     347  );
     348
     349$template->assign('INTRO', $intro);
    305350
    306351if (in_array(get_extension($row['path']),$conf['picture_ext']))
     
    433478}
    434479
    435 // associate to another category ?
     480// associate to albums
     481$query = '
     482SELECT id
     483  FROM '.CATEGORIES_TABLE.'
     484    INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = category_id
     485  WHERE image_id = '.$_GET['image_id'].'
     486;';
     487$associate_options_selected = array_from_query($query, 'id');
     488
    436489$query = '
    437490SELECT id,name,uppercats,global_rank
    438491  FROM '.CATEGORIES_TABLE.'
    439     INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = category_id
    440   WHERE image_id = '.$_GET['image_id'];
    441 if (isset($storage_category_id))
    442 {
    443   $query.= '
    444     AND id != '.$storage_category_id;
    445 }
    446 $query.= '
    447 ;';
    448 display_select_cat_wrapper($query, array(), 'associated_options');
    449 
    450 $result = pwg_query($query);
    451 $associateds = array(-1);
    452 if (isset($storage_category_id))
    453 {
    454   array_push($associateds, $storage_category_id);
    455 }
    456 while ($row = pwg_db_fetch_assoc($result))
    457 {
    458   array_push($associateds, $row['id']);
    459 }
    460 $query = '
    461 SELECT id,name,uppercats,global_rank
    462   FROM '.CATEGORIES_TABLE.'
    463   WHERE id NOT IN ('.implode(',', $associateds).')
    464 ;';
    465 display_select_cat_wrapper($query, array(), 'dissociated_options');
    466 
    467 // representing
    468 $query = '
    469 SELECT id,name,uppercats,global_rank
    470   FROM '.CATEGORIES_TABLE.'
    471   WHERE representative_picture_id = '.$_GET['image_id'].'
    472 ;';
    473 display_select_cat_wrapper($query, array(), 'elected_options');
    474 
    475 $query = '
    476 SELECT id,name,uppercats,global_rank
    477   FROM '.CATEGORIES_TABLE.'
    478   WHERE representative_picture_id != '.$_GET['image_id'].'
    479     OR representative_picture_id IS NULL
    480 ;';
    481 display_select_cat_wrapper($query, array(), 'dismissed_options');
     492;';
     493display_select_cat_wrapper($query, $associate_options_selected, 'associate_options');
     494display_select_cat_wrapper($query, $represent_options_selected, 'represent_options');
    482495
    483496//----------------------------------------------------------- sending html code
Note: See TracChangeset for help on using the changeset viewer.