mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-06 18:01:31 +02:00
batch manager - remove unused code, less sql queries and avoid 4 calls to same display_select function
git-svn-id: http://piwigo.org/svn/trunk@18573 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -74,14 +74,6 @@ if (isset($_SESSION['bulk_manager_filter']['prefilter']))
|
|||||||
$page['prefilter'] = $_SESSION['bulk_manager_filter']['prefilter'];
|
$page['prefilter'] = $_SESSION['bulk_manager_filter']['prefilter'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// $page['category'] is a shortcut to test if the current filter contains a
|
|
||||||
// given category. The idea is the same as for prefilter
|
|
||||||
$page['category'] = -1;
|
|
||||||
if (isset($_SESSION['bulk_manager_filter']['category']))
|
|
||||||
{
|
|
||||||
$page['category'] = $_SESSION['bulk_manager_filter']['category'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
|
$redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
|
||||||
|
|
||||||
if (isset($_POST['submit']))
|
if (isset($_POST['submit']))
|
||||||
@@ -105,15 +97,8 @@ DELETE
|
|||||||
;';
|
;';
|
||||||
pwg_query($query);
|
pwg_query($query);
|
||||||
|
|
||||||
if ('caddie' == $page['prefilter'])
|
// remove from caddie action available only in caddie so reload content
|
||||||
{
|
redirect($redirect_url);
|
||||||
redirect($redirect_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we are here in the code, it means that the user is currently
|
|
||||||
// displaying the caddie content, so we have to remove the current
|
|
||||||
// selection from the current set
|
|
||||||
$page['cat_elements_id'] = array_diff($page['cat_elements_id'], $collection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('add_tags' == $action)
|
if ('add_tags' == $action)
|
||||||
@@ -129,7 +114,7 @@ DELETE
|
|||||||
|
|
||||||
if ('with no tag' == $page['prefilter'])
|
if ('with no tag' == $page['prefilter'])
|
||||||
{
|
{
|
||||||
redirect(get_root_url().'admin.php?page='.$_GET['page']);
|
redirect($redirect_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -445,9 +430,7 @@ $template->set_filenames(array('batch_manager_global' => 'batch_manager_global.t
|
|||||||
|
|
||||||
$base_url = get_root_url().'admin.php';
|
$base_url = get_root_url().'admin.php';
|
||||||
|
|
||||||
$prefilters = array();
|
$prefilters = array(
|
||||||
|
|
||||||
array_push($prefilters,
|
|
||||||
array('ID' => 'caddie', 'NAME' => l10n('Caddie')),
|
array('ID' => 'caddie', 'NAME' => l10n('Caddie')),
|
||||||
array('ID' => 'last import', 'NAME' => l10n('Last import')),
|
array('ID' => 'last import', 'NAME' => l10n('Last import')),
|
||||||
array('ID' => 'with no album', 'NAME' => l10n('With no album')),
|
array('ID' => 'with no album', 'NAME' => l10n('With no album')),
|
||||||
@@ -481,39 +464,8 @@ $template->assign(
|
|||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | caddie options |
|
// | caddie options |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->assign('IN_CADDIE', 'caddie' == $page['prefilter']);
|
||||||
|
|
||||||
$in_caddie = false;
|
|
||||||
if (isset($_SESSION['bulk_manager_filter']['prefilter'])
|
|
||||||
and 'caddie' == $_SESSION['bulk_manager_filter']['prefilter'])
|
|
||||||
{
|
|
||||||
$in_caddie = true;
|
|
||||||
}
|
|
||||||
$template->assign('IN_CADDIE', $in_caddie);
|
|
||||||
|
|
||||||
// +-----------------------------------------------------------------------+
|
|
||||||
// | deletion form |
|
|
||||||
// +-----------------------------------------------------------------------+
|
|
||||||
|
|
||||||
// we can only remove photos that have no storage_category_id, in other
|
|
||||||
// word, it currently (Butterfly) means that the photo was added with
|
|
||||||
// pLoader
|
|
||||||
if (count($page['cat_elements_id']) > 0)
|
|
||||||
{
|
|
||||||
$query = '
|
|
||||||
SELECT
|
|
||||||
id
|
|
||||||
FROM '.IMAGES_TABLE.'
|
|
||||||
WHERE id IN ('.implode(',', $page['cat_elements_id']).')
|
|
||||||
AND file NOT LIKE \'http%\'
|
|
||||||
LIMIT 1
|
|
||||||
;';
|
|
||||||
;
|
|
||||||
|
|
||||||
if ( pwg_db_fetch_row(pwg_query($query)) )
|
|
||||||
{
|
|
||||||
$template->assign('show_delete_form', true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | global mode form |
|
// | global mode form |
|
||||||
@@ -556,8 +508,10 @@ $query = '
|
|||||||
SELECT id,name,uppercats,global_rank
|
SELECT id,name,uppercats,global_rank
|
||||||
FROM '.CATEGORIES_TABLE.'
|
FROM '.CATEGORIES_TABLE.'
|
||||||
;';
|
;';
|
||||||
display_select_cat_wrapper($query, array(), 'associate_options', true);
|
$categories = array_from_query($query);
|
||||||
display_select_cat_wrapper($query, array(), 'move_options', true);
|
usort($categories, 'global_rank_compare');
|
||||||
|
display_select_categories($categories, array(), 'category_full_name_options', true);
|
||||||
|
|
||||||
display_select_cat_wrapper($query, array(), 'category_parent_options');
|
display_select_cat_wrapper($query, array(), 'category_parent_options');
|
||||||
|
|
||||||
// in the filter box, which category to select by default
|
// in the filter box, which category to select by default
|
||||||
@@ -570,8 +524,6 @@ if (isset($_SESSION['bulk_manager_filter']['category']))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we need to know the category in which the last photo was added
|
// we need to know the category in which the last photo was added
|
||||||
$selected_category = array();
|
|
||||||
|
|
||||||
$query = '
|
$query = '
|
||||||
SELECT
|
SELECT
|
||||||
category_id,
|
category_id,
|
||||||
@@ -586,16 +538,11 @@ SELECT
|
|||||||
if (pwg_db_num_rows($result) > 0)
|
if (pwg_db_num_rows($result) > 0)
|
||||||
{
|
{
|
||||||
$row = pwg_db_fetch_assoc($result);
|
$row = pwg_db_fetch_assoc($result);
|
||||||
|
|
||||||
$selected_category = array($row['category_id']);
|
$selected_category = array($row['category_id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = '
|
$template->assign( 'filter_category_selected', $selected_category);
|
||||||
SELECT id,name,uppercats,global_rank
|
|
||||||
FROM '.CATEGORIES_TABLE.'
|
|
||||||
;';
|
|
||||||
display_select_cat_wrapper($query, $selected_category, 'filter_category_options', true);
|
|
||||||
|
|
||||||
// Dissociate from a category : categories listed for dissociation can only
|
// Dissociate from a category : categories listed for dissociation can only
|
||||||
// represent virtual links. We can't create orphans. Links to physical
|
// represent virtual links. We can't create orphans. Links to physical
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ jQuery(document).ready(function() {
|
|||||||
jQuery.fn.enableShiftClick = function() {
|
jQuery.fn.enableShiftClick = function() {
|
||||||
var inputs = [];
|
var inputs = [];
|
||||||
var count=0;
|
var count=0;
|
||||||
var This=$(this);
|
|
||||||
this.find('input[type=checkbox]').each(function() {
|
this.find('input[type=checkbox]').each(function() {
|
||||||
var pos=count;
|
var pos=count;
|
||||||
inputs[count++]=this;
|
inputs[count++]=this;
|
||||||
@@ -522,7 +521,7 @@ $(document).ready(function() {
|
|||||||
<input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
|
<input type="checkbox" name="filter_category_use" class="useFilterCheckbox" {if isset($filter.category)}checked="checked"{/if}>
|
||||||
{'Album'|@translate}
|
{'Album'|@translate}
|
||||||
<select style="width:400px" name="filter_category" size="1">
|
<select style="width:400px" name="filter_category" size="1">
|
||||||
{html_options options=$filter_category_options selected=$filter_category_options_selected}
|
{html_options options=$category_full_name_options selected=$filter_category_selected}
|
||||||
</select>
|
</select>
|
||||||
<label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
|
<label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
|
||||||
</li>
|
</li>
|
||||||
@@ -675,9 +674,7 @@ UL.thumbnails SPAN.wrap2 {ldelim}
|
|||||||
<select name="selectAction">
|
<select name="selectAction">
|
||||||
<option value="-1">{'Choose an action'|@translate}</option>
|
<option value="-1">{'Choose an action'|@translate}</option>
|
||||||
<option disabled="disabled">------------------</option>
|
<option disabled="disabled">------------------</option>
|
||||||
{if isset($show_delete_form) }
|
|
||||||
<option value="delete">{'Delete selected photos'|@translate}</option>
|
<option value="delete">{'Delete selected photos'|@translate}</option>
|
||||||
{/if}
|
|
||||||
<option value="associate">{'Associate to album'|@translate}</option>
|
<option value="associate">{'Associate to album'|@translate}</option>
|
||||||
<option value="move">{'Move to album'|@translate}</option>
|
<option value="move">{'Move to album'|@translate}</option>
|
||||||
{if !empty($dissociate_options)}
|
{if !empty($dissociate_options)}
|
||||||
@@ -714,7 +711,7 @@ UL.thumbnails SPAN.wrap2 {ldelim}
|
|||||||
<!-- associate -->
|
<!-- associate -->
|
||||||
<div id="action_associate" class="bulkAction">
|
<div id="action_associate" class="bulkAction">
|
||||||
<select style="width:400px" name="associate" size="1">
|
<select style="width:400px" name="associate" size="1">
|
||||||
{html_options options=$associate_options }
|
{html_options options=$category_full_name_options}
|
||||||
</select>
|
</select>
|
||||||
<br>{'... or '|@translate} <a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
|
<br>{'... or '|@translate} <a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -722,7 +719,7 @@ UL.thumbnails SPAN.wrap2 {ldelim}
|
|||||||
<!-- move -->
|
<!-- move -->
|
||||||
<div id="action_move" class="bulkAction">
|
<div id="action_move" class="bulkAction">
|
||||||
<select style="width:400px" name="move" size="1">
|
<select style="width:400px" name="move" size="1">
|
||||||
{html_options options=$move_options }
|
{html_options options=$category_full_name_options}
|
||||||
</select>
|
</select>
|
||||||
<br>{'... or '|@translate} <a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
|
<br>{'... or '|@translate} <a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -189,19 +189,28 @@ function pwg_db_insert_id($table=null, $column='id')
|
|||||||
* used here
|
* used here
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param string $fieldname
|
* @param string $fieldname optional
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function array_from_query($query, $fieldname)
|
function array_from_query($query, $fieldname=false)
|
||||||
{
|
{
|
||||||
$array = array();
|
$array = array();
|
||||||
|
|
||||||
$result = pwg_query($query);
|
$result = pwg_query($query);
|
||||||
while ($row = mysql_fetch_assoc($result))
|
if (false === $fieldname)
|
||||||
{
|
{
|
||||||
$array[] = $row[$fieldname];
|
while ($row = mysql_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$array[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ($row = mysql_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$array[] = $row[$fieldname];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user