From 1f3f5ff73f505cbc6041ae213398d240f61d5a60 Mon Sep 17 00:00:00 2001 From: rvelices Date: Sat, 5 Apr 2014 19:24:27 +0000 Subject: bug 3069: add quick search as filter in batch manager git-svn-id: http://piwigo.org/svn/trunk@28087 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/batch_manager.php | 50 ++++++++++++++-------- admin/batch_manager_global.php | 24 +++++------ .../default/template/batch_manager_global.tpl | 10 +++++ 3 files changed, 53 insertions(+), 31 deletions(-) (limited to 'admin') diff --git a/admin/batch_manager.php b/admin/batch_manager.php index 2cb76f7e1..359e5603a 100644 --- a/admin/batch_manager.php +++ b/admin/batch_manager.php @@ -85,14 +85,14 @@ if (isset($_POST['submitFilter'])) if (in_array($_POST['filter_level'], $conf['available_permission_levels'])) { $_SESSION['bulk_manager_filter']['level'] = $_POST['filter_level']; - + if (isset($_POST['filter_level_include_lower'])) { $_SESSION['bulk_manager_filter']['level_include_lower'] = true; } } } - + if (isset($_POST['filter_dimension_use'])) { foreach (array('min_width','max_width','min_height','max_height') as $type) @@ -110,34 +110,39 @@ if (isset($_POST['submitFilter'])) } } } + + if (isset($_POST['filter_search_use'])) + { + $_SESSION['bulk_manager_filter']['search']['q'] = $_POST['q']; + } } // filters from url -else if (isset($_GET['filter'])) +elseif (isset($_GET['filter'])) { if (!is_array($_GET['filter'])) { $_GET['filter'] = explode(',', $_GET['filter']); } - + $_SESSION['bulk_manager_filter'] = array(); - + foreach ($_GET['filter'] as $filter) { 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; } break; - + case 'tag': if (is_numeric($value)) { @@ -145,7 +150,7 @@ else if (isset($_GET['filter'])) $_SESSION['bulk_manager_filter']['tag_mode'] = 'AND'; } break; - + case 'level': if (is_numeric($value) && in_array($value, $conf['available_permission_levels'])) { @@ -178,7 +183,7 @@ SELECT element_id WHERE user_id = '.$user['id'].' ;'; $filter_sets[] = array_from_query($query, 'element_id'); - + break; case 'favorites': @@ -188,7 +193,7 @@ SELECT image_id WHERE user_id = '.$user['id'].' ;'; $filter_sets[] = array_from_query($query, 'image_id'); - + break; case 'last_import': @@ -206,7 +211,7 @@ SELECT id ;'; $filter_sets[] = array_from_query($query, 'id'); } - + break; case 'no_virtual_album': @@ -234,7 +239,7 @@ SELECT id } $filter_sets[] = array_diff($all_elements, $linked_to_virtual); - + break; case 'no_album': @@ -246,7 +251,7 @@ SELECT WHERE category_id is null ;'; $filter_sets[] = array_from_query($query, 'id'); - + break; case 'no_tag': @@ -258,7 +263,7 @@ SELECT WHERE tag_id is null ;'; $filter_sets[] = array_from_query($query, 'id'); - + break; @@ -280,7 +285,7 @@ SELECT id WHERE file IN (\''.implode("','", array_map('pwg_db_real_escape_string', $duplicate_files)).'\') ;'; $filter_sets[] = array_from_query($query, 'id'); - + break; case 'all_photos': @@ -290,7 +295,7 @@ SELECT id '.$conf['order_by']; $filter_sets[] = array_from_query($query, 'id'); - + break; } @@ -325,7 +330,7 @@ if (isset($_SESSION['bulk_manager_filter']['level'])) { $operator = '<='; } - + $query = ' SELECT id FROM '.IMAGES_TABLE.' @@ -374,7 +379,7 @@ if (isset($_SESSION['bulk_manager_filter']['dimension'])) // max_ratio is a floor value, so must be a bit increased $where_clause[] = 'width/height < '.($_SESSION['bulk_manager_filter']['dimension']['max_ratio']+0.01); } - + $query = ' SELECT id FROM '.IMAGES_TABLE.' @@ -384,6 +389,13 @@ SELECT id $filter_sets[] = array_from_query($query, 'id'); } +if (isset($_SESSION['bulk_manager_filter']['search'])) +{ + include_once( PHPWG_ROOT_PATH .'include/functions_search.inc.php' ); + $res = get_quick_search_results($_SESSION['bulk_manager_filter']['search']['q'], array('permissions'=>false)); + $filter_sets[] = $res['items']; +} + $current_set = array_shift($filter_sets); foreach ($filter_sets as $set) { diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index 2828d8b9b..ddcfa222c 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -86,7 +86,7 @@ if (isset($_POST['submit'])) } $action = $_POST['selectAction']; - + if ('remove_from_caddie' == $action) { $query = ' @@ -147,7 +147,7 @@ DELETE $_SESSION['page_infos'] = array( l10n('Information data registered in database') ); - + // let's refresh the page because we the current set might be modified if ('no_album' == $page['prefilter']) { @@ -171,7 +171,7 @@ DELETE $_SESSION['page_infos'] = array( l10n('Information data registered in database') ); - + // let's refresh the page because we the current set might be modified if ('no_album' == $page['prefilter']) { @@ -224,7 +224,7 @@ DELETE $_SESSION['page_infos'] = array( l10n('Information data registered in database') ); - + // let's refresh the page because the current set might be modified redirect($redirect_url); } @@ -237,7 +237,7 @@ DELETE { $_POST['author'] = null; } - + $datas = array(); foreach ($collection as $image_id) { @@ -261,7 +261,7 @@ DELETE { $_POST['title'] = null; } - + $datas = array(); foreach ($collection as $image_id) { @@ -277,7 +277,7 @@ DELETE $datas ); } - + // date_creation if ('date_creation' == $action) { @@ -308,7 +308,7 @@ DELETE $datas ); } - + // privacy_level if ('level' == $action) { @@ -335,13 +335,13 @@ DELETE } } } - + // add_to_caddie if ('add_to_caddie' == $action) { fill_caddie($collection); } - + // delete if ('delete' == $action) { @@ -664,11 +664,11 @@ if (count($page['cat_elements_id']) > 0) $query = ' SELECT id,path,representative_ext,file,filesize,level,name,width,height,rotation FROM '.IMAGES_TABLE; - + if ($is_category) { $category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']); - + $conf['order_by'] = $conf['order_by_inside_category']; if (!empty($category_info['image_order'])) { diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl index 46e2aa77c..7fa0ae473 100644 --- a/admin/themes/default/template/batch_manager_global.tpl +++ b/admin/themes/default/template/batch_manager_global.tpl @@ -665,6 +665,15 @@ $(document).ready(function() { + +

@@ -676,6 +685,7 @@ $(document).ready(function() { + {'Remove all filters'|@translate}

-- cgit v1.2.3