Revision 632 (by ahitrov, 2016/12/14 23:53:09) cloud

<fieldset>
	<legend>Связанные объекты</legend>
% foreach my $class ( @{$state->{tag}->tag_destinations} ) {
%	next	unless exists $objects{$class};
%	my %props = map { $_->{attr} => $_ } grep { $_->{attr} eq 'id' || $_->{attr} eq 'name' || $_->{attr} eq 'status' || exists $_->{column} && $_->{column} } $class->new( $keeper )->structure;
	<h3><% $class->class_name %> <span><% $class %></span></h3>
	
	<table width="100%" border="0" cellpadding="4" cellspacing="0" class="tlistdocs">
	<tr bgcolor="#efefef">
		<th>id</th>
		<th>Название</th>
<%doc>
%	if ( exists $props{status} ) {
		<th>Статус</th>
%	}
</%doc>
	</tr>
%	foreach my $object ( @{$objects{$class}} ) {
%		my $style = $object->contenido_status_style || ( exists $props{status} && $props{status} == 0 ? 'color:gray;' : '' );
	<tr valign="top">
		<td><a href="/contenido/document.html?id=<% $object->id %>&class=<% $object->class %>"<% $style ? ' style="'.$style.'"' : '' %>><% $object->id %></a></td>
		<td><a href="/contenido/document.html?id=<% $object->id %>&class=<% $object->class %>"<% $style ? ' style="'.$style.'"' : '' %>><% $object->name %></a></td>
<%doc>
%	if ( exists $props{status} ) {
%		my $prop = $props{status};
%		my $status_map = exists $prop->{cases} && ref $prop->{cases} eq 'ARRAY' ? $prop->{cases} : $keeper->default_status();
%		my %cases = map { $_->[0] => $_->[1] } @$status_map;
		<td><% exists $cases{$object->status} ? $cases{$object->status}.' ('.$object->status.')' : 'н/с ('.$object->status.')' %></td>
%	}
</%doc>
	</tr>
%	}
% }
</fieldset>
<%args>

	$tag	=> undef

</%args>
<%init>

    return	unless ref $tag;

    my %objects;
    my $found = 0;
    foreach my $class ( @{$state->{tag}->tag_destinations} ) {
	my $objects = $tag->get_objects( class => $class );
	if ( ref $objects eq 'ARRAY' && @$objects ) {
		$objects{$class} = $objects;
		$found = 1;
	}
    }

</%init>