[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;
|
---|
[28899] | 214 | link += "&l=" + encodeForURL(args["l"]) + "&w=" + encodeForURL(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;
|
---|
[28899] | 337 | link += "&l=" + encodeForURL(args["l"]) + "&w=" + encodeForURL(args["w"]) + "\">";
|
---|
[15002] | 338 | }
|
---|
| 339 | else {
|
---|
[18481] | 340 | link = "<a class=\"collectiontitle\" href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here;
|
---|
[28899] | 341 | link += "&l=" + encodeForURL(args["l"]) + "&w=" + encodeForURL(args["w"]) + "\">";
|
---|
[15002] | 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,
|
---|
[28899] | 517 | const text_t &packagename, const text_t &filename, bool encode) {
|
---|
[2785] | 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 | }
|
---|
[28899] | 533 |
|
---|
| 534 | // if we ever need to encode the contents into HTML, call this function with encode=true
|
---|
| 535 | if(encode) {
|
---|
| 536 | filecontent = encodeForHTML(filecontent);
|
---|
| 537 | }
|
---|
| 538 |
|
---|
[2785] | 539 | disp.setmacro (macroname, packagename, dm_safe(filecontent));
|
---|
| 540 | }
|
---|
| 541 |
|
---|
[3625] | 542 | void pageaction::set_language_encoding_macros(displayclass &disp, cgiargsclass &args,
|
---|
| 543 | recptprotolistclass *protos, ColInfoResponse_t *cinfo,
|
---|
| 544 | ostream &logout) {
|
---|
| 545 | // _languageoption_
|
---|
| 546 | // Create the "interface language" selection box for the preferences
|
---|
| 547 | // pages. You can use something like "format PreferenceLanguages
|
---|
| 548 | // en|fr|zn" from within a collect.cfg file to use only a subset of
|
---|
| 549 | // the available languages for any given collection (for
|
---|
| 550 | // collection-specific preferences pages). This facility is kind of
|
---|
| 551 | // ugly though and should be replaced by something better when the
|
---|
| 552 | // configuration files are tidied up (as should all the other
|
---|
| 553 | // "format Preference..." options).
|
---|
| 554 | text_t &arg_l = args["l"];
|
---|
| 555 | const recptconf &configinfo = recpt->get_configinfo();
|
---|
| 556 | // put languages in another map to sort them by longname
|
---|
| 557 | text_tmap languages;
|
---|
| 558 | languageinfo_tmap::const_iterator thislang = configinfo.languages.begin();
|
---|
| 559 | languageinfo_tmap::const_iterator endlang = configinfo.languages.end();
|
---|
| 560 | while (thislang != endlang) {
|
---|
| 561 | languages[(*thislang).second.longname] = (*thislang).first;
|
---|
[9620] | 562 | ++thislang;
|
---|
[3625] | 563 | }
|
---|
| 564 | text_tmap::iterator tlang = languages.begin();
|
---|
| 565 | text_tmap::iterator elang = languages.end();
|
---|
| 566 |
|
---|
| 567 | text_t languageoption;
|
---|
| 568 | bool collection_specific = false;
|
---|
| 569 |
|
---|
| 570 | if (cinfo != NULL) {
|
---|
| 571 | text_tmap::const_iterator it = cinfo->format.find ("PreferenceLanguages");
|
---|
| 572 | if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
|
---|
| 573 | collection_specific = true;
|
---|
| 574 | text_tset pref_langs;
|
---|
| 575 | splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
|
---|
| 576 | if (pref_langs.size() > 1) {
|
---|
| 577 | while (tlang != elang) {
|
---|
| 578 | if (pref_langs.find((*tlang).second) != pref_langs.end()) {
|
---|
| 579 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
| 580 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
[7706] | 581 | languageoption += ">" + (*tlang).first + "</option>\n";
|
---|
[3625] | 582 | }
|
---|
[9620] | 583 | ++tlang;
|
---|
[3625] | 584 | }
|
---|
| 585 | }
|
---|
| 586 | }
|
---|
| 587 | }
|
---|
| 588 |
|
---|
| 589 | if (!collection_specific) {
|
---|
| 590 | while (tlang != elang) {
|
---|
| 591 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
| 592 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
[7706] | 593 | languageoption += ">" + (*tlang).first + "</option>\n";
|
---|
[9620] | 594 | ++tlang;
|
---|
[3625] | 595 | }
|
---|
| 596 | }
|
---|
| 597 |
|
---|
| 598 | if (!languageoption.empty()) {
|
---|
| 599 | languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption;
|
---|
| 600 | languageoption += "</select>\n";
|
---|
| 601 | disp.setmacro ("languageoption", args["p"], languageoption);
|
---|
| 602 | }
|
---|
| 603 |
|
---|
| 604 | // _encodingoption_
|
---|
| 605 | // create the "encoding" selection box for the preferences page
|
---|
| 606 | if (configinfo.encodings.size() > 1) {
|
---|
| 607 | text_t &arg_w = args["w"];
|
---|
| 608 | text_t encodingoption;
|
---|
| 609 | text_tmap::const_iterator thisenc = configinfo.encodings.begin();
|
---|
| 610 | text_tmap::const_iterator endenc = configinfo.encodings.end();
|
---|
| 611 | while (thisenc != endenc) {
|
---|
| 612 | encodingoption += "<option value=\"" + (*thisenc).second + "\"";
|
---|
| 613 | if ((*thisenc).second == arg_w) encodingoption += " selected";
|
---|
[7706] | 614 | encodingoption += ">" + (*thisenc).first + "</option>\n";
|
---|
[9620] | 615 | ++thisenc;
|
---|
[3625] | 616 | }
|
---|
| 617 |
|
---|
| 618 | encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption;
|
---|
| 619 | encodingoption += "</select>\n";
|
---|
| 620 | disp.setmacro ("encodingoption", args["p"], encodingoption);
|
---|
[9676] | 621 | } else if (configinfo.encodings.size() == 1) {
|
---|
| 622 | text_t encodingoption;
|
---|
| 623 | text_tmap::const_iterator thisenc = configinfo.encodings.begin();
|
---|
| 624 | encodingoption = (*thisenc).first;
|
---|
| 625 | disp.setmacro ("encodingoption", args["p"], encodingoption);
|
---|
| 626 | } else { // size == 0. shouldn't really happen, but allow it
|
---|
| 627 | disp.setmacro ("encodingoption", args["p"], "None");
|
---|
[3625] | 628 | }
|
---|
[9676] | 629 |
|
---|
[3625] | 630 | }
|
---|
| 631 |
|
---|
[11986] | 632 |
|
---|
[761] | 633 | void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 634 | recptprotolistclass *protos, ostream &logout) {
|
---|
| 635 |
|
---|
[284] | 636 | // define_internal_macros sets the following macros:
|
---|
| 637 |
|
---|
[866] | 638 | // _numdocs_ the number of documents in the collection
|
---|
| 639 |
|
---|
| 640 | // _builddate_ the date last built
|
---|
| 641 |
|
---|
[471] | 642 | // if page is "home"
|
---|
| 643 | // _homeextra_ this is the list of available collections and collection info
|
---|
| 644 | // to be displayed on the home page
|
---|
[284] | 645 |
|
---|
[471] | 646 |
|
---|
[866] | 647 | // if page is "preferences"
|
---|
| 648 | // _collectionoption_ collections to search/browse (if cross-collection-searching is on)
|
---|
| 649 |
|
---|
| 650 | // _htmloptions_ set to _htmloptionson_ if DocumentUseHTML is set
|
---|
| 651 |
|
---|
[867] | 652 | // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set
|
---|
[866] | 653 |
|
---|
[3625] | 654 |
|
---|
| 655 | // if page is "preferences" or "homepref"
|
---|
[867] | 656 | // _languageoption_ interface languages to select from (dependant on PreferenceLanguages)
|
---|
| 657 |
|
---|
[1856] | 658 | // _encodingoption_ encodings to select from
|
---|
[867] | 659 |
|
---|
[3625] | 660 |
|
---|
[471] | 661 | // if page is "about"
|
---|
[866] | 662 | // _textsubcollections_ the text on which subcollections make up the collection (if
|
---|
| 663 | // cross-collection searching is being used
|
---|
[471] | 664 |
|
---|
| 665 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 666 |
|
---|
| 667 | // _numbrowseoptions_ the number of browsing options
|
---|
| 668 |
|
---|
[2415] | 669 | // _prefschanged_ will be set to _textprefschanged_ if the "set preferences" button
|
---|
| 670 | // was pressed
|
---|
[471] | 671 |
|
---|
[4774] | 672 | // _aboutqueryform_ will be set to "" if the collection isn't searchable
|
---|
[2415] | 673 |
|
---|
[471] | 674 | // if page is "help"
|
---|
| 675 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 676 |
|
---|
| 677 | // _numbrowseoptions_ the number of browsing options
|
---|
| 678 |
|
---|
[875] | 679 | // _topicreadingdocs_ this section of the help text differs depending on what type of
|
---|
| 680 | // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
|
---|
| 681 | // _texthelpreadingdocs_
|
---|
| 682 |
|
---|
[3812] | 683 | // if page is "home" or "homehelp"
|
---|
[1759] | 684 | // _textgocollector_ set to "" if collector is disabled in main.cfg
|
---|
[11998] | 685 | // _textgodepositor_ set to "" if depositor is disabled in main.cfg
|
---|
[1759] | 686 | // _textgoadmin_ set to "" if status is disabled in main.cfg
|
---|
[3774] | 687 | // _textgotranslator_ set to "" if translator is disabled in main.cfg
|
---|
[7762] | 688 | // _textgogliapplet_ set to "" if gliapplet is disabled in main.cfg
|
---|
[1759] | 689 |
|
---|
[2329] | 690 |
|
---|
| 691 | // if page is "homehelp"
|
---|
| 692 | // _collectionlist_ list of available collections to be displayed on the homehelp page
|
---|
[2767] | 693 |
|
---|
[471] | 694 |
|
---|
[2767] | 695 | // if page is "docs"
|
---|
| 696 | // _documentation_ links to PDF documents if they're available
|
---|
| 697 |
|
---|
[2785] | 698 |
|
---|
| 699 | // if page is "bsummary"
|
---|
| 700 | // _importlog_ set to contents of collections import.log file
|
---|
| 701 | // _faillog_ set to contents of collections fail.log file
|
---|
[12503] | 702 | //_buildlog_ set to contents of collections build.log file
|
---|
[2767] | 703 |
|
---|
[1270] | 704 | if (recpt == NULL) {
|
---|
| 705 | logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
|
---|
| 706 | << " information about any receptionists. The method set_receptionist was\n"
|
---|
| 707 | << " probably not called from the module which instantiated this action.\n";
|
---|
| 708 | return;
|
---|
| 709 | }
|
---|
[12463] | 710 | // _versionnnum_ greenstone version number (hard-coded)
|
---|
| 711 | disp.setmacro("versionnum", displayclass::defaultpackage, GSDL_VERSION);
|
---|
[1270] | 712 |
|
---|
[471] | 713 | text_t &arg_p = args["p"];
|
---|
[866] | 714 | text_t &arg_c = args["c"];
|
---|
[1270] | 715 | ColInfoResponse_t *cinfo = NULL;
|
---|
[471] | 716 |
|
---|
[866] | 717 | recptproto* collectproto = protos->getrecptproto (arg_c, logout);
|
---|
[793] | 718 | if (collectproto != NULL) {
|
---|
[1270] | 719 | cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
|
---|
[2370] | 720 |
|
---|
[13982] | 721 | //set the tidyoption
|
---|
| 722 | if (cinfo->useBook == false)
|
---|
| 723 | {
|
---|
| 724 | disp.setmacro ("tidyoption", displayclass::defaultpackage, "untidy");
|
---|
| 725 | }
|
---|
| 726 | else
|
---|
| 727 | {
|
---|
| 728 | disp.setmacro ("tidyoption", displayclass::defaultpackage, "tidy");
|
---|
| 729 | }
|
---|
| 730 |
|
---|
[7432] | 731 | disp.setmacro ("numdocs", displayclass::defaultpackage, cinfo->numDocs);
|
---|
[13966] | 732 | disp.setmacro ("numsections", displayclass::defaultpackage, cinfo->numSections);
|
---|
| 733 | disp.setmacro ("numwords", displayclass::defaultpackage, cinfo->numWords);
|
---|
[793] | 734 | unsigned long current_time = time(NULL);
|
---|
[1270] | 735 | unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
|
---|
[7432] | 736 | disp.setmacro ("builddate", displayclass::defaultpackage, builddate);
|
---|
[2370] | 737 |
|
---|
| 738 | text_t numbytes;
|
---|
| 739 | if ((cinfo->numBytes/(1024*1024)) > 1) {
|
---|
| 740 | numbytes = (text_t)(cinfo->numBytes/(1024*1024)) + " Mb";
|
---|
| 741 | } else if ((cinfo->numBytes/1024) > 1) {
|
---|
| 742 | numbytes = (text_t)(cinfo->numBytes/1024) + " kb";
|
---|
| 743 | } else {
|
---|
| 744 | numbytes = (text_t)cinfo->numBytes + " bytes";
|
---|
| 745 | }
|
---|
[7432] | 746 | disp.setmacro("numbytes", displayclass::defaultpackage, numbytes);
|
---|
[11986] | 747 |
|
---|
[22046] | 748 | // set up ct, qt, qto, sqlqto
|
---|
[11986] | 749 | set_query_type_args(cinfo, args);
|
---|
[12865] | 750 | // set up ks, ss, afs
|
---|
| 751 | set_stem_index_args(cinfo, args);
|
---|
| 752 |
|
---|
[793] | 753 | }
|
---|
[11986] | 754 |
|
---|
[2782] | 755 | //setting _queryformcontent_ so that the query interface is consistent.
|
---|
[3880] | 756 | //also adding usability button if necessary
|
---|
[5509] | 757 | if (arg_p == "about") {
|
---|
| 758 | if (cinfo == NULL) {
|
---|
[28888] | 759 | disp.setmacro("cvariable", displayclass::defaultpackage, encodeForHTML(arg_c));
|
---|
[5509] | 760 | disp.setmacro("content", arg_p, "<p>_textbadcollection_<p>");
|
---|
| 761 | return;
|
---|
| 762 | }
|
---|
| 763 | else {
|
---|
[6810] | 764 |
|
---|
[2785] | 765 | text_tmap::iterator check = cinfo->format.find("QueryInterface");
|
---|
| 766 | if(check != cinfo->format.end()){
|
---|
| 767 | if((*check).second=="DateSearch"){
|
---|
[5633] | 768 | text_t current = "_datesearch_";
|
---|
| 769 | disp.setmacro("optdatesearch","query",current);
|
---|
[2785] | 770 | }
|
---|
[2782] | 771 | }
|
---|
[3880] | 772 | check = cinfo->format.find("Usability");
|
---|
| 773 | if(check != cinfo->format.end()){
|
---|
[11356] | 774 | disp.setmacro("usability", displayclass::defaultpackage, "_usablink_");
|
---|
[7432] | 775 | disp.setmacro("usabinterface", displayclass::defaultpackage, ("_usab"+(*check).second+"_"));
|
---|
| 776 | disp.setmacro("usabilityscript", displayclass::defaultpackage, "_usabshowscript_");
|
---|
[3880] | 777 | }
|
---|
[2782] | 778 | }
|
---|
| 779 | }
|
---|
[9931] | 780 |
|
---|
| 781 |
|
---|
[3812] | 782 | if (arg_p == "home" || arg_p == "homehelp") {
|
---|
[1759] | 783 | if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
|
---|
| 784 | if (collector_disabled) disp.setmacro ("textgocollector", "home", "");
|
---|
[11998] | 785 | if (depositor_disabled) disp.setmacro ("textgodepositor", "home", "");
|
---|
[3774] | 786 | if (translator_disabled) disp.setmacro ("textgotranslator", "home", "");
|
---|
[3625] | 787 |
|
---|
[3812] | 788 | if (arg_p == "home") {
|
---|
[4905] | 789 | homepagestyle (disp, protos, args, logout);
|
---|
[3812] | 790 | } else if (arg_p == "homehelp") {
|
---|
[9931] | 791 | set_collectionlist_macro (disp, protos, args, logout);
|
---|
[3812] | 792 | }
|
---|
| 793 |
|
---|
[7762] | 794 | } else if (arg_p == "gli") {
|
---|
| 795 | if (gliapplet_disabled) disp.setmacro ("gliapplet", "gli", "");
|
---|
| 796 |
|
---|
[3625] | 797 | } else if (arg_p == "homepref") {
|
---|
[2782] | 798 |
|
---|
[3625] | 799 | // set _languageoption_ and _encodingoption_
|
---|
| 800 | set_language_encoding_macros(disp, args, protos, cinfo, logout);
|
---|
| 801 |
|
---|
| 802 | } else if (arg_p == "preferences") {
|
---|
[6810] | 803 |
|
---|
[5513] | 804 | if (cinfo == NULL) {
|
---|
[28888] | 805 | disp.setmacro("cvariable", displayclass::defaultpackage, encodeForHTML(arg_c));
|
---|
[5513] | 806 | disp.setmacro("content", arg_p, "<p>_textbadcollection_<p>");
|
---|
| 807 | return;
|
---|
| 808 | }
|
---|
| 809 |
|
---|
[2105] | 810 | if (collectproto == NULL) {return;}
|
---|
[3625] | 811 |
|
---|
| 812 | // set _languageoption_ and _encodingoption_
|
---|
| 813 | set_language_encoding_macros(disp, args, protos, cinfo, logout);
|
---|
| 814 |
|
---|
[866] | 815 | // _collectionoption_
|
---|
[2785] | 816 | if ((args["ccs"] == "1") && (cinfo->ccsCols.size() > 1)) {
|
---|
[866] | 817 | text_t collectionoption = "_textcollectionoption_";
|
---|
[1270] | 818 | text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
|
---|
| 819 | text_tarray::const_iterator col_end = cinfo->ccsCols.end();
|
---|
[905] | 820 | int count = 0;
|
---|
[866] | 821 | while (col_here != col_end) {
|
---|
| 822 | text_t colname;
|
---|
| 823 | if (*col_here == arg_c) {
|
---|
[9931] | 824 | colname = cinfo->get_collectionmeta("collectionname", args["l"]);
|
---|
[866] | 825 | } else {
|
---|
[1270] | 826 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
|
---|
[9620] | 827 | if (this_cinfo == NULL) {++col_here; continue;}
|
---|
[9931] | 828 | colname = this_cinfo->get_collectionmeta("collectionname", args["l"]);
|
---|
[866] | 829 | }
|
---|
[9931] | 830 | if (colname.empty()) {
|
---|
| 831 | colname = *col_here;
|
---|
| 832 | }
|
---|
[9620] | 833 | ++count;
|
---|
[866] | 834 | collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
|
---|
| 835 | *col_here + "\" onClick=\"updatecc(\'" + *col_here + "\');\"> " +
|
---|
| 836 | colname + "<br>\n";
|
---|
[9620] | 837 | ++col_here;
|
---|
[866] | 838 | }
|
---|
[905] | 839 |
|
---|
| 840 | if (count > 1)
|
---|
| 841 | disp.setmacro ("collectionoption", "preferences", collectionoption);
|
---|
[866] | 842 | }
|
---|
| 843 |
|
---|
| 844 | // _htmloptions_
|
---|
| 845 |
|
---|
[1270] | 846 | text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
|
---|
| 847 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[866] | 848 | disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
|
---|
| 849 |
|
---|
[867] | 850 |
|
---|
| 851 | // _PreferenceDocsFromWeb_
|
---|
| 852 |
|
---|
[1270] | 853 | it = cinfo->format.find ("PreferenceDocsFromWeb");
|
---|
| 854 | if ((it == cinfo->format.end()) || ((*it).second == "true"))
|
---|
[867] | 855 | disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
|
---|
| 856 | }
|
---|
| 857 |
|
---|
[2415] | 858 | // _prefschanged_
|
---|
| 859 | if (!args["bp"].empty()) {
|
---|
| 860 | disp.setmacro ("prefschanged", "preferences", "_textprefschanged_");
|
---|
| 861 | }
|
---|
[867] | 862 |
|
---|
[866] | 863 | } else if (arg_p == "about" || arg_p == "help") {
|
---|
[761] | 864 | if (collectproto == NULL) return;
|
---|
[5225] | 865 |
|
---|
| 866 | comerror_t err;
|
---|
| 867 | bool has_search_button = true;
|
---|
| 868 | collectproto->is_searchable(args["c"], has_search_button, err, logout);
|
---|
| 869 | if (err != noError) has_search_button = true;
|
---|
[761] | 870 |
|
---|
[471] | 871 | // _textbrowseoptions_ and _numbrowseoptions_
|
---|
[761] | 872 |
|
---|
[471] | 873 | FilterResponse_t response;
|
---|
[649] | 874 | text_tset metadata;
|
---|
| 875 | metadata.insert ("Title");
|
---|
[6810] | 876 | //****************
|
---|
| 877 | metadata.insert ("childtype");
|
---|
| 878 | //****************
|
---|
[471] | 879 | bool getParents = false;
|
---|
[7432] | 880 | get_children ("", args["c"], args["l"], metadata, getParents, collectproto, response, logout);
|
---|
[471] | 881 |
|
---|
[5225] | 882 | int numbrowseoptions = response.docInfo.size();
|
---|
| 883 | if (has_search_button) numbrowseoptions += 1;
|
---|
| 884 | disp.setmacro ("numbrowseoptions", "help", numbrowseoptions);
|
---|
[471] | 885 |
|
---|
[649] | 886 | ResultDocInfo_tarray::iterator here = response.docInfo.begin();
|
---|
| 887 | ResultDocInfo_tarray::iterator end = response.docInfo.end();
|
---|
[471] | 888 |
|
---|
[11958] | 889 | text_t helptext;
|
---|
[5225] | 890 | if (has_search_button) {
|
---|
[11958] | 891 | helptext = "<ul><li>_textSearchhelp_\n";
|
---|
[5225] | 892 | }
|
---|
[471] | 893 |
|
---|
[6810] | 894 | // ********************************
|
---|
| 895 | int classifiernumber = 0;
|
---|
| 896 | bool collage = false;
|
---|
| 897 |
|
---|
[471] | 898 | while (here != end) {
|
---|
[6810] | 899 |
|
---|
[9620] | 900 | ++classifiernumber;
|
---|
[6810] | 901 | text_t childtype = (*here).metadata["childtype"].values[0];
|
---|
| 902 | if (childtype == "Collage" && arg_p == "about") {
|
---|
| 903 | // get the classifier number
|
---|
| 904 | disp.setmacro ("classifier", "about", classifiernumber);
|
---|
| 905 | disp.setmacro ("aboutCollage", "about", "_collageapplet_");
|
---|
| 906 | collage = true;
|
---|
| 907 | }
|
---|
[9620] | 908 | ++here;
|
---|
[6810] | 909 | }
|
---|
| 910 | if (! collage)
|
---|
| 911 | disp.setmacro ("aboutCollage", "about", "_collageempty_");
|
---|
| 912 |
|
---|
| 913 | // ********************************
|
---|
| 914 |
|
---|
| 915 | here = response.docInfo.begin();
|
---|
| 916 |
|
---|
| 917 | while (here != end) {
|
---|
| 918 |
|
---|
[649] | 919 | text_t title = (*here).metadata["Title"].values[0];
|
---|
[6810] | 920 |
|
---|
[11958] | 921 | text_t stext;
|
---|
| 922 | disp.expandstring ("help", "_text" + title + "help_", stext);
|
---|
| 923 | if (stext == ("_text" + title + "help_")) {
|
---|
| 924 | text_t ltext, ttext;
|
---|
| 925 | disp.expandstring("Global", "_label"+title+"_", ltext);
|
---|
| 926 | if (ltext == ("_label"+title+"_")) {
|
---|
| 927 | ltext = title;
|
---|
| 928 | }
|
---|
| 929 | disp.expandstring("Global", "_text"+title+"_", ttext);
|
---|
| 930 | if (ttext == ("_text"+title+"_")) {
|
---|
| 931 | ttext = title;
|
---|
| 932 | }
|
---|
| 933 | helptext += "<li>_help:textdefaulthelp_("+ttext+","+ltext+")";
|
---|
[649] | 934 | } else {
|
---|
[11958] | 935 | helptext += "<li>_help:text" + title + "help_";
|
---|
[649] | 936 | }
|
---|
[729] | 937 |
|
---|
[9620] | 938 | ++here;
|
---|
[471] | 939 | }
|
---|
[11958] | 940 | helptext += "</ul>\n";
|
---|
| 941 | disp.setmacro ("textbrowseoptions", "help", helptext);
|
---|
[866] | 942 |
|
---|
[11356] | 943 | if (arg_p == "help") {
|
---|
| 944 | // do we need to add in the datesearch help??
|
---|
| 945 | text_tmap::iterator check = cinfo->format.find("QueryInterface");
|
---|
| 946 | if(check != cinfo->format.end()){
|
---|
| 947 | if((*check).second=="DateSearch"){
|
---|
| 948 | text_t current = "_datesearch_";
|
---|
| 949 | disp.setmacro("optdatesearchhelp","help","_datesearchhelp_");
|
---|
| 950 | disp.setmacro("optdatesearchhelpcontents","help","_datesearchhelpcontents_");
|
---|
| 951 | }
|
---|
| 952 | }
|
---|
| 953 |
|
---|
| 954 | }
|
---|
| 955 |
|
---|
[866] | 956 | if (arg_p == "about") {
|
---|
| 957 |
|
---|
| 958 | // _textsubcollections_
|
---|
[1270] | 959 | if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
|
---|
| 960 | text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
|
---|
| 961 | text_tarray::const_iterator here = cinfo->ccsCols.begin();
|
---|
| 962 | text_tarray::const_iterator end = cinfo->ccsCols.end();
|
---|
[867] | 963 | bool first = true;
|
---|
[905] | 964 | int count = 0;
|
---|
[866] | 965 | while (here != end) {
|
---|
| 966 | if (*here == arg_c) {
|
---|
[867] | 967 | if (!first) textsubcollections += "<br>";
|
---|
[9931] | 968 | textsubcollections += "\n" + cinfo->get_collectionmeta("collectionname", args["l"]) + "\n";
|
---|
[866] | 969 | } else {
|
---|
[1270] | 970 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
|
---|
[9620] | 971 | if (this_cinfo == NULL) {++here; continue;}
|
---|
[905] | 972 | if (!first) textsubcollections += "<br>";
|
---|
[9931] | 973 | textsubcollections += "\n" + this_cinfo->get_collectionmeta("collectionname", args["l"]) + "\n";
|
---|
[866] | 974 | }
|
---|
[9620] | 975 | ++count;
|
---|
[867] | 976 | first = false;
|
---|
[9620] | 977 | ++here;
|
---|
[866] | 978 | }
|
---|
| 979 | textsubcollections += "_textsubcols2_";
|
---|
[4774] | 980 | if (count > 1) {
|
---|
[905] | 981 | disp.setmacro ("textsubcollections", "about", textsubcollections);
|
---|
[4774] | 982 | }
|
---|
[866] | 983 | }
|
---|
[4774] | 984 |
|
---|
| 985 | comerror_t err;
|
---|
| 986 | bool issearchable = true;
|
---|
| 987 | collectproto->is_searchable(args["c"], issearchable, err, logout);
|
---|
| 988 | if (err != noError) issearchable = true;
|
---|
| 989 | outconvertclass t;
|
---|
[11986] | 990 | if (!issearchable ) {
|
---|
[4774] | 991 | disp.setmacro ("aboutqueryform", "about", "");
|
---|
| 992 | }
|
---|
[866] | 993 | }
|
---|
[2329] | 994 |
|
---|
[2767] | 995 | } else if (arg_p == "docs") {
|
---|
| 996 |
|
---|
| 997 | set_documentation_macro (disp);
|
---|
| 998 |
|
---|
[2785] | 999 | } else if (arg_p == "bsummary" && !arg_c.empty()) {
|
---|
| 1000 |
|
---|
| 1001 | set_macro_to_file_contents (disp, "importlog", "bsummary",
|
---|
[16310] | 1002 | filename_cat(collecthome, arg_c, "etc", "import.log"));
|
---|
[2785] | 1003 | set_macro_to_file_contents (disp, "faillog", "bsummary",
|
---|
[16310] | 1004 | filename_cat(collecthome, arg_c, "etc", "fail.log"));
|
---|
[12503] | 1005 | set_macro_to_file_contents (disp, "buildlog", "bsummary",
|
---|
[16310] | 1006 | filename_cat(collecthome, arg_c, "etc", "build.log"));
|
---|
[471] | 1007 | }
|
---|
[284] | 1008 | }
|
---|
| 1009 |
|
---|
[761] | 1010 | bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
|
---|
| 1011 | browsermapclass * /*browsers*/, displayclass &disp,
|
---|
[421] | 1012 | outconvertclass &outconvert, ostream &textout,
|
---|
| 1013 | ostream &/*logout*/) {
|
---|
[173] | 1014 |
|
---|
[172] | 1015 | text_t &arg_p = args["p"];
|
---|
[160] | 1016 |
|
---|
[28888] | 1017 | textout << outconvert << disp << ("_" + encodeForHTML(arg_p) + ":header_\n")
|
---|
| 1018 | << ("_" + encodeForHTML(arg_p) + ":content_\n")
|
---|
| 1019 | << ("_" + encodeForHTML(arg_p) + ":footer_\n");
|
---|
[172] | 1020 |
|
---|
[160] | 1021 | return true;
|
---|
| 1022 | }
|
---|
[1759] | 1023 |
|
---|
| 1024 | void pageaction::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
| 1025 | if ((key == "status") && (cfgline.size() == 1) &&
|
---|
| 1026 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
| 1027 | status_disabled = false;
|
---|
| 1028 | } else if ((key == "collector") && (cfgline.size() == 1) &&
|
---|
| 1029 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
| 1030 | collector_disabled = false;
|
---|
[11998] | 1031 | }
|
---|
| 1032 | else if ((key == "depositor") && (cfgline.size() == 1) &&
|
---|
[3774] | 1033 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
[11998] | 1034 | depositor_disabled = false;
|
---|
| 1035 | }
|
---|
| 1036 | else if ((key == "translator") && (cfgline.size() == 1) &&
|
---|
| 1037 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
[3774] | 1038 | translator_disabled = false;
|
---|
[7762] | 1039 | } else if ((key == "gliapplet") && (cfgline.size() == 1) &&
|
---|
| 1040 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
| 1041 | gliapplet_disabled = false;
|
---|
| 1042 | }
|
---|
| 1043 | else {
|
---|
[1759] | 1044 | // call the parent class to deal with the things which
|
---|
| 1045 | // are not dealt with here
|
---|
| 1046 | action::configure (key, cfgline);
|
---|
| 1047 | }
|
---|
| 1048 | }
|
---|
[3880] | 1049 |
|
---|
| 1050 |
|
---|
| 1051 |
|
---|
| 1052 |
|
---|
| 1053 |
|
---|
| 1054 |
|
---|
| 1055 |
|
---|
| 1056 |
|
---|
| 1057 |
|
---|
| 1058 |
|
---|