Changeset 13366


Ignore:
Timestamp:
2006-11-29T14:18:56+13:00 (17 years ago)
Author:
shaoqun
Message:

added code to support the display of previous and next search result links in a document page

Location:
trunk/gsdl/src/recpt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/queryaction.cpp

    r13280 r13366  
    463463  arg_ainfo.argdefault = "1";
    464464  arg_ainfo.savedarginfo = cgiarginfo::mustnot;
     465  argsinfo.addarginfo (NULL, arg_ainfo);
     466
     467 
     468 // "srn" - the next search result 
     469  arg_ainfo.shortname = "srn";
     470  arg_ainfo.longname = "the next search result";
     471  arg_ainfo.multiplechar = false;
     472  arg_ainfo.defaultstatus = cgiarginfo::weak;
     473  arg_ainfo.argdefault = "0";
     474  arg_ainfo.savedarginfo = cgiarginfo::must;
     475  argsinfo.addarginfo (NULL, arg_ainfo);
     476
     477    // "srp" - the previous search result 
     478  arg_ainfo.shortname = "srp";
     479  arg_ainfo.longname = "the previous search result";
     480  arg_ainfo.multiplechar = false;
     481  arg_ainfo.defaultstatus = cgiarginfo::weak;
     482  arg_ainfo.argdefault = "0";
     483  arg_ainfo.savedarginfo = cgiarginfo::must;
    465484  argsinfo.addarginfo (NULL, arg_ainfo);
    466485
     
    13221341    if (response.numDocs > 0) {
    13231342      numdocs += response.numDocs;
    1324 
     1343   
    13251344      QueryResult_t thisresult;
    13261345      thisresult.collection = *col_here;
     
    13351354    ++col_here;
    13361355  } // for each coll
     1356 
     1357  text_t numdocs_t = numdocs; 
     1358  args["nmd"] = numdocs_t;
    13371359
    13381360  disp.setmacro ("freqmsg", "query", freqmsg);
     
    13671389      if (count < firstdoc) {++count; ++res_here; continue;}
    13681390      if (count > thislast) break;
     1391     
    13691392      formatlistptr = colinfomap[(*res_here).collection].formatlistptr;
    13701393      browserptr = colinfomap[(*res_here).collection].browserptr;
     
    14431466  FilterRequest_t request;
    14441467  FilterResponse_t response;
     1468
     1469  text_t maxDoc_old = args["o"];
     1470  text_t starts_old = args["r"]; 
     1471
     1472    //if the "ifl" argument is set ignore the "r" and "o" arg
     1473  if(!args["ifl"].empty()){
     1474    args["r"] = 1;
     1475    args["o"] = args["m"];
     1476  }
     1477 
     1478
    14451479  bptr->set_filter_options (request, args);
    14461480  bptr->load_metadata_defaults (request.fields);
     
    14531487  text_t formattedstring = "";
    14541488  get_formatted_query_string(formattedstring, segment, args, disp, logout);
    1455  
     1489
     1490
    14561491  if (!formattedstring.empty()) { // do the query
    14571492    // note! formattedstring is in unicode! mg and mgpp must convert!
    14581493    set_queryfilter_options (request, formattedstring, args);
     1494
    14591495    collectproto->filter (collection, request, response, err, logout);
     1496
    14601497    if (err != noError) {
    14611498      outconvertclass text_t2ascii;
     
    14681505    // Perform the "I'm feeling lucky" trick if the "ifl" argument is set
    14691506    if (err == noError && !args["ifl"].empty()) {
    1470       // Find the search result specified by the ifln argument
     1507      //Restore the "r" and "o" arg
     1508      args["r"] = starts_old;
     1509      args["o"] = maxDoc_old ;
     1510
     1511      //Find whether DocumentSearchResultLinks is enabled
     1512      bool show_links = false;
     1513      text_tmap::const_iterator format_here = cinfo->format.begin();
     1514      text_tmap::const_iterator format_end = cinfo->format.end();
     1515
     1516       while (format_here != format_end) {
     1517     if (((*format_here).first == "DocumentSearchResultLinks") &&
     1518         ((*format_here).second == "true")){
     1519       show_links = true;
     1520           break;
     1521     }
     1522         ++format_here;
     1523       }
     1524
     1525       // Find the search result specified by the ifln argument   
     1526      ResultDocInfo_tarray::iterator thissection = response.docInfo.begin();
    14711527      int section_number = 1;
    1472       ResultDocInfo_tarray::iterator thissection = response.docInfo.begin();
    1473       while (section_number != args["ifln"] && thissection != response.docInfo.end()) {
    1474     section_number++;
     1528      int ifln = args["ifln"].getint();
     1529             
     1530    while (section_number != ifln  && thissection != response.docInfo.end()) {     
    14751531    thissection++;
     1532        section_number++;
    14761533      }
    1477 
    14781534      // If the search result exists, go directly to it
    1479       if (section_number == args["ifln"] && thissection != response.docInfo.end()) {
     1535      if (section_number == ifln && thissection != response.docInfo.end()) {
    14801536    // Location response (this URL must have "&" and not "&amp;"!)
    1481     textout << outconvert << disp << "Location: _gwcgi_?e=_compressedoptions_&a=d&c=" << collection << "&d=" << (*thissection).OID << "\n\n";
     1537        int num_docs =  response.numDocs;
     1538        int srn = 0;
     1539    int srp = 0;
     1540        if (show_links && section_number < num_docs ) {
     1541          srn = section_number + 1;
     1542    }   
     1543        if (show_links && section_number > 1 ) {
     1544          srp = section_number - 1;
     1545    }   
     1546       
     1547    textout << outconvert << disp << "Location: _gwcgi_?e=_compressedoptions_&a=d&c=" << collection << "&d=" << (*thissection).OID <<"&srn="<<srn<<"&srp="<<srp<< "\n\n";
    14821548    textout << flush;
    1483     return true;
     1549        return true;
    14841550      }
    1485 
     1551       
    14861552      // There weren't enough (or any) matching documents
    14871553      // We'll just carry on as if ifl wasn't set. The only catch is that get_cgihead_info won't have
    14881554      // done the right thing (because ifl was set), so we need to make sure the output is html
    14891555      textout << "Content-type: text/html\n\n";
     1556     
    14901557    }
    14911558
     
    15171584  if (err == noError) {
    15181585    // output the results
     1586    text_t numdocs_t = response.numDocs; 
     1587    args["nmd"] = numdocs_t;
    15191588    bool use_table = is_table_content (formatlistptr);
    15201589    bptr->output_section_group (response, args, collection, 0, formatlistptr,
  • trunk/gsdl/src/recpt/vlistbrowserclass.cpp

    r12488 r13366  
    6161    "<td valign=\"top\">[highlight]{Or}{[dls.Title],[dc.Title],[Title],Untitled}[/highlight]"
    6262    "{If}{[Source],<br><i>([Source])</i>}</td>";
     63}
     64
     65bool vlistbrowserclass::show_search_result_links(recptproto * collectproto,const text_t &collection,ostream& logout){
     66     ColInfoResponse_t cinfo;
     67     comerror_t err;
     68     collectproto->get_collectinfo (collection, cinfo, err, logout);
     69     bool show_links = false;
     70
     71     text_tmap::const_iterator format_here = cinfo.format.begin();
     72     text_tmap::const_iterator format_end = cinfo.format.end();
     73     
     74     while (format_here != format_end) {
     75       if (((*format_here).first == "DocumentSearchResultLinks") &&
     76       ((*format_here).second == "true")){
     77     show_links = true;
     78         break;
     79       }
     80       ++format_here;
     81     }
     82     
     83     return show_links;
    6384}
    6485
     
    7495  text_t link, icon;
    7596  text_t collink = collection;
     97  bool show_links = show_search_result_links(collectproto,collection,logout);
     98
    7699
    77100#ifndef DOCHANDLE
     
    79102#endif
    80103
    81   get_link_icon (section, args, collink, link, icon);
     104  get_link_icon (section, args, collink, link, icon, show_links);
     105
     106  //get_link_icon (section, args, collink, link, icon);
     107
    82108  bool highlight = false;
    83109  if (!args["d"].empty()) {
     
    133159  text_t &arg_d = args["d"];
    134160  text_t &arg_cl = args["cl"];
    135 
     161 
    136162  text_t collink = collection;
     163  bool show_links = show_search_result_links(collectproto,collection,logout);
     164
    137165#ifndef DOCHANDLE
    138166  if (!collink.empty()) collink = "&amp;c=" + collink;
     
    183211  }
    184212
     213  int count = 0;
     214
    185215  while (thissection != endsection) {
    186216    ++item;
    187     get_link_icon (*thissection, args, collink, link, icon);
     217    get_link_icon (*thissection, args, collink, link, icon,show_links);
     218    //get_link_icon (*thissection, args, collink, link, icon);
    188219    bool highlight = false;
    189220    if (!arg_d.empty()) {
     
    227258// [modification to allow default document detach settings -- kjdon]
    228259void vlistbrowserclass::get_link_icon (ResultDocInfo_t &section, cgiargsclass &args,
    229                        const text_t &collink, text_t &link, text_t &icon) {
     260                       const text_t &collink, text_t &link, text_t &icon, bool showresultlinks) {
     261
     262 
    230263
    231264#ifndef DOCHANDLE
     
    236269
    237270  text_t link_end = "\">";
     271
    238272#ifndef DOCHANDLE
    239273  text_t detach_link_end = "&amp;x=1\" target=\\_blank>"; // to detach the link, and x=1 signifies it is a detached page
     
    252286    doctype = section.metadata["doctype"].values[0];
    253287
     288
    254289  text_t &arg_d = args["d"];
    255290  text_t &arg_cl = args["cl"];
    256 
     291 
     292 
    257293  if (args["a"] == "q") {
    258294    // query results list
    259295#ifndef DOCHANDLE
    260     link += "&amp;cl=search&amp;d=" + section.OID;
     296    int result_num = section.result_num;
     297    int num_docs = args["nmd"].getint();
     298    int srn = 0;
     299    int srp = 0;
     300    if (showresultlinks && result_num < num_docs) {
     301      srn = result_num  + 1;
     302    }   
     303    if (showresultlinks && result_num > 1 ) {
     304      srp = result_num  - 1;
     305    }   
     306       
     307    text_t srp_t = srp;
     308    text_t srn_t = srn;
     309    link +="&amp;srp="+srp_t;
     310    link +="&amp;srn="+srn_t;
     311    link +="&amp;cl=search&amp;d=" + section.OID;
    261312#else
    262313    link += "," + section.OID+")";
    263314#endif
     315
     316 
    264317    if (args["xx"] == "1") {
    265318      link += detach_link_end;
  • trunk/gsdl/src/recpt/vlistbrowserclass.h

    r7432 r13366  
    6262protected:
    6363
     64 
    6465  virtual void get_link_icon (ResultDocInfo_t &section, cgiargsclass &args,
    65                   const text_t &collink, text_t &link, text_t &icon);
     66                 const text_t &collink, text_t &link, text_t &icon, bool showresultlinks);
     67
     68  virtual bool show_search_result_links (recptproto * collectproto,const text_t &collection,ostream& logout);
    6669
    6770  receptionist *recpt;
Note: See TracChangeset for help on using the changeset viewer.