<input type="hidden" name="<% $widget %>|update_cb" value="1">

<%perl>
my $rightText = $m->scomp( '/widgets/profile/imageSubmit.mc',
  formName => "theForm",
  callback => $widget . "|trail_cb",
  image    => "view_trail_teal"
) . '&nbsp;';

$rightText .= $m->scomp( '/widgets/profile/imageSubmit.mc',
  formName => "theForm",
  callback => $widget . "|notes_cb",
  image    =>  %{ $story->get_notes } ? 'note_fill' : "note",
  useGlobalImage => 1,
  value    => 'edit'
);

$m->comp("/widgets/wrappers/sharky/table_top.mc",
         caption => "Information",
         number  => $num++,
         id      => 'storyinfo',
         rightText => $rightText

);

</%perl>
<table border="0" width="578" cellpadding="0" cellspacing="0">
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('ID') %>:&nbsp;</span></td>
  <td width="470">&nbsp;<% $id %></td>
  </tr>
  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('Story Type Element') %>:&nbsp;</span></td>
  <td width="470">&nbsp;<% $story->get_element_name %></td>
  </tr>
  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('Current Version') %>:&nbsp;</span></td>
  <td width="470">&nbsp;<% $story->get_current_version %></td>
  </tr>
  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('Published Version') %>:&nbsp;</span></td>
  <td width="470">&nbsp;<% $story->get_published_version || '' %></td>
  </tr>
  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('First Published') %>:&nbsp;</span></td>
  <td width="470">&nbsp;<% $story->get_first_publish_date || '' %></td>
  </tr>
  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('Last Published') %>:&nbsp;</span></td>
  <td width="470">&nbsp;<% $story->get_publish_date || '' %></td>
  </tr>

  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('URI') %>:&nbsp;</span></td>
% if (@ocs == 1) {
  <td width="470">&nbsp;<% $m->comp('/widgets/profile/preview_link.mc',
                                    type  => 'story',
                                    title => $story->get_primary_uri,
                                    doc   => $story,
                                    style => 'blackUnderlinedLink') %></td>
% } else {
  <td width="470">&nbsp;<% $story->get_primary_uri %></td>
  </tr>
  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('Preview in') %>:&nbsp;</span></td>
  <td width="470" valign="middle">&nbsp;<% $oc_select %>&nbsp;<%
                           $m->comp('/widgets/profile/preview_link.mc',
                                    type  => 'story',
                                    title => $story->get_primary_uri,
                                    doc   => $story,
                                    oc_js => 'window.document.theForm.ocSelect.options[window.document.theForm.ocSelect.selectedIndex].value',
                                    style => 'blackUnderlinedLink') %></td>
% }
  </tr>
  <tr>
  <td bgcolor="white"><img src="/media/images/spacer.gif" width="1" height="1" /></td>
  </tr>
  <tr>
  <td class="medHeader"><img src="/media/images/spacer.gif" height="18" width="1" /></td>
  <td width="<% $infoIndent %>" align="right" class="medHeader"><span class="label"><% $lang->maketext('Site') %>:&nbsp;</span></td>
  <td width="470">&nbsp;<% Bric::Biz::Site->lookup({id => $story->get_site_id})->
  get_name() %></td>
  </tr>
  <tr>
  <td class="medHeader" colspan=3><img src="/media/images/spacer.gif" height="1" width="1" /></td>
  </tr>
</table>

<% $ieSpacer %>

<& '/widgets/select_object/select_object.mc',
  object   => 'source',
  name     => "$widget|source__id",
  field    => 'source_name',
  selected => $story->get_source__id,
  indent   => 0,
  useTable => 1,
  disp     => "Source"
&>

<% $ieSpacer %>

<& '/widgets/profile/displayFormElement.mc',
   objref => $story,
   key => 'priority',
&>

<% $ieSpacer %>

<& '/widgets/profile/displayFormElement.mc',
   objref => $story,
   key => 'title',
&>

<% $ieSpacer %>

<& '/widgets/profile/displayFormElement.mc',
   objref => $story,
   key => 'description',
&>

<% $ieSpacer %>

<& '/widgets/profile/displayFormElement.mc',
   vals => $slug_vals,
   key => 'slug',
&>

<% $ieSpacer %>

<& '/widgets/profile/displayFormElement.mc',
   objref => $story,
   key => 'cover_date',
&>

<% $ieSpacer %>

<& '/widgets/profile/displayFormElement.mc',
   objref => $story,
   key => 'expire_date',
&>

<% $ieSpacer %>
<%perl>;
$m->comp("/widgets/wrappers/sharky/table_bottom.mc");

$num = $m->comp('/widgets/container_prof/container_prof.mc',
        tile            => $tile,
        tile_type       => 'story',
        action          => $story->get_alias_id ? 'view' : 'edit',
        title           => 'Content',
        num             => $num,
        start_count     => 4
);

</%perl>
<%doc>

We might want to actually put the categories in using listManager instead.
The only issue is having the addition argument put up a button instead of a
link. Here is a starter:

