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

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

adding changes to search stuff

  • 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#include "OIDtools.h"
30
31browseaction::browseaction(){
32
33
34
35 cgiarginfo arg_ainfo;
36 arg_ainfo.shortname = "a";
37 arg_ainfo.longname = "action";
38 arg_ainfo.multiplechar = true;
39 arg_ainfo.defaultstatus = cgiarginfo::weak;
40 arg_ainfo.argdefault = "br";
41 arg_ainfo.savedarginfo = cgiarginfo::must;
42 argsinfo.addarginfo (NULL, arg_ainfo);
43
44 //the first browsing criterion -- collection metadata types
45 arg_ainfo.shortname = "b1";
46 arg_ainfo.longname = "browse criterion 1";
47 arg_ainfo.multiplechar = false;
48 arg_ainfo.defaultstatus = cgiarginfo::weak;
49 arg_ainfo.argdefault = "0";
50 arg_ainfo.savedarginfo = cgiarginfo::must;
51 argsinfo.addarginfo (NULL, arg_ainfo);
52
53 //the second browsing criterion -- collection metadata types + none - meaning
54 //only one browsing criterion. None is the default.
55 arg_ainfo.shortname = "b2";
56 arg_ainfo.longname = "browse criterion 2";
57 arg_ainfo.multiplechar = false;
58 arg_ainfo.defaultstatus = cgiarginfo::weak;
59 arg_ainfo.argdefault = "0";
60 arg_ainfo.savedarginfo = cgiarginfo::must;
61 argsinfo.addarginfo (NULL, arg_ainfo);
62
63 //the number of documents to show per page -- if the box is empty then
64 //only the most basic divisions are made (so, first letter for A-Z, year
65 //for date).
66 arg_ainfo.shortname = "bnu";
67 arg_ainfo.longname = "browse docs per page";
68 arg_ainfo.multiplechar = true;
69 arg_ainfo.defaultstatus = cgiarginfo::good;
70 arg_ainfo.argdefault = "";
71 arg_ainfo.savedarginfo = cgiarginfo::must;
72 argsinfo.addarginfo (NULL, arg_ainfo);
73
74 //The text to filter documents for browsing (only documents containing these
75 //words will be browsed).
76 arg_ainfo.shortname = "bft";
77 arg_ainfo.longname = "browse filter text";
78 arg_ainfo.multiplechar = true;
79 arg_ainfo.defaultstatus = cgiarginfo::none;
80 arg_ainfo.argdefault = "";
81 arg_ainfo.savedarginfo = cgiarginfo::must;
82 argsinfo.addarginfo (NULL, arg_ainfo);
83
84
85 //Whether all or just some of the words in the filter box have to be present
86 //0 - any 1- all
87 arg_ainfo.shortname = "bt";
88 arg_ainfo.longname = "browse all or any";
89 arg_ainfo.multiplechar = false;
90 arg_ainfo.defaultstatus = cgiarginfo::weak;
91 arg_ainfo.argdefault = "0";
92 arg_ainfo.savedarginfo = cgiarginfo::must;
93 argsinfo.addarginfo (NULL, arg_ainfo);
94
95
96}
97
98browseaction::~browseaction(){}
99
100bool browseaction::init (ostream &logout){
101 return true;
102}
103
104void browseaction::configure (const text_t &key, const text_tarray &cfgline){
105 action::configure(key, cfgline);
106}
107
108
109
110bool browseaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
111 ostream &/*logout*/) {
112 // don't want to check anything yet.
113
114 return true;
115}
116
117
118void browseaction::get_cgihead_info (cgiargsclass &args,
119 recptprotolistclass *protos,
120 response_t &response,
121 text_t &response_data,
122 ostream &logout){
123 response = content;
124 response_data = "text/html";
125
126
127}
128
129void browseaction::define_internal_macros (displayclass &disp,
130 cgiargsclass &args,
131 recptprotolistclass *protos,
132 ostream &logout){
133
134}
135
136void browseaction::define_external_macros (displayclass &disp,
137 cgiargsclass &args,
138 recptprotolistclass *protos,
139 ostream &logout){
140
141}
142
143bool browseaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
144 browsermapclass *browsers, displayclass &disp,
145 outconvertclass &outconvert, ostream &textout,
146 ostream &logout){
147
148 if(args["c"].empty()) return false;
149 else if(get_document_list(args, protos, browsers, disp, outconvert, textout,
150 logout)) return true;
151 else return false;
152}
153
154bool browseaction::get_document_list(cgiargsclass &args,
155 recptprotolistclass *protos, browsermapclass *browsers,
156 displayclass &disp, outconvertclass &outconvert,
157 ostream &textout, ostream &logout){
158
159 text_t collection = args["c"];
160 comerror_t err;
161 text_t list_type = "VList"; //result display type
162
163 //check that the protocol is alive
164 recptproto* colproto = protos->getrecptproto (collection, logout);
165 if(colproto == NULL) {
166 logout << outconvert << "ERROR: Null collection protocol trying to browse "
167 << collection << "\n";
168 return false;
169 }
170
171 //check the collection is responding/in place
172 ColInfoResponse_t *colinfo = recpt->get_collectinfo_ptr(colproto, collection,
173 logout);
174 if(colinfo == NULL){
175 logout << outconvert << "ERROR: Null returned for get_collectinfo_ptr on "
176 << collection << "in browseaction\n";
177 return false;
178 }
179
180 browserclass* br_ptr = browsers->getbrowser(list_type);
181
182 FilterRequest_t request;
183 FilterResponse_t response;
184
185 //set up browser structure
186 br_ptr->set_filter_options(request, args);
187 br_ptr->load_metadata_defaults(request.fields);
188
189 //set up format information
190 format_t* formatptr = new format_t();
191 parse_formatstring(br_ptr->get_default_formatstring(), formatptr,
192 request.fields, request.getParents);
193
194 request.filterResultOptions = FROID | FRmetadata;
195
196 text_t bf_string = "";
197 format_browsestring(args["bft"],bf_string,args.getintarg("bt"));
198
199 set_browsefilter_options(request, bf_string, args);
200
201 //set up browse filter string;
202 if(!args["bft"].empty()){
203
204 colproto->filter (collection, request, response, err, logout);
205 if (err != noError) {
206 outconvertclass text_t2ascii;
207 logout << text_t2ascii
208 << "browseaction::get_document_list QueryFilter failed "
209 << "for " << collection << " collection ("
210 << get_comerror_string (err) << ")\n";
211 return false;
212 }// if (err != noError)
213
214 }// if(!args["bft"].empty())
215
216 textout << outconvert << disp << "_browse:header_\n" <<"_browse:content_";
217
218
219 bool use_table = is_table_content (formatptr);
220 br_ptr->output_section_group (response, args, collection, 0, formatptr,
221 use_table, request.fields, request.getParents,
222 colproto, disp, outconvert, textout, logout);
223
224 textout << outconvert << disp << "_browse:footer_";
225
226
227
228 return true;
229}
230
231
232
233
234
Note: See TracBrowser for help on using the repository browser.