Changeset 3322
- Timestamp:
- 2002-08-05T15:15:18+12:00 (22 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/Makefile.in
r3321 r3322 138 138 datelistbrowserclass.h invbrowserclass.h pagedbrowserclass.h \ 139 139 htmlbrowserclass.h phindbrowserclass.h historydb.h collectoraction.h \ 140 phindaction.h summarise.h 140 phindaction.h summarise.h highlighttext.h 141 141 142 142 RECEPTHEADERS = … … 160 160 invbrowserclass.cpp pagedbrowserclass.cpp htmlbrowserclass.cpp \ 161 161 phindbrowserclass.cpp historydb.cpp collectoraction.cpp argdb.cpp \ 162 browseactiontools.h formattools.cpp phindaction.cpp summarise.cpp 162 browseactiontools.h formattools.cpp phindaction.cpp summarise.cpp \ 163 highlighttext.cpp 163 164 164 165 … … 192 193 pagedbrowserclass.o htmlbrowserclass.o phindbrowserclass.o \ 193 194 historydb.o $(Z_COMOBJS) collectoraction.o phindaction.o \ 194 summarise.o 195 summarise.o highlighttext.o 195 196 196 197 RECPTOBJECTS = recptmain.o -
trunk/gsdl/src/recpt/documentaction.cpp
r3087 r3322 31 31 #include "unitool.h" 32 32 #include "gsdltools.h" 33 #include "highlighttext.h" 33 34 34 35 documentaction::documentaction () { … … 106 107 107 108 // in this action "hl" is the "highlighting on/ 108 // highlighting off control 109 // highlighting off control ("hl" == "2" is a 110 // special case that forces phrase highlighting 111 // to be used even if the query string doesn't 112 // appear to be a phrase) 109 113 arg_ainfo.shortname = "hl"; 110 114 arg_ainfo.longname = "highlighting on/off"; … … 181 185 // check hl argument 182 186 int arg_hl = args.getintarg("hl"); 183 if (arg_hl != 0 && arg_hl != 1) {187 if (arg_hl < 0 || arg_hl > 2) { 184 188 logout << "Warning: \"hl\" argument out of range (" << arg_hl << ")\n"; 185 189 cgiarginfo *hlinfo = argsinfo.getarginfo ("hl"); … … 782 786 text_t &collection, recptproto *collectproto, 783 787 displayclass &disp, outconvertclass &outconvert, 784 ostream &textout, ostream &logout) { 788 ostream &textout, ostream &logout, 789 cgiargsclass &args) { 785 790 786 791 DocumentRequest_t docrequest; … … 798 803 // (wanttext will equal 2 if we want text and other stuff too) 799 804 if (wanttext == 1) 800 if (highlight) 801 highlighttext(docresponse.doc, terminfo, disp, outconvert, textout, logout);802 else805 if (highlight) { 806 highlighttext(docresponse.doc, args, terminfo, disp, outconvert, textout); 807 } else { 803 808 textout << outconvert << disp << docresponse.doc; 809 } 804 810 } 805 811 806 812 if (wanttext != 1) { 807 813 text_t doctext 808 809 810 814 = get_formatted_string (collection, collectproto, 815 docinfo, disp, formatlistptr, docresponse.doc, 816 logout); 811 817 812 if (highlight) 813 highlighttext(doctext, terminfo, disp, outconvert, textout, logout);814 else818 if (highlight) { 819 highlighttext(doctext, args, terminfo, disp, outconvert, textout); 820 } else { 815 821 textout << outconvert << disp << doctext; 822 } 816 823 } 817 824 } … … 876 883 output_text (inforesponse.docInfo[0], formatlistptr, queryresponse.termInfo, 877 884 OID, highlight, hastxt, wanttext, collection, collectproto, 878 disp, outconvert, textout, logout );885 disp, outconvert, textout, logout, args); 879 886 880 887 … … 919 926 output_text (thisdocinfo, formatlistptr, queryresponse.termInfo, 920 927 OID, highlight, hastxt, wanttext, collection, 921 collectproto, disp, outconvert, textout, logout );928 collectproto, disp, outconvert, textout, logout, args); 922 929 923 930 } … … 936 943 output_text (*sechere, formatlistptr, queryresponse.termInfo, 937 944 (*sechere).OID, highlight, shastxt, wanttext, collection, 938 collectproto, disp, outconvert, textout, logout );945 collectproto, disp, outconvert, textout, logout, args); 939 946 count ++; 940 947 sechere ++; … … 945 952 delete formatlistptr; 946 953 } 947 948 // highlighttext highlights query terms in text string and outputs the resulting text string949 void documentaction::highlighttext(text_t &text, const TermInfo_tarray &terms,950 displayclass &disp, outconvertclass &outconvert,951 ostream &textout, ostream &/*logout*/) {952 953 text_tmap allterms;954 text_tmap::const_iterator it;955 956 // first load all the term variations into a map957 TermInfo_tarray::const_iterator this_term = terms.begin();958 TermInfo_tarray::const_iterator last_term = terms.end();959 while (this_term != last_term) {960 text_tarray::const_iterator this_var = (*this_term).matchTerms.begin();961 text_tarray::const_iterator last_var = (*this_term).matchTerms.end();962 while (this_var != last_var) {963 allterms[*this_var] = 1;964 this_var ++;965 }966 this_term ++;967 }968 969 // get the text to start and end a hightlight970 text_t starthighlight = "<b><u>";971 text_t endhighlight = "</u></b>";972 if (disp.isdefaultmacro("Global", "starthighlight"))973 disp.expandstring("Global", "_starthighlight_", starthighlight);974 if (disp.isdefaultmacro("Global", "endhighlight"))975 disp.expandstring("Global", "_endhighlight_", endhighlight);976 977 978 text_t::iterator here = text.begin();979 text_t::iterator end = text.end();980 text_t word, buffer;981 while (here != end) {982 if (is_unicode_letdig(*here)) {983 // not word boundary984 word.push_back(*here);985 here++;986 987 } else {988 // found word boundary989 // add last word if there was one990 if (!word.empty()) {991 it = allterms.find(word);992 if (it != allterms.end()) {993 word = starthighlight + word + endhighlight;994 }995 buffer += word;996 word.clear();997 }998 999 if (*here == '<') {1000 // skip over rest of html tag1001 while ((here != end) && (*here != '>')) {1002 buffer.push_back(*here);1003 here++;1004 }1005 }1006 1007 buffer.push_back(*here);1008 here++;1009 1010 if (buffer.size() > 1024) {1011 textout << outconvert << disp << buffer;1012 buffer.clear();1013 }1014 }1015 }1016 textout << outconvert << disp << buffer;1017 } -
trunk/gsdl/src/recpt/documentaction.h
r1805 r3322 54 54 text_t &collection, recptproto *collectproto, 55 55 displayclass &disp, outconvertclass &outconvert, 56 ostream &textout, ostream &logout); 56 ostream &textout, ostream &logout, 57 cgiargsclass &args); 57 58 58 59 virtual void output_document (const text_t &OID, cgiargsclass &args, … … 60 61 outconvertclass &outconvert, ostream &textout, 61 62 ostream &logout); 62 63 void highlighttext(text_t &text, const TermInfo_tarray &terms,64 displayclass &disp, outconvertclass &outconvert,65 ostream &textout, ostream &logout);66 63 67 64 formatinfo_t formatinfo; -
trunk/gsdl/src/recpt/win32.mak
r3321 r3322 80 80 htmlbrowserclass.h historydb.h phindbrowserclass.h collectoraction.h \ 81 81 nullproto.h argdb.h browseaction.h browseactiontools.h phindaction.h \ 82 summarise.h 82 summarise.h highlighttext.h 83 83 84 84 CGIHEADERS = cgiwrapper.h … … 97 97 historydb.cpp phindbrowserclass.cpp collectoraction.cpp nullproto.cpp \ 98 98 argdb.cpp browseaction.cpp browseactiontools.cpp phindaction.cpp \ 99 summarise.cpp 99 summarise.cpp highlighttext.cpp 100 100 101 101 CGISOURCES = librarymain.cpp cgiwrapper.cpp … … 114 114 historydb.obj phindbrowserclass.obj collectoraction.obj nullproto.obj \ 115 115 argdb.obj browseaction.obj browseactiontools.obj phindaction.obj \ 116 summarise.obj 116 summarise.obj highlighttext.obj 117 117 118 118 CGIOBJECTS = librarymain.obj cgiwrapper.obj
Note:
See TracChangeset
for help on using the changeset viewer.