summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Traits.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-02-20 18:35:06 +0100
committerYorhel <git@yorhel.nl>2011-02-20 18:35:06 +0100
commit0d8e97158208681c63d934e0c75472d8f5eb11c8 (patch)
tree1b8a9939eb70b8e9974507f394421a80b321cb6c /lib/VNDB/Handler/Traits.pm
parentea2f5b57d819bf21ef3ce8a2107b04ef19b9f4f2 (diff)
chardb: Added friendly character <-> trait linking interface
Diffstat (limited to 'lib/VNDB/Handler/Traits.pm')
-rw-r--r--lib/VNDB/Handler/Traits.pm31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm
index 6beaab94..f86fb4cc 100644
--- a/lib/VNDB/Handler/Traits.pm
+++ b/lib/VNDB/Handler/Traits.pm
@@ -3,7 +3,7 @@ package VNDB::Handler::Traits;
use strict;
use warnings;
-use TUWF ':html', 'html_escape';
+use TUWF ':html', ':xml', 'html_escape';
use VNDB::Func;
@@ -14,6 +14,7 @@ TUWF::register(
qr{i/new}, \&traitedit,
qr{i/list}, \&traitlist,
qr{i}, \&traitindex,
+ qr{xml/traits\.xml}, \&traitxml,
);
@@ -329,5 +330,33 @@ sub traitindex {
}
+sub traitxml {
+ my $self = shift;
+
+ my $f = $self->formValidate(
+ { get => 'q', required => 0, maxlength => 500 },
+ { get => 'id', required => 0, multi => 1, template => 'int' },
+ { get => 'r', required => 0, default => 15, template => 'int', min => 1, max => 100 },
+ );
+ return $self->resNotFound if $f->{_err} || (!$f->{q} && !$f->{id} && !$f->{id}[0]);
+
+ my($list, $np) = $self->dbTraitGet(
+ !$f->{q} ? () : $f->{q} =~ /^i([1-9]\d*)/ ? (id => $1) : (search => $f->{q}),
+ $f->{id} && $f->{id}[0] ? (id => $f->{id}) : (),
+ results => $f->{r},
+ page => 1,
+ sort => 'groupname'
+ );
+
+ $self->resHeader('Content-type' => 'text/xml; charset=UTF-8');
+ xml;
+ tag 'tags', more => $np ? 'yes' : 'no';
+ for(@$list) {
+ tag 'item', id => $_->{id}, meta => $_->{meta} ? 'yes' : 'no', group => $_->{group}||'', groupname => $_->{groupname}||'', state => $_->{state}, $_->{name};
+ }
+ end;
+}
+
+
1;