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

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

in the coll lists on home and home help pages, we are now adding in a qto arg for mgpp collections - this indicates what search options should be available to the end user - plain (qto=1), form (qto=2) or both (qto=3)

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