summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Traits.pm
blob: 640af81e448ec9cb3a6900d72896b853105bf7e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

package VNDB::Handler::Traits;

use strict;
use warnings;
use TUWF ':html';
use VNDB::Func;


TUWF::register(
  qr{i([1-9]\d*)},  \&traitpage,
);


sub traitpage {
  my($self, $trait) = @_;

  my $t = $self->dbTraitGet(id => $trait, what => 'parents(0) childs(2) aliases')->[0];
  return $self->resNotFound if !$t;

  my $title = mt '_traitp_title', $t->{meta}?0:1, $t->{name};
  $self->htmlHeader(title => $title, noindex => $t->{state} != 2);

  if($t->{state} != 2) {
    div class => 'mainbox';
     h1 $title;
     if($t->{state} == 1) {
       div class => 'warning';
        h2 mt '_traitp_del_title';
        p;
         lit mt '_traitp_del_msg';
        end;
       end;
     } else {
       div class => 'notice';
        h2 mt '_traitp_pending_title';
        p mt '_traitp_pending_msg';
       end;
     }
    end 'div';
  }

  div class => 'mainbox';
   h1 $title;

   parenttags($t, mt('_traitp_indexlink'), 'i');

   if($t->{description}) {
     p class => 'description';
      lit bb2html $t->{description};
     end;
   }
   if(@{$t->{aliases}}) {
     p class => 'center';
      b mt('_traitp_aliases');
      br;
      lit xml_escape($_).'<br />' for (@{$t->{aliases}});
     end;
   }
  end 'div';

  childtags($self, mt('_traitp_childs'), 'i', $t) if @{$t->{childs}};

  # TODO: list of characters
  
  $self->htmlFooter;
}


1;

__END__

Simple test database:

  INSERT INTO traits (name, description, state, meta, addedby) VALUES
    ('Blood Type', 'Describes the blood type of the character', 2, true, 2),
    ('Blood Type O', '', 2, true, 2),
    ('Blood Type B', '', 2, true, 2);
  INSERT INTO traits_parents (trait, parent) VALUES (2, 1), (3, 1);