Revision 634 (by ahitrov, 2016/12/19 18:37:20) Tag search

<% $json %>
<%once>

    use JSON::XS;

</%once>
<%args>

	$id	=> undef
	$name	=> undef

</%args>
<%init>

    warn Dumper \%ARGS		if $DEBUG;

    my %result;
    if ( $id && $id =~ /^\d+$/ || $name && length( Encode::decode('utf-8', $name) ) > 1 ) {
	my @tags = $keeper->get_documents(
			class	=> 'tag::Tag',
			status	=> 1,
			$id ? ( id => [$id] ) : (name => '%'.$name.'%'),
			ilike	=> 1,
			order_by	=> 'name',
		);
	$result{success} = 1;
	if ( @tags ) {
		$result{html} = Encode::decode('utf-8', $m->scomp('/contenido/tag/components/block_tag_list.msn', tags => \@tags) );
	} else {
		$result{html} = '';
	}
    } else {
	$result{error} = Encode::decode('utf-8', 'Недостаточные параметры для поиска тега');
    }
    my $json = encode_json \%result;

</%init>