| 1 |
<% String pageTitle = "Search"; %> |
|---|
| 2 |
<%@ include file="header2.jsp" %> |
|---|
| 3 |
|
|---|
| 4 |
<%@ page import="java.util.*" %> |
|---|
| 5 |
<%@ page import="com.qwirx.lex.Search" %> |
|---|
| 6 |
<%@ page import="com.qwirx.lex.Search.SearchResult" %> |
|---|
| 7 |
<%@ page import="com.qwirx.lex.hebrew.*" %> |
|---|
| 8 |
<%@ page import="com.qwirx.lex.morph.*" %> |
|---|
| 9 |
<%@ page import="jemdros.*" %> |
|---|
| 10 |
<%@ page import="org.aptivate.webutils.EditField" %> |
|---|
| 11 |
|
|---|
| 12 |
<script type="text/javascript"><!-- |
|---|
| 13 |
|
|---|
| 14 |
function enableLimitControls() |
|---|
| 15 |
{ |
|---|
| 16 |
var form = document.forms.simple; |
|---|
| 17 |
form.book.disabled = !form.limit_loc.checked; |
|---|
| 18 |
// form.max_results.disabled = !form.limit_num.checked; |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
function toggle(button, divid) |
|---|
| 22 |
{ |
|---|
| 23 |
div = document.getElementById(divid); |
|---|
| 24 |
if (div.style.display == "block") |
|---|
| 25 |
{ |
|---|
| 26 |
div.style.display = "none"; |
|---|
| 27 |
button.value = button.value.replace("«", "»"); |
|---|
| 28 |
} |
|---|
| 29 |
else |
|---|
| 30 |
{ |
|---|
| 31 |
div.style.display = "block"; |
|---|
| 32 |
button.value = button.value.replace("»", "«"); |
|---|
| 33 |
} |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
//--></script> |
|---|
| 37 |
|
|---|
| 38 |
<% |
|---|
| 39 |
EditField field = new EditField(request); |
|---|
| 40 |
List<String> books = emdros.getEnumerationConstantNames("book_name_e"); |
|---|
| 41 |
|
|---|
| 42 |
int maxResults = 100; |
|---|
| 43 |
|
|---|
| 44 |
try |
|---|
| 45 |
{ |
|---|
| 46 |
maxResults = Integer.parseInt(request.getParameter("max_results")); |
|---|
| 47 |
} |
|---|
| 48 |
catch (Exception e) |
|---|
| 49 |
{ |
|---|
| 50 |
// do nothing |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
String query = null; |
|---|
| 54 |
Search search = null; |
|---|
| 55 |
DatabaseException exception = null; |
|---|
| 56 |
boolean simpleSearch = (request.getParameter("simple") != null); |
|---|
| 57 |
boolean advancedSearch = (request.getParameter("advanced") != null); |
|---|
| 58 |
List<SearchResult> results = null; |
|---|
| 59 |
|
|---|
| 60 |
if (simpleSearch || advancedSearch) |
|---|
| 61 |
{ |
|---|
| 62 |
search = new Search(emdros); |
|---|
| 63 |
search.setMaxResults(maxResults); |
|---|
| 64 |
|
|---|
| 65 |
if (simpleSearch) |
|---|
| 66 |
{ |
|---|
| 67 |
query = request.getParameter("q"); |
|---|
| 68 |
results = search.basic(query); |
|---|
| 69 |
} |
|---|
| 70 |
else if (advancedSearch) |
|---|
| 71 |
{ |
|---|
| 72 |
query = request.getParameter("aq"); |
|---|
| 73 |
// results = search.advanced(query); |
|---|
| 74 |
|
|---|
| 75 |
try |
|---|
| 76 |
{ |
|---|
| 77 |
results = search.advanced(query); |
|---|
| 78 |
} |
|---|
| 79 |
catch (DatabaseException e) |
|---|
| 80 |
{ |
|---|
| 81 |
exception = e; |
|---|
| 82 |
} |
|---|
| 83 |
} |
|---|
| 84 |
} |
|---|
| 85 |
%> |
|---|
| 86 |
|
|---|
| 87 |
<form name="simple" method="GET" class="bigborder"> |
|---|
| 88 |
<p> |
|---|
| 89 |
Simple search (enter surface consonants for a Hebrew word): |
|---|
| 90 |
</p> |
|---|
| 91 |
<p> |
|---|
| 92 |
<%= field.text("q", "", true, 40) %> |
|---|
| 93 |
<input type="submit" name="simple" value="Search" /> |
|---|
| 94 |
<% |
|---|
| 95 |
if (simpleSearch && request.getParameter("q").equals("")) |
|---|
| 96 |
{ |
|---|
| 97 |
results = null; |
|---|
| 98 |
%><div class="errormsg">Please enter a word to search for.</div><% |
|---|
| 99 |
} |
|---|
| 100 |
%> |
|---|
| 101 |
</p> |
|---|
| 102 |
<hr /> |
|---|
| 103 |
<p> |
|---|
| 104 |
Advanced search (enter an MQL query to nest within [clause]): |
|---|
| 105 |
</p> |
|---|
| 106 |
<p> |
|---|
| 107 |
<%= field.text("aq").setAttribute("size", "40") %> |
|---|
| 108 |
<input type="submit" name="advanced" value="Search" /> |
|---|
| 109 |
<% |
|---|
| 110 |
if (advancedSearch) |
|---|
| 111 |
{ |
|---|
| 112 |
if (request.getParameter("aq").equals("")) |
|---|
| 113 |
{ |
|---|
| 114 |
results = null; |
|---|
| 115 |
%><div class="errormsg">Please enter an MQL query.</div><% |
|---|
| 116 |
} |
|---|
| 117 |
else if (exception != null) |
|---|
| 118 |
{ |
|---|
| 119 |
%> |
|---|
| 120 |
<div class="errormsg"> |
|---|
| 121 |
<%= exception.getCause().getMessage() |
|---|
| 122 |
.replaceAll("\n(.)", ": $1") %> |
|---|
| 123 |
</div> |
|---|
| 124 |
<% |
|---|
| 125 |
} |
|---|
| 126 |
} |
|---|
| 127 |
%> |
|---|
| 128 |
</p> |
|---|
| 129 |
<hr /> |
|---|
| 130 |
<div id="simple_adv_div" class="advanced"> |
|---|
| 131 |
<p> |
|---|
| 132 |
<%= field.checkbox("limit_loc").setAttribute("onclick", |
|---|
| 133 |
"return enableLimitControls()") %> |
|---|
| 134 |
Limit search to <%= field.select("book", books) %> |
|---|
| 135 |
</p> |
|---|
| 136 |
<p> |
|---|
| 137 |
Return only the first |
|---|
| 138 |
<%= field.text("max_results", "100", true, 5) %> |
|---|
| 139 |
clauses |
|---|
| 140 |
</p> |
|---|
| 141 |
<hr /> |
|---|
| 142 |
<p> |
|---|
| 143 |
Three Latin consonants are expected, in upper or lower case, |
|---|
| 144 |
from the set: |
|---|
| 145 |
</p> |
|---|
| 146 |
<table class="grid"> |
|---|
| 147 |
<tr> |
|---|
| 148 |
<th>Consonants</th> |
|---|
| 149 |
<% |
|---|
| 150 |
String latin = ">BGDHWZXVJKLMNS<PYQRFCT"; |
|---|
| 151 |
|
|---|
| 152 |
for (int i = 0; i < latin.length() ; i++) |
|---|
| 153 |
{ |
|---|
| 154 |
String c = latin.substring(i, i + 1).replaceAll("<", "<"); |
|---|
| 155 |
%> |
|---|
| 156 |
<td><%= c %></td> |
|---|
| 157 |
<% |
|---|
| 158 |
} |
|---|
| 159 |
%> |
|---|
| 160 |
</tr> |
|---|
| 161 |
<tr> |
|---|
| 162 |
<th>Hebrew</th> |
|---|
| 163 |
<% |
|---|
| 164 |
for (int i = 0; i < latin.length() ; i++) |
|---|
| 165 |
{ |
|---|
| 166 |
String c = latin.substring(i, i + 1); |
|---|
| 167 |
String h = HebrewConverter.toHebrew(c); |
|---|
| 168 |
%> |
|---|
| 169 |
<td class="hebrew"><%= h %></td> |
|---|
| 170 |
<% |
|---|
| 171 |
} |
|---|
| 172 |
%> |
|---|
| 173 |
</tr> |
|---|
| 174 |
<tr> |
|---|
| 175 |
<th>Transliteration</th> |
|---|
| 176 |
<% |
|---|
| 177 |
for (int i = 0; i < latin.length() ; i++) |
|---|
| 178 |
{ |
|---|
| 179 |
String c = latin.substring(i, i + 1); |
|---|
| 180 |
String h = HebrewConverter.toTranslit(c); |
|---|
| 181 |
%> |
|---|
| 182 |
<td><%= h %></td> |
|---|
| 183 |
<% |
|---|
| 184 |
} |
|---|
| 185 |
%> |
|---|
| 186 |
</tr> |
|---|
| 187 |
</table> |
|---|
| 188 |
</div> |
|---|
| 189 |
<div> |
|---|
| 190 |
<input type="button" name="simple_adv_btn" |
|---|
| 191 |
value="Advanced Options »" |
|---|
| 192 |
onclick="toggle(this, 'simple_adv_div')" /> |
|---|
| 193 |
</div> |
|---|
| 194 |
</form> |
|---|
| 195 |
|
|---|
| 196 |
<script type="text/javascript"><!-- |
|---|
| 197 |
enableLimitControls(); |
|---|
| 198 |
//--></script> |
|---|
| 199 |
|
|---|
| 200 |
<% |
|---|
| 201 |
if (search != null && results != null) |
|---|
| 202 |
{ |
|---|
| 203 |
%> |
|---|
| 204 |
<h3>Search Results for <em><%= query %></em></h3> |
|---|
| 205 |
<% |
|---|
| 206 |
|
|---|
| 207 |
if (results.size() == 0) |
|---|
| 208 |
{ |
|---|
| 209 |
%><h4>No matches found</h4><% |
|---|
| 210 |
} |
|---|
| 211 |
else |
|---|
| 212 |
{ |
|---|
| 213 |
int numShown = search.getResultCount(); |
|---|
| 214 |
%><h4>Displaying first <%= results.size() %> of |
|---|
| 215 |
<%= search.getResultCount() %> results.</h4><% |
|---|
| 216 |
|
|---|
| 217 |
%> |
|---|
| 218 |
<table class="search_results"> |
|---|
| 219 |
<tr> |
|---|
| 220 |
<th>Clause Text</th> |
|---|
| 221 |
<th>Reference</th> |
|---|
| 222 |
</tr> |
|---|
| 223 |
<% |
|---|
| 224 |
|
|---|
| 225 |
for (Iterator<SearchResult> i = results.iterator(); i.hasNext();) |
|---|
| 226 |
{ |
|---|
| 227 |
SearchResult result = i.next(); |
|---|
| 228 |
|
|---|
| 229 |
%> |
|---|
| 230 |
<tr> |
|---|
| 231 |
<td class="translit"><%= result.getDescription() %></td> |
|---|
| 232 |
<td><a href="<%= result.getLinkUrl() %>"><%= |
|---|
| 233 |
result.getLocation() |
|---|
| 234 |
%></a></td> |
|---|
| 235 |
</tr> |
|---|
| 236 |
<% |
|---|
| 237 |
} |
|---|
| 238 |
|
|---|
| 239 |
%> |
|---|
| 240 |
</table> |
|---|
| 241 |
<% |
|---|
| 242 |
} |
|---|
| 243 |
} |
|---|
| 244 |
%> |
|---|
| 245 |
|
|---|
| 246 |
<%@ include file="footer.jsp" %> |
|---|