% # Do paging
% if ($num_pages) {
% } # if $num_pages
<& /widgets/buttons/submit.mc,
disp => $chk_label,
widget => $widget,
cb => $chk_cb . '_cb',
button => $chk_cb . '_assets_' . $color1,
useTable => 0 &>
<& /widgets/buttons/submit.mc,
disp => 'Check All',
name => 'checkall',
button => 'select_all_lgreen',
js => qq{onclick="checkAll('} . $checkbox_name . qq{'); return false"},
useTable => 0 &>
<& /widgets/buttons/submit.mc,
disp => $act_label,
widget => $widget,
cb => $act_cb . '_cb',
button => $act_label,
useTable => 0 &>
<%args>
$widget
$wf => undef
$desk => undef
$w_id => undef
$d_id => undef
$offset => 0
$show_all => undef
%args>
<%init>
# desk_asset matches Callback/Desk.pm class_key
my $d = $r->pnotes('desk_asset.objs'); # from desk.mc
$d->{story} ||= []; $d->{media} ||= []; $d->{template} ||= [];
my $num_objs = @{$d->{story}} + @{$d->{media}} + @{$d->{template}};
return unless $num_objs;
$wf ||= Bric::Biz::Workflow->lookup({ id => $w_id }) if defined $w_id;
$desk ||= Bric::Biz::Workflow::Parts::Desk->lookup({ id => $d_id }) if defined $d_id;
my ($chk_label, $chk_cb, $act_label, $act_cb);
if ($desk) {
$chk_label = 'Move Assets';
$chk_cb = 'move';
} else {
$chk_label = 'Check In Assets';
$chk_cb = 'checkin';
}
if ($desk && $desk->can_publish) {
if ($wf && $wf->get_type == TEMPLATE_WORKFLOW) {
$act_label = 'deploy_checked_red';
$act_cb = 'deploy';
} else {
$act_label = 'publish_checked_red';
$act_cb = 'publish';
}
} else {
$act_label = 'delete_checked_red';
$act_cb = 'delete';
}
my $color1 = ($chk_cb eq 'move') ? 'lgreen' : 'red';
my $color2 = ($act_cb) ? 'red' : 'red';
my $mod = ($chk_cb eq 'move') ? 'assets': 'checked';
my $checkbox_name = $act_cb eq 'delete' ? '_delete_ids' : 'desk_asset|';
# Paging
my $limit = get_pref('Search Results / Page');
my $num_pages = ($num_objs <= $limit)
? 0
: $limit
? int($num_objs / $limit)
: 0;
my $style = q{style="border-style:solid; border-color:#cccc99;"};
my $colspan = $show_all ? '' : 'colspan="2"';
my $url = $r->uri;
my $prev_offset = $offset ? $offset - $limit : 0;
my $next_offset = $offset + $limit;
$next_offset = $num_pages * $limit if $next_offset > $num_objs;
my ($prev_link, $next_link) = ('', '');
if ($offset) {
$prev_link = qq{«};
}
unless ($offset == $num_pages * $limit) {
$next_link = qq{»};
}
%init>