<& '/widgets/search/search.mc', object => 'media', state_key => 'rel_media', type => 'media', field => 'title', use_form_tag => 0 &> <& '/widgets/wrappers/sharky/table_top.mc', caption => 'Choose Related Media' &> <& /widgets/listManager/listManager.mc, object => 'media', state_key => 'rel_media', sortBy => 'name', select => undef, profile => $related_profile, constrain => ($args->{'search|uri'} ? {} : { uri => '/%' }), # Must have a file associated. featured => $relate_id ? [$relate_id] : undef, exclude => $excl_sub, fields => [(USE_THUMBNAILS ? 'thumb' : ()), qw(id name uri cover_date)], addition => '', behavior => 'expand', field_values => $thumburi, field_titles => { thumb => $lang->maketext('Thumb')}, &> <& '/widgets/wrappers/sharky/table_bottom.mc' &> <& '/widgets/buttons/submit.mc', disp => 'Return', widget => $widget, cb => 'related_up_cb', button => 'return_dgreen', value => 'Return', useTable => 0, &> <%args> $widget $args <%init>; # The element object. my $element = get_state_data($widget, 'element'); my $relate_id = $element->get_related_media_id; my $excl_sub; if ($element->get_object_type eq 'media') { my $asset_id = get_state_data('media_prof', 'media')->get_id; $excl_sub = sub { return 1 if $_[0]->get_id == $asset_id; return !chk_authz($_[0], READ, 1); }; } else { $excl_sub = sub { return !chk_authz($_[0], READ, 1) }; } <%once>; my $related_profile = sub { my ($o,$flags) = @_; unless ($flags->{featured}) { return ['Relate', $r->uri, "container_prof|relate_media_cb=".$o->get_id]; } else { return ['Un-relate', $r->uri, "container_prof|unrelate_media_cb=".$o->get_id]; } }; my $thumburi = sub { my ($selfobj, $fieldname) = @_; return unless $fieldname eq 'thumb'; # If we get a thumbnail URI, we have an image. Otherwise, simply return # a space to fill the column properly because we aren't an image object # but USE_THUMBNAILS is on. my $thumb_uri = $selfobj->thumbnail_uri or return ' '; return qq{ }; };