Changeset 24834 for trunk/admin


Ignore:
Timestamp:
Oct 10, 2013, 1:07:45 PM (10 years ago)
Author:
mistic100
Message:

feature 2969: Unified Batch Manager URL

Location:
trunk/admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r23746 r24834  
    4444check_input_parameter('selection', $_POST, true, PATTERN_ID);
    4545
     46
    4647// +-----------------------------------------------------------------------+
    4748// |                      initialize current set                           |
    4849// +-----------------------------------------------------------------------+
    4950
     51// filters from form
    5052if (isset($_POST['submitFilter']))
    5153{
     
    110112  }
    111113}
    112 else if (isset($_GET['cat']))
    113 {
    114   if ('caddie' == $_GET['cat'])
    115   {
    116     $_SESSION['bulk_manager_filter'] = array(
    117       'prefilter' => 'caddie'
    118       );
    119   }
    120   else if ('recent' == $_GET['cat'])
    121   {
    122     $_SESSION['bulk_manager_filter'] = array(
    123       'prefilter' => 'last import'
    124       );
    125   }
    126   else if (is_numeric($_GET['cat']))
    127   {
    128     $_SESSION['bulk_manager_filter'] = array(
    129       'category' => $_GET['cat']
    130       );
    131   }
    132 }
    133 else if (isset($_GET['tag']))
    134 {
    135   if (is_numeric($_GET['tag']))
    136   {
    137     $_SESSION['bulk_manager_filter'] = array(
    138       'tags' => array($_GET['tag']),
    139       'tag_mode' => 'AND',
    140       );
    141   }
    142 }
    143 
    144 if (!isset($_SESSION['bulk_manager_filter']))
     114// filters from url
     115else if (isset($_GET['filter']))
     116{
     117  if (!is_array($_GET['filter']))
     118  {
     119    $_GET['filter'] = explode(',', $_GET['filter']);
     120  }
     121 
     122  $_SESSION['bulk_manager_filter'] = array();
     123 
     124  foreach ($_GET['filter'] as $filter)
     125  {
     126    list($type, $value) = explode('-', $filter);
     127   
     128    switch ($type)
     129    {
     130    case 'prefilter':
     131      $_SESSION['bulk_manager_filter']['prefilter'] = $value;
     132      break;
     133   
     134    case 'album':
     135      if (is_numeric($value))
     136      {
     137        $_SESSION['bulk_manager_filter']['category'] = $value;
     138      }
     139      break;
     140     
     141    case 'tag':
     142      if (is_numeric($value))
     143      {
     144        $_SESSION['bulk_manager_filter']['tags'] = array($value);
     145        $_SESSION['bulk_manager_filter']['tag_mode'] = 'AND';
     146      }
     147      break;
     148     
     149    case 'level':
     150      if (is_numeric($value) && in_array($value, $conf['available_permission_levels']))
     151      {
     152        $_SESSION['bulk_manager_filter']['level'] = $value;
     153      }
     154      break;
     155    }
     156  }
     157}
     158
     159if (empty($_SESSION['bulk_manager_filter']))
    145160{
    146161  $_SESSION['bulk_manager_filter'] = array(
     
    151166// echo '<pre>'; print_r($_SESSION['bulk_manager_filter']); echo '</pre>';
    152167
    153 // depending on the current filter (in session), we find the appropriate
    154 // photos
     168// depending on the current filter (in session), we find the appropriate photos
    155169$filter_sets = array();
    156170if (isset($_SESSION['bulk_manager_filter']['prefilter']))
    157171{
    158   if ('caddie' == $_SESSION['bulk_manager_filter']['prefilter'])
    159   {
     172  switch ($_SESSION['bulk_manager_filter']['prefilter'])
     173  {
     174  case 'caddie':
    160175    $query = '
    161176SELECT element_id
     
    167182      array_from_query($query, 'element_id')
    168183      );
    169   }
    170 
    171   if ('favorites' == $_SESSION['bulk_manager_filter']['prefilter'])
    172   {
     184   
     185    break;
     186
     187  case 'favorites':
    173188    $query = '
    174189SELECT image_id
     
    180195      array_from_query($query, 'image_id')
    181196      );
    182   }
    183 
    184   if ('last import'== $_SESSION['bulk_manager_filter']['prefilter'])
    185   {
     197   
     198    break;
     199
     200  case 'last_import':
    186201    $query = '
    187202SELECT MAX(date_available) AS date
     
    201216        );
    202217    }
    203   }
    204 
    205   if ('with no virtual album' == $_SESSION['bulk_manager_filter']['prefilter'])
    206   {
     218   
     219    break;
     220
     221  case 'no_virtual_album':
    207222    // we are searching elements not linked to any virtual category
    208223    $query = '
     
    232247      array_diff($all_elements, $linked_to_virtual)
    233248      );
    234   }
    235 
    236   if ('with no album' == $_SESSION['bulk_manager_filter']['prefilter'])
    237   {
     249   
     250    break;
     251
     252  case 'no_album':
    238253    $query = '
    239254SELECT
     
    247262      array_from_query($query, 'id')
    248263      );
    249   }
    250 
    251   if ('with no tag' == $_SESSION['bulk_manager_filter']['prefilter'])
    252   {
     264   
     265    break;
     266
     267  case 'no_tag':
    253268    $query = '
    254269SELECT
     
    262277      array_from_query($query, 'id')
    263278      );
    264   }
    265 
    266 
    267   if ('duplicates' == $_SESSION['bulk_manager_filter']['prefilter'])
    268   {
     279   
     280    break;
     281
     282
     283  case 'duplicates':
    269284    // we could use the group_concat MySQL function to retrieve the list of
    270285    // image_ids but it would not be compatible with PostgreSQL, so let's
    271286    // perform 2 queries instead. We hope there are not too many duplicates.
    272 
    273287    $query = '
    274288SELECT file
     
    289303      array_from_query($query, 'id')
    290304      );
    291   }
    292 
    293   if ('all photos' == $_SESSION['bulk_manager_filter']['prefilter'])
    294   {
     305   
     306    break;
     307
     308  case 'all_photos':
    295309    $query = '
    296310SELECT id
     
    299313
    300314    $filter_sets[] = array_from_query($query, 'id');
     315   
     316    break;
    301317  }
    302318
     
    404420$page['cat_elements_id'] = $current_set;
    405421
     422
    406423// +-----------------------------------------------------------------------+
    407424// |                       first element to display                        |
     
    424441}
    425442
     443
    426444// +-----------------------------------------------------------------------+
    427445// |                                 Tabs                                  |
     
    443461$tabsheet->assign();
    444462
     463
    445464// +-----------------------------------------------------------------------+
    446465// |                              tags                                     |
     
    452471;';
    453472$template->assign('tags', get_taglist($query, false));
     473
    454474
    455475// +-----------------------------------------------------------------------+
  • trunk/admin/batch_manager_global.php

    r24526 r24834  
    113113      add_tags($tag_ids, $collection);
    114114
    115       if ('with no tag' == $page['prefilter'])
     115      if ('no_tag' == $page['prefilter'])
    116116      {
    117117        redirect($redirect_url);
     
    150150   
    151151    // let's refresh the page because we the current set might be modified
    152     if ('with no album' == $page['prefilter'])
     152    if ('no_album' == $page['prefilter'])
    153153    {
    154154      redirect($redirect_url);
    155155    }
    156156
    157     if ('with no virtual album' == $page['prefilter'])
     157    if ('no_virtual_album' == $page['prefilter'])
    158158    {
    159159      $category_info = get_cat_info($_POST['associate']);
     
    174174   
    175175    // let's refresh the page because we the current set might be modified
    176     if ('with no album' == $page['prefilter'])
     176    if ('no_album' == $page['prefilter'])
    177177    {
    178178      redirect($redirect_url);
    179179    }
    180180
    181     if ('with no virtual album' == $page['prefilter'])
     181    if ('no_virtual_album' == $page['prefilter'])
    182182    {
    183183      $category_info = get_cat_info($_POST['move']);
     
    436436  array('ID' => 'caddie', 'NAME' => l10n('Caddie')),
    437437  array('ID' => 'favorites', 'NAME' => l10n('Your favorites')),
    438   array('ID' => 'last import', 'NAME' => l10n('Last import')),
    439   array('ID' => 'with no album', 'NAME' => l10n('With no album')),
    440   array('ID' => 'with no tag', 'NAME' => l10n('With no tag')),
     438  array('ID' => 'last_import', 'NAME' => l10n('Last import')),
     439  array('ID' => 'no_album', 'NAME' => l10n('With no album')),
     440  array('ID' => 'no_tag', 'NAME' => l10n('With no tag')),
    441441  array('ID' => 'duplicates', 'NAME' => l10n('Duplicates')),
    442   array('ID' => 'all photos', 'NAME' => l10n('All'))
     442  array('ID' => 'all_photos', 'NAME' => l10n('All'))
    443443);
    444444
     
    446446{
    447447  array_push($prefilters,
    448     array('ID' => 'with no virtual album', 'NAME' => l10n('With no virtual album'))
     448    array('ID' => 'no_virtual_album', 'NAME' => l10n('With no virtual album'))
    449449  );
    450450}
     
    461461    'START' => $page['start'],
    462462    'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')),
    463     'F_ACTION'=>$base_url.get_query_string_diff(array('cat','start','tag')),
     463    'F_ACTION'=>$base_url.get_query_string_diff(array('cat','start','tag','filter')),
    464464   )
    465465 );
  • trunk/admin/cat_list.php

    r19703 r24834  
    323323  {
    324324    $tpl_cat['U_MANAGE_ELEMENTS']=
    325       $base_url.'batch_manager&amp;cat='.$category['id'];
     325      $base_url.'batch_manager&amp;filter=album-'.$category['id'];
    326326  }
    327327
  • trunk/admin/cat_modify.php

    r19703 r24834  
    253253  $template->assign(
    254254    'U_MANAGE_ELEMENTS',
    255     $base_url.'batch_manager&amp;cat='.$category['id']
     255    $base_url.'batch_manager&amp;filter=album-'.$category['id']
    256256    );
    257257
  • trunk/admin/photos_add_direct.php

    r19703 r24834  
    5858    );
    5959
    60   redirect(get_root_url().'admin.php?page=batch_manager&cat=caddie');
     60  redirect(get_root_url().'admin.php?page=batch_manager&filter=prefilter-caddie');
    6161}
    6262
  • trunk/admin/tags.php

    r19703 r24834  
    462462  $tag['counter'] = intval(@$tag_counters[ $tag['id'] ]);
    463463  $tag['U_VIEW'] = make_index_url(array('tags'=>array($tag)));
    464   $tag['U_EDIT'] = 'admin.php?page=batch_manager&amp;tag='.$tag['id'];
     464  $tag['U_EDIT'] = 'admin.php?page=batch_manager&amp;filter=tag-'.$tag['id'];
    465465
    466466  $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
Note: See TracChangeset for help on using the changeset viewer.