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

Last change on this file since 4770 was 4770, checked in by kjdon, 21 years ago

removed some stuff which wasn't supposed to be there, and made the default search type (ie whether the search page first shows plain or form) the first one in the list of search types

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 26.4 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
529 // if page is "help"
530 // _textbrowseoptions_ the 'how to find information' text in the about and help pages
531
532 // _numbrowseoptions_ the number of browsing options
533
534 // _topicreadingdocs_ this section of the help text differs depending on what type of
535 // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
536 // _texthelpreadingdocs_
537
538 // if page is "home" or "homehelp"
539 // _textgocollector_ set to "" if collector is disabled in main.cfg
540 // _textgoadmin_ set to "" if status is disabled in main.cfg
541 // _textgotranslator_ set to "" if translator is disabled in main.cfg
542
543
544 // if page is "homehelp"
545 // _collectionlist_ list of available collections to be displayed on the homehelp page
546
547
548 // if page is "docs"
549 // _documentation_ links to PDF documents if they're available
550
551
552 // if page is "bsummary"
553 // _importlog_ set to contents of collections import.log file
554 // _faillog_ set to contents of collections fail.log file
555
556
557 if (recpt == NULL) {
558 logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
559 << " information about any receptionists. The method set_receptionist was\n"
560 << " probably not called from the module which instantiated this action.\n";
561 return;
562 }
563
564 text_t &arg_p = args["p"];
565 text_t &arg_c = args["c"];
566 ColInfoResponse_t *cinfo = NULL;
567
568 recptproto* collectproto = protos->getrecptproto (arg_c, logout);
569 if (collectproto != NULL) {
570 cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
571
572 disp.setmacro ("numdocs", "Global", cinfo->numDocs);
573 unsigned long current_time = time(NULL);
574 unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
575 disp.setmacro ("builddate", "Global", builddate);
576
577 text_t numbytes;
578 if ((cinfo->numBytes/(1024*1024)) > 1) {
579 numbytes = (text_t)(cinfo->numBytes/(1024*1024)) + " Mb";
580 } else if ((cinfo->numBytes/1024) > 1) {
581 numbytes = (text_t)(cinfo->numBytes/1024) + " kb";
582 } else {
583 numbytes = (text_t)cinfo->numBytes + " bytes";
584 }
585 disp.setmacro("numbytes", "Global", numbytes);
586 }
587
588 //setting _queryformcontent_ so that the query interface is consistent.
589 //also adding usability button if necessary
590 if(arg_p == "about"){
591 if (cinfo != NULL) {
592 text_tmap::iterator check = cinfo->format.find("QueryInterface");
593 if(check != cinfo->format.end()){
594 if((*check).second=="DateSearch"){
595 text_t current = "_basicqueryform_ _datesearch_";
596
597 disp.setmacro("queryformcontent","query",current);
598 }
599 }
600 check = cinfo->format.find("Usability");
601 if(check != cinfo->format.end()){
602 disp.setmacro("usability","Global","_imageusab_");
603 disp.setmacro("usabinterface","Global",("_usab"+(*check).second+"_"));
604 disp.setmacro("usabilityscript", "Global", "_usabshowscript_");
605 }
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 } else if (arg_p == "docs") {
748
749 set_documentation_macro (disp);
750
751 } else if (arg_p == "bsummary" && !arg_c.empty()) {
752
753 set_macro_to_file_contents (disp, "importlog", "bsummary",
754 filename_cat(gsdlhome, "collect", arg_c, "etc", "import.log"));
755 set_macro_to_file_contents (disp, "faillog", "bsummary",
756 filename_cat(gsdlhome, "collect", arg_c, "etc", "fail.log"));
757 }
758}
759
760bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
761 browsermapclass * /*browsers*/, displayclass &disp,
762 outconvertclass &outconvert, ostream &textout,
763 ostream &/*logout*/) {
764
765 text_t &arg_p = args["p"];
766
767 textout << outconvert << disp << ("_" + arg_p + ":header_\n")
768 << ("_" + arg_p + ":content_\n")
769 << ("_" + arg_p + ":footer_\n");
770
771 return true;
772}
773
774void pageaction::configure (const text_t &key, const text_tarray &cfgline) {
775 if ((key == "status") && (cfgline.size() == 1) &&
776 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
777 status_disabled = false;
778 } else if ((key == "collector") && (cfgline.size() == 1) &&
779 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
780 collector_disabled = false;
781 } else if ((key == "translator") && (cfgline.size() == 1) &&
782 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
783 translator_disabled = false;
784 } else {
785 // call the parent class to deal with the things which
786 // are not dealt with here
787 action::configure (key, cfgline);
788 }
789}
790
791
792
793
794
795
796
797
798
799
Note: See TracBrowser for help on using the repository browser.