Bugzilla – Attachment 19169 Details for
Bug 10480
Improvements for framework plugins in cataloguing/item editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10480: Followup for additem.pl (no redefines for plugins)
Bug-10480-Followup-for-additempl-no-redefines-for-.patch (text/plain), 4.46 KB, created by
Marcel de Rooy
on 2013-06-20 09:21:22 UTC
(
hide
)
Description:
Bug 10480: Followup for additem.pl (no redefines for plugins)
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2013-06-20 09:21:22 UTC
Size:
4.46 KB
patch
obsolete
>From 5916cd5836bafdeef4d6188779024595f617f190 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 20 Jun 2013 11:03:41 +0200 >Subject: [PATCH] Bug 10480: Followup for additem.pl (no redefines for > plugins) >Content-Type: text/plain; charset=utf-8 > >Adds the same functionality for additem as in addbiblio. >Note that the new subroutine is slightly different from the addbiblio case. > >Test plan: >Test your cataloging plugins on Add/edit items. >If you have no one, temporarily connect new_example_plugin.pl; it will only >put 12345 in your item field. >--- > cataloguing/additem.pl | 47 ++++++++++++++++++++++++++++++++++++++--------- > 1 files changed, 38 insertions(+), 9 deletions(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index a2eacef..a6695f6 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -41,6 +41,10 @@ use MARC::File::XML; > use URI::Escape; > > our $dbh = C4::Context->dbh; >+our $building_plugin={}; >+ #hashref { record => .., subfieldid => .., } >+ #used in building the new cataloging plugins (without redefinitions) >+ #plugin script should add function and javascript to hash > > sub find_value { > my ($tagfield,$insubfield,$record) = @_; >@@ -241,19 +245,19 @@ sub generate_subfield_form { > elsif ( $subfieldlib->{value_builder} ) { > # opening plugin > my $plugin = C4::Context->intranetdir . "/cataloguing/value_builder/" . $subfieldlib->{'value_builder'}; >- if (do $plugin) { >- my $extended_param = plugin_parameters( $dbh, $temp, $tagslib, $subfield_data{id}, $loop_data ); >- my ( $function_name, $javascript ) = plugin_javascript( $dbh, $temp, $tagslib, $subfield_data{id}, $loop_data ); >- my $change = index($javascript, 'function Change') > -1 ? >- "return Change$function_name($subfield_data{random}, '$subfield_data{id}');" : >- 'return 1;'; >+ my ( $function_name, $javascript ) = _new_plugin_builder( $plugin, $temp, $subfield_data{id} ); #no tabno passed for items >+ if( $function_name ) { >+ my $change = index($javascript, 'function Change') > -1 ? >+ "return Change$function_name($subfield_data{random}, '$subfield_data{id}');" : >+ 'return 1;'; > $subfield_data{marc_value} = qq[<input type="text" $attributes > onfocus="Focus$function_name($subfield_data{random}, '$subfield_data{id}');" >- onchange=" $change" >- onblur=" Blur$function_name($subfield_data{random}, '$subfield_data{id}');" /> >+ onchange=" $change" >+ onblur=" Blur$function_name($subfield_data{random}, '$subfield_data{id}');" /> > <a href="#" class="buttonDot" onclick="Clic$function_name('$subfield_data{id}'); return false;" title="Tag Editor">...</a> > $javascript]; >- } else { >+ } >+ else { > warn "Plugin Failed: $plugin"; > $subfield_data{marc_value} = "<input type=\"text\" $attributes />"; # supply default input form > } >@@ -280,6 +284,31 @@ sub generate_subfield_form { > return \%subfield_data; > } > >+sub _new_plugin_builder { >+ my ($plugin, $record, $subfieldid) = @_; >+ >+ $building_plugin = { >+ record => $record, >+ subfieldid => $subfieldid, >+ }; >+ do $plugin || return; >+ >+ #first, try the new way without redefines using building_plugin hash >+ if( defined $building_plugin->{function} && >+ defined $building_plugin->{javascript} ) { >+ return ($building_plugin->{function}, >+ $building_plugin->{javascript} ); >+ } >+ >+ #arriving here, we try the old way with redefines: we are PHASING this OUT >+ #next call is of no use, commented >+ #my $extended_param = plugin_parameters( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop ); >+ my ( $function_name, $javascript ) = plugin_javascript( undef, $record, undef, $subfieldid ); #no tabno passed for items, same for tagslib >+ #first param was dbh, not needed: use C4::Context->dbh in plugin >+ return ( $function_name, $javascript ); >+ #caller tests if function_name is defined >+} >+ > # Removes some subfields when prefilling items > # This function will remove any subfield that is not in the SubfieldsToUseWhenPrefill syspref > sub removeFieldsForPrefill { >-- >1.7.7.6
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 10480
:
19064
|
19072
|
19098
|
19152
|
19154
|
19168
|
19169
|
34308
|
34309
|
34310
|
34311
|
34312
|
35187
|
35188
|
35189
|
35190
|
35191
|
35286
|
35287
|
36106
|
36107
|
36108
|
36109
|
36110
|
36953
|
36954
|
36955
|
36956
|
36957
|
37948
|
37949
|
37950
|
37951
|
37952
|
37953
|
37983