%#--- Arguments ---#

<%args>
$widget
$object
$disp_field
$use_form_tag
</%args>

%#--- Initialization ---#
<%init>
my $agent = detect_agent();
my $spacerRow = $agent->ie ? '<img src="/media/images/spacer.gif" width=550 height=3>' : "";

my $advanced_search = get_state_data($widget, 'advanced_search');
$advanced_search = get_pref('Default Search')
  unless defined $advanced_search;
my $sites = $c->get('__SITES__');

unless ($sites) {
    $sites = Bric::Biz::Site->list({ active => 1 });
    $c->set('__SITES__', $sites);
}

$sites = [grep { chk_authz($_, EDIT, 1) } @$sites];
</%init>

% if ($use_form_tag) {
<form action="<% $r->uri %>" method="post">
% }

<table border=0 cellpadding=0 cellspacing=0 width=580>
<tr>
  <td class=darkHeader valign=top width=13><img src="/media/images/666633_curve_left.gif" width=13 height=18></td>
% unless ($advanced_search) {
  <td class=darkHeader width=556><% $lang->maketext('SEARCH')%> [ <a href="<% $r->uri %>?<% $widget %>|set_advanced_cb=1" class="whiteUnderlinedLink"><% $lang->maketext('Advanced Search')%></a> ]</td>
% } else {
  <td class=darkHeader width=556><% $lang->maketext('ADVANCED SEARCH')%> [ <a href="<% $r->uri %>?<% $widget %>|unset_advanced_cb=1" class="whiteUnderlinedLink"><%$lang->maketext('Simple Search')%></a> ]</td>
% }
  <td class=darkHeader valign=top width=13 align=right><img src="/media/images/666633_curve_right.gif" width=13 height=18></td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=580>
<tr>
  <td class=darkHeader><img src="/media/images/spacer.gif" width=1 height=1></td>
  <td class=lightHeader>
<% $spacerRow %>
            <table>
