Ignore:
Timestamp:
10/09/12 06:58:57 (7 years ago)
Author:
rvelices
Message:

batch manager - remove unused code, less sql queries and avoid 4 calls to same display_select function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r18459 r18573  
    7575} 
    7676 
    77 // $page['category'] is a shortcut to test if the current filter contains a 
    78 // given category. The idea is the same as for prefilter 
    79 $page['category'] = -1; 
    80 if (isset($_SESSION['bulk_manager_filter']['category'])) 
    81 { 
    82   $page['category'] = $_SESSION['bulk_manager_filter']['category']; 
    83 } 
    84  
    8577$redirect_url = get_root_url().'admin.php?page='.$_GET['page']; 
    8678 
     
    10698    pwg_query($query); 
    10799 
    108     if ('caddie' == $page['prefilter']) 
    109     { 
    110       redirect($redirect_url); 
    111     } 
    112      
    113     // if we are here in the code, it means that the user is currently 
    114     // displaying the caddie content, so we have to remove the current 
    115     // selection from the current set 
    116     $page['cat_elements_id'] = array_diff($page['cat_elements_id'], $collection); 
     100    // remove from caddie action available only in caddie so reload content 
     101    redirect($redirect_url); 
    117102  } 
    118103 
     
    130115      if ('with no tag' == $page['prefilter']) 
    131116      { 
    132         redirect(get_root_url().'admin.php?page='.$_GET['page']); 
     117        redirect($redirect_url); 
    133118      } 
    134119    } 
     
    446431$base_url = get_root_url().'admin.php'; 
    447432 
    448 $prefilters = array(); 
    449  
    450 array_push($prefilters, 
     433$prefilters = array( 
    451434  array('ID' => 'caddie', 'NAME' => l10n('Caddie')), 
    452435  array('ID' => 'last import', 'NAME' => l10n('Last import')), 
     
    482465// |                            caddie options                             | 
    483466// +-----------------------------------------------------------------------+ 
    484  
    485 $in_caddie = false; 
    486 if (isset($_SESSION['bulk_manager_filter']['prefilter']) 
    487     and 'caddie' == $_SESSION['bulk_manager_filter']['prefilter']) 
    488 { 
    489   $in_caddie = true; 
    490 } 
    491 $template->assign('IN_CADDIE', $in_caddie); 
    492  
    493 // +-----------------------------------------------------------------------+ 
    494 // |                            deletion form                              | 
    495 // +-----------------------------------------------------------------------+ 
    496  
    497 // we can only remove photos that have no storage_category_id, in other 
    498 // word, it currently (Butterfly) means that the photo was added with 
    499 // pLoader 
    500 if (count($page['cat_elements_id']) > 0) 
    501 { 
    502   $query = ' 
    503 SELECT 
    504     id 
    505   FROM '.IMAGES_TABLE.' 
    506   WHERE id IN ('.implode(',', $page['cat_elements_id']).') 
    507     AND file NOT LIKE \'http%\' 
    508   LIMIT 1 
    509 ;'; 
    510   ; 
    511  
    512   if ( pwg_db_fetch_row(pwg_query($query)) ) 
    513   { 
    514     $template->assign('show_delete_form', true); 
    515   } 
    516 } 
     467$template->assign('IN_CADDIE', 'caddie' == $page['prefilter']); 
     468 
    517469 
    518470// +-----------------------------------------------------------------------+ 
     
    557509  FROM '.CATEGORIES_TABLE.' 
    558510;'; 
    559 display_select_cat_wrapper($query, array(), 'associate_options', true); 
    560 display_select_cat_wrapper($query, array(), 'move_options', true); 
     511$categories = array_from_query($query); 
     512usort($categories, 'global_rank_compare'); 
     513display_select_categories($categories, array(), 'category_full_name_options', true); 
     514 
    561515display_select_cat_wrapper($query, array(), 'category_parent_options'); 
    562516 
     
    571525{ 
    572526  // we need to know the category in which the last photo was added 
    573   $selected_category = array(); 
    574  
    575527  $query = ' 
    576528SELECT 
     
    587539  { 
    588540    $row = pwg_db_fetch_assoc($result); 
    589    
    590541    $selected_category = array($row['category_id']); 
    591542  } 
    592543} 
    593544 
    594 $query = ' 
    595 SELECT id,name,uppercats,global_rank 
    596   FROM '.CATEGORIES_TABLE.' 
    597 ;'; 
    598 display_select_cat_wrapper($query, $selected_category, 'filter_category_options', true); 
     545$template->assign( 'filter_category_selected', $selected_category); 
    599546 
    600547// Dissociate from a category : categories listed for dissociation can only 
Note: See TracChangeset for help on using the changeset viewer.