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

Last change on this file since 13017 was 12865, checked in by kjdon, 18 years ago

need to call set_stem_index_args to set up the ss, ks and afs args

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