summaryrefslogtreecommitdiffstats
path: root/template/en/default/attachment/list.html.tmpl
blob: 97fd2dc9519969a6dca6187fb2294c84daf933b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[% RETURN UNLESS attachments.size || Param("maxattachmentsize") || Param("maxlocalattachment") %]

<script type="text/javascript">
<!--
function toggle_display(link) {
    var table = document.getElementById("attachment_table");
    var view_all = document.getElementById("view_all");
    var hide_obsolete_url_parameter = "&hide_obsolete=1";
    // Store current height for scrolling later
    var originalHeight = table.offsetHeight;
    var rows = YAHOO.util.Dom.getElementsByClassName(
        'bz_tr_obsolete', 'tr', table);

    for (var i = 0; i < rows.length; i++) {
        bz_toggleClass(rows[i], 'bz_default_hidden');
    }

    if (YAHOO.util.Dom.hasClass(rows[0], 'bz_default_hidden')) {
        link.innerHTML = "Show Obsolete";
        view_all.href = view_all.href + hide_obsolete_url_parameter 
    }
    else {
        link.innerHTML = "Hide Obsolete";
        view_all.href = view_all.href.replace(hide_obsolete_url_parameter,"");
    }

    var newHeight = table.offsetHeight;
    // This scrolling makes the window appear to not move at all.
    window.scrollBy(0, newHeight - originalHeight);

    return false;
}
//-->
</script>

<br>
<table id="attachment_table">
  <tr id="a0">
    <th colspan="[% show_attachment_flags ? 3 : 2 %]" class="left">
      Attachments
    </th>
  </tr>

  [% count = 0 %]
  [% obsolete_attachments = 0 %]
  [% user_cache = template_cache.users %]

  [% FOREACH attachment = attachments %]
    [% count = count + 1 %]
    [% IF !attachment.isprivate || user.is_insider || attachment.attacher.id == user.id %]
      [% IF attachment.isobsolete %]
        [% obsolete_attachments = obsolete_attachments + 1 %]
      [% END %]
      <tr id="a[% count %]" class="[% "bz_contenttype_" _ attachment.contenttype
                     FILTER css_class_quote %]
                 [% " bz_patch" IF attachment.ispatch %]
                 [% " bz_private" IF attachment.isprivate %]
                 [% " bz_tr_obsolete bz_default_hidden" 
                     IF attachment.isobsolete %]">
        <td>
          [% IF attachment.datasize %]
            <a href="attachment.cgi?id=[% attachment.id %]"
               title="View the content of the attachment">
          [% END %]
          <b>
            [% IF attachment.isobsolete %]
              <span class="bz_obsolete">
            [% END %]
            [% attachment.description FILTER html %]
            [% IF attachment.isobsolete %]
              </span>
            [% END %]
          </b>
          [% "</a>" IF attachment.datasize %]

          <span class="bz_attach_extra_info">
            [% IF attachment.datasize %]
              ([% attachment.datasize FILTER unitconvert %],
              [% IF attachment.ispatch %]
                patch)
              [% ELSE %]
                [%+ attachment.contenttype FILTER html %])
              [% END %]
            [% ELSE %]
              (<em>deleted</em>)
            [% END %]

            <br>
            <a href="#attach_[% attachment.id %]"
               title="Go to the comment associated with the attachment">
              [%- attachment.attached FILTER time("%Y-%m-%d %H:%M %Z") %]</a>,

            [%# No need to recreate the exact same template if we already have it. %]
            [% attacher_id = attachment.attacher.id %]
            [% UNLESS user_cache.$attacher_id %]
              [% user_cache.$attacher_id = BLOCK %]
                [% INCLUDE global/user.html.tmpl who = attachment.attacher %]
              [% END %]
            [% END %]
            [% user_cache.$attacher_id FILTER none %]
          </span>
        </td>

        [% IF show_attachment_flags %]
          <td class="bz_attach_flags">
            [% IF attachment.flags.size == 0 %]
              <i>no flags</i>
            [% ELSE %]
              [% FOREACH flag = attachment.flags %]
                [% IF user.id %]
                  <span title="[% flag.setter.identity FILTER html %]">[% flag.setter.nick FILTER html %]</span>:
                [% ELSIF flag.setter.name %]
                  <span title="[% flag.setter.name FILTER html %]">[% flag.setter.nick FILTER html %]</span>:
                [% ELSE %]
                  [% flag.setter.nick FILTER html %]:
                [% END %]
                [%+ flag.type.name FILTER html %][% flag.status %]
                [%+ IF flag.status == "?" && flag.requestee %]
                  [% IF user.id %]
                    (<span title="[% flag.requestee.identity FILTER html %]">[% flag.requestee.nick FILTER html %]</span>)
                  [% ELSIF flag.requestee.name %]
                    (<span title="[% flag.requestee.name FILTER html %]">[% flag.requestee.nick FILTER html %]</span>)
                  [% ELSE %]
                    ([% flag.requestee.nick FILTER html %])
                  [% END %]
                [% END %]<br>
              [% END %]
            [% END %]
          </td>
        [% END %]

        <td>
          <a href="attachment.cgi?id=[% attachment.id %]&amp;action=edit">Details</a>
          [% IF attachment.ispatch && feature_enabled('patch_viewer') %]
            | <a href="attachment.cgi?id=[% attachment.id %]&amp;action=diff">Diff</a>
          [% END %]
          [% Hook.process("action") %]
        </td>
      </tr>
    [% END %]
  [% END %]

  <tr class="bz_attach_footer">
    <td colspan="[% show_attachment_flags ? 3 : 2 %]">
      [% IF attachments.size %]
        <span class="bz_attach_view_hide">
          [% IF obsolete_attachments %]
            <a href="#a0" onclick="return toggle_display(this);">Show
              Obsolete</a> ([% obsolete_attachments %])
          [% END %]
          [% IF Param("allow_attachment_display") %]
            <a id="view_all" href="attachment.cgi?bugid=
                  [%- bugid %]&amp;action=viewall
                  [%- "&amp;hide_obsolete=1" IF obsolete_attachments %]">View All</a>
          [% END %]
        </span>
      [% END %]
      [% IF Param("maxattachmentsize") || Param("maxlocalattachment") %]
        <a href="attachment.cgi?bugid=[% bugid %]&amp;action=enter">Add an attachment</a>
        (proposed patch, testcase, etc.)
      [% END %]
    </td>
  </tr>
</table>
<br>