source: trunk/gsdl/src/recpt/browsetools.cpp@ 296

Last change on this file since 296 was 293, checked in by rjmcnab, 25 years ago

Fixed a small "bug" -- well I probably just covered another one...

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