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

(-)a/authorities/auth_finder.pl (-2 / +2 lines)
Lines 136-142 if ( $op eq "do_search" ) { Link Here
136
    }
136
    }
137
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
137
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
138
        {
138
        {
139
            template_name   => "authorities/searchresultlist-auth.tmpl",
139
            template_name   => "authorities/searchresultlist-auth.tt",
140
            query           => $query,
140
            query           => $query,
141
            type            => 'intranet',
141
            type            => 'intranet',
142
            authnotrequired => 0,
142
            authnotrequired => 0,
Lines 166-172 if ( $op eq "do_search" ) { Link Here
166
} else {
166
} else {
167
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
167
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
168
        {
168
        {
169
            template_name   => "authorities/auth_finder.tmpl",
169
            template_name   => "authorities/auth_finder.tt",
170
            query           => $query,
170
            query           => $query,
171
            type            => 'intranet',
171
            type            => 'intranet',
172
            authnotrequired => 0,
172
            authnotrequired => 0,
(-)a/authorities/ysearch.pl (+93 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 strict;
30
31
#use warnings; FIXME - Bug 2505
32
use CGI;
33
use C4::Context;
34
use C4::AuthoritiesMarc;
35
use C4::Auth qw/check_cookie_auth/;
36
use Switch;
37
38
my $query = new CGI;
39
40
binmode STDOUT, ":utf8";
41
print $query->header( -type => 'text/plain', -charset => 'UTF-8' );
42
43
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { } );
44
if ( $auth_status ne "ok" ) {
45
    exit 0;
46
}
47
48
    my $searchstr = $query->param('query');
49
    my $searchtype = $query->param('querytype');
50
    my @value;
51
    switch ($searchtype) {
52
	case "marclist"      { @value = (undef, undef, $searchstr); }
53
	case "mainentry"     { @value = (undef, $searchstr, undef); }
54
	case "mainmainentry" { @value = ($searchstr, undef, undef); }
55
    }
56
    my @marclist  = ($searchtype);
57
    my $authtypecode = $query->param('authtypecode');
58
    my @and_or    = $query->param('and_or');
59
    my @excluding = $query->param('excluding');
60
    my @operator  = $query->param('operator');
61
    my $orderby   = $query->param('orderby');
62
63
    my $resultsperpage = 50;
64
    my $startfrom = 0;
65
66
    my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby );
67
    foreach (@$results) {
68
	my ($value) = $_->{'summary'};
69
	print nsb_clean($value) . "\n";
70
    }
71
72
73
74
sub nsb_clean {
75
    my $NSB = '\x88' ;        # NSB : begin Non Sorting Block
76
    my $NSE = '\x89' ;        # NSE : Non Sorting Block end
77
    my $NSB2 = '\x98' ;        # NSB : begin Non Sorting Block
78
    my $NSE2 = '\x9C' ;        # NSE : Non Sorting Block end
79
    my $htmlnewline = "<br />";
80
    my $newline = "\n";
81
    # handles non sorting blocks
82
    my ($string) = @_ ;
83
    $_ = $string ;
84
    s/$NSB//g ;
85
    s/$NSE//g ;
86
    s/$NSB2//g ;
87
    s/$NSE2//g ;
88
    s/$htmlnewline/ /g;
89
    s/$newline//g;
90
    $string = $_ ;
91
92
    return($string) ;
93
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc (-11 / +84 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="" />
106
                    <input type="hidden" name="marclist" value="" />
Lines 41-55 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
47
		<label for="orderby">Sort by </label>
118
                <li>
48
		<select name="orderby" id="orderby">
119
                <label for="orderby">Sort by </label>
49
		    <option value="">No order</option>
120
                <select name="orderby" id="orderby">
50
            <option value="HeadingAsc" selected="selected">Heading Ascendant</option>
121
                    <option value="">No order</option>
51
            <option value="HeadingDsc">Heading Descendant</option>
122
                    <option value="HeadingAsc" selected="selected">Heading Ascendant</option>
52
        </select>
123
                    <option value="HeadingDsc">Heading Descendant</option>
53
		</li></ol></fieldset>
124
                </select>
125
                </li></ol></fieldset>
54
            <fieldset class="action"> <input type="submit" value="Start search" class="submit" /> <a class="cancel close" href="#">Cancel</a></fieldset>
126
            <fieldset class="action"> <input type="submit" value="Start search" class="submit" /> <a class="cancel close" href="#">Cancel</a></fieldset>
55
</form>
127
</form>
128
</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