<%doc> This is to display the page after you click Clone in My Workspace. It was mostly copied from edit_new.html and gets called through story_prof.mc. It lets you modify the category, slug, and cover date of the cloned story, using the current values by default. <& '/widgets/wrappers/sharky/table_top.mc', caption => 'Properties', number => 1, &> <& '/widgets/profile/displayFormElement.mc', key => 'title', vals => $tmeth &> <& '/widgets/profile/displayFormElement.mc', key => 'slug', vals => $smeth &> <%perl>; # Category my $cats = Bric::Biz::Category->list({ site_id => $site_id }); $m->comp('/widgets/select_object/select_object.mc', object => 'category', selected => $cat_id, disp => 'Primary Category', name => 'desk_asset|new_category_id', objs => $cats, exclude => $excl_sub, req => 1, field => 'uri', localize => 0, useTable => 1 ); # Secondary categories $cats = Bric::Biz::Category->list({ site_id => $site_id }); $m->comp('/widgets/select_object/select_object.mc', object => 'category', disp => 'Secondary Categories', name => 'desk_asset|secondary_category_id', selected => join('__OPT__', map { $_->get_id } $story->get_secondary_categories), objs => $cats, exclude => $excl_sub, req => 0, size => @$cats < 5 ? scalar @$cats : 5, field => 'uri', localize => 0, useTable => 1, multiple => 1, ); my $ocs = [grep { $_->get_site_id == $site_id } $elem->get_output_channels]; # Output Channel $m->comp('/widgets/select_object/select_object.mc', object => 'output_channel', selected => $oc_id, disp => 'Primary Output Channel', name => 'desk_asset|new_oc_id', objs => $ocs, req => 1, field => 'name', localize => 0, useTable => 1 ); if (@$ocs > 1) { # Secondary Output Channels $m->comp('/widgets/select_object/select_object.mc', object => 'output_channel', selected => join('__OPT__', map { $_->get_id } $story->get_output_channels), disp => 'Secondary Output Channels', name => 'desk_asset|secondary_oc_id', objs => $ocs, req => 0, field => 'name', localize => 0, useTable => 1, multiple => 1, size => @$ocs >= 5 ? 5 : scalar @$ocs, ); # Output Channel groups if (my @grps = grep { chk_authz($_, READ, 1) } Bric::Util::Grp::OutputChannel->list({ obj => ANY(@$ocs), permanent => 0, })) { $m->comp('/widgets/select_object/select_object.mc', object => 'output_channel_grp', disp => 'Output Channel Group', name => 'desk_asset|oc_grp_id', objs => \@grps, default => [''], selected => '', req => 0, field => 'name', useTable => 1, ); } } <& '/widgets/profile/displayFormElement.mc', key => 'cover_date', vals => $cmeth, &> <& '/widgets/wrappers/sharky/table_bottom.mc' &> <& '/widgets/profile/hidden.mc', name => 'desk_asset|clone_cb', value => $sid, &> <& '/widgets/buttons/submit.mc', name => "", &> <%args> $widget <%once>; my $spkg = 'Bric::Biz::Asset::Business::Story'; # Title, Slug, and Cover Date my_meths my $tmeth = { %{ $spkg->my_meths->{title} } }; my $smeth = { %{ $spkg->my_meths->{slug} } }; my $cmeth = { %{ $spkg->my_meths->{cover_date} } }; # listManager exclude my $excl_sub = sub { ! chk_authz($_[0], READ, 1) }; <%init>; my $w_id = get_state_data($widget, 'work_id'); my $wf = Bric::Biz::Workflow->lookup({ id => $w_id }); my $site_id = $wf->get_site_id; # (used pnotes in clone/dhandler because story_prof.mc messes with state_data) my $story = $r->pnotes('cloned_story'); my $sid = $story->get_id; # Default values $tmeth->{value} = 'Clone of ' . $story->get_title; $smeth->{value} = $story->get_slug; $cmeth->{value} = $story->get_cover_date(ISO_8601_FORMAT); my $cat_id = $story->get_primary_category->get_id; my $oc_id = $story->get_primary_oc_id; my $elem = Bric::Biz::ElementType->lookup({id => $story->get_element_type_id});