-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.php
More file actions
executable file
·219 lines (174 loc) · 7.76 KB
/
forms.php
File metadata and controls
executable file
·219 lines (174 loc) · 7.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
include ("includes/cms.php");
// update download_csv.php with any changes made here
$searchStr = initVars('s', '');
$glossID = initVars('id', '');
$aWordForm = initVars('aWf', '');
$aHeadword = initVars('aHw', '');
$aWordClass = initVars('aWc', '');
$aSubclass = initVars('aSc', '');
$aMorph = initVars('aMor', '');
$findChars = array('*', '·', '-');
$replaceChars = array('%', '', '');
// custom replacements
$aSubclass = preg_replace('/\bio\b/', 'i̯o', $aSubclass);
$aSubclass = preg_replace('/\bia\b/', 'i̯a', $aSubclass);
// lists
$aWordClassList = array('adjective', 'adverb', 'article', 'conjunction', 'noun', 'number', 'particle', 'preposition', 'pronoun', 'verb');
// error checking
$error = '';
templateHeader();
?>
<div class="container-fluid bg-light border-bottom mb-5 ">
<div class="container px-4 py-4 ">
<!-- browse form -->
<h2 class="h3 border-bottom">Search for Old Irish forms</h2>
<form name="form01" id="form01" action="forms.php" method="get">
<div class="row">
<div class="col-lg-2 py-1">
<label for="aWf">Word form:</label>
</div>
<div class="col-lg-4 py-1">
<input class="form-control" type="text" id="aWf" name="aWf" value="<?php print $aWordForm ?>" placeholder=""/>
</div>
</div>
<div class="row">
<div class="col-lg-2 py-1">
<label for="aHw">Headword:</label>
</div>
<div class="col-lg-4 py-1">
<input class="form-control" type="text" id="aHw" name="aHw" value="<?php print $aHeadword ?>" placeholder=""/>
</div>
</div>
<div class="row">
<div class="col-lg-2 py-1">
<label for="aWc">Word class:</label>
</div>
<div class="col-lg-4 py-1">
<select class="form-select" id="aWc" name="aWc">
<option value="">(any)</option>
<?php
foreach ($aWordClassList As $val) {
writeOption($val, $val, $aWordClass);
}
?>
</select>
</div>
</div>
<div class="row">
<div class="col-lg-2 py-1">
<label for="aSc">Sub-class:</label>
</div>
<div class="col-lg-4 py-1">
<input class="form-control" type="text" id="aSc" name="aSc" value="<?php print $aSubclass ?>" placeholder="" />
</div>
</div>
<div class="row">
<div class="col-lg-2 py-1">
<label for="aMor">Morphology:</label>
</div>
<div class="col-lg-4 py-1">
<input class="form-control" type="text" id="aMor" name="aMor" value="<?php print $aMorph ?>" placeholder="" />
</div>
</div>
<div class="row">
<div class="col-lg-2 py-1"></div>
<div class="col-lg-4 py-1">
<input class="btn btn-secondary btn-sm" type="submit" value="Search" />
<input class="btn btn-secondary btn-sm" type="button" id="formClear" value="Clear" />
</div>
</div>
</form>
<script src="components/forms_autocomplete.js"></script>
</div>
</div>
<div class="container">
<?php
// searching
if ($error != '') print $error;
elseif ($aWordForm <> '' or $aHeadword <> '' or $aWordClass <> '' or $aSubclass <> '' or $aMorph <> '') {
print '<h2>Search results</h2>';
// search analysis data
$sql = "Select g.ms_ref, g.code, g.thesaurus_ref, g.thesaurus_page, w.glossID, w.word_instance, w.headword, w.DIL_headword, w.wordclass, w.subclass, w.meaning, w.analysis, w.voice, w.rel
From word_instances w Left Join
glosses g On w.glossID = g.recordID
Where g.recordID > 0 "; // dummy condition
if ($aWordForm <> '') $sql .= "And w.word_instance_index Like '" . str_replace($findChars, $replaceChars, $aWordForm) . "' ";
if ($aHeadword <> '') $sql .= "And w.headword Like '" . $aHeadword . "' ";
if ($aWordClass <> '') $sql .= "And w.wordclass Like '" . $aWordClass . "%' ";
if ($aSubclass <> '') $sql .= "And w.subclass Like '%" . $aSubclass . "%' ";
if ($aMorph <> '') $sql .= "And w.analysis Like '%" . $aMorph . "%' ";
$sql .= "Order By g.recordID ";
$results = mysqli_query($link, $sql);
if (mysqli_num_rows($results) == 0) {
print '<p>No details found.</p><p> </p>';
writeInstructions();
}
else {
$rows = mysqli_fetch_all($results, MYSQLI_ASSOC);
if (mysqli_num_rows($results) == 1) print '<p>One matching Old Irish form found. ';
else print '<p>' . mysqli_num_rows($results) . ' matching Old Irish forms found. ';
print ' (Click on a column heading to sort by that column.) </p>';
print '<table id="myTable" class="table table-striped mt-5 sortable">';
print '<tr>';
print '<th onclick="sortTable(0);">MS</th>';
print '<th>Gloss</th>';
print '<th><i>Thes.</i></th>';
print '<th onclick="sortTable(3);">Word form</th>';
print '<th onclick="sortTable(4);">Headword</th>';
print '<th onclick="sortTable(5);">Word class</th>';
print '<th onclick="sortTable(6);">Sub-class</th>';
print '<th onclick="sortTable(7);">Morph.</th>';
print '<th>Meaning</th>';
print '<th>Voice</th>';
print '<th>Relative?</th>';
print '</tr>';
$row = 0;
while ($row < mysqli_num_rows($results)) {
print '<tr>';
print '<td class="small" nowrap="nowrap">' . formatMsRef($rows[$row]['ms_ref']) . '</td>';
print '<td class="small" nowrap="nowrap">' . $rows[$row]['code'] . '</td>';
print '<td class="small" nowrap="nowrap">' . formatThesRef($rows[$row]['thesaurus_ref'], $rows[$row]['thesaurus_page']) . '</td>';
print '<td nowrap="nowrap"><a data-bs-toggle="tooltip" title="Click to view full gloss." href="index.php?id=' . $rows[$row]['glossID'] . '&an=1">' . $rows[$row]['word_instance'] . '</a></td>';
print '<td nowrap="nowrap"><a data-bs-toggle="tooltip" title="Click to see all attestations of this headword." href="forms.php?aHw=' . $rows[$row]['headword'] . '">' . $rows[$row]['headword'] . '</a>';
if ($rows[$row]['DIL_headword'] != 'n/a') print ' <span class="note">[<a class="note" target="_blank" href="http://www.dil.ie/search?q=' . $rows[$row]['DIL_headword'] . '&search_in=headword">DIL</a>]</span>';
print '</td>';
print '<td class="small" nowrap="nowrap">' . $rows[$row]['wordclass'] . '</td>';
print '<td class="small" nowrap="nowrap"><a href="forms.php?aSc=' . $rows[$row]['subclass'] . '">' . $rows[$row]['subclass'] . '</a></td>';
print '<td class="small"><a href="forms.php?aMor=' . $rows[$row]['analysis'] . '">' . $rows[$row]['analysis'] . '</a></td>';
print '<td class="small">' . $rows[$row]['meaning'] . '</td>';
print '<td class="small" nowrap="nowrap">' . $rows[$row]['voice'] . '</td>';
print '<td class="small" nowrap="nowrap">' . $rows[$row]['rel'] . '</td>';
print '</tr>';
$row ++;
}
print '</table>';
print '<p> </p>';
print '<p class="small">Download this table as a <a href="download_csv.php?' . $_SERVER['QUERY_STRING'] . '">CSV file</a> (Unicode/UTF-8 character set).</p>';
}
}
else {
writeInstructions();
}
?>
</div>
<?php
templateFooter();
function writeInstructions() {
?>
<p>How to use the search form:</p>
<ul>
<li><b>Word form</b> represents the form actually found in the manuscript.
<br/><span class="small">Enter a precise form or use * as a wildcard, e.g. <i>dogniat, dogn*, *iat</i>. Diacritics, etc. unnecessary.<span></li>
<li><b>Headword</b> is the normalised lemma (usually corresponding to the headword in <a href="http://www.dil.ie" target="_blank">DIL</a>).
<br/><span class="small">Enter a complete form or use * as a wildcard, e.g. <i>dogni, dog*, *ni</i>. Diacritics, etc. unnecessary.<span></li>
<li><b>Word class</b> corresponds to part of speech.
</li>
<li><b>Sub-class</b> refers to the headword's morphological class (e.g. <i>ā</i>-stem noun, BI verb).
<br/><span class="small">e.g. <i>m, o; f, a; 3pl</i>. Type something to see options.<span></li>
<li><b>Morphology</b> provides a description of the specific word form.
<br/><span class="small">e.g. <i>gen.sg., 3sg., pass., imperf.</i> Type something to see options.<span></li>
</ul>
<?php
}
?>