<%perl>
# Show the story summary if needed.
if ($show_summary) {
    my $type  = $tile->get_object_type;

    # Nab the story from the story_prof widget 
    my $asset = get_state_data($type.'_prof', $type);
    $m->comp('/widgets/summary/summary.mc', asset => $asset, number => ++$i);
}
</%perl>

<& '/widgets/wrappers/sharky/table_top.mc',
   caption => $lang->maketext("[_1] Field Text",$field),
   id      => 'containerprof',
   number  => ++$i,
&>

<& '/widgets/profile/textarea.mc', 'name'  => $widget.'|text',
                                   'rows'  => $rows,
                                   'cols'  => $cols,
                                   'value' => $text &>
<table>
<tr>
<td>
<img src="/media/images/spacer.gif" width=10 height=1>
</td>
<td>
<& '/widgets/profile/text.mc', 'name'    => $widget.'|cols',
	                       'value'   => "$cols",
	                       'size'     => 3,
                               'useTable' => 0 &>
</td>
<td>
<%$lang->maketext('Columns')%>&nbsp;
</td>
<td>
<& '/widgets/profile/text.mc', 'name'    => $widget.'|rows',
	                       'value'   => "$rows",
	                       'size'     => 3,
                               'useTable' => 0 &>
</td>
<td>
<%$lang->maketext('Rows')%>
</td>
<td>
<input type="image" src="/media/images/<% $lang_key %>/resize_lgreen.gif" border=0 name="<% $widget %>|resize_cb" value="Resize">
</td>
</tr>
</table>

<& '/widgets/wrappers/sharky/table_bottom.mc' &>

<& '/widgets/wrappers/sharky/table_top.mc',
   caption => 'Separator String',
   number  => ++$i,
&>

<table>
<tr>
<td>
<img src="/media/images/spacer.gif" width=10 height=1>
  </td>
<td>
<& '/widgets/profile/radio.mc', 'name'    => $widget.'|separator',
                                'value'   => "\n",
                                'checked' => $sep eq "\n" &>
<%$lang->maketext('One blank line')%>
</td>
<td>
<& '/widgets/profile/radio.mc', 'name'    => $widget.'|separator',
                                'value'   => '<p>',
                                'checked' => $sep eq '<p>' &>
&lt;p>
</td>
<td>
<& '/widgets/profile/radio.mc', 'name'    => $widget.'|separator',
                                'value'   => '<br>',
                                'checked' => $sep eq '<br>' &>
&lt;br>
</td>
<td>
<& '/widgets/profile/radio.mc', 'name'    => $widget.'|separator',
                                'value'   => 'custom',
                                'checked' => $use_custom_sep &>
<input type="text" name="<% $widget %>|custom_sep" value="<% $custom_sep %>" size=3>
&nbsp;
</td>
<td>
<input type="image" src="/media/images/<% $lang_key %>/change_red.gif" border=0  name="<% $widget %>|change_sep_cb" value="Change">
</td></tr></table>

<& '/widgets/wrappers/sharky/table_bottom.mc' &>

<& '/widgets/wrappers/sharky/table_top.mc',
   caption => 'Statistics',
   number  => ++$i,
&>
<table>
<tr>
<td>
<img src="/media/images/spacer.gif" width=10 height=1>
</td>
<td><%$lang->maketext('Words')%><br /><input type="text" name="words" size=5 value="<% $words %>" /></td>
<td><%$lang->maketext('Characters')%><br /><input type="text" name="chars" size=5 value="<% $bytes %>" /></td>
  <td><a href="#" onClick="return wordCount(document.theForm, '<% $widget . "|text" %>', 'words', 'chars')"><img src="/media/images/<% $lang_key %>/recount_lgreen.gif" border=0></a></td>
</tr>
</table>
<& '/widgets/wrappers/sharky/table_bottom.mc' &>

<input type="image" src="/media/images/<% $lang_key %>/save_red.gif" border=0 name="<% $widget %>|bulk_save_and_up_cb">
<input type="image" src="/media/images/<% $lang_key %>/save_and_stay_lgreen.gif" border=0 name="<% $widget %>|bulk_save_cb">
<input type="image" src="/media/images/<% $lang_key %>/cancel_red.gif" border=0 name="<% $widget %>|bulk_up_cb" value="Return without Saving">

<%args>
$widget
$show_summary
</%args>

<%init>
# the tile object
my $tile       = get_state_data($widget, 'tile');
my $field      = get_state_data($widget, 'field');
my $data       = get_state_data($widget, 'data');
my $sep        = get_state_data($widget, 'separator');
my $custom_sep = get_state_data($widget, 'custom_sep');
my $cols       = get_state_data($widget, 'cols');
my $rows       = get_state_data($widget, 'rows');

# Create the text blob
my $split = $sep eq "\n" ? '' : $sep;
my $text = join("\n$split\n", @$data);

my ($i, $words, $bytes, @tmp);

foreach (@$data) {
    $words += scalar(@tmp = /\S+/g);
    $bytes += length;
}

my $use_custom_sep = get_state_data($widget, 'use_custom_sep') || 0;

</%init>
