<%perl>; my $i; $m->comp('/widgets/wrappers/sharky/header.mc', title => $lang->maketext("Select Categories"), context => $lang->maketext("Workflow | Profile | $disp | Select Alias")); $m->print('\n}); $m->comp("/widgets/wrappers/sharky/table_top.mc", caption => $caption, number => ++$i); # Let 'em pick a category for the story they're aliasing. $m->print('
', $cat_sel->(), '
'); $m->comp('/widgets/wrappers/sharky/table_bottom.mc'); # Let 'em alias related stories. $m->comp('.relateds', 'story', \@rel_story, ++$i) if @rel_story; # Let 'em alias related media. $m->comp('.relateds', 'media', \@rel_media, ++$i) if @rel_media; # Send 'em on up! $m->comp('/widgets/buttons/submit.mc', widget => $widget, cb => 'pick_cats_cb', useTable => 0, ); $m->print("\n"); $m->comp('/widgets/wrappers/sharky/footer.mc'); <%once>; my $widget = 'alias'; my %classes = ( story => get_package_name('story'), media => get_package_name('media'), ); my %dispmap = ( story => get_disp_name('story'), media => get_disp_name('media') ); my $excl_sub = sub { ! chk_authz($_[0], READ, 1) }; my ($caption, $site_id, $class_key); # We'll use this closure to output the hidden fields and select lists for # related assets, as well as the main select list for the main asset being # aliased. my $cat_sel = sub { my ($o, $field) = @_; my ($cap, $table, $default); my $ret; if ($field) { if ($field eq 'name') { # Give 'em a preview link. return qq{' . $o->get_title . ''; } return if $field ne 'category'; $cap = ''; $table = 0; $default = ['', $lang->maketext('No Alias')]; # Output a hidden field for this asset. $ret = $m->scomp( '/widgets/profile/hidden.mc', name => $o->key_name . '_id', value => $o->get_id ); } else { $cap = $caption; $table = 1; } return $ret . $m->scomp( '/widgets/select_object/select_object.mc', object => 'category', disp => $cap, name => "category_id", constrain => { site_id => $site_id }, exclude => $excl_sub, req => 1, default => $default, field => 'uri', sort_field => 'uri', useTable => $table, no_persist => 1, ); }; <%shared>; $caption = $lang->maketext("Select a Category"); my $wf_id = get_state_data($widget, 'wf_id'); my $wf = Bric::Biz::Workflow->lookup({ id => $wf_id }); my $gid = $wf->get_all_desk_grp_id; $site_id = $wf->get_site_id; $class_key = get_state_data($widget, 'class_key'); <%init>; # Load 'em on up! my $disp = $dispmap{$class_key} or redirect("/"); my $aliased_id = get_state_data($widget, 'aliased_id'); my $aliased = $classes{$class_key}->lookup({ id => $aliased_id }); # Find any related assets. my (@rel_story, @rel_media); foreach my $rel ($aliased->get_related_objects) { # Keep the related ID. my $ref = ref $rel; if(chk_authz($rel, READ, 1) and chk_authz($ref, CREATE, 0, $site_id, $gid)) { if ($ref->isa('Bric::Biz::Asset::Business::Story')) { push @rel_story, $rel; } else { push @rel_media, $rel; } } } <%def .relateds> <%perl>; my ($key, $rels, $num) = @_; $m->comp('/widgets/wrappers/sharky/table_top.mc', caption => 'Related %n to Alias', object => $key, number => $num ); $m->comp('/widgets/listManager/listManager.mc', object => $key, addition => undef, objs => $rels, fields => [qw(name uri category)], field_titles => { category => $lang->maketext("Alias in Category") }, field_values => $cat_sel, profile => undef, select => undef, ); $m->comp('/widgets/wrappers/sharky/table_bottom.mc');