5 # This file is part of Koha.
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
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.
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.
22 #use warnings; FIXME - Bug 2505
23 use C4
::TmplTokenType
;
26 use vars
qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
28 ###############################################################################
32 TmplToken.pm - Object representing a scanner token for .tmpl files
36 This is a class representing a token scanned from an HTML::Template .tmpl file.
40 ###############################################################################
42 $VERSION = 3.07.00.049;
47 ###############################################################################
51 my $class = ref($this) || $this;
54 ($self->{'_string'}, $self->{'_type'}, $self->{'_lc'}, $self->{'_path'}) = @_;
60 return $this->{'_string'}
65 return $this->{'_type'}
70 return $this->{'_path'}
80 return $this->{'_attr'};
85 $this->{'_attr'} = ref $_[0] eq 'HASH'?
$_[0]: \
@_;
89 # only meaningful for TEXT_PARAMETRIZED tokens
92 return $this->{'_kids'};
95 # only meaningful for TEXT_PARAMETRIZED tokens
98 $this->{'_kids'} = ref $_[0] eq 'ARRAY'?
$_[0]: \
@_;
102 # only meaningful for TEXT_PARAMETRIZED tokens
103 # FIXME: DIRECTIVE is not necessarily TMPL_VAR !!
104 sub parameters_and_fields
{
106 return map { $_->type == C4
::TmplTokenType
::DIRECTIVE?
$_:
107 ($_->type == C4
::TmplTokenType
::TAG
108 && $_->string =~ /^<input\b/is)?
$_: ()}
112 # only meaningful for TEXT_PARAMETRIZED tokens
115 return map { $_->type == C4
::TmplTokenType
::TAG
&& $_->string =~ /^<a\b/is?
$_: ()} @
{$this->{'_kids'}};
118 # only meaningful for TEXT_PARAMETRIZED tokens
121 return $this->{'_form'};
124 # only meaningful for TEXT_PARAMETRIZED tokens
127 $this->{'_form'} = $_[0];
133 return defined $this->{'_js_data'} && ref($this->{'_js_data'}) eq 'ARRAY';
138 return $this->{'_js_data'};
143 $this->{'_js_data'} = $_[0];
151 return $this->type == C4
::TmplTokenType
::TAG
;
156 return $this->type == C4
::TmplTokenType
::CDATA
;
161 return $this->type == C4
::TmplTokenType
::TEXT
;
164 sub text_parametrized_p
{
166 return $this->type == C4
::TmplTokenType
::TEXT_PARAMETRIZED
;
171 return $this->type == C4
::TmplTokenType
::DIRECTIVE
;
174 ###############################################################################