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