|
Lines 1-5
Link Here
|
| 1 |
package Koha::Upload; |
1 |
package Koha::Upload; |
| 2 |
|
2 |
|
|
|
3 |
# Copyright 2007 LibLime, Galen Charlton |
| 4 |
# Copyright 2011-2012 BibLibre |
| 3 |
# Copyright 2015 Rijksmuseum |
5 |
# Copyright 2015 Rijksmuseum |
| 4 |
# |
6 |
# |
| 5 |
# This file is part of Koha. |
7 |
# This file is part of Koha. |
|
Lines 25-47
Koha::Upload - Facilitate file upload
Link Here
|
| 25 |
|
27 |
|
| 26 |
use Koha::Upload; |
28 |
use Koha::Upload; |
| 27 |
|
29 |
|
| 28 |
=head1 DESCRIPTION |
30 |
# add an upload (see tools/upload-file.pl) |
| 29 |
|
31 |
my $upload = Koha::Upload->new( public => 1, category => 'A' ); |
| 30 |
This class |
32 |
my $cgi = $upload->cgi; |
|
|
33 |
# Do something with $upload->count, $upload->result or $upload->err |
| 31 |
|
34 |
|
| 32 |
=head1 METHODS |
35 |
# get some upload records |
| 33 |
|
36 |
my @uploads = Koha::Upload->new->get( term => $term ); |
| 34 |
=head2 new |
37 |
$template->param( uploads => \@uploads ); |
| 35 |
|
38 |
|
| 36 |
Create object (via Class::Accessor). |
39 |
# download |
|
|
40 |
my $rec = Koha::Upload->new->get({ id => $id, filehandle => 1 }); |
| 41 |
my $fh = $rec->{fh}; |
| 42 |
my @hdr = Koha::Upload->httpheaders( $rec->{name} ); |
| 43 |
print Encode::encode_utf8( $input->header( @hdr ) ); |
| 44 |
while( <$fh> ) { print $_; } |
| 45 |
$fh->close; |
| 37 |
|
46 |
|
| 38 |
=head1 PROPERTIES |
47 |
# delete an upload |
|
|
48 |
my ( $fn ) = Koha::Upload->new->delete({ id => $id }); |
| 39 |
|
49 |
|
| 40 |
=head2 ??? |
50 |
=head1 DESCRIPTION |
| 41 |
|
51 |
|
| 42 |
??? |
52 |
This module is a refactored version of C4::UploadedFile but adds on top |
|
|
53 |
of that the new functions from report 6874 (Upload plugin in editor). |
| 54 |
That report added module UploadedFiles.pm. This module contains the |
| 55 |
functionality of both. |
| 43 |
|
56 |
|
| 44 |
=head1 ADDITIONAL COMMENTS |
57 |
=head1 METHODS |
| 45 |
|
58 |
|
| 46 |
=cut |
59 |
=cut |
| 47 |
|
60 |
|
|
Lines 78-84
sub new {
Link Here
|
| 78 |
|
91 |
|
| 79 |
=head2 cgi |
92 |
=head2 cgi |
| 80 |
|
93 |
|
| 81 |
Returns new object based on Class::Accessor. |
94 |
Returns CGI object. The CGI hook is used to store the uploaded files. |
| 82 |
|
95 |
|
| 83 |
=cut |
96 |
=cut |
| 84 |
|
97 |
|
|
Lines 109-115
sub count {
Link Here
|
| 109 |
|
122 |
|
| 110 |
=head2 result |
123 |
=head2 result |
| 111 |
|
124 |
|
| 112 |
Returns new object based on Class::Accessor. |
125 |
Returns a string of id's for each successful upload separated by commas. |
| 113 |
|
126 |
|
| 114 |
=cut |
127 |
=cut |
| 115 |
|
128 |
|
|
Lines 140-147
sub err {
Link Here
|
| 140 |
|
153 |
|
| 141 |
=head2 get |
154 |
=head2 get |
| 142 |
|
155 |
|
| 143 |
Returns array |
156 |
Returns arrayref of uploaded records (hash) or one uploaded record. |
| 144 |
optional parameter: filehandle => 1 (name, path only by default) |
157 |
You can pass id => $id or hashvalue => $hash or term => $term. |
|
|
158 |
Optional parameter filehandle => 1 returns you a filehandle too. |
| 145 |
|
159 |
|
| 146 |
=cut |
160 |
=cut |
| 147 |
|
161 |
|
|
Lines 400-406
sub _compute {
Link Here
|
| 400 |
|
414 |
|
| 401 |
=head1 AUTHOR |
415 |
=head1 AUTHOR |
| 402 |
|
416 |
|
| 403 |
Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands |
417 |
Koha Development Team |
|
|
418 |
Larger parts from Galen Charlton, Julian Maurice and Marcel de Rooy |
| 404 |
|
419 |
|
| 405 |
=cut |
420 |
=cut |
| 406 |
|
421 |
|
| 407 |
- |
|
|