Changeset 11854


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

feature 2387: addd a filter by tag in the batch manager (merge from trunk)

Location:
branches/2.2/admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/admin/batch_manager.php

    r11056 r11854  
    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;';
  • branches/2.2/admin/batch_manager_global.php

    r11056 r11854  
    486486    )
    487487  );
     488
     489if (!empty($_SESSION['bulk_manager_filter']['tags']))
     490{
     491        $query = '
     492SELECT id, name
     493        FROM '.TAGS_TABLE.'
     494        WHERE id IN ('.implode(',', $_SESSION['bulk_manager_filter']['tags']).')';
     495        $template->assign('filter_tags', get_taglist($query));
     496}
    488497
    489498// Virtualy associate a picture to a category
  • branches/2.2/admin/batch_manager_unit.php

    r11221 r11854  
    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
  • branches/2.2/admin/include/functions.php

    r11727 r11854  
    21162116      $taglist,
    21172117      array(
    2118         'name' => $row['tag_name'],
    2119         'id' => '~~'.$row['tag_id'].'~~',
     2118        'name' => $row['name'],
     2119        'id' => '~~'.$row['id'].'~~',
    21202120        )
    21212121      );
     
    21282128}
    21292129
    2130 function get_tag_ids($raw_tags)
     2130function get_tag_ids($raw_tags, $allow_create=true)
    21312131{
    21322132  // In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New
     
    21442144      array_push($tag_ids, $matches[1]);
    21452145    }
    2146     else
     2146    elseif ($allow_create)
    21472147    {
    21482148      // we have to create a new tag
    2149       array_push(
    2150         $tag_ids,
    2151         tag_id_from_tag_name($raw_tag)
    2152         );
     2149      $tag_ids[] = tag_id_from_tag_name($raw_tag);
    21532150    }
    21542151  }
  • branches/2.2/admin/picture_modify.php

    r11221 r11854  
    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;';
  • branches/2.2/admin/themes/default/template/batch_manager_global.tpl

    r11211 r11854  
    1010{footer_script require='jquery.tokeninput'}
    1111jQuery(document).ready(function() {ldelim}
     12        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}];
    1213  jQuery("#tags").tokenInput(
    13     [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name|@escape:'javascript'}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
     14    tag_src,
    1415    {ldelim}
    1516      hintText: '{'Type in a search term'|@translate}',
     
    2223    }
    2324  );
     25       
     26  jQuery("#tagsFilter").tokenInput(
     27    tag_src,
     28    {ldelim}
     29      hintText: '{'Type in a search term'|@translate}',
     30      noResultsText: '{'No results'|@translate}',
     31      searchingText: '{'Searching...'|@translate}',
     32      animateDropdown: false,
     33      preventDuplicates: true,
     34      allowCreation: false
     35    }
     36  );
     37
    2438});
    2539{/footer_script}
     
    347361        <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
    348362      </li>
     363                        <li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}>
     364                                <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     365                                <input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
     366                                {'Tags'|@translate}
     367                                <select id="tagsFilter" name="filter_tags">
     368                                        {foreach from=$filter_tags item=tag}
     369                                        <option value="{$tag.id}">{$tag.name}</option>
     370                                        {/foreach}
     371                                </select>
     372                        </li>
    349373      <li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
    350374        <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     
    363387        <option value="filter_prefilter">{'predefined filter'|@translate}</option>
    364388        <option value="filter_category">{'album'|@translate}</option>
     389                                <option value="filter_tags">{'Tags'|@translate}</option>
    365390        <option value="filter_level">{'Who can see these photos?'|@translate}</option>
    366391      </select>
Note: See TracChangeset for help on using the changeset viewer.