<& '/widgets/wrappers/sharky/table_top.mc',
    caption => "Content",
    id      => 'containerprof',
    number  => $num++
&>

<& '/widgets/profile/hidden.mc',
    name    => "$widget|view_cb",
    value   => '',
&>

<table class="containerProf">

  <tr>
      <th><% $lang->maketext('Fields') %></th>
      <th><% $lang->maketext('Values') %></th>
  </tr>

% foreach my $dt (@elements) {
  <tr>
    <td class="name"><% $dt->get_name %>:</td>
%   if ($dt->is_container) {
    <td>

<%perl>
# Find a suitable field of a tile to display
my($disp_buf, $value_buf);
foreach my $field ($dt->get_fields) {
#    next if $field->get_widget_type !~ /^text/;
    if (my $value = $field->get_value) {
        $disp_buf  = $field->get_name;
        $value_buf = substr($value, 0, 64);
        last;
    }
}
</%perl>
% if ($value_buf) {
<% $disp_buf %>: <% escape_html($value_buf) %><br />
% }

<&
    '/widgets/profile/imageSubmit.mc',
      formName  => 'theForm',
      callback  => 'container_prof|view_cb',
      image     => 'view_dgreen',
      value     => $dt->get_id,
      useHidden => 0,
      alt       => 'View',
&>
    </td>
%   } else {
    <td class="fieldcontent">
<pre>
%     my $value = $dt->get_value;
%     $value = $lang->maketext("Not defined.") unless defined $value;
%     $m->out(escape_html($value));
</pre>
    </td>
%   }
  </tr>
% }


% if (!scalar(@elements)) {
  <tr>
    <td colspan="2"><%$lang->maketext('No elements are present.')%></td>
  </tr>
% }

</table>

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

% return $num;

<%args>
$widget
$num => 1
</%args>
<%init>
# the element object
my $element = get_state_data($widget, 'element');

# the contained elements
my @elements = $element->get_elements();
</%init>
