1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * documentaction.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: documentaction.cpp 261 1999-06-08 04:29:42Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.3 1999/06/08 04:29:37 sjboddie
|
---|
15 | added argsinfo to the call to check_cgiargs to make it easy to set
|
---|
16 | args to their default if they're found to be screwed up
|
---|
17 |
|
---|
18 | Revision 1.2 1999/05/10 03:40:35 sjboddie
|
---|
19 | lots of changes - slowly getting document action sorted out
|
---|
20 |
|
---|
21 | Revision 1.1 1999/04/30 01:59:40 sjboddie
|
---|
22 | lots of stuff - getting documentaction working (documentaction replaces
|
---|
23 | old browseaction)
|
---|
24 |
|
---|
25 | Revision 1.2 1999/03/29 02:14:27 sjboddie
|
---|
26 |
|
---|
27 | More changes to browseaction
|
---|
28 |
|
---|
29 | Revision 1.1 1999/03/25 03:09:40 sjboddie
|
---|
30 |
|
---|
31 | subjectbrowseaction became browseaction
|
---|
32 |
|
---|
33 |
|
---|
34 | */
|
---|
35 |
|
---|
36 |
|
---|
37 | #include "documentaction.h"
|
---|
38 | #include "browsetools.h"
|
---|
39 | #include "OIDtools.h"
|
---|
40 |
|
---|
41 | documentaction::documentaction () {
|
---|
42 | // this action uses cgi variables "a", "d", "cl",
|
---|
43 | // "x", "gc", "gt", "gp", and "hl"
|
---|
44 | cgiarginfo arg_ainfo;
|
---|
45 | arg_ainfo.shortname = "a";
|
---|
46 | arg_ainfo.longname = "action";
|
---|
47 | arg_ainfo.multiplechar = true;
|
---|
48 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
49 | arg_ainfo.argdefault = "p";
|
---|
50 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
51 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
52 |
|
---|
53 | arg_ainfo.shortname = "d";
|
---|
54 | arg_ainfo.longname = "document OID";
|
---|
55 | arg_ainfo.multiplechar = true;
|
---|
56 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
57 | arg_ainfo.argdefault = "";
|
---|
58 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
59 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
60 |
|
---|
61 | arg_ainfo.shortname = "cl";
|
---|
62 | arg_ainfo.longname = "classification OID";
|
---|
63 | arg_ainfo.multiplechar = true;
|
---|
64 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
65 | arg_ainfo.argdefault = "";
|
---|
66 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
67 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
68 |
|
---|
69 | // in this action "gc" controls the expand/contract
|
---|
70 | // contents function
|
---|
71 | arg_ainfo.shortname = "gc";
|
---|
72 | arg_ainfo.longname = "expand contents";
|
---|
73 | arg_ainfo.multiplechar = false;
|
---|
74 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
75 | arg_ainfo.argdefault = "0";
|
---|
76 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
77 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
78 |
|
---|
79 | // in this action "gt" controls the expand/contract
|
---|
80 | // text function 0 = not expanded, 1 = expand unless
|
---|
81 | // there are more than 10 sections containing text,
|
---|
82 | // 2 = expand all
|
---|
83 | arg_ainfo.shortname = "gt";
|
---|
84 | arg_ainfo.longname = "expand text";
|
---|
85 | arg_ainfo.multiplechar = false;
|
---|
86 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
87 | arg_ainfo.argdefault = "0";
|
---|
88 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
89 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
90 |
|
---|
91 | // in this action "gp" is the "go to page" control
|
---|
92 | // used by the Book type of toc
|
---|
93 | arg_ainfo.shortname = "gp";
|
---|
94 | arg_ainfo.longname = "go to page";
|
---|
95 | arg_ainfo.multiplechar = true;
|
---|
96 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
97 | arg_ainfo.argdefault = "";
|
---|
98 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
99 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
100 |
|
---|
101 | // in this action "hl" is the "highlighting on/
|
---|
102 | // highlighting off control
|
---|
103 | arg_ainfo.shortname = "hl";
|
---|
104 | arg_ainfo.longname = "highlighting on/off";
|
---|
105 | arg_ainfo.multiplechar = false;
|
---|
106 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
107 | arg_ainfo.argdefault = "1";
|
---|
108 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
109 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
110 |
|
---|
111 | // "x" is 0 normally or 1 if page
|
---|
112 | // has been "detached"
|
---|
113 | arg_ainfo.shortname = "x";
|
---|
114 | arg_ainfo.longname = "detached page";
|
---|
115 | arg_ainfo.multiplechar = false;
|
---|
116 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
117 | arg_ainfo.argdefault = "0";
|
---|
118 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
119 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
120 | }
|
---|
121 |
|
---|
122 | documentaction::~documentaction () {
|
---|
123 | }
|
---|
124 |
|
---|
125 | bool documentaction::init (ostream &logout) {
|
---|
126 | return action::init (logout);
|
---|
127 | }
|
---|
128 |
|
---|
129 | bool documentaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
|
---|
130 | ostream &/*logout*/) {
|
---|
131 | // don't want to check anything yet.
|
---|
132 | return true;
|
---|
133 | }
|
---|
134 |
|
---|
135 | void documentaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
|
---|
136 | text_t &response_data, ostream &/*logout*/) {
|
---|
137 | response = content;
|
---|
138 | response_data = "text/html";
|
---|
139 | }
|
---|
140 |
|
---|
141 |
|
---|
142 | // define all the macros which might be used by other actions
|
---|
143 | // to produce pages.
|
---|
144 | void documentaction::define_external_macros (displayclass &disp, cgiargsclass &args,
|
---|
145 | recptproto *collectproto, ostream &logout) {
|
---|
146 |
|
---|
147 | // define_external_macros sets the following macros:
|
---|
148 |
|
---|
149 | // _navigationbar_ this is the navigation bar containing the search button
|
---|
150 | // and any classification buttons - it goes at the top of
|
---|
151 | // most pages. for now we're assuming that there'll always
|
---|
152 | // be a search button - we should probably check that there
|
---|
153 | // is a query action before making this assumption
|
---|
154 |
|
---|
155 | // _httpbrowseXXX_ the http macros for each classification (i.e. if there
|
---|
156 | // are Title and Creator classifications _httpbrowseTitle_
|
---|
157 | // and _httpbrowseCreator_ will be set
|
---|
158 |
|
---|
159 | // _javaimagesnavbar_ this is the javascript code to shove in to make the
|
---|
160 | // flashy images used by _navigationbar_ work
|
---|
161 |
|
---|
162 | // _cgiargd_ these are overridden if they use the tricky ".xx" syntax
|
---|
163 | // _cgiargcl_
|
---|
164 |
|
---|
165 |
|
---|
166 | outconvertclass text_t2ascii;
|
---|
167 | comerror_t err;
|
---|
168 | InfoFiltersResponse_t filterinfo;
|
---|
169 | FilterResponse_t response;
|
---|
170 | FilterRequest_t request;
|
---|
171 | text_tarray metadata;
|
---|
172 | text_t navigationbar, javaimagesnavbar, width, topparent;
|
---|
173 | int twidth, swidth, iwidth = 0;
|
---|
174 |
|
---|
175 | // if the "gp" (go to page) argument is set we need to set
|
---|
176 | // the "d" argument to the corresponding page
|
---|
177 | if ((!args["d"].empty()) && (!args["gp"].empty()) &&
|
---|
178 | (is_number (args["gp"]))) {
|
---|
179 | text_t top;
|
---|
180 | get_top (args["d"], top);
|
---|
181 | metadata.push_back ("Title");
|
---|
182 | get_children (top, args["c"], metadata, collectproto, response, logout);
|
---|
183 | ResultDocInfo_tarray::const_iterator dochere = response.docInfo.begin();
|
---|
184 | ResultDocInfo_tarray::const_iterator docend = response.docInfo.end();
|
---|
185 | while (dochere != docend) {
|
---|
186 | if ((*dochere).metadata[0].values[0] == args["gp"]) {
|
---|
187 | args["d"] = (*dochere).OID;
|
---|
188 | disp.setmacro ("cgiargd", "Global", args["d"]);
|
---|
189 | break;
|
---|
190 | }
|
---|
191 | dochere ++;
|
---|
192 | }
|
---|
193 | metadata.erase (metadata.begin(), metadata.end());
|
---|
194 | }
|
---|
195 |
|
---|
196 | // do a call to translate OIDs if required
|
---|
197 | request.filterName = "NullFilter";
|
---|
198 | request.filterResultOptions = FROID;
|
---|
199 | if (needs_translating (args["d"])) {
|
---|
200 | request.docSet.insert (args["d"]);
|
---|
201 | collectproto->filter (args["c"], request, response, err, logout);
|
---|
202 | args["d"] = response.docInfo[0].OID;
|
---|
203 | request.docSet.erase (request.docSet.begin(), request.docSet.end());
|
---|
204 | disp.setmacro ("cgiargd", "Global", args["d"]);
|
---|
205 | }
|
---|
206 | if (needs_translating (args["cl"])) {
|
---|
207 | request.docSet.insert (args["cl"]);
|
---|
208 | collectproto->filter (args["c"], request, response, err, logout);
|
---|
209 | args["cl"] = response.docInfo[0].OID;
|
---|
210 | disp.setmacro ("cgiargcl", "Global", args["cl"]);
|
---|
211 | }
|
---|
212 |
|
---|
213 | get_top (args["cl"], topparent);
|
---|
214 |
|
---|
215 | collectproto->get_filterinfo (args["c"], filterinfo, err, logout);
|
---|
216 | if (err == noError) {
|
---|
217 | // check that there's a browse filter
|
---|
218 | if (filterinfo.filterNames.find ("BrowseFilter") != filterinfo.filterNames.end()) {
|
---|
219 |
|
---|
220 | metadata.push_back ("Title");
|
---|
221 | metadata.push_back ("classifytype");
|
---|
222 | get_children ("", args["c"], metadata, collectproto, response, logout);
|
---|
223 |
|
---|
224 | // don't do anything unless there are classifications
|
---|
225 | if (!response.docInfo.empty()) {
|
---|
226 |
|
---|
227 | ResultDocInfo_tarray::const_iterator dochere = response.docInfo.begin();
|
---|
228 | ResultDocInfo_tarray::const_iterator docend = response.docInfo.end();
|
---|
229 |
|
---|
230 | navigationbar = "<!-- Navigation Bar -->\n";
|
---|
231 |
|
---|
232 | // calculate width of spacers and set macro
|
---|
233 | if (args.getintarg("v") == 0) {
|
---|
234 | disp.expandstring ("Global", "_pagewidth_", width);
|
---|
235 | twidth = width.getint();
|
---|
236 |
|
---|
237 | disp.expandstring ("query", "_searchwidth_", width);
|
---|
238 | iwidth += width.getint();
|
---|
239 |
|
---|
240 | while (dochere != docend) {
|
---|
241 | disp.expandstring ("document", "_" + (*dochere).metadata[0].values[0] + "width_", width);
|
---|
242 | iwidth += width.getint();
|
---|
243 | dochere ++;
|
---|
244 | }
|
---|
245 | if ((twidth - iwidth) < int(response.docInfo.size())) swidth = 2;
|
---|
246 | else swidth = (twidth - iwidth) / response.docInfo.size();
|
---|
247 | disp.setmacro ("widthtspace", "Global", swidth);
|
---|
248 | }
|
---|
249 |
|
---|
250 | navigationbar += "<nobr>\n";
|
---|
251 | if (args["a"] == "q") {
|
---|
252 | navigationbar += "_icontabsearchgreen_";
|
---|
253 | } else {
|
---|
254 | navigationbar += "_imagesearch_";
|
---|
255 | javaimagesnavbar = "_javasearch_";
|
---|
256 | }
|
---|
257 | dochere = response.docInfo.begin();
|
---|
258 | while (dochere != docend) {
|
---|
259 | const text_t &title = (*dochere).metadata[0].values[0];
|
---|
260 | const text_t &classifytype = (*dochere).metadata[1].values[0];
|
---|
261 |
|
---|
262 | // if we're inside a document all the classification buttons should be enabled
|
---|
263 | if (args["d"].empty() && ((*dochere).OID == topparent))
|
---|
264 | navigationbar += "_imagespacer__icontab" + title + "green_";
|
---|
265 | else {
|
---|
266 | navigationbar += "_imagespacer__image" + title + "_";
|
---|
267 |
|
---|
268 | // set the _httpbrowseXXX_ macro for this classification
|
---|
269 | text_t link = (*dochere).OID;
|
---|
270 | if (classifytype == "AZList" || classifytype == "Datelist") link += ".fc";
|
---|
271 | disp.setmacro ("httpbrowse" + title, "Global",
|
---|
272 | "_httpdocument_&cl=" + link);
|
---|
273 | }
|
---|
274 | javaimagesnavbar += "_java" + title + "_";
|
---|
275 | dochere ++;
|
---|
276 | }
|
---|
277 | navigationbar += "\n</nobr>\n";
|
---|
278 | navigationbar += "<!-- End of Navigation Bar -->\n";
|
---|
279 | disp.setmacro ("navigationbar", "Global", navigationbar);
|
---|
280 | if (args.getintarg("v") == 0)
|
---|
281 | disp.setmacro ("javaimagesnavbar", "Global", javaimagesnavbar);
|
---|
282 | }
|
---|
283 | }
|
---|
284 | } else {
|
---|
285 | logout << text_t2ascii
|
---|
286 | << "Error (documentaction::define_external_macros()) in call to get_filterinfo() "
|
---|
287 | << get_comerror_string (err);
|
---|
288 | }
|
---|
289 | }
|
---|
290 |
|
---|
291 |
|
---|
292 | // define all the macros which are related to pages generated
|
---|
293 | // by this action
|
---|
294 | void documentaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
295 | recptproto *collectproto, ostream &logout) {
|
---|
296 |
|
---|
297 | // define_internal_macros sets the following macros:
|
---|
298 |
|
---|
299 | // _imagethispage_ the title image to be displayed at top right of page
|
---|
300 |
|
---|
301 | // _classificationlinks_ the links between classifications to be displayed
|
---|
302 | // at top of list or datelist classifications
|
---|
303 |
|
---|
304 | // _httpprevarrow_ these are set if next or previous arrows
|
---|
305 | // _httpnextarrow_ are to be used - (i.e. if it's an AZList or a Datelist
|
---|
306 | // classifytype at a top level or if it's a Book or a
|
---|
307 | // Hierarchy classifytype at document level
|
---|
308 |
|
---|
309 | // _header_ the header macro is overridden if we're not at a top level
|
---|
310 | // classification to remove the title block
|
---|
311 |
|
---|
312 | // _javaimagescontent_ this is the javascript code to shove in to make the
|
---|
313 | // flashy buttons work
|
---|
314 |
|
---|
315 |
|
---|
316 | text_tarray metadata;
|
---|
317 | FilterResponse_t response;
|
---|
318 |
|
---|
319 | metadata.push_back ("Title");
|
---|
320 | metadata.push_back ("classifytype");
|
---|
321 |
|
---|
322 | if (!args["d"].empty()) {
|
---|
323 | // we're at document level
|
---|
324 | text_t javaimagescontent;
|
---|
325 |
|
---|
326 | // get metadata for top level of document
|
---|
327 | text_t doctop;
|
---|
328 | get_top (args["d"], doctop);
|
---|
329 | if (get_info (doctop, args["c"], metadata, collectproto, response, logout)) {
|
---|
330 | disp.setmacro ("header", "document", "_textheader_");
|
---|
331 | text_t &classifytype = response.docInfo[0].metadata[1].values[0];
|
---|
332 | if (classifytype.empty()) classifytype = "Book"; // defaults to Book
|
---|
333 | if ((classifytype == "Book") || (classifytype == "Hierarchy"))
|
---|
334 | set_arrow_macros (args["d"], classifytype, disp, collectproto, args["c"], logout);
|
---|
335 |
|
---|
336 | if (args["u"] != "1") {
|
---|
337 | javaimagescontent += "_javadetach_";
|
---|
338 | if (args["gt"] == "1")
|
---|
339 | javaimagescontent += "_javacontracttext__javacontinue_";
|
---|
340 | else
|
---|
341 | javaimagescontent += "_javaexpandtext_";
|
---|
342 | if (classifytype == "Hierarchy")
|
---|
343 | if (args["gc"] == "1")
|
---|
344 | javaimagescontent += "_javacontractcontents_";
|
---|
345 | else
|
---|
346 | javaimagescontent += "_javaexpandcontents_";
|
---|
347 | if (args["hl"] != "1")
|
---|
348 | javaimagescontent += "_javahighlighting_";
|
---|
349 | else
|
---|
350 | javaimagescontent += "_javanohighlighting_";
|
---|
351 | disp.setmacro ("javaimagescontent", "document", javaimagescontent);
|
---|
352 | }
|
---|
353 | }
|
---|
354 | } else {
|
---|
355 | if (!args["cl"].empty()) {
|
---|
356 |
|
---|
357 | // get metadata for top level classification
|
---|
358 | text_t classtop;
|
---|
359 | get_top (args["cl"], classtop);
|
---|
360 | if (get_info (classtop, args["c"], metadata, collectproto, response, logout)) {
|
---|
361 |
|
---|
362 | text_t &title = response.docInfo[0].metadata[0].values[0];
|
---|
363 | text_t &classifytype = response.docInfo[0].metadata[1].values[0];
|
---|
364 |
|
---|
365 | disp.setmacro ("imagethispage", "document",
|
---|
366 | "_icon" + title + "page_");
|
---|
367 |
|
---|
368 | // now get the metadata for each child of top level
|
---|
369 | // so we can generate the _classificationlinks_ and arrow macros
|
---|
370 | // (if they're required by the current classification type)
|
---|
371 |
|
---|
372 | if ((classifytype == "AZList") || (classifytype == "Datelist")) {
|
---|
373 |
|
---|
374 | text_t classificationlinks, navarrows;
|
---|
375 | text_t link = "<a href=\"_httpdocument_&cl=";
|
---|
376 |
|
---|
377 | metadata.erase(metadata.begin(), metadata.end());
|
---|
378 | metadata.push_back ("Title");
|
---|
379 | metadata.push_back ("doctype");
|
---|
380 | if (get_children (classtop, args["c"], metadata, collectproto, response, logout)) {
|
---|
381 |
|
---|
382 | // don't want links unless there are 2 or more sections
|
---|
383 | if (response.docInfo.size() >= 2) {
|
---|
384 |
|
---|
385 | classificationlinks += "<!-- Classification Links -->\n";
|
---|
386 | classificationlinks += "<table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0>\n";
|
---|
387 | classificationlinks += "<tr><td valign=top><center>\n";
|
---|
388 |
|
---|
389 | ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
|
---|
390 | ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
|
---|
391 |
|
---|
392 | while (sechere != secend) {
|
---|
393 | if ((*sechere).metadata[1].values[0] == "classify") {
|
---|
394 | if ((*sechere).OID == args["cl"]) {
|
---|
395 |
|
---|
396 | // set the _httpprevarrow_, _httpnextarrow_ macros while we're here
|
---|
397 | if (sechere != response.docInfo.begin())
|
---|
398 | disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + (*(sechere-1)).OID);
|
---|
399 | if ((sechere + 1) != secend)
|
---|
400 | disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + (*(sechere+1)).OID);
|
---|
401 |
|
---|
402 | classificationlinks += "\n<b>" + (*sechere).metadata[0].values[0] + "</b> ";
|
---|
403 | } else {
|
---|
404 | classificationlinks += link + (*sechere).OID + "\">";
|
---|
405 | classificationlinks += (*sechere).metadata[0].values[0] + "</a>";
|
---|
406 | if ((sechere + 1) != secend) classificationlinks += " ";
|
---|
407 | }
|
---|
408 | }
|
---|
409 | sechere ++;
|
---|
410 | }
|
---|
411 |
|
---|
412 | classificationlinks += "\n</center></td></tr></table>\n";
|
---|
413 | classificationlinks += "<!-- End of Classification Links -->\n";
|
---|
414 |
|
---|
415 | disp.setmacro ("classificationlinks", "document", classificationlinks);
|
---|
416 | }
|
---|
417 | }
|
---|
418 | }
|
---|
419 | }
|
---|
420 | }
|
---|
421 | }
|
---|
422 | }
|
---|
423 |
|
---|
424 | bool documentaction::do_action (cgiargsclass &args, recptproto *collectproto,
|
---|
425 | displayclass &disp, outconvertclass &outconvert,
|
---|
426 | ostream &textout, ostream &logout) {
|
---|
427 |
|
---|
428 | text_tarray metadata;
|
---|
429 | FilterResponse_t response;
|
---|
430 | DocumentRequest_t docrequest;
|
---|
431 | DocumentResponse_t docresponse;
|
---|
432 | text_t topparent, classifytype, classifytitle;
|
---|
433 | comerror_t err;
|
---|
434 |
|
---|
435 | text_t &arg_d = args["d"];
|
---|
436 | text_t &arg_cl = args["cl"];
|
---|
437 | text_t &collection = args["c"];
|
---|
438 |
|
---|
439 | text_t OID = arg_d;
|
---|
440 | if (arg_d.empty()) OID = arg_cl;
|
---|
441 |
|
---|
442 | textout << outconvert << disp << "_document:header_\n"
|
---|
443 | << "_document:content_\n";
|
---|
444 |
|
---|
445 | if (arg_d.empty() && arg_cl.empty()) {
|
---|
446 | textout << outconvert << disp << "Document contains no data_document:footer_\n";
|
---|
447 | return true;
|
---|
448 | }
|
---|
449 |
|
---|
450 | // get the classifytitle and classifytype
|
---|
451 | get_top (OID, topparent);
|
---|
452 | metadata.push_back ("Title");
|
---|
453 | metadata.push_back ("classifytype");
|
---|
454 | if (get_info (topparent, collection, metadata, collectproto, response, logout)) {
|
---|
455 | classifytitle = response.docInfo[0].metadata[0].values[0];
|
---|
456 | classifytype = response.docInfo[0].metadata[1].values[0];
|
---|
457 | }
|
---|
458 |
|
---|
459 | if (!arg_d.empty()) {
|
---|
460 |
|
---|
461 | if (classifytype == "Hierarchy")
|
---|
462 | output_hierarchy_toc (classifytitle, args, collectproto, disp,
|
---|
463 | outconvert, textout, logout);
|
---|
464 | else
|
---|
465 | // Book is the default for a document level toc - AZList and Datelist don't
|
---|
466 | // make sense for document level
|
---|
467 | output_book_toc (classifytitle, args, collectproto, disp,
|
---|
468 | outconvert, textout, logout);
|
---|
469 | } else {
|
---|
470 |
|
---|
471 | if (classifytype == "Hierarchy")
|
---|
472 | output_hierarchy_toc (classifytitle, args, collectproto, disp,
|
---|
473 | outconvert, textout, logout);
|
---|
474 | else if (classifytype == "Datelist")
|
---|
475 | output_datelist_toc (classifytitle, args, collectproto, disp,
|
---|
476 | outconvert, textout, logout);
|
---|
477 | else
|
---|
478 | // AZList is the default for a classification level toc - Book doesn't make
|
---|
479 | // sense for classification level
|
---|
480 | output_azlist_toc (classifytitle, args, collectproto, disp,
|
---|
481 | outconvert, textout, logout);
|
---|
482 | }
|
---|
483 |
|
---|
484 | // get info on this document
|
---|
485 | metadata.erase (metadata.begin(), metadata.end());
|
---|
486 | metadata.push_back("Title");
|
---|
487 | metadata.push_back("hastxt");
|
---|
488 | metadata.push_back("haschildren");
|
---|
489 |
|
---|
490 | if (get_info (OID, collection, metadata, collectproto, response, logout)) {
|
---|
491 | text_t &title = response.docInfo[0].metadata[0].values[0];
|
---|
492 | int hastxt = response.docInfo[0].metadata[1].values[0].getint();
|
---|
493 | int haschildren = response.docInfo[0].metadata[2].values[0].getint();
|
---|
494 |
|
---|
495 | int gt = args.getintarg("gt");
|
---|
496 | if (gt == 0) {
|
---|
497 | if (hastxt == 1) {
|
---|
498 | // get the text
|
---|
499 | docrequest.OID = OID;
|
---|
500 | collectproto->get_document (collection, docrequest, docresponse, err, logout);
|
---|
501 |
|
---|
502 | textout << outconvert << disp
|
---|
503 | << "<p>\n<h3>" << title << "</h3>" << docresponse.doc;
|
---|
504 | }
|
---|
505 | } else {
|
---|
506 |
|
---|
507 | // text is to be expanded
|
---|
508 | int tmp; // this doesn't get used here
|
---|
509 | if (!haschildren)
|
---|
510 | OID = get_parent (OID);
|
---|
511 |
|
---|
512 | get_contents (OID, classifytype, tmp, collection, collectproto, response, logout);
|
---|
513 |
|
---|
514 | ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
|
---|
515 | ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
|
---|
516 |
|
---|
517 | if (gt == 1) {
|
---|
518 | // check if there are more than 10 sections containing text to be expanded -
|
---|
519 | // if there are output warning message - this isn't a great way to do this
|
---|
520 | // since the sections may be very large or very small - one day I'll fix it
|
---|
521 | // -- Stefan.
|
---|
522 | int seccount = 0;
|
---|
523 | while (sechere != secend) {
|
---|
524 | if ((*sechere).metadata[3].values[0] == "1") seccount ++;
|
---|
525 | if (seccount > 10) break;
|
---|
526 | sechere ++;
|
---|
527 | }
|
---|
528 | if (seccount > 10) textout << outconvert << disp << "_document:textltwarning_";
|
---|
529 | else gt = 2;
|
---|
530 | }
|
---|
531 |
|
---|
532 | if (gt == 2) {
|
---|
533 | // get the text for each section
|
---|
534 | sechere = response.docInfo.begin();
|
---|
535 | int count = 0;
|
---|
536 | while (sechere != secend) {
|
---|
537 | textout << outconvert << disp << "\n<p><a name=" << count << "><h3>"
|
---|
538 | << (*sechere).metadata[0].values[0] << "</h3></a>\n";
|
---|
539 | if ((*sechere).metadata[3].values[0] == "1") {
|
---|
540 | docrequest.OID = (*sechere).OID;
|
---|
541 | collectproto->get_document (collection, docrequest, docresponse, err, logout);
|
---|
542 | textout << outconvert << disp << docresponse.doc;
|
---|
543 | }
|
---|
544 | count ++;
|
---|
545 | sechere ++;
|
---|
546 | }
|
---|
547 | }
|
---|
548 | }
|
---|
549 | }
|
---|
550 | textout << outconvert << disp << "_document:footer_\n";
|
---|
551 | return true;
|
---|
552 | }
|
---|
553 |
|
---|