1
[%# 1.0@bugzilla.org %]
2
[%# The contents of this file are subject to the Mozilla Public
3
# License Version 1.1 (the "License"); you may not use this file
4
# except in compliance with the License. You may obtain a copy of
5
# the License at http://www.mozilla.org/MPL/
7
# Software distributed under the License is distributed on an "AS
8
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
# implied. See the License for the specific language governing
10
# rights and limitations under the License.
12
# The Original Code is the Bugzilla Bug Tracking System.
14
# The Initial Developer of the Original Code is Netscape Communications
15
# Corporation. Portions created by Netscape are
16
# Copyright (C) 1998 Netscape Communications Corporation. All
19
# Contributor(s): Myk Melez <myk@mozilla.org>
20
# Frédéric Buclin <LpSolit@gmail.com>
23
[% PROCESS global/variables.none.tmpl %]
25
[%# Define strings that will serve as the title and header of this page %]
27
Attachment [% attachment.id %] Details for [% terms.Bug %] [%+ attachment.bug_id %]
30
Attachment [% attachment.id %] Details for
31
[%+ "$terms.Bug ${attachment.bug_id}" FILTER bug_link(attachment.bug_id) FILTER none %]
33
[% subheader = BLOCK %][% bugsummary FILTER html %][% END %]
35
[% PROCESS global/header.html.tmpl
41
<script type="text/javascript">
43
var prev_mode = 'raw';
44
var current_mode = 'raw';
46
var has_viewed_as_diff = 0;
47
function editAsComment()
49
// Get the content of the document as a string.
50
var viewFrame = document.getElementById('viewFrame');
51
var aSerializer = new XMLSerializer();
52
var contentDocument = viewFrame.contentDocument;
53
var theContent = aSerializer.serializeToString(contentDocument);
55
// If this is a plaintext document, remove cruft that Mozilla adds
56
// because it treats it as an HTML document with a big PRE section.
57
// http://bugzilla.mozilla.org/show_bug.cgi?id=86012
58
var contentType = '[% attachment.contenttype FILTER js %]';
59
if ( contentType == 'text/plain' )
61
theContent = theContent.replace( /^<html><head\/?><body><pre>/i , "" );
62
theContent = theContent.replace( /<\/pre><\/body><\/html>$/i , "" );
63
theContent = theContent.replace( /</gi , "<" );
64
theContent = theContent.replace( />/gi , ">" );
65
theContent = theContent.replace( /&/gi , "&" );
68
// Add mail-style quote indicators (>) to the beginning of each line.
69
// ".*\n" matches lines that end with a newline, while ".+" matches
70
// the rare situation in which the last line of a file does not end
72
theContent = theContent.replace( /(.*\n|.+)/g , ">$1" );
76
// Copy the contents of the diff into the textarea
77
var editFrame = document.getElementById('editFrame');
78
editFrame.value = theContent + "\n\n";
82
function undoEditAsComment()
84
switchToMode(prev_mode);
86
function redoEditAsComment()
90
[% IF patchviewerinstalled %]
95
// If we have not viewed as diff before, set the view diff frame URL
96
if (!has_viewed_as_diff) {
97
var viewDiffFrame = document.getElementById('viewDiffFrame');
99
'attachment.cgi?id=[% attachment.id %]&action=diff&headers=0';
100
has_viewed_as_diff = 1;
109
function switchToMode(mode)
111
if (mode == current_mode) {
112
alert('switched to same mode! This should not happen.');
116
// Switch out of current mode
117
if (current_mode == 'edit') {
118
hideElementById('editFrame');
119
hideElementById('undoEditButton');
120
} else if (current_mode == 'raw') {
121
hideElementById('viewFrame');
122
[% IF patchviewerinstalled %]
123
hideElementById('viewDiffButton');
125
hideElementById(has_edited ? 'redoEditButton' : 'editButton');
126
hideElementById('smallCommentFrame');
127
} else if (current_mode == 'diff') {
128
[% IF patchviewerinstalled %]
129
hideElementById('viewDiffFrame');
131
hideElementById('viewRawButton');
132
hideElementById(has_edited ? 'redoEditButton' : 'editButton');
133
hideElementById('smallCommentFrame');
136
// Switch into new mode
137
if (mode == 'edit') {
138
showElementById('editFrame');
139
showElementById('undoEditButton');
140
} else if (mode == 'raw') {
141
showElementById('viewFrame');
142
[% IF patchviewerinstalled %]
143
showElementById('viewDiffButton');
145
showElementById(has_edited ? 'redoEditButton' : 'editButton');
146
showElementById('smallCommentFrame');
147
} else if (mode == 'diff') {
148
[% IF patchviewerinstalled %]
149
showElementById('viewDiffFrame');
151
showElementById('viewRawButton');
152
showElementById(has_edited ? 'redoEditButton' : 'editButton');
153
showElementById('smallCommentFrame');
156
prev_mode = current_mode;
160
function hideElementById(id)
162
var elm = document.getElementById(id);
164
elm.style.display = 'none';
168
function showElementById(id, val)
170
var elm = document.getElementById(id);
172
if (!val) val = 'inline';
173
elm.style.display = val;
177
function normalizeComments()
179
// Remove the unused comment field from the document so its contents
180
// do not get transmitted back to the server.
182
var small = document.getElementById('smallCommentFrame');
183
var big = document.getElementById('editFrame');
184
if ( (small) && (small.style.display == 'none') )
186
small.parentNode.removeChild(small);
188
if ( (big) && (big.style.display == 'none') )
190
big.parentNode.removeChild(big);
196
<form method="post" action="attachment.cgi" onsubmit="normalizeComments();">
197
<input type="hidden" name="id" value="[% attachment.id %]">
198
<input type="hidden" name="action" value="update">
199
<input type="hidden" name="contenttypemethod" value="manual">
201
<table class="attachment_info" width="100%">
206
<b><label for="description">Description</label>:</b><br>
207
[% INCLUDE global/textarea.html.tmpl
213
defaultcontent = attachment.description
216
[% IF attachment.isurl %]
217
<input type="hidden" name="filename"
218
value="[% attachment.filename FILTER html %]">
219
<input type="hidden" name="contenttypeentry"
220
value="[% attachment.contenttype FILTER html %]">
222
<b><label for="filename">Filename</label>:</b><br>
223
<input type="text" size="20" id="filename" name="filename"
224
value="[% attachment.filename FILTER html %]"><br>
226
[% IF attachment.datasize %]
227
[%+ attachment.datasize FILTER unitconvert %]
232
<b><label for="contenttypeentry">MIME Type</label>:</b><br>
233
<input type="text" size="20"
234
id="contenttypeentry" name="contenttypeentry"
235
value="[% attachment.contenttype FILTER html %]"><br>
237
<input type="checkbox" id="ispatch" name="ispatch" value="1"
238
[% 'checked="checked"' IF attachment.ispatch %]>
239
<label for="ispatch">patch</label>
241
<input type="checkbox" id="isobsolete" name="isobsolete" value="1"
242
[% 'checked="checked"' IF attachment.isobsolete %]>
243
<label for="isobsolete">obsolete</label>
244
[% IF (Param("insidergroup") && user.in_group(Param("insidergroup"))) %]
245
<input type="checkbox" id="isprivate" name="isprivate" value="1"
246
[% " checked" IF attachment.isprivate %]>
247
<label for="isprivate">private</label><br>
252
[% IF flag_types.size > 0 %]
253
[% PROCESS "flag/list.html.tmpl" bug_id = attachment.bug_id
254
attach_id = attachment.id %]<br>
257
<div id="smallCommentFrame">
258
<b><small><label for="comment">Comment</label> (on the
259
[%+ terms.bug %]):</small></b><br>
260
[% INCLUDE global/textarea.html.tmpl
269
<input type="submit" value="Submit" id="update"><br><br>
270
<strong>Actions:</strong>
271
<a href="attachment.cgi?id=[% attachment.id %]">View</a>
272
[% IF attachment.ispatch && patchviewerinstalled %]
273
| <a href="attachment.cgi?id=[% attachment.id %]&action=diff">Diff</a>
275
[% IF Param("allow_attachment_deletion")
277
&& attachment.datasize > 0 %]
278
| <a href="attachment.cgi?id=[% attachment.id %]&action=delete">Delete</a>
282
[% IF !attachment.datasize %]
283
<td width="75%"><b>The content of this attachment has been deleted.</b></td>
284
[% ELSIF isviewable %]
286
[% INCLUDE global/textarea.html.tmpl
289
style = 'height: 400px; width: 100%; display: none'
294
<iframe id="viewFrame" src="attachment.cgi?id=[% attachment.id %]" style="height: 400px; width: 100%;">
295
<b>You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
296
<a href="attachment.cgi?id=[% attachment.id %]">View the attachment on a separate page</a>.</b>
298
<script type="text/javascript">
300
if (typeof document.getElementById == "function") {
301
[% IF patchviewerinstalled %]
302
document.write('<iframe id="viewDiffFrame" style="height: 400px; width: 100%; display: none;"><\/iframe>');
304
document.write('<button type="button" id="editButton" onclick="editAsComment();">Edit Attachment As Comment<\/button>');
305
document.write('<button type="button" id="undoEditButton" onclick="undoEditAsComment();" style="display: none;">Undo Edit As Comment<\/button>');
306
document.write('<button type="button" id="redoEditButton" onclick="redoEditAsComment();" style="display: none;">Redo Edit As Comment<\/button>');
307
[% IF patchviewerinstalled %]
308
document.write('<button type="button" id="viewDiffButton" onclick="viewDiff();">View Attachment As Diff<\/button>');
310
document.write('<button type="button" id="viewRawButton" onclick="viewRaw();" style="display: none;">View Attachment As Raw<\/button>');
315
[% ELSIF attachment.isurl %]
317
<a href="[% attachment.data FILTER html %]">
318
[% IF attachment.datasize < 120 %]
319
[% attachment.data FILTER html %]
321
[% attachment.data FILTER truncate(80) FILTER html %]
323
[% attachment.data.match(".*(.{20})$").0 FILTER html %]
328
<td id="noview" width="50%">
330
Attachment is not viewable in your browser because its MIME type
331
([% attachment.contenttype FILTER html %]) is not one that your browser is
335
<a href="attachment.cgi?id=[% attachment.id %]">Download the attachment</a>.
344
Attachments on this [% terms.Bug %]:
345
[% FOREACH a = attachments %]
346
[% IF a == attachment.id %]
349
<a href="attachment.cgi?id=[% a %]&action=edit">[% a %]</a>
351
[% " |" UNLESS loop.last() %]
358
[% PROCESS global/footer.html.tmpl %]