Revision 480 (by ahitrov, 2015/03/03 12:14:40) |
Tags plugin: initial import
|
<% $json %>
<%once>
use JSON::XS;
</%once>
<%args>
$id => undef
$class => undef
$term => undef
</%args>
<%init>
warn Dumper \%ARGS if $DEBUG;
return if length( $ARGS{term} ) < 3;
my @links = $keeper->get_links(
class => 'tag::Cloud',
dest_class => $class,
dest_id => $id,
);
my %ex = map { $_->source_id => 1 } @links;
my @ex = keys %ex;
my @tags = $keeper->get_documents(
@ex ? ( excludes => \@ex ) : (),
class => 'tag::Tag',
status => 1,
name => '%'.$ARGS{term}.'%',
ilike => 1,
order_by => 'name',
);
return unless @tags;
my @result = map { {id => $_->id, label => Encode::decode('utf-8', $_->name), value => Encode::decode('utf-8', $_->name)} } @tags;
my $json = encode_json \@result;
</%init>