Changeset 18573 for trunk/admin


Ignore:
Timestamp:
Oct 9, 2012, 6:58:57 AM (11 years ago)
Author:
rvelices
Message:

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

Location:
trunk/admin
Files:
2 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
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r18484 r18573  
    1616    var inputs = [];
    1717    var count=0;
    18     var This=$(this);
    1918    this.find('input[type=checkbox]').each(function() {
    2019      var pos=count;
     
    523522        {'Album'|@translate}
    524523        <select style="width:400px" name="filter_category" size="1">
    525           {html_options options=$filter_category_options selected=$filter_category_options_selected}
     524          {html_options options=$category_full_name_options selected=$filter_category_selected}
    526525        </select>
    527526        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
     
    676675      <option value="-1">{'Choose an action'|@translate}</option>
    677676      <option disabled="disabled">------------------</option>
    678   {if isset($show_delete_form) }
    679677      <option value="delete">{'Delete selected photos'|@translate}</option>
    680   {/if}
    681678      <option value="associate">{'Associate to album'|@translate}</option>
    682679      <option value="move">{'Move to album'|@translate}</option>
     
    715712    <div id="action_associate" class="bulkAction">
    716713          <select style="width:400px" name="associate" size="1">
    717             {html_options options=$associate_options }
     714            {html_options options=$category_full_name_options}
    718715         </select>
    719716<br>{'... or '|@translate} <a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
     
    723720    <div id="action_move" class="bulkAction">
    724721          <select style="width:400px" name="move" size="1">
    725             {html_options options=$move_options }
     722            {html_options options=$category_full_name_options}
    726723         </select>
    727724<br>{'... or '|@translate} <a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
Note: See TracChangeset for help on using the changeset viewer.