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