From 20b2bad134d0ab812148ea58059d6d43ddc3368c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 4 Apr 2019 13:08:42 -0300 Subject: [PATCH] Bug 22508: add POD --- Koha/UploadedFile.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Koha/UploadedFile.pm b/Koha/UploadedFile.pm index 990c7ebfc8..6a5db5b539 100644 --- a/Koha/UploadedFile.pm +++ b/Koha/UploadedFile.pm @@ -154,6 +154,15 @@ sub httpheaders { } } +=head3 url + + my $url = $uploaded_file->url; + +Return the URL of the file, proxied by opac-retrieve-file.pl +The syspref OPACBaseURL is used to generate this link. + +=cut + sub url { my ($self) = @_; my $OPACBaseURL = C4::Context->preference('OPACBaseURL'); @@ -161,6 +170,16 @@ sub url { return "$OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=" . $self->hashvalue; } +=head3 local_public_path + + my $local_public_path = $uploaded_file->local_public_path + +Return the local public path for the uploaded file. +It is generated using the upload_public_path config entry. +Return If this config entry does not exist. + +=cut + sub local_public_path { my ($self) = @_; my $upload_public_path = C4::Context->config('upload_public_path'); @@ -170,12 +189,30 @@ sub local_public_path { return $filepath; } + +=head3 has_local_public_path + + my $local_public_path = $uploaded_file->local_public_path + +Return the local public path for the uploaded file, if exists. + +=cut + sub has_local_public_path { my ($self) = @_; my $filepath = $self->local_public_path; return $filepath if -e $filepath; } +=head3 direct_url + + my $direct_url = $uploaded_file->direct_url + +Return the direct url of the file, ie. without using opac-retrieve-file.pl +The config entry upload_public_url must be defined. + +=cut + sub direct_url { my ( $self ) = @_; # TODO It could start with '/' and we prefix with OPACBaseURL -- 2.11.0