Merge pull request #435 from geosohh/master

Fixes for mass_tagger extension
This commit is contained in:
Shish 2014-08-02 17:48:21 +01:00
commit d6eb3892e2
2 changed files with 19 additions and 2 deletions

View file

@ -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()));
}
}

View file

@ -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);