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

Last change on this file since 3128 was 3128, checked in by sjboddie, 22 years ago

Added a hack to reset language to English if trying to view the home page
in a language other than English or French

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