Bugzilla – Attachment 5440 Details for
Bug 6874
Attach files to bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
0001-Bug-6874-Adds-the-ability-to-upload-a-file-for-a-sub.patch (text/plain), 34.22 KB, created by
Julian Maurice
on 2011-09-16 10:34:46 UTC
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2011-09-16 10:34:46 UTC
Size:
34.22 KB
patch
obsolete
>From f9488d7b3d7442b219cabc9f43a344c270df3f39 Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Wed, 8 Dec 2010 17:41:37 +0100 >Subject: [PATCH] Bug 6874: Adds the ability to upload a file for a subfield > >Biblibre MT5108 >--- > C4/Biblio.pm | 18 ++- > basket/basket.pl | 2 +- > catalogue/MARCdetail.pl | 11 ++ > catalogue/detail.pl | 2 +- > cataloguing/value_builder/upload.pl | 188 ++++++++++++++++++++ > installer/data/mysql/sysprefs.sql | 2 + > installer/data/mysql/updatedatabase.pl | 14 ++ > .../prog/en/modules/catalogue/MARCdetail.tt | 80 ++++++++- > .../en/modules/cataloguing/value_builder/upload.tt | 50 +++++ > .../value_builder/upload_delete_file.tt | 52 ++++++ > kohaversion.pl | 2 +- > misc/strip_value_from_tag.pl | 60 ++++++ > opac/opac-MARCdetail.pl | 10 + > opac/opac-basket.pl | 2 +- > opac/opac-detail.pl | 2 +- > 15 files changed, 475 insertions(+), 20 deletions(-) > create mode 100755 cataloguing/value_builder/upload.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt > create mode 100644 misc/strip_value_from_tag.pl > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 96baaef..d4d98c0 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1624,7 +1624,7 @@ sub GetMarcAuthors { > > =head2 GetMarcUrls > >- $marcurls = GetMarcUrls($record,$marcflavour); >+ $marcurls = GetMarcUrls($record,$marcflavour,$frameworkcode); > > Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop. > Assumes web resources (not uncommon in MARC21 to omit resource type ind) >@@ -1632,15 +1632,19 @@ Assumes web resources (not uncommon in MARC21 to omit resource type ind) > =cut > > sub GetMarcUrls { >- my ( $record, $marcflavour ) = @_; >+ my ( $record, $marcflavour, $frameworkcode ) = @_; >+ >+ my $tagslib = &GetMarcStructure(1, $frameworkcode); >+ my $urltag = '856'; >+ my $urlsubtag = 'u'; > > my @marcurls; >- for my $field ( $record->field('856') ) { >+ for my $field ( $record->field($urltag) ) { > my @notes; > for my $note ( $field->subfield('z') ) { > push @notes, { note => $note }; > } >- my @urls = $field->subfield('u'); >+ my @urls = $field->subfield($urlsubtag); > foreach my $url (@urls) { > my $marcurl; > if ( $marcflavour eq 'MARC21' ) { >@@ -1669,7 +1673,11 @@ sub GetMarcUrls { > $marcurl->{'toc'} = 1 if ( defined($s3) && $s3 =~ /^[Tt]able/ ); > } else { > $marcurl->{'linktext'} = $field->subfield('2') || C4::Context->preference('URLLinkText') || $url; >- $marcurl->{'MARCURL'} = $url; >+ if ($tagslib->{ $urltag }->{ $urlsubtag }->{value_builder} eq "upload.pl") { >+ $marcurl->{'MARCURL'} = C4::Context->preference('uploadWebPath') . "/" . $url; >+ } else { >+ $marcurl->{'MARCURL'} = $url; >+ } > } > push @marcurls, $marcurl; > } >diff --git a/basket/basket.pl b/basket/basket.pl >index 8fc15e4..59894b3 100755 >--- a/basket/basket.pl >+++ b/basket/basket.pl >@@ -65,7 +65,7 @@ foreach my $biblionumber ( @bibs ) { > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); >- my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+ my $marcurlsarray = GetMarcUrls ($record,$marcflavour, GetFrameworkCode($biblionumber)); > my @items = GetItemsInfo( $biblionumber ); > > my $hasauthors = 0; >diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl >index 0a2974b..19d26b8 100755 >--- a/catalogue/MARCdetail.pl >+++ b/catalogue/MARCdetail.pl >@@ -82,6 +82,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >+my $uploadWebPath; >+if (C4::Context->preference('uploadWebPath')) { >+ $uploadWebPath = C4::Context->preference('uploadWebPath'); >+} >+ > my $record = GetMarcBiblio($biblionumber); > > if ( not defined $record ) { >@@ -215,6 +220,12 @@ for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) { > GetAuthorisedValueDesc( $fields[$x_i]->tag(), > $subf[$i][0], $subf[$i][1], '', $tagslib) || $subf[$i][1]; > >+ if ($tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{value_builder} eq "upload.pl" and $uploadWebPath) { >+ my $file_uri = qq($uploadWebPath/$subf[$i][1]); >+ $subfield_data{marc_value} = qq/<a href="$file_uri">$subfield_data{marc_value}<\/a>/; >+ $subfield_data{is_file} = 1; >+ } >+ > } > $subfield_data{marc_subfield} = $subf[$i][0]; > $subfield_data{marc_tag} = $fields[$x_i]->tag(); >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 8738737..744af0c 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -104,7 +104,7 @@ my $marcisbnsarray = GetMarcISBN( $record, $marcflavour ); > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries($record,$marcflavour); >-my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+my $marcurlsarray = GetMarcUrls ($record, $marcflavour, $fw); > my $subtitle = GetRecordValue('subtitle', $record, $fw); > > # Get Branches, Itemtypes and Locations >diff --git a/cataloguing/value_builder/upload.pl b/cataloguing/value_builder/upload.pl >new file mode 100755 >index 0000000..88e30de >--- /dev/null >+++ b/cataloguing/value_builder/upload.pl >@@ -0,0 +1,188 @@ >+#!/usr/bin/perl >+ >+use strict; >+use warnings; >+ >+use C4::Auth; >+use CGI qw/-utf8/; >+use C4::Context; >+use C4::Debug; >+ >+use C4::AuthoritiesMarc; >+use C4::Output; >+use File::Basename; >+use Text::Undiacritic qw/undiacritic/; >+use Encode; >+ >+#use open qw(:std :utf8); >+ >+ >+my $upload_path = C4::Context->preference('uploadPath'); >+ >+=head1 >+ >+plugin_parameters : other parameters added when the plugin is called by the dopop function >+ >+=cut >+ >+sub plugin_parameters { >+ my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_; >+ return ""; >+} >+ >+sub plugin_javascript { >+ my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_; >+ my $function_name = $field_number; >+ my $res = " >+ <script type=\"text/javascript\"> >+ function Focus$function_name(subfield_managed) { >+ return 1; >+ } >+ >+ function Blur$function_name(subfield_managed) { >+ return 1; >+ } >+ >+ function Clic$function_name(index) { >+ defaultvalue = document.getElementById(index).value; >+ window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=upload.pl&index=\"+index+\"&result=\"+defaultvalue,'upload','width=600,height=400,toolbar=false,scrollbars=no'); >+ >+ } >+ </script> >+"; >+ >+ return ( $function_name, $res ); >+} >+ >+sub plugin { >+ my ($input) = @_; >+ my $index = $input->param('index'); >+ my $result = $input->param('result'); >+ my $delete = $input->param('delete'); >+ my $uploaded_file = $input->param('uploaded_file'); >+ >+ my $template_name = $result || $delete ? "upload_delete_file.tmpl" : "upload.tmpl"; >+ >+ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => "cataloguing/value_builder/$template_name", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { editcatalogue => '*' }, >+ debug => 1, >+ } >+ ); >+ >+ >+ my $filefield = CGI::filefield( -name=>'uploaded_file', >+ -default=>'starting value', >+ -size=>50, >+ -maxlength=>80); >+ >+ $template->param( >+ index => $index, >+ result => $result, >+ filefield => $filefield >+ ); >+ >+ >+ # If there's already a file uploaded for this field, >+ # We handle is deletion >+ if ($delete) { >+ warn "deletion of $upload_path/$result"; >+ my $success = unlink("$upload_path/$result"); >+ if ($success) { >+ $template->param(success => $success); >+ } else { >+ $template->param(error => 1); >+ } >+ } >+ >+ >+ # Dealing with the uploaded file >+ if ($uploaded_file) { >+ >+ my $fh = $input->upload('uploaded_file'); >+ my $error; >+ my $success; >+ >+ if (defined $fh) { >+ >+ # Dealing with filenames: >+ >+ # Normalizing filename: >+ $uploaded_file = normalize_string($uploaded_file); >+ $uploaded_file = undiacritic($uploaded_file); >+ >+ # Checking for an existing filename in destination directory >+ if (-f "$upload_path/$uploaded_file") { >+ >+ # And getting a new one if needed >+ my ($dir, $file, $ext) = fileparse("$upload_path/$uploaded_file", qr/\.[^.]*/); >+ $uploaded_file = findname($dir, $file, $ext); >+ } >+ >+ # Copying the temp file to the destination directory >+ my $io_fh = $fh->handle; >+ open (OUTFILE, '>', "$upload_path/$uploaded_file") or $error = $!; >+ if (!$error) { >+ my $buffer; >+ while (my $bytesread = $io_fh->read($buffer,1024)) { >+ print OUTFILE $buffer; >+ } >+ close(OUTFILE); >+ $success = 1; >+ } else { >+ $error = "Could not write to destination file"; >+ } >+ } else { >+ $error = "Could not get the file"; >+ } >+ $template->param(success => $success) if ($success); >+ $template->param(error => $error) if ($error); >+ $template->param(uploaded_file => $uploaded_file); >+ } >+ >+ output_html_with_http_headers $input, $cookie, $template->output; >+} >+ >+sub findname { >+ my $file = shift; >+ my $dir = shift; >+ my $ext = shift; >+ >+ my $count = 1; >+ my $found = 0; >+ >+ while ($found == 0) { >+ if (-f "$dir/$file-$count$ext") { >+ $count++; >+ } else { >+ $found = 1; >+ } >+ } >+ >+ return "$file-$count$ext"; >+} >+ >+=head2 normalize_string >+ Given >+ a string >+ Returns a utf8 NFC normalized string >+ >+ Sample code : >+=cut >+ >+sub normalize_string{ >+ my ($string)=@_; >+ $debug and warn " string in normalize before normalize :",$string; >+ $string=decode_utf8($string,1); >+ $debug and warn " string in normalize :",$string; >+ $string=~s/\<|\>|\^|\;|\?|,|\-|\(|\)|\[|\]|\{|\}|\$|\%|\!|\*|\:|\\|\/|\&|\"|\'|\s/_/g; >+ $string=~s/\s+$//g; >+ $string=~s/^\s+//g; >+ return $string; >+} >+ >+ >+1; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 79d4893..a8562c0 100755 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -318,3 +318,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn | a|a d', NULL, NULL, 'Textarea'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('uploadPath','','Sets the upload path for the upload.pl plugin','',''); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('uploadWebPath','','Set the upload path starting from document root for the upload.pl plugin','',''); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 6b88c29..a903e07 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -4446,6 +4446,20 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > SetVersion($DBversion); > } > >+$DBversion = "XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do(" >+ INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('uploadPath','','Sets the upload path for the upload.pl plugin','',''); >+ "); >+ >+ $dbh->do(" >+ INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('uploadWebPath','','Set the upload path starting from document root for the upload.pl plugin','',''); >+ "); >+ print "Upgrade to $DBversion done (Adding upload plugin sysprefs)\n"; >+ SetVersion($DBversion); >+} >+ >+=item DropAllForeignKeys($table) > > =head1 FUNCTIONS > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >index 3fac577..d774d9a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >@@ -109,7 +109,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %][% subfiel.marc_subfield %][% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -139,7 +145,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -169,7 +181,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -199,7 +217,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_url ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -229,7 +253,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF (subfiel.is_url ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -259,7 +289,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF (subfiel.is_url ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -289,7 +325,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF (subfiel.is_url ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -319,7 +361,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF (subfiel.is_url ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -349,7 +397,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF (subfiel.is_url ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -379,7 +433,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF (subfiel.is_url ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt >new file mode 100644 >index 0000000..0a8235e >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt >@@ -0,0 +1,50 @@ >+<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN" >+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >+<html xmlns="http://www.w3.org/1999/xhtml"> >+<head> >+ <title>Upload plugin</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ <script type="text/javascript" src="[% yuipath %]/utilities/utilities.js"></script> >+ <link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" /> >+ >+</head> >+<body> >+[% IF ( success ) %] >+ >+ <script type="text/javascript"> >+ function report() { >+ var doc = opener.document; >+ var field = doc.getElementById("[% index %]"); >+ field.value = "[% uploaded_file %]"; >+ window.close(); >+ return false; >+ } >+ </script> >+ >+ >+ The file [% uploaded_file %] has been successfully added. >+ <p><input type="button" value="close" onclick="javascript:report();" /></p> >+ >+[% ELSE %] >+ >+ [% IF ( error ) %] >+ Error: [% error %] >+ <p><input type="button" value="close" onclick="javascript:window.close();" /></p> >+ [% ELSE %] >+ >+ [% IF ( uploaded_file ) %] >+ uploaded file: [% uploaded_file %] >+ [% ELSE %] >+ <h2>Please select the file to upload : </h2> >+ <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl"> >+ [% filefield %] >+ <input type="hidden" name="plugin_name" value="upload.pl" /> >+ <input type="hidden" name="index" value="[% index %]" /> >+ <input type="submit"> >+ </form> >+ [% END %] >+ [% END %] >+[% END %] >+ >+</body> >+</html> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt >new file mode 100644 >index 0000000..cf0dc66 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt >@@ -0,0 +1,52 @@ >+<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN" >+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >+<html xmlns="http://www.w3.org/1999/xhtml"> >+<head> >+ <title>Upload plugin</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ <script type="text/javascript" src="[% yuipath %]/utilities/utilities.js"></script> >+ <link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" /> >+ >+</head> >+<body> >+[% IF ( success ) %] >+ >+ <script type="text/javascript"> >+ function report() { >+ var doc = opener.document; >+ var field = doc.getElementById("[% index %]"); >+ field.value = ""; >+ window.close(); >+ return false; >+ } >+ </script> >+ >+ The file has been successfully deleted. >+ <p><input type="button" value="close" onclick="javascript:report();" /></p> >+ >+[% ELSE %] >+ >+ [% IF ( error ) %] >+ Error: Unable to delete the file. >+ <p><input type="button" value="close" onclick="javascript:window.close();" /></p> >+ [% ELSE %] >+ >+ [% IF ( uploaded_file ) %] >+ uploaded file: [% uploaded_file %] >+ [% ELSE %] >+ <h2>File deletion</h2> >+ <p>A file has already been uploaded for this field. Do you want to delete it?</p> >+ <form method="post" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl"> >+ <input type="hidden" name="plugin_name" value="upload.pl" /> >+ <input type="hidden" name="delete" value="delete" /> >+ <input type="hidden" name="result" value="[% result %]" /> >+ <input type="hidden" name="index" value="[% index %]" /> >+ <input type="button" value="Cancel" onclick="javascript:window.close();" /> >+ <input type="submit" value="Delete" /> >+ </form> >+ [% END %] >+ [% END %] >+[% END %] >+ >+</body> >+</html> >diff --git a/kohaversion.pl b/kohaversion.pl >index f864378..aa2eac2 100644 >--- a/kohaversion.pl >+++ b/kohaversion.pl >@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts : > use strict; > > sub kohaversion { >- our $VERSION = '3.05.00.011'; >+ our $VERSION = 'XXX'; > # version needs to be set this way > # so that it can be picked up by Makefile.PL > # during install >diff --git a/misc/strip_value_from_tag.pl b/misc/strip_value_from_tag.pl >new file mode 100644 >index 0000000..807e7b5 >--- /dev/null >+++ b/misc/strip_value_from_tag.pl >@@ -0,0 +1,60 @@ >+#!/usr/bin/perl >+ >+# This script takes every biblio record in the database, >+# looks for a value beginning with $find in $fieldtag$$subfieldtag >+# and strips $find from this value. >+# This was originally made for the file upload plugin, but might >+# be used for other purposes. >+ >+use strict; >+ >+use Getopt::Long; >+use C4::Context; >+use C4::Biblio; >+ >+my $debug = 0; >+ >+# Which field are we processing? >+my $fieldtag = "857"; >+my $subfieldtag = "u"; >+ >+# Whichi beginning pattern are we looking to delete? >+my $find = "http://myurl.tld/"; >+my $length = length($find); >+my $pattern = qr|^$find|; >+ >+print "Field $fieldtag\$$subfieldtag\n"; >+ >+# Getting db connection >+my $dbh = C4::Context->dbh; >+ >+# Getting max bibnumber >+my $query = "SELECT MAX(biblionumber) from biblio"; >+my $sth = $dbh->prepare($query); >+$sth->execute(); >+my $bibliocount = $sth->fetchrow; >+ >+warn "unable to get biblio count" and exit -1 unless $bibliocount; >+ >+print "Biblio count : $bibliocount\n"; >+ >+# Foreach each biblio >+foreach (1..$bibliocount) { >+ my $found = 0; >+ my $record = GetMarcBiblio($_); >+ $debug and warn "unable to get marc for record $_" unless $record; >+ next unless $record; >+ foreach my $field ($record->field($fieldtag)) { >+ my $newfield = $field->clone(); >+ my $subfield = $newfield->subfield($subfieldtag); >+ if ($subfield and $subfield =~ $pattern) { >+ my $newsubfield = substr $subfield, $length; >+ $newsubfield =~ s/\s+$//; >+ $newfield->update($subfieldtag, $newsubfield); >+ $field->replace_with($newfield); >+ $found = 1; >+ } >+ } >+ print "processing $_\n" if ($found == 1); >+ ModBiblioMarc($record, $_, GetFrameworkCode($_)) if ($found == 1); >+} >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index ffa0a6d..4005ee4 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -90,6 +90,11 @@ if (C4::Context->preference("RequestOnOpac")) { > $RequestOnOpac = 1; > } > >+my $uploadWebPath; >+if (C4::Context->preference('uploadWebPath')) { >+ $uploadWebPath = C4::Context->preference('uploadWebPath'); >+} >+ > # fill arrays > my @loop_data = (); > my $tag; >@@ -161,6 +166,11 @@ for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) { > } > $subfield_data{marc_value} = GetAuthorisedValueDesc( $fields[$x_i]->tag(), > $subf[$i][0], $subf[$i][1], '', $tagslib, '', 'opac' ); >+ if ($tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{value_builder} eq "upload.pl" and $uploadWebPath) { >+ my $file_uri = qq($uploadWebPath/$subf[$i][1]); >+ $subfield_data{marc_value} = qq/<a href="$file_uri">$subfield_data{marc_value}<\/a>/; >+ } >+ > } > $subfield_data{marc_subfield} = $subf[$i][0]; > $subfield_data{marc_tag} = $fields[$x_i]->tag(); >diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl >index 5e92d15..8f31ba8 100755 >--- a/opac/opac-basket.pl >+++ b/opac/opac-basket.pl >@@ -67,7 +67,7 @@ foreach my $biblionumber ( @bibs ) { > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); >- my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+ my $marcurlsarray = GetMarcUrls ($record, $marcflavour, GetFrameworkCode($biblionumber)); > my @items = &GetItemsLocationInfo( $biblionumber ); > my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index e18e046..5a830b6 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -223,7 +223,7 @@ my $marcisbnsarray = GetMarcISBN ($record,$marcflavour); > my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour); > my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); >-my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+my $marcurlsarray = GetMarcUrls ($record, $marcflavour, $dat->{'frameworkcode'}); > my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); > > $template->param( >-- >1.7.6.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6874
:
5439
|
5440
|
5764
|
7114
|
7980
|
8234
|
8468
|
10664
|
10673
|
10863
|
10982
|
11098
|
11634
|
12355
|
12356
|
12357
|
12358
|
14130
|
14131
|
14132
|
14133
|
16343
|
16354
|
16355
|
16356
|
16357
|
16370
|
16693
|
16694
|
16695
|
16696
|
16697
|
16698
|
16699
|
16712
|
16713
|
16714
|
16715
|
16716
|
16717
|
16718
|
16719
|
17368
|
17369
|
18767
|
18768
|
18769
|
18770
|
18771
|
18772
|
18773
|
18774
|
18775
|
18776
|
18777
|
18891
|
18892
|
18893
|
18894
|
20059
|
20060
|
20779
|
21432
|
21433
|
21434
|
21435
|
21436
|
21489
|
21543
|
21546
|
21635
|
21798
|
21799
|
21800
|
21801
|
21802
|
21803
|
23588
|
23589
|
23590
|
23591
|
23607
|
23608
|
23609
|
23610
|
23611
|
23612
|
23613
|
26418
|
26419
|
26420
|
26421
|
26422
|
26423
|
26424
|
26878
|
26879
|
26880
|
26881
|
26882
|
26883
|
26884
|
27114
|
27125
|
27154
|
27155
|
27225
|
30362
|
30363
|
30364
|
30365
|
30366
|
30367
|
30368
|
30369
|
30370
|
30371
|
32384
|
32385
|
32386
|
32387
|
32388
|
32389
|
32390
|
32391
|
32392
|
32393
|
36198
|
36199
|
36200
|
36201
|
36202
|
36203
|
36204
|
36205
|
36206
|
36207
|
36208
|
36209
|
36210
|
36211
|
36213
|
36214
|
36215
|
36216
|
36217
|
36218
|
36219
|
36220
|
36221
|
36222
|
36223
|
36224
|
36225
|
36226
|
36227
|
36228
|
36229
|
36230
|
36231
|
36232
|
37681
|
37682
|
37683
|
37684
|
37685
|
37686
|
37687
|
37688
|
37689
|
37690
|
37691
|
37692
|
37693
|
37694
|
37696
|
37697
|
37698
|
37699
|
37700
|
37701
|
37702
|
37703
|
37704
|
37705
|
37706
|
38911
|
38912
|
38913
|
38914
|
38915
|
38916
|
38917
|
38918
|
38919
|
38920
|
38921
|
38922
|
38923
|
38924
|
38925
|
38926
|
38927
|
38928
|
38929
|
38930
|
38931
|
38932
|
38933
|
38934
|
38935
|
38936
|
39113
|
39114
|
39115
|
39116
|
39117
|
39118
|
39119
|
39120
|
39121
|
39122
|
39123
|
39626
|
39627
|
39628
|
39629
|
39630
|
39631
|
39632
|
39633
|
39634
|
39635
|
39636
|
39637
|
39638
|
41275
|
41276
|
41277
|
41278
|
41279
|
41280
|
41281
|
41282
|
41283
|
41284
|
41285
|
41286
|
41287
|
41288
|
41448
|
41449
|
41450
|
41783