<%
  import java.util.Locale;
  import java.text.DateFormat;
  import org.exoplatform.portal.webui.util.Util;
  import java.net.URLEncoder;
  
  Locale currentLocale = Util.getPortalRequestContext().getLocale();
%>
<div class="UIAttachmentUploadListForm">
  <% uiform.begin(); %>
    <div class="AttachmentTit"><%= _ctx.appRes("UIAttachmentUploadListForm.label.AttachmentTitle"); %></div>
    <table cellspacing="1" cellpadding="0" border="0" class="UIFormGrid">
      <thead>
        <tr>
          <th><%= _ctx.appRes("UIAttachmentUploadListForm.label.File"); %></th>
          <th style="width: 30%"><%= _ctx.appRes("UIAttachmentUploadListForm.label.Creator"); %></th>
          <th style="width: 150px;"><%= _ctx.appRes("UIAttachmentUploadListForm.label.LastUpdate"); %></th>
          <th style="width:120px;"></th>
        </tr>
      </thead>
      <tbody>
    <%
      attachments = uicomponent.getAttachmentsList();
      int index = 0;
      String rowClass;
      DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, currentLocale);
      String creator;
      String downloadLink;
      String deleteLink;
      for(attachment in attachments){
        index++;
        if(index%2 == 1){
          rowClass = "EvenRow";
        }else{
          rowClass = "OddRow";
        }
        if(attachment.getCreator() == null){
          creator = _ctx.appRes("UIWikiPortlet.label.Anonymous");
        }else{
          creator = attachment.getCreator();
          creator = uicomponent.getFullName(creator);
        }
        downloadLink = attachment.getDownloadURL();
        deleteLink = uicomponent.event(uicomponent.DELETE_ACTION, URLEncoder.encode(attachment.getName(), "UTF-8"));
    %>
        <tr class="$rowClass">
          <td class="Tit"><a title="<%= _ctx.appRes("UIAttachmentUploadListForm.label.DownloadAttachment"); %>" target="_blank" href="$downloadLink"><%= attachment.getFullTitle() %></a></td>
          <td><%= creator %></td>
          <td><%= df.format(attachment.getUpdatedDate().getTime())%></td>
          <td><img title="<%= _ctx.appRes("UIAttachmentUploadListForm.label.RemoveAttachment"); %>" onclick="$deleteLink" alt="" class="RemoveFile" src="/eXoResources/skin/DefaultSkin/background/Blank.gif"/></td>
        </tr>
        
    <%}%>
    
      </tbody>
    </table>
  <% uiform.end();%>
</div>