1 |
dpavlin |
604 |
<?php // vim:syntax=php |
2 |
|
|
/* |
3 |
|
|
The Malete project - the Z39.2/Z39.50 database framework of OpenIsis. |
4 |
|
|
Version 0.9.x (patchlevel see file Version) |
5 |
|
|
Copyright (C) 2001-2004 by Erik Grziwotz, erik@openisis.org |
6 |
|
|
|
7 |
|
|
This library is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU Lesser General Public |
9 |
|
|
License as published by the Free Software Foundation; either |
10 |
|
|
version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
|
12 |
|
|
This library is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
|
|
Lesser General Public License for more details. |
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU Lesser General Public |
18 |
|
|
License along with this library; if not, write to the Free Software |
19 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
|
|
|
21 |
|
|
see README for more information |
22 |
|
|
EOH */ |
23 |
|
|
|
24 |
|
|
// $Id: unicode.php,v 1.3 2004/11/12 09:35:17 kripke Exp $ |
25 |
|
|
// unicode demo for the Isis package |
26 |
|
|
|
27 |
|
|
/* |
28 |
|
|
NOTE: this file contains offending literal UTF-8 data |
29 |
|
|
If you see more than one character between these >ß< angle brackets, then: |
30 |
|
|
- use an UTF-8 capable xterm like |
31 |
|
|
LC_CTYPE=en_US.UTF-8 LESSCHARSET=UTF-8 \ |
32 |
|
|
xterm -u8 -fn -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1 |
33 |
|
|
- use an UTF-8 capable editor like |
34 |
|
|
vim '+set encoding=utf-8' unicode.php |
35 |
|
|
|
36 |
|
|
moreover this file contains some german: |
37 |
|
|
stadt=city land=country fluss=river bitte=please suchen=search |
38 |
|
|
*/ |
39 |
|
|
|
40 |
|
|
header("Content-type: text/html; charset=UTF-8"); |
41 |
|
|
|
42 |
|
|
require 'Isis.php'; // use require 'Isis/Rec.php' if you need only this |
43 |
|
|
?><html><head> |
44 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
45 |
|
|
<title>Unicode-Demo for package Isis</title> |
46 |
|
|
</head><body> |
47 |
|
|
<?php |
48 |
|
|
|
49 |
|
|
// create a db with field list ("fdt") |
50 |
|
|
$fdt = array( |
51 |
|
|
'bitte' => 10, |
52 |
|
|
'nach' => 11, |
53 |
|
|
'mfn' => 12, |
54 |
|
|
'stadt' => 21, |
55 |
|
|
'land' => 22, |
56 |
|
|
'fluss' => 23 |
57 |
|
|
); |
58 |
|
|
|
59 |
|
|
// get request parameters a and b |
60 |
|
|
// (as well as any plain numeric and v%d style |
61 |
|
|
$db = new Isis_Db($fdt, 'unicode', new Isis_Server()); |
62 |
|
|
if ( !$db->srv->sock ) { |
63 |
|
|
echo "could not contact server</body></html>\n"; |
64 |
|
|
exit; |
65 |
|
|
} |
66 |
|
|
// $db->srv->dbg = true; |
67 |
|
|
$param = Isis_Http::fromReq($db); |
68 |
|
|
$paramdump = $param->toString(); |
69 |
|
|
|
70 |
|
|
$bitte = $param->v('bitte'); |
71 |
|
|
$param->del('bitte'); |
72 |
|
|
$nach = $param->v('nach'); |
73 |
|
|
if ('\"' == substr($nach,0,2)) // grrr ... stupid magic_quotes_gpc |
74 |
|
|
$nach = stripslashes($nach); |
75 |
|
|
$param->del('nach'); |
76 |
|
|
$mfn = $param->v('mfn'); |
77 |
|
|
$param->del('mfn'); |
78 |
|
|
// if ('bearbeiten' == $bitte) { $param = $db->read($mfn); } |
79 |
|
|
?> |
80 |
|
|
<img src="http://openisis.org/img/logo.gif" alt="Isi" |
81 |
|
|
width="100" height="100" align="left" hspace="25" border="0"/> |
82 |
|
|
<form action="/php/unicode" method="POST"> |
83 |
|
|
Stadt <input type="text" name="stadt" value="<?=$param->h('stadt')?>"/> |
84 |
|
|
Land <input type="text" name="land" value="<?=$param->h('land')?>"/> |
85 |
|
|
Fluß <input type="text" name="fluss" value="<?=$param->h('fluss')?>"/> |
86 |
|
|
<input type="submit" name="bitte" value="speichern"/> |
87 |
|
|
</form> |
88 |
|
|
<br/> |
89 |
|
|
<form action="/php/unicode"> |
90 |
|
|
nach <input type="text" name="nach" value="<?=htmlspecialchars($nach)?>"/> |
91 |
|
|
<input type="submit" name="bitte" value="suchen"/> |
92 |
|
|
<input type="submit" name="bitte" value="terms"/> |
93 |
|
|
alle |
94 |
|
|
<a href="/php/unicode?bitte=suchen">suchen</a> |
95 |
|
|
<a href="/php/unicode?bitte=terms">terms</a> |
96 |
|
|
</form> |
97 |
|
|
<br/> |
98 |
|
|
<?php |
99 |
|
|
switch ($bitte) { |
100 |
|
|
case 'speichern': |
101 |
|
|
$mfns = $db->write($param); |
102 |
|
|
echo "wrote ",count($mfns), " mfns: ", join(',',$mfns),"</br>\n"; |
103 |
|
|
$idx = new Isis_Rec(); |
104 |
|
|
$idx->head = 's'; |
105 |
|
|
$idx->set($fdt['stadt'], $param->v('stadt')); |
106 |
|
|
$idx->set($fdt['land'], $param->v('land')); |
107 |
|
|
$idx->set($fdt['fluss'], $param->v('fluss')); |
108 |
|
|
// echo "<pre>---\n", $idx->toString(), "---\n</pre>\n"; |
109 |
|
|
$res = $db->index($idx); |
110 |
|
|
echo "got $res</br>\n"; |
111 |
|
|
break; |
112 |
|
|
case 'suchen': |
113 |
|
|
if (!$nach) |
114 |
|
|
$nach = '""$'; |
115 |
|
|
$recs = $db->query($nach); |
116 |
|
|
?> |
117 |
|
|
<table cols=4 width="100%"> |
118 |
|
|
<tr bgcolor="#CCCCCC"> |
119 |
|
|
<th width="7%">Mfn</th> |
120 |
|
|
<th>Stadt</th> |
121 |
|
|
<th>Land</th> |
122 |
|
|
<th>Fluß</th> |
123 |
|
|
</tr> |
124 |
|
|
<?php |
125 |
|
|
foreach ($recs as $r) { |
126 |
|
|
echo "<tr>\n"; |
127 |
|
|
list($mfn,) = split("@",$r->head); |
128 |
|
|
printf("<td>%s</td>\n", $mfn); |
129 |
|
|
printf("<td>%s</td>\n", $r->h('stadt')); |
130 |
|
|
printf("<td>%s</td>\n", $r->h('land')); |
131 |
|
|
printf("<td>%s</td>\n", $r->h('fluss')); |
132 |
|
|
echo "</tr>\n"; |
133 |
|
|
} |
134 |
|
|
echo "</table>\n"; |
135 |
|
|
break; |
136 |
|
|
case 'terms': |
137 |
|
|
$terms = $db->terms($nach); |
138 |
|
|
$nterms = count($terms); |
139 |
|
|
$percol = (int)(($nterms+4)/5); |
140 |
|
|
?> |
141 |
|
|
<table cols=5 width="100%"> |
142 |
|
|
<tr bgcolor="#CCCCCC"> <th colspan=5 align="center"> |
143 |
|
|
<?=$nterms?> Indexeinträge</th></tr> |
144 |
|
|
<tr valign="top"><td> |
145 |
|
|
<?php |
146 |
|
|
$n = 0; |
147 |
|
|
foreach ($terms as $t) { |
148 |
|
|
$tab = strpos($t, "\t"); |
149 |
|
|
$cnt = substr($t, 0, $tab); |
150 |
|
|
$term = substr($t, $tab+1); /* there may be tabs in term */ |
151 |
|
|
printf( |
152 |
|
|
'<a href="/php/unicode?nach=%%22%s%%22&bitte=suchen">%s</a> (%d)'."<br/>\n", |
153 |
|
|
urlencode($term), $term, $cnt); |
154 |
|
|
if (!(++$n % $percol) && $nterms != $n) echo "</td><td>"; |
155 |
|
|
} |
156 |
|
|
echo "</td></tr></table>\n"; |
157 |
|
|
break; |
158 |
|
|
} |
159 |
|
|
?> |
160 |
|
|
<br/> |
161 |
|
|
<table cols="4" width="100%"> |
162 |
|
|
<tr bgcolor="#CCCCCC"> |
163 |
|
|
<th width="7%">Code</th> |
164 |
|
|
<th width="7%"> </th> |
165 |
|
|
<th width="30%">Kategorie</th> |
166 |
|
|
<th>Name</th></tr> |
167 |
|
|
<tr><td colspan="2"></td><td colspan="2">aus |
168 |
|
|
<a href="http://www.alanwood.net/unicode/latin_1_supplement.html"> |
169 |
|
|
Latin-1 Supplement 0080-00FF</a></td></tr> |
170 |
|
|
<tr><td>00D6</td><td>'Ö'</td> |
171 |
|
|
<td>LATIN CAPITAL LETTER</td><td>O WITH DIAERESIS (Ouml)</td></tr> |
172 |
|
|
<tr><td>00F1</td><td>'ñ'</td> |
173 |
|
|
<td valign="top" rowspan=4>LATIN SMALL LETTER</td><td>N WITH TILDE (ntilde)</td></tr> |
174 |
|
|
<tr><td>00F3</td><td>'ó'</td><td>O WITH ACUTE (oacute)</td></tr> |
175 |
|
|
<tr><td>00F6</td><td>'ö'</td><td>O WITH DIAERESIS (ouml)</td></tr> |
176 |
|
|
<tr><td>00FC</td><td>'ü'</td><td>U WITH DIAERESIS (uuml)</td></tr> |
177 |
|
|
|
178 |
|
|
<tr><td colspan="2"></td><td colspan="2">aus |
179 |
|
|
<a href="http://www.alanwood.net/unicode/latin_extended_a.html"> |
180 |
|
|
Latin Extended-A 0100-017F</a></td></tr> |
181 |
|
|
<tr><td>010C</td><td>'Č'</td> |
182 |
|
|
<td valign="top" rowspan=2>LATIN CAPITAL LETTER</td><td>C WITH CARON</td></tr> |
183 |
|
|
<tr><td>0141</td><td>'Ł'</td><td>L WITH STROKE</td></tr> |
184 |
|
|
<tr><td>0142</td><td>'ł'</td> |
185 |
|
|
<td valign="top" rowspan=2>LATIN SMALL LETTER</td><td>L WITH STROKE</td></tr> |
186 |
|
|
<tr><td>017A</td><td>'ź'</td><td>Z WITH ACUTE</td></tr> |
187 |
|
|
|
188 |
|
|
<tr><td colspan="2"></td><td colspan="2">aus |
189 |
|
|
<a href="http://www.alanwood.net/unicode/ipa_extensions.html"> |
190 |
|
|
IPA Extensions 0250-02AF</a></td></tr> |
191 |
|
|
<tr><td>0283</td><td>'ʃ'</td> |
192 |
|
|
<td valign="top" rowspan=3>LATIN SMALL LETTER</td><td>ESH</td></tr> |
193 |
|
|
<tr><td>028C</td><td>'ʌ'</td><td>TURNED V</td></tr> |
194 |
|
|
<tr><td>02A8</td><td>'ʨ'</td><td>TC DIGRAPH WITH CURL</td></tr> |
195 |
|
|
|
196 |
|
|
<tr><td colspan="2"></td><td colspan="2">aus |
197 |
|
|
<a href="http://www.alanwood.net/unicode/greek.html"> |
198 |
|
|
Greek and Coptic 0370-03FF</a></td></tr> |
199 |
|
|
<tr><td>0391</td><td>'Α'</td> |
200 |
|
|
<td valign="top" rowspan=2>GREEK CAPITAL LETTER</td><td>ALPHA (Alpha)</td></tr> |
201 |
|
|
<tr><td>0395</td><td>'Ε'</td><td>EPSILON (Epsilon)</td></tr> |
202 |
|
|
<tr><td>03AC</td><td>'ά'</td> |
203 |
|
|
<td valign="top" rowspan=7>GREEK SMALL LETTER</td><td>ALPHA WITH TONOS</td></tr> |
204 |
|
|
<tr><td>03AE</td><td>'ή'</td><td>ETA WITH TONOS</td></tr> |
205 |
|
|
<tr><td>03B1</td><td>'α'</td><td>ALPHA (alpha)</td></tr> |
206 |
|
|
<tr><td>03B4</td><td>'δ'</td><td>DELTA (delta)</td></tr> |
207 |
|
|
<tr><td>03B8</td><td>'θ'</td><td>THETA (theta)</td></tr> |
208 |
|
|
<tr><td>03BB</td><td>'λ'</td><td>LAMDA (lambda)</td></tr> |
209 |
|
|
<tr><td>03BD</td><td>'ν'</td><td>NU (nu)</td></tr> |
210 |
|
|
|
211 |
|
|
<tr><td colspan="2"></td><td colspan="2">aus |
212 |
|
|
<a href="http://www.alanwood.net/unicode/cyrillic.html"> |
213 |
|
|
Cyrillic 0400-04FF</a></td></tr> |
214 |
|
|
<tr><td>041C</td><td>'М'</td> |
215 |
|
|
<td valign="top" rowspan=2>CYRILLIC CAPITAL LETTER</td><td>EM</td></tr> |
216 |
|
|
<tr><td>0420</td><td>'Р'</td><td>ER</td></tr> |
217 |
|
|
<tr><td>0430</td><td>'а'</td> |
218 |
|
|
<td valign="top" rowspan=7>CYRILLIC SMALL LETTER</td><td>A</td></tr> |
219 |
|
|
<tr><td>0432</td><td>'в'</td><td>VE</td></tr> |
220 |
|
|
<tr><td>0438</td><td>'и'</td><td>I</td></tr> |
221 |
|
|
<tr><td>043A</td><td>'к'</td><td>KA</td></tr> |
222 |
|
|
<tr><td>043E</td><td>'о'</td><td>O</td></tr> |
223 |
|
|
<tr><td>0441</td><td>'с'</td><td>ES</td></tr> |
224 |
|
|
<tr><td>044F</td><td>'я'</td><td>YA</td></tr> |
225 |
|
|
</table> |
226 |
|
|
<?php |
227 |
|
|
// phpinfo(); |
228 |
|
|
/* |
229 |
|
|
function printrange ($name, $beg, $end, $aw) |
230 |
|
|
{ |
231 |
|
|
printf("**** %s %04X-%04X ", $name, $beg, $end); |
232 |
|
|
printf('<a href="http://www.alanwood.net/unicode/%s.html">html</a> ', $aw); |
233 |
|
|
printf('<a href="http://www.unicode.org/charts/PDF/U%04X.pdf">pdf</a>', $beg); |
234 |
|
|
printf("<br/>\n"); |
235 |
|
|
|
236 |
|
|
for (; $beg < $end; ) { |
237 |
|
|
$line = sprintf("%04X", $beg); |
238 |
|
|
for ($i=16; $i--; $beg++) |
239 |
|
|
$line .= sprintf(" %c%c", 192+($beg>>6), 128+(63&$beg)); |
240 |
|
|
printf("%s<br/>\n", $line); |
241 |
|
|
} |
242 |
|
|
} |
243 |
|
|
// c.f. http://openisis.org/Doc/UniStat |
244 |
|
|
// http://www.alanwood.net/unicode/#links |
245 |
|
|
printrange('Latin-1 Supplement', 0x0080, 0x00FF, 'latin_1_supplement'); |
246 |
|
|
printrange('Latin Extended-A', 0x0100, 0x017F, 'latin_extended_a'); |
247 |
|
|
printrange('Latin Extended-B', 0x0180, 0x024F, 'latin_extended_b'); |
248 |
|
|
printrange('IPA Extensions', 0x0250, 0x02AF, 'ipa_extensions'); |
249 |
|
|
printrange('Greek and Coptic', 0x0370, 0x03FF, 'greek'); |
250 |
|
|
printrange('Cyrillic', 0x0400, 0x04FF, 'cyrillic'); |
251 |
|
|
|
252 |
|
|
<br/> |
253 |
|
|
Parameters: |
254 |
|
|
<pre>-- |
255 |
|
|
<?=htmlspecialchars($paramdump)?>--</pre> |
256 |
|
|
*/ |
257 |
|
|
?> |
258 |
|
|
</body></html> |