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

Last change on this file since 3774 was 3774, checked in by davidb, 21 years ago

* empty log message *

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