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

(-)a/C4/Charset.pm (+35 lines)
Lines 39-44 BEGIN { Link Here
39
        SetUTF8Flag
39
        SetUTF8Flag
40
        SetMarcUnicodeFlag
40
        SetMarcUnicodeFlag
41
        StripNonXmlChars
41
        StripNonXmlChars
42
        nsb_clean
42
    );
43
    );
43
}
44
}
44
45
Lines 382-387 sub StripNonXmlChars { Link Here
382
    return $str;
383
    return $str;
383
}
384
}
384
385
386
387
388
=head2 nsb_clean
389
390
=over 4
391
392
nsb_clean($string);
393
394
=back
395
396
Removes Non Sorting Block characters
397
398
=cut
399
sub nsb_clean {
400
    my $NSB  = '\x88' ;        # NSB : begin Non Sorting Block
401
    my $NSE  = '\x89' ;        # NSE : Non Sorting Block end
402
    my $NSB2 = '\x98' ;        # NSB : begin Non Sorting Block
403
    my $NSE2 = '\x9C' ;        # NSE : Non Sorting Block end
404
    my $C2   = '\xC2' ;        # What is this char ? It is sometimes left by the regexp after removing NSB / NSE
405
406
    # handles non sorting blocks
407
    my ($string) = @_ ;
408
    $_ = $string ;
409
    s/$NSB//g ;
410
    s/$NSE//g ;
411
    s/$NSB2//g ;
412
    s/$NSE2//g ;
413
    s/$C2//g ;
414
    $string = $_ ;
415
416
    return($string) ;
417
}
418
419
385
=head1 INTERNAL FUNCTIONS
420
=head1 INTERNAL FUNCTIONS
386
421
387
=head2 _default_marc21_charconv_to_utf8
422
=head2 _default_marc21_charconv_to_utf8
(-)a/authorities/auth_finder.pl (-2 / +2 lines)
Lines 137-143 if ( $op eq "do_search" ) { Link Here
137
    }
137
    }
