[248] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * documentaction.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.
|
---|
[248] | 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 | *
|
---|
[248] | 24 | *********************************************************************/
|
---|
| 25 |
|
---|
[443] | 26 | #include <string.h>
|
---|
[4936] | 27 |
|
---|
[248] | 28 | #include "documentaction.h"
|
---|
| 29 | #include "OIDtools.h"
|
---|
[267] | 30 | #include "querytools.h"
|
---|
| 31 | #include "unitool.h"
|
---|
[1148] | 32 | #include "gsdltools.h"
|
---|
[3322] | 33 | #include "highlighttext.h"
|
---|
[12044] | 34 | #include "browsetoolsclass.h"
|
---|
[248] | 35 |
|
---|
| 36 | documentaction::documentaction () {
|
---|
[1270] | 37 | recpt = NULL;
|
---|
[600] | 38 |
|
---|
[248] | 39 | // this action uses cgi variables "a", "d", "cl",
|
---|
[257] | 40 | // "x", "gc", "gt", "gp", and "hl"
|
---|
[248] | 41 | cgiarginfo arg_ainfo;
|
---|
| 42 | arg_ainfo.shortname = "a";
|
---|
| 43 | arg_ainfo.longname = "action";
|
---|
| 44 | arg_ainfo.multiplechar = true;
|
---|
| 45 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 46 | arg_ainfo.argdefault = "p";
|
---|
| 47 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 48 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 49 |
|
---|
| 50 | arg_ainfo.shortname = "d";
|
---|
| 51 | arg_ainfo.longname = "document OID";
|
---|
| 52 | arg_ainfo.multiplechar = true;
|
---|
| 53 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
[7441] | 54 | arg_ainfo.argdefault = g_EmptyText;
|
---|
[248] | 55 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
| 56 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 57 |
|
---|
[722] | 58 | // whether or not a document should be retrieved from the
|
---|
| 59 | // library or the Web.
|
---|
| 60 | arg_ainfo.shortname = "il";
|
---|
| 61 | arg_ainfo.longname = "internal link preference";
|
---|
| 62 | arg_ainfo.multiplechar = false;
|
---|
| 63 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 64 | arg_ainfo.argdefault = "l";
|
---|
| 65 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 66 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 67 |
|
---|
[248] | 68 | arg_ainfo.shortname = "cl";
|
---|
| 69 | arg_ainfo.longname = "classification OID";
|
---|
| 70 | arg_ainfo.multiplechar = true;
|
---|
| 71 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
[7441] | 72 | arg_ainfo.argdefault = g_EmptyText;
|
---|
[248] | 73 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
| 74 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 75 |
|
---|
| 76 | // in this action "gc" controls the expand/contract
|
---|
| 77 | // contents function
|
---|
| 78 | arg_ainfo.shortname = "gc";
|
---|
| 79 | arg_ainfo.longname = "expand contents";
|
---|
| 80 | arg_ainfo.multiplechar = false;
|
---|
| 81 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 82 | arg_ainfo.argdefault = "0";
|
---|
| 83 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
| 84 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 85 |
|
---|
| 86 | // in this action "gt" controls the expand/contract
|
---|
[257] | 87 | // text function 0 = not expanded, 1 = expand unless
|
---|
| 88 | // there are more than 10 sections containing text,
|
---|
| 89 | // 2 = expand all
|
---|
[248] | 90 | arg_ainfo.shortname = "gt";
|
---|
| 91 | arg_ainfo.longname = "expand text";
|
---|
| 92 | arg_ainfo.multiplechar = false;
|
---|
| 93 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 94 | arg_ainfo.argdefault = "0";
|
---|
| 95 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
| 96 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 97 |
|
---|
| 98 | // in this action "gp" is the "go to page" control
|
---|
| 99 | // used by the Book type of toc
|
---|
| 100 | arg_ainfo.shortname = "gp";
|
---|
| 101 | arg_ainfo.longname = "go to page";
|
---|
| 102 | arg_ainfo.multiplechar = true;
|
---|
| 103 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
[7441] | 104 | arg_ainfo.argdefault = g_EmptyText;
|
---|
[248] | 105 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
| 106 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 107 |
|
---|
[257] | 108 | // in this action "hl" is the "highlighting on/
|
---|
[3322] | 109 | // highlighting off control ("hl" == "2" is a
|
---|
| 110 | // special case that forces phrase highlighting
|
---|
| 111 | // to be used even if the query string doesn't
|
---|
| 112 | // appear to be a phrase)
|
---|
[257] | 113 | arg_ainfo.shortname = "hl";
|
---|
| 114 | arg_ainfo.longname = "highlighting on/off";
|
---|
| 115 | arg_ainfo.multiplechar = false;
|
---|
| 116 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 117 | arg_ainfo.argdefault = "1";
|
---|
| 118 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 119 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 120 |
|
---|
[248] | 121 | // "x" is 0 normally or 1 if page
|
---|
| 122 | // has been "detached"
|
---|
| 123 | arg_ainfo.shortname = "x";
|
---|
| 124 | arg_ainfo.longname = "detached page";
|
---|
| 125 | arg_ainfo.multiplechar = false;
|
---|
| 126 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 127 | arg_ainfo.argdefault = "0";
|
---|
[282] | 128 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
[248] | 129 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
[870] | 130 |
|
---|
[5124] | 131 | // "xx" is 0 normally or 1 if documents should be detached by default
|
---|
| 132 | arg_ainfo.shortname = "xx";
|
---|
| 133 | arg_ainfo.longname = "detach all doc pages";
|
---|
| 134 | arg_ainfo.multiplechar = false;
|
---|
| 135 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 136 | arg_ainfo.argdefault = "0";
|
---|
| 137 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 138 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 139 |
|
---|
| 140 |
|
---|
[870] | 141 | // f arg is set to 1 if document is to
|
---|
| 142 | // be displayed in a frame
|
---|
| 143 | arg_ainfo.shortname = "f";
|
---|
| 144 | arg_ainfo.longname = "frame";
|
---|
| 145 | arg_ainfo.multiplechar = false;
|
---|
| 146 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 147 | arg_ainfo.argdefault = "0";
|
---|
| 148 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
| 149 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 150 |
|
---|
| 151 | // fc arg is "1" if search bar is to be included (i.e. if "fc" == 1
|
---|
| 152 | // the httpdocument macro will include "&f=1"
|
---|
| 153 | arg_ainfo.shortname = "fc";
|
---|
| 154 | arg_ainfo.longname = "include search bar";
|
---|
| 155 | arg_ainfo.multiplechar = false;
|
---|
| 156 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 157 | arg_ainfo.argdefault = "1";
|
---|
| 158 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 159 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
[1941] | 160 |
|
---|
| 161 | //rd is whether a document will be displayed
|
---|
| 162 | //with a relevant document list
|
---|
| 163 | arg_ainfo.shortname = "rd";
|
---|
| 164 | arg_ainfo.longname = "include relevant documents";
|
---|
| 165 | arg_ainfo.multiplechar = false;
|
---|
| 166 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 167 | arg_ainfo.argdefault = "0";
|
---|
| 168 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 169 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 170 |
|
---|
[6645] | 171 | //dm is the metadata that has been used for the datelist
|
---|
| 172 | arg_ainfo.shortname = "dm";
|
---|
| 173 | arg_ainfo.longname = "date metadata";
|
---|
| 174 | arg_ainfo.multiplechar = true;
|
---|
| 175 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
[7441] | 176 | arg_ainfo.argdefault = g_EmptyText;
|
---|
[6645] | 177 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 178 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 179 |
|
---|
[248] | 180 | }
|
---|
| 181 |
|
---|
[12044] | 182 | documentaction::~documentaction()
|
---|
| 183 | {
|
---|
[248] | 184 | }
|
---|
| 185 |
|
---|
[284] | 186 | bool documentaction::check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
|
---|
[4974] | 187 | recptprotolistclass *protos, ostream &logout) {
|
---|
[284] | 188 |
|
---|
[4974] | 189 | if(!args["d"].empty())
|
---|
| 190 | {
|
---|
[4984] | 191 | text_t docTop;
|
---|
| 192 | get_top(args["d"],docTop);
|
---|
| 193 |
|
---|
[4974] | 194 | recptproto* collectproto = protos->getrecptproto (args["c"], logout);
|
---|
| 195 | if (collectproto != NULL)
|
---|
| 196 | {
|
---|
| 197 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, args["c"], logout);
|
---|
| 198 |
|
---|
[5024] | 199 | if(cinfo->authenticate == "document")
|
---|
[4974] | 200 | {
|
---|
| 201 | // both are either commented out or uncomment and are empty
|
---|
[5024] | 202 | if (cinfo->public_documents.empty() && cinfo->private_documents.empty())
|
---|
[4974] | 203 | {
|
---|
| 204 | //deny everything
|
---|
| 205 | args["uan"] = "1";
|
---|
| 206 | args["ug"] = cinfo->auth_group;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
[5024] | 209 | // both public_documents and private_documents are turned on !
|
---|
| 210 | else if (!cinfo->public_documents.empty() && !cinfo->private_documents.empty())
|
---|
[4974] | 211 | {
|
---|
| 212 | //deny everything
|
---|
| 213 | args["uan"] = "1";
|
---|
| 214 | args["ug"] = cinfo->auth_group;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
[5179] | 217 | // if public_documents is set but this document isn't
|
---|
| 218 | // listed in it we need to authenticate
|
---|
| 219 | else if ((!cinfo->public_documents.empty()) &&
|
---|
| 220 | (cinfo->public_documents.find(docTop) == cinfo->public_documents.end()))
|
---|
| 221 | {
|
---|
| 222 | args["uan"] = "1";
|
---|
| 223 | args["ug"] = cinfo->auth_group;
|
---|
| 224 | }
|
---|
[4974] | 225 |
|
---|
[5179] | 226 | // if private_documents is set and this document is
|
---|
| 227 | // listed in it we need to authenticate
|
---|
| 228 | else if ((!cinfo->private_documents.empty()) &&
|
---|
| 229 | (cinfo->private_documents.find(docTop) != cinfo->private_documents.end()))
|
---|
| 230 | {
|
---|
| 231 | args["uan"] = "1";
|
---|
| 232 | args["ug"] = cinfo->auth_group;
|
---|
| 233 | }
|
---|
[4974] | 234 |
|
---|
| 235 | }
|
---|
| 236 | }
|
---|
| 237 | }
|
---|
| 238 | // check gc argument
|
---|
| 239 | int arg_gc = args.getintarg("gc");
|
---|
[2805] | 240 | if (arg_gc < 0 || arg_gc > 2) {
|
---|
[284] | 241 | logout << "Warning: \"gc\" argument out of range (" << arg_gc << ")\n";
|
---|
| 242 | cgiarginfo *gcinfo = argsinfo.getarginfo ("gc");
|
---|
| 243 | if (gcinfo != NULL) args["gc"] = gcinfo->argdefault;
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | // check gt argument (may be either 0, 1 or 2)
|
---|
| 247 | int arg_gt = args.getintarg("gt");
|
---|
| 248 | if (arg_gt != 0 && arg_gt != 1 && arg_gt != 2) {
|
---|
| 249 | logout << "Warning: \"gt\" argument out of range (" << arg_gt << ")\n";
|
---|
| 250 | cgiarginfo *gtinfo = argsinfo.getarginfo ("gt");
|
---|
| 251 | if (gtinfo != NULL) args["gt"] = gtinfo->argdefault;
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | // check hl argument
|
---|
| 255 | int arg_hl = args.getintarg("hl");
|
---|
[3322] | 256 | if (arg_hl < 0 || arg_hl > 2) {
|
---|
[284] | 257 | logout << "Warning: \"hl\" argument out of range (" << arg_hl << ")\n";
|
---|
| 258 | cgiarginfo *hlinfo = argsinfo.getarginfo ("hl");
|
---|
| 259 | if (hlinfo != NULL) args["hl"] = hlinfo->argdefault;
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | // check x argument
|
---|
| 263 | int arg_x = args.getintarg("x");
|
---|
| 264 | if (arg_x != 0 && arg_x != 1) {
|
---|
| 265 | logout << "Warning: \"x\" argument out of range (" << arg_x << ")\n";
|
---|
| 266 | cgiarginfo *xinfo = argsinfo.getarginfo ("x");
|
---|
| 267 | if (xinfo != NULL) args["x"] = xinfo->argdefault;
|
---|
| 268 | }
|
---|
| 269 |
|
---|
[1941] | 270 | //checks whether rd arg is valid
|
---|
| 271 | int arg_rd = args.getintarg("rd");
|
---|
| 272 | if (arg_rd != 0 && arg_rd != 1) {
|
---|
| 273 | logout << "Warning: \"rd\" argument out of range (" << arg_rd << ")\n";
|
---|
| 274 | cgiarginfo *rdinfo = argsinfo.getarginfo ("rd");
|
---|
| 275 | if (rdinfo != NULL) args["rd"] = rdinfo->argdefault;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 |
|
---|
[248] | 279 | return true;
|
---|
| 280 | }
|
---|
| 281 |
|
---|
[758] | 282 | void documentaction::get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos,
|
---|
| 283 | response_t &response,text_t &response_data,
|
---|
| 284 | ostream &logout) {
|
---|
[722] | 285 |
|
---|
[758] | 286 | if ((args["il"] == "w") && (!args["d"].empty())) {
|
---|
[722] | 287 |
|
---|
[758] | 288 | recptproto* collectproto = protos->getrecptproto (args["c"], logout);
|
---|
| 289 | if (collectproto != NULL) {
|
---|
| 290 |
|
---|
[722] | 291 | text_tset metadata;
|
---|
| 292 | FilterResponse_t filt_response;
|
---|
[758] | 293 | text_t top;
|
---|
[722] | 294 |
|
---|
| 295 | metadata.insert ("URL");
|
---|
[758] | 296 |
|
---|
| 297 | // get metadata for parent document
|
---|
| 298 | get_top (args["d"], top);
|
---|
[7432] | 299 | if (get_info (top, args["c"], args["l"], metadata, false, collectproto, filt_response, logout)) {
|
---|
[781] | 300 | text_t url = filt_response.docInfo[0].metadata["URL"].values[0];
|
---|
[758] | 301 |
|
---|
| 302 | response = location;
|
---|
| 303 | response_data = url;
|
---|
| 304 | return;
|
---|
| 305 | } else {
|
---|
| 306 | // error, no URL
|
---|
| 307 | logout << "Error: documentaction::get_cgihead_info failed on get_info" << endl;
|
---|
| 308 | }
|
---|
[722] | 309 | }
|
---|
[758] | 310 | }
|
---|
| 311 | response = content;
|
---|
| 312 | response_data = "text/html";
|
---|
[248] | 313 | }
|
---|
| 314 |
|
---|
[600] | 315 | // set_widthtspace calculates how wide the spaces in the nav bar should
|
---|
| 316 | // be and sets the appropriate macro
|
---|
[4774] | 317 | void documentaction::set_spacemacro (displayclass &disp, FilterResponse_t &response,
|
---|
| 318 | bool has_search_button) {
|
---|
[600] | 319 |
|
---|
| 320 | text_t width;
|
---|
| 321 | int twidth, swidth, iwidth = 0;
|
---|
| 322 |
|
---|
| 323 | int numc = response.docInfo.size();
|
---|
[649] | 324 | ResultDocInfo_tarray::iterator dochere = response.docInfo.begin();
|
---|
| 325 | ResultDocInfo_tarray::iterator docend = response.docInfo.end();
|
---|
[600] | 326 |
|
---|
[7433] | 327 | disp.expandstring (displayclass::defaultpackage, "_pagewidth_", width);
|
---|
[600] | 328 | twidth = width.getint();
|
---|
[9923] | 329 |
|
---|
[4774] | 330 | if (has_search_button) {
|
---|
| 331 | disp.expandstring ("query", "_searchwidth_", width);
|
---|
| 332 | iwidth += width.getint();
|
---|
| 333 | } else {
|
---|
| 334 | numc -= 1;
|
---|
| 335 | }
|
---|
[600] | 336 |
|
---|
| 337 | while (dochere != docend) {
|
---|
[649] | 338 | const text_t &title = (*dochere).metadata["Title"].values[0];
|
---|
[600] | 339 |
|
---|
| 340 | disp.expandstring ("document", "_" + title + "width_", width);
|
---|
[9923] | 341 | if (width == ("_" + title + "width_")) {
|
---|
[649] | 342 | disp.expandstring ("document", "_defaultwidth_", width);
|
---|
[9923] | 343 | }
|
---|
[600] | 344 | iwidth += width.getint();
|
---|
[9620] | 345 | ++dochere;
|
---|
[600] | 346 | }
|
---|
[9923] | 347 |
|
---|
[600] | 348 | if ((twidth - iwidth) < numc) swidth = 2;
|
---|
| 349 | else {
|
---|
| 350 | swidth = twidth - iwidth;
|
---|
| 351 | if (numc > 0) swidth = swidth / numc;
|
---|
| 352 | }
|
---|
[7433] | 353 | disp.setmacro ("widthtspace", displayclass::defaultpackage, swidth);
|
---|
[600] | 354 | }
|
---|
| 355 |
|
---|
[1419] | 356 | // set_navbarmacros sets _navigationbar_ and _httpbrowseXXX_ macros
|
---|
[649] | 357 | // reponse contains 1 metadata field (Title)
|
---|
| 358 | void documentaction::set_navbarmacros (displayclass &disp, FilterResponse_t &response,
|
---|
[4893] | 359 | bool has_search_button, cgiargsclass &args,
|
---|
| 360 | ColInfoResponse_t &cinfo) {
|
---|
[600] | 361 |
|
---|
| 362 |
|
---|
[4893] | 363 | bool use_pulldown = false;
|
---|
| 364 | text_tmap::iterator it = cinfo.format.find("NavigationBar");
|
---|
| 365 | if (it != cinfo.format.end()) {
|
---|
| 366 | if (it->second == "pulldown") {
|
---|
| 367 | use_pulldown = true;
|
---|
| 368 | }
|
---|
| 369 | }
|
---|
[600] | 370 |
|
---|
[4893] | 371 | text_t topparent;
|
---|
| 372 | text_t &arg_d = args["d"];
|
---|
| 373 | text_t navigationbar = "<!-- Navigation Bar -->\n";
|
---|
| 374 |
|
---|
| 375 | get_top (args["cl"], topparent);
|
---|
| 376 | int numc = response.docInfo.size();
|
---|
| 377 | ResultDocInfo_tarray::iterator dochere = response.docInfo.begin();
|
---|
| 378 | ResultDocInfo_tarray::iterator docend = response.docInfo.end();
|
---|
| 379 |
|
---|
| 380 | if (!use_pulldown) {
|
---|
| 381 | if (has_search_button) {
|
---|
[12229] | 382 | // search uses its own navtab, as it may be suppressed based on other args
|
---|
[11413] | 383 | navigationbar += "_navtabsearch_";
|
---|
[12174] | 384 | if (args["a"] == "q") {
|
---|
| 385 | navigationbar += "(selected)";
|
---|
| 386 | }
|
---|
[4893] | 387 | }
|
---|
[12174] | 388 |
|
---|
[10873] | 389 | if (has_search_button || numc == 0) navigationbar += "_navbarspacer_";
|
---|
[12174] | 390 |
|
---|
[4893] | 391 | bool first = true;
|
---|
| 392 | while (dochere != docend) {
|
---|
[12174] | 393 | if (!first) navigationbar += "_navbarspacer_";
|
---|
| 394 |
|
---|
| 395 | text_t title = (*dochere).metadata["Title"].values[0];
|
---|
| 396 |
|
---|
[12229] | 397 | navigationbar += "_navtab_(_httpbrowse"+(*dochere).OID+"_,"+title;
|
---|
[12174] | 398 | // if we are at this classifier
|
---|
| 399 | if (arg_d.empty() && ((*dochere).OID == topparent)) {
|
---|
[10873] | 400 | // don't link to this classifier as it is the current one
|
---|
[12174] | 401 | navigationbar += ",selected";
|
---|
[10873] | 402 | }
|
---|
[12174] | 403 | navigationbar += ")";
|
---|
[10873] | 404 |
|
---|
[12229] | 405 | // set the _httpbrowseCLX_ macro for this classification
|
---|
| 406 | disp.setmacro ("httpbrowse" + (*dochere).OID, displayclass::defaultpackage, "_httpdocument_&cl=" + (*dochere).OID);
|
---|
[9620] | 407 | ++dochere;
|
---|
[4893] | 408 | first = false;
|
---|
| 409 | }
|
---|
[12174] | 410 |
|
---|
[10873] | 411 | navigationbar += "\n<!-- End of Navigation Bar -->\n";
|
---|
[4774] | 412 |
|
---|
[4893] | 413 | } else {
|
---|
[4774] | 414 |
|
---|
[4893] | 415 | navigationbar = "<form method=\"get\" name=\"navform\">\n";
|
---|
| 416 | navigationbar += "<select name=\"navbar\" onChange=\"location.href=";
|
---|
| 417 | navigationbar += "document.navform.navbar.options[document.navform.navbar.selectedIndex].value\">\n";
|
---|
[600] | 418 |
|
---|
[4893] | 419 | if (args["a"] != "q" && args["cl"].empty()) {
|
---|
[5019] | 420 | navigationbar += "<option value=\"\" selected>_textselectpage_</option>\n";
|
---|
[4893] | 421 | }
|
---|
| 422 |
|
---|
| 423 | if (has_search_button) {
|
---|
| 424 | navigationbar += "<option value=\"_httpquery_\"";
|
---|
| 425 | if (args["a"] == "q") {
|
---|
| 426 | navigationbar += " selected";
|
---|
| 427 | }
|
---|
[11355] | 428 | navigationbar += ">_labelSearch_</option>\n";
|
---|
[4893] | 429 | }
|
---|
[649] | 430 |
|
---|
[4893] | 431 | while (dochere != docend) {
|
---|
| 432 | text_t title = dochere->metadata["Title"].values[0];
|
---|
[6645] | 433 |
|
---|
[11771] | 434 | navigationbar += "<option value=\"_httpdocument_&cl=" + dochere->OID + "\"";
|
---|
[4893] | 435 | if (topparent == dochere->OID) {
|
---|
| 436 | navigationbar += " selected";
|
---|
| 437 | }
|
---|
[12174] | 438 | navigationbar += ">_navlinktitle_(" + title + ")</option>\n";
|
---|
[9620] | 439 | ++dochere;
|
---|
[4893] | 440 | }
|
---|
[649] | 441 |
|
---|
[4893] | 442 | navigationbar += "</select>\n";
|
---|
| 443 | navigationbar += "</form>\n";
|
---|
| 444 | }
|
---|
[649] | 445 |
|
---|
[7433] | 446 | disp.setmacro ("navigationbar", displayclass::defaultpackage, navigationbar);
|
---|
[600] | 447 | }
|
---|
| 448 |
|
---|
[248] | 449 | // define all the macros which might be used by other actions
|
---|
| 450 | // to produce pages.
|
---|
[758] | 451 | void documentaction::define_external_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 452 | recptprotolistclass *protos, ostream &logout) {
|
---|
[248] | 453 |
|
---|
| 454 | // define_external_macros sets the following macros:
|
---|
| 455 |
|
---|
| 456 | // _navigationbar_ this is the navigation bar containing the search button
|
---|
| 457 | // and any classification buttons - it goes at the top of
|
---|
| 458 | // most pages. for now we're assuming that there'll always
|
---|
| 459 | // be a search button - we should probably check that there
|
---|
| 460 | // is a query action before making this assumption
|
---|
| 461 |
|
---|
| 462 | // _httpbrowseXXX_ the http macros for each classification (i.e. if there
|
---|
| 463 | // are Title and Creator classifications _httpbrowseTitle_
|
---|
| 464 | // and _httpbrowseCreator_ will be set
|
---|
| 465 |
|
---|
[600] | 466 | // _widthtspace_ the width of the spacers between buttons in navigation
|
---|
| 467 | // bar
|
---|
[438] | 468 |
|
---|
[870] | 469 | // _httpdocument_ has '&f=1' added if displaying document inside a frame
|
---|
[248] | 470 |
|
---|
[870] | 471 | // _gsdltop_ macro to replace _top targets with
|
---|
| 472 |
|
---|
| 473 | // _httppagehome_ overridden home url if html collections have own homepage
|
---|
| 474 |
|
---|
[11355] | 475 | // _usability_ macros for remote usability reporting: if
|
---|
| 476 | // _usabinterface_ "format Usability [multi|textonly|stepwise]" is in
|
---|
| 477 | // _usabilityscript_ collect.cfg
|
---|
[3880] | 478 |
|
---|
[12463] | 479 | // _versionnnum_ greenstone version number (hard-coded)
|
---|
[758] | 480 | // must have a valid collection server to continue
|
---|
[4936] | 481 |
|
---|
[758] | 482 | text_t &collection = args["c"];
|
---|
| 483 | if (collection.empty()) return;
|
---|
| 484 | recptproto *collectproto = protos->getrecptproto (collection, logout);
|
---|
[267] | 485 | if (collectproto == NULL) return;
|
---|
[758] | 486 |
|
---|
[1270] | 487 | if (recpt == NULL) {
|
---|
| 488 | logout << "ERROR (documentaction::define_external_macros): This action does not contain\n"
|
---|
| 489 | << " information about any receptionists. The method set_receptionist was\n"
|
---|
| 490 | << " probably not called from the module which instantiated this action.\n";
|
---|
| 491 | return;
|
---|
| 492 | }
|
---|
| 493 |
|
---|
[248] | 494 | outconvertclass text_t2ascii;
|
---|
| 495 | comerror_t err;
|
---|
| 496 | InfoFiltersResponse_t filterinfo;
|
---|
| 497 | FilterResponse_t response;
|
---|
[649] | 498 | text_tset metadata;
|
---|
[277] | 499 |
|
---|
[1347] | 500 | // get info on current collection and load up formatinfo
|
---|
| 501 | // I'd prefer not to do this here as we're getting
|
---|
| 502 | // collection info every time (and probably also getting
|
---|
| 503 | // it in other places some of the time) - One day I'll
|
---|
| 504 | // fix it ... maybe - Stefan.
|
---|
| 505 | ColInfoResponse_t cinfo;
|
---|
[870] | 506 |
|
---|
[1347] | 507 | collectproto->get_collectinfo (collection, cinfo, err, logout);
|
---|
| 508 | load_formatinfo (cinfo.format, args.getintarg("gt"));
|
---|
| 509 | // ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, collection, logout);
|
---|
| 510 | // if (cinfo == NULL) {
|
---|
| 511 | // logout << "ERROR (documentaction::define_external_macros): get_collectinfo_ptr returned NULL\n";
|
---|
| 512 | // return;
|
---|
| 513 | // }
|
---|
| 514 | //load_formatinfo (cinfo->format, args.getintarg("gt"));
|
---|
| 515 |
|
---|
[870] | 516 | if (formatinfo.DocumentUseHTML) {
|
---|
| 517 |
|
---|
| 518 | // frame stuff
|
---|
| 519 | if (args["fc"] == "1") {
|
---|
| 520 | text_t httpdocument;
|
---|
[7433] | 521 | disp.expandstring (displayclass::defaultpackage, "_httpdocument_", httpdocument);
|
---|
[10873] | 522 | httpdocument += "&f=1";
|
---|
[7433] | 523 | disp.setmacro ("httpdocument", displayclass::defaultpackage, httpdocument);
|
---|
| 524 | disp.setmacro ("gsdltop", displayclass::defaultpackage, "documenttop");
|
---|
[2422] | 525 | formatinfo.DocumentText = "[Text]";
|
---|
[870] | 526 | }
|
---|
[1348] | 527 | text_tmap::iterator it = cinfo.format.find ("homepage");
|
---|
| 528 | if (it != cinfo.format.end()) {
|
---|
[870] | 529 | text_t httppagehome;
|
---|
| 530 | if (get_link (args, protos, (*it).second, httppagehome, logout))
|
---|
[7433] | 531 | disp.setmacro ("httppagehome", displayclass::defaultpackage, httppagehome);
|
---|
[870] | 532 | }
|
---|
| 533 | }
|
---|
| 534 |
|
---|
[282] | 535 | // don't want navigation bar if page is 'detached'
|
---|
| 536 | if (!args.getintarg("x")) {
|
---|
[248] | 537 |
|
---|
[282] | 538 | collectproto->get_filterinfo (collection, filterinfo, err, logout);
|
---|
| 539 | if (err == noError) {
|
---|
| 540 | // check that there's a browse filter
|
---|
| 541 | if (filterinfo.filterNames.find ("BrowseFilter") != filterinfo.filterNames.end()) {
|
---|
[248] | 542 |
|
---|
[649] | 543 | metadata.insert ("Title");
|
---|
[405] | 544 | bool getParents = false;
|
---|
[7432] | 545 | get_children ("", collection, args["l"], metadata, getParents, collectproto, response, logout);
|
---|
[282] | 546 |
|
---|
[4774] | 547 | bool has_search_button = true;
|
---|
| 548 | collectproto->is_searchable(collection, has_search_button, err, logout);
|
---|
[11413] | 549 | if (err != noError) has_search_button = false;
|
---|
[4774] | 550 |
|
---|
[600] | 551 | // calculate width of spacers and set _widthtspace_ macro
|
---|
[4774] | 552 | if (args.getintarg("v") == 0) set_spacemacro (disp, response, has_search_button);
|
---|
[450] | 553 |
|
---|
[1419] | 554 | // set _navigationbar_ macro
|
---|
[4893] | 555 | set_navbarmacros (disp, response, has_search_button, args, cinfo);
|
---|
[928] | 556 |
|
---|
[248] | 557 | }
|
---|
[282] | 558 | } else {
|
---|
| 559 | logout << text_t2ascii
|
---|
| 560 | << "Error (documentaction::define_external_macros()) in call to get_filterinfo() "
|
---|
| 561 | << get_comerror_string (err);
|
---|
[248] | 562 | }
|
---|
| 563 | }
|
---|
[11355] | 564 |
|
---|
| 565 | // send feedback button and pages
|
---|
| 566 | text_tmap::iterator usability = cinfo.format.find("Usability");
|
---|
| 567 | if(usability!=cinfo.format.end()){
|
---|
| 568 | disp.setmacro("usability",displayclass::defaultpackage,"_usablink_");
|
---|
| 569 | disp.setmacro("usabinterface",displayclass::defaultpackage,("_usab"+(*usability).second+"_"));
|
---|
| 570 | disp.setmacro("usabilityscript", displayclass::defaultpackage, "_usabshowscript_");
|
---|
| 571 | }
|
---|
| 572 |
|
---|
[12463] | 573 | // version num
|
---|
| 574 | disp.setmacro("versionnum", displayclass::defaultpackage, GSDL_VERSION);
|
---|
| 575 |
|
---|
[248] | 576 | }
|
---|
| 577 |
|
---|
[870] | 578 | bool documentaction::get_link (cgiargsclass &args, recptprotolistclass *protos,
|
---|
| 579 | const text_t &inlink, text_t &outlink, ostream &logout) {
|
---|
| 580 |
|
---|
| 581 | FilterResponse_t response;
|
---|
| 582 | text_tset metadata;
|
---|
| 583 | metadata.insert ("section");
|
---|
| 584 |
|
---|
| 585 | // check current collection first
|
---|
| 586 | recptproto *collectproto = protos->getrecptproto (args["c"], logout);
|
---|
| 587 |
|
---|
[7432] | 588 | if (get_info (inlink, args["c"], args["l"], metadata, false, collectproto, response, logout)) {
|
---|
[870] | 589 | if (!response.docInfo[0].metadata["section"].values[0].empty()) {
|
---|
[11998] | 590 | #ifndef DOCHANDLE
|
---|
[10873] | 591 | outlink = "_httpdocument_&d=" + response.docInfo[0].metadata["section"].values[0];
|
---|
[11998] | 592 | #else
|
---|
| 593 | outlink = "_httpdocumenthandle_("+args["c"]+","+response.docInfo[0].metadata["section"].values[0]+")";
|
---|
| 594 | #endif
|
---|
| 595 |
|
---|
[870] | 596 | return true;
|
---|
| 597 | }
|
---|
| 598 | }
|
---|
| 599 |
|
---|
| 600 | // check all the other enabled collections
|
---|
| 601 |
|
---|
| 602 | if (args["ccs"] == "1" && !args["cc"].empty()) {
|
---|
| 603 | text_tarray collections;
|
---|
| 604 | splitchar (args["cc"].begin(), args["cc"].end(), ',', collections);
|
---|
| 605 |
|
---|
| 606 | text_tarray::const_iterator col_here = collections.begin();
|
---|
| 607 | text_tarray::const_iterator col_end = collections.end();
|
---|
| 608 |
|
---|
| 609 | while (col_here != col_end) {
|
---|
| 610 |
|
---|
| 611 | // don't need to check current collection again
|
---|
[9620] | 612 | if (*col_here == args["c"]) {++col_here; continue;}
|
---|
[870] | 613 |
|
---|
| 614 | collectproto = protos->getrecptproto (*col_here, logout);
|
---|
| 615 |
|
---|
[7432] | 616 | if (get_info (inlink, *col_here, args["l"], metadata, false, collectproto, response, logout)) {
|
---|
[870] | 617 | if (!response.docInfo[0].metadata["section"].values[0].empty()) {
|
---|
[11998] | 618 | #ifndef DOCHANDLE
|
---|
[10873] | 619 | outlink = "_httpdocument_&c=" + *col_here + "&d=" +
|
---|
[870] | 620 | response.docInfo[0].metadata["section"].values[0];
|
---|
[11998] | 621 | #else
|
---|
| 622 | outlink = "_httpdocumenthandle_("+*col_here+","+response.docInfo[0].metadata["section"].values[0]+")";
|
---|
| 623 | #endif
|
---|
| 624 |
|
---|
[870] | 625 | return true;
|
---|
| 626 | }
|
---|
| 627 | }
|
---|
[9620] | 628 | ++col_here;
|
---|
[870] | 629 | }
|
---|
| 630 | }
|
---|
| 631 | return false;
|
---|
| 632 | }
|
---|
| 633 |
|
---|
[464] | 634 | void documentaction::load_formatinfo (const text_tmap &colformat, int gt) {
|
---|
| 635 |
|
---|
| 636 | formatinfo.clear();
|
---|
| 637 | text_tmap::const_iterator format_here = colformat.begin();
|
---|
| 638 | text_tmap::const_iterator format_end = colformat.end();
|
---|
| 639 |
|
---|
| 640 | while (format_here != format_end) {
|
---|
[1079] | 641 | if (((*format_here).first == "DocumentImages") &&
|
---|
| 642 | ((*format_here).second == "true"))
|
---|
| 643 | formatinfo.DocumentImages = true;
|
---|
| 644 | else if (((*format_here).first == "DocumentTitles") &&
|
---|
| 645 | ((*format_here).second == "false"))
|
---|
| 646 | formatinfo.DocumentTitles = false;
|
---|
| 647 | else if ((*format_here).first == "DocumentHeading")
|
---|
| 648 | formatinfo.DocumentHeading = (*format_here).second;
|
---|
| 649 | else if (((*format_here).first == "DocumentContents") &&
|
---|
| 650 | ((*format_here).second == "false"))
|
---|
| 651 | formatinfo.DocumentContents = false;
|
---|
[464] | 652 | else if (((*format_here).first == "DocumentArrowsBottom") &&
|
---|
| 653 | ((*format_here).second == "false"))
|
---|
| 654 | formatinfo.DocumentArrowsBottom = false;
|
---|
[4868] | 655 | else if (((*format_here).first == "DocumentArrowsTop") &&
|
---|
| 656 | ((*format_here).second == "true"))
|
---|
| 657 | formatinfo.DocumentArrowsTop = true;
|
---|
[464] | 658 | else if ((*format_here).first == "DocumentButtons")
|
---|
| 659 | splitchar ((*format_here).second.begin(), (*format_here).second.end(),
|
---|
| 660 | '|', formatinfo.DocumentButtons);
|
---|
| 661 | else if ((*format_here).first == "DocumentText")
|
---|
[1941] | 662 | formatinfo.DocumentText = (*format_here).second;
|
---|
| 663 | else if ((*format_here).first == "RelatedDocuments")
|
---|
| 664 | formatinfo.RelatedDocuments = (*format_here).second;
|
---|
[870] | 665 | else if (((*format_here).first == "DocumentUseHTML") &&
|
---|
| 666 | ((*format_here).second == "true"))
|
---|
| 667 | formatinfo.DocumentUseHTML = true;
|
---|
[4972] | 668 | else if (((*format_here).first == "AllowExtendedOptions") &&
|
---|
| 669 | ((*format_here).second == "true"))
|
---|
| 670 | formatinfo.AllowExtendedOptions = true;
|
---|
[649] | 671 | else
|
---|
| 672 | formatinfo.formatstrings[(*format_here).first] = (*format_here).second;
|
---|
[870] | 673 |
|
---|
[9620] | 674 | ++format_here;
|
---|
[464] | 675 | }
|
---|
| 676 |
|
---|
| 677 | // never want arrows when text is expanded
|
---|
[4868] | 678 | if (gt) {
|
---|
| 679 | formatinfo.DocumentArrowsBottom = false;
|
---|
| 680 | formatinfo.DocumentArrowsTop = false;
|
---|
| 681 | }
|
---|
[464] | 682 | }
|
---|
| 683 |
|
---|
| 684 |
|
---|
[248] | 685 | // define all the macros which are related to pages generated
|
---|
[443] | 686 | // by this action. we also load up the formatinfo structure
|
---|
| 687 | // here (it's used in do_action as well as here)
|
---|
[758] | 688 | void documentaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 689 | recptprotolistclass *protos, ostream &logout) {
|
---|
[464] | 690 |
|
---|
[248] | 691 | // define_internal_macros sets the following macros:
|
---|
[464] | 692 |
|
---|
[277] | 693 | // _pagetitle_ the title to be displayed at the top of the browser window
|
---|
| 694 |
|
---|
[248] | 695 | // _imagethispage_ the title image to be displayed at top right of page
|
---|
| 696 |
|
---|
[4868] | 697 | // _navarrowsbottom_ this may be overridden to "" when format option
|
---|
[448] | 698 | // DocumentArrowsBottom is false
|
---|
| 699 |
|
---|
[4868] | 700 | // _navarrowstop_ likewise for DocumentArrowsTop
|
---|
| 701 |
|
---|
| 702 | // _httpprevarrow_ links to next and previous sections of document - used
|
---|
| 703 | // _httpnextarrow_ by DocumentArrowsBottom
|
---|
| 704 |
|
---|
[248] | 705 | // _header_ the header macro is overridden if we're not at a top level
|
---|
| 706 | // classification to remove the title block
|
---|
[257] | 707 |
|
---|
[300] | 708 | // _thisOID_ the OID (directory) of the current document - this corresponds
|
---|
| 709 | // to the archivedir metadata element
|
---|
| 710 |
|
---|
[12943] | 711 | // _documentheader_ Custom header info for the specified document
|
---|
[758] | 712 | // must have a valid collection server to continue
|
---|
[4936] | 713 |
|
---|
| 714 | text_t &collection = args["c"];
|
---|
[758] | 715 | if (collection.empty()) return;
|
---|
| 716 | recptproto *collectproto = protos->getrecptproto (collection, logout);
|
---|
[267] | 717 | if (collectproto == NULL) return;
|
---|
[758] | 718 |
|
---|
[649] | 719 | text_tset metadata;
|
---|
[248] | 720 | FilterResponse_t response;
|
---|
[277] | 721 | text_t &arg_d = args["d"];
|
---|
| 722 | text_t &arg_cl = args["cl"];
|
---|
| 723 |
|
---|
[4868] | 724 | if (!formatinfo.DocumentArrowsBottom) {
|
---|
| 725 | disp.setmacro("navarrowsbottom", "document", "");
|
---|
| 726 | } else if (!formatinfo.DocumentArrowsBottom) {
|
---|
| 727 | disp.setmacro("navarrowstop", "document", "");
|
---|
| 728 | }
|
---|
[448] | 729 |
|
---|
[4868] | 730 | if (!arg_d.empty() && (formatinfo.DocumentArrowsBottom || formatinfo.DocumentArrowsTop)) {
|
---|
| 731 | // set _httpprevarrow_ and _httpnextarrow_
|
---|
| 732 | set_arrow_macros (args, collectproto, disp, logout);
|
---|
| 733 | }
|
---|
| 734 |
|
---|
[649] | 735 | metadata.insert ("Title");
|
---|
[12943] | 736 | metadata.insert ("gs.DocumentHeader");
|
---|
| 737 | metadata.insert ("DocumentHeader");
|
---|
| 738 |
|
---|
[738] | 739 | bool fulltoc = false;
|
---|
| 740 |
|
---|
| 741 | if (args["cl"] != "search") {
|
---|
| 742 | // see if there's a FullTOC string
|
---|
| 743 | text_t cl_top, full_toc;
|
---|
| 744 | get_top (arg_cl, cl_top);
|
---|
| 745 | if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
|
---|
| 746 | if (full_toc == "true") fulltoc = true;
|
---|
| 747 | }
|
---|
[248] | 748 |
|
---|
[738] | 749 | if (!arg_d.empty() && !fulltoc) {
|
---|
[248] | 750 | // we're at document level
|
---|
[649] | 751 |
|
---|
| 752 | metadata.insert ("archivedir");
|
---|
[1347] | 753 |
|
---|
[2113] | 754 | comerror_t err;
|
---|
[1347] | 755 | OptionValue_tarray options;
|
---|
[2646] | 756 | // we need to do the query again for the z3950proto
|
---|
[2113] | 757 | if (collectproto->get_protocol_name(err)=="z3950proto") {
|
---|
[1347] | 758 | OptionValue_t opt;
|
---|
[2646] | 759 | opt.name="Term";opt.value=args["q"];options.push_back(opt);
|
---|
| 760 | opt.name="QueryType";
|
---|
| 761 | opt.value=(args.getintarg("t")) ? "ranked" : "boolean";
|
---|
[1347] | 762 | options.push_back(opt);
|
---|
[2646] | 763 | opt.name="Index";opt.value=args["h"];options.push_back(opt);
|
---|
[1347] | 764 | }
|
---|
[1941] | 765 |
|
---|
| 766 | //do not display relation metadata
|
---|
| 767 | disp.setmacro ("relateddoc", "document", "");
|
---|
| 768 |
|
---|
| 769 | //if preferences indicate relevant docs should be collected
|
---|
| 770 | //and there is no particular format specified then display
|
---|
| 771 | //this default format.
|
---|
| 772 | if(args["rd"] == "1" && formatinfo.RelatedDocuments.empty()){
|
---|
[1347] | 773 |
|
---|
[7441] | 774 | text_t relation = g_EmptyText; //string for displaying relation metadata
|
---|
[1941] | 775 |
|
---|
| 776 | //call function in formattools.cpp which will return the text of the
|
---|
| 777 | //related documents in a vertical list. This is the default format.
|
---|
[4936] | 778 |
|
---|
[7432] | 779 | if (get_info (arg_d, collection, args["l"], metadata, options, false, collectproto, response, logout))
|
---|
[1941] | 780 | relation += get_related_docs(collection, collectproto, response.docInfo[0], logout);
|
---|
| 781 |
|
---|
| 782 | //set macro to be the related document string
|
---|
[4936] | 783 |
|
---|
[1941] | 784 | disp.setmacro ("relateddoc", "document", relation);
|
---|
| 785 | }
|
---|
| 786 |
|
---|
| 787 |
|
---|
[277] | 788 | // get metadata for this document and it's parents
|
---|
[7432] | 789 | if (get_info (arg_d, collection, args["l"], metadata, options,
|
---|
[1347] | 790 | true, collectproto, response, logout)) {
|
---|
[1941] | 791 |
|
---|
[248] | 792 | disp.setmacro ("header", "document", "_textheader_");
|
---|
[669] | 793 | text_tarray pagetitlearray;
|
---|
| 794 | if (!response.docInfo[0].metadata["Title"].values[0].empty())
|
---|
| 795 | pagetitlearray.push_back (response.docInfo[0].metadata["Title"].values[0]);
|
---|
[1941] | 796 |
|
---|
[870] | 797 | if (args["gt"] != "1") {
|
---|
[669] | 798 | MetadataInfo_t *parenttitle = response.docInfo[0].metadata["Title"].parent;
|
---|
| 799 | while (parenttitle != NULL) {
|
---|
| 800 | if (!parenttitle->values[0].empty())
|
---|
| 801 | pagetitlearray.push_back (parenttitle->values[0]);
|
---|
| 802 | parenttitle = parenttitle->parent;
|
---|
[284] | 803 | }
|
---|
[277] | 804 | }
|
---|
[669] | 805 | reverse (pagetitlearray.begin(), pagetitlearray.end());
|
---|
| 806 | text_t pagetitle;
|
---|
| 807 | joinchar (pagetitlearray, ": ", pagetitle);
|
---|
[6936] | 808 | // remove html tags from the title
|
---|
| 809 | text_t::iterator open_tag=pagetitle.begin();
|
---|
| 810 | while (open_tag < pagetitle.end()) {
|
---|
| 811 | if (*open_tag == '<') {
|
---|
| 812 | text_t::iterator close_tag=open_tag+1;
|
---|
| 813 | text_t::iterator donechar=pagetitle.end();
|
---|
| 814 | while (close_tag < donechar) {
|
---|
| 815 | if (*close_tag == '>')
|
---|
| 816 | break;
|
---|
| 817 | ++close_tag;
|
---|
| 818 | }
|
---|
| 819 | if (close_tag < donechar) // remove this html tag, replace with space
|
---|
| 820 | *close_tag=' ';
|
---|
| 821 | pagetitle.erase(open_tag, close_tag);
|
---|
| 822 | }
|
---|
| 823 | ++open_tag;
|
---|
| 824 | }
|
---|
[277] | 825 | disp.setmacro ("pagetitle", "document", pagetitle);
|
---|
[669] | 826 |
|
---|
[12943] | 827 | // custom header info
|
---|
| 828 | text_t custom_header;
|
---|
| 829 | if (is_top (arg_d)) {
|
---|
| 830 | custom_header = response.docInfo[0].metadata["gs.DocumentHeader"].values[0];
|
---|
| 831 | if (custom_header.empty()) {
|
---|
| 832 | // try ex header
|
---|
| 833 | custom_header = response.docInfo[0].metadata["DocumentHeader"].values[0];
|
---|
| 834 | }
|
---|
| 835 | } else {
|
---|
| 836 | MetadataInfo_t *parentch = response.docInfo[0].metadata["gs.DocumentHeader"].parent;
|
---|
| 837 | while (parentch != NULL) {
|
---|
| 838 | custom_header = parentch->values[0];
|
---|
| 839 | parentch = parentch->parent;
|
---|
| 840 | }
|
---|
| 841 | if (custom_header.empty()) {
|
---|
| 842 | // try ex header
|
---|
| 843 | MetadataInfo_t *parentch = response.docInfo[0].metadata["DocumentHeader"].parent;
|
---|
| 844 | while (parentch != NULL) {
|
---|
| 845 | custom_header = parentch->values[0];
|
---|
| 846 | parentch = parentch->parent;
|
---|
| 847 | }
|
---|
| 848 | }
|
---|
| 849 | }
|
---|
| 850 | if (!custom_header.empty()) {
|
---|
| 851 | disp.setmacro("documentheader", "document", custom_header);
|
---|
| 852 | }
|
---|
| 853 |
|
---|
[669] | 854 | if (is_top (arg_d))
|
---|
[7433] | 855 | disp.setmacro ("thisOID", displayclass::defaultpackage, dm_safe(response.docInfo[0].metadata["archivedir"].values[0]));
|
---|
[669] | 856 | else {
|
---|
| 857 | MetadataInfo_t *parentad = response.docInfo[0].metadata["archivedir"].parent;
|
---|
| 858 | text_t thisOID;
|
---|
| 859 | while (parentad != NULL) {
|
---|
| 860 | thisOID = parentad->values[0];
|
---|
| 861 | parentad = parentad->parent;
|
---|
| 862 | }
|
---|
[7433] | 863 | disp.setmacro ("thisOID", displayclass::defaultpackage, dm_safe(thisOID));
|
---|
[669] | 864 | }
|
---|
[248] | 865 | }
|
---|
| 866 | } else {
|
---|
[277] | 867 | if (!arg_cl.empty()) {
|
---|
[248] | 868 |
|
---|
[9917] | 869 | // create the currentnodevalue macro - this is the value of the node
|
---|
| 870 | // in the hierarchy that is currently open.
|
---|
| 871 | if (get_info (arg_cl, collection, args["l"], metadata, false, collectproto, response, logout)) {
|
---|
| 872 | text_t &title = response.docInfo[0].metadata["Title"].values[0];
|
---|
| 873 | disp.setmacro ("currentnodevalue", "document", title);
|
---|
| 874 | }
|
---|
[248] | 875 | // get metadata for top level classification
|
---|
[257] | 876 | text_t classtop;
|
---|
[277] | 877 | get_top (arg_cl, classtop);
|
---|
[1804] | 878 | metadata.insert ("childtype");
|
---|
[2017] | 879 | metadata.insert ("parameters");
|
---|
[1804] | 880 |
|
---|
[7432] | 881 | if (get_info (classtop, collection, args["l"], metadata, false, collectproto, response, logout)) {
|
---|
[248] | 882 |
|
---|
[649] | 883 | text_t &title = response.docInfo[0].metadata["Title"].values[0];
|
---|
| 884 | bool unknown = false;
|
---|
[257] | 885 |
|
---|
[11152] | 886 | // test if we have macros defined for this classification's
|
---|
| 887 | // metadata name - if not we'll just display the name
|
---|
[649] | 888 | text_t tmp;
|
---|
[11152] | 889 | text_t macroname="_label" + title + "_";
|
---|
| 890 | disp.expandstring ("Global", macroname, tmp);
|
---|
[10873] | 891 | if (tmp == macroname) unknown = true; // it wasn't expanded
|
---|
[604] | 892 |
|
---|
[649] | 893 | if (unknown) {
|
---|
| 894 | disp.setmacro ("pagetitle", "document", title);
|
---|
| 895 | } else {
|
---|
[11152] | 896 | disp.setmacro ("pagetitle", "document", macroname);
|
---|
[649] | 897 | }
|
---|
[11158] | 898 | /* for ns4/image layout compatibility. when this is no longer
|
---|
| 899 | * needed, set imagethispage to _label+title+_ */
|
---|
| 900 | text_t titlemacroname="_titleimage" + title + "_";
|
---|
| 901 | disp.expandstring ("Global", titlemacroname, tmp);
|
---|
| 902 | if (tmp == titlemacroname) { /* _titleimage$META_ isn't defined */
|
---|
| 903 | if (!unknown) /* _label$META_ is defined */
|
---|
| 904 | disp.setmacro ("imagethispage", "document", macroname);
|
---|
| 905 | else
|
---|
| 906 | disp.setmacro ("imagethispage", "document", title);
|
---|
| 907 | } else { /* _titleimage$META_ is defined */
|
---|
| 908 | disp.setmacro ("imagethispage", "document", titlemacroname);
|
---|
| 909 | }
|
---|
[1804] | 910 |
|
---|
[1941] | 911 | //if the document is not a document from a collection
|
---|
| 912 | //we must set the macro to be an empty string
|
---|
| 913 | disp.setmacro ("relateddoc", "document", "");
|
---|
| 914 |
|
---|
[6811] | 915 | // Add macros specific to the Collage/Phind classifiers
|
---|
[1804] | 916 | text_t &childtype = response.docInfo[0].metadata["childtype"].values[0];
|
---|
[6811] | 917 | if (childtype == "Collage") {
|
---|
| 918 |
|
---|
| 919 | text_t::iterator a = arg_cl.begin();
|
---|
| 920 | text_t::iterator b = arg_cl.end();
|
---|
| 921 |
|
---|
| 922 | bool collage = true;
|
---|
| 923 | while (a != b) {
|
---|
| 924 | if (*a == 46) collage = false;
|
---|
[9620] | 925 | ++a;
|
---|
[6811] | 926 | }
|
---|
| 927 |
|
---|
[7333] | 928 | if (collage) {
|
---|
[6811] | 929 | disp.setmacro ("collageclassifier", "document", "_collageapplet_");
|
---|
[7333] | 930 |
|
---|
| 931 | // Next, macros that control the way the classifier is displayed
|
---|
| 932 | text_t parameters = response.docInfo[0].metadata["parameters"].values[0];
|
---|
| 933 |
|
---|
| 934 | // extract key=value pairs and set as macros
|
---|
| 935 | text_t::iterator here = parameters.begin();
|
---|
| 936 | text_t::iterator end = parameters.end();
|
---|
| 937 | text_t key, value;
|
---|
| 938 |
|
---|
| 939 | while (here != end) {
|
---|
| 940 | // get the next key and value pair
|
---|
| 941 | here = getdelimitstr (here, end, '=', key);
|
---|
| 942 | here = getdelimitstr (here, end, ';', value);
|
---|
| 943 |
|
---|
| 944 | // store this key=value pair
|
---|
| 945 | if (!key.empty() && !value.empty()) {
|
---|
| 946 | disp.setmacro ("collage"+key, "document", value);
|
---|
| 947 | }
|
---|
| 948 | }
|
---|
| 949 |
|
---|
| 950 |
|
---|
| 951 | }
|
---|
[6811] | 952 | }
|
---|
| 953 |
|
---|
[1804] | 954 | if (childtype == "Phind") {
|
---|
[2017] | 955 |
|
---|
| 956 | // First, a macro to display the phind classifier
|
---|
[1804] | 957 | disp.setmacro ("phindclassifier", "document", "_phindapplet_");
|
---|
[2017] | 958 |
|
---|
| 959 | // Next, macros that control the way the classifier is displayed
|
---|
| 960 | text_t parameters = response.docInfo[0].metadata["parameters"].values[0];
|
---|
| 961 |
|
---|
| 962 | // extract key=value pairs and set as macros
|
---|
| 963 | text_t::iterator here = parameters.begin();
|
---|
| 964 | text_t::iterator end = parameters.end();
|
---|
| 965 | text_t key, value;
|
---|
| 966 |
|
---|
| 967 | while (here != end) {
|
---|
| 968 | // get the next key and value pair
|
---|
| 969 | here = getdelimitstr (here, end, '=', key);
|
---|
| 970 | here = getdelimitstr (here, end, ';', value);
|
---|
| 971 |
|
---|
| 972 | // store this key=value pair
|
---|
| 973 | if (!key.empty() && !value.empty()) {
|
---|
| 974 | disp.setmacro (key, "document", value);
|
---|
| 975 | }
|
---|
| 976 | }
|
---|
| 977 | } // end if (childtype == "Phind")
|
---|
[248] | 978 | }
|
---|
[2017] | 979 | } // end if (!arg_cl.empty()) {
|
---|
[248] | 980 | }
|
---|
| 981 | }
|
---|
| 982 |
|
---|
[464] | 983 |
|
---|
[12044] | 984 | bool documentaction::do_action(cgiargsclass &args, recptprotolistclass *protos,
|
---|
| 985 | browsermapclass *browsers, displayclass &disp,
|
---|
| 986 | outconvertclass &outconvert, ostream &textout,
|
---|
| 987 | ostream &logout)
|
---|
| 988 | {
|
---|
[758] | 989 | // must have a valid collection server
|
---|
| 990 | recptproto *collectproto = protos->getrecptproto (args["c"], logout);
|
---|
[267] | 991 | if (collectproto == NULL) {
|
---|
| 992 | logout << "documentaction::do_action called with NULL collectproto\n";
|
---|
| 993 | textout << outconvert << disp << "_document:header_\n"
|
---|
| 994 | << "Error: Attempt to get document without setting collection\n"
|
---|
| 995 | << "_document:footer_\n";
|
---|
| 996 | } else {
|
---|
[758] | 997 |
|
---|
[649] | 998 | text_t OID = args["d"];
|
---|
| 999 | if (OID.empty()) OID = args["cl"];
|
---|
| 1000 | if (OID.empty()) {
|
---|
| 1001 | textout << outconvert << disp << "Document contains no data_document:footer_\n";
|
---|
| 1002 | return true;
|
---|
| 1003 | }
|
---|
[420] | 1004 |
|
---|
[1941] | 1005 |
|
---|
[1991] | 1006 | if (formatinfo.DocumentUseHTML && !args["d"].empty()) {
|
---|
[870] | 1007 |
|
---|
[1991] | 1008 | if (args["f"] == "1") {
|
---|
| 1009 | textout << outconvert << disp
|
---|
| 1010 | << "<html><head></head>\n"
|
---|
| 1011 | << "<frameset rows=\"68,*\" noresize border=0>\n"
|
---|
| 1012 | << "<frame scrolling=no frameborder=0 src=\"_gwcgi_?_optsite_e=_compressedoptions_&a=p&p=nav\">\n"
|
---|
[11998] | 1013 | #ifndef DOCHANDLE
|
---|
[1991] | 1014 | << "<frame name=\"documenttop\" frameborder=0 src=\"_gwcgi_?_optsite_e=_compressedoptions_&a=d&d="
|
---|
| 1015 | << args["d"] << "\">"
|
---|
[11998] | 1016 | #else
|
---|
| 1017 | << "<frame name=\"documenttop\" frameborder=0 src=\"_httpdocumenthandle_("
|
---|
| 1018 | << args["c"] << "," << args["d"] << ")\">"
|
---|
| 1019 | #endif
|
---|
[1991] | 1020 | << "<noframes>\n"
|
---|
| 1021 | << "<p>You must have a frame enabled browser to view this.</p>\n"
|
---|
| 1022 | << "</noframes>\n"
|
---|
| 1023 | << "</frameset>\n"
|
---|
| 1024 | << "</html>\n";
|
---|
| 1025 | } else {
|
---|
[4936] | 1026 | output_document (OID, args, collectproto, browsers, disp, outconvert, textout, logout);
|
---|
[870] | 1027 | }
|
---|
[1991] | 1028 | return true;
|
---|
[870] | 1029 | }
|
---|
| 1030 |
|
---|
[1941] | 1031 |
|
---|
[267] | 1032 | textout << outconvert << disp << "_document:header_\n"
|
---|
| 1033 | << "_document:content_\n";
|
---|
[1079] | 1034 |
|
---|
| 1035 | // output the table of contents
|
---|
[12044] | 1036 | browsetoolsclass b;
|
---|
| 1037 | b.output_toc(args, browsers, formatinfo, collectproto,
|
---|
| 1038 | disp, outconvert, textout, logout);
|
---|
[1941] | 1039 |
|
---|
[4868] | 1040 | if (formatinfo.DocumentArrowsTop && !args["d"].empty()) {
|
---|
| 1041 | textout << outconvert << disp << "_document:navarrowstop_\n";
|
---|
| 1042 | }
|
---|
| 1043 |
|
---|
[1941] | 1044 | //output the related documents (may be the empty string)
|
---|
| 1045 | //will not output the docs if a format string is specified
|
---|
| 1046 | textout << outconvert << disp << "_document:relateddoc_\n";
|
---|
| 1047 |
|
---|
[284] | 1048 | // output the document text
|
---|
[3087] | 1049 | if (!args["d"].empty()) {
|
---|
[3666] | 1050 | textout << outconvert << "<p>\n";
|
---|
[4936] | 1051 | output_document (OID, args, collectproto, browsers, disp, outconvert, textout, logout);
|
---|
[3087] | 1052 | }
|
---|
[284] | 1053 |
|
---|
| 1054 | textout << outconvert << disp << "_document:footer_\n";
|
---|
| 1055 | }
|
---|
| 1056 | return true;
|
---|
| 1057 | }
|
---|
| 1058 |
|
---|
[649] | 1059 | void documentaction::output_text (ResultDocInfo_t &docinfo, format_t *formatlistptr,
|
---|
[443] | 1060 | const TermInfo_tarray &terminfo, const text_t &OID,
|
---|
[649] | 1061 | bool highlight, int hastxt, int wanttext,
|
---|
[4936] | 1062 | text_t &collection, recptproto *collectproto,
|
---|
| 1063 | browsermapclass *browsers, displayclass &disp,
|
---|
| 1064 | outconvertclass &outconvert, ostream &textout,
|
---|
| 1065 | ostream &logout, cgiargsclass &args) {
|
---|
[443] | 1066 |
|
---|
| 1067 | DocumentRequest_t docrequest;
|
---|
| 1068 | DocumentResponse_t docresponse;
|
---|
| 1069 | comerror_t err;
|
---|
[649] | 1070 | if (hastxt == 1) {
|
---|
[443] | 1071 |
|
---|
| 1072 | if (wanttext) {
|
---|
| 1073 | // get the text
|
---|
| 1074 | docrequest.OID = OID;
|
---|
| 1075 | collectproto->get_document (collection, docrequest, docresponse, err, logout);
|
---|
| 1076 |
|
---|
| 1077 | // cut down on overhead by not using formattools if we only want the text
|
---|
| 1078 | // (wanttext will equal 2 if we want text and other stuff too)
|
---|
| 1079 | if (wanttext == 1)
|
---|
[3322] | 1080 | if (highlight) {
|
---|
| 1081 | highlighttext(docresponse.doc, args, terminfo, disp, outconvert, textout);
|
---|
| 1082 | } else {
|
---|
[443] | 1083 | textout << outconvert << disp << docresponse.doc;
|
---|
[3322] | 1084 | }
|
---|
[443] | 1085 | }
|
---|
| 1086 |
|
---|
| 1087 | if (wanttext != 1) {
|
---|
[4906] | 1088 | text_tmap options;
|
---|
| 1089 | options["text"] = docresponse.doc;
|
---|
[4936] | 1090 |
|
---|
[4972] | 1091 | if (formatinfo.AllowExtendedOptions) {
|
---|
[12044] | 1092 | browsetoolsclass b;
|
---|
| 1093 | b.load_extended_options(options, args, browsers, formatinfo,
|
---|
| 1094 | collectproto, disp, outconvert, logout);
|
---|
[4936] | 1095 | }
|
---|
| 1096 |
|
---|
[1443] | 1097 | text_t doctext
|
---|
[4906] | 1098 | = get_formatted_string (collection, collectproto, docinfo, disp,
|
---|
| 1099 | formatlistptr, options, logout);
|
---|
[443] | 1100 |
|
---|
[3322] | 1101 | if (highlight) {
|
---|
| 1102 | highlighttext(doctext, args, terminfo, disp, outconvert, textout);
|
---|
| 1103 | } else {
|
---|
[443] | 1104 | textout << outconvert << disp << doctext;
|
---|
[3322] | 1105 | }
|
---|
[443] | 1106 | }
|
---|
| 1107 | }
|
---|
| 1108 | }
|
---|
| 1109 |
|
---|
| 1110 |
|
---|
[284] | 1111 | void documentaction::output_document (const text_t &OID, cgiargsclass &args,
|
---|
[4936] | 1112 | recptproto *collectproto, browsermapclass *browsers,
|
---|
| 1113 | displayclass &disp, outconvertclass &outconvert,
|
---|
| 1114 | ostream &textout, ostream &logout) {
|
---|
[284] | 1115 | FilterResponse_t inforesponse;
|
---|
| 1116 | FilterResponse_t queryresponse;
|
---|
[649] | 1117 | text_tset metadata;
|
---|
[443] | 1118 | bool getParents = false;
|
---|
[284] | 1119 | bool highlight = false;
|
---|
[443] | 1120 | int wanttext = 0;
|
---|
[284] | 1121 | int arg_gt = args.getintarg("gt");
|
---|
| 1122 | text_t &collection = args["c"];
|
---|
[267] | 1123 |
|
---|
[284] | 1124 | // if we have a query string and highlighting is turned on we need
|
---|
| 1125 | // to redo the query to get the terms for highlighting
|
---|
[4936] | 1126 |
|
---|
[284] | 1127 | if (!args["q"].empty() && args.getintarg("hl")) {
|
---|
[6584] | 1128 |
|
---|
| 1129 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, collection, logout);
|
---|
| 1130 | bool segment = false;
|
---|
| 1131 | if (cinfo != NULL) {
|
---|
| 1132 | segment = cinfo->isSegmented;
|
---|
| 1133 | }
|
---|
[284] | 1134 | FilterRequest_t request;
|
---|
[758] | 1135 | comerror_t err;
|
---|
[284] | 1136 | request.filterResultOptions = FRmatchTerms;
|
---|
[758] | 1137 | text_t formattedstring = args["q"];
|
---|
[6584] | 1138 | format_querystring (formattedstring, args.getintarg("b"), segment);
|
---|
[758] | 1139 | set_queryfilter_options (request, formattedstring, args);
|
---|
[8715] | 1140 | args["q"] = formattedstring; // need to set this here for phrase
|
---|
| 1141 | // highlighting, where we look at the querystring
|
---|
[758] | 1142 | collectproto->filter (args["c"], request, queryresponse, err, logout);
|
---|
| 1143 | if (err != noError) {
|
---|
| 1144 | outconvertclass text_t2ascii;
|
---|
| 1145 | logout << text_t2ascii
|
---|
| 1146 | << "documentaction::output_document: call to QueryFilter failed "
|
---|
| 1147 | << "for " << args["c"] << " collection (" << get_comerror_string (err) << ")\n";
|
---|
| 1148 | highlight = false;
|
---|
| 1149 | } else {
|
---|
[284] | 1150 | highlight = true;
|
---|
[758] | 1151 | }
|
---|
[284] | 1152 | }
|
---|
| 1153 |
|
---|
[443] | 1154 | format_t *formatlistptr = new format_t();
|
---|
| 1155 | parse_formatstring (formatinfo.DocumentText, formatlistptr, metadata, getParents);
|
---|
[431] | 1156 |
|
---|
[649] | 1157 | metadata.insert ("hastxt");
|
---|
| 1158 | metadata.insert ("haschildren");
|
---|
[2422] | 1159 |
|
---|
[443] | 1160 | if (formatinfo.DocumentText == "[Text]")
|
---|
| 1161 | wanttext = 1;
|
---|
| 1162 | else {
|
---|
| 1163 | char *docformat = formatinfo.DocumentText.getcstr();
|
---|
| 1164 | if (strstr (docformat, "[Text]") != NULL)
|
---|
| 1165 | wanttext = 2;
|
---|
[9633] | 1166 | delete []docformat;
|
---|
[443] | 1167 | }
|
---|
[267] | 1168 |
|
---|
[11144] | 1169 | textout << outconvert << "<div class=\"documenttext\">\n";
|
---|
| 1170 |
|
---|
[7432] | 1171 | if (get_info (OID, collection, args["l"], metadata, getParents, collectproto, inforesponse, logout)) {
|
---|
[649] | 1172 | int hastxt = inforesponse.docInfo[0].metadata["hastxt"].values[0].getint();
|
---|
| 1173 | int haschildren = inforesponse.docInfo[0].metadata["haschildren"].values[0].getint();
|
---|
[669] | 1174 |
|
---|
[284] | 1175 | if (arg_gt == 0) {
|
---|
[443] | 1176 | output_text (inforesponse.docInfo[0], formatlistptr, queryresponse.termInfo,
|
---|
| 1177 | OID, highlight, hastxt, wanttext, collection, collectproto,
|
---|
[4936] | 1178 | browsers, disp, outconvert, textout, logout, args);
|
---|
[443] | 1179 |
|
---|
[284] | 1180 | } else {
|
---|
[443] | 1181 |
|
---|
| 1182 | ResultDocInfo_t thisdocinfo = inforesponse.docInfo[0];
|
---|
[267] | 1183 |
|
---|
[284] | 1184 | // text is to be expanded
|
---|
| 1185 | text_t exOID = OID;
|
---|
[649] | 1186 | if (haschildren != 1) exOID = get_parent (OID);
|
---|
[443] | 1187 | if (exOID.empty()) exOID = OID;
|
---|
[267] | 1188 |
|
---|
[284] | 1189 | // if we're not in a document (i.e. we're in a top level classification)
|
---|
[649] | 1190 | // we need to pass "is_classify = true" to get_contents so that it
|
---|
[284] | 1191 | // doesn't recurse all the way through each document in the classification
|
---|
[649] | 1192 | bool is_classify = false;
|
---|
| 1193 | if (args["d"].empty()) is_classify = true;
|
---|
[284] | 1194 |
|
---|
[7432] | 1195 | get_contents (exOID, is_classify, metadata, collection, args["l"],
|
---|
[443] | 1196 | collectproto, inforesponse, logout);
|
---|
[267] | 1197 |
|
---|
[649] | 1198 | ResultDocInfo_tarray::iterator sechere = inforesponse.docInfo.begin();
|
---|
| 1199 | ResultDocInfo_tarray::iterator secend = inforesponse.docInfo.end();
|
---|
[1860] | 1200 |
|
---|
[284] | 1201 | if (arg_gt == 1) {
|
---|
| 1202 | // check if there are more than 10 sections containing text to be expanded -
|
---|
| 1203 | // if there are output warning message - this isn't a great way to do this
|
---|
| 1204 | // since the sections may be very large or very small - one day I'll fix it
|
---|
| 1205 | // -- Stefan.
|
---|
| 1206 | int seccount = 0;
|
---|
| 1207 | while (sechere != secend) {
|
---|
[649] | 1208 | int shastxt = (*sechere).metadata["hastxt"].values[0].getint();
|
---|
[9620] | 1209 | if (shastxt == 1) ++seccount;
|
---|
[284] | 1210 | if (seccount > 10) break;
|
---|
[9620] | 1211 | ++sechere;
|
---|
[267] | 1212 | }
|
---|
[284] | 1213 | if (seccount > 10) {
|
---|
| 1214 | // more than 10 sections so output warning message and text
|
---|
| 1215 | // for current section only
|
---|
[11153] | 1216 | textout << outconvert << disp << "<div class=\"warning\">_document:textltwarning_</div>\n";
|
---|
[443] | 1217 |
|
---|
| 1218 | output_text (thisdocinfo, formatlistptr, queryresponse.termInfo,
|
---|
| 1219 | OID, highlight, hastxt, wanttext, collection,
|
---|
[4936] | 1220 | collectproto, browsers, disp, outconvert, textout, logout, args);
|
---|
[284] | 1221 |
|
---|
| 1222 | }
|
---|
| 1223 | else arg_gt = 2;
|
---|
| 1224 | }
|
---|
[257] | 1225 |
|
---|
[284] | 1226 | if (arg_gt == 2) {
|
---|
[267] | 1227 | // get the text for each section
|
---|
[284] | 1228 | sechere = inforesponse.docInfo.begin();
|
---|
| 1229 | int count = 0;
|
---|
| 1230 | while (sechere != secend) {
|
---|
[3087] | 1231 | textout << outconvert << disp << "\n<p><a name=" << (*sechere).OID << "></a>\n";
|
---|
[437] | 1232 |
|
---|
[649] | 1233 | int shastxt = (*sechere).metadata["hastxt"].values[0].getint();
|
---|
[443] | 1234 |
|
---|
| 1235 | output_text (*sechere, formatlistptr, queryresponse.termInfo,
|
---|
| 1236 | (*sechere).OID, highlight, shastxt, wanttext, collection,
|
---|
[4936] | 1237 | collectproto, browsers, disp, outconvert, textout, logout, args);
|
---|
[9620] | 1238 | ++count;
|
---|
| 1239 | ++sechere;
|
---|
[267] | 1240 | }
|
---|
| 1241 | }
|
---|
| 1242 | }
|
---|
[257] | 1243 | }
|
---|
[11144] | 1244 | textout << outconvert << "</div>\n";
|
---|
[443] | 1245 | delete formatlistptr;
|
---|
[267] | 1246 | }
|
---|
[4868] | 1247 |
|
---|
| 1248 | void documentaction::set_arrow_macros (cgiargsclass &args, recptproto *collectproto,
|
---|
| 1249 | displayclass &disp, ostream &logout) {
|
---|
| 1250 |
|
---|
| 1251 | text_tset metadata;
|
---|
| 1252 | FilterResponse_t response;
|
---|
| 1253 | FilterResponse_t presponse;
|
---|
| 1254 |
|
---|
| 1255 | int haschildren = 0;
|
---|
| 1256 | text_tarray next_siblings;
|
---|
| 1257 | text_t previous_sibling;
|
---|
| 1258 | text_t &arg_d = args["d"];
|
---|
| 1259 |
|
---|
| 1260 | // get info on current section
|
---|
| 1261 | metadata.insert("haschildren");
|
---|
[7432] | 1262 | if (!get_info(arg_d, args["c"], args["l"], metadata, false, collectproto, response, logout)) {
|
---|
[4868] | 1263 | logout << "error 1 in documentaction::set_arrow_macros\n";
|
---|
| 1264 | return;
|
---|
| 1265 | }
|
---|
| 1266 | haschildren = response.docInfo[0].metadata["haschildren"].values[0].getint();
|
---|
| 1267 |
|
---|
| 1268 | // get OIDs of next and previous siblings of current section and
|
---|
| 1269 | // all it's parents
|
---|
| 1270 | int parentcount = countchar(arg_d.begin(), arg_d.end(), '.');
|
---|
| 1271 | text_t thisoid = arg_d;
|
---|
| 1272 | while (parentcount > 0) {
|
---|
[7432] | 1273 | get_children (get_parent(thisoid), args["c"], args["l"], metadata, false,
|
---|
[4868] | 1274 | collectproto, response, logout);
|
---|
| 1275 | ResultDocInfo_tarray::iterator this_sibling = response.docInfo.begin();
|
---|
| 1276 | ResultDocInfo_tarray::iterator last_sibling = response.docInfo.end();
|
---|
| 1277 | bool first = true;
|
---|
| 1278 | while (this_sibling != last_sibling) {
|
---|
| 1279 | if ((*this_sibling).OID == thisoid) {
|
---|
| 1280 | if (!first && next_siblings.empty()) {
|
---|
| 1281 | previous_sibling = (*(this_sibling-1)).OID;
|
---|
| 1282 | int section_has_children = (*(this_sibling-1)).metadata["haschildren"].values[0].getint();
|
---|
| 1283 | // if previous sibling has children we need to recurse
|
---|
| 1284 | // down to the last descendant
|
---|
| 1285 | while (section_has_children) {
|
---|
[7432] | 1286 | get_children (previous_sibling, args["c"], args["l"], metadata, false,
|
---|
[4868] | 1287 | collectproto, presponse, logout);
|
---|
| 1288 | if (!presponse.docInfo.empty()) {
|
---|
| 1289 | ResultDocInfo_tarray::iterator it = presponse.docInfo.end() - 1;
|
---|
| 1290 | previous_sibling = (*it).OID;
|
---|
| 1291 | section_has_children = (*it).metadata["haschildren"].values[0].getint();
|
---|
| 1292 | } else {
|
---|
| 1293 | section_has_children = 0; // this should never happen
|
---|
| 1294 | }
|
---|
| 1295 | }
|
---|
| 1296 | }
|
---|
| 1297 |
|
---|
| 1298 | if ((this_sibling+1) != last_sibling) {
|
---|
| 1299 | next_siblings.push_back((*(this_sibling+1)).OID);
|
---|
| 1300 | } else {
|
---|
| 1301 | next_siblings.push_back("");
|
---|
| 1302 | }
|
---|
| 1303 | break;
|
---|
| 1304 | }
|
---|
[9620] | 1305 | ++this_sibling;
|
---|
[4868] | 1306 | first = false;
|
---|
| 1307 | }
|
---|
| 1308 | thisoid = get_parent(thisoid);
|
---|
[9620] | 1309 | --parentcount;
|
---|
[4868] | 1310 | }
|
---|
| 1311 |
|
---|
| 1312 | // work out values for next link
|
---|
| 1313 | if (haschildren) {
|
---|
[11998] | 1314 | #ifndef DOCHANLE
|
---|
[10873] | 1315 | disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + args["cl"] +
|
---|
| 1316 | "&d=" + arg_d + ".fc");
|
---|
[11998] | 1317 | #else
|
---|
| 1318 | disp.setmacro ("httpnextarrow", "document", "_httpdocumenthandle_("+args["c"]+","+arg_d + ".fc)";
|
---|
| 1319 |
|
---|
| 1320 | #endif
|
---|
| 1321 |
|
---|
[4868] | 1322 | } else {
|
---|
| 1323 | text_tarray::const_iterator h = next_siblings.begin();
|
---|
| 1324 | text_tarray::const_iterator e = next_siblings.end();
|
---|
| 1325 | while (h != e) {
|
---|
| 1326 | if (!(*h).empty()) {
|
---|
[11998] | 1327 | #ifndef DOCHANLE
|
---|
[10873] | 1328 | disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + args["cl"] +
|
---|
| 1329 | "&d=" + *h);
|
---|
[11998] | 1330 | #else
|
---|
| 1331 | disp.setmacro ("httpnextarrow", "document", "_httpdocumenthandle_("+args["c"]+","+*h+")";
|
---|
| 1332 |
|
---|
| 1333 | #endif
|
---|
| 1334 |
|
---|
[4868] | 1335 | break;
|
---|
| 1336 | }
|
---|
[9620] | 1337 | ++h;
|
---|
[4868] | 1338 | }
|
---|
| 1339 | }
|
---|
| 1340 |
|
---|
| 1341 | // work out value for previous link
|
---|
| 1342 | if (!previous_sibling.empty()) {
|
---|
[11998] | 1343 | #ifndef DOCHANDLE
|
---|
[10873] | 1344 | disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + args["cl"] +
|
---|
| 1345 | "&d=" + previous_sibling);
|
---|
[11998] | 1346 | #else
|
---|
| 1347 | disp.setmacro ("httpprevarrow", "document", "_httpdocumenthandle_("+args["c"]+","+ previous_sibling+")");
|
---|
| 1348 |
|
---|
| 1349 | #endif
|
---|
| 1350 |
|
---|
[4868] | 1351 | } else {
|
---|
| 1352 | if (countchar(arg_d.begin(), arg_d.end(), '.')) {
|
---|
[11998] | 1353 | #ifndef DOCHANDLE
|
---|
[10873] | 1354 | disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + args["cl"] +
|
---|
| 1355 | "&d=" + get_parent(arg_d));
|
---|
[11998] | 1356 | #else
|
---|
| 1357 | disp.setmacro ("httpprevarrow", "document", "_httpdocumenthandle_("+args["c"]+","+get_parent(arg_d)+")");
|
---|
| 1358 |
|
---|
| 1359 | #endif
|
---|
| 1360 |
|
---|
[4868] | 1361 | }
|
---|
| 1362 | }
|
---|
| 1363 | }
|
---|