User: sits
Date: 08/06/19 21:27:16
Modified: lib/Codestriker/Http Template.pm
lib/Codestriker/Action ListTopics.pm
Added: template/en/default listtopics.xml.tmpl
Log:
Commit from Rob Webset - ability to retrieve list of topics in xml format for
reporting purposes:
https://sourceforge.net/tracker/?func=detail&atid=429862&aid=1904057&group_id=41136
Index: listtopics.xml.tmpl
===================================================================
RCS file: listtopics.xml.tmpl
diff -N listtopics.xml.tmpl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ listtopics.xml.tmpl 20 Jun 2008 04:27:15 -0000 1.1
@@ -0,0 +1,27 @@
+Content-type: text/plain
+
+<?xml version="1.0" encoding="UTF-8"?>
+<topics>
+ [% FOREACH topic = alltopics %]
+ <topic>
+ <topicid>[% topic.topicid %]</topicid>
+ <title>[% topic.title %]</title>
+ <description>[% topic.description %]</description>
+ <topic_state>[% topic.topic_state %]</topic_state>
+ <topic_state_id>[% topic.topic_state_id %]</topic_state_id>
+ <author>[% topic.author %]</author>
+ <cc>[% topic.cc %]</cc>
+ <reviewers>[% topic.reviewers %]</reviewers>
+ <project_name>[% topic.project_name %]</project_name>
+ <project_id>[% topic.project_id %]</project_id>
+ [%# Make sure we remove any password from the end of the repository %]
+ <repository>[% topic.repository.split( ';' ).0 %]</repository>
+ <module>[% topic.module %]</module>
+ <start_tag>[% topic.start_tag %]</start_tag>
+ <end_tag>[% topic.end_tag %]</end_tag>
+ <bug_ids>[% topic.bug_ids %]</bug_ids>
+ <version>[% topic.version %]</version>
+ <creation_ts>[% topic.creation_ts %]</creation_ts>
+ </topic>
+ [% END %]
+</topics>
Index: Template.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Template.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Template.pm 7 Mar 2007 03:03:40 -0000 1.17
+++ Template.pm 20 Jun 2008 04:27:15 -0000 1.18
@@ -16,10 +16,16 @@
# Create a new template.
sub new($$) {
- my ($type, $name) = @_;
+ my ($type, $name, $ttype) = @_;
my $self = {};
$self->{name} = $name;
+
+ if (defined $ttype && $ttype ne "") {
+ $self->{type} = $ttype;
+ } else {
+ $self->{type} = "html";
+ }
# Template configuration.
my $config = {
@@ -123,7 +129,7 @@
$vars->{'doc_url'} = $url_builder->doc_url();
my $data = "";
- my $rc = $self->{template}->process($self->{name} . ".html.tmpl",
+ my $rc = $self->{template}->process($self->{name} . "." . $self->{type}
. ".tmpl",
$vars, \$data);
die $self->{template}->error() if (!defined $rc || $rc == 0);
print $data;
Index: ListTopics.pm
===================================================================
RCS file:
/cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopics.pm,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- ListTopics.pm 23 Feb 2008 02:28:09 -0000 1.31
+++ ListTopics.pm 20 Jun 2008 04:27:15 -0000 1.32
@@ -13,10 +13,24 @@
use Codestriker::Http::Template;
use Codestriker::Model::Topic;
-# If the input is valid, list the appropriate topics.
+# find out which format to display the list in
sub process($$$) {
my ($type, $http_input, $http_response) = @_;
+ my $format = $http_input->get('format');
+
+ if (defined $format && $format eq "xml") {
+ process_xml($type, $http_input, $http_response);
+ } else {
+ process_default($type, $http_input, $http_response);
+ }
+}
+
+
+# If the input is valid, list the appropriate topics.
+sub process_default($$$) {
+ my ($type, $http_input, $http_response) = @_;
+
my $query = $http_response->get_query();
# Check if this action is allowed.
@@ -226,6 +240,36 @@
$http_response->generate_footer();
}
+
+# If the input is valid, display the topic.
+sub process_xml($$$) {
+ my ($self, $http_input, $http_response) = @_;
+
+ my $sbugid = $http_input->get('sbugid') || "";
+ my $sauthor = $http_input->get('sauthor') || "";
+ my $sreviewer = $http_input->get('sreviewer') || "";
+ my $scc = $http_input->get('scc') || "";
+ my $stext = $http_input->get('stext') || "";
+
+ my @sort_order;
+ my @topics = Codestriker::Model::Topic->query($sauthor,
+ $sreviewer,
+ $scc,
+ $sbugid,
+ "", "",
+ $stext,
+ "", "", "", "", "",
+ [EMAIL PROTECTED] );
+
+ my $var;
+ $var->{ alltopics } = [EMAIL PROTECTED];
+
+ # Fire the template for generating the view topic screen.
+ my $template = Codestriker::Http::Template->new("listtopics", "xml");
+ $template->process($var);
+}
+
+
# Process the input and return the parts that will feed into the topic
# list query. Returns in the same order that the topic query function
# takes them.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits