View | Details | Raw Unified | Return to bug 10480
Collapse All | Expand All

(-)a/cataloguing/addbiblio.pl (-4 / +32 lines)
Lines 46-51 if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { Link Here
46
}
46
}
47
47
48
our($tagslib,$authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950);
48
our($tagslib,$authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950);
49
our $building_plugin={};
50
    #hashref { record => .., subfieldid => .., tabno => .., }
51
    #used in building the new cataloging plugins (without redefinitions)
52
    #plugin script should add function and javascript to hash
49
53
50
=head1 FUNCTIONS
54
=head1 FUNCTIONS
51
55
Lines 406-415 sub create_input { Link Here
406
            closedir( DIR );
410
            closedir( DIR );
407
        }
411
        }
408
        my $plugin = $cgidir . "/" . $tagslib->{$tag}->{$subfield}->{'value_builder'};
412
        my $plugin = $cgidir . "/" . $tagslib->{$tag}->{$subfield}->{'value_builder'};
409
        if (do $plugin) {
413
        my ( $function_name, $javascript ) = _new_plugin_builder( $plugin, $rec, $subfield_data{id}, $tabloop );
410
            my $extended_param = plugin_parameters( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop );
414
        if ($function_name) {
411
            my ( $function_name, $javascript ) = plugin_javascript( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop );
412
        
413
            $subfield_data{marc_value} =
415
            $subfield_data{marc_value} =
414
                    "<input tabindex=\"1\"
416
                    "<input tabindex=\"1\"
415
                            type=\"text\"
417
                            type=\"text\"
Lines 491-496 sub create_input { Link Here
491
    return \%subfield_data;
493
    return \%subfield_data;
492
}
494
}
493
495
496
sub _new_plugin_builder {
497
    my ($plugin, $record, $subfieldid, $tabno) = @_;
498
499
    $building_plugin = {
500
        record     => $record,
501
        subfieldid => $subfieldid,
502
        tabno      => $tabno,
503
    };
504
    do $plugin || return;
505
506
    #first, try the new way without redefines using building_plugin hash
507
    if( defined $building_plugin->{function} &&
508
            defined $building_plugin->{javascript} ) {
509
        return ($building_plugin->{function},
510
            $building_plugin->{javascript} );
511
    }
512
513
    #arriving here, we try the old way with redefines: we are PHASING this OUT
514
    #next call is of no use, commented
515
    #my $extended_param = plugin_parameters( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop );
516
    my ( $function_name, $javascript ) = plugin_javascript( undef, $record, $tagslib, $subfieldid, $tabno );
517
        #first param was dbh, not needed: use C4::Context->dbh in plugin
518
        #note also that tagslib is global (so actually superfluous)
519
    return ( $function_name, $javascript );
520
        #caller tests if function_name is defined
521
}
494
522
495
=head2 format_indicator
523
=head2 format_indicator
496
524
(-)a/cataloguing/value_builder/marc21_leader.pl (-57 / +60 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
4
# Copyright 2000-2002 Katipo Communications
3
# Copyright 2000-2002 Katipo Communications
5
#
4
#
6
# This file is part of Koha.
5
# This file is part of Koha.
Lines 19-47 Link Here
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
19
21
use strict;
20
use strict;
22
#use warnings; FIXME - Bug 2505
21
use warnings;
23
use C4::Auth;
22
24
use CGI;
23
use CGI;
25
use C4::Context;
26
24
25
use C4::Auth;
26
use C4::Context;
27
use C4::Search;
27
use C4::Search;
28
use C4::Output;
28
use C4::Output;
29
29
30
=head1
30
# This plugin has been moved to the new style using $building_plugin
31
31
32
plugin_parameters : other parameters added when the plugin is called by the dopop function
32
our $building_plugin;
33
if(defined $building_plugin) {
34
    pass_script_for_marc21_leader();
35
}
36
else {
37
    run_marc21_leader_plugin();
38
}
33
39
34
=cut
40
#-------------------------------------------------------------------------------
35
41
36
sub plugin_parameters {
42
sub pass_script_for_marc21_leader {
37
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
43
    my $field_number= $building_plugin->{subfieldid};
38
return "";
39
}
40
44
41
sub plugin_javascript {
45
    my $function_name= $field_number;
42
my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
46
    my $res="
43
my $function_name= $field_number;
44
my $res="
45
<script type=\"text/javascript\">
47
<script type=\"text/javascript\">
46
//<![CDATA[
48
//<![CDATA[
47
49
Lines 53-108 function Focus$function_name(subfield_managed) { Link Here
53
}
55
}
54
56
55
function Blur$function_name(subfield_managed) {
57
function Blur$function_name(subfield_managed) {
56
	return 1;
58
    return 1;
57
}
59
}
58
60
59
function Clic$function_name(i) {
61
function Clic$function_name(i) {
60
	defaultvalue=document.getElementById(\"$field_number\").value;
62
    defaultvalue=document.getElementById(\"$field_number\").value;
61
	newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=$field_number&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
63
    newin=window.open(\"../cataloguing/value_builder/marc21_leader.pl?index=$field_number&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
62
63
}
64
}
64
//]]>
65
//]]>
65
</script>
66
</script>
66
";
67
";
67
68
    $building_plugin->{function}= $function_name;
68
return ($function_name,$res);
69
    $building_plugin->{javascript}= $res;
69
}
70
}
70
sub plugin {
71
71
my ($input) = @_;
72
sub run_marc21_leader_plugin {
72
	my $index= $input->param('index');
73
    my $input = new CGI;
73
	my $result= $input->param('result');
74
    my $index= $input->param('index');
74
75
    my $result= $input->param('result');
75
76
76
	my $dbh = C4::Context->dbh;
77
    my $dbh = C4::Context->dbh;
77
78
78
my ($template, $loggedinuser, $cookie)
79
    my ($template, $loggedinuser, $cookie) = get_template_and_user(
79
    = get_template_and_user({template_name => "cataloguing/value_builder/marc21_leader.tmpl",
80
        {
80
			     query => $input,
81
            template_name => "cataloguing/value_builder/marc21_leader.tmpl",
81
			     type => "intranet",
82
            query => $input,
82
			     authnotrequired => 0,
83
            type => "intranet",
83
			     flagsrequired => {editcatalogue => '*'},
84
            authnotrequired => 0,
84
			     debug => 1,
85
            flagsrequired => {editcatalogue => '*'},
85
			     });
86
            debug => 1,
86
	$result = "     nam a22     7a 4500" unless $result;
87
        });
87
	my $f5 = substr($result,5,1);
88
    $result = "     nam a22     7a 4500" unless $result;
88
	my $f6 = substr($result,6,1);
89
    my $f5 = substr($result,5,1);
89
	my $f7 = substr($result,7,1);
90
    my $f6 = substr($result,6,1);
90
	my $f8 = substr($result,8,1);
91
    my $f7 = substr($result,7,1);
91
	my $f17 = substr($result,17,1);
92
    my $f8 = substr($result,8,1);
92
	my $f18 = substr($result,18,1);
93
    my $f17 = substr($result,17,1);
93
	my $f19 = substr($result,19,1);
94
    my $f18 = substr($result,18,1);
94
	my $f2023 = substr($result,20,4);
95
    my $f19 = substr($result,19,1);
95
	$template->param(index => $index,
96
    my $f2023 = substr($result,20,4);
96
							"f5$f5" => 1,
97
    $template->param(
97
							"f6$f6" => 1,
98
        index => $index,
98
							"f7$f7" => 1,
99
        "f5$f5" => 1,
99
							"f8$f8" => 1,
100
        "f6$f6" => 1,
100
							"f17$f17" => 1,
101
        "f7$f7" => 1,
101
							"f18$f18" => 1,
102
        "f8$f8" => 1,
102
							"f19$f19" => 1,
103
        "f17$f17" => 1,
103
							"f2023" => $f2023,
104
        "f18$f18" => 1,
104
					);
105
        "f19$f19" => 1,
105
        output_html_with_http_headers $input, $cookie, $template->output;
106
        "f2023" => $f2023,
107
    );
108
    output_html_with_http_headers $input, $cookie, $template->output;
106
}
109
}
107
110
108
1;
111
1;
(-)a/cataloguing/value_builder/new_example_plugin.pl (-1 / +71 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
6
use CGI;
7
8
#-------------------------------------------------------------------------------
9
10
# example of new cataloging plugin style without redefines
11
# if addbiblio calls this script, the global $building_plugin exists
12
# when copying this example, pick two new names to prevent redefining
13
14
our $building_plugin;
15
if(defined $building_plugin) {
16
    pass_script_for_myexample_plugin(); #TODO: pick a new name !
17
}
18
else {
19
    run_myexample_plugin(); #TODO: pick a new name !
20
}
21
22
#-------------------------------------------------------------------------------
23
24
sub pass_script_for_myexample_plugin { #TODO: pick a new name
25
26
    #via global $building_plugin, you receive three parameters:
27
    my $subfieldid = $building_plugin->{subfieldid};
28
    #uncomment following lines, if you need them
29
    #my $tabno = $building_plugin->{tabno};
30
    #my $oldrecord = $building_plugin->{record};
31
32
    #now return function name and javascript via global $building_plugin
33
    #your javascript normally contains a Blur, Clic and Focus function
34
    #call your plugin NO LONGER via plugin_launcher but directly
35
    #see also marc21_leader.pl
36
    my $function_name= $subfieldid; #valid choice, but may be different
37
    my $javascript=qq|
38
<script type=\"text/javascript\">
39
//<![CDATA[
40
function Focus$function_name(subfield_managed) {
41
    return 1;
42
}
43
function Blur$function_name(subfield_managed) {
44
    document.getElementById(\"$subfieldid\").value= '12345';
45
    return 1;
46
}
47
function Clic$function_name(i) {
48
    return 1;
49
}
50
//]]>
51
</script>
52
|;
53
#as you may be aware, this example just puts 12345 in your field and does not
54
#call a popup
55
56
    #FUNDAMENTAL: pass back via global hashref
57
    $building_plugin->{function}= $function_name;
58
    $building_plugin->{javascript}= $javascript;
59
}
60
61
62
#-------------------------------------------------------------------------------
63
64
sub run_myexample_plugin { #TODO: pick a new name !
65
    my $query=new CGI;
66
67
    #does nothing now
68
    #rest of your plugin script comes here
69
}
70
71
1;

Return to bug 10480