Bug 21468: (QA follow-up) Simplify payload
[koha.git] / C4 / TmplTokenType.pm
1 package C4::TmplTokenType;
2
3 # Copyright 2011 Tamil
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21 require Exporter;
22
23 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
24
25 ###############################################################################
26
27 =head1 NAME
28
29 C4::TmplTokenType.pm - Types of TmplToken objects
30
31 =head1 DESCRIPTION
32
33 This is a Java-style "safe enum" singleton class for types of TmplToken objects.
34 The predefined constants are
35
36 =cut
37
38 ###############################################################################
39
40
41 @ISA = qw(Exporter);
42 @EXPORT_OK = qw(
43     &TEXT
44     &TEXT_PARAMETRIZED
45     &CDATA
46     &TAG
47     &DECL
48     &PI
49     &DIRECTIVE
50     &COMMENT
51     &UNKNOWN
52 );
53
54 ###############################################################################
55
56 use vars qw( $_text $_text_parametrized $_cdata
57     $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
58
59 BEGIN {
60     my $new = sub {
61         my $this = 'C4::TmplTokenType';#shift;
62         my $class = ref($this) || $this;
63         my $self = {};
64         bless $self, $class;
65         ($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
66         return $self;
67     };
68     $_text              = &$new(0, 'TEXT');
69     $_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
70     $_cdata             = &$new(1, 'CDATA');
71     $_tag               = &$new(2, 'TAG');
72     $_decl              = &$new(3, 'DECL');
73     $_pi                = &$new(4, 'PI');
74     $_directive         = &$new(5, 'DIRECTIVE');
75     $_comment           = &$new(6, 'COMMENT');
76     $_unknown           = &$new(7, 'UNKNOWN');
77 }
78
79 sub to_string {
80     my $this = shift;
81     return $this->{'name'}
82 }
83
84 sub TEXT              { $_text }
85 sub TEXT_PARAMETRIZED { $_text_parametrized }
86 sub CDATA             { $_cdata }
87 sub TAG               { $_tag }
88 sub DECL              { $_decl }
89 sub PI                { $_pi }
90 sub DIRECTIVE         { $_directive }
91 sub COMMENT           { $_comment }
92 sub UNKNOWN           { $_unknown }
93
94 ###############################################################################
95
96 =over
97
98 =item TEXT
99
100 normal text (#text in the DTD)
101
102 =item TEXT_PARAMETRIZED
103
104 parametrized normal text
105 (result of simple recognition of text interspersed with <TMPL_VAR> directives;
106 this has to be explicitly enabled in the scanner)
107
108 =item CDATA
109
110 normal text (CDATA in the DTD)
111
112 =item TAG
113
114 something that has the form of an HTML tag
115
116 =item DECL
117
118 something that has the form of an SGML declaration
119
120 =item PI
121
122 something that has the form of an SGML processing instruction
123
124 =item DIRECTIVE
125
126 a Template Toolkit directive
127
128 =item COMMENT
129
130 something that has the form of an HTML comment
131 (and is not recognized as an HTML::Template directive)
132
133 =item UNKNOWN
134
135 something that is not recognized at all by the scanner
136
137 =back
138
139 Note that end of file is currently represented by undef,
140 instead of a constant predefined by this module.
141
142 =cut
143
144 1;