Revision 635
- Date:
- 2016/12/21 10:19:32
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/tag/comps/contenido/tag/ajax/manage.html
74 74 $result{fallback} = 1; 75 75 } 76 76 } 77 my ($prop) = grep { $_->{type} eq 'tagset' } $doc->structure; 78 if ( ref $prop && !(exists $prop->{virtual} && $prop->{virtual}) ) { 79 my $class = $doc->class; 80 my $name = $prop->{attr}; 81 my $is_extra = scalar( grep { ref $_ && $_->{attr} eq $name } $class->class_table->required_properties ) ? 0 : 1; 82 83 my $result; 84 my @tags; 85 if ( $doc->id ) { 86 @tags = $keeper->get_documents( 87 class => 'tag::Tag', 88 lclass => 'tag::Cloud', 89 ldest => $doc->id, 90 ldestclass => $doc->class, 91 ); 92 if ( @tags ) { 93 $result = []; 94 foreach my $tag ( @tags ) { 95 push @$result, { id => $tag->id, name => $is_extra ? $tag->name : Encode::decode('utf-8', $tag->name) }; 96 } 97 unless ( $is_extra ) { 98 $result = Encode::encode('utf-8', JSON::XS->new->encode( $result )); 99 } 100 } 101 warn Dumper $result if $DEBUG; 102 $doc->$name( $result ); 103 $doc->store; 104 } 105 } 77 106 } 78 107 $result{ok} = 1 unless exists $result{fallback}; 79 108 -
utf8/plugins/tag/lib/tag/Keeper.pm
51 51 return $tree; 52 52 } 53 53 54 sub store_extras { 55 my $self = shift; 56 my $object = shift; 57 58 if ( ref $object && $object->id ) { 59 my ($prop) = grep { $_->{type} eq 'tagset' } $object->structure; 60 if ( ref $prop && !(exists $prop->{virtual} && $prop->{virtual}) ) { 61 my $name = $prop->{attr}; 62 my $class = $object->class; 63 my $is_extra = scalar( grep { ref $_ && $_->{attr} eq $name } $class->class_table->required_properties ) ? 0 : 1; 64 65 my $result; 66 my @tags; 67 @tags = $keeper->get_documents( 68 class => 'tag::Tag', 69 lclass => 'tag::Cloud', 70 ldest => $object->id, 71 ldestclass => $object->class, 72 ); 73 if ( @tags ) { 74 $result = []; 75 foreach my $tag ( @tags ) { 76 push @$result, { id => $tag->id, name => $is_extra ? $tag->name : Encode::decode('utf-8', $tag->name) }; 77 } 78 unless ( $is_extra ) { 79 $result = Encode::encode('utf-8', $json->encode( $result )); 80 } 81 } 82 warn Dumper $result if $DEBUG; 83 $object->$name( $result ); 84 $object->store; 85 } 86 } 87 } 88 54 89 1;