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

Last change on this file since 12082 was 11998, checked in by davidb, 18 years ago

First cut at 'The Depositor' -- Greenstone support for institutional
repositories

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 31.0 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\"><tr valign=\"top\">\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 bool first = true;
246 while (collist_here != collist_end) {
247 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
248
249 if (cinfo != NULL) {
250 if (cinfo->isPublic && (cinfo->buildDate > 0)) {
251
252 found_valid_col = true;
253 text_t collectionname = *collist_here;
254 text_t alt = cinfo->get_collectionmeta("collectionname", args["l"]);
255 if (alt.empty()) {
256 alt = collectionname;
257 }
258
259 // url to image: try iconcollectionsmall, then iconcollection
260 text_t iconurl = cinfo->get_collectionmeta("iconcollectionsmall", args["l"]);
261 if (iconurl.empty()) {
262 iconurl = cinfo->get_collectionmeta("iconcollection", args["l"]);
263 }
264
265 if (!iconurl.empty()) {
266
267 // check to see URL is local to colserver
268 text_t::iterator iconurl_head = iconurl.begin();
269 text_t iconhead = substr(iconurl_head,iconurl_head+16);
270 if (iconhead=="_httpcollection_") {
271
272 // local and using _httpcollection_
273 text_t icontail = substr(iconurl_head+16,iconurl.end());
274 iconurl = "http://" + cinfo->httpdomain
275 + cinfo->httpprefix + "/collect/"
276 + *collist_here + "/" + icontail;
277 }
278 else if (iconurl[0]=='/') {
279
280 // local but with full path
281 iconurl = "http://" + cinfo->httpdomain + iconurl;
282 }
283
284 collectionname
285 = "<img width=\"150\" src=\"" + iconurl + "\" alt=\"" + alt + "\">";
286 } else {
287 collectionname = alt;
288 }
289
290 if ((count%configinfo.HomePageCols == 0) && (!first))
291 homeextra += "</tr><tr valign=\"top\">\n";
292
293 comerror_t err;
294 text_t optsite = g_EmptyText;
295 text_t site_name = (*rprotolist_here).p->get_site_name (err);
296 if (!site_name.empty()) { optsite = "site="+site_name+"&amp;"; }
297
298 text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&amp;p=about&amp;c=" + *collist_here;
299 link += "&amp;l=" + args["l"] + "&amp;w=" + args["w"] + "\">";
300
301 if (!cinfo->receptionist.empty())
302 link = "<a href=\"" + cinfo->receptionist + "\">";
303
304 homeextra += "<td>" + link + collectionname + "</a></td>\n";
305
306 ++count;
307 first = false;
308 }
309 }
310 ++collist_here;
311 }
312
313 for (; count%configinfo.HomePageCols != 0; ++count) homeextra += "<td></td>\n";
314 }
315 }
316 homeextra += "</tr>\n<tr>\n";
317 ++rprotolist_here;
318 }
319
320 if (!found_valid_col) {
321 homeextra += "<td>No valid (i.e. built and public) collections are available</td>\n";
322 }
323 homeextra += "</tr></table>\n";
324 disp.setmacro ("homeextra", "home", homeextra);
325}
326
327void pageaction::set_collectionlist_macro (displayclass &disp,
328 recptprotolistclass *protos,
329 cgiargsclass &args,
330 ostream &logout) {
331
332 text_t collectionlist;
333 int count = 0;
334
335 recptprotolistclass::iterator rprotolist_here = protos->begin();
336 recptprotolistclass::iterator rprotolist_end = protos->end();
337 while (rprotolist_here != rprotolist_end) {
338 if ((*rprotolist_here).p != NULL) {
339
340 text_tarray collist;
341 comerror_t err;
342 (*rprotolist_here).p->get_collection_list (collist, err, logout);
343 if (err == noError) {
344 text_tarray::iterator collist_here = collist.begin();
345 text_tarray::iterator collist_end = collist.end();
346
347 while (collist_here != collist_end) {
348 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
349
350 if (cinfo != NULL) {
351 if (cinfo->isPublic && (cinfo->buildDate > 0)) {
352
353 ++count;
354
355 text_t collectionname = cinfo->get_collectionmeta("collectionname", args["l"]);
356 if (collectionname.empty()) {
357 collectionname = *collist_here;
358 }
359
360 comerror_t err;
361 text_t optsite = g_EmptyText;
362 text_t site_name = (*rprotolist_here).p->get_site_name (err);
363 if (!site_name.empty()) { optsite = "site="+site_name+"&amp;"; }
364
365 text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + "\">";
366
367 if (!cinfo->receptionist.empty())
368 link = "<a href=\"" + cinfo->receptionist + "\">";
369
370 collectionlist += "<li>" + link + collectionname + "</a>\n";
371 }
372 }
373 ++collist_here;
374 }
375 }
376 }
377 ++rprotolist_here;
378 }
379
380 if (count == 1) {
381 collectionlist = "<p>_text1coll_\n<ul>" +
382 collectionlist + "</ul>\n";
383 } else if (count > 1) {
384 collectionlist = "<p>_textmorecolls_(" + text_t(count) +
385 ")\n<ul>" + collectionlist + "</ul>\n";
386 }
387
388 disp.setmacro ("collectionlist", "homehelp", collectionlist);
389}
390
391void pageaction::set_documentation_macro (displayclass &disp) {
392
393 text_t documentation;
394 text_t docsdir = filename_cat(gsdlhome, "docs");
395
396 if (file_exists(filename_cat(docsdir, "User.pdf"))) {
397 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/User.pdf\">_iconpdf_"
398 "</a></td><td>_textuserguide_</td></tr>";
399 }
400
401 if (file_exists(filename_cat(docsdir, "Install.pdf"))) {
402 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Install.pdf\">_iconpdf_"
403 "</a></td><td>_textinstallerguide_</td></tr>";
404 }
405
406 if (file_exists(filename_cat(docsdir, "Develop.pdf"))) {
407 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Develop.pdf\">_iconpdf_"
408 "</a></td><td>_textdeveloperguide_</td></tr>";
409 }
410
411 if (file_exists(filename_cat(docsdir, "Paper.pdf"))) {
412 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Paper.pdf\">_iconpdf_"
413 "</a></td><td>_textpaperguide_</td></tr>";
414 }
415
416 if (file_exists(filename_cat(docsdir, "Organize.pdf"))) {
417 documentation += "<tr valign=middle><td><a href=\"_httpdocs_/Organize.pdf\">_iconpdf_"
418 "</a></td><td>_textorganizerguide_</td></tr>";
419 }
420
421 if (!documentation.empty()) {
422 disp.setmacro("documentation", "docs", "<p>\n<table border=0>\n" + documentation + "\n</table>\n");
423 }
424}
425
426void pageaction::set_macro_to_file_contents (displayclass &disp, const text_t &macroname,
427 const text_t &packagename, const text_t &filename) {
428
429 text_t filecontent;
430 char *filenamec = filename.getcstr();
431 ifstream file_in (filenamec);
432 delete []filenamec;
433 if (file_in) {
434 char c;
435 file_in.get(c);
436 while (!file_in.eof ()) {
437 if (c == '\n') filecontent += "<br>";
438 filecontent.push_back(c);
439 file_in.get(c);
440 }
441 file_in.close();
442 }
443 disp.setmacro (macroname, packagename, dm_safe(filecontent));
444}
445
446void pageaction::set_language_encoding_macros(displayclass &disp, cgiargsclass &args,
447 recptprotolistclass *protos, ColInfoResponse_t *cinfo,
448 ostream &logout) {
449 // _languageoption_
450 // Create the "interface language" selection box for the preferences
451 // pages. You can use something like "format PreferenceLanguages
452 // en|fr|zn" from within a collect.cfg file to use only a subset of
453 // the available languages for any given collection (for
454 // collection-specific preferences pages). This facility is kind of
455 // ugly though and should be replaced by something better when the
456 // configuration files are tidied up (as should all the other
457 // "format Preference..." options).
458 text_t &arg_l = args["l"];
459 const recptconf &configinfo = recpt->get_configinfo();
460 // put languages in another map to sort them by longname
461 text_tmap languages;
462 languageinfo_tmap::const_iterator thislang = configinfo.languages.begin();
463 languageinfo_tmap::const_iterator endlang = configinfo.languages.end();
464 while (thislang != endlang) {
465 languages[(*thislang).second.longname] = (*thislang).first;
466 ++thislang;
467 }
468 text_tmap::iterator tlang = languages.begin();
469 text_tmap::iterator elang = languages.end();
470
471 text_t languageoption;
472 bool collection_specific = false;
473
474 if (cinfo != NULL) {
475 text_tmap::const_iterator it = cinfo->format.find ("PreferenceLanguages");
476 if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
477 collection_specific = true;
478 text_tset pref_langs;
479 splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
480 if (pref_langs.size() > 1) {
481 while (tlang != elang) {
482 if (pref_langs.find((*tlang).second) != pref_langs.end()) {
483 languageoption += "<option value=\"" + (*tlang).second + "\"";
484 if ((*tlang).second == arg_l) languageoption += " selected";
485 languageoption += ">" + (*tlang).first + "</option>\n";
486 }
487 ++tlang;
488 }
489 }
490 }
491 }
492
493 if (!collection_specific) {
494 while (tlang != elang) {
495 languageoption += "<option value=\"" + (*tlang).second + "\"";
496 if ((*tlang).second == arg_l) languageoption += " selected";
497 languageoption += ">" + (*tlang).first + "</option>\n";
498 ++tlang;
499 }
500 }
501
502 if (!languageoption.empty()) {
503 languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption;
504 languageoption += "</select>\n";
505 disp.setmacro ("languageoption", args["p"], languageoption);
506 }
507
508 // _encodingoption_
509 // create the "encoding" selection box for the preferences page
510 if (configinfo.encodings.size() > 1) {
511 text_t &arg_w = args["w"];
512 text_t encodingoption;
513 text_tmap::const_iterator thisenc = configinfo.encodings.begin();
514 text_tmap::const_iterator endenc = configinfo.encodings.end();
515 while (thisenc != endenc) {
516 encodingoption += "<option value=\"" + (*thisenc).second + "\"";
517 if ((*thisenc).second == arg_w) encodingoption += " selected";
518 encodingoption += ">" + (*thisenc).first + "</option>\n";
519 ++thisenc;
520 }
521
522 encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption;
523 encodingoption += "</select>\n";
524 disp.setmacro ("encodingoption", args["p"], encodingoption);
525 } else if (configinfo.encodings.size() == 1) {
526 text_t encodingoption;
527 text_tmap::const_iterator thisenc = configinfo.encodings.begin();
528 encodingoption = (*thisenc).first;
529 disp.setmacro ("encodingoption", args["p"], encodingoption);
530 } else { // size == 0. shouldn't really happen, but allow it
531 disp.setmacro ("encodingoption", args["p"], "None");
532 }
533
534}
535
536
537void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
538 recptprotolistclass *protos, ostream &logout) {
539
540 // define_internal_macros sets the following macros:
541
542 // _numdocs_ the number of documents in the collection
543
544 // _builddate_ the date last built
545
546 // if page is "home"
547 // _homeextra_ this is the list of available collections and collection info
548 // to be displayed on the home page
549
550
551 // if page is "preferences"
552 // _collectionoption_ collections to search/browse (if cross-collection-searching is on)
553
554 // _htmloptions_ set to _htmloptionson_ if DocumentUseHTML is set
555
556 // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set
557
558
559 // if page is "preferences" or "homepref"
560 // _languageoption_ interface languages to select from (dependant on PreferenceLanguages)
561
562 // _encodingoption_ encodings to select from
563
564
565 // if page is "about"
566 // _textsubcollections_ the text on which subcollections make up the collection (if
567 // cross-collection searching is being used
568
569 // _textbrowseoptions_ the 'how to find information' text in the about and help pages
570
571 // _numbrowseoptions_ the number of browsing options
572
573 // _prefschanged_ will be set to _textprefschanged_ if the "set preferences" button
574 // was pressed
575
576 // _aboutqueryform_ will be set to "" if the collection isn't searchable
577
578 // if page is "help"
579 // _textbrowseoptions_ the 'how to find information' text in the about and help pages
580
581 // _numbrowseoptions_ the number of browsing options
582
583 // _topicreadingdocs_ this section of the help text differs depending on what type of
584 // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
585 // _texthelpreadingdocs_
586
587 // if page is "home" or "homehelp"
588 // _textgocollector_ set to "" if collector is disabled in main.cfg
589 // _textgodepositor_ set to "" if depositor is disabled in main.cfg
590 // _textgoadmin_ set to "" if status is disabled in main.cfg
591 // _textgotranslator_ set to "" if translator is disabled in main.cfg
592 // _textgogliapplet_ set to "" if gliapplet is disabled in main.cfg
593
594
595 // if page is "homehelp"
596 // _collectionlist_ list of available collections to be displayed on the homehelp page
597
598
599 // if page is "docs"
600 // _documentation_ links to PDF documents if they're available
601
602
603 // if page is "bsummary"
604 // _importlog_ set to contents of collections import.log file
605 // _faillog_ set to contents of collections fail.log file
606
607
608 if (recpt == NULL) {
609 logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
610 << " information about any receptionists. The method set_receptionist was\n"
611 << " probably not called from the module which instantiated this action.\n";
612 return;
613 }
614
615 text_t &arg_p = args["p"];
616 text_t &arg_c = args["c"];
617 ColInfoResponse_t *cinfo = NULL;
618
619 recptproto* collectproto = protos->getrecptproto (arg_c, logout);
620 if (collectproto != NULL) {
621 cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
622
623 disp.setmacro ("numdocs", displayclass::defaultpackage, cinfo->numDocs);
624 unsigned long current_time = time(NULL);
625 unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
626 disp.setmacro ("builddate", displayclass::defaultpackage, builddate);
627
628 text_t numbytes;
629 if ((cinfo->numBytes/(1024*1024)) > 1) {
630 numbytes = (text_t)(cinfo->numBytes/(1024*1024)) + " Mb";
631 } else if ((cinfo->numBytes/1024) > 1) {
632 numbytes = (text_t)(cinfo->numBytes/1024) + " kb";
633 } else {
634 numbytes = (text_t)cinfo->numBytes + " bytes";
635 }
636 disp.setmacro("numbytes", displayclass::defaultpackage, numbytes);
637
638 // set up ct, qt, qto
639 set_query_type_args(cinfo, args);
640
641 }
642
643 //setting _queryformcontent_ so that the query interface is consistent.
644 //also adding usability button if necessary
645 if (arg_p == "about") {
646 if (cinfo == NULL) {
647 disp.setmacro("cvariable", displayclass::defaultpackage, arg_c);
648 disp.setmacro("content", arg_p, "<p>_textbadcollection_<p>");
649 return;
650 }
651 else {
652
653 text_tmap::iterator check = cinfo->format.find("QueryInterface");
654 if(check != cinfo->format.end()){
655 if((*check).second=="DateSearch"){
656 text_t current = "_datesearch_";
657 disp.setmacro("optdatesearch","query",current);
658 }
659 }
660 check = cinfo->format.find("Usability");
661 if(check != cinfo->format.end()){
662 disp.setmacro("usability", displayclass::defaultpackage, "_usablink_");
663 disp.setmacro("usabinterface", displayclass::defaultpackage, ("_usab"+(*check).second+"_"));
664 disp.setmacro("usabilityscript", displayclass::defaultpackage, "_usabshowscript_");
665 }
666 }
667 }
668
669
670 if (arg_p == "home" || arg_p == "homehelp") {
671 if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
672 if (collector_disabled) disp.setmacro ("textgocollector", "home", "");
673 if (depositor_disabled) disp.setmacro ("textgodepositor", "home", "");
674 if (translator_disabled) disp.setmacro ("textgotranslator", "home", "");
675
676 if (arg_p == "home") {
677 homepagestyle (disp, protos, args, logout);
678 } else if (arg_p == "homehelp") {
679 set_collectionlist_macro (disp, protos, args, logout);
680 }
681
682 } else if (arg_p == "gli") {
683 if (gliapplet_disabled) disp.setmacro ("gliapplet", "gli", "");
684
685 } else if (arg_p == "homepref") {
686
687 // set _languageoption_ and _encodingoption_
688 set_language_encoding_macros(disp, args, protos, cinfo, logout);
689
690 } else if (arg_p == "preferences") {
691
692 if (cinfo == NULL) {
693 disp.setmacro("cvariable", displayclass::defaultpackage, arg_c);
694 disp.setmacro("content", arg_p, "<p>_textbadcollection_<p>");
695 return;
696 }
697
698 if (collectproto == NULL) {return;}
699
700 // set _languageoption_ and _encodingoption_
701 set_language_encoding_macros(disp, args, protos, cinfo, logout);
702
703 // _collectionoption_
704 if ((args["ccs"] == "1") && (cinfo->ccsCols.size() > 1)) {
705 text_t collectionoption = "_textcollectionoption_";
706 text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
707 text_tarray::const_iterator col_end = cinfo->ccsCols.end();
708 int count = 0;
709 while (col_here != col_end) {
710 text_t colname;
711 if (*col_here == arg_c) {
712 colname = cinfo->get_collectionmeta("collectionname", args["l"]);
713 } else {
714 ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
715 if (this_cinfo == NULL) {++col_here; continue;}
716 colname = this_cinfo->get_collectionmeta("collectionname", args["l"]);
717 }
718 if (colname.empty()) {
719 colname = *col_here;
720 }
721 ++count;
722 collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
723 *col_here + "\" onClick=\"updatecc(\'" + *col_here + "\');\"> " +
724 colname + "<br>\n";
725 ++col_here;
726 }
727
728 if (count > 1)
729 disp.setmacro ("collectionoption", "preferences", collectionoption);
730 }
731
732 // _htmloptions_
733
734 text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
735 if ((it != cinfo->format.end()) && ((*it).second == "true")) {
736 disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
737
738
739 // _PreferenceDocsFromWeb_
740
741 it = cinfo->format.find ("PreferenceDocsFromWeb");
742 if ((it == cinfo->format.end()) || ((*it).second == "true"))
743 disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
744 }
745
746 // _prefschanged_
747 if (!args["bp"].empty()) {
748 disp.setmacro ("prefschanged", "preferences", "_textprefschanged_");
749 }
750
751 } else if (arg_p == "about" || arg_p == "help") {
752 if (collectproto == NULL) return;
753
754 comerror_t err;
755 bool has_search_button = true;
756 collectproto->is_searchable(args["c"], has_search_button, err, logout);
757 if (err != noError) has_search_button = true;
758
759 // _textbrowseoptions_ and _numbrowseoptions_
760
761 FilterResponse_t response;
762 text_tset metadata;
763 metadata.insert ("Title");
764 //****************
765 metadata.insert ("childtype");
766 //****************
767 bool getParents = false;
768 get_children ("", args["c"], args["l"], metadata, getParents, collectproto, response, logout);
769
770 int numbrowseoptions = response.docInfo.size();
771 if (has_search_button) numbrowseoptions += 1;
772 disp.setmacro ("numbrowseoptions", "help", numbrowseoptions);
773
774 ResultDocInfo_tarray::iterator here = response.docInfo.begin();
775 ResultDocInfo_tarray::iterator end = response.docInfo.end();
776
777 text_t helptext;
778 if (has_search_button) {
779 helptext = "<ul><li>_textSearchhelp_\n";
780 }
781
782 // ********************************
783 int classifiernumber = 0;
784 bool collage = false;
785
786 while (here != end) {
787
788 ++classifiernumber;
789 text_t childtype = (*here).metadata["childtype"].values[0];
790 if (childtype == "Collage" && arg_p == "about") {
791 // get the classifier number
792 disp.setmacro ("classifier", "about", classifiernumber);
793 disp.setmacro ("aboutCollage", "about", "_collageapplet_");
794 collage = true;
795 }
796 ++here;
797 }
798 if (! collage)
799 disp.setmacro ("aboutCollage", "about", "_collageempty_");
800
801 // ********************************
802
803 here = response.docInfo.begin();
804
805 while (here != end) {
806
807 text_t title = (*here).metadata["Title"].values[0];
808
809 text_t stext;
810 disp.expandstring ("help", "_text" + title + "help_", stext);
811 if (stext == ("_text" + title + "help_")) {
812 text_t ltext, ttext;
813 disp.expandstring("Global", "_label"+title+"_", ltext);
814 if (ltext == ("_label"+title+"_")) {
815 ltext = title;
816 }
817 disp.expandstring("Global", "_text"+title+"_", ttext);
818 if (ttext == ("_text"+title+"_")) {
819 ttext = title;
820 }
821 helptext += "<li>_help:textdefaulthelp_("+ttext+","+ltext+")";
822 } else {
823 helptext += "<li>_help:text" + title + "help_";
824 }
825
826 ++here;
827 }
828 helptext += "</ul>\n";
829 disp.setmacro ("textbrowseoptions", "help", helptext);
830
831 if (arg_p == "help") {
832 // do we need to add in the datesearch help??
833 text_tmap::iterator check = cinfo->format.find("QueryInterface");
834 if(check != cinfo->format.end()){
835 if((*check).second=="DateSearch"){
836 text_t current = "_datesearch_";
837 disp.setmacro("optdatesearchhelp","help","_datesearchhelp_");
838 disp.setmacro("optdatesearchhelpcontents","help","_datesearchhelpcontents_");
839 }
840 }
841
842 }
843
844 if (arg_p == "about") {
845
846 // _textsubcollections_
847 if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
848 text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
849 text_tarray::const_iterator here = cinfo->ccsCols.begin();
850 text_tarray::const_iterator end = cinfo->ccsCols.end();
851 bool first = true;
852 int count = 0;
853 while (here != end) {
854 if (*here == arg_c) {
855 if (!first) textsubcollections += "<br>";
856 textsubcollections += "\n" + cinfo->get_collectionmeta("collectionname", args["l"]) + "\n";
857 } else {
858 ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
859 if (this_cinfo == NULL) {++here; continue;}
860 if (!first) textsubcollections += "<br>";
861 textsubcollections += "\n" + this_cinfo->get_collectionmeta("collectionname", args["l"]) + "\n";
862 }
863 ++count;
864 first = false;
865 ++here;
866 }
867 textsubcollections += "_textsubcols2_";
868 if (count > 1) {
869 disp.setmacro ("textsubcollections", "about", textsubcollections);
870 }
871 }
872
873 comerror_t err;
874 bool issearchable = true;
875 collectproto->is_searchable(args["c"], issearchable, err, logout);
876 if (err != noError) issearchable = true;
877 outconvertclass t;
878 if (!issearchable ) {
879 disp.setmacro ("aboutqueryform", "about", "");
880 }
881 }
882
883 } else if (arg_p == "docs") {
884
885 set_documentation_macro (disp);
886
887 } else if (arg_p == "bsummary" && !arg_c.empty()) {
888
889 set_macro_to_file_contents (disp, "importlog", "bsummary",
890 filename_cat(gsdlhome, "collect", arg_c, "etc", "import.log"));
891 set_macro_to_file_contents (disp, "faillog", "bsummary",
892 filename_cat(gsdlhome, "collect", arg_c, "etc", "fail.log"));
893 }
894}
895
896bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
897 browsermapclass * /*browsers*/, displayclass &disp,
898 outconvertclass &outconvert, ostream &textout,
899 ostream &/*logout*/) {
900
901 text_t &arg_p = args["p"];
902
903 textout << outconvert << disp << ("_" + arg_p + ":header_\n")
904 << ("_" + arg_p + ":content_\n")
905 << ("_" + arg_p + ":footer_\n");
906
907 return true;
908}
909
910void pageaction::configure (const text_t &key, const text_tarray &cfgline) {
911 if ((key == "status") && (cfgline.size() == 1) &&
912 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
913 status_disabled = false;
914 } else if ((key == "collector") && (cfgline.size() == 1) &&
915 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
916 collector_disabled = false;
917 }
918 else if ((key == "depositor") && (cfgline.size() == 1) &&
919 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
920 depositor_disabled = false;
921 }
922 else if ((key == "translator") && (cfgline.size() == 1) &&
923 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
924 translator_disabled = false;
925 } else if ((key == "gliapplet") && (cfgline.size() == 1) &&
926 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
927 gliapplet_disabled = false;
928 }
929 else {
930 // call the parent class to deal with the things which
931 // are not dealt with here
932 action::configure (key, cfgline);
933 }
934}
935
936
937
938
939
940
941
942
943
944
Note: See TracBrowser for help on using the repository browser.