Changeset 4868 for trunk/gsdl/src/recpt/documentaction.cpp
- Timestamp:
- 2003-07-02T23:18:45+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/documentaction.cpp
r4774 r4868 532 532 ((*format_here).second == "false")) 533 533 formatinfo.DocumentArrowsBottom = false; 534 else if (((*format_here).first == "DocumentArrowsTop") && 535 ((*format_here).second == "true")) 536 formatinfo.DocumentArrowsTop = true; 534 537 else if ((*format_here).first == "DocumentButtons") 535 538 splitchar ((*format_here).second.begin(), (*format_here).second.end(), … … 549 552 550 553 // never want arrows when text is expanded 551 if (gt) formatinfo.DocumentArrowsBottom = false; 554 if (gt) { 555 formatinfo.DocumentArrowsBottom = false; 556 formatinfo.DocumentArrowsTop = false; 557 } 552 558 } 553 559 … … 565 571 // _imagethispage_ the title image to be displayed at top right of page 566 572 567 // _navarrows _this may be overridden to "" when format option573 // _navarrowsbottom_ this may be overridden to "" when format option 568 574 // DocumentArrowsBottom is false 575 576 // _navarrowstop_ likewise for DocumentArrowsTop 577 578 // _httpprevarrow_ links to next and previous sections of document - used 579 // _httpnextarrow_ by DocumentArrowsBottom 569 580 570 581 // _header_ the header macro is overridden if we're not at a top level … … 585 596 text_t &arg_cl = args["cl"]; 586 597 587 if (!formatinfo.DocumentArrowsBottom) 588 disp.setmacro("navarrows", "document", ""); 598 if (!formatinfo.DocumentArrowsBottom) { 599 disp.setmacro("navarrowsbottom", "document", ""); 600 } else if (!formatinfo.DocumentArrowsBottom) { 601 disp.setmacro("navarrowstop", "document", ""); 602 } 603 604 if (!arg_d.empty() && (formatinfo.DocumentArrowsBottom || formatinfo.DocumentArrowsTop)) { 605 // set _httpprevarrow_ and _httpnextarrow_ 606 set_arrow_macros (args, collectproto, disp, logout); 607 } 589 608 590 609 metadata.insert ("Title"); … … 787 806 disp, outconvert, textout, logout); 788 807 808 if (formatinfo.DocumentArrowsTop && !args["d"].empty()) { 809 textout << outconvert << disp << "_document:navarrowstop_\n"; 810 } 811 789 812 //output the related documents (may be the empty string) 790 813 //will not output the docs if a format string is specified … … 973 996 delete formatlistptr; 974 997 } 998 999 void documentaction::set_arrow_macros (cgiargsclass &args, recptproto *collectproto, 1000 displayclass &disp, ostream &logout) { 1001 1002 text_tset metadata; 1003 FilterResponse_t response; 1004 FilterResponse_t presponse; 1005 1006 int haschildren = 0; 1007 text_tarray next_siblings; 1008 text_t previous_sibling; 1009 text_t &arg_d = args["d"]; 1010 1011 // get info on current section 1012 metadata.insert("haschildren"); 1013 if (!get_info(arg_d, args["c"], metadata, false, collectproto, response, logout)) { 1014 logout << "error 1 in documentaction::set_arrow_macros\n"; 1015 return; 1016 } 1017 haschildren = response.docInfo[0].metadata["haschildren"].values[0].getint(); 1018 1019 // get OIDs of next and previous siblings of current section and 1020 // all it's parents 1021 int parentcount = countchar(arg_d.begin(), arg_d.end(), '.'); 1022 text_t thisoid = arg_d; 1023 while (parentcount > 0) { 1024 get_children (get_parent(thisoid), args["c"], metadata, false, 1025 collectproto, response, logout); 1026 ResultDocInfo_tarray::iterator this_sibling = response.docInfo.begin(); 1027 ResultDocInfo_tarray::iterator last_sibling = response.docInfo.end(); 1028 bool first = true; 1029 while (this_sibling != last_sibling) { 1030 if ((*this_sibling).OID == thisoid) { 1031 if (!first && next_siblings.empty()) { 1032 previous_sibling = (*(this_sibling-1)).OID; 1033 int section_has_children = (*(this_sibling-1)).metadata["haschildren"].values[0].getint(); 1034 // if previous sibling has children we need to recurse 1035 // down to the last descendant 1036 while (section_has_children) { 1037 get_children (previous_sibling, args["c"], metadata, false, 1038 collectproto, presponse, logout); 1039 if (!presponse.docInfo.empty()) { 1040 ResultDocInfo_tarray::iterator it = presponse.docInfo.end() - 1; 1041 previous_sibling = (*it).OID; 1042 section_has_children = (*it).metadata["haschildren"].values[0].getint(); 1043 } else { 1044 section_has_children = 0; // this should never happen 1045 } 1046 } 1047 } 1048 1049 if ((this_sibling+1) != last_sibling) { 1050 next_siblings.push_back((*(this_sibling+1)).OID); 1051 } else { 1052 next_siblings.push_back(""); 1053 } 1054 break; 1055 } 1056 this_sibling++; 1057 first = false; 1058 } 1059 thisoid = get_parent(thisoid); 1060 parentcount--; 1061 } 1062 1063 // work out values for next link 1064 if (haschildren) { 1065 disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + args["cl"] + 1066 "&d=" + arg_d + ".fc"); 1067 } else { 1068 text_tarray::const_iterator h = next_siblings.begin(); 1069 text_tarray::const_iterator e = next_siblings.end(); 1070 while (h != e) { 1071 if (!(*h).empty()) { 1072 disp.setmacro ("httpnextarrow", "document", "_httpdocument_&cl=" + args["cl"] + 1073 "&d=" + *h); 1074 break; 1075 } 1076 h++; 1077 } 1078 } 1079 1080 // work out value for previous link 1081 if (!previous_sibling.empty()) { 1082 disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + args["cl"] + 1083 "&d=" + previous_sibling); 1084 } else { 1085 if (countchar(arg_d.begin(), arg_d.end(), '.')) { 1086 disp.setmacro ("httpprevarrow", "document", "_httpdocument_&cl=" + args["cl"] + 1087 "&d=" + get_parent(arg_d)); 1088 } 1089 } 1090 }
Note:
See TracChangeset
for help on using the changeset viewer.