<%args> $widget $container => undef $container_id => undef $type => 'story' <%once> my $find_subelement; $find_subelement = sub { my ($element, $id) = @_; return $element if $element->get_id == $id; foreach my $container ($element->get_containers) { my $subelement = $find_subelement->($container, $id); return $subelement if $subelement; } }; <%init> $container ||= $find_subelement->( get_state_data('container_prof', 'element'), $container_id ); my $rel = $type eq 'story' ? $container->get_related_story : $container->get_related_media; my $button = $m->scomp( '/widgets/profile/button.mc', name => "pick_related_".$type, button => "edit_lgreen", js => qq{onclick="openWindow('/workflow/profile/} . $container->get_object_type . qq{/container/edit_related_$type.html?id=} . $container->get_id . qq{', undefined, { closeOnUnload: true }); return false"}, useTable => 0 ); if ($rel) { add_msg('Related [_1] "[_2]" is not active. Please relate another [_1].', $type, $rel->get_title) unless $rel->is_active; my $thumb = ''; if (USE_THUMBNAILS && $type ne 'story') { if ($thumb = $rel->thumbnail_uri) { $thumb = $m->comp( '/widgets/profile/preview_link.mc', doc => $rel, value => qq{ }, type => $type, ); } } # The summary info $m->comp('/widgets/summary/summary.mc', asset => $rel, type => $type, header => 'Currently Related '.ucfirst($type), frame => 0, button => $thumb . $button ); } else { $m->out('
', $lang->maketext('No related [_1]', ucfirst($type)), qq{
$button
}, '
' ); }