5 # This file is part of Koha.
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.
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.
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>.
23 use C4
::TmplTokenType
;
27 TmplToken.pm - Object representing a scanner token for .tmpl files
31 This is a class representing a token scanned from an HTML::Template .tmpl file.
35 our $VERSION = 3.07.00.049;
40 my $class = ref($this) || $this;
43 ($self->{'_string'}, $self->{'_type'}, $self->{'_lc'}, $self->{'_path'}) = @_;
49 return $this->{'_string'}
54 return $this->{'_type'}
59 return $this->{'_path'}
69 return $this->{'_attr'};
74 $this->{'_attr'} = ref $_[0] eq 'HASH'?
$_[0]: \
@_;
78 # only meaningful for TEXT_PARAMETRIZED tokens
81 return $this->{'_kids'};
84 # only meaningful for TEXT_PARAMETRIZED tokens
87 $this->{'_kids'} = ref $_[0] eq 'ARRAY'?
$_[0]: \
@_;
91 # only meaningful for TEXT_PARAMETRIZED tokens
92 # FIXME: DIRECTIVE is not necessarily TMPL_VAR !!
93 sub parameters_and_fields
{
95 return map { $_->type == C4
::TmplTokenType
::DIRECTIVE?
$_:
96 ($_->type == C4
::TmplTokenType
::TAG
97 && $_->string =~ /^<input\b/is)?
$_: ()}
101 # only meaningful for TEXT_PARAMETRIZED tokens
104 return map { $_->type == C4
::TmplTokenType
::TAG
&& $_->string =~ /^<a\b/is?
$_: ()} @
{$this->{'_kids'}};
107 # only meaningful for TEXT_PARAMETRIZED tokens
110 return $this->{'_form'};
113 # only meaningful for TEXT_PARAMETRIZED tokens
116 $this->{'_form'} = $_[0];
122 return defined $this->{'_js_data'} && ref($this->{'_js_data'}) eq 'ARRAY';
127 return $this->{'_js_data'};
132 $this->{'_js_data'} = $_[0];
140 return $this->type == C4
::TmplTokenType
::TAG
;
145 return $this->type == C4
::TmplTokenType
::CDATA
;
150 return $this->type == C4
::TmplTokenType
::TEXT
;
153 sub text_parametrized_p
{
155 return $this->type == C4
::TmplTokenType
::TEXT_PARAMETRIZED
;
160 return $this->type == C4
::TmplTokenType
::DIRECTIVE
;
163 ###############################################################################