Move advanced search limiter config to config.tt2.
This should, in theory, make it much easier to customize the fields shown
for searching in TPac.
Also adds the VR Format Coded Value Maps so that we can populate that
limiter with them.
And removes dojo.css from being loaded - That includes reset stuff that
messes with our CSS but doesn't seem to give us any benefit.
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
CREATE VIEW config.audience_map AS SELECT code, value, description FROM config.coded_value_map WHERE ctype = 'audience';
CREATE VIEW config.videorecording_format_map AS SELECT code, value FROM config.coded_value_map WHERE ctype = 'vr_format';
+CREATE OR REPLACE FUNCTION config.update_coded_value_map(in_ctype TEXT, in_code TEXT, in_value TEXT, in_description TEXT DEFAULT NULL, in_opac_visible BOOL DEFAULT NULL, in_search_label TEXT DEFAULT NULL, in_is_simple BOOL DEFAULT NULL, add_only BOOL DEFAULT FALSE) RETURNS VOID AS $f$
+DECLARE
+ current_row config.coded_value_map%ROWTYPE;
+BEGIN
+ -- Look for a current value
+ SELECT INTO current_row * FROM config.coded_value_map WHERE ctype = in_ctype AND code = in_code;
+ -- If we have one..
+ IF FOUND THEN
+ -- Update anything we were handed
+ current_row.value := COALESCE(current_row.value, in_value);
+ current_row.description := COALESCE(current_row.description, in_description);
+ current_row.opac_visible := COALESCE(current_row.opac_visible, in_opac_visible);
+ current_row.search_label := COALESCE(current_row.search_label, in_search_label);
+ current_row.is_simple := COALESCE(current_row.is_simple, in_is_simple);
+ UPDATE config.coded_value_map
+ SET
+ value = current_row.value,
+ description = current_row.description,
+ opac_visible = current_row.opac_visible,
+ search_label = current_row.search_label,
+ is_simple = current_row.is_simple
+ WHERE id = current_row.id;
+ ELSIF NOT add_only THEN
+ INSERT INTO config.coded_value_map(ctype, code, value, description, opac_visible, search_label, is_simple) VALUES
+ (in_ctype, in_code, in_value, in_description, COALESCE(in_opac_visible, TRUE), in_search_label, COALESCE(in_is_simple, FALSE));
+ END IF;
+END;
+$f$ LANGUAGE PLPGSQL;
+
CREATE OR REPLACE FUNCTION oils_tsearch2 () RETURNS TRIGGER AS $$
DECLARE
normalizer RECORD;
(535, 'bib_level', 'm', oils_i18n_gettext('535', 'Monograph/Item', 'ccvm', 'value')),
(536, 'bib_level', 's', oils_i18n_gettext('536', 'Serial', 'ccvm', 'value'));
+INSERT INTO config.coded_value_map(id, ctype, code, value) VALUES
+ (537, 'vr_format', 'a', oils_i18n_gettext('537', 'Beta', 'ccvm', 'value')),
+ (538, 'vr_format', 'b', oils_i18n_gettext('538', 'VHS', 'ccvm', 'value')),
+ (539, 'vr_format', 'c', oils_i18n_gettext('539', 'U-matic', 'ccvm', 'value')),
+ (540, 'vr_format', 'd', oils_i18n_gettext('540', 'EIAJ', 'ccvm', 'value')),
+ (541, 'vr_format', 'e', oils_i18n_gettext('541', 'Type C', 'ccvm', 'value')),
+ (542, 'vr_format', 'f', oils_i18n_gettext('542', 'Quadruplex', 'ccvm', 'value')),
+ (543, 'vr_format', 'g', oils_i18n_gettext('543', 'Laserdisc', 'ccvm', 'value')),
+ (544, 'vr_format', 'h', oils_i18n_gettext('544', 'CED videodisc', 'ccvm', 'value')),
+ (545, 'vr_format', 'i', oils_i18n_gettext('545', 'Betacam', 'ccvm', 'value')),
+ (546, 'vr_format', 'j', oils_i18n_gettext('546', 'Betacam SP', 'ccvm', 'value')),
+ (547, 'vr_format', 'k', oils_i18n_gettext('547', 'Super-VHS', 'ccvm', 'value')),
+ (548, 'vr_format', 'm', oils_i18n_gettext('548', 'M-II', 'ccvm', 'value')),
+ (549, 'vr_format', 'o', oils_i18n_gettext('549', 'D-2', 'ccvm', 'value')),
+ (550, 'vr_format', 'p', oils_i18n_gettext('550', '8 mm.', 'ccvm', 'value')),
+ (551, 'vr_format', 'q', oils_i18n_gettext('551', 'Hi-8 mm.', 'ccvm', 'value')),
+ (552, 'vr_format', 's', oils_i18n_gettext('552', 'Blu-ray disc', 'ccvm', 'value')),
+ (553, 'vr_format', 'u', oils_i18n_gettext('553', 'Unknown', 'ccvm', 'value')),
+ (554, 'vr_format', 'v', oils_i18n_gettext('554', 'DVD', 'ccvm', 'value')),
+ (555, 'vr_format', 'z', oils_i18n_gettext('555', 'Other', 'ccvm', 'value')),
+ (556, 'vr_format', ' ', oils_i18n_gettext('556', 'Unspecified', 'ccvm', 'value'));
+
SELECT SETVAL('config.coded_value_map_id_seq'::TEXT, (SELECT max(id) FROM config.coded_value_map));
-- Trigger Event Definitions -------------------------------------------------
--- /dev/null
+CREATE OR REPLACE FUNCTION config.update_coded_value_map(in_ctype TEXT, in_code TEXT, in_value TEXT, in_description TEXT DEFAULT NULL, in_opac_visible BOOL DEFAULT NULL, in_search_label TEXT DEFAULT NULL, in_is_simple BOOL DEFAULT NULL, add_only BOOL DEFAULT FALSE) RETURNS VOID AS $f$
+DECLARE
+ current_row config.coded_value_map%ROWTYPE;
+BEGIN
+ -- Look for a current value
+ SELECT INTO current_row * FROM config.coded_value_map WHERE ctype = in_ctype AND code = in_code;
+ -- If we have one..
+ IF FOUND AND NOT add_only THEN
+ -- Update anything we were handed
+ current_row.value := COALESCE(current_row.value, in_value);
+ current_row.description := COALESCE(current_row.description, in_description);
+ current_row.opac_visible := COALESCE(current_row.opac_visible, in_opac_visible);
+ current_row.search_label := COALESCE(current_row.search_label, in_search_label);
+ current_row.is_simple := COALESCE(current_row.is_simple, in_is_simple);
+ UPDATE config.coded_value_map
+ SET
+ value = current_row.value,
+ description = current_row.description,
+ opac_visible = current_row.opac_visible,
+ search_label = current_row.search_label,
+ is_simple = current_row.is_simple
+ WHERE id = current_row.id;
+ ELSE
+ INSERT INTO config.coded_value_map(ctype, code, value, description, opac_visible, search_label, is_simple) VALUES
+ (in_ctype, in_code, in_value, in_description, COALESCE(in_opac_visible, TRUE), in_search_label, COALESCE(in_is_simple, FALSE));
+ END IF;
+END;
+$f$ LANGUAGE PLPGSQL;
+
+SELECT config.update_coded_value_map('vr_format', 'a', 'Beta', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'b', 'VHS', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'c', 'U-matic', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'd', 'EIAJ', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'e', 'Type C', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'f', 'Quadruplex', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'g', 'Laserdisc', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'h', 'CED videodisc', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'i', 'Betacam', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'j', 'Betacam SP', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'k', 'Super-VHS', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'm', 'M-II', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'o', 'D-2', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'p', '8 mm.', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'q', 'Hi-8 mm.', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 's', 'Blu-ray disc', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'u', 'Unknown', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'v', 'DVD', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', 'z', 'Other', add_only := TRUE);
+SELECT config.update_coded_value_map('vr_format', ' ', 'Unspecified', add_only := TRUE);
# scalar.merge treats the scalar as a 1-item array
WHILE queries.size < rowcount; queries = queries.merge(['']); END;
WHILE bools.size < rowcount; bools = bools.merge(['and']); END;
- WHILE qtypes.size < rowcount; qtypes = qtypes.merge(['keyword']); END;
+ WHILE qtypes.size < rowcount; qtypes = qtypes.merge(search.default_qtypes.${qtypes.size} ? [search.default_qtypes.${qtypes.size}] : ['keyword']); END;
FOR qtype IN qtypes;
c = contains.shift;
<tr>
<td align='top'>
<div style="width:100%;" class="header_middle">[% l('Search Filters') %]</div>
- <table cellpadding='10' cellspacing='0' border='0'><tr>
+ <table cellpadding='10' cellspacing='0' border='0'>
+[%
+ in_row = 0;
+ FOR adv_chunk IN search.adv_config;
+ NEXT IF adv_chunk.adv_hide;
+ IF in_row == 0;
+ in_row = 1; %]
+ <tr>
+[%
+ END; %]
<td valign='top'>
- <strong>[% l("Item Type") %]</strong><br />
- [% INCLUDE "opac/parts/coded_value_selector.tt2"
- attr=["mattype", "item_type"] multiple="multiple" size="4" %]
- </td>
- <td valign='top'>
- <strong>[% l("Language") %]</strong><br />
- [% INCLUDE "opac/parts/coded_value_selector.tt2"
- attr="item_lang" multiple="multiple" size="4" %]
- </td>
- <td valign='top'>
- <strong>[% l("Audience") %]</strong><br />
- [% INCLUDE "opac/parts/coded_value_selector.tt2"
- attr=["audience_group", "audience"] multiple="multiple" size="4" %]
- </select>
- </td>
- <td valign='top'>
- <strong>[% l("Sort Results") %]</strong>
- <table class='adv_global_filter_sort'>
- <tr>
- <td align='center' width='100%'>
- [% INCLUDE "opac/parts/filtersort.tt2"
- value=CGI.param('sort') class='results_header_sel' %]
- </td>
- </tr>
- </table>
- </td>
- </tr></table>
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <table cellpadding='10' cellspacing='0' border='0'>
- <tbody>
- <tr>
- <td valign='top'>
- <strong>[% l("Search Library") %]</strong><br />
- [% PROCESS "opac/parts/org_selector.tt2";
- INCLUDE build_org_selector show_loc_groups=1 %]
+ <strong>[% adv_chunk.adv_label %]</strong><br />
+[%
+ IF adv_chunk.adv_special;
+ SWITCH adv_chunk.adv_special;
+ CASE "lib_selector";
+ PROCESS "opac/parts/org_selector.tt2";
+ INCLUDE build_org_selector show_loc_groups=1; %]
<div style="position:relative;top:7px;">
<input type='checkbox' name="modifier"
value="available"[% CGI.param('modifier').grep('available').size ? ' checked="checked"' : '' %]
for='opac.result.limit2avail'>
[% l("Limit to Available") %]</label>
</div>
- </td>
- <td valign='top'>
- <strong>[% l("Publication Year") %]</strong><br />
+[%
+ CASE "pub_year"; %]
<select name='pubdate' onchange='
if(this.selectedIndex == 3)
unHideMe($("adv_global_pub_date_2_span"));
[% l("and") %] <input name='date2' type='text' size='4' maxlength='4' value="[% CGI.param('date2') | html %]" />
</span>
</div>
- </td>
- </tr>
- <!-- TODO: Copy Location Filter -->
- <tr class='hide_me'>
- <td align='right'>[% l("Shelving Location") %]</td>
- <td align='left'>
- <select size='3' multiple='multiple'>
- [%# TODO: add filter options... %]
- </select>
- </td>
- </tr>
- </tbody>
+[%
+ CASE "sort_selector";
+ INCLUDE "opac/parts/filtersort.tt2"
+ value=CGI.param('sort') class='results_header_sel';
+ END;
+ ELSIF adv_chunk.adv_attr;
+ INCLUDE "opac/parts/coded_value_selector.tt2"
+ attr=adv_chunk.adv_attr multiple="multiple" size="4";
+ END; %]
+ </td>
+[%
+ IF adv_chunk.adv_break;
+ in_row = 0; %]
+ </tr>
+[%
+ END;
+ END; %]
</table>
</td>
</tr>
<link rel="unapi-server" type="application/xml" title="unAPI" href="/opac/extras/unapi" />
[% IF want_dojo %]
<style type="text/css">
- @import "[% ctx.media_prefix %]/js/dojo/dojo/resources/dojo.css";
@import "[% ctx.media_prefix %]/js/dojo/dijit/themes/tundra/tundra.css";
</style>
[% END %]
{facet_class => 'subject', facet_order => ['name', 'geographic']}
];
+##############################################################################
+# Define the advanced search limiters and labels.
+# adv_label is the (translated) label for the limiter
+# adv_attr is an array of possible limiters, the first one that has any
+# values will be used
+# adv_break will end the current row. If specified with a label/attr it
+# will do so *after* that limiter.
+# adv_special will drop in a special entry:
+# lib_selector will put the search library box (with limit to available)
+# pub_year will put the publication year box
+# sort_selector will put the sort results selector
+
+search.adv_config = [
+ {adv_label => l("Item Type"), adv_attr => ["mattype", "item_type"]},
+ {adv_label => l("Item Form"), adv_attr => "item_form"},
+ {adv_label => l("Language"), adv_attr => "item_lang"},
+ {adv_label => l("Audience"), adv_attr => ["audience_group", "audience"], adv_break => 1},
+ {adv_label => l("Video Format"), adv_attr => "vr_format"},
+ {adv_label => l("Bib Level"), adv_attr => "bib_level"},
+ {adv_label => l("Literary Form"), adv_attr => "lit_form", adv_break => 1},
+ {adv_label => l("Search Library"), adv_special => "lib_selector"},
+ {adv_label => l("Publication Year"), adv_special => "pub_year"},
+ {adv_label => l("Sort Results"), adv_special => "sort_selector"},
+];
+
+##############################################################################
+# For each search box the default "query type" value can be specified here
+# This is the actual backend value, not the label
+# Also note that including more than the row count entries won't add rows
+# The first entry should be used as a default for "basic" search as well
+
+search.default_qtypes = ['keyword','title','author'];
+
%]
{value => "id|bibcn", label => l("Bib Call Number")}
] %]
<select name="qtype"[% IF id; ' id="'; id ; '"' ; END %]>
- [% query_type = query_type || CGI.param('qtype');
+ [% query_type = query_type || CGI.param('qtype') || search.default_qtypes.0;
FOR qt IN query_types -%]
<option value='[% qt.value | html %]'[%
query_type == qt.value ? ' selected="selected"' : ''