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