0626f429bde523c6f5ddf79d00eac69d48cd2cd5
[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">');
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) %]" rel="nofollow" vocab="">[% 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" rel="nofollow" vocab="">[%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" 
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 = '';" rel="nofollow" vocab="">&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']) %]" rel="nofollow" vocab="">[% 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 = '';" rel="nofollow" vocab="">[%l ('Next') %] &rarr;</a>
70                     [% END %]
71
72                     <img id="browse-pager-spinner-[% id %]" 
73                         src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif" 
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']) %]" rel="nofollow" vocab="">[% 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
103                     <ul class="browse-result-list">
104                     [% FOR result IN ctx.browse_results %]
105                         <li class="browse-result">
106                             <span class="browse-result-value[% result.row_number == 0 && !CGI.param('bpivot') ? ' browse-result-best-match' : '' %]">
107                                 [% IF result.sources > 0 %] <!-- bib-linked browse value -->
108                                     <a href="[% mkurl(
109                                         ctx.opac_root _ '/results', {
110                                             'fi:has_browse_entry' => (result.browse_entry _ ',' _ result.fields)
111                                         }) %]" rel="nofollow" vocab="">[% result.value | html %]</a>
112                                     <span class="browse-result-sources">([%
113                                         IF result.accurate == 'f';
114                                             l("At least"); " ";
115                                         END;
116                                     result.sources %])</span>
117                                 [% ELSE %] <!-- only authority links -->
118                                     [% result.value | html %]
119                                 [% END %]
120                             </span>
121
122                             [% auth_headings_ul_added = 0; %]
123                                 [% seenit = {}; # for headings we've rendered
124                                    FOR a IN result.sees;
125                                     PROCESS authority_notes authority=a;
126
127                                     # Other than displaying public general
128                                     # notes, we can go no further sans
129                                     # control_set.
130                                     NEXT UNLESS a.control_set;
131
132                                     # get_authority_fields is fast and cache-y.
133                                     acs = ctx.get_authority_fields(a.control_set);
134                                     FOR field_group IN a.headings;
135                                         field_id = field_group.keys.0;
136                                         field = acs.$field_id;
137                                         headings = field_group.values.0;
138                                         FOR h IN headings;
139                                             # We could display headings without
140                                             # links here when h.target is
141                                             # undef, if we wanted to, but note
142                                             # that h.target_count is only
143                                             # defined when h.target is.
144
145                                             IF h.target AND h.target_count AND result.list_authorities.grep('^' _ h.target _ '$').size == 0;
146                                                 id = h.target; NEXT IF seenit.$id; seenit.$id = 1; 
147                                                 IF !auth_headings_ul_added;
148                                                     # only add a <ul> if we have at least one <li> (WCAG 2.0)
149                                                     auth_headings_ul_added = 1; %]
150                                                 <ul class="browse-result-authority-headings"> 
151                                                 [% END %]
152
153                                                 <li><span class="browse-result-authority-field-name">[% field.name %]</span>
154                                                 <a href="[% mkurl(ctx.opac_root _ '/browse', {bterm => h.heading}, ['bpivot']) %]" rel="nofollow" vocab="">[% h.heading | html %]</a>
155                                                 <span class="browse-result-authority-bib-links">([% h.target_count %])</span>
156                                                 </li>
157                                             [% END %]
158                                         [% END %]
159                                     [% END %]
160                                 [% END %]
161                                 [% FOR a IN result.authorities; # I don't think we'll ever get here...
162                                     PROCESS authority_notes authority=a IF !sees.grep(a.id);
163
164                                     # Other than displaying public general
165                                     # notes, we can go no further sans
166                                     # control_set.
167                                     NEXT UNLESS a.control_set;
168
169                                     # get_authority_fields is fast and cache-y.
170                                     acs = ctx.get_authority_fields(a.control_set);
171                                     FOR field_group IN a.headings;
172                                         field_id = field_group.keys.0;
173                                         field = acs.$field_id;
174                                         headings = field_group.values.0;
175                                         FOR h IN headings;
176                                             # We could display headings without
177                                             # links here when h.target is
178                                             # undef, if we wanted to, but note
179                                             # that h.target_count is only
180                                             # defined when h.target is.
181
182                                             IF h.target AND h.target_count AND result.list_sees.grep('^' _ h.target _ '$').size == 0 AND !h.main_entry;
183                                                 id = h.target; NEXT IF seenit.$id; seenit.$id = 1; 
184                                                 IF !auth_headings_ul_added;
185                                                     # only add a <ul> if we have at least one <li> (WCAG 2.0)
186                                                     auth_headings_ul_added = 1; %]
187                                                 <ul class="browse-result-authority-headings"> 
188                                                 [% END %]
189                                                 <li><span class="browse-result-authority-field-name">[% field.name %]</span>
190                                                 <a href="[% mkurl(ctx.opac_root _ '/results', {query => 'identifier|authority_id[' _ h.target _ ']'}) %]" rel="nofollow" vocab="">[% h.heading | html %]</a>
191                                                 <span class="browse-result-authority-bib-links">([% h.target_count %])</span>
192                                                 </li>
193                                             [% END %]
194                                         [% END %]
195                                     [% END %]
196                                 [% END %]
197                             [% IF auth_headings_ul_added %]</ul>[% END %]
198                         </li>
199                     [% END %]
200                     </ul>
201                 [% END %]
202                 </div>
203
204                 [% PROCESS browse_pager id=1 %]
205             </div>
206
207             <div class="common-full-pad"></div> 
208         </div>
209     </div>
210
211     [% BLOCK authority_notes;
212         # Displays public general notes (sometimes called "scope notes" ?)
213         FOR note IN authority.notes %]
214             <div class="browse-public-general-note">
215                 <span class="browse-public-general-note-label">
216                     [% l("Note:") %]
217                 </span>
218                 <span class="browse-public-general-note-body">
219                 [% FOR piece IN note; piece | html; END %]
220                 </span>
221             </div>
222         [% END;
223     END;    # end of BLOCK authority_notes %]
224
225 [% END %]