<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<webwork:bean name="'com.atlassian.jira.web.bean.LatestFileBean'" id="latestFile" />
<webwork:bean name="'com.atlassian.core.user.UserUtils'" id="userUtils" />

<webwork:if test="/attachments && /attachments/size > 0">
<webwork:bean name="'com.atlassian.core.util.FileSize'" id="sizeFormatter" />
	<tr>
		<td bgcolor=f0f0f0 width=20% valign=top>
			<b><webwork:text name="'common.concepts.attachments.files'"/>:</b>

			<webwork:if test="/attachable == true">
			<br>
			<a href="<%= request.getContextPath() %>/secure/ManageAttachments.jspa?id=<webwork:url value="../long('id')" />"><webwork:text name="'common.concepts.manageattachments'"/></a>
			</webwork:if>
		</td>
		<td bgcolor=ffffff valign=top colspan=5>
			<webwork:if test="/fileAttachments != null && /fileAttachments/size > 0">
                <webwork:property value="@latestFile/setup(/fileAttachments)"/>
                <webwork:iterator value="/fileAttachments" status="'attachmentstatus'">
                    <webwork:if test="@latestFile/latestFile(.) == false">
                      <font color="999999">
                      <webwork:property value="@attachmentstatus/count" />.
					  <a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="id" />/<webwork:property value="urlEncoded(filename)" />"><%@ include file="/includes/icons/attachment.jsp" %></a>
					  <a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="id" />/<webwork:property value="urlEncoded(filename)" />" title="<webwork:property value="/outlookDate/formatDMYHMS(created)" /> - <webwork:property value="@userUtils/user(author)/fullName" />"><font color="999999"><webwork:property value="filename" /></font></a> <font size=-2>(<webwork:property value="@sizeFormatter/format(filesize)"/>)</font><br>
                      </font>

                    </webwork:if>
                    <webwork:else>
                    <webwork:property value="@attachmentstatus/count" />.
					<a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="id" />/<webwork:property value="urlEncoded(filename)" />"><%@ include file="/includes/icons/attachment.jsp" %></a>
					<a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="id" />/<webwork:property value="urlEncoded(filename)" />" title="<webwork:text name="'common.words.latest'"/> <webwork:property value="/outlookDate/formatDMYHMS(created)" /> - <webwork:property value="@userUtils/user(author)/fullName" />"><webwork:property value="filename" /></a> <font size=-2>(<webwork:property value="@sizeFormatter/format(filesize)"/>)</font><br>

                    </webwork:else>
				</webwork:iterator>
				<br>
			</webwork:if>
			<webwork:else>
				<webwork:text name="'common.words.none'"/>
			</webwork:else>
<%--  Provide link:
	- if there are some attachments to look at   OR
	- if you have the ability to add attachments --%>
		</td>
	</tr>

    <webwork:if test="/thumbnails && /thumbnails/size > 0 && /toolkitAvailable() == true">
	<tr>
		<td bgcolor=f0f0f0 width=20% valign=top>
			<b><webwork:text name="'common.concepts.attachments.images'"/>:</b>
		</td>
		<td bgcolor=ffffff valign=top colspan=5>
			<webwork:if test="/thumbnails != null && /thumbnails/size > 0">
                <table width="100%"  border=0 cellpadding=0 cellspacing=2>
				<webwork:iterator value="/thumbnails" status="'thumbnailstatus'">
					<webwork:if test="@thumbnailstatus/modulus(3) == 1" >
                    <tr>
                    </webwork:if>
                    <td align=middle width=33% >
                        <a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="attachmentId" />/<webwork:property value="urlEncoded(filename)" />"><img src="<%= request.getContextPath() %>/secure/thumbnail/<webwork:property value="attachmentId" />/<webwork:property value="urlEncoded(filename)" />" width="<webwork:property value="width"/>" height="<webwork:property value="height" />" ></a>
                            <br>
                        <webwork:property value="@thumbnailstatus/count" />.
                        <webwork:property value="attachmentManager/attachment(./attachmentId)" >
                            <a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="id" />/<webwork:property value="urlEncoded(filename)" />">
                                <webwork:property value="filename" /></a>
                            <br><font size=-2>(<webwork:property value="@sizeFormatter/format(filesize)"/>)</font>
                        </webwork:property>
                    </td>
					<webwork:if test="@thumbnailstatus/modulus(3) == 0" >
                    </tr>
                    </webwork:if>
				</webwork:iterator>
                </table>
			</webwork:if>
			<webwork:else>
				<webwork:text name="'common.words.none'"/>
			</webwork:else>
		</td>
	</tr>
    </webwork:if>

    <webwork:if test="/imageAttachments != null && /imageAttachments/size > 0 && /toolkitAvailable() == false">
    <tr>
		<td bgcolor=f0f0f0 width=20% valign=top>
			<b><webwork:text name="'common.concepts.attachments.images'"/>:</b>
		</td>
		<td bgcolor=ffffff valign=top colspan=5>
				<webwork:iterator value="/imageAttachments" status="'attachmentstatus'">
                    <webwork:property value="@attachmentstatus/count" />.
                    <a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="id" />/<webwork:property value="urlEncoded(filename)" />"><%@ include file="/includes/icons/attachment.jsp" %></a>
                    <a href="<%= request.getContextPath() %>/secure/attachment/<webwork:property value="id" />/<webwork:property value="urlEncoded(filename)" />"><webwork:property value="filename" /></a> <font size=-2>(<webwork:property value="@sizeFormatter/format(filesize)"/>)</font><br>
				</webwork:iterator>
				<br>
                <font color="bb0000"><webwork:text name="'thumbnails.error.display'"/></font>
		</td>
	</tr>
    </webwork:if>
</webwork:if>