| 1467 | | text_t maxDoc_old = args["o"]; |
|---|
| 1468 | | text_t starts_old = args["r"]; |
|---|
| 1469 | | |
|---|
| 1470 | | //if the "ifl" argument is set ignore the "r" and "o" arg |
|---|
| 1471 | | if(!args["ifl"].empty()){ |
|---|
| 1472 | | args["r"] = 1; |
|---|
| 1473 | | args["o"] = args["m"]; |
|---|
| 1474 | | } |
|---|
| 1475 | | |
|---|
| | 1467 | text_t hits_per_page_old = args["o"]; |
|---|
| | 1468 | text_t start_results_from_old = args["r"]; |
|---|
| | 1469 | |
|---|
| | 1470 | // if the "ifl" argument is set to 1, we only want to get one document |
|---|
| | 1471 | // this may be the first search result (from "I feel lucky") or maybe a |
|---|
| | 1472 | // specified search result (from next/prev search result link) |
|---|
| | 1473 | if (args["ifl"] == "1") { |
|---|
| | 1474 | args["r"] = args["ifln"]; // the document number we want, |
|---|
| | 1475 | args["o"] = "1"; |
|---|
| | 1476 | } |
|---|
| 1513 | | |
|---|
| 1514 | | while (format_here != format_end) { |
|---|
| 1515 | | if (((*format_here).first == "DocumentSearchResultLinks") && |
|---|
| 1516 | | ((*format_here).second == "true")){ |
|---|
| 1517 | | show_links = true; |
|---|
| 1518 | | break; |
|---|
| 1519 | | } |
|---|
| 1520 | | ++format_here; |
|---|
| 1521 | | } |
|---|
| 1522 | | |
|---|
| 1523 | | if (args["ifl"] == 1 || (args["ifl"] == 2 && response.numDocs == 1)) |
|---|
| 1524 | | { |
|---|
| 1525 | | // Find the search result specified by the ifln argument |
|---|
| 1526 | | ResultDocInfo_tarray::iterator thissection = response.docInfo.begin(); |
|---|
| 1527 | | int section_number = 1; |
|---|
| 1528 | | int ifln = args["ifln"].getint(); |
|---|
| 1529 | | |
|---|
| 1530 | | while (section_number != ifln && thissection != response.docInfo.end()) { |
|---|
| 1531 | | thissection++; |
|---|
| 1532 | | section_number++; |
|---|
| 1533 | | } |
|---|
| 1534 | | // If the search result exists, go directly to it |
|---|
| 1535 | | if (section_number == ifln && thissection != response.docInfo.end()) { |
|---|
| 1536 | | // Location response (this URL must have "&" and not "&"!) |
|---|
| 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 << "&cl=search&d=" << (*thissection).OID <<"&srn="<<srn<<"&srp="<<srp<< "\n\n"; |
|---|
| 1548 | | textout << flush; |
|---|
| 1549 | | |
|---|
| 1550 | | return true; |
|---|
| 1551 | | } |
|---|
| 1552 | | } |
|---|
| 1553 | | |
|---|
| | 1514 | |
|---|
| | 1515 | while (format_here != format_end) { |
|---|
| | 1516 | if (((*format_here).first == "DocumentSearchResultLinks") && |
|---|
| | 1517 | ((*format_here).second == "true")){ |
|---|
| | 1518 | show_links = true; |
|---|
| | 1519 | break; |
|---|
| | 1520 | } |
|---|
| | 1521 | ++format_here; |
|---|
| | 1522 | } |
|---|
| | 1523 | |
|---|
| | 1524 | if (args["ifl"] == 1 || (args["ifl"] == 2 && response.numDocs == 1)) { |
|---|
| | 1525 | |
|---|
| | 1526 | // The first search result is the one we want |
|---|
| | 1527 | if (response.docInfo.begin() != response.docInfo.end()) { |
|---|
| | 1528 | |
|---|
| | 1529 | ResultDocInfo_tarray::iterator section = response.docInfo.begin(); |
|---|
| | 1530 | |
|---|
| | 1531 | // We still need to set "srn" and "srp" values (next and prev search result numbers |
|---|
| | 1532 | int ifln = args["ifln"].getint(); |
|---|
| | 1533 | int srn = ifln + 1; |
|---|
| | 1534 | if (srn > response.numDocs) { |
|---|
| | 1535 | srn = 0; |
|---|
| | 1536 | } |
|---|
| | 1537 | int srp = ifln - 1; |
|---|
| | 1538 | if (srp < 0) { |
|---|
| | 1539 | srp = 0; |
|---|
| | 1540 | } |
|---|
| | 1541 | |
|---|
| | 1542 | |
|---|
| | 1543 | textout << outconvert << disp << "Location: _gwcgi_?e=_compressedoptions_&a=d&c=" << collection << "&cl=search&d=" << (*section).OID <<"&srn="<<srn<<"&srp="<<srp<< "\n\n"; |
|---|
| | 1544 | textout << flush; |
|---|
| | 1545 | |
|---|
| | 1546 | return true; |
|---|
| | 1547 | } |
|---|
| | 1548 | } |
|---|
| | 1549 | |
|---|