/new/search_article.asp

https://github.com/akabeko/fusionexcel · ASP · 188 lines · 161 code · 24 blank · 3 comment · 11 complexity · 4ec2a25f2f46bd3ad17640e7bfe0734a MD5 · raw file

  1. <%
  2. ' Dependancies: The parent file must included libraries before run this files '
  3. Dim OFFSET, lang, sql, RecordSet
  4. Dim objXml, lang_index
  5. Dim prev_page, page, next_page
  6. ' 1 - EN; 2 - BM; 3 - CHI '
  7. lang = base_lang
  8. ' 1 - News & Event, 2 - Charities, 3 - Sponsorship '
  9. lang_index = lang
  10. page = 1
  11. if Request("page") <> "" and IsNumeric(Request("page")) then
  12. page = CInt(Request("page"))
  13. end if
  14. prev_page = page
  15. next_page = page
  16. Dim articlesObj, item
  17. set objXml = GetIndexedArticles(1)
  18. set articlesObj = objXml.selectNodes("articles/article")
  19. %>
  20. <tr>
  21. <td width="180" valign="top">
  22. <!-- Siderbar Start -->
  23. <% Call render_sidebar(articlesObj, 1, 1, false, 20) %>
  24. <!-- Siderbar end -->
  25. </td>
  26. <td width="10" valign="top">&nbsp;</td>
  27. <td width="740" valign="top">
  28. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  29. <tr>
  30. <td height="8"></td>
  31. </tr>
  32. <tr>
  33. <td valign="top" bgcolor="#999999">
  34. <table width="100%" border="0" cellspacing="1" cellpadding="10">
  35. <tbody>
  36. <tr>
  37. <td valign="top" bgcolor="#EEF0FC">
  38. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  39. <tbody>
  40. <%
  41. OFFSET = 50
  42. Dim total_record, total_page
  43. total_record = articlesObj.length
  44. total_page = total_record / OFFSET
  45. if total_page > Round(total_record / OFFSET, 0) then
  46. total_page = total_page + 1
  47. end if
  48. total_page = Round(total_page, 0)
  49. if total_page = 0 and total_record > 1 then
  50. total_page = 1
  51. end if
  52. if page > total_page then
  53. page = total_page
  54. end if
  55. if total_page > next_page then
  56. next_page = next_page + 1
  57. end if
  58. prev_page = prev_page - 1
  59. if prev_page < 1 then
  60. prev_page = 1
  61. end if
  62. %>
  63. <!-- searchbox -->
  64. <tr>
  65. <td>
  66. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  67. <tbody>
  68. <tr>
  69. <td width="100">&nbsp;</td>
  70. <td height="50" valign="middle">
  71. <div class="cse-branding-bottom">
  72. <div class="cse-branding-form">
  73. <form action="search.asp" id="ces-search-box">
  74. <div>
  75. <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
  76. <tbody>
  77. <tr>
  78. <td height="28" bgcolor="#285375">
  79. <span class="conthead style1" style="color:#FFFFFF; padding-left:10px;">Search</span>
  80. </td>
  81. </tr>
  82. <tr>
  83. <td height="50" valign="middle">
  84. <div align="center"><span style="color: blue; font-weight:bold; font-family: arial; font-size: 14px;">Search For : </span><input name="x" type="text" value="<%= Request("x") %>" size="50" /> <input type="submit" name="sa" value="Search" /></div>
  85. </td>
  86. </tr>
  87. </tbody>
  88. </table>
  89. </td>
  90. <td width="100">&nbsp;</td>
  91. </tr>
  92. </tbody>
  93. </table>
  94. </td>
  95. </tr>
  96. <!-- end of searchbox -->
  97. <%
  98. Dim filestream, file, fc
  99. Dim candidate_ids, xmlContent, match_found
  100. set filestream = CreateObject("Scripting.FileSystemObject")
  101. set file = filestream.GetFolder(Server.MapPath(GetArticlePath("")))
  102. set fc = file.files
  103. Dim article_id, content, title, counter
  104. counter = 0
  105. if Request("x") <> "" and Len(Request("x")) >= 4 then
  106. For Each f1 in fc
  107. set xmlContent = getArticleContent(f1.name)
  108. article_id = CInt(Replace(f1.name, ".xml", ""))
  109. if base_lang = 1 then
  110. content = xmlContent.item(0).selectSingleNode("en/content").text
  111. title = xmlContent.item(0).selectSingleNode("en/title").text
  112. elseif base_lang = 2 then
  113. content = xmlContent.item(0).selectSingleNode("bm/content").text
  114. title = xmlContent.item(0).selectSingleNode("bm/title").text
  115. elseif base_lang = 3 then
  116. content = xmlContent.item(0).selectSingleNode("chi/content").text
  117. title = xmlContent.item(0).selectSingleNode("chi/title").text
  118. end if
  119. if InStr(title, Request("x")) or InStr(content, Request("x")) then
  120. if candidate_ids <> "" then
  121. candidate_ids = candidate_ids & "," & article_id
  122. else
  123. candidate_ids = article_id
  124. end if
  125. counter = counter + 1
  126. end if
  127. Next
  128. end if
  129. if counter > 0 then
  130. match_found = "Found " & counter & " item(s)"
  131. else
  132. match_found = "No match found"
  133. end if
  134. %>
  135. <tr><td height="25"></td></tr>
  136. <tr>
  137. <td height="25" valign="middle" bgcolor="#285375">
  138. <span class="conthead style1" style="color:#ffffff; padding-left: 10px;">Results</span>
  139. </td>
  140. </tr>
  141. <tr><td height="10"></td></tr>
  142. <tr>
  143. <td valign="top" style="padding: 10px;" class="content">
  144. Your Search: <b><%= Request(x) %></b> <%= match_found %>
  145. <hr />
  146. </td>
  147. </tr>
  148. <tr>
  149. <td>
  150. <%
  151. %>
  152. </td>
  153. </tr>
  154. </tbody>
  155. </table>
  156. </td>
  157. </tr>
  158. </tbody>
  159. </table>
  160. </td>
  161. </tr>
  162. </table>
  163. </td>
  164. </tr>