Changeset 13280
- Timestamp:
- 2006-11-15T17:24:48+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/queryaction.cpp
r12866 r13280 447 447 argsinfo.addarginfo (NULL, arg_ainfo); 448 448 449 // "ifl" - I'm feeling lucky! (Go directly to the firstmatching document)449 // "ifl" - I'm feeling lucky! (Go directly to a matching document) 450 450 arg_ainfo.shortname = "ifl"; 451 451 arg_ainfo.longname = "i'm feeling lucky"; … … 453 453 arg_ainfo.defaultstatus = cgiarginfo::weak; 454 454 arg_ainfo.argdefault = g_EmptyText; 455 arg_ainfo.savedarginfo = cgiarginfo::mustnot; 456 argsinfo.addarginfo (NULL, arg_ainfo); 457 458 // "ifln" - I'm feeling lucky number (Go directly to the nth matching document) 459 arg_ainfo.shortname = "ifln"; 460 arg_ainfo.longname = "i'm feeling lucky number"; 461 arg_ainfo.multiplechar = true; 462 arg_ainfo.defaultstatus = cgiarginfo::weak; 463 arg_ainfo.argdefault = "1"; 455 464 arg_ainfo.savedarginfo = cgiarginfo::mustnot; 456 465 argsinfo.addarginfo (NULL, arg_ainfo); … … 1456 1465 1457 1466 } 1458 1467 1468 // Perform the "I'm feeling lucky" trick if the "ifl" argument is set 1459 1469 if (err == noError && !args["ifl"].empty()) { 1460 // Go directly to the first matching document 1470 // Find the search result specified by the ifln argument 1471 int section_number = 1; 1461 1472 ResultDocInfo_tarray::iterator thissection = response.docInfo.begin(); 1462 if (thissection != response.docInfo.end()) { 1463 // This URL must have "&" and not "&"! 1464 text_t doc_url = "_gwcgi_?e=_compressedoptions_&a=d&c=" + collection + "&d=" + (*thissection).OID; 1465 1466 // location response (url may contain macros!!) 1467 textout << outconvert << disp << "Location: " << doc_url << "\n\n"; 1473 while (section_number != args["ifln"] && thissection != response.docInfo.end()) { 1474 section_number++; 1475 thissection++; 1476 } 1477 1478 // If the search result exists, go directly to it 1479 if (section_number == args["ifln"] && thissection != response.docInfo.end()) { 1480 // Location response (this URL must have "&" and not "&"!) 1481 textout << outconvert << disp << "Location: _gwcgi_?e=_compressedoptions_&a=d&c=" << collection << "&d=" << (*thissection).OID << "\n\n"; 1468 1482 textout << flush; 1469 1483 return true; 1470 1484 } 1471 // Ooops... there weren't any matching documents 1472 else { 1473 // We'll just carry on as if ifl wasn't set. The only catch is that 1474 // get_cgihead_info won't have done the right thing (because ifl was 1475 // set), so we need to make sure the output is html 1476 textout << "Content-type: text/html\n\n"; 1477 } 1485 1486 // There weren't enough (or any) matching documents 1487 // We'll just carry on as if ifl wasn't set. The only catch is that get_cgihead_info won't have 1488 // done the right thing (because ifl was set), so we need to make sure the output is html 1489 textout << "Content-type: text/html\n\n"; 1478 1490 } 1479 1491
Note:
See TracChangeset
for help on using the changeset viewer.