Bug 26592: [20.05] Prevent XSS vulnerabilities when circ/ysearch.pl is used
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / advsearch.tt
1 [% USE raw %]
2 [% USE Koha %]
3 [% USE Asset %]
4 [% USE Branches %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Catalog &rsaquo; Advanced search</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 </head>
10
11 [%- BLOCK language_limit_select -%]
12 <select name="limit" id="[% ln_id | html %]">
13     <option value="">No limit</option>
14     [% FOREACH ln_loo IN ln_loop %]
15         [% IF ( ln_loo.selected ) %]
16             <option value="[% ln_index | html %],rtrn:[% ln_loo.iso639_2_code | html %]" selected="selected">
17                 [% ln_loo.language_description | html %]
18             </option>
19         [% ELSE %]
20             <option value="[% ln_index | html %],rtrn:[% ln_loo.iso639_2_code | html %]">
21                 [% ln_loo.language_description | html %]
22             </option>
23         [% END %]
24     [% END %]
25 </select>
26 [%- END -%]
27
28 <body id="catalog_advsearch" class="catalog">
29 [% INCLUDE 'header.inc' %]
30 [% INCLUDE 'adv-search.inc' %]
31 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; Advanced search</div>
32
33 <div class="main container-fluid">
34     <div class="row">
35         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
36
37 <form action="search.pl" method="get">
38 <div id="advanced-search">
39 <input type="hidden" name="advsearch" value="1"/>
40 <h1>Advanced search</h1>
41 <p>
42   <a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a>
43 </p>
44
45 <!-- SEARCH BUTTONS -->
46 <div id="toolbar" class="btn-toolbar">
47     <fieldset class="action" id="submit1">
48         <div class="btn-group">
49             <button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search</button>
50         </div>
51         <div class="btn-group">
52         [% IF ( expanded_options ) %]
53             <a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=0" class="btn btn-link"><i class="fa fa-search-minus"></i> Fewer options</a>
54         </div>
55         [% ELSE %]
56             <a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=1" class="btn btn-link"><i class="fa fa-search-plus"></i> More options</a>
57         </div>
58         [% END %]
59         <div class="btn-group">
60             <a href="/cgi-bin/koha/catalogue/search.pl?do=Clear&expanded_options=[% expanded_options | uri %]" class="btn btn-link"><i class="fa fa-trash"></i> Clear fields</a>
61         </div>
62     </fieldset>
63 </div>
64 <!-- /SEARCH BUTTONS -->
65
66
67 [% IF ( outer_servers_loop ) %]
68 <!-- DATABASES -->
69
70 <fieldset>
71         <legend>Select local databases</legend>
72                 [% FOREACH local_servers_loo IN local_servers_loop %]
73 [% IF ( local_servers_loo.checked ) %]<input type="checkbox" id="[% local_servers_loo.id | html %]" name="[% local_servers_loo.name | html %]" checked="checked" value="[% local_servers_loo.value | html %]" />[% ELSE %]<input type="checkbox" id="[% local_servers_loo.id | html %]" name="[% local_servers_loo.name | html %]" value="[% local_servers_loo.value | html %]" />[% END %]<label for="[% local_servers_loo.id | html %]"><img width="16" height="16" alt="[% local_servers_loo.id | html %]" src="[% themelang | html %]/img/[% local_servers_loo.icon | html %]" /> [% local_servers_loo.label | html %]</label>[% END %]
74 </fieldset>
75 <!-- /DATABASES -->
76 [% END %]
77
78 [% IF ( outer_servers_loop ) %]
79 <!-- REMOTE DATABASES -->
80 <fieldset id="databases">
81     <legend>Select remote databases</legend>
82                 [% FOREACH outer_servers_loo IN outer_servers_loop %]
83                 [% IF ( outer_servers_loo.checked ) %]<input type="checkbox" id="[% outer_servers_loo.id | html %]" name="[% outer_servers_loo.name | html %]" checked="checked" value="[% outer_servers_loo.value | html %]" />[% ELSE %]<input type="checkbox" id="[% outer_servers_loo.id | html %]" name="[% outer_servers_loo.name | html %]" value="[% outer_servers_loo.value | html %]" />[% END %]
84 <label for="[% outer_servers_loo.id | html %]"><img alt="[% outer_servers_loo.id | html %]" src="[% themelang | html %]/images/[% outer_servers_loo.icon | html %]" />[% outer_servers_loo.label | html %]</label>
85                 [% END %]
86     </fieldset>
87 <!-- /REMOTE DATABASES -->
88 [% END %]
89
90 <!-- BOOLEAN SEARCH OPTIONS -->
91     <fieldset id="searchterms">
92     <legend>Search for </legend>
93     [% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %]
94         <input type="checkbox" name="whole_record">
95         <label for="whole_record">Search entire MARC record</label>
96     [% END %]
97     [% FOREACH search_box IN search_boxes_loop %]
98         [% IF ( search_boxes_label ) %]<div style="text-indent: 4.5em;">[% ELSE %]<div>[% END %]
99                         [% IF ( expanded_options ) %]
100             [% IF ( search_box.boolean ) %]
101                 <select name="op">
102                     <option value="and" selected="selected">and</option>
103                     <option value="or">or</option>
104                     <option value="not">not</option>
105                 </select>
106             [% END %] 
107                         [% END %]
108                         [% INCLUDE 'search_indexes.inc' %]
109                         <input type="text" size="30" name="q" title="Enter search terms" value="" />
110             [% IF ( expanded_options ) %]
111                 [% IF ( search_box.add_field ) %]
112                     <a href="JavaScript:add_field();" id="ButtonPlus" title="Add another field">[+]</a>
113                                 [% END %]
114               [% IF ( search_box.scan_index ) %]
115                 <label for="scan">Scan indexes:</label> <input type="checkbox" name="scan" id="scan" value="1" />
116               [% END %]
117             [% END %]
118                 </div>
119     [% END %]
120     </fieldset>
121 <!-- /BOOLEAN SEARCH OPTIONS -->
122
123 </div>
124 <!-- MC-TYPE LIMITS -->
125       <div id="advsearches" class="toptabs">
126       <ul>
127       [% FOREACH advsearchloo IN advancedsearchesloop %]
128         <li id="advsearch-tab-[% advsearchloo.advanced_search_type | html %]">
129            <a href="#advsearch-[% advsearchloo.advanced_search_type | uri %]">
130            [% IF ( advsearchloo.advanced_search_type == 'itemtypes' ) %]Item type
131            [% ELSIF ( advsearchloo.advanced_search_type == 'ccode' ) %]Collection
132            [% ELSIF ( advsearchloo.advanced_search_type == 'loc' ) %]Shelving location
133            [% ELSE %]Something else
134            [% END %]
135            </a>
136         </li>
137       [% END %]
138       </ul>
139     [% FOREACH advsearchloo IN advancedsearchesloop %]
140     <div id="advsearch-[% advsearchloo.advanced_search_type | html %]" class="advsearch">
141     <h4>Limit to any of the following:</h4>
142     <table>
143         <tr>
144     [% FOREACH itemtypeloo IN advsearchloo.code_loop %]
145         <td><input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/><label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">[% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %][% IF ( itemtypeloo.imageurl ) %]<img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />[% END %]&nbsp;[% END %]
146         [% itemtypeloo.description | html %]</label></td>
147         [% IF ( loop.last ) %]</tr>[% ELSE %][% UNLESS ( loop.count % 5 ) %]</tr><tr>[% END %][% END %]
148     [% END %]
149     </table>
150     </div>
151     [% END %]
152 <!-- /MC-TYPE LIMIT -->
153 [% IF ( expanded_options ) %]
154 <!-- BASIC LIMITS -->
155  <fieldset id="basiclimits">
156         <legend>Limits</legend>
157 <fieldset id="pubrange">
158 <!-- PUB / COPY YEAR LIMIT --><!-- FIXME: add publication,copyright,acquisition options -->
159         <p><label for="limit-yr">Year: </label>
160                 <input type="text" size="15" name="limit-yr" id="limit-yr" value=""/>&nbsp;&nbsp;(format: yyyy-yyyy)</p>
161 <!-- /PUB / COPY YEAR LIMIT -->
162 </fieldset>
163 <fieldset id="language">
164 <!-- LANGUAGE LIMIT -->
165     <p>
166         <label for="language-limit">Language: </label>
167         [% PROCESS language_limit_select ln_loop=search_languages_loop ln_id='language-limit' ln_index='ln' %]
168         <label for="language-original-limit">Language of original: </label>
169         [% PROCESS language_limit_select ln_loop=search_languages_loop ln_id='language-original-limit' ln_index='language-original' %]
170     </p>
171 <!-- /LANGUAGE LIMIT -->
172 </fieldset>
173 </fieldset>
174 <!-- /BASIC LIMITS -->
175 [% END %]
176
177
178 [% IF ( UNIMARC ) %]
179 [% INCLUDE 'subtypes_unimarc.inc' %]
180 [% ELSE %]
181 <!-- SUBTYPE LIMITS -->
182         <fieldset id="subtype">
183         <legend>Subtype limits</legend><p>
184         
185         <select name="limit" class="subtype">
186             <option value="" selected="selected" class="menuheader">Any audience</option>
187                         <option value="aud:a">Preschool</option>
188                         <option value="aud:b">Primary</option>
189                         <option value="aud:c">Pre-adolescent</option>
190                         <option value="aud:d">Adolescent</option>
191                         <option value="aud:e">Adult</option>
192                         <option value="aud:f">Specialized</option>
193                         <option value="aud:g">General</option>
194                         <option value="aud:j">Juvenile</option>
195         </select>
196         
197         <select name="limit" class="subtype">
198             <option value="" selected="selected" class="menuheader">Any content</option>
199             <option value="fic:1" >Fiction</option>
200             <option value="fic:0" >Non-fiction</option>
201             <option value="bio:b" >Biography</option>
202             <option value="mus:j" >Musical recording</option>
203             <option value="mus:i" >Non-musical recording</option>
204         </select>
205
206         
207         <select name="limit" class="subtype">
208             <option value="" selected="selected" class="menuheader">Any format</option>
209             <option value="l-format:ta" >Regular print</option>
210             <option value="l-format:tb" >Large print</option>
211             <option value="l-format:tc or l-format:fb">Braille</option>
212             <option value="" >-----------</option>
213             <option value="l-format:sd" >CD audio</option>
214             <option value="l-format:ss" >Cassette recording</option>
215             <option value="l-format:vf" >VHS tape / Videocassette</option>
216             <option value="l-format:vd" >DVD video / Videodisc</option>
217             <option value="l-format:co" >CD software</option>
218             <option value="l-format:cr" >Website</option>
219         </select>
220         
221         <select name="limit" class="subtype">
222             <option value="" >Additional content types</option>
223             <option value="ctype:a" >Abstracts / Summaries</option>
224             <option value="ctype:b" >Bibliographies</option>
225             <option value="ctype:c" >Catalogs</option>
226             <option value="ctype:d" >Dictionaries</option>
227             <option value="ctype:e" >Encyclopedias </option>
228             <option value="ctype:f" >Handbooks</option>
229             <option value="ctype:g" >Legal articles</option>
230             <option value="ctype:i" >Indexes</option>
231             <option value="ctype:j" >Patent document</option>
232             <option value="ctype:k" >Discographies</option>
233             <option value="ctype:l" >Legislation</option>
234             <option value="ctype:m" >Theses</option>
235             <option value="ctype:n" >Surveys</option>
236             <option value="ctype:o" >Reviews</option>
237             <option value="ctype:p" >Programmed texts</option>
238             <option value="ctype:q" >Filmographies</option>
239             <option value="ctype:r" >Directories</option>
240             <option value="ctype:s" >Statistics</option>
241             <option value="ctype:t" >Technical reports</option>
242             <option value="ctype:v" >Legal cases and case notes</option>
243             <option value="ctype:w" >Law reports and digests</option>
244             <option value="ctype:z" >Treaties </option>
245         </select>
246        </p>
247
248 </fieldset>
249 [% END %]
250
251 <!-- AVAILABILITY LIMITS -->
252     <fieldset id="availability"><legend>Location and availability</legend>
253 <fieldset id="currently-avail">
254         <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
255 </fieldset>
256
257 <fieldset id="select-libs">
258         <p><label for="branchloop">Individual libraries:</label><select name="limit" id="branchloop">
259         <option value="">All libraries</option>
260         [%# FIXME Should not we filter the libraries displayed? %]
261         [% PROCESS options_for_libraries prefix => "branch:" libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
262         </select></p>
263     <!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
264         [% IF search_groups %]
265             <p>OR</p> <!-- should addjs to grey out group pulldown if a library is selected. -->
266
267             <p>
268                 <label for="categoryloop">Groups of libraries: </label>
269                 <select name="multibranchlimit" id="categoryloop">
270                     <option value=""> -- none -- </option>
271                     [% FOREACH sg IN search_groups %]
272                         [% UNLESS sg.branchcode %]
273                             <option value="[% sg.id | html %]">[% sg.title | html %]</option>
274                         [% END %]
275                     [% END %]
276                 </select>
277             </p>
278     [% END %]
279 </fieldset>
280     </fieldset>
281 <!-- /AVAILABILITY LIMITS -->
282
283 <!-- RANK LIMITS -->
284 <fieldset id="sortby"><legend>Sorting</legend>
285     <p>
286     <label for="sort_by">Sort by: </label><select id="sort_by" name="sort_by">
287   [% INCLUDE 'resort_form.inc' %]
288     </select>
289         </p>
290 </fieldset>
291 </div>
292 <!-- /RANK LIMITS -->
293 </form>
294 </div>
295 </div>
296
297 [% MACRO jsinclude BLOCK %]
298     [% Asset.js("lib/hc-sticky.js") | $raw %]
299     <script>
300         /**
301          *  Function add_field();
302          *  This function allows to display a new field to search.
303          */
304         function add_field() {
305             var ButtonPlus = document.getElementById("ButtonPlus");
306             var line = ButtonPlus.parentNode;
307             var dad  = line.parentNode;
308             dad.appendChild(line.cloneNode(true));
309             line.removeChild(ButtonPlus);
310         }
311         var Sticky;
312         $(document).ready(function() {
313             $("input[name=q]:eq(0)").focus();
314             $('#advsearches').tabs();
315             Sticky = $("#toolbar");
316             Sticky.hcSticky({
317                 stickTo: ".main",
318                 stickyClass: "floating"
319             });
320             $("#branchloop").on("change",function(){
321                 if( this.value != ""){
322                     document.getElementById("categoryloop").disabled=true;
323                 } else {
324                     document.getElementById("categoryloop").disabled=false;
325                 }
326             });
327         });
328     </script>
329 [% END %]
330
331 [% INCLUDE 'intranet-bottom.inc' %]