4e7424185e5e5f1308600cf940e18c54d93874bc
[working/Evergreen.git] / Open-ILS / src / templates / opac / browse.tt2
1 [%- # This is the bib and authority combined record browser.
2
3     PROCESS "opac/parts/header.tt2";
4     PROCESS "opac/parts/misc_util.tt2";
5     PROCESS "opac/parts/org_selector.tt2";
6     WRAPPER "opac/parts/base.tt2";
7     INCLUDE "opac/parts/topnav.tt2";
8
9     ctx.page_title = l("Browse the Catalog");
10     blimit = CGI.param('blimit') || ctx.opac_hits_per_page || 10;
11
12     depart_list = ['blimit', 'bterm', 'bpivot'];
13     ctx.metalinks.push('<meta name="robots" content="noindex,follow">');
14 %]
15
16     <h2 class="sr-only">[% l('Catalog Browse') %]</h2>
17     <div id="search-wrapper">
18         [%# XXX TODO Give searchbar.tt2 more smarts so we can just do:
19           # INCLUDE "opac/parts/searchbar.tt2" %]
20         <div id="search-box">
21             <span class="search_catalog_lbl"><a href="[% mkurl(ctx.opac_root _ '/home', {}, depart_list) %]">[% l('Basic Search') %]</a></span>
22             <span class="adv_search_catalog_lbl"><a href="[% mkurl(ctx.opac_root _ '/advanced', {}, depart_list) %]"
23                     id="home_adv_search_link">[%l('Advanced Search')%]</a></span>
24         
25             <span class="browse_the_catalog_lbl mobile_hide">[% l('Browse the Catalog') %]</span>
26         </div>
27     </div>
28     <div id="content-wrapper">
29         <div id="main-content">
30             <div id="browse-the-catalog">
31                 <div id="browse-controls" class='searchbar'>
32                     <form method="get" onsubmit="$('browse-submit-spinner').className = ''; return true">
33                         <input type="hidden" name="blimit"
34                             value="[% blimit %]" />
35
36                         [% control_qtype = INCLUDE "opac/parts/qtype_selector.tt2"
37                             id="browse-search-class" browse_only=1 plural=1 %]
38
39                         [% control_bterm = BLOCK %]<input type="text" name="bterm" id="browse-term"
40                             value="[% CGI.param('bterm') | html %]" />[% END %]
41                         [% control_locg = INCLUDE build_org_selector id='browse-context'
42                             show_loc_groups=1
43                             arialabel=l('Select holding library') %]
44                         [% l('Browse for [_1] starting with [_2] in [_3]', control_qtype, control_bterm, control_locg) %]
45
46                         <input id='search-submit-go' type="submit" value="[% l('Browse') %]" alt="[% l('Browse') %]" class="opac-button"/>
47                         <img id="browse-submit-spinner" 
48                         src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif[% ctx.cache_key %]"
49                         class="hidden" style="width: 16px; height: 16px;" 
50                         alt="[% l('Search in progress icon') %]" />
51                     </form>
52                 </div>
53
54                 [% BLOCK browse_pager %]
55                 <div class="browse-pager">
56                     [% IF ctx.back_pivot %]
57                     <a class="opac-button" href="[% mkurl('', {bpivot => ctx.back_pivot}) %]" onclick="$('browse-pager-spinner-[% id %]').className = '';">&larr; [%l ('Back') %]</a>
58                     [% END %]
59                     [% IF ctx.pager_shortcuts;
60                         current_qtype = CGI.param('qtype') || 'title' %]
61                     <span class="browse-shortcuts">
62                         [% FOR shortcut IN ctx.pager_shortcuts %]
63                             <a href="[% mkurl('', {qtype => current_qtype, bterm => shortcut.0}, ['bpivot','query']) %]">[% shortcut.1 %]</a>
64                         [% END %]
65                     </span>
66                     [% END %]
67
68                     [% IF ctx.forward_pivot %]
69                     <a class="opac-button" href="[% mkurl('', {bpivot => ctx.forward_pivot}) %]" onclick="$('browse-pager-spinner-[% id %]').className = '';">[%l ('Next') %] &rarr;</a>
70                     [% END %]
71
72                     <img id="browse-pager-spinner-[% id %]" 
73                         src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif[% ctx.cache_key %]"
74                         class="hidden" style="width: 16px; height: 16px;" 
75                         alt="[% l('Search in progress icon') %]" />
76                 </div>
77                 [% END %]
78
79                 [% PROCESS browse_pager id=0 %]
80
81                 <div id="browse-results">
82                 [% IF ctx.browse_error %]
83                     <span class="browse-error">
84                         [% l("An error occurred browsing records. " _
85                         "Please try again in a moment or report the issue " _
86                         "to library staff.") %]
87                     </span>
88                 [% ELSE %]
89                     [% IF ctx.browse_leading_article_warning %]
90                     <div class="browse-leading-article-warning">
91                             [% l("Your browse term seems to begin with an article (a, an, the). You might get better results by omitting the article.") %]
92                             [% IF ctx.browse_leading_article_alternative %]
93                             <p>
94                             [% alternative_link = BLOCK %]
95                             <a href="[% mkurl('', {bterm => ctx.browse_leading_article_alternative}, ['bpivot']) %]">[% ctx.browse_leading_article_alternative | html %]</a>
96                             [%-  END; # alternative_link BLOCK
97                                 l("Did you mean [_1]?", alternative_link);
98                             END # IF %]
99                             </p>
100                     </div>
101                     [% END %]
102                     <ul class="browse-result-list">
103                     [% FOR result IN ctx.browse_results %]
104                         <li class="browse-result">
105                             <span class="browse-result-value[% result.row_number == 0 && !CGI.param('bpivot') ? ' browse-result-best-match' : '' %]">
106                                 [% IF result.sources > 0 %] <!-- bib-linked browse value -->
107                                     <a href="[% mkurl(
108                                         ctx.opac_root _ '/results', {
109                                             'fi:has_browse_entry' => (result.browse_entry _ ',' _ result.fields)
110                                         }) %]">[% result.value | html %]</a>
111                                     <span class="browse-result-sources">([%
112                                         IF result.accurate == 'f';
113                                             l("At least"); " ";
114                                         END;
115                                     result.sources %])</span>
116                                 [% ELSE %] <!-- only authority links -->
117                                     [% result.value | html %]
118                                 [% END %]
119                             </span>
120
121                             [% FOR a IN result.authorities;
122                                     PROCESS authority_notes authority=a IF !sees.grep(a.id);
123                                END %]
124                             [% auth_headings_ul_added = 0; %]
125                                 [% seenit = {}; # for headings we've rendered
126                                    FOR a IN result.sees;
127                                     # We can go no further sans control_set.
128                                     NEXT UNLESS a.control_set;
129
130                                     # get_authority_fields is fast and cache-y.
131                                     acs = ctx.get_authority_fields(a.control_set);
132                                     FOR field_group IN a.headings;
133                                         field_id = field_group.keys.0;
134                                         field = acs.$field_id;
135                                         headings = field_group.values.0;
136                                         FOR h IN headings;
137                                             # We could display headings without
138                                             # links here when h.target is
139                                             # undef, if we wanted to, but note
140                                             # that h.target_count is only
141                                             # defined when h.target is.
142
143                                             IF h.target AND h.target_count AND result.list_authorities.grep('^' _ h.target _ '$').size == 0;
144                                                 id = h.target; NEXT IF seenit.$id; seenit.$id = 1; 
145                                                 IF !auth_headings_ul_added;
146                                                     # only add a <ul> if we have at least one <li> (WCAG 2.0)
147                                                     auth_headings_ul_added = 1; %]
148                                                 <ul class="browse-result-authority-headings"> 
149                                                 [% END %]
150
151                                                 <li><span class="browse-result-authority-field-name">[% field.name %]</span>
152                                                 <a href="[% mkurl(ctx.opac_root _ '/browse', {bterm => h.heading}, ['bpivot']) %]">[% h.heading | html %]</a>
153                                                 <span class="browse-result-authority-bib-links">([% h.target_count %])</span>
154                                                 </li>
155                                             [% END %]
156                                         [% END %]
157                                     [% END %]
158                                 [% END %]
159                                 [% FOR a IN result.authorities;
160                                     # We can go no further sans control_set.
161                                     NEXT UNLESS a.control_set;
162
163                                     # get_authority_fields is fast and cache-y.
164                                     acs = ctx.get_authority_fields(a.control_set);
165                                     FOR field_group IN a.headings;
166                                         field_id = field_group.keys.0;
167                                         field = acs.$field_id;
168                                         headings = field_group.values.0;
169                                         FOR h IN headings;
170                                             # We could display headings without
171                                             # links here when h.target is
172                                             # undef, if we wanted to, but note
173                                             # that h.target_count is only
174                                             # defined when h.target is.
175
176                                             IF h.target AND h.target_count AND result.list_sees.grep('^' _ h.target _ '$').size == 0 AND !h.main_entry;
177                                                 id = h.target; NEXT IF seenit.$id; seenit.$id = 1; 
178                                                 IF !auth_headings_ul_added;
179                                                     # only add a <ul> if we have at least one <li> (WCAG 2.0)
180                                                     auth_headings_ul_added = 1; %]
181                                                 <ul class="browse-result-authority-headings"> 
182                                                 [% END %]
183                                                 <li><span class="browse-result-authority-field-name">[% field.name %]</span>
184                                                 <a href="[% mkurl(ctx.opac_root _ '/results', {query => 'identifier|authority_id[' _ h.target _ ']'}) %]">[% h.heading | html %]</a>
185                                                 <span class="browse-result-authority-bib-links">([% h.target_count %])</span>
186                                                 </li>
187                                             [% END %]
188                                         [% END %]
189                                     [% END %]
190                                 [% END %]
191                             [% IF auth_headings_ul_added %]</ul>[% END %]
192                         </li>
193                     [% END %]
194                     </ul>
195                 [% END %]
196                 </div>
197
198                 [% PROCESS browse_pager id=1 %]
199             </div>
200
201             <div class="common-full-pad"></div> 
202         </div>
203     </div>
204
205     [% BLOCK authority_notes;
206         # Displays public general notes (sometimes called "scope notes" ?)
207         FOR note IN authority.notes %]
208             <div class="browse-public-general-note">
209                 <span class="browse-public-general-note-label">
210                     [% l("Note:") %]
211                 </span>
212                 <span class="browse-public-general-note-body">
213                 [% FOR piece IN note; piece | html; END %]
214                 </span>
215             </div>
216         [% END;
217     END;    # end of BLOCK authority_notes %]
218
219 [% END %]