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

(-)a/admin/z3950servers.pl (-8 / +8 lines)
Lines 36-41 use Koha::Database; Link Here
36
my $input = new CGI;
36
my $input = new CGI;
37
my $op = $input->param('op') || 'list';
37
my $op = $input->param('op') || 'list';
38
my $id = $input->param('id') || 0;
38
my $id = $input->param('id') || 0;
39
my $type = $input->param('type') || '';
39
my $searchfield = '';
40
my $searchfield = '';
40
41
41
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( {
42
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( {
Lines 58-86 if( $op eq 'delete_confirmed' && $id ) { Link Here
58
    my $server = $schema->resultset('Z3950server')->find($id);
59
    my $server = $schema->resultset('Z3950server')->find($id);
59
    if ( $server ) {
60
    if ( $server ) {
60
        $server->delete;
61
        $server->delete;
61
        $template->param( msg_deleted => 1, msg_add => $server->name );
62
        $template->param( msg_deleted => 1, msg_add => $server->servername );
62
    } else {
63
    } else {
63
        $template->param( msg_notfound => 1, msg_add => $id );
64
        $template->param( msg_notfound => 1, msg_add => $id );
64
    }
65
    }
65
    $id = 0;
66
    $id = 0;
66
} elsif ( $op eq 'add_validated' ) {
67
} elsif ( $op eq 'add_validated' ) {
67
    my @fields=qw/host port db userid password rank syntax encoding timeout
68
    my @fields=qw/host port db userid password rank syntax encoding timeout
68
        recordtype checked/;
69
        recordtype checked servername servertype sru_options sru_fields
70
        add_xslt/;
69
    my $formdata = _form_data_hashref( $input, \@fields );
71
    my $formdata = _form_data_hashref( $input, \@fields );
70
    #add name from servername (an input with name="name" gave problems)
71
    $formdata->{name} = $input->param('servername');
72
    if( $id ) {
72
    if( $id ) {
73
        my $server = $schema->resultset('Z3950server')->find($id);
73
        my $server = $schema->resultset('Z3950server')->find($id);
74
        if ( $server ) {
74
        if ( $server ) {
75
            $server->update( $formdata );
75
            $server->update( $formdata );
76
            $template->param( msg_updated => 1, msg_add => $formdata->{name} );
76
            $template->param( msg_updated => 1, msg_add => $formdata->{servername} );
77
        } else {
77
        } else {
78
            $template->param( msg_notfound => 1, msg_add => $id );
78
            $template->param( msg_notfound => 1, msg_add => $id );
79
        }
79
        }
80
        $id = 0;
80
        $id = 0;
81
    } else {
81
    } else {
82
        $schema->resultset('Z3950server')->create( $formdata );
82
        $schema->resultset('Z3950server')->create( $formdata );
83
        $template->param( msg_added => 1, msg_add => $formdata->{name} );
83
        $template->param( msg_added => 1, msg_add => $formdata->{servername} );
84
    }
84
    }
85
} else {
85
} else {
86
    #use searchfield only in remaining operations
86
    #use searchfield only in remaining operations
Lines 94-100 if ( $op eq 'add' || $op eq 'edit' ) { Link Here
94
    $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id;
94
    $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id;
95
    delete $data->[0]->{id} if @$data && $op eq 'add'; #cloning record
95
    delete $data->[0]->{id} if @$data && $op eq 'add'; #cloning record
96
    $template->param( add_form => 1, server => @$data? $data->[0]: undef,
96
    $template->param( add_form => 1, server => @$data? $data->[0]: undef,
97
        op => $op );
97
        op => $op, type => $op eq 'add'? lc $type: '' );
98
} else {
98
} else {
99
    $data = ServerSearch( $schema, $id, $searchfield );
99
    $data = ServerSearch( $schema, $id, $searchfield );
100
    $template->param( loop => \@$data, searchfield => $searchfield, id => $id,
100
    $template->param( loop => \@$data, searchfield => $searchfield, id => $id,
Lines 107-113 output_html_with_http_headers $input, $cookie, $template->output; Link Here
107
sub ServerSearch  { #find server(s) by id or name
107
sub ServerSearch  { #find server(s) by id or name
108
    my ( $schema, $id, $searchstring )= @_;
108
    my ( $schema, $id, $searchstring )= @_;
109
    my $rs = $schema->resultset('Z3950server')->search(
109
    my $rs = $schema->resultset('Z3950server')->search(
110
        $id ? { id => $id }: { name => { like => $searchstring.'%' } },
110
        $id ? { id => $id }: { servername => { like => $searchstring.'%' } },
111
        { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }
111
        { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }
112
    );
112
    );
113
    return [ $rs->all ];
113
    return [ $rs->all ];
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt (-12 / +54 lines)
Lines 1-7 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
3
[% BLOCK ServerType %]
4
    [% IF (server.servertype||type) == 'sru' %]
5
        SRU
6
    [% ELSIF (server.servertype||type) == 'zed' %]
7
        Z39.50
8
    [% END %]
9
[% END %]
10
2
<title>Koha &rsaquo; Administration &rsaquo; Z39.50 servers
11
<title>Koha &rsaquo; Administration &rsaquo; Z39.50 servers
3
[% IF op == 'edit' %] &rsaquo; Modify Z39.50 server [% server.name %][% END %]
12
[% IF op == 'edit' %] &rsaquo; Modify [% PROCESS ServerType %] server [% server.servername %][% END %]
4
[% IF op ==  'add' %] &rsaquo; New Z39.50 server[% END %]
13
[% IF op ==  'add' %] &rsaquo; New [% PROCESS ServerType %] server[% END %]
5
</title>
14
</title>
6
[% INCLUDE 'doc-head-close.inc' %]
15
[% INCLUDE 'doc-head-close.inc' %]
7
16
Lines 20-25 Link Here
20
            $("#encoding").val('[% server.encoding %]');
29
            $("#encoding").val('[% server.encoding %]');
21
            $("#recordtype").val('[% server.recordtype %]');
30
            $("#recordtype").val('[% server.recordtype %]');
22
        [% END %]
31
        [% END %]
32
        // Disable recordtype (and default to bib) for non-Z3950 servers until auth is supported
33
        [% UNLESS (server.servertype||type) == 'zed' %]
34
            $("#recordtype").prop('disabled',true);
35
        [% END %]
23
        $( "#serverentry" ).validate({
36
        $( "#serverentry" ).validate({
24
            rules: {
37
            rules: {
25
                servername: { required: true },
38
                servername: { required: true },
Lines 33-39 Link Here
33
                timeout: { number: true }
46
                timeout: { number: true }
34
            }
47
            }
35
        });
48
        });
49
        $("#serverentry").submit(function( event ) {
50
            // copy show_sru_fields to hidden counterpart
51
            $('#sru_fields').val( $('#show_sru_fields').val() );
52
            // enable recordtype to include field in post
53
            $('#recordtype').prop('disabled',false);
54
        });
36
    });
55
    });
56
    function ModMapping () {
57
        var map= $('#show_sru_fields').val();
58
        window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map,'popup','width=800,height=400,resizable=no,toolbar=false,scrollbars=no,top');
59
    }
37
[% ELSE %]
60
[% ELSE %]
38
    $(document).ready(function() {
61
    $(document).ready(function() {
39
        $("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
62
        $("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
Lines 61-68 Link Here
61
84
62
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
85
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
63
<a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50 servers</a>
86
<a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50 servers</a>
64
[% IF op == 'edit' %]&rsaquo; Modify Z39.50 server [% server.name %][% END %]
87
[% IF op == 'edit' %]&rsaquo; Modify [% PROCESS ServerType %] server [% server.servername %][% END %]
65
[% IF op ==  'add' %]&rsaquo; New Z39.50 server[% END %]
88
[% IF op ==  'add' %]&rsaquo; New [% PROCESS ServerType %] server[% END %]
66
</div>
89
</div>
67
90
68
<div id="doc3" class="yui-t2">
91
<div id="doc3" class="yui-t2">
Lines 83-97 Link Here
83
[% IF ( add_form ) %]
106
[% IF ( add_form ) %]
84
    <form action="[% script_name %]" name="Aform" method="post" id="serverentry">
107
    <form action="[% script_name %]" name="Aform" method="post" id="serverentry">
85
        <input type="hidden" name="op" value="add_validated" />
108
        <input type="hidden" name="op" value="add_validated" />
109
        <input type="hidden" name="servertype" value="[% server.servertype||type||'zed' %]"/>
86
        [% IF op == 'edit' %]
110
        [% IF op == 'edit' %]
87
            <h1>Modify Z39.50 server</h1>
111
            <h1>Modify [% PROCESS ServerType %] server</h1>
88
            <input type="hidden" name="id" value="[% server.id %]" />
112
            <input type="hidden" name="id" value="[% server.id %]" />
89
        [% ELSE %]
113
        [% ELSE %]
90
            <h1>New Z39.50 server</h1>
114
            <h1>New [% PROCESS ServerType %] server</h1>
91
        [% END %]                
115
        [% END %]                
92
        <fieldset class="rows">
116
        <fieldset class="rows">
93
        <ol>
117
        <ol>
94
        <li><label for="name" class="required">Z39.50 server: </label><input type="text" name="servername" id="servername" size="65" maxlength="100" onblur="toUC(this)" value="[% server.name | html %]" required="required"/> <span class="required">Required</span></li>
118
        <li><label for="name">Server name: </label><input type="text" name="servername" id="servername" size="65" maxlength="100" onblur="toUC(this)" value="[% server.servername | html %]"/></li>
95
119
96
        <li><label for="host" class="required">Hostname: </label> <input type="text" name="host" id="host" size="30" value="[% server.host %]" required="required" /> <span class="required">Required</span>
120
        <li><label for="host" class="required">Hostname: </label> <input type="text" name="host" id="host" size="30" value="[% server.host %]" required="required" /> <span class="required">Required</span>
97
        </li>
121
        </li>
Lines 151-156 Link Here
151
            <option value="authority">Authority</option>
175
            <option value="authority">Authority</option>
152
        </select>
176
        </select>
153
        </li>
177
        </li>
178
        [% IF (server.servertype||type) == 'sru' %]
179
        <li>
180
        <label for="sru_options">Additional SRU options: </label>
181
        <input type="text" name="sru_options" id="sru_options" size="50" value="[% server.sru_options %]"/>
182
        <span>( Separate options by commas. Example: sru=get,sru_version=1.1. See also http://www.indexdata.com/yaz/doc/zoom.html.)</span>
183
        </li>
184
        <li>
185
        <label for="sru_fields">SRU Search fields mapping: </label>
186
        <input type="hidden" name="sru_fields" id="sru_fields" value="[% server.sru_fields %]" />
187
        <input type="text" name="show_sru_fields" id="show_sru_fields" size="100" value="[% server.sru_fields %]" disabled/> <input type="button" value="Modify" onclick="ModMapping()" />
188
        </li>
189
        [% END %]
190
        <li>
191
        <label for="add_xslt">XSLT File(s) for transforming results: </label>
192
        <input type="text" name="add_xslt" id="add_xslt" size="100" value="[% server.add_xslt %]"/>
193
        <span>( Separate files by commas.)</span>
194
        </li>
195
154
        </ol>
196
        </ol>
155
        </fieldset>
197
        </fieldset>
156
198
Lines 160-166 Link Here
160
202
161
[% IF op == 'list' %]
203
[% IF op == 'list' %]
162
    <div id="toolbar" class="btn-toolbar">
204
    <div id="toolbar" class="btn-toolbar">
163
        <a id="newserver" class="btn btn-small" href="/cgi-bin/koha/admin/z3950servers.pl?op=add"><i class="icon-plus"></i> New Z39.50 server</a>
205
        <a id="newserver" class="btn btn-small" href="/cgi-bin/koha/admin/z3950servers.pl?op=add&type=zed"><i class="icon-plus"></i> New Z39.50 server</a>
206
        <a id="newserver" class="btn btn-small" href="/cgi-bin/koha/admin/z3950servers.pl?op=add&type=sru"><i class="icon-plus"></i> New SRU server</a>
164
    </div>
207
    </div>
165
    <h3>Z39.50 servers administration</h3>
208
    <h3>Z39.50 servers administration</h3>
166
    [% IF id %]
209
    [% IF id %]
Lines 178-186 Link Here
178
            [% ELSE %]
221
            [% ELSE %]
179
                <tr>
222
                <tr>
180
            [% END %]
223
            [% END %]
181
            <td><a href="[% loo.script_name %]?op=edit&amp;id=[% loo.id %]">[% loo.name %]</a></td><td>[% loo.host %]:[% loo.port %]</td><td>[% loo.db %]</td><td>[% loo.userid %]</td><td>[% IF loo.password %]########[% END %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank %]</td>
224
            <td><a href="[% loo.script_name %]?op=edit&amp;id=[% loo.id %]">[% loo.servername %]</a></td><td>[% loo.host %]:[% loo.port %]</td><td>[% loo.db %]</td><td>[% loo.userid %]</td><td>[% IF loo.password %]########[% END %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank %]</td>
182
<td>[% loo.syntax %]</td><td>[% loo.encoding %]</td><td>[% loo.timeout %]</td><td>[% loo.recordtype %]</td>
225
            <td>[% loo.syntax %]</td><td>[% loo.encoding %]</td><td>[% loo.timeout %]</td><td>[% loo.recordtype %]</td>
183
            <td><a href="[% loo.script_name %]?op=edit&amp;id=[% loo.id %]">Edit</a> <a href="[% loo.script_name %]?op=add&amp;id=[% loo.id %]">Copy</a> <a href="javascript:void(0);" onclick="ConfirmDelete('[% loo.name | replace("['\"]","") %]','[% loo.id %]');">Delete</a></td>
226
            <td><a href="[% loo.script_name %]?op=edit&amp;id=[% loo.id %]">Edit</a> <a href="[% loo.script_name %]?op=add&amp;id=[% loo.id %]">Copy</a> <a href="javascript:void(0);" onclick="ConfirmDelete('[% loo.servername | replace("['\"]","") %]','[% loo.id %]');">Delete</a></td>
184
            </tr>
227
            </tr>
185
        [% END %]
228
        [% END %]
186
        </tbody>
229
        </tbody>
187
- 

Return to bug 6536