Changeset 11853


Ignore:
Timestamp:
Jul 30, 2011, 6:49:02 AM (9 years ago)
Author:
rvelices
Message:

feature 2387: addd a filter by tag in the batch manager

Location:
trunk/admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r11039 r11853  
    6767      $_SESSION['bulk_manager_filter']['category_recursive'] = true;
    6868    }
     69  }
     70
     71  if (isset($_POST['filter_tags_use']))
     72  {
     73    $_SESSION['bulk_manager_filter']['tags'] = get_tag_ids($_POST['filter_tags'], false);
    6974  }
    7075
     
    291296}
    292297
     298if (!empty($_SESSION['bulk_manager_filter']['tags']))
     299{
     300        $query = '
     301SELECT image_id
     302        FROM '.IMAGE_TAG_TABLE.
     303        'WHERE tag_id IN('.implode(',',$_SESSION['bulk_manager_filter']['tags']).')
     304        GROUP BY image_id
     305        HAVING COUNT(tag_id)='.count($_SESSION['bulk_manager_filter']['tags']);
     306        array_push(
     307    $filter_sets,
     308                get_image_ids_for_tags($_SESSION['bulk_manager_filter']['tags'])
     309                );
     310}
     311
    293312$current_set = array_shift($filter_sets);
    294313foreach ($filter_sets as $set)
     
    366385
    367386$query = '
    368 SELECT
    369     id AS tag_id,
    370     name AS tag_name
     387SELECT id, name
    371388  FROM '.TAGS_TABLE.'
    372389;';
  • trunk/admin/batch_manager_global.php

    r11039 r11853  
    538538    )
    539539  );
     540
     541if (!empty($_SESSION['bulk_manager_filter']['tags']))
     542{
     543        $query = '
     544SELECT id, name
     545        FROM '.TAGS_TABLE.'
     546        WHERE id IN ('.implode(',', $_SESSION['bulk_manager_filter']['tags']).')';
     547        $template->assign('filter_tags', get_taglist($query));
     548}
    540549
    541550// Virtualy associate a picture to a category
  • trunk/admin/batch_manager_unit.php

    r11220 r11853  
    252252    $query = '
    253253SELECT
    254     tag_id,
    255     name AS tag_name
     254    id,
     255    name
    256256  FROM '.IMAGE_TAG_TABLE.' AS it
    257257    JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
  • trunk/admin/include/functions.php

    r11828 r11853  
    20492049  while ($row = pwg_db_fetch_assoc($result))
    20502050  {
    2051     if (preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['tag_name'], $matches))
     2051    if (preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
    20522052    {
    20532053      foreach ($matches[2] as $tag_name)
     
    20572057          array(
    20582058            'name' => trigger_event('render_tag_name', $tag_name),
    2059             'id' => '~~'.$row['tag_id'].'~~',
     2059            'id' => '~~'.$row['id'].'~~',
    20602060            )
    20612061          );
     
    20652065    }
    20662066   
    2067     if (strlen($row['tag_name']) > 0)
     2067    if (strlen($row['name']) > 0)
    20682068    {
    20692069      array_push(
    20702070        $taglist,
    20712071        array(
    2072           'name' => trigger_event('render_tag_name', $row['tag_name']),
    2073           'id' => '~~'.$row['tag_id'].'~~',
     2072          'name' => trigger_event('render_tag_name', $row['name']),
     2073          'id' => '~~'.$row['id'].'~~',
    20742074          )
    20752075        );
     
    20832083}
    20842084
    2085 function get_tag_ids($raw_tags)
     2085function get_tag_ids($raw_tags, $allow_create=true)
    20862086{
    20872087  // In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New
     
    20992099      array_push($tag_ids, $matches[1]);
    21002100    }
    2101     else
     2101    elseif ($allow_create)
    21022102    {
    21032103      // we have to create a new tag
    2104       array_push(
    2105         $tag_ids,
    2106         tag_id_from_tag_name($raw_tag)
    2107         );
     2104      $tag_ids[] = tag_id_from_tag_name($raw_tag);
    21082105    }
    21092106  }
  • trunk/admin/picture_modify.php

    r11220 r11853  
    228228$query = '
    229229SELECT
    230     tag_id,
    231     name AS tag_name
     230    id,
     231    name
    232232  FROM '.IMAGE_TAG_TABLE.' AS it
    233233    JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
     
    238238$query = '
    239239SELECT
    240     id AS tag_id,
    241     name AS tag_name
     240    id,
     241    name
    242242  FROM '.TAGS_TABLE.'
    243243;';
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r11754 r11853  
    1212{footer_script require='jquery.tokeninput'}
    1313jQuery(document).ready(function() {ldelim}
     14        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}];
    1415  jQuery("#tags").tokenInput(
    15     [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name|@escape:'javascript'}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
     16    tag_src,
    1617    {ldelim}
    1718      hintText: '{'Type in a search term'|@translate}',
     
    2425    }
    2526  );
     27       
     28  jQuery("#tagsFilter").tokenInput(
     29    tag_src,
     30    {ldelim}
     31      hintText: '{'Type in a search term'|@translate}',
     32      noResultsText: '{'No results'|@translate}',
     33      searchingText: '{'Searching...'|@translate}',
     34      animateDropdown: false,
     35      preventDuplicates: true,
     36      allowCreation: false
     37    }
     38  );
     39
    2640});
    2741{/footer_script}
     
    467481        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
    468482      </li>
     483                        <li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}>
     484                                <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     485                                <input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
     486                                {'Tags'|@translate}
     487                                <select id="tagsFilter" name="filter_tags">
     488                                        {foreach from=$filter_tags item=tag}
     489                                        <option value="{$tag.id}">{$tag.name}</option>
     490                                        {/foreach}
     491                                </select>
     492                        </li>
    469493      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
    470494        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     
    483507        <option value="filter_prefilter">{'predefined filter'|@translate}</option>
    484508        <option value="filter_category">{'album'|@translate}</option>
     509                                <option value="filter_tags">{'Tags'|@translate}</option>
    485510        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
    486511      </select>
Note: See TracChangeset for help on using the changeset viewer.