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