diff options
-rw-r--r-- | admin/batch_manager.php | 23 | ||||
-rw-r--r-- | admin/batch_manager_global.php | 9 | ||||
-rw-r--r-- | admin/batch_manager_unit.php | 4 | ||||
-rw-r--r-- | admin/include/functions.php | 19 | ||||
-rw-r--r-- | admin/picture_modify.php | 8 | ||||
-rw-r--r-- | admin/themes/default/template/batch_manager_global.tpl | 27 |
6 files changed, 69 insertions, 21 deletions
diff --git a/admin/batch_manager.php b/admin/batch_manager.php index c1d3687d4..34bbefeea 100644 --- a/admin/batch_manager.php +++ b/admin/batch_manager.php @@ -68,6 +68,11 @@ if (isset($_POST['submitFilter'])) } } + if (isset($_POST['filter_tags_use'])) + { + $_SESSION['bulk_manager_filter']['tags'] = get_tag_ids($_POST['filter_tags'], false); + } + if (isset($_POST['filter_level_use'])) { if (in_array($_POST['filter_level'], $conf['available_permission_levels'])) @@ -290,6 +295,20 @@ SELECT id ); } +if (!empty($_SESSION['bulk_manager_filter']['tags'])) +{ + $query = ' +SELECT image_id + FROM '.IMAGE_TAG_TABLE. + 'WHERE tag_id IN('.implode(',',$_SESSION['bulk_manager_filter']['tags']).') + GROUP BY image_id + HAVING COUNT(tag_id)='.count($_SESSION['bulk_manager_filter']['tags']); + array_push( + $filter_sets, + get_image_ids_for_tags($_SESSION['bulk_manager_filter']['tags']) + ); +} + $current_set = array_shift($filter_sets); foreach ($filter_sets as $set) { @@ -365,9 +384,7 @@ if (in_array($page['tab'], $tab_codes)) // +-----------------------------------------------------------------------+ $query = ' -SELECT - id AS tag_id, - name AS tag_name +SELECT id, name FROM '.TAGS_TABLE.' ;'; $template->assign('tags', get_taglist($query)); diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index 8535f98c1..b9c139a1b 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -538,6 +538,15 @@ $template->assign( ) ); +if (!empty($_SESSION['bulk_manager_filter']['tags'])) +{ + $query = ' +SELECT id, name + FROM '.TAGS_TABLE.' + WHERE id IN ('.implode(',', $_SESSION['bulk_manager_filter']['tags']).')'; + $template->assign('filter_tags', get_taglist($query)); +} + // Virtualy associate a picture to a category $query = ' SELECT id,name,uppercats,global_rank diff --git a/admin/batch_manager_unit.php b/admin/batch_manager_unit.php index a009a6843..4c0d7227d 100644 --- a/admin/batch_manager_unit.php +++ b/admin/batch_manager_unit.php @@ -251,8 +251,8 @@ SELECT id,path,tn_ext,name,date_creation,comment,author,level,file $query = ' SELECT - tag_id, - name AS tag_name + id, + name FROM '.IMAGE_TAG_TABLE.' AS it JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id WHERE image_id = '.$row['id'].' diff --git a/admin/include/functions.php b/admin/include/functions.php index afd6c7eaf..8d7a178bd 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -2048,7 +2048,7 @@ function get_taglist($query) $taglist = array(); while ($row = pwg_db_fetch_assoc($result)) { - if (preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['tag_name'], $matches)) + if (preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches)) { foreach ($matches[2] as $tag_name) { @@ -2056,7 +2056,7 @@ function get_taglist($query) $taglist, array( 'name' => trigger_event('render_tag_name', $tag_name), - 'id' => '~~'.$row['tag_id'].'~~', + 'id' => '~~'.$row['id'].'~~', ) ); } @@ -2064,13 +2064,13 @@ function get_taglist($query) $row['tag_name'] = preg_replace('#\[lang=(.*?)\](.*?)\[/lang\]#is', null, $row['tag_name']); } - if (strlen($row['tag_name']) > 0) + if (strlen($row['name']) > 0) { array_push( $taglist, array( - 'name' => trigger_event('render_tag_name', $row['tag_name']), - 'id' => '~~'.$row['tag_id'].'~~', + 'name' => trigger_event('render_tag_name', $row['name']), + 'id' => '~~'.$row['id'].'~~', ) ); } @@ -2082,7 +2082,7 @@ function get_taglist($query) return $taglist; } -function get_tag_ids($raw_tags) +function get_tag_ids($raw_tags, $allow_create=true) { // In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New // tag', 'Another new tag') The ~~34~~ means that it is an existing @@ -2098,13 +2098,10 @@ function get_tag_ids($raw_tags) { array_push($tag_ids, $matches[1]); } - else + elseif ($allow_create) { // we have to create a new tag - array_push( - $tag_ids, - tag_id_from_tag_name($raw_tag) - ); + $tag_ids[] = tag_id_from_tag_name($raw_tag); } } diff --git a/admin/picture_modify.php b/admin/picture_modify.php index 779197f0c..7dd6fcbc5 100644 --- a/admin/picture_modify.php +++ b/admin/picture_modify.php @@ -227,8 +227,8 @@ if (isset($_POST['dismiss']) // tags $query = ' SELECT - tag_id, - name AS tag_name + id, + name FROM '.IMAGE_TAG_TABLE.' AS it JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id WHERE image_id = '.$_GET['image_id'].' @@ -237,8 +237,8 @@ $tag_selection = get_taglist($query); $query = ' SELECT - id AS tag_id, - name AS tag_name + id, + name FROM '.TAGS_TABLE.' ;'; $tags = get_taglist($query); diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl index f1e722e35..70ebc137f 100644 --- a/admin/themes/default/template/batch_manager_global.tpl +++ b/admin/themes/default/template/batch_manager_global.tpl @@ -11,8 +11,9 @@ {footer_script require='jquery.tokeninput'} jQuery(document).ready(function() {ldelim} + var tag_src = [{foreach from=$tags item=tag name=tags}{ldelim}name:"{$tag.name|@escape:'javascript'}",id:"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}]; jQuery("#tags").tokenInput( - [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name|@escape:'javascript'}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}], + tag_src, {ldelim} hintText: '{'Type in a search term'|@translate}', noResultsText: '{'No results'|@translate}', @@ -23,6 +24,19 @@ jQuery(document).ready(function() {ldelim} allowCreation: true } ); + + jQuery("#tagsFilter").tokenInput( + tag_src, + {ldelim} + hintText: '{'Type in a search term'|@translate}', + noResultsText: '{'No results'|@translate}', + searchingText: '{'Searching...'|@translate}', + animateDropdown: false, + preventDuplicates: true, + allowCreation: false + } + ); + }); {/footer_script} @@ -466,6 +480,16 @@ jQuery(window).load(function() { </select> <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label> </li> + <li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}> + <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a> + <input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}> + {'Tags'|@translate} + <select id="tagsFilter" name="filter_tags"> + {foreach from=$filter_tags item=tag} + <option value="{$tag.id}">{$tag.name}</option> + {/foreach} + </select> + </li> <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}> <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a> <input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}> @@ -482,6 +506,7 @@ jQuery(window).load(function() { <option disabled="disabled">------------------</option> <option value="filter_prefilter">{'predefined filter'|@translate}</option> <option value="filter_category">{'album'|@translate}</option> + <option value="filter_tags">{'Tags'|@translate}</option> <option value="filter_level">{'Who can see these photos?'|@translate}</option> </select> <!-- <input id="removeFilters" class="submit" type="submit" value="Remove all filters" name="removeFilters"> --> |