discourse-legacysite-perl/site/forum/include_attachments.html
2024-06-17 22:24:05 +10:00

74 lines
3.8 KiB
HTML

<%--
The following loops through attachments that are either going to be added with the
post or message, or, when editing, the new ones to add AND the ones that already exist.
The following variables are available:
- att_id - the attachment ID
(in either post, message, or temp attachment directories)
- att_filename - the filename of the attachment
- att_size - the size of the attachment in bytes. Use
<%GForum::Attachment::friendly_size($att_size)%> to get a "friendly" size such as "66.3 KB" instead of "67890".
- att_content - the content type of the file (such as text/html for .html files). Use
<%GForum::Attachment::icon($att_content, $att_filename)%> to get the web path to the appropriate icon.
- att_type - usually 'temp', but will be 'post' for posts that already exist when editing a post
--%>
<%~if attach_mode eq message%>
<%~set show_inline_checkbox = $config.allow_message_inline%>
<%~else%>
<%~set attach_mode = 'post'%>
<%~set show_inline_checkbox = $forum_attachment_inline%>
<%~endif%>
<%~if this_do eq "${attach_mode}_attachment_list"%>
<%~set ADVANCEDEDITOR = 1%>
<%~endif%>
<%~if ADVANCEDEDITOR%>
<script type="text/javascript">
//<![CDATA[
inlineAttachments = [
<%~loop attachments%>
<%~if att_inline%>
<%~if _get_inline_notfirst%>, <%else%><%set _get_inline_notfirst = 1%><%endif~%>
['<%escape_js att_filename%>', '<%att_type%>', '<%att_id%>']
<%~endif%>
<%~endloop%>
];
//]]>
</script>
<%endif~%>
<%if attachments.length or can_attach%>
<div id="attach_table" class="dtable">
<%loop attachments%>
<div class="drow">
<div class="dcell filename">
<img src="<%GForum::Attachment::icon($att_content, $att_filename)%>" alt="" />
<span><%att_filename%></span>
<span><%GForum::Attachment::friendly_size($att_size)%></span>
</div>
<%~if show_inline_checkbox%>
<div class="dcell inline">
<%if att_inline%><input type="hidden" name="att_deinline-<%att_id%>-<%att_type%>" value="1" /><%endif%>
<span title="Inline image attachments can be inserted using <%if ADVANCEDEDITOR%>the Image button<%else%>[inline Filename] tags<%endif%>"><input type="checkbox" id="att_inline-<%att_id%>-<%att_type%>" tabindex="7" name="att_inline-<%att_id%>-<%att_type%>" value="1"<%if att_inline%> checked="checked"<%endif%> class="checkbox"<%if ADVANCEDEDITOR%> onclick="updateInline('<%escape_js att_filename%>', '<%att_type%>', '<%att_id%>', this.checked)"<%endif%> /><label for="att_inline-<%att_id%>-<%att_type%>">Inline</label></span>
</div>
<%~endif%>
<div class="dcell">
<a href="#" onclick="return submitForm(document.getElementById('<%compose_form_id%>'), ['do', '<%attach_mode%>_attachment_delete', 'att_type', '<%att_type%>', 'att_id', '<%att_id%>', 'redo', '<%in.to_redo || $this_do%>'])" class="sprite-delete">Delete attachment</a>
</div>
</div>
<%endloop%>
<%if can_attach%>
<div class="drow">
<div class="dcell filename">
<input type="file" tabindex="7" name="<%if attach_mode eq message%>msg<%else%>post<%endif%>_attachment" class="file" />
</div>
<%~if show_inline_checkbox%>
<div class="dcell inline">
<span title="Inline image attachments can be inserted using <%if ADVANCEDEDITOR%>the Image button<%else%>[inline Filename] tags<%endif%>"><input type="checkbox" tabindex="7" id="<%attach_mode%>_attachment_inline" name="<%attach_mode%>_attachment_inline" value="1" class="checkbox" /><label for="<%attach_mode%>_attachment_inline">Inline</label></span>
</div>
<%~endif%>
<div class="dcell">
<input type="submit" tabindex="7" id="button_attachment" name="do=<%attach_mode%>_attachment_upload;redo=<%in.to_redo || $this_do%>" value="Upload attachment" class="btn" />
</div>
</div>
<%endif%>
</div>
<%endif%>