ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
langwiz.php
Go to the documentation of this file.
1<?php
13header('Content-Type: text/html; charset=utf-8');
14
15set_time_limit(0);
16error_reporting(E_ALL);
17$time_start = explode(' ', microtime());
18
19//Handle crappy PHP magic:
20if (get_magic_quotes_gpc()) {
21 function stripslashes_deep($value) {
22 $value = is_array($value) ?
23 array_map('stripslashes_deep', $value) :
24 stripslashes($value);
25
26 return $value;
27 }
28
29 $_POST = array_map('stripslashes_deep', $_POST);
30 $_GET = array_map('stripslashes_deep', $_GET);
31 $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
32 $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
33}
34
35function htmlspecialchars_deep($value) {
36 return is_array($value) ? array_map('htmlspecialchars_deep', $value) : htmlspecialchars($value);
37}
38
39define ('TYPE_NOTICE', 0);
40define ('TYPE_WARNING', 1);
41define ('TYPE_ERROR', 2);
42
44$error_cache = array();
46 global $error_cache;
47
48 if(count($error_cache)) {
49 echo "<span style=\"color: #F00; font-weight: bold;\">Failed</span><br />";
50 echo "<ol>\n";
51 foreach($error_cache as $error_msg) {
52 echo "<li>";
53 switch($error_msg['t']) {
54 case TYPE_NOTICE:
55 echo "<span style=\"color: #080; font-weight: bold;\">NOTICE:</span>";
56 break;
57 case TYPE_WARNING:
58 echo "<span style=\"color: #CC0; font-weight: bold;\">WARNING:</span>";
59 break;
60 case TYPE_ERROR:
61 echo "<span style=\"color: #F00; font-weight: bold;\">ERROR:</span>";
62 break;
63 }
64 echo " " . $error_msg['m'] . "</li>";
65 }
66 echo "</ol>\n";
67 } else {
68 echo "<span style=\"color: #080; font-weight: bold;\">OK</span><br />";
69 }
70 echo "\n";
71
72 $error_cache = array();
73}
74
77
78 $error_cache[] = array('t' => $type, 'm' => $message);
79 if(TYPE_ERROR == $type) {
80 $error_abort = true;
81 }
82}
83
84?>
85<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
86 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
87<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
88<head>
89 <title>GeSHi Language File Generator Script</title>
90 <style type="text/css">
91 <!--
92 html {
93 background-color: #f0f0f0;
94 }
95 body {
96 font-family: Verdana, Arial, sans-serif;
97 margin: 10px;
98 border: 2px solid #e0e0e0;
99 background-color: #fcfcfc;
100 padding: 5px;
101 font-size: 10pt;
102 }
103 h2 {
104 margin: .1em 0 .2em .5em;
105 border-bottom: 1px solid #b0b0b0;
106 color: #b0b0b0;
107 font-weight: normal;
108 font-size: 150%;
109 }
110 h3 {
111 margin: .1em 0 .2em .5em;
112 color: #b0b0b0;
113 font-weight: normal;
114 font-size: 120%;
115 }
116 #footer {
117 text-align: center;
118 font-size: 80%;
119 color: #a9a9a9;
120 }
121 #footer a {
122 color: #9999ff;
123 }
124 textarea {
125 border: 1px solid #b0b0b0;
126 font-size: 90%;
127 color: #333;
128 margin-left: 20px;
129 }
130 select, input {
131 margin-left: 2px;
132 border: 1px solid #808080;
133 }
134 p {
135 font-size: 90%;
136 margin-left: .5em;
137 }
138 fieldset {
139 border: 1px dotted gray;
140 background-color: #f0f0f0;
141 margin-bottom: .5em;
142 }
143 legend {
144 font-weight: bold;
145 background-color: #f9f9f9;
146 border: 1px solid #a0a0a0;
147 border-width: 1px 2px 2px 1px;
148 }
149 fieldset table > tbody > tr > td {
150 width: 20%;
151 }
152 fieldset table > tbody > tr > td+td {
153 width: 80%;
154 }
155
156 fieldset table > tbody > tr > td+td > input {
157 width: 98%;
158 }
159 -->
160 </style>
161</head>
162<body>
163<h2>GeSHi Language File Generator Script</h2>
164<p>To use this script, make sure that <strong>geshi.php</strong> is in the
165parent directory or in your include_path, and that the language files are in a
166subdirectory of GeSHi's directory called <strong>geshi/</strong>.</p>
167<p>If not already done, select a language file below that will be used as
168base for the language file to generate or create a blank one. Following this
169you can do whatever you like to edit your language file. But note that not all
170features are made available through this script.</p>
171
172<p>Checking GeSHi installation ... <?php
173// Rudimentary checking of where GeSHi is. In a default install it will be in ../, but
174// it could be in the current directory if the include_path is set. There's nowhere else
175// we can reasonably guess.
176if (is_readable('../geshi.php')) {
177 $path = '../';
178} elseif (is_readable('geshi.php')) {
179 $path = './';
180} else {
181 report_error(TYPE_ERROR, 'Could not find geshi.php - make sure it is in your include path!');
182}
183
184if(!$error_abort) {
185 require $path . 'geshi.php';
186
187 if(!class_exists('GeSHi')) {
188 report_error(TYPE_ERROR, 'The GeSHi class was not found, although it seemed we loaded the correct file!');
189 }
190}
191
192if(!$error_abort) {
193 if(!defined('GESHI_LANG_ROOT')) {
194 report_error(TYPE_ERROR, 'There\'s no information present on where to find the language files!');
195 } elseif(!is_dir(GESHI_LANG_ROOT)) {
196 report_error(TYPE_ERROR, 'The path "'.GESHI_LANG_ROOT.'" given, does not ressemble a directory!');
197 } elseif(!is_readable(GESHI_LANG_ROOT)) {
198 report_error(TYPE_ERROR, 'The path "'.GESHI_LANG_ROOT.'" is not readable to this script!');
199 }
200}
201
202if(!$error_abort) {
203 if (!($dir = @opendir(GESHI_LANG_ROOT))) {
204 report_error(TYPE_ERROR, 'Error requesting listing for available language files!');
205 }
206
207 $languages = array();
208
209 if(!$error_abort) {
210 while ($file = readdir($dir)) {
211 if (!$file || $file[0] == '.' || strpos($file, '.') === false) {
212 continue;
213 }
214 $lang = substr($file, 0, strpos($file, '.'));
215 $languages[] = $lang;
216 }
217 closedir($dir);
218 }
219
220 $languages = array_unique($languages);
221 sort($languages);
222
223 if(!count($languages)) {
224 report_error(TYPE_WARNING, 'Unable to locate any usable language files in "'.GESHI_LANG_ROOT.'"!');
225 }
226}
227
229
230// --- empty variables for values of $_POST - begin ---
231$post_var_names = array('li', 'ai', 'ld');
232
233$li = array(
234 'file' => 'example',
235 'name' => 'Example'
236 );
237
238$ai = array(
239 'name' => 'Benny Baumann',
240 'email' => 'BenBE@geshi.org',
241 'web' => 'http://qbnz.com/highlighter/'
242 );
243
244$ld = array(
245 'cmt' => array(
246 'sl' => array(
247 1 => array(
248 'start' => '//',
249 'style' => 'font-style: italic; color: #666666;'
250 ),
251 2 => array(
252 'start' => '#',
253 'style' => 'font-style: italic; color: #666666;'
254 )
255 ),
256 'ml' => array(
257 1 => array(
258 'start' => '/*',
259 'end' => '*/',
260 'style' => 'font-style: italic; color: #666666;'
261 ),
262 2 => array(
263 'start' => '',
265 'style' => 'font-style: italic; color: #006600;'
266 )
267 ),
268 'rxc' => array(
269 1 => array(
270 'rx' => '/Hello RegExp/',
271 'style' => 'font-style: italic; color: #666666;'
272 )
273 )
274 ),
275 'str' => array(
276 'qm' => array(
277 1 => array(
278 'delim' => "'",
279 'style' => 'color: #0000FF;'
280 ),
281 2 => array(
282 'delim' => "&quot;",
283 'style' => 'color: #0000FF;'
284 )
285 ),
286 'ec' => array(
287 'char' => '\\',
288 'style' => 'font-weight: bold; color: #000080;'
289 ),
290 'erx' => array(
291 1 => array(
292 'rx' => '/\{\\\\$\w+\}/',
293 'style' => 'font-weight: bold; color: #008080;'
294 ),
295 2 => array(
296 'rx'=> '/\{\\\\$\w+\}/',
297 'style' => 'font-weight: bold; color: #008080;'
298 )
299 )
300 ),
301 'kw_case' => 'GESHI_CAPS_NO_CHANGE',
302 'kw' => array(
303 1 => array(
304 'list' => '',
305 'case' => '0',
306 'style' => 'color: #0000FF; font-weight: bold;',
307 'docs' => ''
308 )
309 ),
310 'sy' => array(
311 0 => array(
312 'list' => '',
313 'style' => 'color: #0000FF; font-weight: bold;'
314 )
315 )
316 );
317
319 'GESHI_CAPS_NO_CHANGE' => '',
320 'GESHI_CAPS_UPPER' => '',
321 'GESHI_CAPS_LOWER' => ''
322 );
323
325 1 => array(
326 0 => '',
327 1 => ''
328 )
329 );
330// --- empty variables for values of $_POST - end ---
331
332echo "<pre>";
333//var_dump($languages);
334
335foreach($post_var_names as $varName) { // export wanted variables of $_POST array...
336 if(array_key_exists($varName, $_POST)) {
337 $$varName = htmlspecialchars_deep($_POST[$varName]);
338 }
339}
340
341// determine the selected kw_case...
342$kw_case_sel[$ld['kw_case']] = ' selected="selected"';
343
344// determine the selected kw_cases...
345for($i = 1; $i <= count($kw_cases_sel); $i += 1) {
346 $kw_cases_sel[$i][(int) $ld['kw'][$i]['case']] = ' selected="selected"';
347}
348
350var_dump($lang);
351echo "</pre>";
352
353?>
354
355<form action="?action=test" method="post">
356 <fieldset>
357 <legend>Generic Information</legend>
358
359 <table width="100%">
360 <tr>
361 <td>
362 <label for="li[file]">Language File ID:</label>
363 </td>
364 <td>
365 <input type="text" name="li[file]" id="li[file]" value="<?=$li['file']; ?>" />
366 </td>
367 </tr>
368
369 <tr>
370 <td>
371 <label for="li[name]">Language Name:</label>
372 </td>
373 <td>
374 <input type="text" name="li[name]" id="li[name]" value="<?=$li['name']; ?>" />
375 </td>
376 </tr>
377
378 </table>
379 </fieldset>
380
381 <fieldset>
382 <legend>Author</legend>
383
384 <table width="100%">
385 <tr>
386 <td>
387 <label for="ai[name]">Full Name:</label>
388 </td>
389 <td>
390 <input type="text" name="ai[name]" id="ai[name]" value="<?=$ai['name']; ?>" />
391 </td>
392 </tr>
393
394 <tr>
395 <td>
396 <label for="ai[email]">eMail address:</label>
397 </td>
398 <td>
399 <input type="text" name="ai[email]" id="ai[email]" value="<?=$ai['email']; ?>" />
400 </td>
401 </tr>
402
403 <tr>
404 <td>
405 <label for="ai[web]">Homepage:</label>
406 </td>
407 <td>
408 <input type="text" name="ai[web]" id="ai[web]" value="<?=$ai['web']; ?>" />
409 </td>
410 </tr>
411 </table>
412 </fieldset>
413
414 <fieldset>
415 <legend>Comments</legend>
416
417 <fieldset>
418 <legend>Single Line</legend>
419
420 <fieldset>
421 <legend>Comment Group 1</legend>
422
423 <table width="100%">
424 <tr>
425 <td>
426 <label for="ld[cmt][sl][1][start]">Comment Start:</label>
427 </td>
428 <td>
429 <input type="text" name="ld[cmt][sl][1][start]" id="ld[cmt][sl][1][start]" value="<?=$ld['cmt']['sl'][1]['start']; ?>" />
430 </td>
431 </tr>
432
433 <tr>
434 <td>
435 <label for="ld[cmt][sl][1][style]">Comment Style:</label>
436 </td>
437 <td>
438 <input type="text" name="ld[cmt][sl][1][style]" id="ld[cmt][sl][1][style]" value="<?=$ld['cmt']['sl'][1]['style']; ?>" />
439 </td>
440 </tr>
441 </table>
442 </fieldset>
443
444 <fieldset>
445 <legend>Comment Group 2</legend>
446
447 <table width="100%">
448 <tr>
449 <td>
450 <label for="ld[cmt][sl][2][start]">Comment Start:</label>
451 </td>
452 <td>
453 <input type="text" name="ld[cmt][sl][2][start]" id="ld[cmt][sl][2][start]" value="<?=$ld['cmt']['sl'][2]['start']; ?>" />
454 </td>
455 </tr>
456
457 <tr>
458 <td>
459 <label for="ld[cmt][sl][2][style]">Comment Style:</label>
460 </td>
461 <td>
462 <input type="text" name="ld[cmt][sl][2][style]" id="ld[cmt][sl][2][style]" value="<?=$ld['cmt']['sl'][2]['style']; ?>" />
463 </td>
464 </tr>
465 </table>
466 </fieldset>
467 </fieldset>
468
469 <fieldset>
470 <legend>Multiple Lines</legend>
471
472 <fieldset>
473 <legend>Comment Group 1</legend>
474
475 <table width="100%">
476 <tr>
477 <td>
478 <label for="ld[cmt][ml][1][start]">Comment Start:</label>
479 </td>
480 <td>
481 <input type="text" name="ld[cmt][ml][1][start]" id="ld[cmt][ml][1][start]" value="<?=$ld['cmt']['ml'][1]['start']; ?>" />
482 </td>
483 </tr>
484
485 <tr>
486 <td>
487 <label for="ld[cmt][ml][1][end]">Comment End:</label>
488 </td>
489 <td>
490 <input type="text" name="ld[cmt][ml][1][end]" id="ld[cmt][ml][1][end]" value="<?=$ld['cmt']['ml'][1]['end']; ?>" />
491 </td>
492 </tr>
493
494 <tr>
495 <td>
496 <label for="ld[cmt][ml][1][style]">Comment Style:</label>
497 </td>
498 <td>
499 <input type="text" name="ld[cmt][ml][1][style]" id="ld[cmt][ml][1][style]" value="<?=$ld['cmt']['ml'][1]['style']; ?>" />
500 </td>
501 </tr>
502 </table>
503 </fieldset>
504
505 <fieldset>
506 <legend>Comment Group 2</legend>
507
508 <table width="100%">
509 <tr>
510 <td>
511 <label for="ld[cmt][ml][2][start]">Comment Start:</label>
512 </td>
513 <td>
514 <input type="text" name="ld[cmt][ml][2][start]" id="ld[cmt][ml][2][start]" value="<?=$ld['cmt']['ml'][2]['start']; ?>" />
515 </td>
516 </tr>
517
518 <tr>
519 <td>
520 <label for="ld[cmt][ml][2][end]">Comment End:</label>
521 </td>
522 <td>
523 <input type="text" name="ld[cmt][ml][2][end]" id="ld[cmt][ml][2][end]" value="<?=$ld['cmt']['ml'][2]['end']; ?>" />
524 </td>
525 </tr>
526
527 <tr>
528 <td>
529 <label for="ld[cmt][ml][2][style]">Comment Style:</label>
530 </td>
531 <td>
532 <input type="text" name="ld[cmt][ml][2][style]" id="ld[cmt][ml][2][style]" value="<?=$ld['cmt']['ml'][2]['style']; ?>" />
533 </td>
534 </tr>
535 </table>
536 </fieldset>
537 </fieldset>
538
539 <fieldset>
540 <legend>Regular Expressions</legend>
541
542 <fieldset>
543 <legend>Comment Group 1</legend>
544
545 <table width="100%">
546 <tr>
547 <td>
548 <label for="ld[cmt][rxc][1][rx]">Comment RX:</label>
549 </td>
550 <td>
551 <input type="text" name="ld[cmt][rxc][1][rx]" id="ld[cmt][rxc][1][rx]" value="<?=$ld['cmt']['rxc'][1]['rx']; ?>" />
552 </td>
553 </tr>
554
555 <tr>
556 <td>
557 <label for="ld[cmt][rxc][1][style]">Comment Style:</label>
558 </td>
559 <td>
560 <input type="text" name="ld[cmt][rxc][1][style]" id="ld[cmt][rxc][1][style]" value="<?=$ld['cmt']['rxc'][1]['style']; ?>" />
561 </td>
562 </tr>
563 </table>
564 </fieldset>
565 </fieldset>
566 </fieldset>
567
568 <fieldset>
569 <legend>Strings</legend>
570
571 <fieldset>
572 <legend>String \ Quotes (delimiters, parsed)</legend>
573
574 <fieldset>
575 <legend>Quotemark Group 1</legend>
576
577 <table width="100%">
578 <tr>
579 <td>
580 <label for="ld[str][qm][1][delim]">String Delimiter:</label>
581 </td>
582 <td>
583 <input type="text" name="ld[str][qm][1][delim]" id="ld[str][qm][1][delim]" value="<?=$ld['str']['qm'][1]['delim']; ?>" />
584 </td>
585 </tr>
586
587 <tr>
588 <td>
589 <label for="ld[str][qm][1][style]">String Style:</label>
590 </td>
591 <td>
592 <input type="text" name="ld[str][qm][1][style]" id="ld[str][qm][1][style]" value="<?=$ld['str']['qm'][1]['style']; ?>" />
593 </td>
594 </tr>
595 </table>
596 </fieldset>
597 <fieldset>
598 <legend>Quotemark Group 2</legend>
599
600 <table width="100%">
601 <tr>
602 <td>
603 <label for="ld[str][qm][1][delim]">String Delimiter:</label>
604 </td>
605 <td>
606 <input type="text" name="ld[str][qm][2][delim]" id="ld[str][qm][2][delim]" value="<?=$ld['str']['qm'][2]['delim']; ?>" />
607 </td>
608 </tr>
609
610 <tr>
611 <td>
612 <label for="ld[str][qm][1][style]">String Style:</label>
613 </td>
614 <td>
615 <input type="text" name="ld[str][qm][2][style]" id="ld[str][qm][2][style]" value="<?=$ld['str']['qm'][2]['style']; ?>" />
616 </td>
617 </tr>
618 </table>
619 </fieldset>
620
621
622 </fieldset>
623
624 <fieldset>
625 <legend>Escape Sequences</legend>
626
627 <fieldset>
628 <legend>Generic Escape Char</legend>
629
630 <table width="100%">
631 <tr>
632 <td>
633 <label for="ld[str][ec][char]">Escape Char:</label>
634 </td>
635 <td>
636 <input type="text" name="ld[str][ec][char]" id="ld[str][ec][char]" value="<?=$ld['str']['ec']['char']; ?>" />
637 </td>
638 </tr>
639
640 <tr>
641 <td>
642 <label for="ld[str][ec][style]">Escape Char Style:</label>
643 </td>
644 <td>
645 <input type="text" name="ld[str][ec][style]" id="ld[str][ec][style]" value="<?=$ld['str']['ec']['style']; ?>" />
646 </td>
647 </tr>
648 </table>
649 </fieldset>
650
651 <fieldset>
652 <legend>Escape Regexp Group 1</legend>
653
654 <table width="100%">
655 <tr>
656 <td>
657 <label for="ld[str][erx][1][rx]">Escape Regexp:</label>
658 </td>
659 <td>
660 <input type="text" name="ld[str][erx][1][rx]" id="ld[str][erx][1][rx]" value="<?=$ld['str']['erx'][1]['rx']; ?>" />
661 </td>
662 </tr>
663
664 <tr>
665 <td>
666 <label for="ld[str][erx][1][style]">Escape Style:</label>
667 </td>
668 <td>
669 <input type="text" name="ld[str][erx][1][style]" id="ld[str][erx][1][style]" value="<?=$ld['str']['erx'][1]['style']; ?>" />
670 </td>
671 </tr>
672 </table>
673 </fieldset>
674
675 <fieldset>
676 <legend>Escape Regexp Group 2</legend>
677
678 <table width="100%">
679 <tr>
680 <td>
681 <label for="ld[str][erx][2][rx]">Escape Regexp:</label>
682 </td>
683 <td>
684 <input type="text" name="ld[str][erx][2][rx]" id="ld[str][erx][2][rx]" value="<?=$ld['str']['erx'][2]['rx']; ?>" />
685 </td>
686 </tr>
687
688 <tr>
689 <td>
690 <label for="ld[str][erx][2][style]">Escape Style:</label>
691 </td>
692 <td>
693 <input type="text" name="ld[str][erx][2][style]" id="ld[str][erx][2][style]" value="<?=$ld['str']['erx'][2]['style']; ?>" />
694 </td>
695 </tr>
696 </table>
697 </fieldset>
698 </fieldset>
699 </fieldset>
700
701 <fieldset>
702 <legend>Keywords</legend>
703
704 <fieldset>
705 <legend>Case of Keywords</legend>
706
707 <table width="100%">
708 <tr>
709 <td>
710 <label for="ld[kw_case]">Handling of keywords case:</label>
711 </td>
712 <td>
713 <select name=ld[kw_case]" id="ld[kw_case]">
714 <option value="GESHI_CAPS_NO_CHANGE"<?=$kw_case_sel['GESHI_CAPS_NO_CHANGE']; ?>>Don’t change the case of any keyword</option>
715 <option value="GESHI_CAPS_UPPER"<?=$kw_case_sel['GESHI_CAPS_UPPER']; ?>>Convert the case of all keywords to upper case</option>
716 <option value="GESHI_CAPS_LOWER"<?=$kw_case_sel['GESHI_CAPS_LOWER']; ?>>Convert the case of all keywords to lower case</option>
717 </select>
718 </td>
719 </tr>
720 </table>
721 </fieldset>
722
723 <fieldset>
724 <legend>Keyword Group 1</legend>
725
726 <table width="100%">
727 <tr>
728 <td>
729 <label for="ld[kw][1][list]">Keyword List:</label>
730 </td>
731 <td>
732 <textarea name="ld[kw][1][list]" id="ld[kw][1][list]" rows="10" cols="80"><?=$ld['kw'][1]['list']; ?></textarea>
733 </td>
734 </tr>
735
736 <tr>
737 <td>
738 <label for="ld[kw][1][case]">Case Sensitive:</label>
739 </td>
740 <td>
741 <select name="ld[kw][1][case]" id="ld[kw][1][case]">
742 <option value="0"<?=$kw_cases_sel[1][0]; ?>>No</option>
743 <option value="1"<?=$kw_cases_sel[1][1]; ?>>Yes</option>
744 </select>
745 </td>
746 </tr>
747
748 <tr>
749 <td>
750 <label for="ld[kw][1][style]">Keyword Style:</label>
751 </td>
752 <td>
753 <input type="text" name="ld[kw][1][style]" id="ld[kw][1][style]" value="<?=$ld['kw'][1]['style']; ?>" />
754 </td>
755 </tr>
756
757 <tr>
758 <td>
759 <label for="ld[kw][1][docs]">Documentation URL:</label>
760 </td>
761 <td>
762 <input type="text" name="ld[kw][1][docs]" id="ld[kw][1][docs]" value="<?=$ld['kw'][1]['docs']; ?>" />
763 </td>
764 </tr>
765 </table>
766 </fieldset>
767
768 </fieldset>
769
770
771 <fieldset>
772 <legend>Symbols</legend>
773
774 <fieldset>
775 <legend>Symbols Group 1</legend>
776
777 <table width="100%">
778 <tr>
779 <td>
780 <label for="ld[sy][0][list]">Symbols List:</label>
781 </td>
782 <td>
783 <textarea name="ld[sy][0][list]" id="ld[sy][0][list]" rows="10" cols="80"><?=$ld['sy'][0]['list']; ?></textarea>
784 </td>
785 </tr>
786
787 <tr>
788 <td>
789 <label for="ld[sy][0][style]">Symbols Style:</label>
790 </td>
791 <td>
792 <input type="text" name="ld[sy][0][style]" id="ld[sy][0][style]" value="<?=$ld['sy'][0]['style']; ?>" />
793 </td>
794 </tr>
795 </table>
796 </fieldset>
797
798 </fieldset>
799
800
801 <div id="langfile">
802 <fieldset>
803 <legend>Language File Source</legend>
804<?php
805$G = new GeSHi('', 'php');
806$langfile_source = gen_langfile($lang);
807$G->set_source($langfile_source);
808echo $G->parse_code();
809unset($G);
810?>
811 </fieldset>
812 </div>
813
814 <input type="submit" name="btn" value="Send!" />
815</form>
816
817<p>Operation completed in <?php
818$time_end = explode(' ', microtime());
819$time_diff = $time_end[0] + $time_end[1] - $time_start[0] - $time_start[1];
820
821echo sprintf("%.2f", $time_diff);
822?> seconds.</p>
823
824<div id="footer">GeSHi &copy; 2004-2007 Nigel McNie, 2007-2009 Benny Baumann, released under the GNU GPL</div>
825</body>
826</html>
827<?php
828
829function str_to_phpstring($str, $doublequote = false){
830 if($doublequote) {
831 return '"' . strtr($str,
832 array(
833 "\"" => "\\\"",
834 "\\" => "\\\\",
835 "\0" => "\\0",
836 "\n" => "\\n",
837 "\r" => "\\r",
838 "\t" => "\\t",
839 "\$" => "\\\$"
840 )
841 ) . '"';
842 } else {
843 return "'" . strtr($str,
844 array(
845 "'" => "\\'",
846 "\\" => "\\\\"
847 )
848 ) . "'";
849 }
850}
851
852function validate_lang(){
853 $ai = array(
854 'name' => 'Benny Baumann',
855 'email' => 'BenBE@geshi.org',
856 'web' => 'http://qbnz.com/highlighter/'
857 );
858
859 $li = array(
860 'file' => 'example',
861 'desc' => 'Example'
862 );
863
864 if(isset($_POST['ld'])) {
865 $ld = $_POST['ld'];
866 } else {
867 $ld = array(
868 'cmt' => array(
869 'sl' => array(
870 1 => array(
871 'start' => '//',
872 'style' => 'test'
873 )
874 ),
875 'ml' => array(
876 1 => array(
877 'start' => '/*',
878 'end' => '*/',
879 'style' => 'font-style: italic; color: #666666;'
880 )
881 ),
882 'rxc' => array(
883 1 => array(
884 'rx' => '/Hello/',
885 'style' => 'color: #00000'
886 )
887 )
888 ),
889 'str' => array(
890 'qm' => array(),
891 'ec' => array(
892 'char' => ''
893 ),
894 'erx' => array()
895 ),
896 'kw' => array(),
897 'kw_case' => 'GESHI_CAPS_NO_CHANGE',
898 'sy' => array()
899 );
900 }
901
902 return array('ai' => $ai, 'li' => $li, 'ld' => $ld);
903}
904
905function gen_langfile($lang){
906 $langfile = $lang['li']['file'];
907 $langdesc = $lang['li']['desc'];
908
909 $langauthor_name = $lang['ai']['name'];
910 $langauthor_email = $lang['ai']['email'];
911 $langauthor_web = $lang['ai']['web'];
912
913 $langversion = GESHI_VERSION;
914
915 $langdate = date('Y/m/d');
916 $langyear = date('Y');
917
918 $i = ' ';
919 $i = array('', $i, $i.$i, $i.$i.$i);
920
921 $src = <<<GESHI_LANGFILE_HEAD
922<?php
923/*************************************************************************************
924 * {$langfile}.php
925 * --------
926 * Author: {$langauthor_name} ({$langauthor_email})
927 * Copyright: (c) {$langyear} {$langauthor_name} ({$langauthor_web})
928 * Release Version: {$langversion}
929 * Date Started: {$langdate}
930 *
931 * {$langdesc} language file for GeSHi.
932 *
933 * CHANGES
934 * -------
935 * {$langdate} ({$langversion})
936 * - First Release
937 *
938 * TODO (updated {$langdate})
939 * -------------------------
940 * * Complete language file
941 *
942 *************************************************************************************
943 *
944 * This file is part of GeSHi.
945 *
946 * GeSHi is free software; you can redistribute it and/or modify
947 * it under the terms of the GNU General Public License as published by
948 * the Free Software Foundation; either version 2 of the License, or
949 * (at your option) any later version.
950 *
951 * GeSHi is distributed in the hope that it will be useful,
952 * but WITHOUT ANY WARRANTY; without even the implied warranty of
953 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
954 * GNU General Public License for more details.
955 *
956 * You should have received a copy of the GNU General Public License
957 * along with GeSHi; if not, write to the Free Software
958 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
959 *
960 ************************************************************************************/
961
962\$language_data = array(
963
964GESHI_LANGFILE_HEAD;
965
966 //Language Name
967 $src .= $i[1] . "'LANG_NAME' => ".str_to_phpstring($langdesc).",\n";
968
969 //Comments
970 $src .= $i[1] . "'COMMENT_SINGLE' => array(\n";
971 foreach($lang['ld']['cmt']['sl'] as $idx_cmt_sl => $tmp_cmt_sl) {
972 $src .= $i[2] . ((int)$idx_cmt_sl). " => ". str_to_phpstring($tmp_cmt_sl['start']) . ",\n";
973 }
974 $src .= $i[2] . "),\n";
975 $src .= $i[1] . "'COMMENT_MULTI' => array(\n";
976 foreach($lang['ld']['cmt']['ml'] as $tmp_cmt_ml) {
977 $src .= $i[2] . str_to_phpstring($tmp_cmt_ml['start']). " => ". str_to_phpstring($tmp_cmt_ml['end']) . ",\n";
978 }
979 $src .= $i[2] . "),\n";
980 $src .= $i[1] . "'COMMENT_REGEXP' => array(\n";
981 foreach($lang['ld']['cmt']['rxc'] as $idx_cmt_rxc => $tmp_cmt_rxc) {
982 $src .= $i[2] . ((int)$idx_cmt_rxc). " => ". str_to_phpstring($tmp_cmt_rxc['rx']) . ",\n";
983 }
984 $src .= $i[2] . "),\n";
985
986 //Case Keywords
987 $src .= $i[1] . "'CASE_KEYWORDS' => " . $lang['ld']['kw_case'] . ",\n";
988
989 //Quotes \ Strings
990 $src .= $i[1] . "'QUOTEMARKS' => array(\n";
991 foreach($lang['ld']['str']['qm'] as $idx_str_qm => $tmp_str_qm) {
992 $src .= $i[2] . ((int)$idx_str_qm). " => ". str_to_phpstring($tmp_str_qm['delim']) . ",\n";
993 }
994 $src .= $i[2] . "),\n";
995 $src .= $i[1] . "'ESCAPE_CHAR' => " . str_to_phpstring($lang['ld']['str']['ec']['char']) . ",\n";
996 $src .= $i[1] . "'ESCAPE_REGEXP' => array(\n";
997 foreach($lang['ld']['str']['erx'] as $idx_str_erx => $tmp_str_erx) {
998 $src .= $i[2] . ((int)$idx_str_erx). " => ". str_to_phpstring($tmp_str_erx['rx']) . ",\n";
999 }
1000 $src .= $i[2] . "),\n";
1001
1002 //HardQuotes
1003 $src .= $i[1] . "'HARDQUOTE' => array(\n";
1004 $src .= $i[2] . "),\n";
1005 $src .= $i[1] . "'HARDESCAPE' => array(\n";
1006 $src .= $i[2] . "),\n";
1007 $src .= $i[1] . "'HARDCHAR' => '',\n";
1008
1009 //Numbers
1010 $src .= $i[1] . "'NUMBERS' =>\n";
1012 $src .= $i[2] . "GESHI_NUMBER_FLT_SCI_ZERO,\n";
1013
1014 //Keywords
1015 $src .= $i[1] . "'KEYWRODS' => array(\n";
1016 foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) {
1017 $src .= $i[2] . ((int)$idx_kw) . " => array(\n";
1018 if(!is_array($tmp_kw['list'])) {
1019 $tmp_kw['list'] = explode("\n", $tmp_kw['list']);
1020 }
1021 $tmp_kw['list'] = array_map('trim', $tmp_kw['list']);
1022 sort($tmp_kw['list']);
1023 $kw_esc = array_map('str_to_phpstring', $tmp_kw['list']);
1024 $kw_nl = true;
1025 $kw_pos = 0;
1026 foreach($kw_esc as $kw_data) {
1027 if((strlen($kw_data) + $kw_pos > 79) && $kw_pos > strlen($i[3])) {
1028 $src .= "\n";
1029 $kw_nl = true;
1030 $kw_pos = 0;
1031 }
1032 if($kw_nl) {
1033 $src .= $i[3];
1034 $kw_pos += strlen($i[3]);
1035 $kw_nl = false;
1036 }
1037 $src .= $kw_data . ', ';
1038 $kw_pos += strlen($kw_data) + 2;
1039 }
1040 $src .= "\n";
1041 $src .= $i[3] . "),\n";
1042 }
1043 $src .= $i[2] . "),\n";
1044
1045 //Case Sensitivity
1046 $src .= $i[1] . "'CASE_SENSITIVE' => array(\n";
1047 foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) {
1048 $src .= $i[2] . ((int)$idx_kw) . " => " . ($tmp_kw['case'] ? 'true' : 'false') . ",\n";
1049 }
1050 $src .= $i[2] . "),\n";
1051
1052 //Symbols
1053 $src .= $i[1] . "'SYMBOLS' => array(\n";
1054 foreach($lang['ld']['sy'] as $idx_kw => $tmp_kw) {
1055 $src .= $i[2] . ((int)$idx_kw) . " => array(\n";
1056 $tmp_kw['list'] = (array)$tmp_kw['list'];
1057 sort($tmp_kw['list']);
1058 $kw_esc = array_map('str_to_phpstring', $tmp_kw['list']);
1059 $kw_nl = true;
1060 $kw_pos = strlen($i[3]);
1061 foreach($kw_esc as $kw_data) {
1062 if((strlen($kw_data) + $kw_pos > 79) && $kw_pos > strlen($i[3])) {
1063 $src .= "\n";
1064 $kw_nl = true;
1065 $kw_pos = 0;
1066 }
1067 if($kw_nl) {
1068 $src .= $i[3];
1069 $kw_pos += strlen($i[3]);
1070 $kw_nl = false;
1071 }
1072 $src .= $kw_data . ', ';
1073 $kw_pos += strlen($kw_data) + 2;
1074 }
1075 $src .= "\n";
1076 $src .= $i[3] . "),\n";
1077 }
1078 $src .= $i[2] . "),\n";
1079
1080 //Styles \ CSS
1081 $src .= $i[1] . "'STYLES' => array(\n";
1082 $src .= $i[2] . "'KEYWRODS' => array(\n";
1083 foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) {
1084 $src .= $i[3] . ((int)$idx_kw) . " => " . str_to_phpstring($tmp_kw['style']) . ",\n";
1085 }
1086 $src .= $i[3] . "),\n";
1087 $src .= $i[2] . "'COMMENTS' => array(\n";
1088 foreach($lang['ld']['cmt']['sl'] as $idx_cmt_sl => $tmp_cmt_sl) {
1089 $src .= $i[3] . ((int)$idx_cmt_sl) . " => " . str_to_phpstring($tmp_cmt_sl['style']) . ",\n";
1090 }
1091 foreach($lang['ld']['cmt']['rxc'] as $idx_cmt_rxc => $tmp_cmt_rxc) {
1092 $src .= $i[3] . ((int)$idx_cmt_rxc) . " => " . str_to_phpstring($tmp_cmt_rxc['style']) . ",\n";
1093 }
1094 $src .= $i[3] . "'MULTI' => " . str_to_phpstring($lang['ld']['cmt']['ml'][1]['style']) . "\n";
1095 $src .= $i[3] . "),\n";
1096 $src .= $i[2] . "'ESCAPE_CHAR' => array(\n";
1097 foreach($lang['ld']['str']['erx'] as $idx_str_erx => $tmp_str_erx) {
1098 $src .= $i[3] . ((int)$idx_str_erx). " => ". str_to_phpstring($tmp_str_erx['style']) . ",\n";
1099 }
1100 // 'HARD' => 'color: #000099; font-weight: bold;'
1101 $src .= $i[3] . "),\n";
1102 $src .= $i[2] . "'BRACKETS' => array(\n";
1103 $src .= $i[3] . "),\n";
1104 $src .= $i[2] . "'STRINGS' => array(\n";
1105 foreach($lang['ld']['str']['qm'] as $idx_str_qm => $tmp_str_qm) {
1106 $src .= $i[3] . ((int)$idx_str_qm). " => ". str_to_phpstring($tmp_str_qm['style']) . ",\n";
1107 }
1108 // 'HARD' => 'color: #0000ff;'
1109 $src .= $i[3] . "),\n";
1110 $src .= $i[2] . "'NUMBERS' => array(\n";
1111 $src .= $i[3] . "),\n";
1112 $src .= $i[2] . "'METHODS' => array(\n";
1113 $src .= $i[3] . "),\n";
1114 $src .= $i[2] . "'SYMBOLS' => array(\n";
1115 foreach($lang['ld']['sy'] as $idx_kw => $tmp_kw) {
1116 $src .= $i[3] . ((int)$idx_kw) . " => " . str_to_phpstring($tmp_kw['style']) . ",\n";
1117 }
1118 $src .= $i[3] . "),\n";
1119 $src .= $i[2] . "'REGEXPS' => array(\n";
1120 $src .= $i[3] . "),\n";
1121 $src .= $i[2] . "'SCRIPT' => array(\n";
1122 $src .= $i[3] . "),\n";
1123 $src .= $i[2] . "),\n";
1124
1125 //Keyword Documentation
1126 $src .= $i[1] . "'URLS' => array(\n";
1127 foreach($lang['ld']['kw'] as $idx_kw => $tmp_kw) {
1128 $src .= $i[2] . ((int)$idx_kw) . " => " . str_to_phpstring($tmp_kw['docs']) . ",\n";
1129 }
1130 $src .= $i[2] . "),\n";
1131 $src .= $i[1] . "'OOLANG' => false,\n";
1132 $src .= $i[1] . "'OBJECT_SPLITTERS' => array(\n";
1133 $src .= $i[2] . "),\n";
1134 $src .= $i[1] . "'REGEXPS' => array(\n";
1135 $src .= $i[2] . "),\n";
1136 $src .= $i[1] . "'STRICT_MODE_APPLIES' => GESHI_MAYBE,\n";
1137 $src .= $i[1] . "'SCRIPT_DELIMITERS' => array(\n";
1138 $src .= $i[2] . "),\n";
1139 $src .= $i[1] . "'HIGHLIGHT_STRICT_BLOCK' => array(\n";
1140 $src .= $i[2] . "),\n";
1141 $src .= $i[1] . "'TAB_WIDTH' => 4\n";
1142
1143 $src .= <<<GESHI_LANGFILE_FOOTER
1144);
1145GESHI_LANGFILE_FOOTER;
1146
1147 //Reduce source ...
1148 $src = preg_replace('/array\‍(\s*\‍)/s', 'array()', $src);
1149 $src = preg_replace('/\,(\s*\‍))/s', '\1', $src);
1150 $src = preg_replace('/\s+$/m', '', $src);
1151
1152 return $src;
1153}
html()
$_COOKIE['client_id']
Definition: server.php:9
$path
Definition: aliased.php:25
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Definition: geshi.php:226
$languages
Definition: cssgen2.php:34
$i
Definition: disco.tpl.php:19
const GESHI_NUMBER_INT_BASIC
Basic number format for integers.
Definition: geshi.php:165
const GESHI_MAYBE
Strict mode might apply, and can be enabled or disabled by GeSHi->enable_strict_mode().
Definition: geshi.php:126
const GESHI_CAPS_NO_CHANGE
Lowercase keywords found.
Definition: geshi.php:94
const GESHI_NUMBER_OCT_PREFIX
Number format to highlight octal numbers with a leading zero.
Definition: geshi.php:175
const GESHI_LANG_ROOT(!defined('GESHI_ROOT'))
The language file directory for GeSHi @access private.
Definition: geshi.php:52
const GESHI_NUMBER_HEX_PREFIX
Number format to highlight hex numbers with a prefix 0x.
Definition: geshi.php:183
const GESHI_NUMBER_FLT_SCI_ZERO
Number format to highlight floating-point numbers with support for scientific notation (E) and requir...
Definition: geshi.php:195
const GESHI_CAPS_LOWER
Leave keywords found as the case that they are.
Definition: geshi.php:98
const GESHI_CAPS_UPPER
Uppercase keywords found.
Definition: geshi.php:96
margin left
Definition: langcheck.php:164
if(PHP_SAPI !='cli') color
Definition: langcheck.php:120
input
Definition: langcheck.php:166
textarea
Definition: langcheck.php:160
select
Definition: langcheck.php:166
font size
Definition: langcheck.php:162
$ai
Definition: langwiz.php:238
const TYPE_ERROR
Definition: langwiz.php:41
output_error_cache()
Definition: langwiz.php:45
$time_start
Definition: langwiz.php:17
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$post_var_names
Definition: langwiz.php:231
$kw_case_sel
Definition: langwiz.php:318
$kw_cases_sel
Definition: langwiz.php:324
validate_lang()
Definition: langwiz.php:852
if(get_magic_quotes_gpc()) htmlspecialchars_deep($value)
Definition: langwiz.php:35
$ld
Definition: langwiz.php:244
$li
Definition: langwiz.php:233
$error_cache
Definition: langwiz.php:44
$error_abort
Definition: langwiz.php:43
const TYPE_WARNING
Definition: langwiz.php:40
report_error($type, $message)
Definition: langwiz.php:75
const TYPE_NOTICE
Definition: langwiz.php:39
catch(Exception $e) $message
A simple script which outputs the CSS classes for all languages supported by GeSHi.
$type