home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / is20.cab / ixtrasp.asp < prev    next >
Text File  |  1997-10-09  |  8KB  |  305 lines

  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
  2. <HTML>
  3. <HEAD>
  4.  
  5.   
  6.     <TITLE>Index Server Search Form</TITLE>
  7.     <META NAME="DESCRIPTION" CONTENT="Sample ASP query form for Microsoft Index Server v2.0">
  8.     <META NAME="AUTHOR"      CONTENT="Index Server Team">
  9.     <META NAME="KEYWORDS"    CONTENT="query, content, hit">
  10.     <META NAME="SUBJECT"     CONTENT="sample form">
  11.     <META NAME="MS.CATEGORY" CONTENT="Internet">
  12.     <META NAME="MS.LOCALE"   CONTENT="EN-US">
  13.     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
  14.  
  15. <%
  16.     NewQuery = FALSE
  17.     UseSavedQuery = FALSE
  18.     QueryForm = Request.ServerVariables( "PATH_INFO" )
  19.     ' QueryForm = "ixtrsasp.asp"
  20.     SearchString = ""
  21.     if Request.ServerVariables("REQUEST_METHOD") = "POST" then
  22.         SearchString = Request.Form("SearchString")
  23.         pg = Request.Form("pg")
  24.  
  25.         if pg <> "" then
  26.            NextPageNumber = pg
  27.            NewQuery = FALSE
  28.            UseSavedQuery = TRUE
  29.         else
  30.             NewQuery = SearchString <> ""
  31.         end if
  32.         ' NOTE: this will be true only if the button is actually pushed.
  33.         if Request.Form("Action") = "New Query" then
  34.            NewQuery = TRUE
  35.         end if
  36.     end if
  37.  
  38.  %>
  39. </HEAD>
  40.  
  41.  
  42.  
  43. <TABLE>
  44.     <TR>
  45.         <TD><H1>Sample ASP Search Form</H1></TD>
  46.     </TR>
  47. </TABLE>
  48.  
  49. <HR WIDTH=75% ALIGN=center SIZE=3>
  50. <p>
  51.  
  52. <TABLE>
  53.   <TR>
  54.     <TD ALIGN=LEFT>Enter your query below:</TD>
  55.   </TR>
  56.   <TR>
  57.     <TD>
  58.       <FORM ACTION="<%= QueryForm%>" METHOD=POST>
  59.         <TABLE>
  60.           <TR>
  61.             <TD><INPUT TYPE="TEXT" NAME="SearchString" SIZE="60" MAXLENGTH="100" VALUE="<%=SearchString%>"></TD>
  62.             <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="New Query"></TD>
  63.           </TR>
  64.  
  65.           
  66.         </TABLE>
  67.         
  68.       </FORM>
  69.     </TD>
  70.   </TR>
  71. </TABLE>
  72.  
  73. <BR>
  74.  
  75. <%
  76.  
  77. if SearchString <> "" then
  78.   if NewQuery then
  79.     set Session("Query") = nothing
  80.     set Session("Recordset") = nothing
  81.     NextRecordNumber = 1
  82.  
  83.     
  84.     set Q = Server.CreateObject("ixsso.Query")
  85.     set util = Server.CreateObject("ixsso.util")
  86.     Q.Query = SearchString
  87.     Q.SortBy = "rank[d]"
  88.     Q.Columns = "DocTitle, vpath, path, filename, size, write, characterization"
  89.     util.AddScopeToQuery Q, "/", "deep"
  90.  
  91.     set RS = Q.CreateRecordSet("nonsequential")
  92.  
  93.     RS.PageSize = 10
  94.     ActiveQuery = TRUE
  95.  
  96.   elseif UseSavedQuery then
  97.     if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
  98.       set Q = Session("Query")
  99.       set RS = Session("RecordSet")
  100.  
  101.       if RS.RecordCount <> -1 and NextPageNumber <> -1 then
  102.         RS.AbsolutePage = NextPageNumber
  103.         NextRecordNumber = RS.AbsolutePosition
  104.       end if
  105.  
  106.       ActiveQuery = TRUE
  107.     else
  108.       Response.Write "ERROR - No saved query"
  109.     end if
  110.   end if
  111.  
  112.   if ActiveQuery then
  113.     if not RS.EOF then
  114.  %>
  115.  
  116. <p>
  117. <HR WIDTH=80% ALIGN=center SIZE=3>
  118. <p>
  119.  
  120. <%
  121.         LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
  122.         CurrentPage = RS.AbsolutePage
  123.         if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
  124.             LastRecordOnPage = RS.RecordCount
  125.         end if
  126.  
  127.         Response.Write "Documents " & NextRecordNumber & " to " & LastRecordOnPage
  128.         if RS.RecordCount <> -1 then
  129.             Response.Write " of " & RS.RecordCount
  130.         end if
  131.         Response.Write " matching the query " & chr(34) & "<I>"
  132.         Response.Write SearchString & "</I>" & chr(34) & ".<P>"
  133.  %>
  134.  
  135.  
  136.  
  137. <dl>
  138.  
  139. ' BEGIN first row of query results table
  140. <% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage %>
  141.  
  142. <%
  143.     ' This is the detail portion for Title, Abstract, URL, Size, and
  144.     ' Modification Date.
  145.  
  146.     ' If there is a title, display it, otherwise display the virtual path.
  147. %>
  148.     <p>
  149.     <dt><%= NextRecordNumber%>.
  150.         <%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%>
  151.             <b><a href="<%=RS("vpath")%>"><%= Server.HTMLEncode( RS("filename") )%></a></b>
  152.         <%else%>
  153.             <b><a href="<%=RS("vpath")%>"><%= Server.HTMLEncode(RS("DocTitle"))%></a></b>
  154.         <%end if%>
  155.     <dd>
  156.         <%if VarType(RS("characterization")) = 8 and RS("characterization") <> "" then%>
  157.             <b><i>Abstract:  </I></b><%= Server.HTMLEncode(RS("characterization"))%>
  158.             <br>
  159.         <%end if%>
  160.         <cite>
  161.             <a href="<%=RS("vpath")%>">http://<%=Request("server_name")%><%=RS("vpath")%></a>
  162.             <font size=-1> - <%if RS("size") = "" then%>(size and time unknown)<%else%>size <%=RS("size")%> bytes - <%=RS("write")%> GMT<%end if%></font>
  163.         </cite>
  164.         
  165.  
  166. <%
  167.           RS.MoveNext
  168.           NextRecordNumber = NextRecordNumber+1
  169.       Loop
  170.  %>
  171.  
  172. </dl>
  173.  
  174. <P><BR>
  175.  
  176. <%
  177.   else   ' NOT RS.EOF
  178.       if NextRecordNumber = 1 then
  179.           Response.Write "No documents matched the query<P>"
  180.       else
  181.           Response.Write "No more documents in the query<P>"
  182.       end if
  183.  
  184.   end if ' NOT RS.EOF
  185.  %>
  186.  
  187. ' If the index is out of date, display the fact 
  188.  
  189. <%if Q.OutOfDate then%>
  190.     <P>
  191.     <I><B>The index is out of date.</B></I><BR>
  192. <%end if%>
  193.  
  194.  
  195.     ' If the query was not executed because it needed to enumerate to
  196.     ' resolve the query instead of using the index, but AllowEnumeration
  197.     ' was FALSE, let the user know
  198.  
  199.  
  200. <%if Q.QueryIncomplete then%>
  201.     <P>
  202.     <I><B>The query is too expensive to complete.</B></I><BR>
  203. <%end if%>
  204.  
  205.  
  206.     ' If the query took too long to execute (for example, if too much work
  207.     ' was required to resolve the query), let the user know
  208.  
  209.  
  210. <%if Q.QueryTimedOut then%>
  211.     <P>
  212.     <I><B>The query took too long to complete.</B></I><BR>
  213. <%end if%>
  214.  
  215.  
  216. <TABLE>
  217.  
  218.  
  219.    ' This is the "previous" button.
  220.    ' This retrieves the previous page of documents for the query.
  221.  
  222.  
  223. <%SaveQuery = FALSE%>
  224. <%if CurrentPage > 1 and RS.RecordCount <> -1 then ' BUGBUG - use RS.Supports(adMovePrevious)%>
  225.     <td align=left>
  226.         <form action="<%= QueryForm%>" method="POST">
  227.             <INPUT TYPE="HIDDEN" NAME="SearchString" VALUE="<%=SearchString%>">
  228.             <INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage-1%>" >
  229.            
  230.             <input type="submit" value="Previous <%=RS.PageSize%> documents">
  231.         </form>
  232.     </td>
  233.     <%SaveQuery = TRUE%>
  234. <%end if%>
  235.  
  236.  
  237.     ' This is the "next" button.
  238.     ' This button retrieves the next page of documents for the query.
  239.     ' If the RS.RecordCount is available, the number of 
  240.     ' documents on the next page will be displayed.
  241.  
  242.  
  243. <%if Not RS.EOF then%>
  244.     <td align=right>
  245.         <form action="<%= QueryForm%>" method="POST">
  246.             <INPUT TYPE="HIDDEN" NAME="SearchString" VALUE="<%=SearchString%>">
  247.             <INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage+1%>" >
  248.  
  249.             <% NextString = "Next "
  250.                if RS.RecordCount <> -1 then
  251.                    NextSet = (RS.RecordCount - NextRecordNumber) + 1
  252.                    if NextSet > RS.PageSize then
  253.                        NextSet = RS.PageSize
  254.                    end if
  255.                    NextString = NextString & NextSet & " documents"
  256.                else
  257.                    NextString = NextString & " page of documents"
  258.                end if
  259.              %>
  260.             <input type="submit" value="<%=NextString%>">
  261.         </form>
  262.     </td>
  263.     <%SaveQuery = TRUE%>
  264. <%end if%>
  265.  
  266. </TABLE>
  267.  
  268.  
  269. ' Display the page number
  270.  
  271. Page <%=CurrentPage%>
  272. <%if RS.PageCount <> -1 then
  273.      Response.Write " of " & RS.PageCount
  274.   end if %>
  275.  
  276. <%
  277.     ' If either of the previous or back buttons were displayed, save the query
  278.     ' and the recordset in session variables.
  279.     if SaveQuery then
  280.         set Session("Query") = Q
  281.         set Session("RecordSet") = RS
  282.     else
  283.         RS.close
  284.         Set RS = Nothing
  285.         Set Q = Nothing
  286.         set Session("Query") = Nothing
  287.         set Session("RecordSet") = Nothing
  288.     end if
  289.  %>
  290. <% end if 
  291.  
  292. elseif not NewQuery then
  293.     Response.Write ""
  294. else
  295.     Response.Write "Please enter a word or phrase to search for."
  296. end if
  297.  
  298. %>
  299.  
  300.                              
  301.  
  302. </BODY>
  303. </HTML>
  304.  
  305.