source: trunk/gsdl/src/recpt/pageaction.cpp@ 172

Last change on this file since 172 was 172, checked in by rjmcnab, 25 years ago

Merged sources.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
Line 
1/**********************************************************************
2 *
3 * pageaction.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: pageaction.cpp 172 1999-02-25 21:59:02Z rjmcnab $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.3 1999/02/25 21:58:58 rjmcnab
15
16 Merged sources.
17
18 Revision 1.2 1999/02/21 22:33:54 rjmcnab
19
20 Lots of stuff :-)
21
22 Revision 1.1 1999/02/12 02:40:17 sjboddie
23
24 Added page action
25
26 */
27
28
29#include "pageaction.h"
30#include "receptionist.h"
31
32
33pageaction::pageaction () {
34 // this action uses cgi variables "a" and "p"
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 = "p";
41 arg_ainfo.savedarginfo = cgiarginfo::must;
42 argsinfo.addarginfo (NULL, arg_ainfo);
43
44 arg_ainfo.shortname = "p";
45 arg_ainfo.longname = "page";
46 arg_ainfo.multiplechar = true;
47 arg_ainfo.defaultstatus = cgiarginfo::weak;
48 arg_ainfo.argdefault = "about";
49 arg_ainfo.savedarginfo = cgiarginfo::can;
50 argsinfo.addarginfo (NULL, arg_ainfo);
51}
52
53pageaction::~pageaction () {
54}
55
56bool pageaction::check_cgiargs (cgiargsclass &/*args*/, ostream &/*logout*/) {
57 // don't want to check anything yet.
58 return true;
59}
60
61void pageaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
62 text_t &response_data, ostream &/*logout*/) {
63 response = content;
64 response_data = "text/html";
65}
66
67bool pageaction::do_action (cgiargsclass &args, recptproto */*collectproto*/,
68 displayclass &disp, outconvertclass &outconvert,
69 ostream &textout, ostream &logout) {
70 text_t pageparams;
71 text_t &arg_p = args["p"];
72
73 bool first = true;
74 if (!args["c"].empty()) {
75 pageparams += "collection=" + args["c"]; first = false;}
76 if (args.getintarg("u") == 1)
77 if (first) {pageparams += "style=htmlonly"; first = false;}
78 else pageparams += ",style=htmlonly";
79 if (args.getintarg("v") == 1)
80 if (first) {pageparams += "version=text"; first = false;}
81 else pageparams += ",version=text";
82 if (args.getintarg("f") == 1)
83 if (first) {pageparams += ",queryversion=big"; first = false;}
84 else pageparams += ",queryversion=big";
85 if (args["l"] != "en")
86 if (first) pageparams += ",language=" + args["l"];
87 else pageparams += ",language=" + args["l"];
88
89 disp.openpage(pageparams, MACROPRECEDENCE);
90 define_internal_macros (disp, args, logout);
91
92 textout << outconvert << disp << ("_" + arg_p + ":header_\n")
93 << ("_" + arg_p + ":imagestandardbar_\n") << ("_" + arg_p + ":content_\n")
94 << ("_" + arg_p + ":footer_\n");
95
96 return true;
97}
98
99
100// define all the macros which are related to pages generated
101// by this action
102void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
103 ostream &logout) {
104
105 // not sure which macros should be defined where - what is difference between
106 // define_internal_macros and define_external_macros
107 // urlsafequerystring and querystring macros need some kind of cgisafe and
108 // htmlsafe functions (maybe to be defined in htmlutils.cpp?)
109
110 // the following macros are also defined in libinterface, some of them I'm not
111 // sure how to define from here and some I don't think are required anymore
112 // httpprefix
113 // numdocs
114 // collection
115 // istitle and pagedest -- these don't occur anywhere in the macro files
116
117 // I don't know what structure has replaced what used to be cfg_info
118 // so haven't defined the selection macros _hselection_, _jselection_
119 // and _nselection_ (these should be set in define_query_macros)
120
121 // _imagethispage_ needs to be set for any browse pages but I guess
122 // browse pages will be generated by a different action
123
124 // not sure what to do with any collection specific macros - these
125 // used to be defined in define_collection_macros although there
126 // wasn't much collection specific stuff left I don't think
127
128 // disp.setmacro ("gwcgi", "Global", recpt->get_gwcgi());
129 // disp.setmacro ("httpimg", "Global", recpt->get_httpimg());
130 // disp.setmacro("compressedoptions", "Global", recpt->get_compressed_arg(args));
131
132 // disp.setmacro("urlsafequerystring", "Global", cgisafe(outconvert.convert(args["q"])));
133 // disp.setmacro("querystring", "Global", htmlsafe(outconvert.convert(args["q"]))));
134
135 // define the macro for the "g" argument
136 disp.setmacro("g", "Global", args["g"]);
137
138 // this gets set unless page has been detached by the 'detach' button.
139 if (args.getintarg("x") == 0) disp.setmacro("notdetached", "Global", "1");
140
141 // not sure if home and about pages will both need query macros defined
142 if ((args["p"] == "query") || (args["p"] == "home") || (args["p"] == "about"))
143 define_query_macros (disp, args, logout);
144
145 if (args["p"] == "preferences")
146 define_pref_macros (disp, args, logout);
147
148}
149
150void pageaction::define_query_macros (displayclass &disp, cgiargsclass &args,
151 ostream &/*logout*/) {
152
153 // some/all query type selection
154 text_t qtselect = "<select name=\"t\">\n";
155 qtselect += "<option value=\"1\"";
156 if (args.getintarg("t") == 1) qtselect += " selected";
157 qtselect += ">_query:textsome_\n";
158 qtselect += "<option value=\"0\"";
159 if (args.getintarg("t") == 0) qtselect += " selected";
160 qtselect += ">_query:textall_\n";
161 qtselect += "</select>\n";
162 disp.setmacro("querytypeselection", "query", qtselect);
163
164
165}
166
167void pageaction::define_pref_macros (displayclass &disp, cgiargsclass &args,
168 ostream &/*logout*/) {
169
170 // the caseoption macro
171 text_t caseoption;
172 int arg_k = args.getintarg("k");
173
174 caseoption += "\n<input type=radio name=k value=1";
175 if (arg_k) caseoption += " checked";
176 caseoption += ">_textignorecase_<br>\n";
177 caseoption += "<input type=radio name=k value=0";
178 if (!arg_k) caseoption += " checked";
179 caseoption += ">_textmatchcase_\n";
180
181 disp.setmacro ("caseoption", "preferences", caseoption);
182
183 // the stemoption macro
184 text_t stemoption;
185 int arg_s = args.getintarg("s");
186
187 stemoption += "\n<input type=radio name=s value=1";
188 if (arg_s) stemoption += " checked";
189 stemoption += ">_textstem_<br>\n";
190 stemoption += "<input type=radio name=s value=0";
191 if (!arg_s) stemoption += " checked";
192 stemoption += ">_textnostem_\n";
193
194 disp.setmacro ("stemoption", "preferences", stemoption);
195
196
197 // the encodingoption
198 text_t encodingoption;
199 const text_t &arg_w = args["w"];
200
201 encodingoption += "\n<select name=\"nw\">\n";
202 encodingoption += " <option value=\"w\"";
203 if (arg_w == "w") encodingoption += " selected";
204 encodingoption += ">Western (ISO-8859-1)\n";
205 encodingoption += " <option value=\"g\"";
206 if (arg_w == "g") encodingoption += " selected";
207 encodingoption += ">Simplified Chinese (GB2312)\n";
208 encodingoption += " <option value=\"8\"";
209 if (arg_w == "8") encodingoption += " selected";
210 encodingoption += ">Unicode (UTF-8)\n";
211 encodingoption += "</select>\n";
212
213 disp.setmacro ("encodingoption", "preferences", encodingoption);
214
215 // the maxdocoption
216 text_t maxdocoption;
217 int arg_m = args.getintarg("m");
218
219 maxdocoption += "\n<select name=m>\n";
220 maxdocoption += " <option value=\"50\"";
221 if (arg_m < 100) maxdocoption += " selected";
222 maxdocoption += ">50\n";
223 maxdocoption += " <option value=\"100\"";
224 if (arg_m >= 100 && arg_m < 200) maxdocoption += " selected";
225 maxdocoption += ">100\n";
226 maxdocoption += " <option value=\"200\"";
227 if (arg_m >= 200 && arg_m < 500) maxdocoption += " selected";
228 maxdocoption += ">200\n";
229 maxdocoption += " <option value=\"500\"";
230 if (arg_m >= 500) maxdocoption += " selected";
231 maxdocoption += ">500\n";
232 maxdocoption += "</select>\n";
233
234 disp.setmacro ("maxdocoption", "preferences", maxdocoption);
235
236 // the hitsperpageoption
237 text_t hitsoption;
238 int arg_o = args.getintarg("o");
239
240 hitsoption += "\n<select name=o>\n";
241 hitsoption += " <option value=\"10\"";
242 if (arg_o < 20) hitsoption += " selected";
243 hitsoption += ">10\n";
244 hitsoption += " <option value=\"20\"";
245 if (arg_o >= 20 && arg_o < 50) hitsoption += " selected";
246 hitsoption += ">20\n";
247 hitsoption += " <option value=\"50\"";
248 if (arg_o >= 50 && arg_o < 100) hitsoption += " selected";
249 hitsoption += ">50\n";
250 hitsoption += " <option value=\"100\"";
251 if (arg_o >= 100 && arg_o < 500) hitsoption += " selected";
252 hitsoption += ">100\n";
253 hitsoption += " <option value=\"500\"";
254 if (arg_o >= 500) hitsoption += " selected";
255 hitsoption += ">all\n";
256 hitsoption += " </select>\n";
257
258 disp.setmacro ("hitsperpageoption", "preferences", hitsoption);
259}
260
Note: See TracBrowser for help on using the repository browser.