138
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
138
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
139
        {
139
        {
140
            template_name   => "authorities/searchresultlist-auth.tmpl",
140
            template_name   => "authorities/searchresultlist-auth.tt",
141
            query           => $query,
141
            query           => $query,
142
            type            => 'intranet',
142
            type            => 'intranet',
143
            authnotrequired => 0,
143
            authnotrequired => 0,
Lines 168-174 if ( $op eq "do_search" ) { Link Here
168
} else {
168
} else {
169
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
169
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
170
        {
170
        {
171
            template_name   => "authorities/auth_finder.tmpl",
171
            template_name   => "authorities/auth_finder.tt",
172
            query           => $query,
172
            query           => $query,
173
            type            => 'intranet',
173
            type            => 'intranet',
174
            authnotrequired => 0,
174
            authnotrequired => 0,
(-)a/authorities/ysearch.pl (+71 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
4
5
# Copyright 2011 BibLibre
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
=head1 ysearch.pl
23
24
This script allows ajax call for dynamic authorities search
25
(used in auth_finder.pl)
26
27
=cut
28
29
use CGI;
30
use Modern::Perl;
31
use C4::Context;
32
use C4::Charset;
33
use C4::AuthoritiesMarc;
34
use C4::Auth qw/check_cookie_auth/;
35
36
my $query = new CGI;
37
38
binmode STDOUT, ":utf8";
39
print $query->header( -type => 'text/plain', -charset => 'UTF-8' );
40
41
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { } );
42
if ( $auth_status ne "ok" ) {
43
    exit 0;
44
}
45
46
    my $searchstr = $query->param('query');
47
    my $searchtype = $query->param('querytype');
48
    my @value;
49
    given ($searchtype) {
50
        when (/^marclist$/)      { @value = (undef, undef, $searchstr); }
51
        when (/^mainentry$/)     { @value = (undef, $searchstr, undef); }
52
        when (/^mainmainentry$/) { @value = ($searchstr, undef, undef); }
53
    }
54
    my @marclist  = ($searchtype);
55
    my $authtypecode = $query->param('authtypecode');
56
    my @and_or    = $query->param('and_or');
57
    my @excluding = $query->param('excluding');
58
    my @operator  = $query->param('operator');
59
    my $orderby   = $query->param('orderby');
60
61
    my $resultsperpage = 50;
62
    my $startfrom = 0;
63
64
    my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby );
65
    foreach (@$results) {
66
	my ($value) = $_->{'summary'};
67
        # Removes new lines
68
        $value =~ s/<br \/>/ /g;
69
        $value =~ s/\n//g;
70
	print nsb_clean($value) . "\n";
71
    }
(-)a/cataloguing/ysearch.pl (-19 / +2 lines)
Lines 24-34 Link Here
24
24
25
=cut
25
=cut
26
26
27
use strict;
27
use Modern::Perl;
28
29
#use warnings; FIXME - Bug 2505
30
use CGI;
28
use CGI;
31
use C4::Context;
29
use C4::Context;
30
use C4::Charset;
32
use C4::Auth qw/check_cookie_auth/;
31
use C4::Auth qw/check_cookie_auth/;
33
32
34
my $input = new CGI;
33
my $input = new CGI;
Lines 59-78 while ( my $rec = $sth->fetchrow_hashref ) { Link Here
59
    print nsb_clean($rec->{$field}) . "\n";
58
    print nsb_clean($rec->{$field}) . "\n";
60
}
59
}
61
60
62
sub nsb_clean {
63
    my $NSB = '\x88' ;        # NSB : begin Non Sorting Block
64
    my $NSE = '\x89' ;        # NSE : Non Sorting Block end
65
    my $NSB2 = '\x98' ;        # NSB : begin Non Sorting Block
66
    my $NSE2 = '\x9C' ;        # NSE : Non Sorting Block end
67
    # handles non sorting blocks
68
    my ($string) = @_ ;
69
    $_ = $string ;
70
    s/$NSB//g ;
71
    s/$NSE//g ;
72
    s/$NSB2//g ;
73
    s/$NSE2//g ;
74
    $string = $_ ;
75
76
    return($string) ;
77
}
78
61
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc (-8 / +80 lines)
Lines 1-3 Link Here
1
<script type="text/javascript">
2
//<![CDATA[
3
YAHOO.util.Event.onContentReady("header_search", function() {
4
    new function() {
5
        // Define a custom formatter function
6
        this.fnCustomFormatter = function(oResultItem, sQuery) {
7
            var name        = oResultItem[0];
8
            var aMarkup = [
9
                "<div class=\"sample-result\">",
10
                name,
11
                "<\/div>"];
12
            return (aMarkup.join(""));
13
        };
14
15
    // marclist
16
        this.marclistDS = new YAHOO.widget.DS_XHR("/cgi-bin/koha/authorities/ysearch.pl", ["\n", "\t"]);
17
        this.marclistDS.scriptQueryAppend = "op=do_search&type=intranet&and_or=and&operator=contains&orderby=HeadingAsc&querytype=marclist";
18
        this.marclistDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
19
        this.marclistDS.maxCacheEntries = 60;
20
        this.marclistDS.queryMatchSubset = false;
21
22
        var myInput = document.getElementById('value_any');
23
        var myContainer = document.getElementById('yvaluecontainermarclist');
24
        this.oAutoComp = new YAHOO.widget.AutoComplete(myInput,myContainer,this.marclistDS);
25
        this.oAutoComp.queryDelay = 1;
26
        this.oAutoComp.formatResult = this.fnCustomFormatter;
27
        this.oAutoComp.maxResultsDisplayed = 1000;
28
29
30
    // mainentry
31
    this.mainentryDS = new YAHOO.widget.DS_XHR("/cgi-bin/koha/authorities/ysearch.pl", ["\n", "\t"]);
32
        this.mainentryDS.scriptQueryAppend = "op=do_search&type=intranet&and_or=and&operator=contains&orderby=HeadingAsc&querytype=mainentry";
33
        this.mainentryDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
34
        this.mainentryDS.maxCacheEntries = 60;
35
        this.mainentryDS.queryMatchSubset = false;
36
37
        var myInput = document.getElementById('value_main');
38
        var myContainer = document.getElementById('yvaluecontainermainentry');
39
        this.oAutoComp = new YAHOO.widget.AutoComplete(myInput,myContainer,this.mainentryDS);
40
        this.oAutoComp.queryDelay = 1;
41
        this.oAutoComp.formatResult = this.fnCustomFormatter;
42
        this.oAutoComp.maxResultsDisplayed = 1000;
43
44
45
    // mainmainentry
46
    this.mainentryDS = new YAHOO.widget.DS_XHR("/cgi-bin/koha/authorities/ysearch.pl", ["\n", "\t"]);
47
        this.mainentryDS.scriptQueryAppend = "op=do_search&type=intranet&and_or=and&operator=contains&orderby=HeadingAsc&querytype=mainmainentry";
48
        this.mainentryDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
49
        this.mainentryDS.maxCacheEntries = 60;
50
        this.mainentryDS.queryMatchSubset = false;
51
52
        var myInput = document.getElementById('value_mainstr');
53
        var myContainer = document.getElementById('yvaluecontainermainmainentry');
54
        this.oAutoComp = new YAHOO.widget.AutoComplete(myInput,myContainer,this.mainentryDS);
55
        this.oAutoComp.queryDelay = 1;
56
        this.oAutoComp.formatResult = this.fnCustomFormatter;
57
        this.oAutoComp.maxResultsDisplayed = 1000;
58
59
60
}
61
});
62
//]]>
63
</script>
64
65
66
<span id="header_search">
1
<form name="f" method="get" action="auth_finder.pl">
67
<form name="f" method="get" action="auth_finder.pl">
2
            <input type="hidden" name="op" value="do_search" />
68
            <input type="hidden" name="op" value="do_search" />
3
            <input type="hidden" name="type" value="intranet" />
69
            <input type="hidden" name="type" value="intranet" />
Lines 17-24 Link Here
17
                        <option value="start">starts with</option>
83
                        <option value="start">starts with</option>
18
                        <option value="is">is exactly</option>
84
                        <option value="is">is exactly</option>
19
                    </select>
85
                    </select>
20
                    <input type="text" name="value_mainstr" value="[% value_mainstr |html %]" />
86
                    <input id="value_mainstr" style="width:400px;" type="text" name="value_mainstr" value="[% value_mainstr |html %]" />
87
                    <div id="yvaluecontainermainmainentry"></div>
21
                </li>
88
                </li>
89
22
                <li>
90
                <li>
23
                    <label for="mainentry">Main entry</label>
91
                    <label for="mainentry">Main entry</label>
24
                    <input type="hidden" name="marclist" value="mainentry" />
92
                    <input type="hidden" name="marclist" value="mainentry" />
Lines 29-36 Link Here
29
                        <option value="start">starts with</option>
97
                        <option value="start">starts with</option>
30
                        <option value="is">is exactly</option>
98
                        <option value="is">is exactly</option>
31
                    </select>
99
                    </select>
32
                    <input type="text" name="value_main" value="[% value_main |html %]" />
100
                    <input id="value_main" style="width:400px;" type="text" name="value_main" value="[% value_main |html %]" />
101
                    <div id="yvaluecontainermainentry"></div>
33
                </li>
102
                </li>
103
34
                <li>
104
                <li>
35
                    <label for="marclist">Anywhere</label>
105
                    <label for="marclist">Anywhere</label>
36
                    <input type="hidden" name="marclist" value="any" />
106
                    <input type="hidden" name="marclist" value="any" />
Lines 41-47 Link Here
41
                        <option value="start">starts with</option>
111
                        <option value="start">starts with</option>
42
                        <option value="is">is exactly</option>
112
                        <option value="is">is exactly</option>
43
                    </select>
113
                    </select>
44
                    <input type="text" name="value_any" value="[% value_any |html %]" />
114
                    <input id="value_any" style="width:400px;" type="text" name="value_any" value="[% value_any |html %]" />
115
                    <div id="yvaluecontainermarclist"></div>
45
                </li>
116
                </li>
46
                <li>
117
                <li>
47
                    <label for="marclist">Heading match</label>
118
                    <label for="marclist">Heading match</label>
Lines 55-67 Link Here
55
                    </select>
126
                    </select>
56
                    <input type="text" name="value_match" value="[% value_match |html %]" />
127
                    <input type="text" name="value_match" value="[% value_match |html %]" />
57
                </li>
128
                </li>
58
		<li>
129
        <li>
59
		<label for="orderby">Sort by </label>
130
        <label for="orderby">Sort by </label>
60
		<select name="orderby" id="orderby">
131
        <select name="orderby" id="orderby">
61
		    <option value="">No order</option>
132
            <option value="">No order</option>
62
            <option value="HeadingAsc" selected="selected">Heading Ascendant</option>
133
            <option value="HeadingAsc" selected="selected">Heading Ascendant</option>
63
            <option value="HeadingDsc">Heading Descendant</option>
134
            <option value="HeadingDsc">Heading Descendant</option>
64
        </select>
135
        </select>
65
		</li></ol></fieldset>
136
        </li></ol></fieldset>
66
            <fieldset class="action"> <input type="submit" value="Start search" class="submit" /> <a class="cancel close" href="#">Cancel</a></fieldset>
137
            <fieldset class="action"> <input type="submit" value="Start search" class="submit" /> <a class="cancel close" href="#">Cancel</a></fieldset>
67
</form>
138
</form>
139
</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/auth_finder.tt (-1 / +5 lines)
Lines 4-9 Link Here
4
<style type="text/css">
4
<style type="text/css">
5
#custom-doc { width:51.46em;*width:50.17em;min-width:675px; margin:auto; text-align:left; } 
5
#custom-doc { width:51.46em;*width:50.17em;min-width:675px; margin:auto; text-align:left; } 
6
</style>
6
</style>
7
    <script type="text/javascript" src="[% yuipath %]/utilities/utilities.js"></script>
8
    <script type="text/javascript" src="[% yuipath %]/datasource/datasource.js"></script>
9
    <script type="text/javascript" src="[% yuipath %]/autocomplete/autocomplete-min.js"></script>
10
11
7
</head>
12
</head>
8
<body>
13
<body>
9
<div id="custom-doc" class="yui-t7">
14
<div id="custom-doc" class="yui-t7">
10
- 

Return to bug 7400