diff options
-rwxr-xr-x | show_bug.cgi | 23 | ||||
-rw-r--r-- | template/en/default/bug/show.xml.tmpl | 42 |
2 files changed, 47 insertions, 18 deletions
diff --git a/show_bug.cgi b/show_bug.cgi index 52c7f83f9..80e53e616 100755 --- a/show_bug.cgi +++ b/show_bug.cgi @@ -76,9 +76,30 @@ my @bug_list; if ($::COOKIE{"BUGLIST"}) { @bug_list = split(/:/, $::COOKIE{"BUGLIST"}); } + $vars->{'bug_list'} = \@bug_list; +# Work out which fields we are displaying (currently XML only.) +# If no explicit list is defined, we show all fields. We then exclude any +# on the exclusion list. This is so you can say e.g. "Everything except +# attachments" without listing almost all the fields. +my @fieldlist = (Bug::fields(), 'group', 'long_desc', 'attachment'); +my %displayfields; + +if ($cgi->param("field")) { + @fieldlist = $cgi->param("field"); +} + +foreach (@fieldlist) { + $displayfields{$_} = 1; +} + +foreach ($cgi->param("excludefield")) { + $displayfields{$_} = undef; +} + +$vars->{'displayfields'} = \%displayfields; + print "Content-type: $format->{'ctype'}\n\n"; $template->process("$format->{'template'}", $vars) || ThrowTemplateError($template->error()); - diff --git a/template/en/default/bug/show.xml.tmpl b/template/en/default/bug/show.xml.tmpl index 501ec2c17..618745902 100644 --- a/template/en/default/bug/show.xml.tmpl +++ b/template/en/default/bug/show.xml.tmpl @@ -38,29 +38,37 @@ [% ELSE %] <bug> [% FOREACH field = bug.fields %] - [%+ PROCESS bug_field %] + [% IF displayfields.$field %] + [%+ PROCESS bug_field %] + [% END %] [% END %] [%# Now handle 'special' fields #%] - [% FOREACH g = bug.groups %] - [% NEXT UNLESS g.ison %] - <group>[% g.name FILTER xml %]</group> + [% IF displayfields.group %] + [% FOREACH g = bug.groups %] + [% NEXT UNLESS g.ison %] + <group>[% g.name FILTER xml %]</group> + [% END %] [% END %] - [% FOREACH c = bug.longdescs %] - <long_desc> - <who>[% c.email FILTER xml %]</who> - <bug_when>[% c.time FILTER time FILTER xml %]</bug_when> - <thetext>[% c.body FILTER xml %]</thetext> - </long_desc> + [% IF displayfields.long_desc %] + [% FOREACH c = bug.longdescs %] + <long_desc> + <who>[% c.email FILTER xml %]</who> + <bug_when>[% c.time FILTER time FILTER xml %]</bug_when> + <thetext>[% c.body FILTER xml %]</thetext> + </long_desc> + [% END %] [% END %] - - [% FOREACH a = bug.attachments %] - <attachment> - <attachid>[% a.attachid %]</attachid> - <date>[% a.date FILTER time FILTER xml %]</date> - <desc>[% a.description FILTER xml %]</desc> - </attachment> + + [% IF displayfields.attachment %] + [% FOREACH a = bug.attachments %] + <attachment> + <attachid>[% a.attachid %]</attachid> + <date>[% a.date FILTER time FILTER xml %]</date> + <desc>[% a.description FILTER xml %]</desc> + </attachment> + [% END %] [% END %] </bug> [% END %] |