Bug 26265: (QA follow-up) Remove g option from regex, add few dirs
[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 strict;
21 #use warnings; FIXME - Bug 2505
22 require Exporter;
23
24 use vars qw(@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
42 @ISA = qw(Exporter);
43 @EXPORT_OK = qw(
44     &TEXT
45     &TEXT_PARAMETRIZED
46     &CDATA
47     &TAG
48     &DECL
49     &PI
50     &DIRECTIVE
51     &COMMENT
52     &UNKNOWN
53 );
54
55 ###############################################################################
56
57 use vars qw( $_text $_text_parametrized $_cdata
58     $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
59
60 BEGIN {
61     my $new = sub {
62         my $this = 'C4::TmplTokenType';#shift;
63         my $class = ref($this) || $this;
64         my $self = {};
65         bless $self, $class;
66         ($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
67         return $self;
68     };
69     $_text              = &$new(0, 'TEXT');
70     $_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
71     $_cdata             = &$new(1, 'CDATA');
72     $_tag               = &$new(2, 'TAG');
73     $_decl              = &$new(3, 'DECL');
74     $_pi                = &$new(4, 'PI');
75     $_directive         = &$new(5, 'DIRECTIVE');
76     $_comment           = &$new(6, 'COMMENT');
77     $_unknown           = &$new(7, 'UNKNOWN');
78 }
79
80 sub to_string {
81     my $this = shift;
82     return $this->{'name'}
83 }
84
85 sub TEXT              { $_text }
86 sub TEXT_PARAMETRIZED { $_text_parametrized }
87 sub CDATA             { $_cdata }
88 sub TAG               { $_tag }
89 sub DECL              { $_decl }
90 sub PI                { $_pi }
91 sub DIRECTIVE         { $_directive }
92 sub COMMENT           { $_comment }
93 sub UNKNOWN           { $_unknown }
94
95 ###############################################################################
96
97 =over
98
99 =item TEXT
100
101 normal text (#text in the DTD)
102
103 =item TEXT_PARAMETRIZED
104
105 parametrized normal text
106 (result of simple recognition of text interspersed with <TMPL_VAR> directives;
107 this has to be explicitly enabled in the scanner)
108
109 =item CDATA
110
111 normal text (CDATA in the DTD)
112
113 =item TAG
114
115 something that has the form of an HTML tag
116
117 =item DECL
118
119 something that has the form of an SGML declaration
120
121 =item PI
122
123 something that has the form of an SGML processing instruction
124
125 =item DIRECTIVE
126
127 a Template Toolkit directive
128
129 =item COMMENT
130
131 something that has the form of an HTML comment
132 (and is not recognized as an HTML::Template directive)
133
134 =item UNKNOWN
135
136 something that is not recognized at all by the scanner
137
138 =back
139
140 Note that end of file is currently represented by undef,
141 instead of a constant predefined by this module.
142
143 =cut
144
145 1;