Changeset 14090

Show
Ignore:
Timestamp:
24.05.2007 09:34:58 (12 years ago)
Author:
mdewsnip
Message:

Added a new value for the "ifl" argument: when equal to "2", it only redirects to the first matching document if there is one match. Many thanks to Jens Wille.

Files:
1 modified

Legend:

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

    r13587 r14090  
    15221522       }  
    15231523 
    1524        // Find the search result specified by the ifln argument    
    1525       ResultDocInfo_tarray::iterator thissection = response.docInfo.begin(); 
    1526       int section_number = 1; 
    1527       int ifln = args["ifln"].getint(); 
     1524       if (args["ifl"] == 1 || (args["ifl"] == 2 && response.numDocs == 1)) 
     1525       { 
     1526     // Find the search result specified by the ifln argument    
     1527     ResultDocInfo_tarray::iterator thissection = response.docInfo.begin(); 
     1528     int section_number = 1; 
     1529     int ifln = args["ifln"].getint(); 
    15281530               
    1529     while (section_number != ifln  && thissection != response.docInfo.end()) {       
    1530     thissection++; 
    1531         section_number++; 
    1532       } 
    1533       // If the search result exists, go directly to it 
    1534       if (section_number == ifln && thissection != response.docInfo.end()) { 
    1535     // Location response (this URL must have "&" and not "&"!) 
    1536         int num_docs =  response.numDocs; 
    1537         int srn = 0; 
    1538     int srp = 0; 
    1539         if (show_links && section_number < num_docs ) { 
    1540           srn = section_number + 1; 
    1541     }     
    1542         if (show_links && section_number > 1 ) { 
    1543           srp = section_number - 1; 
    1544     }     
     1531    while (section_number != ifln  && thissection != response.docInfo.end()) {      
     1532       thissection++; 
     1533       section_number++; 
     1534    } 
     1535    // If the search result exists, go directly to it 
     1536    if (section_number == ifln && thissection != response.docInfo.end()) { 
     1537       // Location response (this URL must have "&" and not "&amp;"!) 
     1538       int num_docs =  response.numDocs; 
     1539       int srn = 0; 
     1540       int srp = 0; 
     1541       if (show_links && section_number < num_docs ) { 
     1542         srn = section_number + 1; 
     1543       } 
     1544       if (show_links && section_number > 1 ) { 
     1545         srp = section_number - 1; 
     1546       } 
    15451547         
    1546     textout << outconvert << disp << "Location: _gwcgi_?e=_compressedoptions_&a=d&c=" << collection << "&cl=search&d=" << (*thissection).OID <<"&srn="<<srn<<"&srp="<<srp<< "\n\n"; 
    1547     textout << flush; 
    1548      
    1549         return true; 
    1550       } 
     1548       textout << outconvert << disp << "Location: _gwcgi_?e=_compressedoptions_&a=d&c=" << collection << "&cl=search&d=" << (*thissection).OID <<"&srn="<<srn<<"&srp="<<srp<< "\n\n"; 
     1549       textout << flush; 
     1550        
     1551       return true; 
     1552     } 
     1553       } 
    15511554        
    15521555      // There weren't enough (or any) matching documents