Ignore:
Timestamp:
2010-12-03T16:40:35+13:00 (13 years ago)
Author:
kjdon
Message:

added in code for i feel lucky (used in next and prev search result links) for searching multiple collections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/queryaction.cpp

    r23378 r23380  
    10101010  map<text_t, int, lttext_t> termfreqs;
    10111011
     1012  ColInfoResponse_t *tmp_cinfo;
    10121013  while (col_here != col_end) {
    10131014
     
    10201021      continue;
    10211022    }
    1022     cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
    1023     if (cinfo == NULL) {
     1023    tmp_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
     1024    if (tmp_cinfo == NULL) {
    10241025      // skip this collection
    10251026      logout << "ERROR (query_action::search_multiple_collections): get_collectinfo_ptr returned NULL\n";
     
    10351036      // get the formatstring if there is one
    10361037      if (!get_formatstring (classification, browsertype,
    1037                  cinfo->format, formatstring)) {
     1038                 tmp_cinfo->format, formatstring)) {
    10381039    formatstring = bptr->get_default_formatstring();
    10391040      }
     
    11011102  } // for each coll
    11021103 
     1104  // now we have an ordered list of results. If ifl (I feel lucky) is set, then pick out the one we want
     1105  if (args["ifl"] == 1 || (args["ifl"] == 2 && numdocs == 1)) {
     1106
     1107    //Find whether DocumentSearchResultLinks is enabled
     1108    bool show_links = false;
     1109    text_tmap::const_iterator format_here = cinfo->format.begin();
     1110    text_tmap::const_iterator format_end = cinfo->format.end();
     1111   
     1112    while (format_here != format_end) {
     1113      if (((*format_here).first == "DocumentSearchResultLinks") &&
     1114      ((*format_here).second == "true")){
     1115    show_links = true;
     1116    break;
     1117      }
     1118      ++format_here;
     1119    }
     1120
     1121    // which doc do we want?
     1122    int docnum;
     1123    int ifl;
     1124    int srn = 0;
     1125    int srp = 0;
     1126    if (args["ifl"] == 1) {
     1127      ifl = args["ifln"].getint();
     1128      docnum = ifl - 1;
     1129      if (show_links) {
     1130    // set the values for next and prev search result number
     1131    srn = ifl + 1;
     1132    if (srn > numdocs) {
     1133      srn = 0;
     1134    }
     1135    srp = ifl - 1;
     1136    if (srp < 0) {
     1137      srp = 0;
     1138    }
     1139      }
     1140    } else {
     1141      // we just want the first (and only) result
     1142      docnum = 0;
     1143    }
     1144   
     1145    if (docnum >= 0 && docnum < numdocs) {
     1146    // get the docnum'th item from the results
     1147      QueryResult_tset::iterator res_here = results.begin();
     1148      for (int i=0; i< docnum; i++) {
     1149    ++res_here;
     1150      }
     1151     
     1152      textout << outconvert << disp
     1153          << "Location: _gwcgi_?e=_compressedoptions_&a=d&c="
     1154          << (*res_here).collection << "&cl=search&d=" << (*res_here).doc.OID
     1155          << "&srn=" << srn << "&srp=" << srp << "\n\n";
     1156      textout << flush;
     1157     
     1158      return true;
     1159     
     1160    }
     1161  }
     1162 
     1163  if (!args["ifl"].empty()) {
     1164    // if we get here, and ifl was set but we haven't output a document, then we'll carry on as if ifl wasn't set. The only catch is that get_cgihead_info won't have
     1165    // done the right thing (because ifl was set), so we need to make sure the output is html
     1166    textout << "Content-type: text/html\n\n";
     1167  }
     1168
     1169
    11031170  text_t numdocs_t = numdocs; 
    11041171  args["nmd"] = numdocs_t;
Note: See TracChangeset for help on using the changeset viewer.