1 package Koha
::Template
::Plugin
::Asset
;
3 # Copyright Marc VĂ©ron / marc veron ag, Switzerland
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 base
qw( Template::Plugin );
30 my ($class, $context) = @_;
36 return bless $self, $class;
40 my ( $self, $filename, $attributes ) = @_;
42 my $url = $self->url($filename);
44 warn "File not found : $filename";
48 $attributes->{src
} = $url;
50 return $self->tag('script', $attributes) . '</script>';
54 my ( $self, $filename, $attributes ) = @_;
56 my $url = $self->url($filename);
58 warn "File not found : $filename";
62 $attributes->{rel
} = 'stylesheet';
63 $attributes->{type
} = 'text/css';
64 $attributes->{href
} = $url;
66 return $self->tag('link', $attributes);
70 my ( $self, $filename ) = @_;
72 my $stash = $self->{_CONTEXT
}->stash();
73 my $interface = $stash->get('interface');
74 my $theme = $stash->get('theme');
76 my $configkey = $interface =~ /opac/ ?
'opachtdocs' : 'intrahtdocs';
77 my $root = C4
::Context
->config($configkey);
79 my ($basename, $dirname, $suffix) = fileparse
($filename, qr/\.[^.]*/);
81 my $type = substr $suffix, 1;
87 my $version = C4
::Context
->preference('Version');
88 foreach my $dir (@dirs) {
89 my $abspath = File
::Spec
->catfile($root, $dir, $filename);
91 return File
::Spec
->catfile($interface, $dir, $dirname, "${basename}_${version}${suffix}");
97 my ($self, $name, $attributes) = @_;
101 while (my ($key, $value) = each %$attributes) {
102 push @attributes_strs, qq{$key="$value"};
105 my $attributes_str = join ' ', @attributes_strs;
107 return "<$name $attributes_str>";