Subversion Repositories DevTools

Rev

Rev 1295 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1293 dpurdie 1
###############################################################################
2
# Codestriker: Copyright (c) 2001, 2002 David Sitsky.  All rights reserved.
3
# sits@users.sourceforge.net
4
#
5
# This program is free software; you can redistribute it and modify it under
6
# the terms of the GPL.
7
 
8
# Action object for displaying a list of topics.
9
 
10
package Codestriker::Action::ListTopicsRSS;
11
 
12
use strict;
13
use Codestriker::Http::Template;
14
use Codestriker::Model::Topic;
15
use XML::RSS;
16
 
17
# If the input is valid, list the appropriate topics.
18
sub process($$$) {
19
    my ($type, $http_input, $http_response) = @_;
20
 
21
    my $query = $http_response->get_query();
22
 
23
    # Check if this action is allowed.
24
    if ($Codestriker::allow_searchlist == 0) {
25
	$http_response->error("This function has been disabled");
26
    }
27
 
28
    # Query the model for the specified data.
29
 
30
    my $mode = $http_input->get('mode');
31
 
32
    my ( $sauthor, $sreviewer, $scc, $sbugid,
33
         $sstate, $sproject, $stext,
34
         $stitle, $sdescription,
35
	 $scomments, $sbody, $sfilename,
36
         $sort_order) = Codestriker::Action::ListTopics::get_topic_list_query_params($http_input);
37
 
38
    # Query the model for the specified data.
39
    my @topics = Codestriker::Model::Topic->query($sauthor, $sreviewer, $scc, $sbugid,
40
				     $sstate, $sproject, $stext,
41
				     $stitle, $sdescription,
42
				     $scomments, $sbody, $sfilename,
43
                                     $sort_order);
44
 
45
    # Display the data, with each topic title linked to the view topic screen.
46
    # If only a single project id is being searched over, set that id in the
47
    # cookie.
48
    my @project_ids = ();
49
    if ($sproject ne "") {
50
	@project_ids = split ',', $sproject;
51
    }
52
 
53
    # Print the header. Should really be application/rss+xml, except when 
54
    # people click on the link they get a pop-up asking for an application
55
    # that knows how to show application/rss+xml. Very confusing, so we 
56
    # will just say it is xml, (which it is of coarse). The link tag in
57
    # the template lists it as application/rss+xml.
58
    print $query->header(-type=>'application/xml');
59
 
60
    # Obtain a new URL builder object.
61
    my $url_builder = Codestriker::Http::UrlBuilder->new($query);
62
 
63
    my $rss = new XML::RSS(version => '2.0');
64
 
65
    my $this_url  = 
66
	$url_builder->list_topics_url_rss($sauthor, $sreviewer, $scc, $sbugid,
67
				      $stext, $stitle,
68
				      $sdescription, $scomments,
69
				      $sbody, $sfilename,
70
				      [ split ',', $sstate] , \@project_ids);
71
 
72
 
73
    $rss->channel(title=>$Codestriker::title, language=>"en",link=>$this_url);
74
 
75
    # For each topic, collect all the reviewers, CC, and bugs, and display it
76
    # as a row in the table.  Each bug should be linked appropriately. 
77
    foreach my $topic (@topics) {
78
 
79
        # do the easy stuff first, 1 to 1 mapping into the template.
80
	my $link =
81
	    $url_builder->view_url($topic->{topicid}, -1, $mode,
82
				   $Codestriker::default_topic_br_mode);
83
 
84
	my $comment_link = $url_builder->view_comments_url($topic->{topicid});
85
 
86
	my $description = $topic->{description};
87
	my $title = $topic->{title};
88
 
89
        # Change to 1 to send out the list of files changes in the RSS description.
90
        if (0) {
91
            my (@filenames, @revisions, @offsets, @binary);
92
            $topic->get_filestable(
93
    		        \@filenames,
94
                        \@revisions,
95
                        \@offsets,
96
                        \@binary);
97
 
98
            $description .= "<p>" . join( "\n",@filenames);
99
        }
100
 
101
        my @comments = $topic->read_comments();
102
 
103
        $description .= "<p>Comments: " . scalar( @comments ) . ", ";
104
        $description .= "State: " . $topic->{topic_state} . ", ";
105
        $description .= "Author: " . Codestriker->filter_email($topic->{author});
106
 
107
        $rss->add_item(
108
            title=>$title, 
109
            permaLink=>$link, 
110
            description=>$description,
111
            author=> Codestriker->filter_email($topic->{author}),
112
            pubDate=>Codestriker->format_short_timestamp($topic->{creation_ts}),
113
            category=>$topic->{project_name},
114
            comments=>$comment_link
115
            );
116
 
117
    }
118
 
119
    print $rss->as_string();
120
}
121
 
122
1;