]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/CGI.pm
Add the initial version of CGI.pm which will eventually replace common.pl
[debbugs.git] / Debbugs / CGI.pm
1
2 package Debbugs::CGI;
3
4 =head1 NAME
5
6 Debbugs::CGI -- General routines for the cgi scripts
7
8 =head1 SYNOPSIS
9
10 use Debbugs::CGI qw(:url :html);
11
12 html_escape(bug_url($ref,mbox=>'yes',mboxstatus=>'yes'));
13
14 =head1 DESCRIPTION
15
16 This module is a replacement for parts of common.pl; subroutines in
17 common.pl will be gradually phased out and replaced with equivalent
18 (or better) functionality here.
19
20 =head1 BUGS
21
22 None known.
23
24 =cut
25
26 use warnings;
27 use strict;
28 use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
29 use base qw(Exporter);
30 use Debbugs::URI;
31 use HTML::Entities;
32 use Debbugs::Common qw();
33
34 BEGIN{
35      ($VERSION) = q$Revision: 1.3 $ =~ /^Revision:\s+([^\s+])/;
36      $DEBUG = 0 unless defined $DEBUG;
37
38      @EXPORT = ();
39      %EXPORT_TAGS = (url    => [qw(bug_url)],
40                      html   => [qw(html_escape)],
41                      #status => [qw(getbugstatus)],
42                     );
43      @EXPORT_OK = ();
44      Exporter::export_ok_tags(qw(url html));
45      $EXPORT_TAGS{all} = [@EXPORT_OK];
46 }
47
48
49
50
51 =head2 bug_url
52
53      bug_url($ref,mbox=>'yes',mboxstat=>'yes');
54
55 Constructs urls which point to a specific
56
57 =cut
58
59 sub bug_url{
60      my $ref = shift;
61      my %params = @_;
62      my $url = Debbugs::URI->new('bugreport.cgi?');
63      $url->query_form(bug=>$ref,%params);
64      return $url->as_string;
65 }
66
67 =head2 html_escape
68
69      html_escape($string)
70
71 Escapes html entities by calling HTML::Entities::encode_entities;
72
73 =cut
74
75 sub html_escape{
76      my ($string) = @_;
77
78      return HTML::Entities::encode_entities($string)
79 }
80
81 my %common_bugusertags;
82
83 # =head2 get_bug_status
84
85 #      my $status = getbugstatus($bug_num)
86
87 #      my $status = getbugstatus($bug_num,$bug_index)
88
89
90 # =cut
91
92 # sub get_bug_status {
93 #     my ($bugnum,$bugidx) = @_;
94
95 #     my %status;
96
97 #     if (defined $bugidx and exists $bugidx->{$bugnum}) {
98 #       %status = %{ $bugidx->{$bugnum} };
99 #       $status{pending} = $status{ status };
100 #       $status{id} = $bugnum;
101 #       return \%status;
102 #     }
103
104 #     my $location = getbuglocation($bugnum, 'summary');
105 #     return {} if not length $location;
106 #     %status = %{ readbug( $bugnum, $location ) };
107 #     $status{id} = $bugnum;
108
109
110 #     if (defined $common_bugusertags{$bugnum}) {
111 #         $status{keywords} = "" unless defined $status{keywords};
112 #         $status{keywords} .= " " unless $status{keywords} eq "";
113 #         $status{keywords} .= join(" ", @{$common_bugusertags{$bugnum}});
114 #     }
115 #     $status{tags} = $status{keywords};
116 #     my %tags = map { $_ => 1 } split ' ', $status{tags};
117
118 #     $status{"package"} =~ s/\s*$//;
119 #     $status{"package"} = 'unknown' if ($status{"package"} eq '');
120 #     $status{"severity"} = 'normal' if ($status{"severity"} eq '');
121
122 #     $status{"pending"} = 'pending';
123 #     $status{"pending"} = 'forwarded'      if (length($status{"forwarded"}));
124 #     $status{"pending"} = 'pending-fixed'    if ($tags{pending});
125 #     $status{"pending"} = 'fixed'          if ($tags{fixed});
126
127 #     my @versions;
128 #     if (defined $common_version) {
129 #         @versions = ($common_version);
130 #     } elsif (defined $common_dist) {
131 #         @versions = getversions($status{package}, $common_dist, $common_arch);
132 #     }
133
134 #     # TODO: This should probably be handled further out for efficiency and
135 #     # for more ease of distinguishing between pkg= and src= queries.
136 #     my @sourceversions = makesourceversions($status{package}, $common_arch,
137 #                                             @versions);
138
139 #     if (@sourceversions) {
140 #         # Resolve bugginess states (we might be looking at multiple
141 #         # architectures, say). Found wins, then fixed, then absent.
142 #         my $maxbuggy = 'absent';
143 #         for my $version (@sourceversions) {
144 #             my $buggy = buggyversion($bugnum, $version, \%status);
145 #             if ($buggy eq 'found') {
146 #                 $maxbuggy = 'found';
147 #                 last;
148 #             } elsif ($buggy eq 'fixed' and $maxbuggy ne 'found') {
149 #                 $maxbuggy = 'fixed';
150 #             }
151 #         }
152 #         if ($maxbuggy eq 'absent') {
153 #             $status{"pending"} = 'absent';
154 #         } elsif ($maxbuggy eq 'fixed') {
155 #             $status{"pending"} = 'done';
156 #         }
157 #     }
158 #     
159 #     if (length($status{done}) and
160 #             (not @sourceversions or not @{$status{fixed_versions}})) {
161 #         $status{"pending"} = 'done';
162 #     }
163
164 #     return \%status;
165 # }
166
167
168
169 1;
170
171
172 __END__
173
174
175
176
177
178