From 3d2c55a9d5dd5bc2fa89a9c2ea95a219d8628021 Mon Sep 17 00:00:00 2001 From: Geosohh Date: Tue, 29 Jul 2014 18:02:50 -0300 Subject: [PATCH 1/2] Fixed mass_tagger bug when selecting images with similar ids The mass_tagger extension behaves incorrectly if the id of an image is the same as the ending of the id of another image. Example: Select image 143: var string == "143:" Select image 113: var string == "143:113:" Select image 43: var string == "1113:" So either the wrong image will be tagged, or it will cause an error if that image doesn't exist. --- ext/mass_tagger/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/mass_tagger/script.js b/ext/mass_tagger/script.js index 966e8ac2..7a028e01 100644 --- a/ext/mass_tagger/script.js +++ b/ext/mass_tagger/script.js @@ -23,7 +23,7 @@ function toggle_tag( button, id ) { var list = $('#mass_tagger_ids'); var string = list.val(); - if( string.indexOf( id ) > -1 ) { + if( (string.indexOf(id) == 0) || (string.indexOf(":"+id) > -1) ) { $(button).css('border', 'none'); string = string.replace(id, ''); list.val(string); From 3185af32801a0e4c440f99d47b473ac8ea8f2077 Mon Sep 17 00:00:00 2001 From: Geosohh Date: Tue, 29 Jul 2014 19:11:29 -0300 Subject: [PATCH 2/2] Remove tags from images using mass_tagger Using negative tags removes them from the selected images. --- ext/mass_tagger/main.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ext/mass_tagger/main.php b/ext/mass_tagger/main.php index aa9e650e..d65b8a46 100644 --- a/ext/mass_tagger/main.php +++ b/ext/mass_tagger/main.php @@ -33,6 +33,17 @@ class MassTagger extends Extension { if( !isset($_POST['ids']) or !isset($_POST['tag']) ) return; $tag = $_POST['tag']; + + $tag_array = explode(" ",$tag); + $pos_tag_array = array(); + $neg_tag_array = array(); + foreach($tag_array as $new_tag) { + if (strpos($new_tag, '-') === 0) + $neg_tag_array[] = substr($new_tag,1); + else + $pos_tag_array[] = $new_tag; + } + $ids = explode( ':', $_POST['ids'] ); $ids = array_filter ( $ids , 'is_numeric' ); @@ -48,7 +59,13 @@ class MassTagger extends Extension { else { foreach($images as $image) { - $image->set_tags(Tag::explode($tag . " " . $image->get_tag_list())); + if (!empty($neg_tag_array)) { + $img_tags = array_merge($pos_tag_array, explode(" ",$image->get_tag_list())); + $img_tags = array_diff($img_tags, $neg_tag_array); + $image->set_tags(Tag::explode($img_tags)); + } + else + $image->set_tags(Tag::explode($tag . " " . $image->get_tag_list())); } }