1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * browsetools.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: browsetools.cpp 344 1999-07-07 05:44:25Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.13 1999/07/07 05:44:25 sjboddie
|
---|
15 | Made some changes to allow for new way classifiers work (i.e. you can
|
---|
16 | now have classifiers containing other classifiers). At present there's
|
---|
17 | only a special case for dealing with the hdl 'magazine' section. A bit
|
---|
18 | of a redesign is needed to get it completely flexible
|
---|
19 |
|
---|
20 | Revision 1.12 1999/07/01 03:47:49 rjmcnab
|
---|
21 | Fixed a small warning.
|
---|
22 |
|
---|
23 | Revision 1.11 1999/06/27 21:49:01 sjboddie
|
---|
24 | fixed a couple of version conflicts - tidied up some small things
|
---|
25 |
|
---|
26 | Revision 1.10 1999/06/26 01:07:21 rjmcnab
|
---|
27 | Fixed a small "bug" -- well I probably just covered another one...
|
---|
28 |
|
---|
29 | Revision 1.9 1999/06/24 05:12:15 sjboddie
|
---|
30 | lots of small changes
|
---|
31 |
|
---|
32 | Revision 1.8 1999/06/17 03:06:53 sjboddie
|
---|
33 | got detach button working properly - the close book icon is now disabled
|
---|
34 | when page is detached as the javascript close() function I was using is
|
---|
35 | too unreliable over different browsers
|
---|
36 | note that in my last comment I meant the "cl" arg (not the "c" arg).
|
---|
37 |
|
---|
38 | Revision 1.7 1999/06/16 23:53:14 sjboddie
|
---|
39 | tidied a few things up. documentaction::define_external_macros now
|
---|
40 | resets the "c" arg if it's set to something stupid by the .xx suffixes
|
---|
41 |
|
---|
42 | Revision 1.6 1999/06/16 04:03:47 sjboddie
|
---|
43 | Now sets "cl" arg to "search" when going to a document from a search
|
---|
44 | results page. This allows the close book icon (in hierarchy toc) to
|
---|
45 | take you back to the results page if that's where you came from.
|
---|
46 | If you got to the document page somehow other than from a
|
---|
47 | classification or a search (i.e. if "cl" isn't set) then the close
|
---|
48 | book icon is disabled
|
---|
49 |
|
---|
50 | Revision 1.5 1999/06/16 03:11:25 sjboddie
|
---|
51 | get_info() now takes a getParents argument
|
---|
52 |
|
---|
53 | Revision 1.4 1999/05/10 03:40:26 sjboddie
|
---|
54 | lots of changes - slowly getting document action sorted out
|
---|
55 |
|
---|
56 | Revision 1.3 1999/04/30 01:59:39 sjboddie
|
---|
57 | lots of stuff - getting documentaction working (documentaction replaces
|
---|
58 | old browseaction)
|
---|
59 |
|
---|
60 | Revision 1.2 1999/03/29 02:14:29 sjboddie
|
---|
61 |
|
---|
62 | More changes to browseaction
|
---|
63 |
|
---|
64 | Revision 1.1 1999/03/25 03:10:15 sjboddie
|
---|
65 |
|
---|
66 | new library for browse stuff
|
---|
67 |
|
---|
68 | */
|
---|
69 |
|
---|
70 |
|
---|
71 | #include "browsetools.h"
|
---|
72 | #include "OIDtools.h"
|
---|
73 |
|
---|
74 |
|
---|
75 | // Note that at present the build software is capable (if you write a plugin to do
|
---|
76 | // it) of generating classifications that contain other classifications of a
|
---|
77 | // different type. This module can only handle one case of that however (i.e. an
|
---|
78 | // AZList containing a Hierarchy classification as used by hdl's 'magazine'
|
---|
79 | // section). It really needs redesigning to handle all cases.
|
---|
80 |
|
---|
81 |
|
---|
82 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
---|
83 | Functions for generating a "Book" type table of contents. These should only be called
|
---|
84 | for document level tocs (i.e. when the "d" argument is set) as I don't think it makes
|
---|
85 | sense to display top level classifications in this way.
|
---|
86 | This type of table of contents is intended for documents whose sub-sections are simply
|
---|
87 | numbered as pages.
|
---|
88 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
---|
89 |
|
---|
90 | void book_toc (const text_t &/*classifytitle*/, cgiargsclass &args,
|
---|
91 | recptproto *collectproto, displayclass &disp,
|
---|
92 | outconvertclass &outconvert, ostream &textout,
|
---|
93 | ostream &logout) {
|
---|
94 |
|
---|
95 | if (args["d"].empty()) return;
|
---|
96 |
|
---|
97 | text_tarray metadata;
|
---|
98 | FilterResponse_t response;
|
---|
99 | ResultDocInfo_t docinfo;
|
---|
100 | text_t booktop, title, author;
|
---|
101 |
|
---|
102 | metadata.push_back ("Title");
|
---|
103 | metadata.push_back ("hastxt");
|
---|
104 | if (get_info (args["d"], args["c"], metadata, false, collectproto, response, logout)) {
|
---|
105 |
|
---|
106 | docinfo = response.docInfo[0];
|
---|
107 |
|
---|
108 | textout
|
---|
109 | << "\n<!-- Table of Contents produced by browsetools::output_book_toc -->\n\n";
|
---|
110 |
|
---|
111 | metadata.erase (metadata.begin()+1, metadata.end());
|
---|
112 | metadata.push_back ("Creator");
|
---|
113 |
|
---|
114 | // get title and author of book
|
---|
115 | get_top (args["d"], booktop);
|
---|
116 | metadata.push_back ("Title");
|
---|
117 | metadata.push_back ("Creator");
|
---|
118 | get_info (booktop, args["c"], metadata, false, collectproto, response, logout);
|
---|
119 | title = response.docInfo[0].metadata[0].values[0];
|
---|
120 | author = response.docInfo[0].metadata[1].values[0];
|
---|
121 | metadata.erase (metadata.begin(), metadata.end());
|
---|
122 |
|
---|
123 | textout << outconvert << disp
|
---|
124 | << "<p><center>\n"
|
---|
125 | << "<table cellpadding=0 cellspacing=0 width=_pagewidth_>\n"
|
---|
126 | << "<tr valign=top><td>\n";
|
---|
127 |
|
---|
128 | // don't want arrows and page number if text expanded
|
---|
129 | if (!args.getintarg ("gt")) {
|
---|
130 |
|
---|
131 | // previous arrow
|
---|
132 | textout << "<table><tr valign=top>\n";
|
---|
133 | textout << outconvert << disp << "<td align=left>_document:prevarrow_</td>\n";
|
---|
134 |
|
---|
135 | // page ? of ? text
|
---|
136 | textout << outconvert << "<td align=center>\n";
|
---|
137 |
|
---|
138 | if (is_number (docinfo.metadata[0].values[0])) {
|
---|
139 | text_t doctop;
|
---|
140 | metadata.push_back ("Title");
|
---|
141 | get_top (args["d"], doctop);
|
---|
142 | // get title of last sibling
|
---|
143 | if (get_info (doctop + ".lc", args["c"], metadata, false, collectproto, response, logout)) {
|
---|
144 | if (is_number (response.docInfo[0].metadata[0].values[0])) {
|
---|
145 | textout << outconvert << disp << "_document:page_" << docinfo.metadata[0].values[0]
|
---|
146 | << "_document:of_" << response.docInfo[0].metadata[0].values[0];
|
---|
147 | } else {
|
---|
148 | textout << outconvert << docinfo.metadata[0].values[0];
|
---|
149 | }
|
---|
150 | }
|
---|
151 | } else {
|
---|
152 | textout << outconvert << docinfo.metadata[0].values[0];
|
---|
153 | }
|
---|
154 |
|
---|
155 | // next arrow
|
---|
156 | textout << outconvert << disp << "</td>\n<td align=right>_document:nextarrow_</td>\n</table>\n";
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | // goto line
|
---|
161 | textout << outconvert << disp << "_document:gotoform_";
|
---|
162 |
|
---|
163 | // control buttons
|
---|
164 | output_controls (args, collectproto, disp, outconvert, textout, logout);
|
---|
165 | textout << "</td>\n";
|
---|
166 |
|
---|
167 | // title and author
|
---|
168 | textout << outconvert << "\n<td valign=top align=right>\n<h2>" << title << "</h2>\n";
|
---|
169 |
|
---|
170 | if (!author.empty())
|
---|
171 | textout << outconvert << "<h4><i>" << author << "</i></h4>\n";
|
---|
172 |
|
---|
173 | textout << "</td></tr></table></center>\n";
|
---|
174 | textout << "\n<!-- end of Table of Contents -->\n";
|
---|
175 |
|
---|
176 |
|
---|
177 | }
|
---|
178 | }
|
---|
179 |
|
---|
180 |
|
---|
181 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
---|
182 | Functions for generating a "Hierarchy" type table of contents. These can be used either
|
---|
183 | at top classification level or at document level (the difference being that a cover
|
---|
184 | image and control buttons are displayed at document level).
|
---|
185 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
---|
186 |
|
---|
187 | void hierarchy_toc (const text_t &classifytype, const text_t &/*classifytitle*/,
|
---|
188 | cgiargsclass &args, recptproto *collectproto,
|
---|
189 | displayclass &disp, outconvertclass &outconvert,
|
---|
190 | ostream &textout, ostream &logout) {
|
---|
191 |
|
---|
192 | textout << "\n<!-- Table of Contents produced by browsetools::hierarchy_toc -->\n\n";
|
---|
193 | textout << "<p><table width=100% cellpadding=0 cellspacing=0 border=0><tr>\n";
|
---|
194 |
|
---|
195 | // get the cover image (if there is one) and the control buttons
|
---|
196 | if (!args["d"].empty()) {
|
---|
197 | textout << "<td valign=top width=200>\n";
|
---|
198 | output_cover_image (args, collectproto, disp, outconvert, textout, logout);
|
---|
199 | output_controls (args, collectproto, disp, outconvert, textout, logout);
|
---|
200 | textout << "</td>\n";
|
---|
201 | }
|
---|
202 |
|
---|
203 | // get table of contents
|
---|
204 | textout << "<td valign=top>\n"
|
---|
205 | << "<table>\n";
|
---|
206 |
|
---|
207 | output_hierarchy (classifytype, args, collectproto, disp, outconvert, textout, logout);
|
---|
208 |
|
---|
209 | textout << "</table>\n"
|
---|
210 | << "</td></tr></table>\n"
|
---|
211 | << "\n<!-- end of Table of Contents -->\n";
|
---|
212 | }
|
---|
213 |
|
---|
214 | void output_hierarchy (const text_t &classifytype, cgiargsclass &args,
|
---|
215 | recptproto *collectproto, displayclass &disp,
|
---|
216 | outconvertclass &outconvert, ostream &textout,
|
---|
217 | ostream &logout) {
|
---|
218 |
|
---|
219 | if (args.getintarg("gc"))
|
---|
220 | output_expanded_hierarchy_toc(args, collectproto, disp, outconvert, textout, logout);
|
---|
221 | else
|
---|
222 | output_contracted_hierarchy_toc(classifytype, args, collectproto, disp, outconvert, textout, logout);
|
---|
223 | }
|
---|
224 |
|
---|
225 | // at the moment this just writes out the html to display
|
---|
226 | // the cover image (assuming it's called cover.jpg)
|
---|
227 | // this whole thing should be done with a call to the collection
|
---|
228 | // server which would send a link to the cover image if there
|
---|
229 | // was one otherwise send title, author and stuff
|
---|
230 | void output_cover_image (cgiargsclass &args, recptproto */*collectproto*/,
|
---|
231 | displayclass &disp, outconvertclass &outconvert,
|
---|
232 | ostream &textout, ostream &/*logout*/) {
|
---|
233 |
|
---|
234 | if (args["d"].empty()) return;
|
---|
235 |
|
---|
236 | textout << outconvert << disp <<
|
---|
237 | "<img src=\"_httpcollection_/archives/_thisOID_/cover.jpg\"><br>\n";
|
---|
238 | }
|
---|
239 |
|
---|
240 | // output_controls displays the detach, expand/contract contents,
|
---|
241 | // expand/contract text and highlighting/no highlighting buttons
|
---|
242 | // and the warning if expanded text is going to be large
|
---|
243 | void output_controls (cgiargsclass &args, recptproto *collectproto,
|
---|
244 | displayclass &disp, outconvertclass &outconvert,
|
---|
245 | ostream &textout, ostream &logout) {
|
---|
246 |
|
---|
247 | if (args["u"] != "1") {
|
---|
248 |
|
---|
249 | FilterResponse_t response;
|
---|
250 | text_tarray metadata;
|
---|
251 | text_t top;
|
---|
252 | get_top (args["d"], top);
|
---|
253 |
|
---|
254 | text_tarray buttons;
|
---|
255 |
|
---|
256 | // detach button
|
---|
257 | buttons.push_back ("_document:imagedetach_");
|
---|
258 |
|
---|
259 | // highlighting button
|
---|
260 | if (args["hl"] == "1")
|
---|
261 | buttons.push_back ("_document:imagenohighlight_");
|
---|
262 | else
|
---|
263 | buttons.push_back ("_document:imagehighlight_");
|
---|
264 |
|
---|
265 | // expand/contract contents button - only have this if it's
|
---|
266 | // a Hierarchy type toc
|
---|
267 | metadata.push_back ("classifytype");
|
---|
268 | if (get_info (top, args["c"], metadata, false, collectproto, response, logout)) {
|
---|
269 | if (response.docInfo[0].metadata[0].values[0] == "Hierarchy")
|
---|
270 | if (args["gc"] == "1")
|
---|
271 | buttons.push_back ("_document:imagecontracttoc_");
|
---|
272 | else
|
---|
273 | buttons.push_back ("_document:imageexpandtoc_");
|
---|
274 | }
|
---|
275 |
|
---|
276 | // expand/contract text button
|
---|
277 | if (args.getintarg("gt"))
|
---|
278 | buttons.push_back ("_document:imagecontracttext_");
|
---|
279 | else
|
---|
280 | buttons.push_back ("_document:imageexpandtext_");
|
---|
281 |
|
---|
282 | text_tarray::const_iterator here = buttons.begin();
|
---|
283 | text_tarray::const_iterator end = buttons.end();
|
---|
284 | int count = 0;
|
---|
285 | while (here != end) {
|
---|
286 | if ((count != 0) && ((count % 3) == 0)) textout << "<br>\n";
|
---|
287 | textout << outconvert << disp << *here;
|
---|
288 | count ++;
|
---|
289 | here ++;
|
---|
290 | }
|
---|
291 | }
|
---|
292 | }
|
---|
293 |
|
---|
294 |
|
---|
295 | void output_contracted_hierarchy_toc (const text_t &classifytype, cgiargsclass &args,
|
---|
296 | recptproto *collectproto,displayclass &disp,
|
---|
297 | outconvertclass &outconvert, ostream &textout,
|
---|
298 | ostream &logout) {
|
---|
299 |
|
---|
300 | int colnum, tabcount = 0;
|
---|
301 | text_tarray parents, metadata;
|
---|
302 | FilterResponse_t siblings;
|
---|
303 | FilterResponse_t response;
|
---|
304 |
|
---|
305 | text_t &arg_d = args["d"];
|
---|
306 | text_t &arg_cl = args["cl"];
|
---|
307 |
|
---|
308 | metadata.push_back ("doctype");
|
---|
309 | metadata.push_back ("Title");
|
---|
310 | metadata.push_back ("hastxt");
|
---|
311 | metadata.push_back ("haschildren");
|
---|
312 |
|
---|
313 | // load up parent and sibling arrays
|
---|
314 | if (arg_d.empty()) {
|
---|
315 | if (has_children (arg_cl, args["c"], collectproto, logout)) {
|
---|
316 | get_parents_array (arg_cl + ".fc", parents);
|
---|
317 | if (!get_children (arg_cl, args["c"], metadata,
|
---|
318 | collectproto, siblings, logout))
|
---|
319 | return;
|
---|
320 | } else {
|
---|
321 | get_parents_array (arg_cl, parents);
|
---|
322 | if (!get_children (arg_cl + ".pr", args["c"], metadata,
|
---|
323 | collectproto, siblings, logout))
|
---|
324 | return;
|
---|
325 | }
|
---|
326 | // don't want top parent of classification to be displayed
|
---|
327 | if (!parents.empty()) parents.erase (parents.begin());
|
---|
328 |
|
---|
329 | // this is a special case for an AZList containing a Hierarchy toc
|
---|
330 | if (classifytype == "AZList" && !parents.empty())
|
---|
331 | parents.erase (parents.begin());
|
---|
332 |
|
---|
333 | } else {
|
---|
334 | if (has_children (arg_d, args["c"], collectproto, logout)) {
|
---|
335 | get_parents_array (arg_d + ".fc", parents);
|
---|
336 | if (!get_children (arg_d, args["c"], metadata,
|
---|
337 | collectproto, siblings, logout))
|
---|
338 | return;
|
---|
339 | } else {
|
---|
340 | get_parents_array (arg_d, parents);
|
---|
341 | if (!get_children (arg_d + ".pr", args["c"], metadata,
|
---|
342 | collectproto, siblings, logout))
|
---|
343 | return;
|
---|
344 | }
|
---|
345 | }
|
---|
346 |
|
---|
347 | colnum = parents.size() + 1;
|
---|
348 |
|
---|
349 | // sort out toc of sections parents
|
---|
350 | if (!parents.empty())
|
---|
351 | output_parents_toc(args, parents, tabcount, colnum, disp, collectproto,
|
---|
352 | outconvert, textout, logout);
|
---|
353 |
|
---|
354 | // sort out toc of sections siblings
|
---|
355 | if (!siblings.docInfo.empty())
|
---|
356 | output_siblings_toc (args, siblings, tabcount, colnum, disp,
|
---|
357 | outconvert, textout, logout);
|
---|
358 | }
|
---|
359 |
|
---|
360 |
|
---|
361 | void output_expanded_hierarchy_toc (cgiargsclass &args, recptproto *collectproto,
|
---|
362 | displayclass &disp, outconvertclass &outconvert,
|
---|
363 | ostream &textout, ostream &logout) {
|
---|
364 |
|
---|
365 | text_t OID, topOID, classifytype, icon;
|
---|
366 | FilterResponse_t response;
|
---|
367 | int tabcols=0, totalcols=0, lasttabcols=0;
|
---|
368 |
|
---|
369 | int gt = args.getintarg("gt");
|
---|
370 | text_t doclink = "<a href=\"_httpdocument_&cl=";
|
---|
371 |
|
---|
372 | text_t &arg_d = args["d"];
|
---|
373 | text_t &arg_cl = args["cl"];
|
---|
374 |
|
---|
375 | if (arg_d.empty()) {
|
---|
376 | if (arg_cl.empty()) return;
|
---|
377 | OID = arg_cl;
|
---|
378 | topOID = OID; // don't always want to expand from top if expanding classifications
|
---|
379 | classifytype = "classify";
|
---|
380 | } else {
|
---|
381 | OID = arg_d;
|
---|
382 | get_top (arg_d, topOID);
|
---|
383 | classifytype = "Document";
|
---|
384 | }
|
---|
385 |
|
---|
386 | // Get OIDs and metadata of all topOIDs contents (and topOID itself)
|
---|
387 | get_contents (topOID, classifytype, totalcols, args["c"], collectproto, response, logout);
|
---|
388 | int excess = countchar (topOID.begin(), topOID.end(), '.');
|
---|
389 | totalcols -= excess;
|
---|
390 |
|
---|
391 | // allow for pointer
|
---|
392 | if (classifytype == "Document" && !gt) totalcols += 2;
|
---|
393 | else totalcols += 1;
|
---|
394 |
|
---|
395 | ResultDocInfo_tarray::const_iterator thissection = response.docInfo.begin();
|
---|
396 | ResultDocInfo_tarray::const_iterator lastsection = response.docInfo.end();
|
---|
397 |
|
---|
398 | int count = 1;
|
---|
399 | while (thissection != lastsection) {
|
---|
400 |
|
---|
401 | const text_t &title = (*thissection).metadata[0].values[0];
|
---|
402 | const int haschildren = (*thissection).metadata[1].values[0].getint();
|
---|
403 | const text_t &doctype = (*thissection).metadata[2].values[0];
|
---|
404 |
|
---|
405 | text_t icontabs, tab, pointer;
|
---|
406 |
|
---|
407 | // set up icon
|
---|
408 | icon = "_document:iconsmalltext_";
|
---|
409 | if (is_top((*thissection).OID))
|
---|
410 | if (classifytype == "Document") icon = "_document:iconopenbook_";
|
---|
411 | else
|
---|
412 | if (doctype == "classify") icon = "_document:iconopenbookshelf_";
|
---|
413 | else icon = "_document:iconclosedbook_";
|
---|
414 | else if (haschildren)
|
---|
415 | if (classifytype == "Document") icon = "_document:iconopenfolder_";
|
---|
416 | else icon = "_document:iconopenbookshelf_";
|
---|
417 |
|
---|
418 | // set up tabbing
|
---|
419 | if ((classifytype == "classify") && (doctype != "classify"))
|
---|
420 | tabcols = lasttabcols + 1;
|
---|
421 | else {
|
---|
422 | tabcols = countchar ((*thissection).OID.begin(), (*thissection).OID.end(), '.');
|
---|
423 | lasttabcols = tabcols;
|
---|
424 | }
|
---|
425 | tabcols -= excess;
|
---|
426 |
|
---|
427 | for (int i = 0; i < tabcols; i++)
|
---|
428 | icontabs += "_document:icontab_";
|
---|
429 |
|
---|
430 | // set up pointer
|
---|
431 | if (classifytype == "Document" && !gt) {
|
---|
432 | if ((*thissection).OID == OID) pointer = "_document:iconpointer_";
|
---|
433 | else pointer = "_document:icontab_";
|
---|
434 | tabcols ++;
|
---|
435 | }
|
---|
436 |
|
---|
437 | int colsremaining = totalcols - tabcols;
|
---|
438 |
|
---|
439 | if (tabcols > 0) {
|
---|
440 | tab = "<td";
|
---|
441 | if (tabcols > 1) tab += " colspan=" + text_t(tabcols);
|
---|
442 | tab += ">" + icontabs + pointer + "</td>";
|
---|
443 | }
|
---|
444 |
|
---|
445 | textout << outconvert << disp << "<tr>" << tab << "<td>";
|
---|
446 |
|
---|
447 | if ((classifytype == "Document") && (is_top((*thissection).OID)) &&
|
---|
448 | (args.getintarg("x")))
|
---|
449 | textout << outconvert << disp << icon << "</td><td";
|
---|
450 |
|
---|
451 | else {
|
---|
452 | if (!gt) {
|
---|
453 | const text_t &thisOID = (*thissection).OID;
|
---|
454 | text_t link;
|
---|
455 | if (is_top (thisOID))
|
---|
456 | if (classifytype == "classify")
|
---|
457 | link = doclink + arg_cl + "&d=" + thisOID + "\">";
|
---|
458 | else
|
---|
459 | if (arg_cl.empty())
|
---|
460 | link.clear();
|
---|
461 | else if (arg_cl == "search")
|
---|
462 | link = "<a href=\"_httpquery_\">";
|
---|
463 | else
|
---|
464 | link = doclink + arg_cl + "\">";
|
---|
465 | else
|
---|
466 | if (haschildren)
|
---|
467 | if (classifytype == "classify")
|
---|
468 | link = doclink + thisOID + ".pr\">";
|
---|
469 | else
|
---|
470 | link = doclink + arg_cl + "&d=" + thisOID + ".pr\">";
|
---|
471 | else
|
---|
472 | if (classifytype == "classify")
|
---|
473 | link = doclink + thisOID + "\">";
|
---|
474 | else
|
---|
475 | link = doclink + arg_cl + "&d=" + thisOID + "\">";
|
---|
476 |
|
---|
477 | textout << outconvert << disp << link;
|
---|
478 | } else {
|
---|
479 | textout << "<a href=\"#" << count << "\">";
|
---|
480 | count ++;
|
---|
481 | }
|
---|
482 |
|
---|
483 | textout << outconvert << disp << icon << "</a></td><td";
|
---|
484 | }
|
---|
485 | if (colsremaining > 1) textout << " colspan=" << colsremaining;
|
---|
486 | textout << outconvert << disp << ">" << title << "</td></tr>\n";
|
---|
487 |
|
---|
488 | thissection ++;
|
---|
489 | }
|
---|
490 | }
|
---|
491 |
|
---|
492 |
|
---|
493 | void output_parents_toc (cgiargsclass &args, const text_tarray &parents,
|
---|
494 | int &tabcount, int &colnum, displayclass &disp,
|
---|
495 | recptproto *collectproto, outconvertclass &outconvert,
|
---|
496 | ostream &textout, ostream &logout) {
|
---|
497 |
|
---|
498 | text_t tab, icon;
|
---|
499 | text_tarray metadata;
|
---|
500 | FilterResponse_t response;
|
---|
501 | text_t doclink = "<a href=\"_httpdocument_";
|
---|
502 |
|
---|
503 | text_t &arg_cl = args["cl"];
|
---|
504 |
|
---|
505 | metadata.push_back ("doctype");
|
---|
506 | metadata.push_back ("Title");
|
---|
507 |
|
---|
508 | text_tarray::const_iterator thisparent = parents.begin();
|
---|
509 | text_tarray::const_iterator end = parents.end();
|
---|
510 |
|
---|
511 | while (thisparent != end) {
|
---|
512 | if (get_info (*thisparent, args["c"], metadata, false, collectproto, response, logout)) {
|
---|
513 | text_t &doctype = response.docInfo[0].metadata[0].values[0];
|
---|
514 | text_t &title = response.docInfo[0].metadata[1].values[0];
|
---|
515 |
|
---|
516 | text_t icontabs, pointer;
|
---|
517 | tab.clear();
|
---|
518 |
|
---|
519 | // set up icon for this parent
|
---|
520 | icon = "_document:iconopenfolder_";
|
---|
521 | if (doctype == "classify") icon = "_document:iconopenbookshelf_";
|
---|
522 | else if (is_top(*thisparent)) icon = "_document:iconopenbook_";
|
---|
523 |
|
---|
524 | for (int j = 0; j < tabcount; j++)
|
---|
525 | icontabs += "_document:icontab_";
|
---|
526 |
|
---|
527 | if (doctype != "classify") {
|
---|
528 | if (*thisparent == args["d"]) {
|
---|
529 | icontabs += "_document:iconpointer_";
|
---|
530 | if (is_top (*thisparent))
|
---|
531 | tabcount ++;
|
---|
532 | else
|
---|
533 | icontabs.erase (icontabs.begin(), icontabs.begin()+18);
|
---|
534 | }
|
---|
535 | }
|
---|
536 |
|
---|
537 | if (!icontabs.empty()) {
|
---|
538 | tab = "<td valign=top";
|
---|
539 | if (tabcount > 1) tab += " colspan=" + text_t(tabcount);
|
---|
540 | tab += ">" + icontabs + "</td>";
|
---|
541 | }
|
---|
542 | tabcount ++;
|
---|
543 |
|
---|
544 | textout << outconvert << disp << "<tr>" << tab << "<td valign=top>";
|
---|
545 |
|
---|
546 | if (is_top(*thisparent) && args["x"] == "1") {
|
---|
547 | textout << outconvert << disp << icon;
|
---|
548 | } else {
|
---|
549 | text_t link;
|
---|
550 | if (doctype == "classify") link = doclink + "&cl=" + *thisparent + ".pr\">";
|
---|
551 | else
|
---|
552 | if (is_top (*thisparent))
|
---|
553 | if (arg_cl.empty())
|
---|
554 | link.clear();
|
---|
555 | else if (arg_cl == "search")
|
---|
556 | link = "<a href=\"_httpquery_\">";
|
---|
557 | else
|
---|
558 | link = doclink + "&cl=" + arg_cl + "\">";
|
---|
559 | else link = doclink + "&cl=" + arg_cl + "&d=" + *thisparent + ".pr\">";
|
---|
560 |
|
---|
561 | textout << outconvert << disp << link << icon << "</a>";
|
---|
562 | }
|
---|
563 | textout << "</td><td";
|
---|
564 | if (colnum > 1) textout << outconvert << " colspan=" << text_t(colnum);
|
---|
565 | textout << outconvert << disp << ">" << title << "</td></tr>\n";
|
---|
566 | colnum --;
|
---|
567 | }
|
---|
568 | thisparent ++;
|
---|
569 | }
|
---|
570 | }
|
---|
571 |
|
---|
572 | void output_siblings_toc (cgiargsclass &args, const FilterResponse_t &siblings,
|
---|
573 | int &tabcount, int &colnum, displayclass &disp,
|
---|
574 | outconvertclass &outconvert, ostream &textout,
|
---|
575 | ostream &/*logout*/) {
|
---|
576 |
|
---|
577 | text_t tab, icon, pointer, child, doclink;
|
---|
578 | int count = 1;
|
---|
579 |
|
---|
580 | doclink = "<a href=\"_httpdocument_";
|
---|
581 |
|
---|
582 | ResultDocInfo_tarray::const_iterator thissibling = siblings.docInfo.begin();
|
---|
583 | ResultDocInfo_tarray::const_iterator sibend = siblings.docInfo.end();
|
---|
584 |
|
---|
585 | while (thissibling != sibend) {
|
---|
586 |
|
---|
587 | const text_t &doctype = (*thissibling).metadata[0].values[0];
|
---|
588 | const text_t &title = (*thissibling).metadata[1].values[0];
|
---|
589 | int hastxt = (*thissibling).metadata[2].values[0].getint();
|
---|
590 | int haschildren = (*thissibling).metadata[3].values[0].getint();
|
---|
591 | int gt = args.getintarg("gt");
|
---|
592 |
|
---|
593 | // set up icon for this sibling
|
---|
594 | icon = "_document:iconclosedfolder_";
|
---|
595 | if (doctype == "classify") icon = "_document:iconclosedbookshelf_";
|
---|
596 | else if (is_top((*thissibling).OID)) icon = "_document:iconclosedbook_";
|
---|
597 |
|
---|
598 | // fit pointer into tabbing if current section
|
---|
599 | // note that we don't want pointers at classification levels anymore
|
---|
600 | // (unless the classification contains text)
|
---|
601 | pointer = "_document:icontab_";
|
---|
602 | if (doctype == "classify") {
|
---|
603 | if ((*thissibling).OID == args["cl"] && hastxt)
|
---|
604 | pointer = "_document:iconpointer_";
|
---|
605 | } else if ((*thissibling).OID == args["d"]) pointer = "_document:iconpointer_";
|
---|
606 |
|
---|
607 | text_t thesetabs;
|
---|
608 | for (int j = 0; j < (tabcount - 1); j++)
|
---|
609 | thesetabs += "_document:icontab_";
|
---|
610 |
|
---|
611 | tab = "<td valign=top";
|
---|
612 | if (tabcount > 1) tab += " colspan=" + text_t(tabcount);
|
---|
613 | tab += ">" + thesetabs + pointer + "</td>";
|
---|
614 |
|
---|
615 | if (!haschildren) {
|
---|
616 | // sibling is text document
|
---|
617 | icon = "_document:iconsmalltext_";
|
---|
618 | text_t link;
|
---|
619 | if (doctype == "classify") link = "&cl=" + (*thissibling).OID;
|
---|
620 | else link = "&cl=" + args["cl"] + "&d=" + (*thissibling).OID;
|
---|
621 |
|
---|
622 | textout << outconvert << disp << "<tr>" << tab << "<td valign=top>";
|
---|
623 | if (!gt) {
|
---|
624 | textout << outconvert << disp << doclink << link;
|
---|
625 | } else {
|
---|
626 | textout << "<a href=\"#" << count;
|
---|
627 | count ++;
|
---|
628 | }
|
---|
629 | textout << outconvert << disp << "\">" << icon << "</a></td><td";
|
---|
630 | if (colnum > 1) textout << " colspan=" << colnum;
|
---|
631 | textout << outconvert << disp << ">" << title << "</td></tr>\n";
|
---|
632 |
|
---|
633 | } else {
|
---|
634 | // sibling is closed book or folder
|
---|
635 | text_t link;
|
---|
636 | if (doctype == "classify") link = "&cl=" + (*thissibling).OID;
|
---|
637 | else link = "&cl=" + args["cl"] + "&d=" + (*thissibling).OID;
|
---|
638 |
|
---|
639 | textout << outconvert << disp << "<tr>" << tab << "<td valign=top>"
|
---|
640 | << doclink << link << "\">" << icon << "</a></td><td";
|
---|
641 | if (colnum > 1) textout << " colspan=" << colnum;
|
---|
642 | textout << outconvert << disp << ">" << title << "</td></tr>\n";
|
---|
643 | }
|
---|
644 | thissibling ++;
|
---|
645 | }
|
---|
646 | }
|
---|
647 |
|
---|
648 |
|
---|
649 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
---|
650 | Functions for generating a "List" type table of contents. These can be used only
|
---|
651 | at classification level as it doesn't make sense to display document level stuff
|
---|
652 | this way (I think!!)
|
---|
653 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
---|
654 |
|
---|
655 | void list_toc (const text_t &/*classifytype*/, const text_t &classifytitle,
|
---|
656 | cgiargsclass &args, recptproto *collectproto,
|
---|
657 | displayclass &disp, outconvertclass &outconvert,
|
---|
658 | ostream &textout, ostream &logout) {
|
---|
659 |
|
---|
660 | text_tarray metadata;
|
---|
661 | FilterResponse_t response;
|
---|
662 | text_t &arg_cl = args["cl"];
|
---|
663 | text_t doclink = "<a href=\"_httpdocument_&cl=" + arg_cl + "&d=";
|
---|
664 |
|
---|
665 | metadata.push_back (classifytitle);
|
---|
666 | metadata.push_back ("Title");
|
---|
667 |
|
---|
668 | if (get_children (arg_cl, args["c"], metadata, collectproto, response, logout)) {
|
---|
669 |
|
---|
670 | textout
|
---|
671 | << "\n<!-- Table of Contents produced by browsetools::output_list_toc "
|
---|
672 | << "-->\n\n<p>\n";
|
---|
673 |
|
---|
674 | ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
|
---|
675 | ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
|
---|
676 |
|
---|
677 | while (sechere != secend) {
|
---|
678 |
|
---|
679 | const text_t &ctitle = (*sechere).metadata[0].values[0];
|
---|
680 | const text_t &title = (*sechere).metadata[1].values[0];
|
---|
681 |
|
---|
682 | if (!ctitle.empty()) {
|
---|
683 | textout << outconvert << disp << "<br>" << doclink << (*sechere).OID
|
---|
684 | << "\">" + ctitle + "</a>\n";
|
---|
685 | } else if (!title.empty()) {
|
---|
686 | textout << outconvert << disp << "<br>" << doclink << (*sechere).OID
|
---|
687 | << "\">" + title + "</a>\n";
|
---|
688 | }
|
---|
689 | sechere ++;
|
---|
690 | }
|
---|
691 |
|
---|
692 | textout << "\n<!-- end of Table of Contents -->\n";
|
---|
693 | }
|
---|
694 | }
|
---|
695 |
|
---|
696 |
|
---|
697 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
---|
698 | Functions for generating an "AZList" type table of contents. These can be used only
|
---|
699 | at classification level as it doesn't make sense to display document level stuff
|
---|
700 | this way (I think!!)
|
---|
701 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
---|
702 |
|
---|
703 | void azlist_toc (const text_t &classifytype, const text_t &classifytitle,
|
---|
704 | cgiargsclass &args, recptproto *collectproto,
|
---|
705 | displayclass &disp, outconvertclass &outconvert,
|
---|
706 | ostream &textout, ostream &logout) {
|
---|
707 |
|
---|
708 | text_tarray metadata;
|
---|
709 | FilterResponse_t response;
|
---|
710 | text_t &arg_cl = args["cl"];
|
---|
711 |
|
---|
712 | textout
|
---|
713 | << "\n<!-- Table of Contents produced by browsetools::azlist_toc -->\n\n"
|
---|
714 | << "<table cellpadding=0 cellspacing=2>\n";
|
---|
715 |
|
---|
716 |
|
---|
717 | if (classifytype == "AZList") {
|
---|
718 |
|
---|
719 | metadata.push_back ("Title");
|
---|
720 | metadata.push_back ("Creator");
|
---|
721 | metadata.push_back ("doctype");
|
---|
722 |
|
---|
723 | if (get_children (arg_cl, args["c"], metadata, collectproto, response, logout))
|
---|
724 | output_azlist (response, classifytitle, arg_cl, disp, outconvert, textout);
|
---|
725 | }
|
---|
726 |
|
---|
727 | else if (classifytype == "Hierarchy")
|
---|
728 | output_hierarchy ("AZList", args, collectproto, disp, outconvert, textout, logout);
|
---|
729 |
|
---|
730 | textout << "</table>\n"
|
---|
731 | << "<!-- end of Table of Contents -->\n";
|
---|
732 |
|
---|
733 | }
|
---|
734 |
|
---|
735 | // note that this function expects response to contain three fields of metadata
|
---|
736 | // ("Title", "Creator", "doctype") - if they're not there it may cause a run-time error
|
---|
737 | void output_azlist (const FilterResponse_t &response, const text_t &classifytitle,
|
---|
738 | const text_t &arg_cl, displayclass &disp,
|
---|
739 | outconvertclass &outconvert, ostream &textout) {
|
---|
740 |
|
---|
741 | bool iscreator = false;
|
---|
742 | if (classifytitle == "Creator") iscreator = true;
|
---|
743 |
|
---|
744 | ResultDocInfo_tarray::const_iterator sechere = response.docInfo.begin();
|
---|
745 | ResultDocInfo_tarray::const_iterator secend = response.docInfo.end();
|
---|
746 |
|
---|
747 | while (sechere != secend) {
|
---|
748 |
|
---|
749 | const text_t &title = (*sechere).metadata[0].values[0];
|
---|
750 | const text_t &creator = (*sechere).metadata[1].values[0];
|
---|
751 | const text_t &doctype = (*sechere).metadata[2].values[0];
|
---|
752 |
|
---|
753 | text_t link = "<a href=\"_httpdocument_&cl=";
|
---|
754 | text_t icon = "_document:iconclosedbook_";
|
---|
755 |
|
---|
756 | if (doctype == "classify") {
|
---|
757 | icon = "_document:iconclosedbookshelf_";
|
---|
758 | link += (*sechere).OID;
|
---|
759 | } else {
|
---|
760 | link += arg_cl + "&d=" + (*sechere).OID;
|
---|
761 | }
|
---|
762 |
|
---|
763 | if (iscreator) {
|
---|
764 | if (!creator.empty()) {
|
---|
765 | textout << outconvert << disp << "<tr><td valign=top>" << link << "\">"
|
---|
766 | << icon << "</a></td><td>" << creator << "</td><td>";
|
---|
767 |
|
---|
768 | if (!title.empty())
|
---|
769 | textout << outconvert << " " << title;
|
---|
770 | }
|
---|
771 | } else {
|
---|
772 | if (!title.empty()) {
|
---|
773 | textout << outconvert << disp << "<tr><td valign=top>" << link << "\">"
|
---|
774 | << icon << "</a></td><td>" << title << "</td><td>";
|
---|
775 |
|
---|
776 | if (!creator.empty())
|
---|
777 | textout << outconvert << " " << creator;
|
---|
778 | }
|
---|
779 | }
|
---|
780 | textout << "</td></tr>\n";
|
---|
781 | sechere ++;
|
---|
782 | }
|
---|
783 | }
|
---|
784 |
|
---|
785 |
|
---|
786 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
---|
787 | Functions for generating a "DateList" type table of contents. These can be used only
|
---|
788 | at classification level as it doesn't make sense to display document level stuff
|
---|
789 | this way (I think!!)
|
---|
790 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
---|
791 |
|
---|
792 | void datelist_toc (const text_t &/*classifytype*/, const text_t &/*classifytitle*/,
|
---|
793 | cgiargsclass &/*args*/, recptproto */*collectproto*/,
|
---|
794 | displayclass &/*disp*/, outconvertclass &/*outconvert*/,
|
---|
795 | ostream &/*textout*/, ostream &/*logout*/) {
|
---|
796 | }
|
---|
797 |
|
---|
798 |
|
---|
799 |
|
---|
800 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
---|
801 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
|
---|
802 |
|
---|
803 | // set_arrow_macros sets the _httpprevarrow_ and _httpnextarrow_ macros
|
---|
804 | // it shouldn't be called if OID is the top level of a book
|
---|
805 | // as the "hasprevious" and "hasnext" metadata won't be set
|
---|
806 | // when the filter can't get OIDs parent info - one day I'll
|
---|
807 | // fix this ;-)
|
---|
808 | void set_arrow_macros (const text_t &OID, const text_t &classifytype,
|
---|
809 | displayclass &disp, recptproto *collectproto,
|
---|
810 | const text_t &collection, ostream &logout) {
|
---|
811 |
|
---|
812 | if (OID.empty()) return;
|
---|
813 |
|
---|
814 | text_tarray metadata;
|
---|
815 | FilterResponse_t response;
|
---|
816 |
|
---|
817 | metadata.push_back ("haschildren");
|
---|
818 | metadata.push_back ("hasnext");
|
---|
819 | metadata.push_back ("hasprevious");
|
---|
820 | // get "haschildren", "hasnext" and "hasprevious" metadata for OID
|
---|
821 | if (get_info (OID, collection, metadata, false, collectproto, response, logout)) {
|
---|
822 |
|
---|
823 | text_t haschildren = response.docInfo[0].metadata[0].values[0];
|
---|
824 | text_t hasnext = response.docInfo[0].metadata[1].values[0];
|
---|
825 | text_t hasprevious = response.docInfo[0].metadata[2].values[0];
|
---|
826 |
|
---|
827 | if ((classifytype == "Hierarchy") || (classifytype == "Book")) {
|
---|
828 | if (haschildren == "1")
|
---|
829 | disp.setmacro ("httpnextarrow", "document",
|
---|
830 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.fc,_httpdocument_&cl=_cgiargcl_.fc)");
|
---|
831 | else if (hasnext == "1")
|
---|
832 | disp.setmacro ("httpnextarrow", "document",
|
---|
833 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ns,_httpdocument_&cl=_cgiargcl_.ns)");
|
---|
834 | else {
|
---|
835 | // see if parent has younger siblings
|
---|
836 | if (get_info (OID + ".pr", collection, metadata, false, collectproto, response, logout)) {
|
---|
837 | if (!response.docInfo[0].metadata.empty() &&
|
---|
838 | response.docInfo[0].metadata[1].values[0] == "1")
|
---|
839 | disp.setmacro ("httpnextarrow", "document",
|
---|
840 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.pr.ns,_httpdocument_&cl=_cgiargcl_.pr.ns)");
|
---|
841 | }
|
---|
842 | }
|
---|
843 |
|
---|
844 | if (hasprevious == "1") {
|
---|
845 | // see if OIDs older sibling has children
|
---|
846 | if (get_info (OID + ".ps", collection, metadata, false, collectproto, response, logout)) {
|
---|
847 | if (!response.docInfo[0].metadata.empty() &&
|
---|
848 | response.docInfo[0].metadata[0].values[0] == "1")
|
---|
849 | disp.setmacro ("httpprevarrow", "document",
|
---|
850 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps.lc,_httpdocument_&cl=_cgiargcl_.ps.lc)");
|
---|
851 | else
|
---|
852 | disp.setmacro ("httpprevarrow", "document",
|
---|
853 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps,_httpdocument_&cl=_cgiargcl_.ps)");
|
---|
854 | }
|
---|
855 | } else if (!is_top (OID))
|
---|
856 | disp.setmacro ("httpprevarrow", "document",
|
---|
857 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.pr,_httpdocument_&cl=_cgiargcl_.pr)");
|
---|
858 | }
|
---|
859 |
|
---|
860 | else {
|
---|
861 | if (hasnext == "1")
|
---|
862 | disp.setmacro ("httpnextarrow", "document",
|
---|
863 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ns,_httpdocument_&cl=_cgiargcl_.ns)");
|
---|
864 | if (hasprevious == "1")
|
---|
865 | disp.setmacro ("httpprevarrow", "document",
|
---|
866 | "_If_(_cgiargd_,_httpdocument_&cl=_cgiargcl_&d=_cgiargd_.ps,_httpdocument_&cl=_cgiargcl_.ps)");
|
---|
867 | }
|
---|
868 | }
|
---|
869 | }
|
---|