<%perl>; $m->comp('/widgets/wrappers/sharky/table_top.mc', caption => 'Current Category' ); $m->comp('/widgets/listManager/listManager.mc', object => 'category', userSort => 0, def_sort_field => 'uri', title => 'Current Category', objs => [ $category ], profile => undef, fields => [qw(uri site name)], select => '', addition => '', ); $m->comp('/widgets/profile/hidden.mc', name => 'category_id', value => $existing_category); $m->comp('/widgets/wrappers/sharky/table_bottom.mc'); <& /widgets/search/search.mc, object => 'category', field => 'uri', type => 'singular', use_form_tag => 0 &> <& '/widgets/wrappers/sharky/table_top.mc', caption => 'Choose Categories' &> <& /widgets/listManager/listManager.mc, object => 'category', title => 'Choose Categories', select => undef, profile => $category_profile, exclude => $exclude_cats, fields => [qw(uri site name)], addition => '', behavior => 'expand', &> <& '/widgets/wrappers/sharky/table_bottom.mc' &> <& '/widgets/buttons/submit.mc', disp => 'Save', widget => $widget, cb => 'save_category_cb', button => 'save_red', value => 'Save', &> <& '/widgets/buttons/submit.mc', disp => 'Save and Stay', widget => $widget, cb => 'save_and_stay_category_cb', button => 'save_and_stay_lgreen', value => 'Save and Stay', &> <& '/widgets/buttons/submit.mc', disp => 'Return', widget => $widget, cb => 'leave_category_cb', button => 'return_dgreen', value => 'Return', &> <%args> $widget <%init> my $media = get_state_data($widget, 'media'); my $category = $media->get_category; my $existing_category = $category->get_id; my $exclude_cats = sub { my $cat = shift; # exclude unauthorized categories return 1 unless chk_authz($cat, READ, 1); # exclude already-associated category return 1 if $cat->get_id == $existing_category; # exclude cats not in media's site return 1 if $cat->get_site_id != $media->get_site_id; return 0; }; <%once> my $category_profile = sub { my ($o,$flags) = @_; unless ($flags->{'featured'}) { return ['Associate', $r->uri, "media_prof|assoc_category_cb=".$o->get_id]; } else { return ['Un-Associate', $r->uri, "media_prof|unassoc_category_cb=".$o->get_id]; } };