% 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: <% $story->get_id %>"><% $story->get_uuid %></dd>
<dt><% $lang->maketext('Title') %>:</dt>
<dd><% $story->get_title %></dd>
<dt><% $lang->maketext('Story Type') %>:</dt>
<dd><% $story->get_element_name %></dd>
<dt><% $lang->maketext('First Published') %>:</dt>
<dd><% $story->get_first_publish_date || '&nbsp;' %></dd>
<dt><% $lang->maketext('Last Published') %>:</dt>
<dd><% $story->get_publish_date || '&nbsp;' %></dd>
<dt><% $lang->maketext('URI') %>:</dt>
% if ($is_related_story) {
<dd><% $prim_uri %></dd>
% } else {
%     if (@ocs == 1) {
<dd><% $m->comp('/widgets/profile/preview_link.mc',
                type  => 'story',
                value => $prim_uri,
                doc   => $story,
                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/story/<% $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 $story = get_state_data($widget, 'asset');
my $cat      = $story->get_primary_category;
my $cat_name = $cat ? $cat->get_name : '';
$header ||= 'Story 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_story = $number != 1;

my $id = $story->get_id();
my $prim_uri = $story->get_primary_uri();

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

my @ocs = $story->get_output_channels();
my $primocid = $story->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>
