% if (!@$categories) {
<% $lang->maketext('This story has not been assigned to a category.') %>
% } else { % my $i = 0; % foreach my $cat (sort { $a->get_uri cmp $b->get_uri } @$categories) { % my $cat_id = $cat->get_id; % $curr_cats->{$cat_id} = 1; "> % }
<% $lang->maketext('URI') %> <% $lang->maketext('Name') %> <% $lang->maketext('Primary') %> <% $lang->maketext('Delete') %>
<% $cat->get_uri %> <& '/widgets/profile/hidden.mc', name => "category_id", value => $cat_id &> <% $cat->get_name %> <& "/widgets/profile/radio.mc", disp => '', value => $cat_id, name => "primary_category_id", js => '', req => 0, checked => ($cat_id == $primary_category_id), &> <& '/widgets/profile/button.mc', disp => $lang->maketext("Delete Category"), name => 'delete_category', value => $cat_id, button => 'delete_red', useTable => 0, js => ($cat_id == $primary_category_id ? qq{style="display: none" } : '') . qq{onclick="catListMan.remove(this.parentNode.parentNode); return false"} &>
% if ($new_category_id) { % } % } % my $all_cats = [ % grep { ! $curr_cats->{$_->get_id} && chk_authz($_, READ, 1) } % $cat_pkg->list({ site_id => $story->get_site_id }) % ]; % if (scalar @$all_cats) {
<& '/widgets/profile/button.mc', disp => $lang->maketext("Add Category"), name => 'add_category_button', button => 'add_category_lgreen', useTable => 0, js => qq{onclick="catListMan.add('new_category_uri'); return false"} &>
% } <%args> $story => undef $categories => undef $category_id => undef $new_category_id => undef $new_category_uri => undef $primary_category_id => undef <%init> my $cat_pkg = get_package_name('category'); $story ||= get_state_data('story_prof', 'story'); my $new_category; if ($new_category_uri) { $new_category_uri .= "/" unless substr($new_category_uri, -1) eq "/"; $new_category = $cat_pkg->lookup({ uri => $new_category_uri }); } $new_category_id = $new_category->get_id if $new_category; $category_id = mk_aref($category_id); push @$category_id, $new_category_id if defined $new_category_id; push @$categories, $cat_pkg->list({ id => ANY(@$category_id) }) if @$category_id; my $curr_cats = {};