1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * pageaction.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 | // Changelog:
|
---|
27 |
|
---|
28 | // 11th July 2003:
|
---|
29 |
|
---|
30 | // Added 3 functions to deal with the collection style
|
---|
31 | // A deciding function and then 2 functions that actually
|
---|
32 | // do the work for us, either images or pulldown.
|
---|
33 |
|
---|
34 |
|
---|
35 | #include "OIDtools.h"
|
---|
36 | #include "pageaction.h"
|
---|
37 | #include "receptionist.h"
|
---|
38 | #include "fileutil.h"
|
---|
39 | #include "gsdltools.h"
|
---|
40 | #include <time.h>
|
---|
41 |
|
---|
42 | pageaction::pageaction () {
|
---|
43 |
|
---|
44 | status_disabled = true;
|
---|
45 | collector_disabled = true;
|
---|
46 | translator_disabled = true;
|
---|
47 | gliapplet_disabled = true;
|
---|
48 | recpt = NULL;
|
---|
49 |
|
---|
50 | // this action uses cgi variables "a", "p", and "hp"
|
---|
51 | cgiarginfo arg_ainfo;
|
---|
52 | arg_ainfo.shortname = "a";
|
---|
53 | arg_ainfo.longname = "action";
|
---|
54 | arg_ainfo.multiplechar = true;
|
---|
55 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
56 | arg_ainfo.argdefault = "p";
|
---|
57 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
58 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
59 |
|
---|
60 | arg_ainfo.shortname = "p";
|
---|
61 | arg_ainfo.longname = "page";
|
---|
62 | arg_ainfo.multiplechar = true;
|
---|
63 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
64 | arg_ainfo.argdefault = "home";
|
---|
65 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
66 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
67 |
|
---|
68 | arg_ainfo.shortname = "hp";
|
---|
69 | arg_ainfo.longname = "html page";
|
---|
70 | arg_ainfo.multiplechar = true;
|
---|
71 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
72 | arg_ainfo.argdefault = g_EmptyText;
|
---|
73 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
74 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
75 |
|
---|
76 | arg_ainfo.shortname = "bp";
|
---|
77 | arg_ainfo.longname = "set preferences button";
|
---|
78 | arg_ainfo.multiplechar = true;
|
---|
79 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
80 | arg_ainfo.argdefault = g_EmptyText;
|
---|
81 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
82 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
83 |
|
---|
84 | // the "u" argument will disable the search facility, remove links to the
|
---|
85 | // home and preferences pages, and disable the DocumentButton buttons
|
---|
86 | // (for use when generating static html versions of collections)
|
---|
87 | arg_ainfo.shortname = "u";
|
---|
88 | arg_ainfo.longname = "static page";
|
---|
89 | arg_ainfo.multiplechar = false;
|
---|
90 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
91 | arg_ainfo.argdefault = "0";
|
---|
92 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
93 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
94 | }
|
---|
95 |
|
---|
96 | pageaction::~pageaction () {
|
---|
97 | }
|
---|
98 |
|
---|
99 | bool pageaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &args,
|
---|
100 | recptprotolistclass * /*protos*/, ostream &/*logout*/) {
|
---|
101 |
|
---|
102 | if (args["p"] == "preferences" && !args["bp"].empty()) {
|
---|
103 | if (args["hd"] != "0") args["hd"] = args["hdn"];
|
---|
104 | }
|
---|
105 |
|
---|
106 | return true;
|
---|
107 | }
|
---|
108 |
|
---|
109 | void pageaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
|
---|
110 | response_t &response,text_t &response_data,
|
---|
111 | ostream &/*logout*/) {
|
---|
112 | response = content;
|
---|
113 | response_data = "text/html";
|
---|
114 | }
|
---|
115 |
|
---|
116 | // This function helps decide whether we want a
|
---|
117 | // images or pulldown style collection display
|
---|
118 | // We refer to the macro files for the options
|
---|
119 | // for images or pulldown menu and use that to
|
---|
120 | // switch to the appropriate function to do the job
|
---|
121 |
|
---|
122 | // Aly Dharshi
|
---|
123 | // 11th July 2003
|
---|
124 |
|
---|
125 | void pageaction::homepagestyle(displayclass &disp, recptprotolistclass *protos,
|
---|
126 | cgiargsclass &args, ostream &logout)
|
---|
127 | {
|
---|
128 |
|
---|
129 | const recptconf &configinfo = recpt->get_configinfo();
|
---|
130 |
|
---|
131 | if (configinfo.HomePageType == "images") {
|
---|
132 | home_images(disp, protos, args, configinfo, logout);
|
---|
133 |
|
---|
134 | } else
|
---|
135 | {
|
---|
136 | home_pulldown(disp, protos, args, configinfo, logout);
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | // This function allows for the Greenstone
|
---|
141 | // collection to be displayed in a pull down
|
---|
142 | // menu similar to that in documentaction.cpp
|
---|
143 |
|
---|
144 | // Aly Dharshi
|
---|
145 | // 11th July 2003
|
---|
146 |
|
---|
147 | void pageaction::home_pulldown(displayclass &disp, recptprotolistclass *protos,
|
---|
148 | cgiargsclass &args, const recptconf &configinfo,
|
---|
149 | ostream &logout) {
|
---|
150 |
|
---|
151 | //text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
|
---|
152 | //bool found_valid_col = false;
|
---|
153 |
|
---|
154 | text_t homeextra = "<form method=\"get\" name=\"browse\">\n";
|
---|
155 | homeextra += "<select name=\"collections\" onChange=\"location.href=";
|
---|
156 | homeextra += "document.browse.collections.options[document.browse.collections.selectedIndex].value\">\n";
|
---|
157 |
|
---|
158 |
|
---|
159 | recptprotolistclass::iterator rprotolist_here = protos->begin();
|
---|
160 | recptprotolistclass::iterator rprotolist_end = protos->end();
|
---|
161 | while (rprotolist_here != rprotolist_end) {
|
---|
162 | if ((*rprotolist_here).p != NULL) {
|
---|
163 |
|
---|
164 | text_tarray collist;
|
---|
165 | comerror_t err;
|
---|
166 | (*rprotolist_here).p->get_collection_list (collist, err, logout);
|
---|
167 | if (err == noError) {
|
---|
168 | text_tarray::iterator collist_here = collist.begin();
|
---|
169 | text_tarray::iterator collist_end = collist.end();
|
---|
170 |
|
---|
171 | int count = 0;
|
---|
172 | bool first = true;
|
---|
173 | while (collist_here != collist_end) {
|
---|
174 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
|
---|
175 |
|
---|
176 | if (cinfo != NULL) {
|
---|
177 | if (cinfo->isPublic && (cinfo->buildDate > 0)) {
|
---|
178 |
|
---|
179 | text_t coll_type = "&ct=";
|
---|
180 | if ((cinfo->buildType == "mgpp") || (cinfo->buildType == "lucene")) {
|
---|
181 |
|
---|
182 | if (cinfo->buildType == "mgpp") {
|
---|
183 | coll_type += "1";
|
---|
184 | }
|
---|
185 | else {
|
---|
186 | coll_type += "2";
|
---|
187 | }
|
---|
188 |
|
---|
189 | coll_type += "&qto=";
|
---|
190 |
|
---|
191 | // now we also want to check search types to set the qto arg
|
---|
192 | if (cinfo->searchTypes.size() == 0) {
|
---|
193 | coll_type += "3"; // default to 3 (= both)
|
---|
194 | } else {
|
---|
195 | unsigned int search_types = 0;
|
---|
196 | text_tarray::const_iterator type_here = cinfo->searchTypes.begin();
|
---|
197 | text_tarray::const_iterator type_end = cinfo->searchTypes.end();
|
---|
198 |
|
---|
199 | while (type_here != type_end) {
|
---|
200 | if (*type_here == "form") {
|
---|
201 | search_types |= 2;
|
---|
202 | } else if (*type_here == "plain") {
|
---|
203 | search_types |= 1;
|
---|
204 | }
|
---|
205 | ++type_here;
|
---|
206 | }
|
---|
207 | coll_type += search_types;
|
---|
208 | if (search_types == 3) {
|
---|
209 | // both were specified, now need to look at the order to see which is the default
|
---|
210 | type_here = cinfo->searchTypes.begin();
|
---|
211 | if (*type_here == "form") {
|
---|
212 | coll_type += "&qt=1"; // set the default to form
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 | }
|
---|
217 | }
|
---|
218 | else {
|
---|
219 | coll_type += "0";
|
---|
220 | }
|
---|
221 |
|
---|
222 | FilterResponse_t response;
|
---|
223 | text_tset metadata;
|
---|
224 | metadata.insert ("collectionname");
|
---|
225 | text_t lang = args["l"];
|
---|
226 | if (!lang.empty()) {
|
---|
227 | metadata.insert ("collectionname:"+lang);
|
---|
228 | }
|
---|
229 | text_t collectionname = *collist_here;
|
---|
230 |
|
---|
231 | if (get_info ("collection", *collist_here, "", metadata, false,
|
---|
232 | (*rprotolist_here).p, response, logout)) {
|
---|
233 | if (!lang.empty() && !response.docInfo[0].metadata["collectionname:"+lang].values[0].empty()) {
|
---|
234 | collectionname = response.docInfo[0].metadata["collectionname:"+lang].values[0];
|
---|
235 | } else if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
|
---|
236 | collectionname = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | comerror_t err;
|
---|
241 | text_t optsite = g_EmptyText;
|
---|
242 | text_t site_name = (*rprotolist_here).p->get_site_name (err);
|
---|
243 | if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
|
---|
244 |
|
---|
245 | text_t link = "_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type;
|
---|
246 | link += "&l=" + args["l"] + "&w=" + args["w"];
|
---|
247 |
|
---|
248 | // We are "dynamically" overriding so to speak the
|
---|
249 | // link to the collection aka receptionist.
|
---|
250 |
|
---|
251 | if (!cinfo->receptionist.empty())
|
---|
252 | link = cinfo->receptionist;
|
---|
253 |
|
---|
254 |
|
---|
255 | homeextra += "<option value=\"" + link + "\"";
|
---|
256 | homeextra += ">" + collectionname + "</option>\n";
|
---|
257 |
|
---|
258 | }
|
---|
259 |
|
---|
260 | ++collist_here;
|
---|
261 | }
|
---|
262 |
|
---|
263 | }
|
---|
264 | }
|
---|
265 | ++rprotolist_here;
|
---|
266 | }
|
---|
267 |
|
---|
268 | }
|
---|
269 | homeextra += "</select>\n";
|
---|
270 | homeextra += "</form>\n";
|
---|
271 |
|
---|
272 | disp.setmacro ("homeextra", "home", homeextra);
|
---|
273 | }
|
---|
274 |
|
---|
275 | // originally called set_homeextra_macro
|
---|
276 | // this function displays the Greenstone
|
---|
277 | // main page as usual with the graphics for
|
---|
278 | // the collections.
|
---|
279 |
|
---|
280 | // Aly Dharshi
|
---|
281 | // 11th July 2003
|
---|
282 |
|
---|
283 | void pageaction::home_images(displayclass &disp, recptprotolistclass *protos,
|
---|
284 | cgiargsclass &args, const recptconf &configinfo,
|
---|
285 | ostream &logout) {
|
---|
286 |
|
---|
287 | text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
|
---|
288 | bool found_valid_col = false;
|
---|
289 | recptprotolistclass::iterator rprotolist_here = protos->begin();
|
---|
290 | recptprotolistclass::iterator rprotolist_end = protos->end();
|
---|
291 | while (rprotolist_here != rprotolist_end) {
|
---|
292 | if ((*rprotolist_here).p != NULL) {
|
---|
293 |
|
---|
294 | text_tarray collist;
|
---|
295 | comerror_t err;
|
---|
296 | (*rprotolist_here).p->get_collection_list (collist, err, logout);
|
---|
297 | if (err == noError) {
|
---|
298 | text_tarray::iterator collist_here = collist.begin();
|
---|
299 | text_tarray::iterator collist_end = collist.end();
|
---|
300 |
|
---|
301 | int count = 0;
|
---|
302 | bool first = true;
|
---|
303 | while (collist_here != collist_end) {
|
---|
304 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
|
---|
305 |
|
---|
306 | if (cinfo != NULL) {
|
---|
307 | if (cinfo->isPublic && (cinfo->buildDate > 0)) {
|
---|
308 |
|
---|
309 | text_t coll_type = "&ct=";
|
---|
310 | if ((cinfo->buildType == "mgpp") || (cinfo->buildType == "lucene")) {
|
---|
311 |
|
---|
312 | if (cinfo->buildType == "mgpp") {
|
---|
313 | coll_type += "1";
|
---|
314 | }
|
---|
315 | else {
|
---|
316 | coll_type += "2";
|
---|
317 | }
|
---|
318 |
|
---|
319 | coll_type += "&qto=";
|
---|
320 |
|
---|
321 | // now we also want to check search types to set the qto arg
|
---|
322 | if (cinfo->searchTypes.size() == 0) {
|
---|
323 | coll_type += "3"; // default to 3 (= both)
|
---|
324 | } else {
|
---|
325 | unsigned int search_types = 0;
|
---|
326 | text_tarray::const_iterator type_here = cinfo->searchTypes.begin();
|
---|
327 | text_tarray::const_iterator type_end = cinfo->searchTypes.end();
|
---|
328 |
|
---|
329 | while (type_here != type_end) {
|
---|
330 | if (*type_here == "form") {
|
---|
331 | search_types |= 2;
|
---|
332 | } else if (*type_here == "plain") {
|
---|
333 | search_types |= 1;
|
---|
334 | }
|
---|
335 | ++type_here;
|
---|
336 | }
|
---|
337 | coll_type += search_types;
|
---|
338 | if (search_types == 3) {
|
---|
339 | // both were specified, now need to look at the order to see which is the default
|
---|
340 | type_here = cinfo->searchTypes.begin();
|
---|
341 | if (*type_here == "form") {
|
---|
342 | coll_type += "&qt=1"; // set the default to form
|
---|
343 | }
|
---|
344 | }
|
---|
345 |
|
---|
346 | }
|
---|
347 | }
|
---|
348 | else {
|
---|
349 | coll_type += "0";
|
---|
350 | }
|
---|
351 |
|
---|
352 | found_valid_col = true;
|
---|
353 | FilterResponse_t response;
|
---|
354 | text_tset metadata;
|
---|
355 | metadata.insert ("collectionname");
|
---|
356 | metadata.insert ("iconcollection");
|
---|
357 | metadata.insert ("iconcollectionsmall");
|
---|
358 | // also look for lang specific values
|
---|
359 | text_t lang = args["l"];
|
---|
360 | if (!lang.empty()) {
|
---|
361 | metadata.insert ("collectionname:"+lang);
|
---|
362 | metadata.insert ("iconcollection:"+lang);
|
---|
363 | metadata.insert ("iconcollectionsmall:"+lang);
|
---|
364 | }
|
---|
365 | text_t collectionname = *collist_here;
|
---|
366 | text_t alt = collectionname;
|
---|
367 |
|
---|
368 | if (get_info ("collection", *collist_here, "", metadata, false,
|
---|
369 | (*rprotolist_here).p, response, logout)) {
|
---|
370 | // get the "collectionname"
|
---|
371 | if (!lang.empty() && !response.docInfo[0].metadata["collectionname:"+lang].values[0].empty()) {
|
---|
372 | alt = response.docInfo[0].metadata["collectionname:"+lang].values[0];
|
---|
373 | } else if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
|
---|
374 | alt = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
375 | }
|
---|
376 |
|
---|
377 | text_t iconurl;
|
---|
378 | iconurl.clear();
|
---|
379 |
|
---|
380 | if (!lang.empty() &&!response.docInfo[0].metadata["iconcollectionsmall:"+lang].values[0].empty()) {
|
---|
381 | iconurl = response.docInfo[0].metadata["iconcollectionsmall:"+lang].values[0];
|
---|
382 | } else if (!response.docInfo[0].metadata["iconcollectionsmall"].values[0].empty()) {
|
---|
383 | iconurl = response.docInfo[0].metadata["iconcollectionsmall"].values[0];
|
---|
384 | } else if (!lang.empty() && !response.docInfo[0].metadata["iconcollection:"+lang].values[0].empty()) {
|
---|
385 | iconurl = response.docInfo[0].metadata["iconcollection:"+lang].values[0];
|
---|
386 | } else if (!response.docInfo[0].metadata["iconcollection"].values[0].empty()) {
|
---|
387 | iconurl = response.docInfo[0].metadata["iconcollection"].values[0];
|
---|
388 | }
|
---|
389 |
|
---|
390 | if (!iconurl.empty())
|
---|
391 | {
|
---|
392 | // check to see URL is local to colserver
|
---|
393 | text_t::iterator iconurl_head = iconurl.begin();
|
---|
394 | text_t iconhead = substr(iconurl_head,iconurl_head+16);
|
---|
395 | if (iconhead=="_httpcollection_")
|
---|
396 | {
|
---|
397 | // local and using _httpcollection_
|
---|
398 | text_t icontail = substr(iconurl_head+16,iconurl.end());
|
---|
399 | iconurl = "http://" + cinfo->httpdomain
|
---|
400 | + cinfo->httpprefix + "/collect/"
|
---|
401 | + *collist_here + "/" + icontail;
|
---|
402 | }
|
---|
403 | else if (iconurl[0]=='/')
|
---|
404 | {
|
---|
405 | // local but with full path
|
---|
406 | iconurl = "http://" + cinfo->httpdomain + iconurl;
|
---|
407 | }
|
---|
408 |
|
---|
409 | collectionname
|
---|
410 | = "<img width=150 border=1 src=\"" + iconurl + "\" alt=\"" + alt + "\">";
|
---|
411 | }
|
---|
412 | else
|
---|
413 | {
|
---|
414 | collectionname = alt;
|
---|
415 | }
|
---|
416 |
|
---|
417 | }
|
---|
418 | if ((count%configinfo.HomePageCols == 0) && (!first))
|
---|
419 | homeextra += "</tr><tr valign=top>\n";
|
---|
420 |
|
---|
421 | comerror_t err;
|
---|
422 | text_t optsite = g_EmptyText;
|
---|
423 | text_t site_name = (*rprotolist_here).p->get_site_name (err);
|
---|
424 | if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
|
---|
425 |
|
---|
426 | text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type;
|
---|
427 | link += "&l=" + args["l"] + "&w=" + args["w"] + "\">";
|
---|
428 |
|
---|
429 | if (!cinfo->receptionist.empty())
|
---|
430 | link = "<a href=\"" + cinfo->receptionist + "\">";
|
---|
431 |
|
---|
432 | homeextra += "<td>" + link + collectionname + "</a></td>\n";
|
---|
433 |
|
---|
434 | ++count;
|
---|
435 | first = false;
|
---|
436 | }
|
---|
437 | }
|
---|
438 | ++collist_here;
|
---|
439 | }
|
---|
440 |
|
---|
441 | for (; count%configinfo.HomePageCols != 0; ++count) homeextra += "<td></td>\n";
|
---|
442 | }
|
---|
443 | }
|
---|
444 | homeextra += "</td></tr>\n<tr>\n";
|
---|
445 | ++rprotolist_here;
|
---|
446 | }
|
---|
447 |
|
---|
448 | if (!found_valid_col) {
|
---|
449 | homeextra += "<td>No valid (i.e. built and public) collections are available</td>\n";
|
---|
450 | }
|
---|
451 | homeextra += "</tr></table></center>\n";
|
---|
452 | disp.setmacro ("homeextra", "home", homeextra);
|
---|
453 | }
|
---|
454 |
|
---|
455 | void pageaction::set_collectionlist_macro (displayclass &disp, recptprotolistclass *protos,
|
---|
456 | ostream &logout) {
|
---|
457 |
|
---|
458 | text_t collectionlist;
|
---|
459 | int count = 0;
|
---|
460 |
|
---|
461 | recptprotolistclass::iterator rprotolist_here = protos->begin();
|
---|
462 | recptprotolistclass::iterator rprotolist_end = protos->end();
|
---|
463 | while (rprotolist_here != rprotolist_end) {
|
---|
464 | if ((*rprotolist_here).p != NULL) {
|
---|
465 |
|
---|
466 | text_tarray collist;
|
---|
467 | comerror_t err;
|
---|
468 | (*rprotolist_here).p->get_collection_list (collist, err, logout);
|
---|
469 | if (err == noError) {
|
---|
470 | text_tarray::iterator collist_here = collist.begin();
|
---|
471 | text_tarray::iterator collist_end = collist.end();
|
---|
472 |
|
---|
473 | while (collist_here != collist_end) {
|
---|
474 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
|
---|
475 |
|
---|
476 | if (cinfo != NULL) {
|
---|
477 | if (cinfo->isPublic && (cinfo->buildDate > 0)) {
|
---|
478 |
|
---|
479 | ++count;
|
---|
480 |
|
---|
481 | text_t coll_type = "&ct=";
|
---|
482 |
|
---|
483 | if ((cinfo->buildType == "mgpp") || (cinfo->buildType == "lucene")) {
|
---|
484 |
|
---|
485 | if (cinfo->buildType == "mgpp") {
|
---|
486 | coll_type += "1";
|
---|
487 | }
|
---|
488 | else {
|
---|
489 | coll_type += "2";
|
---|
490 | }
|
---|
491 |
|
---|
492 | coll_type += "&qto=";
|
---|
493 |
|
---|
494 | // now we also want to check search types to set the qto arg
|
---|
495 | if (cinfo->searchTypes.size() == 0) {
|
---|
496 | coll_type += "3"; // default to 2 (= both)
|
---|
497 | } else {
|
---|
498 | int search_types = 0;
|
---|
499 | text_tarray::const_iterator type_here = cinfo->searchTypes.begin();
|
---|
500 | text_tarray::const_iterator type_end = cinfo->searchTypes.end();
|
---|
501 |
|
---|
502 | while (type_here != type_end) {
|
---|
503 | if (*type_here == "form") {
|
---|
504 | search_types |= 0x10;
|
---|
505 | } else if (*type_here == "plain") {
|
---|
506 | search_types |= 0x01;
|
---|
507 | }
|
---|
508 | ++type_here;
|
---|
509 | }
|
---|
510 | coll_type += search_types;
|
---|
511 |
|
---|
512 | if (search_types == 3) {
|
---|
513 | // both were specified, now need to look at the order to see which is the default
|
---|
514 | type_here = cinfo->searchTypes.begin();
|
---|
515 | if (*type_here == "form") {
|
---|
516 | coll_type += "&qt=1"; // set the default to form
|
---|
517 | }
|
---|
518 | }
|
---|
519 | }
|
---|
520 | }
|
---|
521 | else {
|
---|
522 | coll_type += "0";
|
---|
523 | }
|
---|
524 | FilterResponse_t response;
|
---|
525 | text_tset metadata;
|
---|
526 | metadata.insert ("collectionname");
|
---|
527 | text_t collectionname = *collist_here;
|
---|
528 |
|
---|
529 | if (get_info ("collection", *collist_here, "", metadata, false,
|
---|
530 | (*rprotolist_here).p, response, logout)) {
|
---|
531 | if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
|
---|
532 | collectionname = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
533 | }
|
---|
534 | }
|
---|
535 |
|
---|
536 | comerror_t err;
|
---|
537 | text_t optsite = g_EmptyText;
|
---|
538 | text_t site_name = (*rprotolist_here).p->get_site_name (err);
|
---|
539 | if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
|
---|
540 |
|
---|
541 | text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type+"\">";
|
---|
542 |
|
---|
543 | if (!cinfo->receptionist.empty())
|
---|
544 | link = "<a href=\"" + cinfo->receptionist + "\">";
|
---|
545 |
|
---|
546 | collectionlist += "<li>" + link + collectionname + "</a>\n";
|
---|
547 | }
|
---|
548 | }
|
---|
549 | ++collist_here;
|
---|
550 | }
|
---|
551 | }
|
---|
552 | }
|
---|
553 | ++rprotolist_here;
|
---|
554 | }
|
---|
555 |
|
---|
556 | if (count == 1) {
|
---|
557 | collectionlist = "<p>_text1coll_\n<ul>" +
|
---|
558 | collectionlist + "</ul>\n";
|
---|
559 | } else if (count > 1) {
|
---|
560 | collectionlist = "<p>_textmorecolls_(" + text_t(count) +
|
---|
561 | ")\n<ul>" + collectionlist + "</ul>\n";
|
---|
562 | }
|
---|
563 |
|
---|
564 | disp.setmacro ("collectionlist", "homehelp", collectionlist);
|
---|
565 | }
|
---|
566 |
|
---|
567 | void pageaction::set_documentation_macro (displayclass &disp) {
|
---|
568 |
|
---|
569 | text_t documentation;
|
---|
570 | text_t docsdir = filename_cat(gsdlhome, "docs");
|
---|
571 |
|
---|
572 | if (file_exists(filename_cat(docsdir, "User.pdf"))) {
|
---|
573 | documentation += "<tr valign=middle><td><a href=\"_httpdocs_/User.pdf\">_iconpdf_"
|
---|
574 | "</a></td><td>_textuserguide_</td></tr>";
|
---|
575 | }
|
---|
576 |
|
---|
577 | if (file_exists(filename_cat(docsdir, "Install.pdf"))) {
|
---|
578 | documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Install.pdf\">_iconpdf_"
|
---|
579 | "</a></td><td>_textinstallerguide_</td></tr>";
|
---|
580 | }
|
---|
581 |
|
---|
582 | if (file_exists(filename_cat(docsdir, "Develop.pdf"))) {
|
---|
583 | documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Develop.pdf\">_iconpdf_"
|
---|
584 | "</a></td><td>_textdeveloperguide_</td></tr>";
|
---|
585 | }
|
---|
586 |
|
---|
587 | if (file_exists(filename_cat(docsdir, "Paper.pdf"))) {
|
---|
588 | documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Paper.pdf\">_iconpdf_"
|
---|
589 | "</a></td><td>_textpaperguide_</td></tr>";
|
---|
590 | }
|
---|
591 |
|
---|
592 | if (file_exists(filename_cat(docsdir, "Organize.pdf"))) {
|
---|
593 | documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Organize.pdf\">_iconpdf_"
|
---|
594 | "</a></td><td>_textorganizerguide_</td></tr>";
|
---|
595 | }
|
---|
596 |
|
---|
597 | if (!documentation.empty()) {
|
---|
598 | disp.setmacro("documentation", "docs", "<p>\n<table border=0>\n" + documentation + "\n</table>\n");
|
---|
599 | }
|
---|
600 | }
|
---|
601 |
|
---|
602 | void pageaction::set_macro_to_file_contents (displayclass &disp, const text_t ¯oname,
|
---|
603 | const text_t &packagename, const text_t &filename) {
|
---|
604 |
|
---|
605 | text_t filecontent;
|
---|
606 | char *filenamec = filename.getcstr();
|
---|
607 | ifstream file_in (filenamec);
|
---|
608 | delete []filenamec;
|
---|
609 | if (file_in) {
|
---|
610 | char c;
|
---|
611 | file_in.get(c);
|
---|
612 | while (!file_in.eof ()) {
|
---|
613 | if (c == '\n') filecontent += "<br>";
|
---|
614 | filecontent.push_back(c);
|
---|
615 | file_in.get(c);
|
---|
616 | }
|
---|
617 | file_in.close();
|
---|
618 | }
|
---|
619 | disp.setmacro (macroname, packagename, dm_safe(filecontent));
|
---|
620 | }
|
---|
621 |
|
---|
622 | void pageaction::set_language_encoding_macros(displayclass &disp, cgiargsclass &args,
|
---|
623 | recptprotolistclass *protos, ColInfoResponse_t *cinfo,
|
---|
624 | ostream &logout) {
|
---|
625 | // _languageoption_
|
---|
626 | // Create the "interface language" selection box for the preferences
|
---|
627 | // pages. You can use something like "format PreferenceLanguages
|
---|
628 | // en|fr|zn" from within a collect.cfg file to use only a subset of
|
---|
629 | // the available languages for any given collection (for
|
---|
630 | // collection-specific preferences pages). This facility is kind of
|
---|
631 | // ugly though and should be replaced by something better when the
|
---|
632 | // configuration files are tidied up (as should all the other
|
---|
633 | // "format Preference..." options).
|
---|
634 | text_t &arg_l = args["l"];
|
---|
635 | const recptconf &configinfo = recpt->get_configinfo();
|
---|
636 | // put languages in another map to sort them by longname
|
---|
637 | text_tmap languages;
|
---|
638 | languageinfo_tmap::const_iterator thislang = configinfo.languages.begin();
|
---|
639 | languageinfo_tmap::const_iterator endlang = configinfo.languages.end();
|
---|
640 | while (thislang != endlang) {
|
---|
641 | languages[(*thislang).second.longname] = (*thislang).first;
|
---|
642 | ++thislang;
|
---|
643 | }
|
---|
644 | text_tmap::iterator tlang = languages.begin();
|
---|
645 | text_tmap::iterator elang = languages.end();
|
---|
646 |
|
---|
647 | text_t languageoption;
|
---|
648 | bool collection_specific = false;
|
---|
649 |
|
---|
650 | if (cinfo != NULL) {
|
---|
651 | text_tmap::const_iterator it = cinfo->format.find ("PreferenceLanguages");
|
---|
652 | if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
|
---|
653 | collection_specific = true;
|
---|
654 | text_tset pref_langs;
|
---|
655 | splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
|
---|
656 | if (pref_langs.size() > 1) {
|
---|
657 | while (tlang != elang) {
|
---|
658 | if (pref_langs.find((*tlang).second) != pref_langs.end()) {
|
---|
659 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
660 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
661 | languageoption += ">" + (*tlang).first + "</option>\n";
|
---|
662 | }
|
---|
663 | ++tlang;
|
---|
664 | }
|
---|
665 | }
|
---|
666 | }
|
---|
667 | }
|
---|
668 |
|
---|
669 | if (!collection_specific) {
|
---|
670 | while (tlang != elang) {
|
---|
671 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
672 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
673 | languageoption += ">" + (*tlang).first + "</option>\n";
|
---|
674 | ++tlang;
|
---|
675 | }
|
---|
676 | }
|
---|
677 |
|
---|
678 | if (!languageoption.empty()) {
|
---|
679 | languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption;
|
---|
680 | languageoption += "</select>\n";
|
---|
681 | disp.setmacro ("languageoption", args["p"], languageoption);
|
---|
682 | }
|
---|
683 |
|
---|
684 | // _encodingoption_
|
---|
685 | // create the "encoding" selection box for the preferences page
|
---|
686 | if (configinfo.encodings.size() > 1) {
|
---|
687 | text_t &arg_w = args["w"];
|
---|
688 | text_t encodingoption;
|
---|
689 | text_tmap::const_iterator thisenc = configinfo.encodings.begin();
|
---|
690 | text_tmap::const_iterator endenc = configinfo.encodings.end();
|
---|
691 | while (thisenc != endenc) {
|
---|
692 | encodingoption += "<option value=\"" + (*thisenc).second + "\"";
|
---|
693 | if ((*thisenc).second == arg_w) encodingoption += " selected";
|
---|
694 | encodingoption += ">" + (*thisenc).first + "</option>\n";
|
---|
695 | ++thisenc;
|
---|
696 | }
|
---|
697 |
|
---|
698 | encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption;
|
---|
699 | encodingoption += "</select>\n";
|
---|
700 | disp.setmacro ("encodingoption", args["p"], encodingoption);
|
---|
701 | }
|
---|
702 | }
|
---|
703 |
|
---|
704 | void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
705 | recptprotolistclass *protos, ostream &logout) {
|
---|
706 |
|
---|
707 | // define_internal_macros sets the following macros:
|
---|
708 |
|
---|
709 | // _numdocs_ the number of documents in the collection
|
---|
710 |
|
---|
711 | // _builddate_ the date last built
|
---|
712 |
|
---|
713 | // if page is "home"
|
---|
714 | // _homeextra_ this is the list of available collections and collection info
|
---|
715 | // to be displayed on the home page
|
---|
716 |
|
---|
717 |
|
---|
718 | // if page is "preferences"
|
---|
719 | // _collectionoption_ collections to search/browse (if cross-collection-searching is on)
|
---|
720 |
|
---|
721 | // _htmloptions_ set to _htmloptionson_ if DocumentUseHTML is set
|
---|
722 |
|
---|
723 | // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set
|
---|
724 |
|
---|
725 |
|
---|
726 | // if page is "preferences" or "homepref"
|
---|
727 | // _languageoption_ interface languages to select from (dependant on PreferenceLanguages)
|
---|
728 |
|
---|
729 | // _encodingoption_ encodings to select from
|
---|
730 |
|
---|
731 |
|
---|
732 | // if page is "about"
|
---|
733 | // _textsubcollections_ the text on which subcollections make up the collection (if
|
---|
734 | // cross-collection searching is being used
|
---|
735 |
|
---|
736 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
737 |
|
---|
738 | // _numbrowseoptions_ the number of browsing options
|
---|
739 |
|
---|
740 | // _prefschanged_ will be set to _textprefschanged_ if the "set preferences" button
|
---|
741 | // was pressed
|
---|
742 |
|
---|
743 | // _aboutqueryform_ will be set to "" if the collection isn't searchable
|
---|
744 |
|
---|
745 | // if page is "help"
|
---|
746 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
747 |
|
---|
748 | // _numbrowseoptions_ the number of browsing options
|
---|
749 |
|
---|
750 | // _topicreadingdocs_ this section of the help text differs depending on what type of
|
---|
751 | // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
|
---|
752 | // _texthelpreadingdocs_
|
---|
753 |
|
---|
754 | // if page is "home" or "homehelp"
|
---|
755 | // _textgocollector_ set to "" if collector is disabled in main.cfg
|
---|
756 | // _textgoadmin_ set to "" if status is disabled in main.cfg
|
---|
757 | // _textgotranslator_ set to "" if translator is disabled in main.cfg
|
---|
758 | // _textgogliapplet_ set to "" if gliapplet is disabled in main.cfg
|
---|
759 |
|
---|
760 |
|
---|
761 | // if page is "homehelp"
|
---|
762 | // _collectionlist_ list of available collections to be displayed on the homehelp page
|
---|
763 |
|
---|
764 |
|
---|
765 | // if page is "docs"
|
---|
766 | // _documentation_ links to PDF documents if they're available
|
---|
767 |
|
---|
768 |
|
---|
769 | // if page is "bsummary"
|
---|
770 | // _importlog_ set to contents of collections import.log file
|
---|
771 | // _faillog_ set to contents of collections fail.log file
|
---|
772 |
|
---|
773 |
|
---|
774 | if (recpt == NULL) {
|
---|
775 | logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
|
---|
776 | << " information about any receptionists. The method set_receptionist was\n"
|
---|
777 | << " probably not called from the module which instantiated this action.\n";
|
---|
778 | return;
|
---|
779 | }
|
---|
780 |
|
---|
781 | text_t &arg_p = args["p"];
|
---|
782 | text_t &arg_c = args["c"];
|
---|
783 | ColInfoResponse_t *cinfo = NULL;
|
---|
784 |
|
---|
785 | recptproto* collectproto = protos->getrecptproto (arg_c, logout);
|
---|
786 | if (collectproto != NULL) {
|
---|
787 | cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
|
---|
788 |
|
---|
789 | disp.setmacro ("numdocs", displayclass::defaultpackage, cinfo->numDocs);
|
---|
790 | unsigned long current_time = time(NULL);
|
---|
791 | unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
|
---|
792 | disp.setmacro ("builddate", displayclass::defaultpackage, builddate);
|
---|
793 |
|
---|
794 | text_t numbytes;
|
---|
795 | if ((cinfo->numBytes/(1024*1024)) > 1) {
|
---|
796 | numbytes = (text_t)(cinfo->numBytes/(1024*1024)) + " Mb";
|
---|
797 | } else if ((cinfo->numBytes/1024) > 1) {
|
---|
798 | numbytes = (text_t)(cinfo->numBytes/1024) + " kb";
|
---|
799 | } else {
|
---|
800 | numbytes = (text_t)cinfo->numBytes + " bytes";
|
---|
801 | }
|
---|
802 | disp.setmacro("numbytes", displayclass::defaultpackage, numbytes);
|
---|
803 | }
|
---|
804 |
|
---|
805 | //setting _queryformcontent_ so that the query interface is consistent.
|
---|
806 | //also adding usability button if necessary
|
---|
807 | if (arg_p == "about") {
|
---|
808 | if (cinfo == NULL) {
|
---|
809 | disp.setmacro("cvariable", displayclass::defaultpackage, arg_c);
|
---|
810 | disp.setmacro("content", arg_p, "<p>_textbadcollection_<p>");
|
---|
811 | return;
|
---|
812 | }
|
---|
813 | else {
|
---|
814 |
|
---|
815 | text_tmap::iterator check = cinfo->format.find("QueryInterface");
|
---|
816 | if(check != cinfo->format.end()){
|
---|
817 | if((*check).second=="DateSearch"){
|
---|
818 | text_t current = "_datesearch_";
|
---|
819 | disp.setmacro("optdatesearch","query",current);
|
---|
820 | }
|
---|
821 | }
|
---|
822 | check = cinfo->format.find("Usability");
|
---|
823 | if(check != cinfo->format.end()){
|
---|
824 | disp.setmacro("usability", displayclass::defaultpackage, "_imageusab_");
|
---|
825 | disp.setmacro("usabinterface", displayclass::defaultpackage, ("_usab"+(*check).second+"_"));
|
---|
826 | disp.setmacro("usabilityscript", displayclass::defaultpackage, "_usabshowscript_");
|
---|
827 | }
|
---|
828 | }
|
---|
829 | }
|
---|
830 |
|
---|
831 | if (arg_p == "home" || arg_p == "homehelp") {
|
---|
832 | if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
|
---|
833 | if (collector_disabled) disp.setmacro ("textgocollector", "home", "");
|
---|
834 | if (translator_disabled) disp.setmacro ("textgotranslator", "home", "");
|
---|
835 |
|
---|
836 | if (arg_p == "home") {
|
---|
837 | homepagestyle (disp, protos, args, logout);
|
---|
838 | } else if (arg_p == "homehelp") {
|
---|
839 | set_collectionlist_macro (disp, protos, logout);
|
---|
840 | }
|
---|
841 |
|
---|
842 | } else if (arg_p == "gli") {
|
---|
843 | if (gliapplet_disabled) disp.setmacro ("gliapplet", "gli", "");
|
---|
844 |
|
---|
845 | } else if (arg_p == "homepref") {
|
---|
846 |
|
---|
847 | // set _languageoption_ and _encodingoption_
|
---|
848 | set_language_encoding_macros(disp, args, protos, cinfo, logout);
|
---|
849 |
|
---|
850 | } else if (arg_p == "preferences") {
|
---|
851 |
|
---|
852 | if (cinfo == NULL) {
|
---|
853 | disp.setmacro("cvariable", displayclass::defaultpackage, arg_c);
|
---|
854 | disp.setmacro("content", arg_p, "<p>_textbadcollection_<p>");
|
---|
855 | return;
|
---|
856 | }
|
---|
857 |
|
---|
858 | if (collectproto == NULL) {return;}
|
---|
859 |
|
---|
860 | // set _languageoption_ and _encodingoption_
|
---|
861 | set_language_encoding_macros(disp, args, protos, cinfo, logout);
|
---|
862 |
|
---|
863 | // _collectionoption_
|
---|
864 | if ((args["ccs"] == "1") && (cinfo->ccsCols.size() > 1)) {
|
---|
865 | text_t collectionoption = "_textcollectionoption_";
|
---|
866 | text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
|
---|
867 | text_tarray::const_iterator col_end = cinfo->ccsCols.end();
|
---|
868 | int count = 0;
|
---|
869 | while (col_here != col_end) {
|
---|
870 | text_t colname;
|
---|
871 | if (*col_here == arg_c) {
|
---|
872 | colname = cinfo->collectionmeta["collectionname"];
|
---|
873 | } else {
|
---|
874 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
|
---|
875 | if (this_cinfo == NULL) {++col_here; continue;}
|
---|
876 | colname = this_cinfo->collectionmeta["collectionname"];
|
---|
877 | }
|
---|
878 |
|
---|
879 | ++count;
|
---|
880 | collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
|
---|
881 | *col_here + "\" onClick=\"updatecc(\'" + *col_here + "\');\"> " +
|
---|
882 | colname + "<br>\n";
|
---|
883 | ++col_here;
|
---|
884 | }
|
---|
885 |
|
---|
886 | if (count > 1)
|
---|
887 | disp.setmacro ("collectionoption", "preferences", collectionoption);
|
---|
888 | }
|
---|
889 |
|
---|
890 | // _htmloptions_
|
---|
891 |
|
---|
892 | text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
|
---|
893 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
894 | disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
|
---|
895 |
|
---|
896 |
|
---|
897 | // _PreferenceDocsFromWeb_
|
---|
898 |
|
---|
899 | it = cinfo->format.find ("PreferenceDocsFromWeb");
|
---|
900 | if ((it == cinfo->format.end()) || ((*it).second == "true"))
|
---|
901 | disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
|
---|
902 | }
|
---|
903 |
|
---|
904 | // _prefschanged_
|
---|
905 | if (!args["bp"].empty()) {
|
---|
906 | disp.setmacro ("prefschanged", "preferences", "_textprefschanged_");
|
---|
907 | }
|
---|
908 |
|
---|
909 | } else if (arg_p == "about" || arg_p == "help") {
|
---|
910 | if (collectproto == NULL) return;
|
---|
911 |
|
---|
912 | comerror_t err;
|
---|
913 | bool has_search_button = true;
|
---|
914 | collectproto->is_searchable(args["c"], has_search_button, err, logout);
|
---|
915 | if (err != noError) has_search_button = true;
|
---|
916 |
|
---|
917 | // _textbrowseoptions_ and _numbrowseoptions_
|
---|
918 |
|
---|
919 | FilterResponse_t response;
|
---|
920 | text_tset metadata;
|
---|
921 | metadata.insert ("Title");
|
---|
922 | //****************
|
---|
923 | metadata.insert ("childtype");
|
---|
924 | //****************
|
---|
925 | bool getParents = false;
|
---|
926 | get_children ("", args["c"], args["l"], metadata, getParents, collectproto, response, logout);
|
---|
927 |
|
---|
928 | int numbrowseoptions = response.docInfo.size();
|
---|
929 | if (has_search_button) numbrowseoptions += 1;
|
---|
930 | disp.setmacro ("numbrowseoptions", "help", numbrowseoptions);
|
---|
931 |
|
---|
932 | ResultDocInfo_tarray::iterator here = response.docInfo.begin();
|
---|
933 | ResultDocInfo_tarray::iterator end = response.docInfo.end();
|
---|
934 |
|
---|
935 | text_t shorttext;
|
---|
936 | text_t longtext;
|
---|
937 | if (has_search_button) {
|
---|
938 | shorttext = "<ul><li>_textSearchshort_\n";
|
---|
939 | longtext = "_textSearchlong_";
|
---|
940 | }
|
---|
941 |
|
---|
942 | // ********************************
|
---|
943 | int classifiernumber = 0;
|
---|
944 | bool collage = false;
|
---|
945 |
|
---|
946 | while (here != end) {
|
---|
947 |
|
---|
948 | ++classifiernumber;
|
---|
949 | text_t childtype = (*here).metadata["childtype"].values[0];
|
---|
950 | if (childtype == "Collage" && arg_p == "about") {
|
---|
951 | // get the classifier number
|
---|
952 | disp.setmacro ("classifier", "about", classifiernumber);
|
---|
953 | disp.setmacro ("aboutCollage", "about", "_collageapplet_");
|
---|
954 | collage = true;
|
---|
955 | }
|
---|
956 | ++here;
|
---|
957 | }
|
---|
958 | if (! collage)
|
---|
959 | disp.setmacro ("aboutCollage", "about", "_collageempty_");
|
---|
960 |
|
---|
961 | // ********************************
|
---|
962 |
|
---|
963 | here = response.docInfo.begin();
|
---|
964 |
|
---|
965 | while (here != end) {
|
---|
966 |
|
---|
967 | text_t title = (*here).metadata["Title"].values[0];
|
---|
968 |
|
---|
969 | text_t stext, ltext;
|
---|
970 | disp.expandstring ("help", "_text" + title + "short_", stext);
|
---|
971 | if (stext == ("_text" + title + "short_")) {
|
---|
972 | shorttext += "<li>_help:textdefaultshorttext_";
|
---|
973 | longtext += "_help:textdefaultlongtext_";
|
---|
974 | } else {
|
---|
975 | shorttext += "<li>_help:text" + title + "short_";
|
---|
976 | longtext += "_help:text" + title + "long_";
|
---|
977 | }
|
---|
978 |
|
---|
979 | ++here;
|
---|
980 | }
|
---|
981 | shorttext += "</ul>\n";
|
---|
982 | if (response.docInfo.size() > 1) disp.setmacro ("textbrowseoptions", "help", shorttext + longtext);
|
---|
983 | else disp.setmacro ("textbrowseoptions", "help", longtext);
|
---|
984 |
|
---|
985 | if (arg_p == "about") {
|
---|
986 |
|
---|
987 | // _textsubcollections_
|
---|
988 | if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
|
---|
989 | text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
|
---|
990 | text_tarray::const_iterator here = cinfo->ccsCols.begin();
|
---|
991 | text_tarray::const_iterator end = cinfo->ccsCols.end();
|
---|
992 | bool first = true;
|
---|
993 | int count = 0;
|
---|
994 | while (here != end) {
|
---|
995 | if (*here == arg_c) {
|
---|
996 | if (!first) textsubcollections += "<br>";
|
---|
997 | textsubcollections += "\n" + cinfo->collectionmeta["collectionname"] + "\n";
|
---|
998 | } else {
|
---|
999 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
|
---|
1000 | if (this_cinfo == NULL) {++here; continue;}
|
---|
1001 | if (!first) textsubcollections += "<br>";
|
---|
1002 | textsubcollections += "\n" + this_cinfo->collectionmeta["collectionname"] + "\n";
|
---|
1003 | }
|
---|
1004 | ++count;
|
---|
1005 | first = false;
|
---|
1006 | ++here;
|
---|
1007 | }
|
---|
1008 | textsubcollections += "_textsubcols2_";
|
---|
1009 | if (count > 1) {
|
---|
1010 | disp.setmacro ("textsubcollections", "about", textsubcollections);
|
---|
1011 | }
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | comerror_t err;
|
---|
1015 | bool issearchable = true;
|
---|
1016 | collectproto->is_searchable(args["c"], issearchable, err, logout);
|
---|
1017 | if (err != noError) issearchable = true;
|
---|
1018 | outconvertclass t;
|
---|
1019 | if (!issearchable) {
|
---|
1020 | disp.setmacro ("aboutqueryform", "about", "");
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 | } else if (arg_p == "docs") {
|
---|
1025 |
|
---|
1026 | set_documentation_macro (disp);
|
---|
1027 |
|
---|
1028 | } else if (arg_p == "bsummary" && !arg_c.empty()) {
|
---|
1029 |
|
---|
1030 | set_macro_to_file_contents (disp, "importlog", "bsummary",
|
---|
1031 | filename_cat(gsdlhome, "collect", arg_c, "etc", "import.log"));
|
---|
1032 | set_macro_to_file_contents (disp, "faillog", "bsummary",
|
---|
1033 | filename_cat(gsdlhome, "collect", arg_c, "etc", "fail.log"));
|
---|
1034 | }
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
|
---|
1038 | browsermapclass * /*browsers*/, displayclass &disp,
|
---|
1039 | outconvertclass &outconvert, ostream &textout,
|
---|
1040 | ostream &/*logout*/) {
|
---|
1041 |
|
---|
1042 | text_t &arg_p = args["p"];
|
---|
1043 |
|
---|
1044 | textout << outconvert << disp << ("_" + arg_p + ":header_\n")
|
---|
1045 | << ("_" + arg_p + ":content_\n")
|
---|
1046 | << ("_" + arg_p + ":footer_\n");
|
---|
1047 |
|
---|
1048 | return true;
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | void pageaction::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
1052 | if ((key == "status") && (cfgline.size() == 1) &&
|
---|
1053 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
1054 | status_disabled = false;
|
---|
1055 | } else if ((key == "collector") && (cfgline.size() == 1) &&
|
---|
1056 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
1057 | collector_disabled = false;
|
---|
1058 | } else if ((key == "translator") && (cfgline.size() == 1) &&
|
---|
1059 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
1060 | translator_disabled = false;
|
---|
1061 | } else if ((key == "gliapplet") && (cfgline.size() == 1) &&
|
---|
1062 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
1063 | gliapplet_disabled = false;
|
---|
1064 | }
|
---|
1065 | else {
|
---|
1066 | // call the parent class to deal with the things which
|
---|
1067 | // are not dealt with here
|
---|
1068 | action::configure (key, cfgline);
|
---|
1069 | }
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 |
|
---|
1073 |
|
---|
1074 |
|
---|
1075 |
|
---|
1076 |
|
---|
1077 |
|
---|
1078 |
|
---|
1079 |
|
---|
1080 |
|
---|