source: trunk/gsdl/src/recpt/browseaction.cpp@ 2464

Last change on this file since 2464 was 2464, checked in by dmm9, 23 years ago

got filter terms working (sort of)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/**********************************************************************
2 *
3 * browseaction.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#include "browseaction.h"
27#include "querytools.h"
28#include "browseactiontools.h"
29
30browseaction::browseaction(){
31
32
33
34 cgiarginfo arg_ainfo;
35 arg_ainfo.shortname = "a";
36 arg_ainfo.longname = "action";
37 arg_ainfo.multiplechar = true;
38 arg_ainfo.defaultstatus = cgiarginfo::weak;
39 arg_ainfo.argdefault = "br";
40 arg_ainfo.savedarginfo = cgiarginfo::must;
41 argsinfo.addarginfo (NULL, arg_ainfo);
42
43 //the first browsing criterion -- collection metadata types
44 arg_ainfo.shortname = "b1";
45 arg_ainfo.longname = "browse criterion 1";
46 arg_ainfo.multiplechar = false;
47 arg_ainfo.defaultstatus = cgiarginfo::weak;
48 arg_ainfo.argdefault = "0";
49 arg_ainfo.savedarginfo = cgiarginfo::must;
50 argsinfo.addarginfo (NULL, arg_ainfo);
51
52 //the second browsing criterion -- collection metadata types + none - meaning
53 //only one browsing criterion. None is the default.
54 arg_ainfo.shortname = "b2";
55 arg_ainfo.longname = "browse criterion 2";
56 arg_ainfo.multiplechar = false;
57 arg_ainfo.defaultstatus = cgiarginfo::weak;
58 arg_ainfo.argdefault = "0";
59 arg_ainfo.savedarginfo = cgiarginfo::must;
60 argsinfo.addarginfo (NULL, arg_ainfo);
61
62 //the number of documents to show per page -- if the box is empty then
63 //only the most basic divisions are made (so, first letter for A-Z, year
64 //for date).
65 arg_ainfo.shortname = "bnu";
66 arg_ainfo.longname = "browse docs per page";
67 arg_ainfo.multiplechar = true;
68 arg_ainfo.defaultstatus = cgiarginfo::good;
69 arg_ainfo.argdefault = "";
70 arg_ainfo.savedarginfo = cgiarginfo::must;
71 argsinfo.addarginfo (NULL, arg_ainfo);
72
73 //The text to filter documents for browsing (only documents containing these
74 //words will be browsed).
75 arg_ainfo.shortname = "bft";
76 arg_ainfo.longname = "browse filter text";
77 arg_ainfo.multiplechar = true;
78 arg_ainfo.defaultstatus = cgiarginfo::none;
79 arg_ainfo.argdefault = "";
80 arg_ainfo.savedarginfo = cgiarginfo::must;
81 argsinfo.addarginfo (NULL, arg_ainfo);
82
83
84 //Whether all or just some of the words in the filter box have to be present
85 //0 - any 1- all
86 arg_ainfo.shortname = "bt";
87 arg_ainfo.longname = "browse all or any";
88 arg_ainfo.multiplechar = false;
89 arg_ainfo.defaultstatus = cgiarginfo::weak;
90 arg_ainfo.argdefault = "0";
91 arg_ainfo.savedarginfo = cgiarginfo::must;
92 argsinfo.addarginfo (NULL, arg_ainfo);
93
94
95}
96
97browseaction::~browseaction(){}
98
99bool browseaction::init (ostream &logout){
100 return true;
101}
102
103void browseaction::configure (const text_t &key, const text_tarray &cfgline){
104 action::configure(key, cfgline);
105}
106
107
108
109bool browseaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
110 ostream &/*logout*/) {
111 // don't want to check anything yet.
112
113 return true;
114}
115
116
117void browseaction::get_cgihead_info (cgiargsclass &args,
118 recptprotolistclass *protos,
119 response_t &response,
120 text_t &response_data,
121 ostream &logout){
122 response = content;
123 response_data = "text/html";
124
125
126}
127
128void browseaction::define_internal_macros (displayclass &disp,
129 cgiargsclass &args,
130 recptprotolistclass *protos,
131 ostream &logout){
132
133}
134
135void browseaction::define_external_macros (displayclass &disp,
136 cgiargsclass &args,
137 recptprotolistclass *protos,
138 ostream &logout){
139
140}
141
142bool browseaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
143 browsermapclass *browsers, displayclass &disp,
144 outconvertclass &outconvert, ostream &textout,
145 ostream &logout){
146
147 if(args["c"].empty()) return false;
148 else if(get_document_list(args, protos, browsers, disp, outconvert, textout,
149 logout)) return true;
150 else return false;
151}
152
153bool browseaction::get_document_list(cgiargsclass &args,
154 recptprotolistclass *protos, browsermapclass *browsers,
155 displayclass &disp, outconvertclass &outconvert,
156 ostream &textout, ostream &logout){
157
158 text_t collection = args["c"];
159 comerror_t err;
160 text_t list_type = "VList"; //result display type
161
162 //check that the protocol is alive
163 recptproto* colproto = protos->getrecptproto (collection, logout);
164 if(colproto == NULL) {
165 logout << outconvert << "ERROR: Null collection protocol trying to browse "
166 << collection << "\n";
167 return false;
168 }
169
170 //check the collection is responding/in place
171 ColInfoResponse_t *colinfo = recpt->get_collectinfo_ptr(colproto, collection,
172 logout);
173 if(colinfo == NULL){
174 logout << outconvert << "ERROR: Null returned for get_collectinfo_ptr on "
175 << collection << "in browseaction\n";
176 return false;
177 }
178
179 browserclass* br_ptr = browsers->getbrowser(list_type);
180
181 FilterRequest_t request;
182 FilterResponse_t response;
183
184 //set up browser structure
185 br_ptr->set_filter_options(request, args);
186 br_ptr->load_metadata_defaults(request.fields);
187
188 //set up format information
189 format_t* formatptr = new format_t();
190 parse_formatstring(br_ptr->get_default_formatstring(), formatptr,
191 request.fields, request.getParents);
192
193 request.filterResultOptions = FROID | FRmetadata;
194
195 //set up browse filter string;
196 if(!args["bft"].empty()){
197 text_t bf_string = "";
198 format_browsestring(args["bft"],bf_string,args.getintarg("bt"));
199
200 set_browsefilter_options(request, bf_string, args);
201
202 colproto->filter (collection, request, response, err, logout);
203 if (err != noError) {
204 outconvertclass text_t2ascii;
205 logout << text_t2ascii
206 << "browseaction::get_document_list QueryFilter failed "
207 << "for " << collection << " collection ("
208 << get_comerror_string (err) << ")\n";
209 return false;
210 }// if (err != noError)
211
212 }// if(!args["bft"].empty())
213
214 textout << outconvert << disp << "_browse:header_\n" <<"_browse:content_";
215
216
217 bool use_table = is_table_content (formatptr);
218 br_ptr->output_section_group (response, args, collection, 0, formatptr,
219 use_table, request.fields, request.getParents,
220 colproto, disp, outconvert, textout, logout);
221
222 textout << outconvert << disp << "_browse:footer_";
223
224
225
226 return true;
227}
228
229
230
231
232
Note: See TracBrowser for help on using the repository browser.