Index: trunk/extensions/wikihiero/wh_main.php |
— | — | @@ -1,1005 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -////////////////////////////////////////////////////////////////////////// |
5 | | -// |
6 | | -// WikiHiero - A PHP convert from text using "Manual for the encoding of |
7 | | -// hieroglyphic texts for computer input" syntax to HTML entities (table and |
8 | | -// images). |
9 | | -// |
10 | | -// Copyright (C) 2004 Guillaume Blanchard (Aoineko) |
11 | | -// |
12 | | -// This program is free software; you can redistribute it and/or |
13 | | -// modify it under the terms of the GNU General Public License |
14 | | -// as published by the Free Software Foundation; either version 2 |
15 | | -// of the License, or any later version. |
16 | | -// |
17 | | -// This program is distributed in the hope that it will be useful, |
18 | | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | | -// GNU General Public License for more details. |
21 | | -// |
22 | | -// You should have received a copy of the GNU General Public License |
23 | | -// along with this program; if not, write to the Free Software |
24 | | -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | | -// |
26 | | -////////////////////////////////////////////////////////////////////////// |
27 | | - |
28 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
29 | | - die( 'Not an entry point' ); |
30 | | -} |
31 | | - |
32 | | -// ======================================================================== |
33 | | -// I N C L U D E S |
34 | | -include( dirname( __FILE__ ) . '/wh_list.php' ); |
35 | | - |
36 | | -// ======================================================================== |
37 | | -// D E F I N E S |
38 | | -define( "WH_TABLE_S", '<table class="mw-hiero-table">' ); |
39 | | -define( "WH_TABLE_E", '</table>' ); |
40 | | -define( "WH_TD_S", '<td>' ); |
41 | | -define( "WH_TD_E", '</td>' ); |
42 | | - |
43 | | -define( "WH_MODE_DEFAULT", -1 ); // use default mode |
44 | | -define( "WH_MODE_TEXT", 0 ); // text only |
45 | | -define( "WH_MODE_HTML", 1 ); // HTML without CSS |
46 | | -define( "WH_MODE_STYLE", 2 ); // HTML and CSS // not supported |
47 | | -define( "WH_MODE_IMAGE", 3 ); // picture (PNG) // not supported |
48 | | -define( "WH_MODE_RAW", 4 ); // MdC test as it |
49 | | - |
50 | | -define( "WH_TYPE_NONE", 0 ); |
51 | | -define( "WH_TYPE_GLYPH", 1 ); // rendered items |
52 | | -define( "WH_TYPE_CODE", 2 ); // single code as ':', '*', '!', '(' or ')' |
53 | | -define( "WH_TYPE_SPECIAL", 3 ); // advanced code (more than 1 caracter) |
54 | | -define( "WH_TYPE_END", 4 ); // end of line '!' |
55 | | - |
56 | | -define( "WH_SCALE_DEFAULT", -1 ); // use default scale |
57 | | -define( "WH_HEIGHT", 44 ); |
58 | | -define( "WH_IMG_MARGIN", 1 ); // default value |
59 | | -define( "WH_CARTOUCHE_WIDTH", 2 ); // default value |
60 | | - |
61 | | -define( "WH_VER_MAJ", 0 ); |
62 | | -define( "WH_VER_MED", 2 ); |
63 | | -define( "WH_VER_MIN", 14 ); |
64 | | - |
65 | | -global $wgExtensionAssetsPath; |
66 | | -define( "WH_IMG_DIR", $wgExtensionAssetsPath . '/wikihiero/img/' ); |
67 | | -define( "WH_IMG_PRE", "hiero_" ); |
68 | | -define( "WH_IMG_EXT", "png" ); |
69 | | - |
70 | | -define( "WH_DEBUG_MODE", false ); |
71 | | - |
72 | | -class WikiHiero { |
73 | | - private $scale = 100; |
74 | | - |
75 | | - public function __construct( $scale = WH_SCALE_DEFAULT ) { |
76 | | - } |
77 | | - |
78 | | - /** |
79 | | - * Render hieroglyph text |
80 | | - * |
81 | | - * @param $text string: text to convert |
82 | | - * @param $mode string: convertion mode [DEFAULT|TEXT|HTML|STYLE|IMAGE] (def=HTML) |
83 | | - * @param $scale string: global scale in percentage (def=100%) |
84 | | - * @param $line string: use line [true|false] (def=false) |
85 | | - * @return string: converted code |
86 | | - */ |
87 | | - public static function render( $text, $mode = WH_MODE_DEFAULT, $scale = WH_SCALE_DEFAULT, $line = false ) { |
88 | | - if ( $mode == WH_MODE_DEFAULT ) { |
89 | | - $mode = WH_MODE_HTML; |
90 | | - } |
91 | | - |
92 | | - $hiero = new WikiHiero( $scale ); |
93 | | - |
94 | | - switch( $mode ) { |
95 | | - case WH_MODE_TEXT: return $hiero->renderText( $text, $line ); |
96 | | - case WH_MODE_HTML: return $hiero->renderHtml( $text, $scale, $line ); |
97 | | - case WH_MODE_STYLE: die( "ERROR: CSS version not yet implemented" ); |
98 | | - case WH_MODE_IMAGE: die( "ERROR: Image version not yet implemented" ); |
99 | | - } |
100 | | - die( "ERROR: Unknown mode!" ); |
101 | | - } |
102 | | - |
103 | | - /** |
104 | | - * |
105 | | - */ |
106 | | - public static function parserHook( $input ) { |
107 | | - // Strip newlines to avoid breakage in the wiki parser block pass |
108 | | - return str_replace( "\n", " ", self::render( $input, WH_MODE_HTML ) ); |
109 | | - } |
110 | | - |
111 | | - public function getScale() { |
112 | | - return $this->scale; |
113 | | - } |
114 | | - |
115 | | - public function setScale( $scale ) { |
116 | | - $this->scale = $scale; |
117 | | - } |
118 | | - |
119 | | - /** |
120 | | - * Renders a glyph |
121 | | - * |
122 | | - * @param $glyph string: glyph's code to render |
123 | | - * @param $option string: option to add into <img> tag (use for height) |
124 | | - * @return string: a string to add to the stream |
125 | | - */ |
126 | | - private function renderGlyph( $glyph, $option = '' ) { |
127 | | - global $wh_phonemes; |
128 | | - global $wh_files; |
129 | | - |
130 | | - if ( $glyph == ".." ) { // Render void block |
131 | | - $width = WH_HEIGHT; |
132 | | - return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
133 | | - } |
134 | | - elseif ( $glyph == "." ) // Render half-width void block |
135 | | - { |
136 | | - $width = WH_HEIGHT / 2; |
137 | | - return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
138 | | - } |
139 | | - elseif ( $glyph == '<' ) // Render open cartouche |
140 | | - { |
141 | | - $height = intval( WH_HEIGHT * $this->scale / 100 ); |
142 | | - $code = $wh_phonemes[$glyph]; |
143 | | - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
144 | | - } |
145 | | - elseif ( $glyph == '>' ) // Render close cartouche |
146 | | - { |
147 | | - $height = intval( WH_HEIGHT * $this->scale / 100 ); |
148 | | - $code = $wh_phonemes[$glyph]; |
149 | | - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
150 | | - } |
151 | | - |
152 | | - if ( array_key_exists( $glyph, $wh_phonemes ) ) |
153 | | - { |
154 | | - $code = $wh_phonemes[$glyph]; |
155 | | - if ( array_key_exists( $code, $wh_files ) ) |
156 | | - return "<img style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' title='" . htmlspecialchars( "{$code} [{$glyph}]" ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
157 | | - else |
158 | | - return "<font title='" . htmlspecialchars( $code ) . "'>" . htmlspecialchars( $glyph ) . "</font>"; |
159 | | - } |
160 | | - elseif ( array_key_exists( $glyph, $wh_files ) ) |
161 | | - return "<img style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$glyph}." . WH_IMG_EXT ) . "' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
162 | | - else |
163 | | - return htmlspecialchars( $glyph ); |
164 | | - } |
165 | | - |
166 | | - /** |
167 | | - * Resize a glyph |
168 | | - * |
169 | | - * @param $item string: glyph's code |
170 | | - * @param $is_cartouche bool: true if glyph inside a cartouche |
171 | | - * @param $total int: total size of a group for multi-glyph block |
172 | | - * @return size |
173 | | - */ |
174 | | - private function resizeGlyph( $item, $is_cartouche = false, $total = 0 ) { |
175 | | - global $wh_phonemes; |
176 | | - global $wh_files; |
177 | | - |
178 | | - if ( array_key_exists( $item, $wh_phonemes ) ) { |
179 | | - $glyph = $wh_phonemes[$item]; |
180 | | - } else { |
181 | | - $glyph = $item; |
182 | | - } |
183 | | - |
184 | | - $margin = 2 * WH_IMG_MARGIN; |
185 | | - if ( $is_cartouche ) { |
186 | | - $margin += 2 * intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ); |
187 | | - } |
188 | | - |
189 | | - if ( array_key_exists( $glyph, $wh_files ) ) { |
190 | | - $height = $margin + $wh_files[$glyph][1]; |
191 | | - if ( $total ) { |
192 | | - if ( $total > WH_HEIGHT ) { |
193 | | - return ( intval( $height * WH_HEIGHT / $total ) - $margin ) * $this->scale / 100; |
194 | | - } else { |
195 | | - return ( $height - $margin ) * $this->scale / 100; |
196 | | - } |
197 | | - } else { |
198 | | - if ( $height > WH_HEIGHT ) { |
199 | | - return ( intval( WH_HEIGHT * WH_HEIGHT / $height ) - $margin ) * $this->scale / 100; |
200 | | - } else { |
201 | | - return ( $height - $margin ) * $this->scale / 100; |
202 | | - } |
203 | | - } |
204 | | - } |
205 | | - |
206 | | - return ( WH_HEIGHT - $margin ) * $this->scale / 100; |
207 | | - } |
208 | | - |
209 | | - // ------------------------------------------------------------------------ |
210 | | - // WikiHieroText - Render hieroglyph text in text mode |
211 | | - // ------------------------------------------------------------------------ |
212 | | - // hiero << text to convert |
213 | | - // line << use line [true|false] (def=false) |
214 | | - // return >> string with converted code |
215 | | - // ------------------------------------------------------------------------ |
216 | | - public function renderText( $hiero, $line = false ) { |
217 | | - global $wh_text_conv; |
218 | | - |
219 | | - $html = ""; |
220 | | - |
221 | | - if ( $line ) |
222 | | - $html .= "<hr />\n"; |
223 | | - |
224 | | - for ( $char = 0; $char < strlen( $hiero ); $char++ ) |
225 | | - { |
226 | | - if ( array_key_exists( $hiero[$char], $wh_text_conv ) ) |
227 | | - { |
228 | | - $html .= $wh_text_conv[$hiero[$char]]; |
229 | | - if ( $hiero[$char] == '!' ) |
230 | | - if ( $line ) |
231 | | - $html .= "<hr />\n"; |
232 | | - } |
233 | | - else |
234 | | - $html .= $hiero[$char]; |
235 | | - } |
236 | | - |
237 | | - return $html; |
238 | | - } |
239 | | - |
240 | | - // ------------------------------------------------------------------------ |
241 | | - // WikiHiero - Render hieroglyph text |
242 | | - // ------------------------------------------------------------------------ |
243 | | - // hiero << text to convert |
244 | | - // scale << global scale in percentage (def=100%) |
245 | | - // line << use line [true|false] (def=false) |
246 | | - // return >> string with converted code |
247 | | - // ------------------------------------------------------------------------ |
248 | | - public function renderHtml( $hiero, $scale = WH_SCALE_DEFAULT, $line = false ) { |
249 | | - global $wh_prefabs; |
250 | | - global $wh_files; |
251 | | - global $wh_phonemes; |
252 | | - |
253 | | - if ( $scale != WH_SCALE_DEFAULT ) |
254 | | - $this->setScale( $scale ); |
255 | | - |
256 | | - $html = ""; |
257 | | - |
258 | | - if ( $line ) { |
259 | | - $html .= "<hr />\n"; |
260 | | - } |
261 | | - |
262 | | - // ------------------------------------------------------------------------ |
263 | | - // Split text into block, then split block into item |
264 | | - $block = array(); |
265 | | - $block[0] = array(); |
266 | | - $block[0][0] = ""; |
267 | | - $block_id = 0; |
268 | | - $item_id = 0; |
269 | | - $parenthesis = 0; |
270 | | - $type = WH_TYPE_NONE; |
271 | | - $is_cartouche = false; |
272 | | - |
273 | | - for ( $char = 0; $char < strlen( $hiero ); $char++ ) { |
274 | | - |
275 | | - if ( $hiero[$char] == '(' ) { |
276 | | - $parenthesis++; |
277 | | - } elseif ( $hiero[$char] == ')' ) { |
278 | | - $parenthesis--; |
279 | | - } |
280 | | - |
281 | | - if ( $parenthesis == 0 ) { |
282 | | - if ( $hiero[$char] == '-' || $hiero[$char] == ' ' ) { |
283 | | - if ( $type != WH_TYPE_NONE ) { |
284 | | - $block_id++; |
285 | | - $block[$block_id] = array(); |
286 | | - $item_id = 0; |
287 | | - $block[$block_id][$item_id] = ""; |
288 | | - $type = WH_TYPE_NONE; |
289 | | - } |
290 | | - } |
291 | | - } else {// don't slit block if inside parenthesis |
292 | | - if ( $hiero[$char] == '-' ) { |
293 | | - $item_id++; |
294 | | - $block[$block_id][$item_id] = '-'; |
295 | | - $type = WH_TYPE_CODE; |
296 | | - } |
297 | | - } |
298 | | - |
299 | | - if ( $hiero[$char] == '!' ) { |
300 | | - if ( $item_id > 0 ) { |
301 | | - $block_id++; |
302 | | - $block[$block_id] = array(); |
303 | | - $item_id = 0; |
304 | | - } |
305 | | - $block[$block_id][$item_id] = $hiero[$char]; |
306 | | - $type = WH_TYPE_END; |
307 | | - |
308 | | - } elseif ( preg_match( "/[*:()]/", $hiero[$char] ) ) { |
309 | | - |
310 | | - if ( $type == WH_TYPE_GLYPH || $type == WH_TYPE_CODE ) { |
311 | | - $item_id++; |
312 | | - $block[$block_id][$item_id] = ""; |
313 | | - } |
314 | | - $block[$block_id][$item_id] = $hiero[$char]; |
315 | | - $type = WH_TYPE_CODE; |
316 | | - |
317 | | - } elseif ( ctype_alnum( $hiero[$char] ) || $hiero[$char] == '.' || $hiero[$char] == '<' || $hiero[$char] == '>' ) { |
318 | | - if ( $type == WH_TYPE_END ) { |
319 | | - $block_id++; |
320 | | - $block[$block_id] = array(); |
321 | | - $item_id = 0; |
322 | | - $block[$block_id][$item_id] = ""; |
323 | | - } elseif ( $type == WH_TYPE_CODE ) { |
324 | | - $item_id++; |
325 | | - $block[$block_id][$item_id] = ""; |
326 | | - } |
327 | | - $block[$block_id][$item_id] .= $hiero[$char]; |
328 | | - $type = WH_TYPE_GLYPH; |
329 | | - } |
330 | | - } |
331 | | - |
332 | | - // DEBUG: See the block split table |
333 | | - if ( WH_DEBUG_MODE ) { |
334 | | - |
335 | | - foreach ( $block as $code ) { |
336 | | - echo "| "; |
337 | | - foreach ( $code as $item ) { |
338 | | - echo "$item | "; |
339 | | - } |
340 | | - echo "<br />\n"; |
341 | | - } |
342 | | - } |
343 | | - |
344 | | - $contentHtml = $tableHtml = $tableContentHtml = ""; |
345 | | - // $html .= WH_TABLE_S."<tr>\n"; |
346 | | - |
347 | | - // ------------------------------------------------------------------------ |
348 | | - // Loop into all blocks |
349 | | - foreach ( $block as $code ) { |
350 | | - |
351 | | - // simplest case, the block contain only 1 code -> render |
352 | | - if ( count( $code ) == 1 ) |
353 | | - { |
354 | | - if ( $code[0] == "!" ) { // end of line |
355 | | - $tableHtml = "</tr>" . WH_TABLE_E . WH_TABLE_S . "<tr>\n"; |
356 | | - if ( $line ) { |
357 | | - $contentHtml .= "<hr />\n"; |
358 | | - } |
359 | | - |
360 | | - } elseif ( strchr( $code[0], '<' ) ) { // start cartouche |
361 | | - $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
362 | | - $is_cartouche = true; |
363 | | - $contentHtml .= "<td>" . WH_TABLE_S . "<tr><td height='" . intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ) . "px' bgcolor='black'></td></tr><tr><td>" . WH_TABLE_S . "<tr>"; |
364 | | - |
365 | | - } elseif ( strchr( $code[0], '>' ) ) { // end cartouche |
366 | | - $contentHtml .= "</tr>" . WH_TABLE_E . "</td></tr><tr><td height='" . intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ) . "px' bgcolor='black'></td></tr>" . WH_TABLE_E . "</td>"; |
367 | | - $is_cartouche = false; |
368 | | - $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
369 | | - |
370 | | - } elseif ( $code[0] != "" ) { // assum is glyph or '..' or '.' |
371 | | - $option = "height='" . $this->resizeGlyph( $code[0], $is_cartouche ) . "'"; |
372 | | - |
373 | | - $contentHtml .= WH_TD_S . self::renderGlyph( $code[0], $option ) . WH_TD_E; |
374 | | - } |
375 | | - |
376 | | - // block contain more than 1 glyph |
377 | | - } else { |
378 | | - |
379 | | - // convert all code into '&' to test prefabs glyph |
380 | | - $temp = ""; |
381 | | - foreach ( $code as $t ) { |
382 | | - if ( preg_match( "/[*:!()]/", $t[0] ) ) { |
383 | | - $temp .= "&"; |
384 | | - } else { |
385 | | - $temp .= $t; |
386 | | - } |
387 | | - } |
388 | | - |
389 | | - // test is block is into tje prefabs list |
390 | | - if ( in_array( $temp, $wh_prefabs ) ) { |
391 | | - $option = "height='" . $this->resizeGlyph( $temp, $is_cartouche ) . "'"; |
392 | | - |
393 | | - $contentHtml .= WH_TD_S . self::renderGlyph( $temp, $option ) . WH_TD_E; |
394 | | - |
395 | | - // block must be manualy computed |
396 | | - } else { |
397 | | - // get block total height |
398 | | - $line_max = 0; |
399 | | - $total = 0; |
400 | | - $height = 0; |
401 | | - |
402 | | - foreach ( $code as $t ) { |
403 | | - if ( $t == ":" ) { |
404 | | - if ( $height > $line_max ) { |
405 | | - $line_max = $height; |
406 | | - } |
407 | | - $total += $line_max; |
408 | | - $line_max = 0; |
409 | | - |
410 | | - } elseif ( $t == "*" ) { |
411 | | - if ( $height > $line_max ) { |
412 | | - $line_max = $height; |
413 | | - } |
414 | | - } else { |
415 | | - if ( array_key_exists( $t, $wh_phonemes ) ) { |
416 | | - $glyph = $wh_phonemes[$t]; |
417 | | - } else { |
418 | | - $glyph = $t; |
419 | | - } |
420 | | - if ( array_key_exists( $glyph, $wh_files ) ) { |
421 | | - $height = 2 + $wh_files[$glyph][1]; |
422 | | - } |
423 | | - } |
424 | | - } // end foreach |
425 | | - |
426 | | - if ( $height > $line_max ) { |
427 | | - $line_max = $height; |
428 | | - } |
429 | | - |
430 | | - $total += $line_max; |
431 | | - |
432 | | - // render all glyph into the block |
433 | | - $temp = ""; |
434 | | - foreach ( $code as $t ) { |
435 | | - |
436 | | - if ( $t == ":" ) { |
437 | | - $temp .= "<br />"; |
438 | | - |
439 | | - } elseif ( $t == "*" ) { |
440 | | - $temp .= " "; |
441 | | - |
442 | | - } else { |
443 | | - // resize the glyph according to the block total height |
444 | | - $option = "height='" . $this->resizeGlyph( $t, $is_cartouche, $total ) . "'"; |
445 | | - $temp .= self::renderGlyph( $t, $option ); |
446 | | - } |
447 | | - } // end foreach |
448 | | - |
449 | | - $contentHtml .= WH_TD_S . $temp . WH_TD_E; |
450 | | - } |
451 | | - $contentHtml .= "\n"; |
452 | | - } |
453 | | - |
454 | | - if ( strlen( $contentHtml ) > 0 ) { |
455 | | - $tableContentHtml .= $tableHtml . $contentHtml; |
456 | | - $contentHtml = $tableHtml = ""; |
457 | | - } |
458 | | - } |
459 | | - |
460 | | - if ( strlen( $tableContentHtml ) > 0 ) { |
461 | | - $html .= WH_TABLE_S . "<tr>\n" . $tableContentHtml . "</tr>" . WH_TABLE_E; |
462 | | - } |
463 | | - |
464 | | - return "<table class='mw-hiero-table mw-hiero-outer' dir='ltr'><tr><td>\n$html\n</td></tr></table>"; |
465 | | - } |
466 | | - |
467 | | -} |
468 | | - |
469 | | -// ======================================================================== |
470 | | -// G L O B A L S |
471 | | -global $wh_phonemes, $wh_text_conv; |
472 | | - |
473 | | -$wh_phonemes = array( // convertion table phoneme -> gardiner code |
474 | | - "mSa" => "A12", |
475 | | - "xr" => "A15", |
476 | | - "Xrd" => "A17", |
477 | | - "sr" => "A21", |
478 | | - "mniw" => "A33", |
479 | | - "qiz" => "A38", |
480 | | - "iry" => "A47", |
481 | | - "Sps" => "A50", |
482 | | - "Spsi" => "A51", |
483 | | -/* |
484 | | - "x" => "J1", |
485 | | - "mAa" => "J11", |
486 | | - "gs" => "J13", |
487 | | - "im" => "J13", |
488 | | - "M" => "J15", |
489 | | - "sA" => "J17", |
490 | | - "apr" => "J20", |
491 | | - "wDa" => "J21", |
492 | | - "nD" => "J27", |
493 | | - "qd" => "J28", |
494 | | - "Xkr" => "J30", |
495 | | - "Hp" => "J5", |
496 | | - "qn" => "J8", |
497 | | -*/ |
498 | | - "x" => "Aa1", |
499 | | - "mAa" => "Aa11", |
500 | | - "gs" => "Aa13", |
501 | | - "im" => "Aa13", |
502 | | - "M" => "Aa15", |
503 | | - "sA" => "Aa17", |
504 | | - "apr" => "Aa20", |
505 | | - "wDa" => "Aa21", |
506 | | - "nD" => "Aa27", |
507 | | - "qd" => "Aa28", |
508 | | - "Xkr" => "Aa30", |
509 | | - "Hp" => "Aa5", |
510 | | - "qn" => "Aa8", |
511 | | - |
512 | | - "msi" => "B3", |
513 | | - "mAat" => "C10", |
514 | | - "HH" => "C11", |
515 | | - "DHwty" => "C3", |
516 | | - "Xnmw" => "C4", |
517 | | - "inpw" => "C6", |
518 | | - "stX" => "C7", |
519 | | - "mnw" => "C8", |
520 | | - "tp" => "D1", |
521 | | - "wDAt" => "D10", |
522 | | - "R" => "D153", |
523 | | - "fnD" => "D19", |
524 | | - "Hr" => "D2", |
525 | | - "r" => "D21", |
526 | | - "rA" => "D21", |
527 | | - "spt" => "D24", |
528 | | - "spty" => "D25", |
529 | | - "mnD" => "D27", |
530 | | - "kA" => "D28", |
531 | | - "Sny" => "D3", |
532 | | - "aHA" => "D34", |
533 | | - "a" => "D36", |
534 | | - "ir" => "D4", |
535 | | - "Dsr" => "D45", |
536 | | - "d" => "D46", |
537 | | - "Dba" => "D50", |
538 | | - "mt" => "D52", |
539 | | - "gH" => "D56", |
540 | | - "gHs" => "D56", |
541 | | - "rd" => "D56", |
542 | | - "sbq" => "D56", |
543 | | - "b" => "D58", |
544 | | - "ab" => "D59", |
545 | | - "wab" => "D60", |
546 | | - "sAH" => "D61", |
547 | | - "rmi" => "D9", |
548 | | - "zAb" => "E17", |
549 | | - "mAi" => "E22", |
550 | | - "l" => "E23", |
551 | | - "rw" => "E23", |
552 | | - "Aby" => "E24", |
553 | | - "wn" => "E34", |
554 | | - "zzmt" => "E6", |
555 | | - "wsr" => "F12", |
556 | | - "wp" => "F13", |
557 | | - "db" => "F16", |
558 | | - "Hw" => "F18", |
559 | | - "bH" => "F18", |
560 | | - "ns" => "F20", |
561 | | - "DrD" => "F21", |
562 | | - "idn" => "F21", |
563 | | - "msDr" => "F21", |
564 | | - "sDm" => "F21", |
565 | | - "kfA" => "F22", |
566 | | - "pH" => "F22", |
567 | | - "xpS" => "F23", |
568 | | - "wHm" => "F25", |
569 | | - "Xn" => "F26", |
570 | | - "sti" => "F29", |
571 | | - "Sd" => "F30", |
572 | | - "ms" => "F31", |
573 | | - "X" => "F32", |
574 | | - "sd" => "F33", |
575 | | - "ib" => "F34", |
576 | | - "nfr" => "F35", |
577 | | - "zmA" => "F36", |
578 | | - "imAx" => "F39", |
579 | | - "HAt" => "F4", |
580 | | - "Aw" => "F40", |
581 | | - "spr" => "F42", |
582 | | - "isw" => "F44", |
583 | | - "iwa" => "F44", |
584 | | - "pXr" => "F46", |
585 | | - "qAb" => "F46", |
586 | | - "SsA" => "F5", |
587 | | - "A" => "G1", |
588 | | - "mwt" => "G14", |
589 | | - "nbty" => "G16", |
590 | | - "m" => "G17", |
591 | | - "mm" => "G18", |
592 | | - "AA" => "G2", |
593 | | - "nH" => "G21", |
594 | | - "Db" => "G22", |
595 | | - "rxyt" => "G23", |
596 | | - "Ax" => "G25", |
597 | | - "dSr" => "G27", |
598 | | - "gm" => "G28", |
599 | | - "bA" => "G29", |
600 | | - "baHi" => "G32", |
601 | | - "aq" => "G35", |
602 | | - "wr" => "G36", |
603 | | - "nDs" => "G37", |
604 | | - "gb" => "G38", |
605 | | - "zA" => "G39", |
606 | | - "tyw" => "G4", |
607 | | - "pA" => "G40", |
608 | | - "xn" => "G41", |
609 | | - "wSA" => "G42", |
610 | | - "w" => "G43", |
611 | | - "ww" => "G44", |
612 | | - "mAw" => "G46", |
613 | | - "TA" => "G47", |
614 | | - "snD" => "G54", |
615 | | - "pq" => "H2", |
616 | | - "wSm" => "H2", |
617 | | - "pAq" => "H3", |
618 | | - "nr" => "H4", |
619 | | - "Sw" => "H6", |
620 | | - "aSA" => "I1", |
621 | | - "D" => "I10", |
622 | | - "DD" => "I11", |
623 | | - "Styw" => "I2", |
624 | | - "mzH" => "I3", |
625 | | - "sbk" => "I4", |
626 | | - "sAq" => "I5", |
627 | | - "km" => "I6", |
628 | | - "Hfn" => "I8", |
629 | | - "f" => "I9", |
630 | | - "in" => "K1", |
631 | | - "ad" => "K3", |
632 | | - "XA" => "K4", |
633 | | - "bz" => "K5", |
634 | | - "nSmt" => "K6", |
635 | | - "xpr" => "L1", |
636 | | - "bit" => "L2", |
637 | | - "srqt" => "L7", |
638 | | - "iAm" => "M1", |
639 | | - "wdn" => "M11", |
640 | | - "xA" => "M12", |
641 | | - "1000" => "M12", |
642 | | - "wAD" => "M13", |
643 | | - "HA" => "M16", |
644 | | - "i" => "M17", |
645 | | - "ii" => "M18", |
646 | | - "Hn" => "M2", |
647 | | - "sxt" => "M20", |
648 | | - "sm" => "M21", |
649 | | - "nn" => "M22A", |
650 | | - "sw" => "M23", |
651 | | - "rsw" => "M24", |
652 | | - "Sma" => "M26", |
653 | | - "nDm" => "M29", |
654 | | - "xt" => "M3", |
655 | | - "bnr" => "M30", |
656 | | - "bdt" => "M34", |
657 | | - "Dr" => "M36", |
658 | | - "rnp" => "M4", |
659 | | - "iz" => "M40", |
660 | | - "tr" => "M6", |
661 | | - "SA" => "M8", |
662 | | - "zSn" => "M9", |
663 | | - "pt" => "N1", |
664 | | - "Abd" => "N11", |
665 | | - "iaH" => "N11", |
666 | | - "dwA" => "N14", |
667 | | - "sbA" => "N14", |
668 | | - "dwAt" => "N15", |
669 | | - "tA" => "N16", |
670 | | - "iw" => "N18", |
671 | | - "wDb" => "N20", |
672 | | - "spAt" => "N24", |
673 | | - "xAst" => "N25", |
674 | | - "Dw" => "N26", |
675 | | - "Axt" => "N27", |
676 | | - "xa" => "N28", |
677 | | - "q" => "N29", |
678 | | - "iAt" => "N30", |
679 | | - "n" => "N35", |
680 | | - "mw" => "N35A", |
681 | | - "S" => "N37", |
682 | | - "iAdt" => "N4", |
683 | | - "idt" => "N4", |
684 | | - "Sm" => "N40", |
685 | | - "id" => "N41", |
686 | | - "hrw" => "N5", |
687 | | - "ra" => "N5", |
688 | | - "zw" => "N5", |
689 | | - "Hnmmt" => "N8", |
690 | | - "pzD" => "N9", |
691 | | - "pr" => "O1", |
692 | | - "aH" => "O11", |
693 | | - "wsxt" => "O15", |
694 | | - "kAr" => "O18", |
695 | | - "zH" => "O22", |
696 | | - "txn" => "O25", |
697 | | - "iwn" => "O28", |
698 | | - "aA" => "O29", |
699 | | - "zxnt" => "O30", |
700 | | - "z" => "O34", |
701 | | - "zb" => "O35", |
702 | | - "inb" => "O36", |
703 | | - "qnbt" => "O38A", |
704 | | - "h" => "O4", |
705 | | - "Szp" => "O42", |
706 | | - "ipt" => "O45", |
707 | | - "nxn" => "O47", |
708 | | - "niwt" => "O49", |
709 | | - "zp" => "O50", |
710 | | - "Snwt" => "O51", |
711 | | - "Hwt" => "O6", |
712 | | - "wHa" => "P4", |
713 | | - "TAw" => "P5", |
714 | | - "nfw" => "P5", |
715 | | - "aHa" => "P6", |
716 | | - "xrw" => "P8", |
717 | | - "st" => "Q1", |
718 | | - "wz" => "Q2", |
719 | | - "p" => "Q3", |
720 | | - "qrsw" => "Q6", |
721 | | - "xAt" => "R1", |
722 | | - "xAwt" => "R1", |
723 | | - "Dd" => "R11", |
724 | | - "dd" => "R11", |
725 | | - "imnt" => "R14", |
726 | | - "iAb" => "R15", |
727 | | - "wx" => "R16", |
728 | | - "xm" => "R22", |
729 | | - "Htp" => "R4", |
730 | | - "kAp" => "R5", |
731 | | - "kp" => "R5", |
732 | | - "snTr" => "R7", |
733 | | - "nTr" => "R8", |
734 | | - "nTrw" => "R8A", |
735 | | - "bd" => "R9", |
736 | | - "HDt" => "S1", |
737 | | - "mDH" => "S10", |
738 | | - "wsx" => "S11", |
739 | | - "nbw" => "S12", |
740 | | - "THn" => "S15", |
741 | | - "tHn" => "S15", |
742 | | - "mnit" => "S18", |
743 | | - "sDAw" => "S19", |
744 | | - "xtm" => "S20", |
745 | | - "sT" => "S22", |
746 | | - "dmD" => "S23", |
747 | | - "Tz" => "S24", |
748 | | - "Sndyt" => "S26", |
749 | | - "mnxt" => "S27", |
750 | | - "s" => "S29", |
751 | | - "N" => "S3", |
752 | | - "dSrt" => "S3", |
753 | | - "sf" => "S30", |
754 | | - "siA" => "S32", |
755 | | - "Tb" => "S33", |
756 | | - "anx" => "S34", |
757 | | - "Swt" => "S35", |
758 | | - "xw" => "S37", |
759 | | - "HqA" => "S38", |
760 | | - "awt" => "S39", |
761 | | - "wAs" => "S40", |
762 | | - "Dam" => "S41", |
763 | | - "abA" => "S42", |
764 | | - "sxm" => "S42", |
765 | | - "xrp" => "S42", |
766 | | - "md" => "S43", |
767 | | - "Ams" => "S44", |
768 | | - "nxxw" => "S45", |
769 | | - "K" => "S56", |
770 | | - "sxmty" => "S6", |
771 | | - "xprS" => "S7", |
772 | | - "Atf" => "S8", |
773 | | - "Swty" => "S9", |
774 | | - "pD" => "T10", |
775 | | - "sXr" => "T11", |
776 | | - "zin" => "T11", |
777 | | - "zwn" => "T11", |
778 | | - "Ai" => "T12", |
779 | | - "Ar" => "T12", |
780 | | - "rwD" => "T12", |
781 | | - "rwd" => "T12", |
782 | | - "rs" => "T13", |
783 | | - "qmA" => "T14", |
784 | | - "wrrt" => "T17", |
785 | | - "Sms" => "T18", |
786 | | - "qs" => "T19", |
787 | | - "wa" => "T21", |
788 | | - "sn" => "T22", |
789 | | - "iH" => "T24", |
790 | | - "DbA" => "T25", |
791 | | - "Xr" => "T28", |
792 | | - "nmt" => "T29", |
793 | | - "HD" => "T3", |
794 | | - "sSm" => "T31", |
795 | | - "nm" => "T34", |
796 | | - "HDD" => "T6", |
797 | | - "pd" => "T9", |
798 | | - "mA" => "U1", |
799 | | - "it" => "U10", |
800 | | - "HqAt" => "U11", |
801 | | - "Sna" => "U13", |
802 | | - "hb" => "U13", |
803 | | - "tm" => "U15", |
804 | | - "biA" => "U16", |
805 | | - "grg" => "U17", |
806 | | - "stp" => "U21", |
807 | | - "mnx" => "U22", |
808 | | - "Ab" => "U23", |
809 | | - "Hmt" => "U24", |
810 | | - "wbA" => "U26", |
811 | | - "DA" => "U28", |
812 | | - "rtH" => "U31", |
813 | | - "zmn" => "U32", |
814 | | - "ti" => "U33", |
815 | | - "xsf" => "U34", |
816 | | - "Hm" => "U36", |
817 | | - "mxAt" => "U38", |
818 | | - "mr" => "U6", |
819 | | - "100" => "V1", |
820 | | - "arq" => "V12", |
821 | | - "T" => "V13", |
822 | | - "iTi" => "V15", |
823 | | - "TmA" => "V19", |
824 | | - "XAr" => "V19", |
825 | | - "mDt" => "V19", |
826 | | - "sTA" => "V2", |
827 | | - "10" => "V20", |
828 | | - "mD" => "V20", |
829 | | - "mH" => "V22", |
830 | | - "wD" => "V24", |
831 | | - "aD" => "V26", |
832 | | - "H" => "V28", |
833 | | - "sk" => "V29", |
834 | | - "wAH" => "V29", |
835 | | - "sTAw" => "V3", |
836 | | - "nb" => "V30", |
837 | | - "k" => "V31", |
838 | | - "msn" => "V32", |
839 | | - "sSr" => "V33", |
840 | | - "idr" => "V37", |
841 | | - "wA" => "V4", |
842 | | - "snT" => "V5", |
843 | | - "sS" => "V6", |
844 | | - "Sn" => "V7", |
845 | | - "iab" => "W10", |
846 | | - "g" => "W11", |
847 | | - "nzt" => "W11", |
848 | | - "Hz" => "W14", |
849 | | - "xnt" => "W17", |
850 | | - "mi" => "W19", |
851 | | - "bAs" => "W2", |
852 | | - "Hnqt" => "W22", |
853 | | - "nw" => "W24", |
854 | | - "ini" => "W25", |
855 | | - "Hb" => "W3", |
856 | | - "Xnm" => "W9", |
857 | | - "t" => "X1", |
858 | | - "di" => "X8", |
859 | | - "rdi" => "X8", |
860 | | - "mDAt" => "Y1", |
861 | | - "mnhd" => "Y3", |
862 | | - "zS" => "Y3", |
863 | | - "mn" => "Y5", |
864 | | - "ibA" => "Y6", |
865 | | - "zSSt" => "Y8", |
866 | | - "imi" => "Z11", |
867 | | - "y" => "Z4", |
868 | | - "W" => "Z7", |
869 | | - |
870 | | - "<1" => "Ca1", // cartouche |
871 | | - "2>" => "Ca2", |
872 | | - "<2" => "Ca2a", |
873 | | - "1>" => "Ca1a", |
874 | | - "<0" => "Ca1", |
875 | | - "0>" => "Ca2", |
876 | | - "<h1" => "Cah1", // horus |
877 | | - "h1>" => "Cah1a", |
878 | | - "<h2" => "Cah2", |
879 | | - "h2>" => "Cah2a", |
880 | | - "<h3" => "Cah3", |
881 | | - "h3>" => "Cah3a", |
882 | | - "<h0" => "Cah1", |
883 | | - "h0>" => "Cah1a", |
884 | | - "<" => "Ca1", // cartouche |
885 | | - ">" => "Ca2", |
886 | | - "[&" => "Ba16", |
887 | | - "&]" => "Ba16", |
888 | | - "[{" => "Ba17", |
889 | | - "}]" => "Ba17a", |
890 | | - "[[" => "Ba15", |
891 | | - "]]" => "Ba15a", |
892 | | - "[\"" => "", |
893 | | - "\"]" => "", |
894 | | - "['" => "", |
895 | | - "']" => "", |
896 | | -); |
897 | | - |
898 | | -/* not used yet |
899 | | -$wh_syntax = array( |
900 | | - "-", //block sepatator |
901 | | - ":", //supperposition |
902 | | - "*", //juxtaposition |
903 | | - "(", //open bracket |
904 | | - ")", //close bracket |
905 | | - "!!", //end of text |
906 | | - "!", //end of line |
907 | | - "..", //blank caracter |
908 | | - ".", //half-size blank caracter |
909 | | - "$", //color |
910 | | - "#", //shade |
911 | | - "[&", //select |
912 | | - "&]", |
913 | | - "[{", |
914 | | - "}]", |
915 | | - "[[", |
916 | | - "]]", |
917 | | - "[\"", |
918 | | - "\"]", |
919 | | - "['", |
920 | | - "']", |
921 | | - "<", //cartouche |
922 | | - ">", |
923 | | - "<1", |
924 | | - "2>", |
925 | | - "<2", |
926 | | - "1>", |
927 | | - "<0", |
928 | | - "0>", |
929 | | - "<h1", //horus |
930 | | - "h1>", |
931 | | - "<h2", |
932 | | - "h2>", |
933 | | - "<h3", |
934 | | - "h3>", |
935 | | - "<h0", |
936 | | - "h0>", |
937 | | - "++", //comment |
938 | | - "+s", //hieroglyph |
939 | | - "+t", //transcription |
940 | | - "+l", //latin-normal |
941 | | - "+i", //latin-italic |
942 | | - "+g", //latin-bold (gras) |
943 | | - "+b", //latin-bold |
944 | | - "+c", |
945 | | -); |
946 | | -*/ |
947 | | - |
948 | | -// convertion table for text mode |
949 | | -$wh_text_conv = array( |
950 | | - "-" => " ", |
951 | | - ":" => "-", |
952 | | - "*" => "-", |
953 | | - "!" => "<br />", |
954 | | - "." => "", |
955 | | - "=" => "", |
956 | | - "(" => "", |
957 | | - ")" => "", |
958 | | - "<1" => "(", |
959 | | - "2>" => ")|", |
960 | | - "<2" => "|(", |
961 | | - "1>" => ")", |
962 | | - "<0" => "(", |
963 | | - "0>" => ")|", |
964 | | - "<h1" => "[", // horus |
965 | | - "h1>" => "]", |
966 | | - "<h2" => "[", |
967 | | - "h2>" => "]", |
968 | | - "<h3" => "[", |
969 | | - "h3>" => "]", |
970 | | - "<h0" => "[", |
971 | | - "h0>" => "]", |
972 | | - "<" => "(", // cartouche |
973 | | - ">" => ")|", |
974 | | -); |
975 | | - |
976 | | -// ======================================================================== |
977 | | -// F U N C T I O N S |
978 | | - |
979 | | - |
980 | | -// ======================================================================== |
981 | | -// |
982 | | -// W i k i H i e r o |
983 | | -// |
984 | | - |
985 | | -// ------------------------------------------------------------------------ |
986 | | -// WH_GetCode - Get glyph code from file name |
987 | | -// ------------------------------------------------------------------------ |
988 | | -// file << file name |
989 | | -// return >> string with converted code |
990 | | -// ------------------------------------------------------------------------ |
991 | | -function WH_GetCode( $file ) { |
992 | | - return substr( $file, strlen( WH_IMG_PRE ), -( 1 + strlen( WH_IMG_EXT ) ) ); |
993 | | -} |
994 | | - |
995 | | -// ------------------------------------------------------------------------ |
996 | | -// WH_Credit - Get glyph code from file name |
997 | | -// ------------------------------------------------------------------------ |
998 | | -// return >> credit string |
999 | | -// ------------------------------------------------------------------------ |
1000 | | -function WH_Credit() { |
1001 | | - $html = ""; |
1002 | | - $html .= "<b>WikiHiero v" . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN . "</b>\n"; |
1003 | | - $html .= "by Guillaume Blanchard (Aoineko) under GPL (2004).<br />\n"; |
1004 | | - $html .= "Hieroglyph credit: S. Rosmorduc, G. Watson, J. Hirst (under GFDL).\n"; |
1005 | | - return $html; |
1006 | | -} |
Index: trunk/extensions/wikihiero/wikihiero.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | ); |
39 | 39 | $wgExtensionMessagesFiles['Wikihiero'] = dirname( __FILE__ ) . '/wikihiero.i18n.php'; |
40 | 40 | |
41 | | -$wgAutoloadClasses['WikiHiero'] = dirname( __FILE__ ) . '/wh_main.php'; |
| 41 | +$wgAutoloadClasses['WikiHiero'] = dirname( __FILE__ ) . '/wikihiero.body.php'; |
42 | 42 | |
43 | 43 | $wgResourceModules['ext.wikihiero'] = array( |
44 | 44 | 'styles' => 'ext.wikihiero.css', |
Index: trunk/extensions/wikihiero/wikihiero.body.php |
— | — | @@ -0,0 +1,1005 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +////////////////////////////////////////////////////////////////////////// |
| 5 | +// |
| 6 | +// WikiHiero - A PHP convert from text using "Manual for the encoding of |
| 7 | +// hieroglyphic texts for computer input" syntax to HTML entities (table and |
| 8 | +// images). |
| 9 | +// |
| 10 | +// Copyright (C) 2004 Guillaume Blanchard (Aoineko) |
| 11 | +// |
| 12 | +// This program is free software; you can redistribute it and/or |
| 13 | +// modify it under the terms of the GNU General Public License |
| 14 | +// as published by the Free Software Foundation; either version 2 |
| 15 | +// of the License, or any later version. |
| 16 | +// |
| 17 | +// This program is distributed in the hope that it will be useful, |
| 18 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +// GNU General Public License for more details. |
| 21 | +// |
| 22 | +// You should have received a copy of the GNU General Public License |
| 23 | +// along with this program; if not, write to the Free Software |
| 24 | +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | +// |
| 26 | +////////////////////////////////////////////////////////////////////////// |
| 27 | + |
| 28 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 29 | + die( 'Not an entry point' ); |
| 30 | +} |
| 31 | + |
| 32 | +// ======================================================================== |
| 33 | +// I N C L U D E S |
| 34 | +include( dirname( __FILE__ ) . '/wh_list.php' ); |
| 35 | + |
| 36 | +// ======================================================================== |
| 37 | +// D E F I N E S |
| 38 | +define( "WH_TABLE_S", '<table class="mw-hiero-table">' ); |
| 39 | +define( "WH_TABLE_E", '</table>' ); |
| 40 | +define( "WH_TD_S", '<td>' ); |
| 41 | +define( "WH_TD_E", '</td>' ); |
| 42 | + |
| 43 | +define( "WH_MODE_DEFAULT", -1 ); // use default mode |
| 44 | +define( "WH_MODE_TEXT", 0 ); // text only |
| 45 | +define( "WH_MODE_HTML", 1 ); // HTML without CSS |
| 46 | +define( "WH_MODE_STYLE", 2 ); // HTML and CSS // not supported |
| 47 | +define( "WH_MODE_IMAGE", 3 ); // picture (PNG) // not supported |
| 48 | +define( "WH_MODE_RAW", 4 ); // MdC test as it |
| 49 | + |
| 50 | +define( "WH_TYPE_NONE", 0 ); |
| 51 | +define( "WH_TYPE_GLYPH", 1 ); // rendered items |
| 52 | +define( "WH_TYPE_CODE", 2 ); // single code as ':', '*', '!', '(' or ')' |
| 53 | +define( "WH_TYPE_SPECIAL", 3 ); // advanced code (more than 1 caracter) |
| 54 | +define( "WH_TYPE_END", 4 ); // end of line '!' |
| 55 | + |
| 56 | +define( "WH_SCALE_DEFAULT", -1 ); // use default scale |
| 57 | +define( "WH_HEIGHT", 44 ); |
| 58 | +define( "WH_IMG_MARGIN", 1 ); // default value |
| 59 | +define( "WH_CARTOUCHE_WIDTH", 2 ); // default value |
| 60 | + |
| 61 | +define( "WH_VER_MAJ", 0 ); |
| 62 | +define( "WH_VER_MED", 2 ); |
| 63 | +define( "WH_VER_MIN", 14 ); |
| 64 | + |
| 65 | +global $wgExtensionAssetsPath; |
| 66 | +define( "WH_IMG_DIR", $wgExtensionAssetsPath . '/wikihiero/img/' ); |
| 67 | +define( "WH_IMG_PRE", "hiero_" ); |
| 68 | +define( "WH_IMG_EXT", "png" ); |
| 69 | + |
| 70 | +define( "WH_DEBUG_MODE", false ); |
| 71 | + |
| 72 | +class WikiHiero { |
| 73 | + private $scale = 100; |
| 74 | + |
| 75 | + public function __construct( $scale = WH_SCALE_DEFAULT ) { |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * Render hieroglyph text |
| 80 | + * |
| 81 | + * @param $text string: text to convert |
| 82 | + * @param $mode string: convertion mode [DEFAULT|TEXT|HTML|STYLE|IMAGE] (def=HTML) |
| 83 | + * @param $scale string: global scale in percentage (def=100%) |
| 84 | + * @param $line string: use line [true|false] (def=false) |
| 85 | + * @return string: converted code |
| 86 | + */ |
| 87 | + public static function render( $text, $mode = WH_MODE_DEFAULT, $scale = WH_SCALE_DEFAULT, $line = false ) { |
| 88 | + if ( $mode == WH_MODE_DEFAULT ) { |
| 89 | + $mode = WH_MODE_HTML; |
| 90 | + } |
| 91 | + |
| 92 | + $hiero = new WikiHiero( $scale ); |
| 93 | + |
| 94 | + switch( $mode ) { |
| 95 | + case WH_MODE_TEXT: return $hiero->renderText( $text, $line ); |
| 96 | + case WH_MODE_HTML: return $hiero->renderHtml( $text, $scale, $line ); |
| 97 | + case WH_MODE_STYLE: die( "ERROR: CSS version not yet implemented" ); |
| 98 | + case WH_MODE_IMAGE: die( "ERROR: Image version not yet implemented" ); |
| 99 | + } |
| 100 | + die( "ERROR: Unknown mode!" ); |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * |
| 105 | + */ |
| 106 | + public static function parserHook( $input ) { |
| 107 | + // Strip newlines to avoid breakage in the wiki parser block pass |
| 108 | + return str_replace( "\n", " ", self::render( $input, WH_MODE_HTML ) ); |
| 109 | + } |
| 110 | + |
| 111 | + public function getScale() { |
| 112 | + return $this->scale; |
| 113 | + } |
| 114 | + |
| 115 | + public function setScale( $scale ) { |
| 116 | + $this->scale = $scale; |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Renders a glyph |
| 121 | + * |
| 122 | + * @param $glyph string: glyph's code to render |
| 123 | + * @param $option string: option to add into <img> tag (use for height) |
| 124 | + * @return string: a string to add to the stream |
| 125 | + */ |
| 126 | + private function renderGlyph( $glyph, $option = '' ) { |
| 127 | + global $wh_phonemes; |
| 128 | + global $wh_files; |
| 129 | + |
| 130 | + if ( $glyph == ".." ) { // Render void block |
| 131 | + $width = WH_HEIGHT; |
| 132 | + return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
| 133 | + } |
| 134 | + elseif ( $glyph == "." ) // Render half-width void block |
| 135 | + { |
| 136 | + $width = WH_HEIGHT / 2; |
| 137 | + return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
| 138 | + } |
| 139 | + elseif ( $glyph == '<' ) // Render open cartouche |
| 140 | + { |
| 141 | + $height = intval( WH_HEIGHT * $this->scale / 100 ); |
| 142 | + $code = $wh_phonemes[$glyph]; |
| 143 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 144 | + } |
| 145 | + elseif ( $glyph == '>' ) // Render close cartouche |
| 146 | + { |
| 147 | + $height = intval( WH_HEIGHT * $this->scale / 100 ); |
| 148 | + $code = $wh_phonemes[$glyph]; |
| 149 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 150 | + } |
| 151 | + |
| 152 | + if ( array_key_exists( $glyph, $wh_phonemes ) ) |
| 153 | + { |
| 154 | + $code = $wh_phonemes[$glyph]; |
| 155 | + if ( array_key_exists( $code, $wh_files ) ) |
| 156 | + return "<img style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' title='" . htmlspecialchars( "{$code} [{$glyph}]" ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 157 | + else |
| 158 | + return "<font title='" . htmlspecialchars( $code ) . "'>" . htmlspecialchars( $glyph ) . "</font>"; |
| 159 | + } |
| 160 | + elseif ( array_key_exists( $glyph, $wh_files ) ) |
| 161 | + return "<img style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$glyph}." . WH_IMG_EXT ) . "' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 162 | + else |
| 163 | + return htmlspecialchars( $glyph ); |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * Resize a glyph |
| 168 | + * |
| 169 | + * @param $item string: glyph's code |
| 170 | + * @param $is_cartouche bool: true if glyph inside a cartouche |
| 171 | + * @param $total int: total size of a group for multi-glyph block |
| 172 | + * @return size |
| 173 | + */ |
| 174 | + private function resizeGlyph( $item, $is_cartouche = false, $total = 0 ) { |
| 175 | + global $wh_phonemes; |
| 176 | + global $wh_files; |
| 177 | + |
| 178 | + if ( array_key_exists( $item, $wh_phonemes ) ) { |
| 179 | + $glyph = $wh_phonemes[$item]; |
| 180 | + } else { |
| 181 | + $glyph = $item; |
| 182 | + } |
| 183 | + |
| 184 | + $margin = 2 * WH_IMG_MARGIN; |
| 185 | + if ( $is_cartouche ) { |
| 186 | + $margin += 2 * intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ); |
| 187 | + } |
| 188 | + |
| 189 | + if ( array_key_exists( $glyph, $wh_files ) ) { |
| 190 | + $height = $margin + $wh_files[$glyph][1]; |
| 191 | + if ( $total ) { |
| 192 | + if ( $total > WH_HEIGHT ) { |
| 193 | + return ( intval( $height * WH_HEIGHT / $total ) - $margin ) * $this->scale / 100; |
| 194 | + } else { |
| 195 | + return ( $height - $margin ) * $this->scale / 100; |
| 196 | + } |
| 197 | + } else { |
| 198 | + if ( $height > WH_HEIGHT ) { |
| 199 | + return ( intval( WH_HEIGHT * WH_HEIGHT / $height ) - $margin ) * $this->scale / 100; |
| 200 | + } else { |
| 201 | + return ( $height - $margin ) * $this->scale / 100; |
| 202 | + } |
| 203 | + } |
| 204 | + } |
| 205 | + |
| 206 | + return ( WH_HEIGHT - $margin ) * $this->scale / 100; |
| 207 | + } |
| 208 | + |
| 209 | + // ------------------------------------------------------------------------ |
| 210 | + // WikiHieroText - Render hieroglyph text in text mode |
| 211 | + // ------------------------------------------------------------------------ |
| 212 | + // hiero << text to convert |
| 213 | + // line << use line [true|false] (def=false) |
| 214 | + // return >> string with converted code |
| 215 | + // ------------------------------------------------------------------------ |
| 216 | + public function renderText( $hiero, $line = false ) { |
| 217 | + global $wh_text_conv; |
| 218 | + |
| 219 | + $html = ""; |
| 220 | + |
| 221 | + if ( $line ) |
| 222 | + $html .= "<hr />\n"; |
| 223 | + |
| 224 | + for ( $char = 0; $char < strlen( $hiero ); $char++ ) |
| 225 | + { |
| 226 | + if ( array_key_exists( $hiero[$char], $wh_text_conv ) ) |
| 227 | + { |
| 228 | + $html .= $wh_text_conv[$hiero[$char]]; |
| 229 | + if ( $hiero[$char] == '!' ) |
| 230 | + if ( $line ) |
| 231 | + $html .= "<hr />\n"; |
| 232 | + } |
| 233 | + else |
| 234 | + $html .= $hiero[$char]; |
| 235 | + } |
| 236 | + |
| 237 | + return $html; |
| 238 | + } |
| 239 | + |
| 240 | + // ------------------------------------------------------------------------ |
| 241 | + // WikiHiero - Render hieroglyph text |
| 242 | + // ------------------------------------------------------------------------ |
| 243 | + // hiero << text to convert |
| 244 | + // scale << global scale in percentage (def=100%) |
| 245 | + // line << use line [true|false] (def=false) |
| 246 | + // return >> string with converted code |
| 247 | + // ------------------------------------------------------------------------ |
| 248 | + public function renderHtml( $hiero, $scale = WH_SCALE_DEFAULT, $line = false ) { |
| 249 | + global $wh_prefabs; |
| 250 | + global $wh_files; |
| 251 | + global $wh_phonemes; |
| 252 | + |
| 253 | + if ( $scale != WH_SCALE_DEFAULT ) |
| 254 | + $this->setScale( $scale ); |
| 255 | + |
| 256 | + $html = ""; |
| 257 | + |
| 258 | + if ( $line ) { |
| 259 | + $html .= "<hr />\n"; |
| 260 | + } |
| 261 | + |
| 262 | + // ------------------------------------------------------------------------ |
| 263 | + // Split text into block, then split block into item |
| 264 | + $block = array(); |
| 265 | + $block[0] = array(); |
| 266 | + $block[0][0] = ""; |
| 267 | + $block_id = 0; |
| 268 | + $item_id = 0; |
| 269 | + $parenthesis = 0; |
| 270 | + $type = WH_TYPE_NONE; |
| 271 | + $is_cartouche = false; |
| 272 | + |
| 273 | + for ( $char = 0; $char < strlen( $hiero ); $char++ ) { |
| 274 | + |
| 275 | + if ( $hiero[$char] == '(' ) { |
| 276 | + $parenthesis++; |
| 277 | + } elseif ( $hiero[$char] == ')' ) { |
| 278 | + $parenthesis--; |
| 279 | + } |
| 280 | + |
| 281 | + if ( $parenthesis == 0 ) { |
| 282 | + if ( $hiero[$char] == '-' || $hiero[$char] == ' ' ) { |
| 283 | + if ( $type != WH_TYPE_NONE ) { |
| 284 | + $block_id++; |
| 285 | + $block[$block_id] = array(); |
| 286 | + $item_id = 0; |
| 287 | + $block[$block_id][$item_id] = ""; |
| 288 | + $type = WH_TYPE_NONE; |
| 289 | + } |
| 290 | + } |
| 291 | + } else {// don't slit block if inside parenthesis |
| 292 | + if ( $hiero[$char] == '-' ) { |
| 293 | + $item_id++; |
| 294 | + $block[$block_id][$item_id] = '-'; |
| 295 | + $type = WH_TYPE_CODE; |
| 296 | + } |
| 297 | + } |
| 298 | + |
| 299 | + if ( $hiero[$char] == '!' ) { |
| 300 | + if ( $item_id > 0 ) { |
| 301 | + $block_id++; |
| 302 | + $block[$block_id] = array(); |
| 303 | + $item_id = 0; |
| 304 | + } |
| 305 | + $block[$block_id][$item_id] = $hiero[$char]; |
| 306 | + $type = WH_TYPE_END; |
| 307 | + |
| 308 | + } elseif ( preg_match( "/[*:()]/", $hiero[$char] ) ) { |
| 309 | + |
| 310 | + if ( $type == WH_TYPE_GLYPH || $type == WH_TYPE_CODE ) { |
| 311 | + $item_id++; |
| 312 | + $block[$block_id][$item_id] = ""; |
| 313 | + } |
| 314 | + $block[$block_id][$item_id] = $hiero[$char]; |
| 315 | + $type = WH_TYPE_CODE; |
| 316 | + |
| 317 | + } elseif ( ctype_alnum( $hiero[$char] ) || $hiero[$char] == '.' || $hiero[$char] == '<' || $hiero[$char] == '>' ) { |
| 318 | + if ( $type == WH_TYPE_END ) { |
| 319 | + $block_id++; |
| 320 | + $block[$block_id] = array(); |
| 321 | + $item_id = 0; |
| 322 | + $block[$block_id][$item_id] = ""; |
| 323 | + } elseif ( $type == WH_TYPE_CODE ) { |
| 324 | + $item_id++; |
| 325 | + $block[$block_id][$item_id] = ""; |
| 326 | + } |
| 327 | + $block[$block_id][$item_id] .= $hiero[$char]; |
| 328 | + $type = WH_TYPE_GLYPH; |
| 329 | + } |
| 330 | + } |
| 331 | + |
| 332 | + // DEBUG: See the block split table |
| 333 | + if ( WH_DEBUG_MODE ) { |
| 334 | + |
| 335 | + foreach ( $block as $code ) { |
| 336 | + echo "| "; |
| 337 | + foreach ( $code as $item ) { |
| 338 | + echo "$item | "; |
| 339 | + } |
| 340 | + echo "<br />\n"; |
| 341 | + } |
| 342 | + } |
| 343 | + |
| 344 | + $contentHtml = $tableHtml = $tableContentHtml = ""; |
| 345 | + // $html .= WH_TABLE_S."<tr>\n"; |
| 346 | + |
| 347 | + // ------------------------------------------------------------------------ |
| 348 | + // Loop into all blocks |
| 349 | + foreach ( $block as $code ) { |
| 350 | + |
| 351 | + // simplest case, the block contain only 1 code -> render |
| 352 | + if ( count( $code ) == 1 ) |
| 353 | + { |
| 354 | + if ( $code[0] == "!" ) { // end of line |
| 355 | + $tableHtml = "</tr>" . WH_TABLE_E . WH_TABLE_S . "<tr>\n"; |
| 356 | + if ( $line ) { |
| 357 | + $contentHtml .= "<hr />\n"; |
| 358 | + } |
| 359 | + |
| 360 | + } elseif ( strchr( $code[0], '<' ) ) { // start cartouche |
| 361 | + $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
| 362 | + $is_cartouche = true; |
| 363 | + $contentHtml .= "<td>" . WH_TABLE_S . "<tr><td height='" . intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ) . "px' bgcolor='black'></td></tr><tr><td>" . WH_TABLE_S . "<tr>"; |
| 364 | + |
| 365 | + } elseif ( strchr( $code[0], '>' ) ) { // end cartouche |
| 366 | + $contentHtml .= "</tr>" . WH_TABLE_E . "</td></tr><tr><td height='" . intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ) . "px' bgcolor='black'></td></tr>" . WH_TABLE_E . "</td>"; |
| 367 | + $is_cartouche = false; |
| 368 | + $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
| 369 | + |
| 370 | + } elseif ( $code[0] != "" ) { // assum is glyph or '..' or '.' |
| 371 | + $option = "height='" . $this->resizeGlyph( $code[0], $is_cartouche ) . "'"; |
| 372 | + |
| 373 | + $contentHtml .= WH_TD_S . self::renderGlyph( $code[0], $option ) . WH_TD_E; |
| 374 | + } |
| 375 | + |
| 376 | + // block contain more than 1 glyph |
| 377 | + } else { |
| 378 | + |
| 379 | + // convert all code into '&' to test prefabs glyph |
| 380 | + $temp = ""; |
| 381 | + foreach ( $code as $t ) { |
| 382 | + if ( preg_match( "/[*:!()]/", $t[0] ) ) { |
| 383 | + $temp .= "&"; |
| 384 | + } else { |
| 385 | + $temp .= $t; |
| 386 | + } |
| 387 | + } |
| 388 | + |
| 389 | + // test is block is into tje prefabs list |
| 390 | + if ( in_array( $temp, $wh_prefabs ) ) { |
| 391 | + $option = "height='" . $this->resizeGlyph( $temp, $is_cartouche ) . "'"; |
| 392 | + |
| 393 | + $contentHtml .= WH_TD_S . self::renderGlyph( $temp, $option ) . WH_TD_E; |
| 394 | + |
| 395 | + // block must be manualy computed |
| 396 | + } else { |
| 397 | + // get block total height |
| 398 | + $line_max = 0; |
| 399 | + $total = 0; |
| 400 | + $height = 0; |
| 401 | + |
| 402 | + foreach ( $code as $t ) { |
| 403 | + if ( $t == ":" ) { |
| 404 | + if ( $height > $line_max ) { |
| 405 | + $line_max = $height; |
| 406 | + } |
| 407 | + $total += $line_max; |
| 408 | + $line_max = 0; |
| 409 | + |
| 410 | + } elseif ( $t == "*" ) { |
| 411 | + if ( $height > $line_max ) { |
| 412 | + $line_max = $height; |
| 413 | + } |
| 414 | + } else { |
| 415 | + if ( array_key_exists( $t, $wh_phonemes ) ) { |
| 416 | + $glyph = $wh_phonemes[$t]; |
| 417 | + } else { |
| 418 | + $glyph = $t; |
| 419 | + } |
| 420 | + if ( array_key_exists( $glyph, $wh_files ) ) { |
| 421 | + $height = 2 + $wh_files[$glyph][1]; |
| 422 | + } |
| 423 | + } |
| 424 | + } // end foreach |
| 425 | + |
| 426 | + if ( $height > $line_max ) { |
| 427 | + $line_max = $height; |
| 428 | + } |
| 429 | + |
| 430 | + $total += $line_max; |
| 431 | + |
| 432 | + // render all glyph into the block |
| 433 | + $temp = ""; |
| 434 | + foreach ( $code as $t ) { |
| 435 | + |
| 436 | + if ( $t == ":" ) { |
| 437 | + $temp .= "<br />"; |
| 438 | + |
| 439 | + } elseif ( $t == "*" ) { |
| 440 | + $temp .= " "; |
| 441 | + |
| 442 | + } else { |
| 443 | + // resize the glyph according to the block total height |
| 444 | + $option = "height='" . $this->resizeGlyph( $t, $is_cartouche, $total ) . "'"; |
| 445 | + $temp .= self::renderGlyph( $t, $option ); |
| 446 | + } |
| 447 | + } // end foreach |
| 448 | + |
| 449 | + $contentHtml .= WH_TD_S . $temp . WH_TD_E; |
| 450 | + } |
| 451 | + $contentHtml .= "\n"; |
| 452 | + } |
| 453 | + |
| 454 | + if ( strlen( $contentHtml ) > 0 ) { |
| 455 | + $tableContentHtml .= $tableHtml . $contentHtml; |
| 456 | + $contentHtml = $tableHtml = ""; |
| 457 | + } |
| 458 | + } |
| 459 | + |
| 460 | + if ( strlen( $tableContentHtml ) > 0 ) { |
| 461 | + $html .= WH_TABLE_S . "<tr>\n" . $tableContentHtml . "</tr>" . WH_TABLE_E; |
| 462 | + } |
| 463 | + |
| 464 | + return "<table class='mw-hiero-table mw-hiero-outer' dir='ltr'><tr><td>\n$html\n</td></tr></table>"; |
| 465 | + } |
| 466 | + |
| 467 | +} |
| 468 | + |
| 469 | +// ======================================================================== |
| 470 | +// G L O B A L S |
| 471 | +global $wh_phonemes, $wh_text_conv; |
| 472 | + |
| 473 | +$wh_phonemes = array( // convertion table phoneme -> gardiner code |
| 474 | + "mSa" => "A12", |
| 475 | + "xr" => "A15", |
| 476 | + "Xrd" => "A17", |
| 477 | + "sr" => "A21", |
| 478 | + "mniw" => "A33", |
| 479 | + "qiz" => "A38", |
| 480 | + "iry" => "A47", |
| 481 | + "Sps" => "A50", |
| 482 | + "Spsi" => "A51", |
| 483 | +/* |
| 484 | + "x" => "J1", |
| 485 | + "mAa" => "J11", |
| 486 | + "gs" => "J13", |
| 487 | + "im" => "J13", |
| 488 | + "M" => "J15", |
| 489 | + "sA" => "J17", |
| 490 | + "apr" => "J20", |
| 491 | + "wDa" => "J21", |
| 492 | + "nD" => "J27", |
| 493 | + "qd" => "J28", |
| 494 | + "Xkr" => "J30", |
| 495 | + "Hp" => "J5", |
| 496 | + "qn" => "J8", |
| 497 | +*/ |
| 498 | + "x" => "Aa1", |
| 499 | + "mAa" => "Aa11", |
| 500 | + "gs" => "Aa13", |
| 501 | + "im" => "Aa13", |
| 502 | + "M" => "Aa15", |
| 503 | + "sA" => "Aa17", |
| 504 | + "apr" => "Aa20", |
| 505 | + "wDa" => "Aa21", |
| 506 | + "nD" => "Aa27", |
| 507 | + "qd" => "Aa28", |
| 508 | + "Xkr" => "Aa30", |
| 509 | + "Hp" => "Aa5", |
| 510 | + "qn" => "Aa8", |
| 511 | + |
| 512 | + "msi" => "B3", |
| 513 | + "mAat" => "C10", |
| 514 | + "HH" => "C11", |
| 515 | + "DHwty" => "C3", |
| 516 | + "Xnmw" => "C4", |
| 517 | + "inpw" => "C6", |
| 518 | + "stX" => "C7", |
| 519 | + "mnw" => "C8", |
| 520 | + "tp" => "D1", |
| 521 | + "wDAt" => "D10", |
| 522 | + "R" => "D153", |
| 523 | + "fnD" => "D19", |
| 524 | + "Hr" => "D2", |
| 525 | + "r" => "D21", |
| 526 | + "rA" => "D21", |
| 527 | + "spt" => "D24", |
| 528 | + "spty" => "D25", |
| 529 | + "mnD" => "D27", |
| 530 | + "kA" => "D28", |
| 531 | + "Sny" => "D3", |
| 532 | + "aHA" => "D34", |
| 533 | + "a" => "D36", |
| 534 | + "ir" => "D4", |
| 535 | + "Dsr" => "D45", |
| 536 | + "d" => "D46", |
| 537 | + "Dba" => "D50", |
| 538 | + "mt" => "D52", |
| 539 | + "gH" => "D56", |
| 540 | + "gHs" => "D56", |
| 541 | + "rd" => "D56", |
| 542 | + "sbq" => "D56", |
| 543 | + "b" => "D58", |
| 544 | + "ab" => "D59", |
| 545 | + "wab" => "D60", |
| 546 | + "sAH" => "D61", |
| 547 | + "rmi" => "D9", |
| 548 | + "zAb" => "E17", |
| 549 | + "mAi" => "E22", |
| 550 | + "l" => "E23", |
| 551 | + "rw" => "E23", |
| 552 | + "Aby" => "E24", |
| 553 | + "wn" => "E34", |
| 554 | + "zzmt" => "E6", |
| 555 | + "wsr" => "F12", |
| 556 | + "wp" => "F13", |
| 557 | + "db" => "F16", |
| 558 | + "Hw" => "F18", |
| 559 | + "bH" => "F18", |
| 560 | + "ns" => "F20", |
| 561 | + "DrD" => "F21", |
| 562 | + "idn" => "F21", |
| 563 | + "msDr" => "F21", |
| 564 | + "sDm" => "F21", |
| 565 | + "kfA" => "F22", |
| 566 | + "pH" => "F22", |
| 567 | + "xpS" => "F23", |
| 568 | + "wHm" => "F25", |
| 569 | + "Xn" => "F26", |
| 570 | + "sti" => "F29", |
| 571 | + "Sd" => "F30", |
| 572 | + "ms" => "F31", |
| 573 | + "X" => "F32", |
| 574 | + "sd" => "F33", |
| 575 | + "ib" => "F34", |
| 576 | + "nfr" => "F35", |
| 577 | + "zmA" => "F36", |
| 578 | + "imAx" => "F39", |
| 579 | + "HAt" => "F4", |
| 580 | + "Aw" => "F40", |
| 581 | + "spr" => "F42", |
| 582 | + "isw" => "F44", |
| 583 | + "iwa" => "F44", |
| 584 | + "pXr" => "F46", |
| 585 | + "qAb" => "F46", |
| 586 | + "SsA" => "F5", |
| 587 | + "A" => "G1", |
| 588 | + "mwt" => "G14", |
| 589 | + "nbty" => "G16", |
| 590 | + "m" => "G17", |
| 591 | + "mm" => "G18", |
| 592 | + "AA" => "G2", |
| 593 | + "nH" => "G21", |
| 594 | + "Db" => "G22", |
| 595 | + "rxyt" => "G23", |
| 596 | + "Ax" => "G25", |
| 597 | + "dSr" => "G27", |
| 598 | + "gm" => "G28", |
| 599 | + "bA" => "G29", |
| 600 | + "baHi" => "G32", |
| 601 | + "aq" => "G35", |
| 602 | + "wr" => "G36", |
| 603 | + "nDs" => "G37", |
| 604 | + "gb" => "G38", |
| 605 | + "zA" => "G39", |
| 606 | + "tyw" => "G4", |
| 607 | + "pA" => "G40", |
| 608 | + "xn" => "G41", |
| 609 | + "wSA" => "G42", |
| 610 | + "w" => "G43", |
| 611 | + "ww" => "G44", |
| 612 | + "mAw" => "G46", |
| 613 | + "TA" => "G47", |
| 614 | + "snD" => "G54", |
| 615 | + "pq" => "H2", |
| 616 | + "wSm" => "H2", |
| 617 | + "pAq" => "H3", |
| 618 | + "nr" => "H4", |
| 619 | + "Sw" => "H6", |
| 620 | + "aSA" => "I1", |
| 621 | + "D" => "I10", |
| 622 | + "DD" => "I11", |
| 623 | + "Styw" => "I2", |
| 624 | + "mzH" => "I3", |
| 625 | + "sbk" => "I4", |
| 626 | + "sAq" => "I5", |
| 627 | + "km" => "I6", |
| 628 | + "Hfn" => "I8", |
| 629 | + "f" => "I9", |
| 630 | + "in" => "K1", |
| 631 | + "ad" => "K3", |
| 632 | + "XA" => "K4", |
| 633 | + "bz" => "K5", |
| 634 | + "nSmt" => "K6", |
| 635 | + "xpr" => "L1", |
| 636 | + "bit" => "L2", |
| 637 | + "srqt" => "L7", |
| 638 | + "iAm" => "M1", |
| 639 | + "wdn" => "M11", |
| 640 | + "xA" => "M12", |
| 641 | + "1000" => "M12", |
| 642 | + "wAD" => "M13", |
| 643 | + "HA" => "M16", |
| 644 | + "i" => "M17", |
| 645 | + "ii" => "M18", |
| 646 | + "Hn" => "M2", |
| 647 | + "sxt" => "M20", |
| 648 | + "sm" => "M21", |
| 649 | + "nn" => "M22A", |
| 650 | + "sw" => "M23", |
| 651 | + "rsw" => "M24", |
| 652 | + "Sma" => "M26", |
| 653 | + "nDm" => "M29", |
| 654 | + "xt" => "M3", |
| 655 | + "bnr" => "M30", |
| 656 | + "bdt" => "M34", |
| 657 | + "Dr" => "M36", |
| 658 | + "rnp" => "M4", |
| 659 | + "iz" => "M40", |
| 660 | + "tr" => "M6", |
| 661 | + "SA" => "M8", |
| 662 | + "zSn" => "M9", |
| 663 | + "pt" => "N1", |
| 664 | + "Abd" => "N11", |
| 665 | + "iaH" => "N11", |
| 666 | + "dwA" => "N14", |
| 667 | + "sbA" => "N14", |
| 668 | + "dwAt" => "N15", |
| 669 | + "tA" => "N16", |
| 670 | + "iw" => "N18", |
| 671 | + "wDb" => "N20", |
| 672 | + "spAt" => "N24", |
| 673 | + "xAst" => "N25", |
| 674 | + "Dw" => "N26", |
| 675 | + "Axt" => "N27", |
| 676 | + "xa" => "N28", |
| 677 | + "q" => "N29", |
| 678 | + "iAt" => "N30", |
| 679 | + "n" => "N35", |
| 680 | + "mw" => "N35A", |
| 681 | + "S" => "N37", |
| 682 | + "iAdt" => "N4", |
| 683 | + "idt" => "N4", |
| 684 | + "Sm" => "N40", |
| 685 | + "id" => "N41", |
| 686 | + "hrw" => "N5", |
| 687 | + "ra" => "N5", |
| 688 | + "zw" => "N5", |
| 689 | + "Hnmmt" => "N8", |
| 690 | + "pzD" => "N9", |
| 691 | + "pr" => "O1", |
| 692 | + "aH" => "O11", |
| 693 | + "wsxt" => "O15", |
| 694 | + "kAr" => "O18", |
| 695 | + "zH" => "O22", |
| 696 | + "txn" => "O25", |
| 697 | + "iwn" => "O28", |
| 698 | + "aA" => "O29", |
| 699 | + "zxnt" => "O30", |
| 700 | + "z" => "O34", |
| 701 | + "zb" => "O35", |
| 702 | + "inb" => "O36", |
| 703 | + "qnbt" => "O38A", |
| 704 | + "h" => "O4", |
| 705 | + "Szp" => "O42", |
| 706 | + "ipt" => "O45", |
| 707 | + "nxn" => "O47", |
| 708 | + "niwt" => "O49", |
| 709 | + "zp" => "O50", |
| 710 | + "Snwt" => "O51", |
| 711 | + "Hwt" => "O6", |
| 712 | + "wHa" => "P4", |
| 713 | + "TAw" => "P5", |
| 714 | + "nfw" => "P5", |
| 715 | + "aHa" => "P6", |
| 716 | + "xrw" => "P8", |
| 717 | + "st" => "Q1", |
| 718 | + "wz" => "Q2", |
| 719 | + "p" => "Q3", |
| 720 | + "qrsw" => "Q6", |
| 721 | + "xAt" => "R1", |
| 722 | + "xAwt" => "R1", |
| 723 | + "Dd" => "R11", |
| 724 | + "dd" => "R11", |
| 725 | + "imnt" => "R14", |
| 726 | + "iAb" => "R15", |
| 727 | + "wx" => "R16", |
| 728 | + "xm" => "R22", |
| 729 | + "Htp" => "R4", |
| 730 | + "kAp" => "R5", |
| 731 | + "kp" => "R5", |
| 732 | + "snTr" => "R7", |
| 733 | + "nTr" => "R8", |
| 734 | + "nTrw" => "R8A", |
| 735 | + "bd" => "R9", |
| 736 | + "HDt" => "S1", |
| 737 | + "mDH" => "S10", |
| 738 | + "wsx" => "S11", |
| 739 | + "nbw" => "S12", |
| 740 | + "THn" => "S15", |
| 741 | + "tHn" => "S15", |
| 742 | + "mnit" => "S18", |
| 743 | + "sDAw" => "S19", |
| 744 | + "xtm" => "S20", |
| 745 | + "sT" => "S22", |
| 746 | + "dmD" => "S23", |
| 747 | + "Tz" => "S24", |
| 748 | + "Sndyt" => "S26", |
| 749 | + "mnxt" => "S27", |
| 750 | + "s" => "S29", |
| 751 | + "N" => "S3", |
| 752 | + "dSrt" => "S3", |
| 753 | + "sf" => "S30", |
| 754 | + "siA" => "S32", |
| 755 | + "Tb" => "S33", |
| 756 | + "anx" => "S34", |
| 757 | + "Swt" => "S35", |
| 758 | + "xw" => "S37", |
| 759 | + "HqA" => "S38", |
| 760 | + "awt" => "S39", |
| 761 | + "wAs" => "S40", |
| 762 | + "Dam" => "S41", |
| 763 | + "abA" => "S42", |
| 764 | + "sxm" => "S42", |
| 765 | + "xrp" => "S42", |
| 766 | + "md" => "S43", |
| 767 | + "Ams" => "S44", |
| 768 | + "nxxw" => "S45", |
| 769 | + "K" => "S56", |
| 770 | + "sxmty" => "S6", |
| 771 | + "xprS" => "S7", |
| 772 | + "Atf" => "S8", |
| 773 | + "Swty" => "S9", |
| 774 | + "pD" => "T10", |
| 775 | + "sXr" => "T11", |
| 776 | + "zin" => "T11", |
| 777 | + "zwn" => "T11", |
| 778 | + "Ai" => "T12", |
| 779 | + "Ar" => "T12", |
| 780 | + "rwD" => "T12", |
| 781 | + "rwd" => "T12", |
| 782 | + "rs" => "T13", |
| 783 | + "qmA" => "T14", |
| 784 | + "wrrt" => "T17", |
| 785 | + "Sms" => "T18", |
| 786 | + "qs" => "T19", |
| 787 | + "wa" => "T21", |
| 788 | + "sn" => "T22", |
| 789 | + "iH" => "T24", |
| 790 | + "DbA" => "T25", |
| 791 | + "Xr" => "T28", |
| 792 | + "nmt" => "T29", |
| 793 | + "HD" => "T3", |
| 794 | + "sSm" => "T31", |
| 795 | + "nm" => "T34", |
| 796 | + "HDD" => "T6", |
| 797 | + "pd" => "T9", |
| 798 | + "mA" => "U1", |
| 799 | + "it" => "U10", |
| 800 | + "HqAt" => "U11", |
| 801 | + "Sna" => "U13", |
| 802 | + "hb" => "U13", |
| 803 | + "tm" => "U15", |
| 804 | + "biA" => "U16", |
| 805 | + "grg" => "U17", |
| 806 | + "stp" => "U21", |
| 807 | + "mnx" => "U22", |
| 808 | + "Ab" => "U23", |
| 809 | + "Hmt" => "U24", |
| 810 | + "wbA" => "U26", |
| 811 | + "DA" => "U28", |
| 812 | + "rtH" => "U31", |
| 813 | + "zmn" => "U32", |
| 814 | + "ti" => "U33", |
| 815 | + "xsf" => "U34", |
| 816 | + "Hm" => "U36", |
| 817 | + "mxAt" => "U38", |
| 818 | + "mr" => "U6", |
| 819 | + "100" => "V1", |
| 820 | + "arq" => "V12", |
| 821 | + "T" => "V13", |
| 822 | + "iTi" => "V15", |
| 823 | + "TmA" => "V19", |
| 824 | + "XAr" => "V19", |
| 825 | + "mDt" => "V19", |
| 826 | + "sTA" => "V2", |
| 827 | + "10" => "V20", |
| 828 | + "mD" => "V20", |
| 829 | + "mH" => "V22", |
| 830 | + "wD" => "V24", |
| 831 | + "aD" => "V26", |
| 832 | + "H" => "V28", |
| 833 | + "sk" => "V29", |
| 834 | + "wAH" => "V29", |
| 835 | + "sTAw" => "V3", |
| 836 | + "nb" => "V30", |
| 837 | + "k" => "V31", |
| 838 | + "msn" => "V32", |
| 839 | + "sSr" => "V33", |
| 840 | + "idr" => "V37", |
| 841 | + "wA" => "V4", |
| 842 | + "snT" => "V5", |
| 843 | + "sS" => "V6", |
| 844 | + "Sn" => "V7", |
| 845 | + "iab" => "W10", |
| 846 | + "g" => "W11", |
| 847 | + "nzt" => "W11", |
| 848 | + "Hz" => "W14", |
| 849 | + "xnt" => "W17", |
| 850 | + "mi" => "W19", |
| 851 | + "bAs" => "W2", |
| 852 | + "Hnqt" => "W22", |
| 853 | + "nw" => "W24", |
| 854 | + "ini" => "W25", |
| 855 | + "Hb" => "W3", |
| 856 | + "Xnm" => "W9", |
| 857 | + "t" => "X1", |
| 858 | + "di" => "X8", |
| 859 | + "rdi" => "X8", |
| 860 | + "mDAt" => "Y1", |
| 861 | + "mnhd" => "Y3", |
| 862 | + "zS" => "Y3", |
| 863 | + "mn" => "Y5", |
| 864 | + "ibA" => "Y6", |
| 865 | + "zSSt" => "Y8", |
| 866 | + "imi" => "Z11", |
| 867 | + "y" => "Z4", |
| 868 | + "W" => "Z7", |
| 869 | + |
| 870 | + "<1" => "Ca1", // cartouche |
| 871 | + "2>" => "Ca2", |
| 872 | + "<2" => "Ca2a", |
| 873 | + "1>" => "Ca1a", |
| 874 | + "<0" => "Ca1", |
| 875 | + "0>" => "Ca2", |
| 876 | + "<h1" => "Cah1", // horus |
| 877 | + "h1>" => "Cah1a", |
| 878 | + "<h2" => "Cah2", |
| 879 | + "h2>" => "Cah2a", |
| 880 | + "<h3" => "Cah3", |
| 881 | + "h3>" => "Cah3a", |
| 882 | + "<h0" => "Cah1", |
| 883 | + "h0>" => "Cah1a", |
| 884 | + "<" => "Ca1", // cartouche |
| 885 | + ">" => "Ca2", |
| 886 | + "[&" => "Ba16", |
| 887 | + "&]" => "Ba16", |
| 888 | + "[{" => "Ba17", |
| 889 | + "}]" => "Ba17a", |
| 890 | + "[[" => "Ba15", |
| 891 | + "]]" => "Ba15a", |
| 892 | + "[\"" => "", |
| 893 | + "\"]" => "", |
| 894 | + "['" => "", |
| 895 | + "']" => "", |
| 896 | +); |
| 897 | + |
| 898 | +/* not used yet |
| 899 | +$wh_syntax = array( |
| 900 | + "-", //block sepatator |
| 901 | + ":", //supperposition |
| 902 | + "*", //juxtaposition |
| 903 | + "(", //open bracket |
| 904 | + ")", //close bracket |
| 905 | + "!!", //end of text |
| 906 | + "!", //end of line |
| 907 | + "..", //blank caracter |
| 908 | + ".", //half-size blank caracter |
| 909 | + "$", //color |
| 910 | + "#", //shade |
| 911 | + "[&", //select |
| 912 | + "&]", |
| 913 | + "[{", |
| 914 | + "}]", |
| 915 | + "[[", |
| 916 | + "]]", |
| 917 | + "[\"", |
| 918 | + "\"]", |
| 919 | + "['", |
| 920 | + "']", |
| 921 | + "<", //cartouche |
| 922 | + ">", |
| 923 | + "<1", |
| 924 | + "2>", |
| 925 | + "<2", |
| 926 | + "1>", |
| 927 | + "<0", |
| 928 | + "0>", |
| 929 | + "<h1", //horus |
| 930 | + "h1>", |
| 931 | + "<h2", |
| 932 | + "h2>", |
| 933 | + "<h3", |
| 934 | + "h3>", |
| 935 | + "<h0", |
| 936 | + "h0>", |
| 937 | + "++", //comment |
| 938 | + "+s", //hieroglyph |
| 939 | + "+t", //transcription |
| 940 | + "+l", //latin-normal |
| 941 | + "+i", //latin-italic |
| 942 | + "+g", //latin-bold (gras) |
| 943 | + "+b", //latin-bold |
| 944 | + "+c", |
| 945 | +); |
| 946 | +*/ |
| 947 | + |
| 948 | +// convertion table for text mode |
| 949 | +$wh_text_conv = array( |
| 950 | + "-" => " ", |
| 951 | + ":" => "-", |
| 952 | + "*" => "-", |
| 953 | + "!" => "<br />", |
| 954 | + "." => "", |
| 955 | + "=" => "", |
| 956 | + "(" => "", |
| 957 | + ")" => "", |
| 958 | + "<1" => "(", |
| 959 | + "2>" => ")|", |
| 960 | + "<2" => "|(", |
| 961 | + "1>" => ")", |
| 962 | + "<0" => "(", |
| 963 | + "0>" => ")|", |
| 964 | + "<h1" => "[", // horus |
| 965 | + "h1>" => "]", |
| 966 | + "<h2" => "[", |
| 967 | + "h2>" => "]", |
| 968 | + "<h3" => "[", |
| 969 | + "h3>" => "]", |
| 970 | + "<h0" => "[", |
| 971 | + "h0>" => "]", |
| 972 | + "<" => "(", // cartouche |
| 973 | + ">" => ")|", |
| 974 | +); |
| 975 | + |
| 976 | +// ======================================================================== |
| 977 | +// F U N C T I O N S |
| 978 | + |
| 979 | + |
| 980 | +// ======================================================================== |
| 981 | +// |
| 982 | +// W i k i H i e r o |
| 983 | +// |
| 984 | + |
| 985 | +// ------------------------------------------------------------------------ |
| 986 | +// WH_GetCode - Get glyph code from file name |
| 987 | +// ------------------------------------------------------------------------ |
| 988 | +// file << file name |
| 989 | +// return >> string with converted code |
| 990 | +// ------------------------------------------------------------------------ |
| 991 | +function WH_GetCode( $file ) { |
| 992 | + return substr( $file, strlen( WH_IMG_PRE ), -( 1 + strlen( WH_IMG_EXT ) ) ); |
| 993 | +} |
| 994 | + |
| 995 | +// ------------------------------------------------------------------------ |
| 996 | +// WH_Credit - Get glyph code from file name |
| 997 | +// ------------------------------------------------------------------------ |
| 998 | +// return >> credit string |
| 999 | +// ------------------------------------------------------------------------ |
| 1000 | +function WH_Credit() { |
| 1001 | + $html = ""; |
| 1002 | + $html .= "<b>WikiHiero v" . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN . "</b>\n"; |
| 1003 | + $html .= "by Guillaume Blanchard (Aoineko) under GPL (2004).<br />\n"; |
| 1004 | + $html .= "Hieroglyph credit: S. Rosmorduc, G. Watson, J. Hirst (under GFDL).\n"; |
| 1005 | + return $html; |
| 1006 | +} |
Property changes on: trunk/extensions/wikihiero/wikihiero.body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1007 | + native |
Added: svn:keywords |
2 | 1008 | + Author Date Id Revision |