<%perl>;$repeatable_opts
my $cats = $story->get_categories;
    $m->comp('/widgets/listManager/listManager.mc',
             object => 'category',
             userSort => 0,
             objs => $cats,
             title => '%n',
#            addition => $no_edit ? undef : ['Add', "/admin/profile/action?dest_id=$id"],
#            constrain => { server_type_id => $id },
             fields => [qw(name)],
             profile => undef,
             select =>  ['Delete', "$widget|delete_cat"],
             number => $num
            );
</%perl>
<br />

</%doc>

% unless (ENABLE_CATEGORY_BROWSER) {
% $m->comp("/widgets/wrappers/sharky/table_top.mc",
%        caption => "Categories",
%        number  => $num++);

% my @cat = $story->get_categories;
% my $primary = $story->get_primary_category();
% my $p_id    = $primary ? $primary->get_id : '';
% my $rowspan = scalar (@cat) + 2;

<table border=0 cellpadding=0 cellspacing=0 width=578>
<tr>
  <td width=20 class="medHeader"><img src="/media/images/spacer.gif" width="20" height="20" /></td>
  <td width=100 class="medHeader"><span class="label"><% $lang->maketext('Name') %></span></td>
  <td width=1><img src="/media/images/spacer.gif" width="1" height="20" /></td>
  <td width=300 class="medHeader"><span class="label"><% $lang->maketext('URI') %></span></td>
  <td width=1><img src="/media/images/spacer.gif" width="1" height="20" /></td>
  <td width=80 class="medHeader" align="center"><span class="label"><% $lang->maketext('Primary') %></span></td>
  <td width=1><img src="/media/images/spacer.gif" width="1" height="20" /></td>
  <td width=1 rowspan=<% $rowspan %> class="medHeader"><img src="/media/images/spacer.gif" width="1" height="20" /></td>
  <td width=75 class="medHeader" align="center"><span class="label" align="center"><% $lang->maketext('Delete') %></span></td>
</tr>

% # BEGIN FOREACH CAT
% my $curr_cats = {};
% foreach (sort { $a->get_uri cmp $b->get_uri } @cat) {
%     my $cat_id = $_->get_id;
%     $curr_cats->{$cat_id} = 1;
  <tr>
    <td width=20><img src="/media/images/spacer.gif" width="20" height="20" /></td>
    <td colspan="2"><% $_->get_name %></td>
    <td colspan="2"><% $_->get_uri %></td>
    <td colspan=2 align="center"><input type="radio" name="<% $widget %>|primary_cat" value="<% $_->get_id %>" <% $cat_id == $p_id ? 'CHECKED' : '' %>></td>
    <td align="center">
% if ($cat_id != $p_id) {
<& '/widgets/profile/checkbox.mc',
        name => "$widget|delete_cat",
        value => $_->get_id
&>
% }
&nbsp;
    </td>
  </tr>
% }
% # END FOREACH CAT


% if (!@cat) {
<tr>
  <td colspan=5><% $lang->maketext('This story has not been assigned to a category.')%></td>
</tr>
% } else {

<tr>
  <td align="right" colspan=8>&nbsp;</td>
  <td align="center" valign="middle"><input type="image" src="/media/images/<% $lang_key %>/delete_red.gif" border=0 vspace=3 name="<% $widget %>|delete_cat_cb" value="Delete Categories"></td>
</tr>
% }

</table>
% # Create the subroutine to exclude categories.
% my $excl_sub = sub { $curr_cats->{$_[0]->get_id} || ! chk_authz($_[0], READ, 1) };

<table border=0 cellpadding=0 cellspacing=0 width=578>
<tr class=medHeader>
  <td align="right" width=<% FIELD_INDENT - 10 %>><&
  '/widgets/profile/imageSubmit.mc',
             formName => "theForm",
             callback => "$widget|add_category_cb",
             image    => "add_category_lgreen",
             vspace   => 3,
             hspace   => 2
&></td>
  <td width=<% 588 - FIELD_INDENT %> valign="middle">
<& '/widgets/select_object/select_object.mc', 
        object => 'category',
        name => "$widget|new_category_id",
        constrain => { site_id => $story->get_site_id },
        exclude => $excl_sub,
        field => 'uri',
        sort_field => 'uri',
        useTable => 0
&>
  </td>
</tr>
</table>

<%perl>;
$m->comp("/widgets/wrappers/sharky/table_bottom.mc");

}   # unless ENABLE_CATEGORY_BROWSER

if (ENABLE_OC_ASSET_ASSOCIATION) {
    $m->comp('/widgets/profile/asset_ocs.mc',
             asset  => $story,
             widget => $widget,
             ocs    => \@ocs,
             num    => $num++,
             at_ocs => \@aocs
         );
}

$m->out("$ieSpacer<br />\n");

$m->comp("/widgets/wrappers/sharky/table_top.mc",
       caption => "Associations",
       number  => $num++);
