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

Last change on this file since 4774 was 4774, checked in by sjboddie, 21 years ago

No longer show search page (or search form on "about" page) if a collection
doesn't have at least one searchable index. Note that this change includes
the addition of an is_searchable() function to the protocol.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 26.8 KB
Line 
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#include "OIDtools.h"
27#include "pageaction.h"
28#include "receptionist.h"
29#include "fileutil.h"
30#include "gsdltools.h"
31#include <time.h>
32
33pageaction::pageaction () {
34
35 status_disabled = true;
36 collector_disabled = true;
37 translator_disabled = true;
38 recpt = NULL;
39
40 // this action uses cgi variables "a", "p", and "hp"
41 cgiarginfo arg_ainfo;
42 arg_ainfo.shortname = "a";
43 arg_ainfo.longname = "action";
44 arg_ainfo.multiplechar = true;
45 arg_ainfo.defaultstatus = cgiarginfo::weak;
46 arg_ainfo.argdefault = "p";
47 arg_ainfo.savedarginfo = cgiarginfo::must;
48 argsinfo.addarginfo (NULL, arg_ainfo);
49
50 arg_ainfo.shortname = "p";
51 arg_ainfo.longname = "page";
52 arg_ainfo.multiplechar = true;
53 arg_ainfo.defaultstatus = cgiarginfo::weak;
54 arg_ainfo.argdefault = "home";
55 arg_ainfo.savedarginfo = cgiarginfo::must;
56 argsinfo.addarginfo (NULL, arg_ainfo);
57
58 arg_ainfo.shortname = "hp";
59 arg_ainfo.longname = "html page";
60 arg_ainfo.multiplechar = true;
61 arg_ainfo.defaultstatus = cgiarginfo::weak;
62 arg_ainfo.argdefault = "";
63 arg_ainfo.savedarginfo = cgiarginfo::mustnot;
64 argsinfo.addarginfo (NULL, arg_ainfo);
65
66 arg_ainfo.shortname = "bp";
67 arg_ainfo.longname = "set preferences button";
68 arg_ainfo.multiplechar = true;
69 arg_ainfo.defaultstatus = cgiarginfo::weak;
70 arg_ainfo.argdefault = "";
71 arg_ainfo.savedarginfo = cgiarginfo::mustnot;
72 argsinfo.addarginfo (NULL, arg_ainfo);
73
74 // the "u" argument will disable the search facility, remove links to the
75 // home and preferences pages, and disable the DocumentButton buttons
76 // (for use when generating static html versions of collections)
77 arg_ainfo.shortname = "u";
78 arg_ainfo.longname = "static page";
79 arg_ainfo.multiplechar = false;
80 arg_ainfo.defaultstatus = cgiarginfo::weak;
81 arg_ainfo.argdefault = "0";
82 arg_ainfo.savedarginfo = cgiarginfo::mustnot;
83 argsinfo.addarginfo (NULL, arg_ainfo);
84}
85
86pageaction::~pageaction () {
87}
88
89bool pageaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &args,
90 recptprotolistclass * /*protos*/, ostream &/*logout*/) {
91
92 if (args["p"] == "preferences" && !args["bp"].empty()) {
93 if (args["hd"] != "0") args["hd"] = args["hdn"];
94 }
95
96 return true;
97}
98
99void pageaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
100 response_t &response,text_t &response_data,
101 ostream &/*logout*/) {
102 response = content;
103 response_data = "text/html";
104}
105
106void pageaction::set_homeextra_macro (displayclass &disp, recptprotolistclass *protos,
107 cgiargsclass &args, ostream &logout) {
108 text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
109 bool found_valid_col = false;
110
111 recptprotolistclass::iterator rprotolist_here = protos->begin();
112 recptprotolistclass::iterator rprotolist_end = protos->end();
113 while (rprotolist_here != rprotolist_end) {
114 if ((*rprotolist_here).p != NULL) {
115
116 text_tarray collist;
117 comerror_t err;
118 (*rprotolist_here).p->get_collection_list (collist, err, logout);
119 if (err == noError) {
120 text_tarray::iterator collist_here = collist.begin();
121 text_tarray::iterator collist_end = collist.end();
122
123 int count = 0;
124 bool first = true;
125 while (collist_here != collist_end) {
126 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
127
128 if (cinfo != NULL) {
129 if (cinfo->isPublic && (cinfo->buildDate > 0)) {
130
131 text_t coll_type = "&ct=";
132 if (cinfo->buildType == "mgpp") {
133 coll_type += "1&qto=";
134
135 // now we also want to check search types to set the qto arg
136 if (cinfo->searchTypes.size() == 0) {
137 coll_type += "3"; // default to 3 (= both)
138 } else {
139 unsigned int search_types = 0;
140 text_tarray::const_iterator type_here = cinfo->searchTypes.begin();
141 text_tarray::const_iterator type_end = cinfo->searchTypes.end();
142
143 while (type_here != type_end) {
144 if (*type_here == "form") {
145 search_types |= 2;
146 } else if (*type_here == "plain") {
147 search_types |= 1;
148 }
149 type_here ++;
150 }
151 coll_type += search_types;
152 if (search_types == 3) {
153 // both were specified, now need to look at the order to see which is the default
154 type_here = cinfo->searchTypes.begin();
155 if (*type_here == "form") {
156 coll_type += "&qt=1"; // set the default to form
157 }
158 }
159
160 }
161 }
162 else {
163 coll_type += "0";
164 }
165
166 found_valid_col = true;
167 FilterResponse_t response;
168 text_tset metadata;
169 metadata.insert ("collectionname");
170 metadata.insert ("iconcollection");
171 metadata.insert ("iconcollectionsmall");
172 text_t collectionname = *collist_here;
173 text_t alt = collectionname;
174
175 if (get_info ("collection", *collist_here, metadata, false,
176 (*rprotolist_here).p, response, logout)) {
177 if (!response.docInfo[0].metadata["collectionname"].values[0].empty())
178 alt = response.docInfo[0].metadata["collectionname"].values[0];
179
180 text_t iconurl;
181 iconurl.clear();
182
183 if (!response.docInfo[0].metadata["iconcollectionsmall"].values[0].empty()) {
184 iconurl = response.docInfo[0].metadata["iconcollectionsmall"].values[0];
185 } else if (!response.docInfo[0].metadata["iconcollection"].values[0].empty()) {
186 iconurl = response.docInfo[0].metadata["iconcollection"].values[0];
187 }
188
189 if (!iconurl.empty())
190 {
191 // check to see URL is local to colserver
192 text_t::iterator iconurl_head = iconurl.begin();
193 text_t iconhead = substr(iconurl_head,iconurl_head+16);
194 if (iconhead=="_httpcollection_")
195 {
196 // local and using _httpcollection_
197 text_t icontail = substr(iconurl_head+16,iconurl.end());
198 iconurl = "http://" + cinfo->httpdomain
199 + cinfo->httpprefix + "/collect/"
200 + *collist_here + "/" + icontail;
201 }
202 else if (iconurl[0]=='/')
203 {
204 // local but with full path
205 iconurl = "http://" + cinfo->httpdomain + iconurl;
206 }
207
208 collectionname
209 = "<img width=150 border=1 src=\"" + iconurl + "\" alt=\"" + alt + "\">";
210 }
211 else
212 {
213 collectionname = alt;
214 }
215
216 }
217 if ((count%3 == 0) && (!first))
218 homeextra += "</tr><tr valign=top>\n";
219
220 comerror_t err;
221 text_t optsite = "";
222 text_t site_name = (*rprotolist_here).p->get_site_name (err);
223 if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
224
225 text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type;
226 link += "&l=" + args["l"] + "&w=" + args["w"] + "\">";
227
228 if (!cinfo->receptionist.empty())
229 link = "<a href=\"" + cinfo->receptionist + "\">";
230
231 homeextra += "<td>" + link + collectionname + "</a></td>\n";
232
233 count ++;
234 first = false;
235 }
236 }
237 collist_here ++;
238 }
239
240 for (; count%3 != 0; count ++) homeextra += "<td></td>\n";
241 }
242 }
243 homeextra += "</td></tr>\n<tr>\n";
244 rprotolist_here ++;
245 }
246
247 if (!found_valid_col) {
248 homeextra += "<td>No valid (i.e. built and public) collections are available</td>\n";
249 }
250 homeextra += "</tr></table></center>\n";
251 disp.setmacro ("homeextra", "home", homeextra);
252}
253
254void pageaction::set_collectionlist_macro (displayclass &disp, recptprotolistclass *protos,
255 ostream &logout) {
256
257 text_t collectionlist;
258 int count = 0;
259
260 recptprotolistclass::iterator rprotolist_here = protos->begin();
261 recptprotolistclass::iterator rprotolist_end = protos->end();
262 while (rprotolist_here != rprotolist_end) {
263 if ((*rprotolist_here).p != NULL) {
264
265 text_tarray collist;
266 comerror_t err;
267 (*rprotolist_here).p->get_collection_list (collist, err, logout);
268 if (err == noError) {
269 text_tarray::iterator collist_here = collist.begin();
270 text_tarray::iterator collist_end = collist.end();
271
272 while (collist_here != collist_end) {
273 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
274
275 if (cinfo != NULL) {
276 if (cinfo->isPublic && (cinfo->buildDate > 0)) {
277
278 count ++;
279
280 text_t coll_type = "&ct=";
281 if (cinfo->buildType == "mgpp") {
282 coll_type += "1&qto=";
283
284 // now we also want to check search types to set the qto arg
285 if (cinfo->searchTypes.size() == 0) {
286 coll_type += "3"; // default to 2 (= both)
287 } else {
288 int search_types = 0;
289 text_tarray::const_iterator type_here = cinfo->searchTypes.begin();
290 text_tarray::const_iterator type_end = cinfo->searchTypes.end();
291
292 while (type_here != type_end) {
293 if (*type_here == "form") {
294 search_types |= 0x10;
295 } else if (*type_here == "plain") {
296 search_types |= 0x01;
297 }
298 type_here ++;
299 }
300 coll_type += search_types;
301
302 if (search_types == 3) {
303 // both were specified, now need to look at the order to see which is the default
304 type_here = cinfo->searchTypes.begin();
305 if (*type_here == "form") {
306 coll_type += "&qt=1"; // set the default to form
307 }
308 }
309 }
310 }
311 else {
312 coll_type += "0";
313 }
314 FilterResponse_t response;
315 text_tset metadata;
316 metadata.insert ("collectionname");
317 text_t collectionname = *collist_here;
318
319 if (get_info ("collection", *collist_here, metadata, false,
320 (*rprotolist_here).p, response, logout)) {
321 if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
322 collectionname = response.docInfo[0].metadata["collectionname"].values[0];
323 }
324 }
325
326 comerror_t err;
327 text_t optsite = "";
328 text_t site_name = (*rprotolist_here).p->get_site_name (err);
329 if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
330
331 text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type+"\">";
332
333 if (!cinfo->receptionist.empty())
334 link = "<a href=\"" + cinfo->receptionist + "\">";
335
336 collectionlist += "<li>" + link + collectionname + "</a>\n";
337 }
338 }
339 collist_here ++;
340 }
341 }
342 }
343 rprotolist_here ++;
344 }
345
346 if (count == 1) {
347 collectionlist = "<p>_text1coll_\n<ul>" +
348 collectionlist + "</ul>\n";
349 } else if (count > 1) {
350 collectionlist = "<p>_textmorecolls_(" + text_t(count) +
351 ")\n<ul>" + collectionlist + "</ul>\n";
352 }
353
354 disp.setmacro ("collectionlist", "homehelp", collectionlist);
355}
356
357void pageaction::set_documentation_macro (displayclass &disp) {
358
359 text_t documentation;
360 text_t docsdir = filename_cat(gsdlhome, "docs");
361
362 if (file_exists(filename_cat(docsdir, "User.pdf"))) {
363 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/User.pdf\">_iconpdf_"
364 "</a></td><td>_textuserguide_</td></tr>";
365 }
366
367 if (file_exists(filename_cat(docsdir, "Install.pdf"))) {
368 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Install.pdf\">_iconpdf_"
369 "</a></td><td>_textinstallerguide_</td></tr>";
370 }
371
372 if (file_exists(filename_cat(docsdir, "Develop.pdf"))) {
373 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Develop.pdf\">_iconpdf_"
374 "</a></td><td>_textdeveloperguide_</td></tr>";
375 }
376
377 if (file_exists(filename_cat(docsdir, "Paper.pdf"))) {
378 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Paper.pdf\">_iconpdf_"
379 "</a></td><td>_textpaperguide_</td></tr>";
380 }
381
382 if (!documentation.empty()) {
383 disp.setmacro("documentation", "docs", "<p>\n<table border=0>\n" + documentation + "\n</table>\n");
384 }
385}
386
387void pageaction::set_macro_to_file_contents (displayclass &disp, const text_t &macroname,
388 const text_t &packagename, const text_t &filename) {
389
390 text_t filecontent;
391 char *filenamec = filename.getcstr();
392 ifstream file_in (filenamec);
393 delete filenamec;
394 if (file_in) {
395 char c;
396 file_in.get(c);
397 while (!file_in.eof ()) {
398 if (c == '\n') filecontent += "<br>";
399 filecontent.push_back(c);
400 file_in.get(c);
401 }
402 file_in.close();
403 }
404 disp.setmacro (macroname, packagename, dm_safe(filecontent));
405}
406
407void pageaction::set_language_encoding_macros(displayclass &disp, cgiargsclass &args,
408 recptprotolistclass *protos, ColInfoResponse_t *cinfo,
409 ostream &logout) {
410 // _languageoption_
411 // Create the "interface language" selection box for the preferences
412 // pages. You can use something like "format PreferenceLanguages
413 // en|fr|zn" from within a collect.cfg file to use only a subset of
414 // the available languages for any given collection (for
415 // collection-specific preferences pages). This facility is kind of
416 // ugly though and should be replaced by something better when the
417 // configuration files are tidied up (as should all the other
418 // "format Preference..." options).
419 text_t &arg_l = args["l"];
420 const recptconf &configinfo = recpt->get_configinfo();
421 // put languages in another map to sort them by longname
422 text_tmap languages;
423 languageinfo_tmap::const_iterator thislang = configinfo.languages.begin();
424 languageinfo_tmap::const_iterator endlang = configinfo.languages.end();
425 while (thislang != endlang) {
426 languages[(*thislang).second.longname] = (*thislang).first;
427 thislang++;
428 }
429 text_tmap::iterator tlang = languages.begin();
430 text_tmap::iterator elang = languages.end();
431
432 text_t languageoption;
433 bool collection_specific = false;
434
435 if (cinfo != NULL) {
436 text_tmap::const_iterator it = cinfo->format.find ("PreferenceLanguages");
437 if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
438 collection_specific = true;
439 text_tset pref_langs;
440 splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
441 if (pref_langs.size() > 1) {
442 while (tlang != elang) {
443 if (pref_langs.find((*tlang).second) != pref_langs.end()) {
444 languageoption += "<option value=\"" + (*tlang).second + "\"";
445 if ((*tlang).second == arg_l) languageoption += " selected";
446 languageoption += ">" + (*tlang).first + "\n";
447 }
448 tlang ++;
449 }
450 }
451 }
452 }
453
454 if (!collection_specific) {
455 while (tlang != elang) {
456 languageoption += "<option value=\"" + (*tlang).second + "\"";
457 if ((*tlang).second == arg_l) languageoption += " selected";
458 languageoption += ">" + (*tlang).first + "\n";
459 tlang ++;
460 }
461 }
462
463 if (!languageoption.empty()) {
464 languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption;
465 languageoption += "</select>\n";
466 disp.setmacro ("languageoption", args["p"], languageoption);
467 }
468
469 // _encodingoption_
470 // create the "encoding" selection box for the preferences page
471 if (configinfo.encodings.size() > 1) {
472 text_t &arg_w = args["w"];
473 text_t encodingoption;
474 text_tmap::const_iterator thisenc = configinfo.encodings.begin();
475 text_tmap::const_iterator endenc = configinfo.encodings.end();
476 while (thisenc != endenc) {
477 encodingoption += "<option value=\"" + (*thisenc).second + "\"";
478 if ((*thisenc).second == arg_w) encodingoption += " selected";
479 encodingoption += ">" + (*thisenc).first + "\n";
480 thisenc ++;
481 }
482
483 encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption;
484 encodingoption += "</select>\n";
485 disp.setmacro ("encodingoption", args["p"], encodingoption);
486 }
487}
488
489void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
490 recptprotolistclass *protos, ostream &logout) {
491
492 // define_internal_macros sets the following macros:
493
494 // _numdocs_ the number of documents in the collection
495
496 // _builddate_ the date last built
497
498 // if page is "home"
499 // _homeextra_ this is the list of available collections and collection info
500 // to be displayed on the home page
501
502
503 // if page is "preferences"
504 // _collectionoption_ collections to search/browse (if cross-collection-searching is on)
505
506 // _htmloptions_ set to _htmloptionson_ if DocumentUseHTML is set
507
508 // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set
509
510
511 // if page is "preferences" or "homepref"
512 // _languageoption_ interface languages to select from (dependant on PreferenceLanguages)
513
514 // _encodingoption_ encodings to select from
515
516
517 // if page is "about"
518 // _textsubcollections_ the text on which subcollections make up the collection (if
519 // cross-collection searching is being used
520
521 // _textbrowseoptions_ the 'how to find information' text in the about and help pages
522
523 // _numbrowseoptions_ the number of browsing options
524
525 // _prefschanged_ will be set to _textprefschanged_ if the "set preferences" button
526 // was pressed
527
528 // _aboutqueryform_ will be set to "" if the collection isn't searchable
529
530 // if page is "help"
531 // _textbrowseoptions_ the 'how to find information' text in the about and help pages
532
533 // _numbrowseoptions_ the number of browsing options
534
535 // _topicreadingdocs_ this section of the help text differs depending on what type of
536 // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
537 // _texthelpreadingdocs_
538
539 // if page is "home" or "homehelp"
540 // _textgocollector_ set to "" if collector is disabled in main.cfg
541 // _textgoadmin_ set to "" if status is disabled in main.cfg
542 // _textgotranslator_ set to "" if translator is disabled in main.cfg
543
544
545 // if page is "homehelp"
546 // _collectionlist_ list of available collections to be displayed on the homehelp page
547
548
549 // if page is "docs"
550 // _documentation_ links to PDF documents if they're available
551
552
553 // if page is "bsummary"
554 // _importlog_ set to contents of collections import.log file
555 // _faillog_ set to contents of collections fail.log file
556
557
558 if (recpt == NULL) {
559 logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
560 << " information about any receptionists. The method set_receptionist was\n"
561 << " probably not called from the module which instantiated this action.\n";
562 return;
563 }
564
565 text_t &arg_p = args["p"];
566 text_t &arg_c = args["c"];
567 ColInfoResponse_t *cinfo = NULL;
568
569 recptproto* collectproto = protos->getrecptproto (arg_c, logout);
570 if (collectproto != NULL) {
571 cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
572
573 disp.setmacro ("numdocs", "Global", cinfo->numDocs);
574 unsigned long current_time = time(NULL);
575 unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
576 disp.setmacro ("builddate", "Global", builddate);
577
578 text_t numbytes;
579 if ((cinfo->numBytes/(1024*1024)) > 1) {
580 numbytes = (text_t)(cinfo->numBytes/(1024*1024)) + " Mb";
581 } else if ((cinfo->numBytes/1024) > 1) {
582 numbytes = (text_t)(cinfo->numBytes/1024) + " kb";
583 } else {
584 numbytes = (text_t)cinfo->numBytes + " bytes";
585 }
586 disp.setmacro("numbytes", "Global", numbytes);
587 }
588
589 //setting _queryformcontent_ so that the query interface is consistent.
590 //also adding usability button if necessary
591 if(arg_p == "about"){
592 if (cinfo != NULL) {
593 text_tmap::iterator check = cinfo->format.find("QueryInterface");
594 if(check != cinfo->format.end()){
595 if((*check).second=="DateSearch"){
596 text_t current = "_basicqueryform_ _datesearch_";
597
598 disp.setmacro("queryformcontent","query",current);
599 }
600 }
601 check = cinfo->format.find("Usability");
602 if(check != cinfo->format.end()){
603 disp.setmacro("usability","Global","_imageusab_");
604 disp.setmacro("usabinterface","Global",("_usab"+(*check).second+"_"));
605 disp.setmacro("usabilityscript", "Global", "_usabshowscript_");
606 }
607 }
608 }
609
610 if (arg_p == "home" || arg_p == "homehelp") {
611 if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
612 if (collector_disabled) disp.setmacro ("textgocollector", "home", "");
613 if (translator_disabled) disp.setmacro ("textgotranslator", "home", "");
614
615 if (arg_p == "home") {
616 set_homeextra_macro (disp, protos, args, logout);
617 } else if (arg_p == "homehelp") {
618 set_collectionlist_macro (disp, protos, logout);
619 }
620
621 } else if (arg_p == "homepref") {
622
623 // set _languageoption_ and _encodingoption_
624 set_language_encoding_macros(disp, args, protos, cinfo, logout);
625
626 } else if (arg_p == "preferences") {
627 if (collectproto == NULL) {return;}
628
629 // set _languageoption_ and _encodingoption_
630 set_language_encoding_macros(disp, args, protos, cinfo, logout);
631
632 // _collectionoption_
633
634 if ((args["ccs"] == "1") && (cinfo->ccsCols.size() > 1)) {
635 text_t collectionoption = "_textcollectionoption_";
636 text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
637 text_tarray::const_iterator col_end = cinfo->ccsCols.end();
638 int count = 0;
639 while (col_here != col_end) {
640 text_t colname;
641 if (*col_here == arg_c) {
642 colname = cinfo->collectionmeta["collectionname"];
643 } else {
644 ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
645 if (this_cinfo == NULL) {col_here ++; continue;}
646 colname = this_cinfo->collectionmeta["collectionname"];
647 }
648
649 count ++;
650 collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
651 *col_here + "\" onClick=\"updatecc(\'" + *col_here + "\');\"> " +
652 colname + "<br>\n";
653 col_here ++;
654 }
655
656 if (count > 1)
657 disp.setmacro ("collectionoption", "preferences", collectionoption);
658 }
659
660 // _htmloptions_
661
662 text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
663 if ((it != cinfo->format.end()) && ((*it).second == "true")) {
664 disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
665
666
667 // _PreferenceDocsFromWeb_
668
669 it = cinfo->format.find ("PreferenceDocsFromWeb");
670 if ((it == cinfo->format.end()) || ((*it).second == "true"))
671 disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
672 }
673
674 // _prefschanged_
675 if (!args["bp"].empty()) {
676 disp.setmacro ("prefschanged", "preferences", "_textprefschanged_");
677 }
678
679 } else if (arg_p == "about" || arg_p == "help") {
680 if (collectproto == NULL) return;
681
682 // _textbrowseoptions_ and _numbrowseoptions_
683
684 FilterResponse_t response;
685 text_tset metadata;
686 metadata.insert ("Title");
687 bool getParents = false;
688 get_children ("", args["c"], metadata, getParents, collectproto, response, logout);
689
690 disp.setmacro ("numbrowseoptions", "help", response.docInfo.size()+1);
691
692 ResultDocInfo_tarray::iterator here = response.docInfo.begin();
693 ResultDocInfo_tarray::iterator end = response.docInfo.end();
694
695 // we're assuming that we've always got a search button
696 text_t shorttext = "<ul><li>_textSearchshort_\n";
697 text_t longtext = "_textSearchlong_";
698
699 while (here != end) {
700 text_t title = (*here).metadata["Title"].values[0];
701
702 text_t stext, ltext;
703 disp.expandstring ("help", "_text" + title + "short_", stext);
704 if (stext == ("_text" + title + "short_")) {
705 shorttext += "<li>_help:textdefaultshorttext_";
706 longtext += "_help:textdefaultlongtext_";
707 } else {
708 shorttext += "<li>_help:text" + title + "short_";
709 longtext += "_help:text" + title + "long_";
710 }
711
712 here ++;
713 }
714 shorttext += "</ul>\n";
715 if (response.docInfo.size() > 1) disp.setmacro ("textbrowseoptions", "help", shorttext + longtext);
716 else disp.setmacro ("textbrowseoptions", "help", longtext);
717
718 if (arg_p == "about") {
719
720 // _textsubcollections_
721 if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
722 text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
723 text_tarray::const_iterator here = cinfo->ccsCols.begin();
724 text_tarray::const_iterator end = cinfo->ccsCols.end();
725 bool first = true;
726 int count = 0;
727 while (here != end) {
728 if (*here == arg_c) {
729 if (!first) textsubcollections += "<br>";
730 textsubcollections += "\n" + cinfo->collectionmeta["collectionname"] + "\n";
731 } else {
732 ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
733 if (this_cinfo == NULL) {here ++; continue;}
734 if (!first) textsubcollections += "<br>";
735 textsubcollections += "\n" + this_cinfo->collectionmeta["collectionname"] + "\n";
736 }
737 count ++;
738 first = false;
739 here ++;
740 }
741 textsubcollections += "_textsubcols2_";
742 if (count > 1) {
743 disp.setmacro ("textsubcollections", "about", textsubcollections);
744 }
745 }
746
747 comerror_t err;
748 bool issearchable = true;
749 collectproto->is_searchable(args["c"], issearchable, err, logout);
750 if (err != noError) issearchable = true;
751 outconvertclass t;
752 if (!issearchable) {
753 disp.setmacro ("aboutqueryform", "about", "");
754 }
755 }
756
757 } else if (arg_p == "docs") {
758
759 set_documentation_macro (disp);
760
761 } else if (arg_p == "bsummary" && !arg_c.empty()) {
762
763 set_macro_to_file_contents (disp, "importlog", "bsummary",
764 filename_cat(gsdlhome, "collect", arg_c, "etc", "import.log"));
765 set_macro_to_file_contents (disp, "faillog", "bsummary",
766 filename_cat(gsdlhome, "collect", arg_c, "etc", "fail.log"));
767 }
768}
769
770bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
771 browsermapclass * /*browsers*/, displayclass &disp,
772 outconvertclass &outconvert, ostream &textout,
773 ostream &/*logout*/) {
774
775 text_t &arg_p = args["p"];
776
777 textout << outconvert << disp << ("_" + arg_p + ":header_\n")
778 << ("_" + arg_p + ":content_\n")
779 << ("_" + arg_p + ":footer_\n");
780
781 return true;
782}
783
784void pageaction::configure (const text_t &key, const text_tarray &cfgline) {
785 if ((key == "status") && (cfgline.size() == 1) &&
786 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
787 status_disabled = false;
788 } else if ((key == "collector") && (cfgline.size() == 1) &&
789 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
790 collector_disabled = false;
791 } else if ((key == "translator") && (cfgline.size() == 1) &&
792 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
793 translator_disabled = false;
794 } else {
795 // call the parent class to deal with the things which
796 // are not dealt with here
797 action::configure (key, cfgline);
798 }
799}
800
801
802
803
804
805
806
807
808
809
Note: See TracBrowser for help on using the repository browser.