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

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

working up query stuff to use browseactiontools

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 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 cerr<<"initialising browseaction"<<endl;
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 cerr<<"constructor"<<endl;
95}
96
97browseaction::~browseaction(){}
98
99bool browseaction::init (ostream &logout){
100 cerr<<"init"<<endl;
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 //cerr<<"check_cgiargs"<<endl;
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 //cerr<<"get_cgihead_info"<<endl;
127}
128
129void browseaction::define_internal_macros (displayclass &disp,
130 cgiargsclass &args,
131 recptprotolistclass *protos,
132 ostream &logout){
133 //cerr<<"define_internal_macros"<<endl;
134}
135
136void browseaction::define_external_macros (displayclass &disp,
137 cgiargsclass &args,
138 recptprotolistclass *protos,
139 ostream &logout){
140 //cerr<<"define_external_macros"<<endl;
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
149 textout << outconvert << disp << "_browse:header_\n" <<"_browse:content_"
150 << "_browse:footer_";
151 if(args["c"].empty()) return false;
152 else if(get_document_list(args, protos, browsers, disp, outconvert, textout,
153 logout)) return true;
154 else return false;
155}
156
157bool browseaction::get_document_list(cgiargsclass &args,
158 recptprotolistclass *protos, browsermapclass *browsers,
159 displayclass &disp, outconvertclass &outconvert,
160 ostream &textout, ostream &logout){
161
162 text_t collection = args["c"];
163 comerror_t err;
164 text_t list_type = "VList"; //result display type
165
166 //check that the protocol is alive
167 recptproto* colproto = protos->getrecptproto (collection, logout);
168 if(colproto == NULL) {
169 logout << outconvert << "ERROR: Null collection protocol trying to browse "
170 << collection << "\n";
171 return false;
172 }
173
174 //check the collection is responding/in place
175 ColInfoResponse_t *colinfo = recpt->get_collectinfo_ptr(colproto, collection,
176 logout);
177 if(colinfo == NULL){
178 logout << outconvert << "ERROR: Null returned for get_collectinfo_ptr on "
179 << collection << "in browseaction\n";
180 return false;
181 }
182
183 browserclass* br_ptr = browsers->getbrowser(list_type);
184
185 FilterRequest_t request;
186 FilterResponse_t response;
187
188 //set up browser structure
189 br_ptr->set_filter_options(request, args);
190 br_ptr->load_metadata_defaults(request.fields);
191
192 //set up format information
193 format_t* formatptr = new format_t();
194 parse_formatstring(br_ptr->get_default_formatstring(), formatptr,
195 request.fields, request.getParents);
196
197 request.filterResultOptions = FROID | FRmetadata;
198
199 //set up querystring;
200 text_t newqstring = "";
201 format_qstring(args["bft"],newqstring,args.getintarg("bt"));
202
203 //check that there is a querystring
204 //if(!newqstring.empty()){
205
206
207
208 return true;
209}
210
211
212
213
214
Note: See TracBrowser for help on using the repository browser.