</%perl>
<table border=0 width=578 cellpadding=0 cellspacing=0>
<tr>
  <td width=20 class="medHeader"><img src="/media/images/spacer.gif" width="20" height="20" /></td>
  <td width=100 class="medHeader"><span class="label"><% $lang->maketext('Type') %></span></td>
  <td width=1><img src="/media/images/spacer.gif" width="1" height="20" /></td>
  <td width=376 class="medHeader"><span class="label">&nbsp;<% $lang->maketext('Values') %></span></td>
  <td width=1><img src="/media/images/spacer.gif" width="1" height="20" /></td>
  <td width=80 class="medHeader" align="center"><span class="label">&nbsp;<% $lang->maketext('Action') %></span></td>
</tr>
</table>

% if (ENABLE_CATEGORY_BROWSER) {
<table border=0 width=578 cellpadding=0 cellspacing=0>
<tr>
  <td width=120 align=right valign=top><span class=label><% $lang->maketext('Categories') %>:&nbsp;</span></td>
  <td width=378 valign=top>
<%perl>
my @cats;
my $primary_cat_uri = $story->get_primary_category->get_uri;
push @cats, $primary_cat_uri;
foreach my $cat ($story->get_secondary_categories) {
    push @cats, $cat->get_uri;
}
$m->out(scalar(@cats) ? join('<br />', @cats) : $lang->maketext("No categories defined."));
</%perl>
  </td>
  <td width=80 align="center" valign=top><& '/widgets/profile/imageSubmit.mc',
             formName => "theForm",
             callback => "$widget|categories_cb",
             image    => "edit_lgreen",
             vspace   => 4
&></td>
</tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="578">
<tr><td class="medHeader"><img src="/media/images/spacer.gif" width="578" height="1" /></td></tr>
</table>

% }   # if ENABLE_CATEGORY_BROWSER

<table border=0 width=578 cellpadding=0 cellspacing=0>
<tr>
  <td width=120 align=right valign=top><span class=label><% $lang->maketext('Keywords') %>:&nbsp;</span></td>
  <td width=378 valign=top>
<%perl>
my @keywords;
foreach my $kw ($story->get_keywords) {
    push @keywords, $kw->get_name;
}

$m->out(scalar(@keywords) ? join(", ", @keywords) : $lang->maketext("No keywords defined."));

</%perl>
  </td>
  <td width=80 align="center" valign=top><& '/widgets/profile/imageSubmit.mc',
             formName => "theForm",
             callback => "$widget|keywords_cb",
             image    => "edit_lgreen",
             vspace   => 4
&></td>
</tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="578">
<tr><td class="medHeader"><img src="/media/images/spacer.gif" width="578" height="1" /></td></tr>
</table>

<table border=0 cellpadding=0 cellspacing=0 width=578>
<tr>
  <td align="right" width="120" valign="top"><span class="label"><% $lang->maketext('Contributors') %>:&nbsp;</span></td>
  <td width="378" valign="top">

<%perl>
my @contribs;
foreach my $cntr ($story->get_contributors) {
    push @contribs,  $cntr->get_name;
}
$m->out(scalar(@contribs) ? join(", ", @contribs) : $lang->maketext("No contributors defined."));

</%perl>
  </td>
  <td width="80" align="center" valign="top">
% if ($story->get_alias_id) {
<img src="/media/images/spacer.gif" height="20" />
% } else {
<& /widgets/profile/imageSubmit.mc,
   formName => "theForm",
   callback => $widget . "|contributors_cb",
   image    => "edit_lgreen",
   vspace   => 3
&>
% }
</td>
</tr>
</table>
<%perl>

$m->comp("/widgets/wrappers/sharky/table_bottom.mc");

$m->comp("/widgets/profile/buttonBar.mc",
         widget      => $widget,
         desks       => $desks,
         cd          => $cd,
         obj         => $story,
);

</%perl>
<%args>
$widget
</%args>
<%init>
my $story   = get_state_data($widget, 'story');
my $tile    = $story->get_tile();
my $id = $story->get_id;
my $wf_id = get_state_data($widget, 'work_id');
$wf_id = $story->get_workflow_id() unless $wf_id;
my $wf = Bric::Biz::Workflow->lookup( { id => $wf_id });
my $desks = $wf->allowed_desks();
my $cd = $story->get_current_desk();
$cd = $wf->get_start_desk() unless $cd;
my $agent = detect_agent();
my $infoIndent = $agent->nav4 ? FIELD_INDENT - 5 : FIELD_INDENT + 8;
my $ieSpacer = $agent->ie ? qq{<table><tr><td><img src="/media/images/spacer.gif" width=578 height=5 /></td></tr></table>} : '';
my $num = 1;

# get output channel info
my $at = $story->get_element__id;
my $asset_type = Bric::Biz::AssetType->lookup({id => $at});
my @aocs = $asset_type->get_output_channels;
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>';

# Set slug required if it is
my $slug_req = 0;
unless (ALLOW_SLUGLESS_NONFIXED || $story->is_fixed) {
    # This isn't a Cover (it's non-fixed) and ALLOW_SLUGLESS_NONFIXED
    # is false, so we make slug required
    $slug_req = 1;
}
my $slug_vals = {
    %{ Bric::Biz::Asset::Business::Story->my_meths->{slug} },
    value => $story->get_slug,
    req => $slug_req,
};
</%init>
