feature 2969: Unified Batch Manager URL
git-svn-id: http://piwigo.org/svn/trunk@24834 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
92d692a334
commit
cfdfeb989d
7 changed files with 88 additions and 68 deletions
|
|
@ -189,7 +189,7 @@ $template->assign(
|
|||
'U_CAT_OPTIONS'=> $link_start.'cat_options',
|
||||
'U_CAT_UPDATE'=> $link_start.'site_update&site=1',
|
||||
'U_RATING'=> $link_start.'rating',
|
||||
'U_RECENT_SET'=> $link_start.'batch_manager&cat=recent',
|
||||
'U_RECENT_SET'=> $link_start.'batch_manager&filter=prefilter-last_import',
|
||||
'U_BATCH'=> $link_start.'batch_manager',
|
||||
'U_TAGS'=> $link_start.'tags',
|
||||
'U_USERS'=> $link_start.'user_list',
|
||||
|
|
@ -222,7 +222,7 @@ if ($nb_photos_in_caddie > 0)
|
|||
$template->assign(
|
||||
array(
|
||||
'NB_PHOTOS_IN_CADDIE' => $nb_photos_in_caddie,
|
||||
'U_CADDIE' => $link_start.'batch_manager&cat=caddie',
|
||||
'U_CADDIE' => $link_start.'batch_manager&filter=prefilter-caddie',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,12 @@ check_status(ACCESS_ADMINISTRATOR);
|
|||
|
||||
check_input_parameter('selection', $_POST, true, PATTERN_ID);
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | initialize current set |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// filters from form
|
||||
if (isset($_POST['submitFilter']))
|
||||
{
|
||||
// echo '<pre>'; print_r($_POST); echo '</pre>';
|
||||
|
|
@ -109,39 +111,52 @@ if (isset($_POST['submitFilter']))
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (isset($_GET['cat']))
|
||||
// filters from url
|
||||
else if (isset($_GET['filter']))
|
||||
{
|
||||
if ('caddie' == $_GET['cat'])
|
||||
if (!is_array($_GET['filter']))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter'] = array(
|
||||
'prefilter' => 'caddie'
|
||||
);
|
||||
$_GET['filter'] = explode(',', $_GET['filter']);
|
||||
}
|
||||
else if ('recent' == $_GET['cat'])
|
||||
|
||||
$_SESSION['bulk_manager_filter'] = array();
|
||||
|
||||
foreach ($_GET['filter'] as $filter)
|
||||
{
|
||||
$_SESSION['bulk_manager_filter'] = array(
|
||||
'prefilter' => 'last import'
|
||||
);
|
||||
list($type, $value) = explode('-', $filter);
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'prefilter':
|
||||
$_SESSION['bulk_manager_filter']['prefilter'] = $value;
|
||||
break;
|
||||
|
||||
case 'album':
|
||||
if (is_numeric($value))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter']['category'] = $value;
|
||||
}
|
||||
else if (is_numeric($_GET['cat']))
|
||||
break;
|
||||
|
||||
case 'tag':
|
||||
if (is_numeric($value))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter'] = array(
|
||||
'category' => $_GET['cat']
|
||||
);
|
||||
$_SESSION['bulk_manager_filter']['tags'] = array($value);
|
||||
$_SESSION['bulk_manager_filter']['tag_mode'] = 'AND';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'level':
|
||||
if (is_numeric($value) && in_array($value, $conf['available_permission_levels']))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter']['level'] = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (isset($_GET['tag']))
|
||||
{
|
||||
if (is_numeric($_GET['tag']))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter'] = array(
|
||||
'tags' => array($_GET['tag']),
|
||||
'tag_mode' => 'AND',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['bulk_manager_filter']))
|
||||
if (empty($_SESSION['bulk_manager_filter']))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter'] = array(
|
||||
'prefilter' => 'caddie'
|
||||
|
|
@ -150,13 +165,13 @@ if (!isset($_SESSION['bulk_manager_filter']))
|
|||
|
||||
// echo '<pre>'; print_r($_SESSION['bulk_manager_filter']); echo '</pre>';
|
||||
|
||||
// depending on the current filter (in session), we find the appropriate
|
||||
// photos
|
||||
// depending on the current filter (in session), we find the appropriate photos
|
||||
$filter_sets = array();
|
||||
if (isset($_SESSION['bulk_manager_filter']['prefilter']))
|
||||
{
|
||||
if ('caddie' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
switch ($_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
case 'caddie':
|
||||
$query = '
|
||||
SELECT element_id
|
||||
FROM '.CADDIE_TABLE.'
|
||||
|
|
@ -166,10 +181,10 @@ SELECT element_id
|
|||
$filter_sets,
|
||||
array_from_query($query, 'element_id')
|
||||
);
|
||||
}
|
||||
|
||||
if ('favorites' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
break;
|
||||
|
||||
case 'favorites':
|
||||
$query = '
|
||||
SELECT image_id
|
||||
FROM '.FAVORITES_TABLE.'
|
||||
|
|
@ -179,10 +194,10 @@ SELECT image_id
|
|||
$filter_sets,
|
||||
array_from_query($query, 'image_id')
|
||||
);
|
||||
}
|
||||
|
||||
if ('last import'== $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
break;
|
||||
|
||||
case 'last_import':
|
||||
$query = '
|
||||
SELECT MAX(date_available) AS date
|
||||
FROM '.IMAGES_TABLE.'
|
||||
|
|
@ -200,10 +215,10 @@ SELECT id
|
|||
array_from_query($query, 'id')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ('with no virtual album' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
break;
|
||||
|
||||
case 'no_virtual_album':
|
||||
// we are searching elements not linked to any virtual category
|
||||
$query = '
|
||||
SELECT id
|
||||
|
|
@ -231,10 +246,10 @@ SELECT id
|
|||
$filter_sets,
|
||||
array_diff($all_elements, $linked_to_virtual)
|
||||
);
|
||||
}
|
||||
|
||||
if ('with no album' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
break;
|
||||
|
||||
case 'no_album':
|
||||
$query = '
|
||||
SELECT
|
||||
id
|
||||
|
|
@ -246,10 +261,10 @@ SELECT
|
|||
$filter_sets,
|
||||
array_from_query($query, 'id')
|
||||
);
|
||||
}
|
||||
|
||||
if ('with no tag' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
break;
|
||||
|
||||
case 'no_tag':
|
||||
$query = '
|
||||
SELECT
|
||||
id
|
||||
|
|
@ -261,15 +276,14 @@ SELECT
|
|||
$filter_sets,
|
||||
array_from_query($query, 'id')
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
if ('duplicates' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
case 'duplicates':
|
||||
// we could use the group_concat MySQL function to retrieve the list of
|
||||
// image_ids but it would not be compatible with PostgreSQL, so let's
|
||||
// perform 2 queries instead. We hope there are not too many duplicates.
|
||||
|
||||
$query = '
|
||||
SELECT file
|
||||
FROM '.IMAGES_TABLE.'
|
||||
|
|
@ -288,16 +302,18 @@ SELECT id
|
|||
$filter_sets,
|
||||
array_from_query($query, 'id')
|
||||
);
|
||||
}
|
||||
|
||||
if ('all photos' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||
{
|
||||
break;
|
||||
|
||||
case 'all_photos':
|
||||
$query = '
|
||||
SELECT id
|
||||
FROM '.IMAGES_TABLE.'
|
||||
'.$conf['order_by'];
|
||||
|
||||
$filter_sets[] = array_from_query($query, 'id');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$filter_sets = trigger_event('perform_batch_manager_prefilters', $filter_sets, $_SESSION['bulk_manager_filter']['prefilter']);
|
||||
|
|
@ -403,6 +419,7 @@ foreach ($filter_sets as $set)
|
|||
}
|
||||
$page['cat_elements_id'] = $current_set;
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | first element to display |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
@ -423,6 +440,7 @@ else
|
|||
$page['start'] = $_REQUEST['start'];
|
||||
}
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Tabs |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
@ -442,6 +460,7 @@ $tabsheet->set_id('batch_manager');
|
|||
$tabsheet->select($page['tab']);
|
||||
$tabsheet->assign();
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | tags |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
@ -452,6 +471,7 @@ SELECT id, name
|
|||
;';
|
||||
$template->assign('tags', get_taglist($query, false));
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | dimensions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ DELETE
|
|||
$tag_ids = get_tag_ids($_POST['add_tags']);
|
||||
add_tags($tag_ids, $collection);
|
||||
|
||||
if ('with no tag' == $page['prefilter'])
|
||||
if ('no_tag' == $page['prefilter'])
|
||||
{
|
||||
redirect($redirect_url);
|
||||
}
|
||||
|
|
@ -149,12 +149,12 @@ DELETE
|
|||
);
|
||||
|
||||
// let's refresh the page because we the current set might be modified
|
||||
if ('with no album' == $page['prefilter'])
|
||||
if ('no_album' == $page['prefilter'])
|
||||
{
|
||||
redirect($redirect_url);
|
||||
}
|
||||
|
||||
if ('with no virtual album' == $page['prefilter'])
|
||||
if ('no_virtual_album' == $page['prefilter'])
|
||||
{
|
||||
$category_info = get_cat_info($_POST['associate']);
|
||||
if (empty($category_info['dir']))
|
||||
|
|
@ -173,12 +173,12 @@ DELETE
|
|||
);
|
||||
|
||||
// let's refresh the page because we the current set might be modified
|
||||
if ('with no album' == $page['prefilter'])
|
||||
if ('no_album' == $page['prefilter'])
|
||||
{
|
||||
redirect($redirect_url);
|
||||
}
|
||||
|
||||
if ('with no virtual album' == $page['prefilter'])
|
||||
if ('no_virtual_album' == $page['prefilter'])
|
||||
{
|
||||
$category_info = get_cat_info($_POST['move']);
|
||||
if (empty($category_info['dir']))
|
||||
|
|
@ -435,17 +435,17 @@ $base_url = get_root_url().'admin.php';
|
|||
$prefilters = array(
|
||||
array('ID' => 'caddie', 'NAME' => l10n('Caddie')),
|
||||
array('ID' => 'favorites', 'NAME' => l10n('Your favorites')),
|
||||
array('ID' => 'last import', 'NAME' => l10n('Last import')),
|
||||
array('ID' => 'with no album', 'NAME' => l10n('With no album')),
|
||||
array('ID' => 'with no tag', 'NAME' => l10n('With no tag')),
|
||||
array('ID' => 'last_import', 'NAME' => l10n('Last import')),
|
||||
array('ID' => 'no_album', 'NAME' => l10n('With no album')),
|
||||
array('ID' => 'no_tag', 'NAME' => l10n('With no tag')),
|
||||
array('ID' => 'duplicates', 'NAME' => l10n('Duplicates')),
|
||||
array('ID' => 'all photos', 'NAME' => l10n('All'))
|
||||
array('ID' => 'all_photos', 'NAME' => l10n('All'))
|
||||
);
|
||||
|
||||
if ($conf['enable_synchronization'])
|
||||
{
|
||||
array_push($prefilters,
|
||||
array('ID' => 'with no virtual album', 'NAME' => l10n('With no virtual album'))
|
||||
array('ID' => 'no_virtual_album', 'NAME' => l10n('With no virtual album'))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ $template->assign(
|
|||
'all_elements' => $page['cat_elements_id'],
|
||||
'START' => $page['start'],
|
||||
'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')),
|
||||
'F_ACTION'=>$base_url.get_query_string_diff(array('cat','start','tag')),
|
||||
'F_ACTION'=>$base_url.get_query_string_diff(array('cat','start','tag','filter')),
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ foreach ($categories as $category)
|
|||
if ( array_key_exists($category['id'], $categories_with_images) )
|
||||
{
|
||||
$tpl_cat['U_MANAGE_ELEMENTS']=
|
||||
$base_url.'batch_manager&cat='.$category['id'];
|
||||
$base_url.'batch_manager&filter=album-'.$category['id'];
|
||||
}
|
||||
|
||||
$template->append('categories', $tpl_cat);
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ if ($category['has_images'])
|
|||
{
|
||||
$template->assign(
|
||||
'U_MANAGE_ELEMENTS',
|
||||
$base_url.'batch_manager&cat='.$category['id']
|
||||
$base_url.'batch_manager&filter=album-'.$category['id']
|
||||
);
|
||||
|
||||
$query = '
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ DELETE FROM '.CADDIE_TABLE.'
|
|||
$inserts
|
||||
);
|
||||
|
||||
redirect(get_root_url().'admin.php?page=batch_manager&cat=caddie');
|
||||
redirect(get_root_url().'admin.php?page=batch_manager&filter=prefilter-caddie');
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ while ($tag = pwg_db_fetch_assoc($result))
|
|||
$tag['name'] = trigger_event('render_tag_name', $raw_name);
|
||||
$tag['counter'] = intval(@$tag_counters[ $tag['id'] ]);
|
||||
$tag['U_VIEW'] = make_index_url(array('tags'=>array($tag)));
|
||||
$tag['U_EDIT'] = 'admin.php?page=batch_manager&tag='.$tag['id'];
|
||||
$tag['U_EDIT'] = 'admin.php?page=batch_manager&filter=tag-'.$tag['id'];
|
||||
|
||||
$alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
|
||||
$alt_names = array_diff( array_unique($alt_names), array($tag['name']) );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue