Changeset 4906 for trunk/gsdl/src/recpt/formattools.cpp
- Timestamp:
- 2003-07-12T08:58:10+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/formattools.cpp
r4868 r4906 32 32 33 33 // a few function prototypes 34 34 35 static text_t format_string (const text_t& collection, recptproto* collectproto, 35 36 ResultDocInfo_t &docinfo, displayclass &disp, 36 format_t *formatlistptr, 37 const text_t &link, const text_t &icon, 38 const text_t &text, bool highlight, ostream& logout); 37 format_t *formatlistptr, text_tmap &options, 38 ostream& logout); 39 39 40 40 static bool parse_action (text_t::const_iterator &here, const text_t::const_iterator &end, 41 41 format_t *formatlistptr, text_tset &metadata, bool &getParents); 42 42 43 text_t format_summary (const text_t& collection, recptproto* collectproto, 44 ResultDocInfo_t &docinfo, displayclass &disp, 45 const text_t &text, bool highlight, 46 ostream& logout); 43 static text_t format_summary (const text_t& collection, recptproto* collectproto, 44 ResultDocInfo_t &docinfo, displayclass &disp, 45 text_tmap &options, ostream& logout); 47 46 48 47 … … 866 865 static text_t get_or (const text_t& collection, recptproto* collectproto, 867 866 ResultDocInfo_t &docinfo, displayclass &disp, 868 format_t *orptr, 869 const text_t &link, const text_t &icon, 870 const text_t &text, bool highlight, 867 format_t *orptr, text_tmap &options, 871 868 ostream& logout) { 872 869 … … 875 872 876 873 tmp = format_string (collection,collectproto, docinfo, disp, orptr, 877 link, icon, text, highlight, logout);874 options, logout); 878 875 if (!tmp.empty()) return tmp; 879 876 … … 886 883 ResultDocInfo_t &docinfo, displayclass &disp, 887 884 const decision_t &decision, 888 format_t *ifptr, format_t *elseptr, const text_t &link, 889 const text_t &icon, const text_t &text, bool highlight, 890 ostream& logout) 885 format_t *ifptr, format_t *elseptr, 886 text_tmap &options, ostream& logout) 891 887 { 892 888 … … 897 893 if (ifptr != NULL) 898 894 return get_formatted_string (collection,collectproto, docinfo, disp, ifptr, 899 link, icon, text, highlight, logout);895 options, logout); 900 896 } 901 897 else { 902 898 if (elseptr != NULL) 903 899 return get_formatted_string (collection,collectproto, docinfo, disp, elseptr, 904 link, icon, text, highlight, logout);900 options, logout); 905 901 } 906 902 } … … 920 916 if (ifptr != NULL) 921 917 return get_formatted_string (collection, collectproto, docinfo, disp, ifptr, 922 link, icon, text, highlight, logout);918 options, logout); 923 919 } else { 924 920 if (elseptr != NULL) 925 921 return get_formatted_string (collection, collectproto, docinfo, disp, elseptr, 926 link, icon, text, highlight, logout);922 options, logout); 927 923 } 928 924 } … … 947 943 text_t format_string (const text_t& collection, recptproto* collectproto, 948 944 ResultDocInfo_t &docinfo, displayclass &disp, 949 format_t *formatlistptr, 950 const text_t &link, const text_t &icon, 951 const text_t &text, bool highlight, 945 format_t *formatlistptr, text_tmap &options, 952 946 ostream& logout) { 953 947 … … 958 952 return formatlistptr->text; 959 953 case comLink: 960 return link;954 return options["link"]; 961 955 case comEndLink: 962 if ( link.empty()) return "";956 if (options["link"].empty()) return ""; 963 957 else return "</a>"; 964 958 case comHref: 965 return get_href( link);959 return get_href(options["link"]); 966 960 case comIcon: 967 return icon;961 return options["icon"]; 968 962 case comNum: 969 963 return docinfo.result_num; … … 971 965 return get_related_docs(collection, collectproto, docinfo, logout); 972 966 case comSummary: 973 return format_summary(collection, collectproto,docinfo,disp,text,highlight,logout);967 return format_summary(collection, collectproto, docinfo, disp, options, logout); 974 968 case comMeta: 975 969 … … 998 992 = get_formatted_string(collection, collectproto, 999 993 response.docInfo[0], disp, expanded_formatlistptr, 1000 link, icon, highlight, logout);994 options, logout); 1001 995 1002 996 return expanded_metavalue; … … 1013 1007 } 1014 1008 case comDoc: 1015 return text;1009 return options["text"]; 1016 1010 case comHighlight: 1017 if ( highlight) return "<b>";1011 if (options["highlight"] == "1") return "<b>"; 1018 1012 break; 1019 1013 case comEndHighlight: 1020 if ( highlight) return "</b>";1014 if (options["highlight"] == "1") return "</b>"; 1021 1015 break; 1022 1016 case comIf: 1023 1017 return get_if (collection, collectproto, docinfo, disp, 1024 1018 formatlistptr->decision, formatlistptr->ifptr, 1025 formatlistptr->elseptr, link, icon, text, highlight, 1026 logout); 1019 formatlistptr->elseptr, options, logout); 1027 1020 case comOr: 1028 1021 return get_or (collection,collectproto, docinfo, disp, formatlistptr->orptr, 1029 link, icon, text, highlight, logout);1022 options, logout); 1030 1023 } 1031 1024 return ""; 1032 }1033 1034 1035 1036 1037 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,1038 ResultDocInfo_t& docinfo, displayclass &disp,1039 format_t* formatlistptr,1040 const text_t& link, const text_t& icon,1041 const text_t& text, const bool highlight,1042 ostream& logout) {1043 1044 text_t ft;1045 while (formatlistptr != NULL)1046 {1047 ft += format_string (collection, collectproto, docinfo, disp, formatlistptr,1048 link, icon, text, highlight, logout);1049 formatlistptr = formatlistptr->nextptr;1050 }1051 1052 return ft;1053 1025 } 1054 1026 1055 1027 text_t get_formatted_string (const text_t& collection, recptproto* collectproto, 1056 1028 ResultDocInfo_t &docinfo, displayclass &disp, 1057 format_t *formatlistptr, 1058 const text_t &link, const text_t &icon, 1059 const bool highlight, 1029 format_t *formatlistptr, text_tmap &options, 1060 1030 ostream& logout) { 1061 1031 1062 text_t text = ""; 1063 1064 return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr, 1065 link, icon, text, highlight, logout); 1066 } 1067 1068 text_t get_formatted_string (const text_t& collection, recptproto* collectproto, 1069 ResultDocInfo_t &docinfo, displayclass &disp, 1070 format_t *formatlistptr, 1071 const text_t& text, 1072 ostream& logout) { 1073 1074 text_t link = "<a href=\"_httpdocument_&cl=search&d=" + docinfo.OID + "\">"; 1075 text_t icon = "_icontext_"; 1076 bool highlight = false; 1077 1078 return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr, 1079 link, icon, text, highlight, logout); 1080 } 1081 1082 text_t get_formatted_string (const text_t& collection, recptproto* collectproto, 1083 ResultDocInfo_t &docinfo, displayclass &disp, 1084 format_t *formatlistptr, 1085 ostream& logout) { 1086 1087 text_t text = ""; 1088 1089 return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr, 1090 text, logout); 1032 text_t ft; 1033 while (formatlistptr != NULL) 1034 { 1035 ft += format_string (collection, collectproto, docinfo, disp, formatlistptr, 1036 options, logout); 1037 formatlistptr = formatlistptr->nextptr; 1038 } 1039 1040 return ft; 1091 1041 } 1092 1042 … … 1097 1047 1098 1048 text_t format_summary (const text_t& collection, recptproto* collectproto, 1099 ResultDocInfo_t &docinfo, displayclass &disp, 1100 const text_t &text, bool highlight, 1101 ostream& logout) { 1049 ResultDocInfo_t &docinfo, displayclass &disp, 1050 text_tmap &options, ostream& logout) { 1102 1051 1103 1052 // GRB: added code here to ensure that the cstr (and other collections) … … 1111 1060 1112 1061 text_t textToSummarise, query; 1113 if( text.empty()) { // get document text1114 1115 1116 1117 1118 1119 1062 if(options["text"].empty()) { // get document text 1063 DocumentRequest_t docrequest; 1064 DocumentResponse_t docresponse; 1065 comerror_t err; 1066 docrequest.OID = docinfo.OID; 1067 collectproto->get_document (collection, docrequest, docresponse, err, logout); 1068 textToSummarise = docresponse.doc; 1120 1069 } else // in practice, this would not happen, because text is only 1121 1070 // loaded with the [Text] command 1122 textToSummarise = text;1071 textToSummarise = options["text"]; 1123 1072 disp.expandstring("_cgiargq_",query); 1124 1073 return summarise(textToSummarise,query,80);
Note:
See TracChangeset
for help on using the changeset viewer.