% unless ($advanced_search) {
              <tr>
                <td>
                  <& /widgets/profile/text.mc, 
                     name     => $widget.'|simple',
                     value    => get_state_data($widget, 'simple') || '',
                     useTable => 0 &>
                </td>
                <td>
%# This hidden field is required to make the form submit when the user hits
%# the "enter" key.
                  <input type="hidden" name="<% $widget %>|formatting_cb" value="Search" />
                  <input type="image" src="/media/images/<% $lang_key %>/search_red.gif" border=0 name="<% $widget %>|formatting_cb" value="Search">
                </td>
% } else {
              <tr>
                <td align=right><span class=label><%$lang->maketext('Name')%>:</span></td>
                <td>
                  <& /widgets/profile/text.mc, 
                     name     => $widget.'|name',
                     value    => get_state_data($widget, 'name') || '',
                     useTable => 0 &>
                </td>
              </tr>             
              <tr>
                <td align=right><span class=label><%$lang->maketext('File Name')%>:</span></td>
                <td>
                  <& /widgets/profile/text.mc, 
                     name     => $widget.'|file_name',
                     value    => get_state_data($widget, 'file_name') || '',
                     useTable => 0 &>
                </td>
              </tr>
% my $site_id = $c->get_user_cx(get_user_id);
% my ($one_site, $oc_name_getter);
% if (get_pref("Filter by Site Context")) {
%     $one_site = 1;
<& /widgets/profile/hidden.mc,
   name => "$widget|site_id",
   value => $site_id &>
% } elsif (@$sites > 1) {
<%perl>;
my $ng = Bric::Biz::OutputChannel->my_meths->{name}{get_meth};
my $sg = Bric::Biz::OutputChannel->my_meths->{site}{get_meth};
$oc_name_getter = sub {
    my $o = shift;
    return $ng->($o) . ' (' . $sg->($o) . ')';
};
</%perl>\
%     $one_site = 
              <tr>
                <td align="right"><span class=label><% $lang->maketext('Site') %>:</span></td>
                <td>
                  <& /widgets/profile/select.mc,
                     name     => $widget.'|site_id',
                     value    => get_state_data($widget, 'site_id') || '',
                     options  => [ [ '' => $lang->maketext('All Sites') ],
                                   map { [$_->get_id => $_->get_name] } @$sites ],
                     localize => 0,
                     useTable => 0 &>
                </td>
              </tr>
% } else {
%     $one_site = 1;
% }
              <tr>
                <td align="right"><span class=label><% $lang->maketext('Output Channel') %>:</span></td>
                <td>
                  <& /widgets/select_object/select_object.mc,
                     object => 'output_channel',
                     field  => 'name',
                     constrain => { active => 1, $one_site ? (site_id => $site_id) : () },
                     no_persist => 1,
                     name   => "$widget|output_channel_id",
                     useTable => 0,
                     default => ['', $lang->maketext('All Output Channels')],
                     getter => $oc_name_getter,
                  &>
                </td>
              </tr>
              <tr>

                <td colspan=2><span class=label><% $lang->maketext('Cover Date') %></span><br />
                  <% $lang->maketext('From') %>:
                  <& '/widgets/select_time/select_time.mc', 
                     base_name  => "$widget|cover_date_start",
                     indent     => 1,
                     no_hour    => 1,
                     no_min     => 1,
                     repopulate => 0,
                     def_date   => get_state_data($widget, 'cover_date_start')||'',,
                     compact    => 1,
                     style      => 'inline',
                  &>
                  <% $lang->maketext('To') %>:
                  <& '/widgets/select_time/select_time.mc', 
                     base_name  => "$widget|cover_date_end",
                     indent     => 1,
                     no_hour    => 1,
                     no_min     => 1,
                     repopulate => 0,
                     def_date   => get_state_data($widget, 'cover_date_end')||'',,
                     compact    => 1,
                     style      => 'inline',
                  &>
                </td>
              </tr>
              <tr>
                <td colspan=2><span class=label><% $lang->maketext('Publish Date') %></span><br />
                  <% $lang->maketext('From') %>:
                  <& '/widgets/select_time/select_time.mc', 
                     base_name  => "$widget|publish_date_start",
                     indent     => 1,
                     no_hour    => 1,
                     no_min     => 1,
                     repopulate => 0,
                     def_date   => get_state_data($widget, 'publish_date_start')||'',,
                     compact    => 1,
                     style      => 'inline',
                  &>
                  <% $lang->maketext('To') %>:
                  <& '/widgets/select_time/select_time.mc', 
                     base_name  => "$widget|publish_date_end",
                     indent     => 1,
                     no_hour    => 1,
                     no_min     => 1,
                     repopulate => 0,
                     def_date   => get_state_data($widget, 'publish_date_end')||'',,
                     compact    => 1,
                     style      => 'inline',
                  &>
                </td>
              </tr>
              <tr>
                <td colspan=2><span class=label><% $lang->maketext('Expire Date') %></span><br />
                  <% $lang->maketext('From') %>:
                  <& '/widgets/select_time/select_time.mc', 
                     base_name  => "$widget|expire_date_start",
                     indent     => 1,
                     no_hour    => 1,
                     no_min     => 1,
                     repopulate => 0,
                     def_date   => get_state_data($widget, 'expire_date_start')||'',,
                     compact    => 1,
                     style      => 'inline',
                  &>
                  <% $lang->maketext('To') %>:
                  <& '/widgets/select_time/select_time.mc', 
                     base_name  => "$widget|expire_date_end",
                     indent     => 1,
                     no_hour    => 1,
                     no_min     => 1,
                     repopulate => 0,
                     def_date   => get_state_data($widget, 'expire_date_end')||'',,
                     compact    => 1,
                     style      => 'inline',
                  &>
                </td>
              </tr>
% }
            </table>
  </td>
  <td class=darkHeader><img src="/media/images/spacer.gif" width=1 height=1></td>
</tr>
<tr>
  <td class=darkHeader width=580 colspan=2><img src="/media/images/spacer.gif" width=580 height=1></td>
</tr>
</table>
% if ($advanced_search) {
<p></p>
<input type="image" src="/media/images/<% $lang_key %>/search_lgreen.gif" border=0 name="<% $widget %>|formatting_cb" value="Search">
<input type="image" src="/media/images/<% $lang_key %>/clear_values_lgreen.gif" border=0 name="<% $widget %>|clear_cb" value="Clear Values">
% }
%#--- Log History ---#
% if ($use_form_tag) {
</form>
% }

