% if ($frame) {
<& /widgets/wrappers/sharky/table_top.mc,
   caption => $header,
   number  => $number
&>
% }
<div style="float: right;"><% $button %></div>
<dl class="viewmeta">
<dt><% $lang->maketext('UUID') %>:</dt>
<dd title="ID: <% $media->get_id %>"><% $media->get_uuid %></dd>
<dt><% $lang->maketext('Title') %>:</dt>
<dd><% $media->get_title %></dd>
<dt><% $lang->maketext('Media Type') %>:</dt>
<dd><% $media->get_element_name %></dd>
<dt><% $lang->maketext('First Published') %>:</dt>
<dd><% $media->get_first_publish_date || '&nbsp;' %></dd>
<dt><% $lang->maketext('Last Published') %>:</dt>
<dd><% $media->get_publish_date || '&nbsp;' %></dd>
<dt><% $lang->maketext('URI') %>:</dt>
% if (@ocs == 1) {
<dd><% $m->comp('/widgets/profile/preview_link.mc',
                type  => 'media',
                value => $prim_uri,
                doc   => $media,
                style => 'blackUnderlinedLink') %></dd>
%     } else {
<dd><% $prim_uri %></dd>
<dt><% $lang->maketext('Preview in') %>:</dt>
<dd><% $oc_select %>&nbsp;<a href="#" onClick="window.open('/workflow/profile/preview/media/<% $id %>/' + window.document.theForm.ocSelect.options[window.document.theForm.ocSelect.selectedIndex].value, 'preview_<% SERVER_WINDOW_NAME %>');return false;"><img src="/media/images/<% $lang_key %>/preview_lgreen.gif" alt="Preview" border="0" width="74" height="20"></a></dd>
% }
</dl>

% if ($frame) {
<& /widgets/wrappers/sharky/table_bottom.mc &>
%}
<%args>
$widget
$header => undef
$number => undef
$frame  => undef
$button => "&nbsp;"
</%args>

<%init>;
my $media = get_state_data($widget, 'asset');
my $cat      = $media->get_category;
my $cat_name = $cat ? $cat->get_name : '';
$header ||= 'Media Information';

# see whether we're at the top of the page or not;
# otherwise, we won't show the "Preview in" line
my $is_related_media = $number != 1;

my $id = $media->get_id();
my $prim_uri = $media->get_uri();

# get output channel info
my $at = $media->get_element_type_id;
my $asset_type = Bric::Biz::ElementType->lookup({id => $at});

my @ocs = $media->get_output_channels();
my $primocid = $media->get_primary_oc_id;

my $oc_select = '<select name="ocSelect">';
foreach my $oc (@ocs) {
    my $ocid = $oc->get_id;
    my $selected = $ocid == $primocid ? ' selected' : '';
    $oc_select .= qq{<option value="$ocid" $selected>} . $oc->get_name . '</option>';
}
$oc_select .= '</select>';
</%init>
