Bug 17600: Standardize our EXPORT_OK
[srvgit] / Koha / Template / Plugin / Asset.pm
index 5b78345..0afe209 100644 (file)
@@ -45,9 +45,10 @@ use Modern::Perl;
 use Template::Plugin;
 use base qw( Template::Plugin );
 
-use File::Basename;
+use File::Basename qw( fileparse );
 use File::Spec;
 use C4::Context;
+use Koha;
 
 =head1 FUNCTIONS
 
@@ -86,7 +87,7 @@ sub js {
 
     $attributes->{src} = $url;
 
-    return $self->tag('script', $attributes) . '</script>';
+    return $self->_tag('script', $attributes) . '</script>';
 }
 
 =head2 css
@@ -111,7 +112,7 @@ sub css {
     $attributes->{type} = 'text/css';
     $attributes->{href} = $url;
 
-    return $self->tag('link', $attributes);
+    return $self->_tag('link', $attributes);
 }
 
 =head2 url
@@ -140,7 +141,8 @@ sub url {
         ".",
     );
 
-    my $version = C4::Context->preference('Version');
+    my $version = Koha::version;
+    $version =~ s/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/$1.$2$3$4/;
     foreach my $dir (@dirs) {
         my $abspath = File::Spec->catfile($root, $dir, $filename);
         if (-e $abspath) {
@@ -149,16 +151,14 @@ sub url {
     }
 }
 
-=head2 tag
+=head2 _tag
 
 Returns an HTML tag with given name and attributes.
 This shouldn't be used directly.
 
-    [% Asset.tag("script", { src = "/koha-tmpl/intranet-tmpl/prog/css/datatables.css" }) %]
-
 =cut
 
-sub tag {
+sub _tag {
     my ($self, $name, $attributes) = @_;
 
     my @attributes_strs;