%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.
%doc>
<%perl>;
# Display the properties
$m->comp("/widgets/wrappers/sharky/table_top.mc",
caption => "Properties",
number => 1);
$m->out($ieSpacer, '
');
# Title
$m->comp('/widgets/profile/displayFormElement.mc',
key => 'title',
vals => $tmeth
);
$m->out($ieSpacer);
# Slug
$m->comp('/widgets/profile/displayFormElement.mc',
key => 'slug',
vals => $smeth
);
$m->out($ieSpacer);
# 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
);
$m->out($ieSpacer);
# Secondary categories
my $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,
);
$m->out($ieSpacer);
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
);
$m->out($ieSpacer);
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,
);
$m->out($ieSpacer);
# 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,
);
$m->out($ieSpacer);
}
}
# Cover date
$m->comp('/widgets/profile/displayFormElement.mc',
key => 'cover_date',
vals => $cmeth,
);
$m->out($ieSpacer, '
');
$m->comp('/widgets/wrappers/sharky/table_bottom.mc');
# Have to use a separate hidden field as IE only sent desk_asset|clone_cb.x
# and .y, but not desk_asset|clone_cb with value=$sid
$m->comp('/widgets/profile/hidden.mc',
name => 'desk_asset|clone_cb',
value => $sid);
$m->comp('/widgets/profile/create_button.html',
widget => '', cb => '');
%perl>
<%args>
$widget
%args>
<%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) };
%once>
<%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::AssetType->lookup({id => $story->get_element__id});
my $agent = detect_agent();
my $ieSpacer = $agent->ie ? qq{
![]() |