%@ LANGUAGE="VBSCRIPT" %>
<% PageStrings = "152, 153, 154, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202" %>
<%
Const DISPLAY_LETTERS = 100
recor = request.querystring("recor")
SearchedID = request.querystring("PT_ID")
SearchFor = request.querystring("SearchFor")
keywords = trim(Request.querystring("keywords"))
If SearchFor = "" or isnull(SearchFor) then SearchFor = "any"
If SearchedID = "" or isnull(SearchedID) then SearchedID = "all"
If recor="" or not isNumeric(recor) or isNull(recor) then recor=1
If Not IsNumeric(SearchedID) and SearchedID<>"all" then response.redirect("../ecommerce/error_occ.asp")
If iCount= "" then iCount = 0
Call ReadFromTemplate(templatelocation,aryPageTemplate,strBasketHTML,strCategoryListHTML)
response.write(aryPageTemplate(0))
if keywords <> "" then
tempval = keywords
keywords = SafeHTMLencode(keywords)
if searchfor = "exact" then
KeyWordsToPass = tempval
else
KeyWordsToPass = replace(tempval," ", ",")
end if
tempval = Replace(SqlSafe(tempval),","," ")
tempval = Replace(tempval,";"," ")
tempval = Replace(tempval," "," ")
tempval = Replace(tempval," "," ")
tempval=Trim(tempval)
If tempval ="" then tempval = " "
keyarray = Split(tempval," ",-1)
if searchfor = "exact" then
ProductsClause = "((P_Name LIKE '%" & keywords & "%') OR (P_Desc LIKE '%" & keywords & "%'))"
else
If tempval <> "" then
t=0
For Each X in keyarray
if t <> 0 then
if searchfor = "all" then
ProductsClause = ProductsClause & " AND "
else
ProductsClause = ProductsClause & " OR "
end if
end if
ProductsClause = ProductsClause & "((P_Name LIKE '%" & keyarray(t) & "%') OR (P_Desc LIKE '%" & keyarray(t) & "%'))"
t=t+1
Next
else
ProductsClause = "1 = 1"
end if
end if
ProductsClause = "(" & ProductsClause & ")"
ProdTypeClause = Replace(ProductsClause, "P", "PT")
VersionsClause = Replace(ProductsClause, "P", "V")
if SearchedID = "all" then
sectionclause = "1 = 1"
else
sectionclause = "tbl_Prodtype.PT_ID = " & SearchedID
end if
if SearchedID = "all" and recor = "1" then
theQuery = "SELECT PT_ID, PT_Name, PT_Desc, PT_MasterCategory FROM tbl_Prodtype WHERE PT_Live = 'y' AND " & ProdTypeClause & " ORDER BY PT_Name"
Call ExecuteSQL(theQuery,cursortype,rs_main)
if not (rs_main.eof and rs_main.bof) then
BestBets = true
%>
| <% WriteString("PageTitle_SearchResults") %> |
<% WriteString("ContentText_NewSearch") %> |
| <% WriteString("ContentText_TryTheseCategories") %>:
<%
do while not rs_main.eof
If rs_main("PT_MasterCategory") = "y" then
dummystring = dummystring & "" & rs_main("PT_Name") & ", "
else
dummystring = dummystring & "" & rs_main("PT_Name") & ", "
end if
rs_main.movenext
loop
response.write(left(DummyString, len(DummyString) - 2))
%>
|
<%
end if
rs_main.close
end if
If DBType = "mysql" Then
theQuery = "SELECT DISTINCT P_ID, P_Name FROM tbl_Versions INNER JOIN tbl_Products ON tbl_Versions.V_Product = tbl_Products.P_ID INNER JOIN tbl_Prodtype ON tbl_Products.P_ID = tbl_ProductProdTypeLink.PPT_ProductID INNER JOIN tbl_ProductProdTypeLink ON tbl_Prodtype.PT_ID = tbl_ProductProdTypeLink.PPT_ProdTypeID WHERE PT_Live='y' AND P_Live='y' AND V_Live='y' AND ((" & ProductsClause & ") OR (" & VersionsClause & ")) AND (" & sectionclause & ") ORDER BY P_Name"
Else
theQuery = "SELECT DISTINCT P_ID, P_Name FROM tbl_Versions INNER JOIN (tbl_Prodtype INNER JOIN (tbl_Products INNER JOIN tbl_ProductProdTypeLink ON tbl_Products.P_ID = tbl_ProductProdTypeLink.PPT_ProductID) ON tbl_Prodtype.PT_ID = tbl_ProductProdTypeLink.PPT_ProdTypeID) ON tbl_Versions.V_Product = tbl_Products.P_ID WHERE PT_Live='y' AND P_Live='y' AND V_Live='y' AND ((" & ProductsClause & ") OR (" & VersionsClause & ")) AND (" & sectionclause & ") ORDER BY P_Name"
End If
Call ExecuteSQL(theQuery,cursortype,rs_main)
IntNumRecs = rs_main.RecordCount
If IntNumRecs >0 then
rs_main.movefirst
recordnumber = recor - 1
rs_main.move recordnumber
ItemsOnThisPage = recor + Application(HASHKEYNUMBERXYZ & "searchpagesize") - 1
If ItemsOnThisPage > IntNumRecs then ItemsOnThisPage = intNumRecs
if not BestBets then
%>
| <% WriteString("PageTitle_SearchResults") %> |
<% WriteString("ContentText_NewSearch") %> |
<%
end if
response.write " " & chr(13)
response.write " | " & GetString("ContentText_ViewingResults") & " " & recor & " - " & ItemsOnThisPage & " " & GetString("ContentText_Of") & " " & IntNumRecs & " " & GetString("ContentText_For") & " '" & keywords & "' | " & chr(13)
response.write "
" & chr(13)
do while recordnumber<(recor+Application(HASHKEYNUMBERXYZ & "searchpagesize")-1) AND not rs_main.EOF
recordnumber = recordnumber + 1
ProdLink = "" & rs_main("P_Name") & ""
PositionWordFound = 0
SpaceLeft = 0
EitherSide = 0
MidPoint1 = 0
MidPoint2 = 0
WordInRange = false
theQuery = "SELECT P_Desc FROM tbl_Products WHERE P_ID = " & rs_main("P_ID")
call executeSQL(theQuery,cursortype,rs_main2)
P_Desc = rs_main2("P_Desc")
rs_main2.close
WeGotAMatch = false
for each KeyWord in keyArray
if instr(lcase(P_Desc), lcase(KeyWord)) > 0 then
WeGotAMatch = true
exit for
end if
next
If WeGotAMatch = false then
theQuery = "SELECT V_ID, V_Live, V_Name, V_Desc FROM tbl_Versions WHERE V_Product = " & rs_main("P_ID")
call executeSQL(theQuery,cursortype,rs_main2)
if not (rs_main2.bof and rs_main2.eof) then
Do while not rs_main2.eof and not WeGotAMatch
dummyDesc = rs_main2("V_Desc")
for each KeyWord in KeyArray
If instr(lcase(dummyDesc), lcase(KeyWord)) then
WeGotAMatch = true
P_Desc = dummyDesc
ProdLink = ProdLink & " > " & rs_main2("V_Name") & ""
Exit for
end if
next
rs_main2.movenext
Loop
end if
rs_main2.close
end if
If len(P_Desc) > DISPLAY_LETTERS then
for each KeyWord in keyArray
if instr(lcase(P_Desc), lcase(KeyWord)) < (DISPLAY_LETTERS - len(KeyWord)) and instr(lcase(P_Desc), lcase(KeyWord)) > 0 then
WordInRange = true
exit for
end if
next
If not WordInRange then
for each KeyWord in keyArray
if instr(lcase(P_Desc), lcase(KeyWord)) > 0 and len(KeyWord) < DISPLAY_LETTERS then
PositionWordFound = instr(lcase(P_Desc), lcase(KeyWord))
If len(P_Desc) - PositionWordFound < DISPLAY_LETTERS then
MidPoint1 = len(P_Desc) - DISPLAY_LETTERS
MidPoint2 = len(P_Desc)
AfterString = ""
else
SpaceLeft = DISPLAY_LETTERS - len(KeyWord) - 6
EitherSide = int(SpaceLeft / 2)
MidPoint1 = PositionWordFound - EitherSide
MidPoint2 = (PositionWordFound + len(KeyWord) + EitherSide) - MidPoint1
AfterString = "..."
end if
P_Desc = "..." & mid(P_Desc, MidPoint1, MidPoint2) & AfterString
exit for
end if
next
else
P_Desc = left(P_Desc,DISPLAY_LETTERS - 3) & "..."
end if
End if
response.write "" & chr(13)
response.write " | " & recordnumber & ". " & ProdLink & " | " & chr(13)
response.write "
" & chr(13)
response.write "" & chr(13)
response.write "| " & chr(13)
if searchfor = "exact" then
response.write Highlight(P_Desc, tempval, "mednormalhighlight")
else
response.write Highlight(P_Desc, replace(tempval," ",","), "mednormalhighlight")
end if
response.write " | " & chr(13)
response.write "
" & chr(13)
rs_main.moveNext
loop
rs_main.Close
%>
| |
|
<%
if recordnumber > Application(HASHKEYNUMBERXYZ & "searchpagesize") then
response.write(" << " & GetString("ContentText_Previous") & " ")
end if
If IntNumRecs > Application(HASHKEYNUMBERXYZ & "searchpagesize") then
for t = 1 to CInt((IntNumRecs/Application(HASHKEYNUMBERXYZ & "searchpagesize"))+0.49)
If Cint(recor) <> (Application(HASHKEYNUMBERXYZ & "searchpagesize")*(t-1))+1 then
response.write(" " & t & " ")
else
response.write(" "& t & " ")
end if
next
End if
if IntNumRecs>recordnumber then
response.write(" " & GetString("ContentText_Next") & " >> ")
end if
%>
|
| |
<% else
If BestBets = false then
rs_main.close
SubText = GetString("ContentText_NoResults")
DoSearchForm = True
else
response.write "
"
end if
end if
else
SubText = GetString("ContentText_EnterKeywords")
DoSearchForm = True
end if
If DoSearchForm then
%>
<%
end if
response.write(aryPageTemplate(1))
DataConn.Close
set DataConn = nothing
%>