1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * queryaction.h --
|
---|
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 |
|
---|
27 | #ifndef QUERYACTION_H
|
---|
28 | #define QUERYACTION_H
|
---|
29 |
|
---|
30 | #include "gsdlconf.h"
|
---|
31 | #include "action.h"
|
---|
32 | #include "receptionist.h"
|
---|
33 |
|
---|
34 | struct colinfo_t {
|
---|
35 | void clear();
|
---|
36 | colinfo_t () {clear();}
|
---|
37 |
|
---|
38 | format_t *formatlistptr;
|
---|
39 | browserclass *browserptr;
|
---|
40 | };
|
---|
41 |
|
---|
42 | struct QueryResult_t {
|
---|
43 | void clear ();
|
---|
44 | QueryResult_t () {clear();}
|
---|
45 |
|
---|
46 | ResultDocInfo_t doc;
|
---|
47 | text_t collection;
|
---|
48 | };
|
---|
49 |
|
---|
50 | struct gteqQueryResult_t
|
---|
51 | {
|
---|
52 | bool operator()(const QueryResult_t &t1, const QueryResult_t &t2) const
|
---|
53 | { return t1.doc.ranking >= t2.doc.ranking; }
|
---|
54 | };
|
---|
55 |
|
---|
56 | typedef set<QueryResult_t, gteqQueryResult_t> QueryResult_tset;
|
---|
57 |
|
---|
58 |
|
---|
59 | class queryaction : public action {
|
---|
60 |
|
---|
61 | protected:
|
---|
62 |
|
---|
63 | receptionist *recpt;
|
---|
64 |
|
---|
65 | text_t m_strUseInterfaceLanguageForQuery;
|
---|
66 | text_t formatstring;
|
---|
67 | text_tmap reqfields; // required fields
|
---|
68 | int num_phrases;
|
---|
69 |
|
---|
70 | virtual void define_single_query_macros (cgiargsclass &args,
|
---|
71 | displayclass &disp,
|
---|
72 | const FilterResponse_t &response);
|
---|
73 | virtual void define_query_macros (cgiargsclass &args, displayclass &disp,
|
---|
74 | int numDocs, isapprox isApprox);
|
---|
75 |
|
---|
76 | void get_formatted_query_string (text_t &formattedstring, bool segment,
|
---|
77 | cgiargsclass &args,
|
---|
78 | displayclass &disp, ostream &logout);
|
---|
79 | void define_query_interface(displayclass &disp, cgiargsclass &args,
|
---|
80 | recptprotolistclass *protos, ostream &logout);
|
---|
81 |
|
---|
82 | void define_form_macros (displayclass &disp, cgiargsclass &args,
|
---|
83 | recptprotolistclass *protos, ostream &logout);
|
---|
84 |
|
---|
85 | void define_history_macros (displayclass &disp, cgiargsclass &args,
|
---|
86 | recptprotolistclass *protos, ostream &logout);
|
---|
87 |
|
---|
88 | virtual void set_option_macro (const text_t ¯oname, text_t current_value,
|
---|
89 | bool display_single, bool add_js_update,
|
---|
90 | const FilterOption_t &option, displayclass &disp);
|
---|
91 |
|
---|
92 | void set_gformselection_macro (text_t current_value,
|
---|
93 | const FilterOption_t &option,
|
---|
94 | displayclass &disp);
|
---|
95 | void set_sfselection_macro (text_t current_value,
|
---|
96 | const FilterOption_t &option,
|
---|
97 | displayclass &disp);
|
---|
98 |
|
---|
99 | void output_ccp (cgiargsclass &args, recptprotolistclass *protos,
|
---|
100 | displayclass &disp, outconvertclass &outconvert,
|
---|
101 | ostream &textout, ostream &logout);
|
---|
102 |
|
---|
103 | bool search_multiple_collections (cgiargsclass &args,
|
---|
104 | recptprotolistclass *protos,
|
---|
105 | browsermapclass *browsers,
|
---|
106 | displayclass &disp,
|
---|
107 | outconvertclass &outconvert,
|
---|
108 | ostream &textout,
|
---|
109 | ostream &logout);
|
---|
110 |
|
---|
111 | virtual bool search_single_collection (cgiargsclass &args,
|
---|
112 | const text_t &collection,
|
---|
113 | recptprotolistclass *protos,
|
---|
114 | browsermapclass *browsers,
|
---|
115 | displayclass &disp,
|
---|
116 | outconvertclass &outconvert,
|
---|
117 | ostream &textout, ostream &logout);
|
---|
118 |
|
---|
119 |
|
---|
120 | bool save_search_history(cgiargsclass &args, int numdocs, isapprox isApprox);
|
---|
121 |
|
---|
122 | public:
|
---|
123 | queryaction ();
|
---|
124 | virtual ~queryaction () {}
|
---|
125 |
|
---|
126 | void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
|
---|
127 |
|
---|
128 | void configure (const text_t &key, const text_tarray &cfgline);
|
---|
129 | bool init (ostream &logout);
|
---|
130 |
|
---|
131 | virtual text_t get_action_name () {return "q";}
|
---|
132 |
|
---|
133 | virtual bool check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
|
---|
134 | recptprotolistclass *protos, ostream &logout);
|
---|
135 |
|
---|
136 | void get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos,
|
---|
137 | response_t &response, text_t &response_data,
|
---|
138 | ostream &logout);
|
---|
139 |
|
---|
140 | virtual void define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
141 | recptprotolistclass *protos, ostream &logout);
|
---|
142 |
|
---|
143 | virtual void define_external_macros (displayclass &disp, cgiargsclass &args,
|
---|
144 | recptprotolistclass *protos, ostream &logout);
|
---|
145 |
|
---|
146 | virtual bool do_action (cgiargsclass &args, recptprotolistclass *protos,
|
---|
147 | browsermapclass *browsers, displayclass &disp,
|
---|
148 | outconvertclass &outconvert, ostream &textout,
|
---|
149 | ostream &logout);
|
---|
150 |
|
---|
151 | };
|
---|
152 |
|
---|
153 | #endif
|
---|