Ignore:
Timestamp:
Feb 2, 2012, 12:03:35 AM (12 years ago)
Author:
plg
Message:

feature 2561: redesign on album administration screen.

  • only one form on the screen and several tabs
  • simpler URL pattern : page=album-123-properties / page=album-123-sort_order / page=album-123-permissions
  • action to associate all photos of an album to another (new) virtual album was removed. This can be easily done with the new Batch Manager
  • notification by email on an album still has to be moved on a new dedicated tab
  • action icons (jump to album, manage photos, manage sub-albums, delete album...) replaced by plain text links
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r12954 r13013  
    164164  }
    165165
    166   array_push($page['infos'], l10n('Album updated successfully'));
     166  // we redirect to hide/show the "permissions" tab if the category status
     167  // has changed
     168  $_SESSION['page_infos'] = array(l10n('Album updated successfully'));
     169  redirect($admin_album_base_url);
    167170}
    168171elseif (isset($_POST['set_random_representant']))
     
    179182  pwg_query($query);
    180183}
    181 elseif (isset($_POST['submitAdd']))
    182 {
    183   $output_create = create_virtual_category(
    184     $_POST['virtual_name'],
    185     (0 == $_POST['parent'] ? null : $_POST['parent'])
    186     );
    187 
    188   if (isset($output_create['error']))
    189   {
    190     array_push($page['errors'], $output_create['error']);
    191   }
    192   else
    193   {
    194     // Virtual album creation succeeded
    195     //
    196     // Add the information in the information list
    197     array_push($page['infos'], $output_create['info']);
    198 
    199     // Link the new category to the current category
    200     associate_categories_to_categories(
    201       array($_GET['cat_id']),
    202       array($output_create['id'])
    203       );
    204 
    205     // information
    206     array_push(
    207       $page['infos'],
    208       sprintf(
    209         l10n('Album photos associated to the following albums: %s'),
    210         '<ul><li>'
    211         .get_cat_display_name_from_id($output_create['id'])
    212         .'</li></ul>'
    213         )
    214       );
    215   }
    216 }
    217 elseif (isset($_POST['submitDestinations'])
    218          and isset($_POST['destinations'])
    219          and count($_POST['destinations']) > 0)
    220 {
    221   associate_categories_to_categories(
    222     array($_GET['cat_id']),
    223     $_POST['destinations']
    224     );
    225 
    226   $category_names = array();
    227   foreach ($_POST['destinations'] as $category_id)
    228   {
    229     array_push(
    230       $category_names,
    231       get_cat_display_name_from_id($category_id)
    232       );
    233   }
    234 
    235   array_push(
    236     $page['infos'],
    237     sprintf(
    238       l10n('Album photos associated to the following albums: %s'),
    239       '<ul><li>'.implode('</li><li>', $category_names).'</li></ul>'
    240       )
    241     );
    242 }
    243 
    244 $query = '
    245 SELECT *
    246   FROM '.CATEGORIES_TABLE.'
    247   WHERE id = '.$_GET['cat_id'].'
    248 ;';
    249 $category = pwg_db_fetch_assoc( pwg_query( $query ) );
     184
    250185// nullable fields
    251186foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
     
    269204$navigation = get_cat_display_name_cache(
    270205  $category['uppercats'],
    271   get_root_url().'admin.php?page=cat_modify&amp;cat_id='
     206  get_root_url().'admin.php?page=album-'
    272207  );
    273208
    274 $form_action = get_root_url().'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
     209$form_action = $admin_album_base_url.'-properties';
    275210
    276211//----------------------------------------------------- template initialization
    277 $template->set_filename( 'categories', 'cat_modify.tpl');
     212$template->set_filename( 'album_properties', 'cat_modify.tpl');
    278213
    279214$base_url = get_root_url().'admin.php?page=';
     
    304239      ),
    305240
    306     'MAIL_CONTENT' => empty($_POST['mail_content'])
    307         ? '' : stripslashes($_POST['mail_content']),
    308241    'U_CHILDREN' => $cat_list_url.'&amp;parent_id='.$category['id'],
    309242    'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_modify',
     
    318251}
    319252
    320 
    321 if ('private' == $category['status'])
    322 {
    323   $template->assign( 'U_MANAGE_PERMISSIONS',
    324       $base_url.'cat_perm&amp;cat='.$category['id']
    325     );
    326 }
    327 
    328253// manage album elements link
    329254if ($category['has_images'])
     
    333258    $base_url.'batch_manager&amp;cat='.$category['id']
    334259    );
    335 }
     260
     261  $query = '
     262SELECT
     263    COUNT(image_id),
     264    MIN(DATE(date_available)),
     265    MAX(DATE(date_available))
     266  FROM '.IMAGES_TABLE.'
     267    JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
     268  WHERE category_id = '.$category['id'].'
     269;';
     270  list($image_count, $min_date, $max_date) = pwg_db_fetch_row(pwg_query($query));
     271
     272  if ($min_date == $max_date)
     273  {
     274    $intro = sprintf(
     275      l10n('This album contains %d photos, added on %s.'),
     276      $image_count,
     277      format_date($min_date)
     278      );
     279  }
     280  else
     281  {
     282    $intro = sprintf(
     283      l10n('This album contains %d photos, added between %s and %s.'),
     284      $image_count,
     285      format_date($min_date),
     286      format_date($max_date)
     287      );
     288  }
     289}
     290else
     291{
     292  $intro = l10n('This album contains no photo.');
     293}
     294
     295$template->assign('INTRO', $intro);
    336296
    337297$template->assign(
     
    353313  $template->assign(
    354314    array(
    355       'CAT_FULL_DIR'       => preg_replace('/\/$/',
    356                                     '',
    357                                     $category['cat_full_dir'] )
     315      'CAT_FULL_DIR' => preg_replace('/\/$/', '', $category['cat_full_dir'])
    358316      )
    359317    );
     
    431389}
    432390
    433 
    434 // create virtual in parent and link
    435 $query = '
    436 SELECT id,name,uppercats,global_rank
    437   FROM '.CATEGORIES_TABLE.'
    438 ;';
    439 display_select_cat_wrapper(
    440   $query,
    441   array(),
    442   'create_new_parent_options'
    443   );
    444 
    445 
    446 // destination categories
    447 $query = '
    448 SELECT id,name,uppercats,global_rank
    449   FROM '.CATEGORIES_TABLE.'
    450   WHERE id != '.$category['id'].'
    451 ;';
    452 display_select_cat_wrapper(
    453   $query,
    454   array(),
    455   'category_destination_options'
    456   );
    457 
    458 // info by email to an access granted group of category informations
    459 if (isset($_POST['submitEmail']) and !empty($_POST['group']))
    460 {
    461   set_make_full_url();
    462 
    463   /* TODO: if $category['representative_picture_id']
    464     is empty find child representative_picture_id */
    465   if (!empty($category['representative_picture_id']))
    466   {
    467     $query = '
    468 SELECT id, file, path, representative_ext
    469   FROM '.IMAGES_TABLE.'
    470   WHERE id = '.$category['representative_picture_id'].'
    471 ;';
    472 
    473     $result = pwg_query($query);
    474     if (pwg_db_num_rows($result) > 0)
    475     {
    476       $element = pwg_db_fetch_assoc($result);
    477 
    478       $img_url  = '<a href="'.
    479                       make_picture_url(array(
    480                           'image_id' => $element['id'],
    481                           'image_file' => $element['file'],
    482                           'category' => $category
    483                         ))
    484                       .'" class="thumblnk"><img src="'.DerivativeImage::thumb_url($element).'"></a>';
    485     }
    486   }
    487 
    488   if (!isset($img_url))
    489   {
    490     $img_url = '';
    491   }
    492 
    493   // TODO Mettre un array pour traduction subjet
    494   pwg_mail_group(
    495     $_POST['group'],
    496     get_str_email_format(true), /* TODO add a checkbox in order to choose format*/
    497     get_l10n_args('[%s] Visit album %s',
    498       array($conf['gallery_title'], $category['name'])),
    499     'cat_group_info',
    500     array
    501     (
    502       'IMG_URL' => $img_url,
    503       'CAT_NAME' => $category['name'],
    504       'LINK' => make_index_url(
    505           array(
    506             'category' => array(
    507               'id' => $category['id'],
    508               'name' => $category['name'],
    509               'permalink' => $category['permalink']
    510               ))),
    511       'CPL_CONTENT' => empty($_POST['mail_content'])
    512                           ? '' : stripslashes($_POST['mail_content'])
    513     ),
    514     '' /* TODO Add listbox in order to choose Language selected */);
    515 
    516   unset_make_full_url();
    517 
    518   $query = '
    519 SELECT
    520     name
    521   FROM '.GROUPS_TABLE.'
    522   WHERE id = '.$_POST['group'].'
    523 ;';
    524   list($group_name) = pwg_db_fetch_row(pwg_query($query));
    525 
    526   array_push(
    527     $page['infos'],
    528     sprintf(
    529       l10n('An information email was sent to group "%s"'),
    530       $group_name
    531       )
    532     );
    533 }
    534 
    535 if ('private' == $category['status'])
    536 {
    537   $query = '
    538 SELECT
    539     group_id
    540   FROM '.GROUP_ACCESS_TABLE.'
    541   WHERE cat_id = '.$category['id'].'
    542 ;';
    543 }
    544 else
    545 {
    546   $query = '
    547 SELECT
    548     id AS group_id
    549   FROM '.GROUPS_TABLE.'
    550 ;';
    551 }
    552 $group_ids = array_from_query($query, 'group_id');
    553 
    554 if (count($group_ids) > 0)
    555 {
    556   $query = '
    557 SELECT
    558     id,
    559     name
    560   FROM '.GROUPS_TABLE.'
    561   WHERE id IN ('.implode(',', $group_ids).')
    562   ORDER BY name ASC
    563 ;';
    564   $template->assign('group_mail_options',
    565       simple_hash_from_query($query, 'id', 'name')
    566     );
    567 }
    568 
    569391trigger_action('loc_end_cat_modify');
    570392
    571393//----------------------------------------------------------- sending html code
    572 $template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
     394$template->assign_var_from_handle('ADMIN_CONTENT', 'album_properties');
    573395?>
Note: See TracChangeset for help on using the changeset viewer.