[195] | 1 | <?php
|
---|
[894] | 2 |
|
---|
[195] | 3 | $depth = array();
|
---|
| 4 | //$xml_buffer = array();
|
---|
| 5 |
|
---|
[815] | 6 | function startElement($parser, $name, $attrs)
|
---|
[195] | 7 | {
|
---|
[302] | 8 | global $depth, $xml_buffer;
|
---|
[815] | 9 |
|
---|
| 10 | for ($i = 0; $i < $depth[$parser]; $i++)
|
---|
[302] | 11 | {
|
---|
| 12 | echo " ";
|
---|
| 13 | }
|
---|
[195] | 14 | // echo "<BR />$name\n";
|
---|
| 15 | // print_r( $attrs);
|
---|
| 16 | // generování proměných
|
---|
[815] | 17 |
|
---|
[195] | 18 | $xml_buffer[count($xml_buffer)+1] = array($depth[$parser],$attrs);
|
---|
| 19 | // print_r($xml_buffer);
|
---|
| 20 | $depth[$parser]++;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
[815] | 23 | function endElement($parser, $name)
|
---|
[195] | 24 | {
|
---|
[302] | 25 | global $depth;
|
---|
[815] | 26 |
|
---|
[302] | 27 | $depth[$parser]--;
|
---|
[195] | 28 | }
|
---|
[565] | 29 | //TODO: Use '.$Config['Web']['GameVersion'].'
|
---|
[314] | 30 | $verze = '../source/3.3.0/FrameXML';
|
---|
[195] | 31 |
|
---|
| 32 | $files = scandir($verze);
|
---|
[880] | 33 | foreach ($files as $file)
|
---|
[302] | 34 | {
|
---|
| 35 | $end = substr($file, strlen($file) - 3);
|
---|
[880] | 36 | if ($end == 'xml')
|
---|
[302] | 37 | {
|
---|
| 38 | echo('<br />--'.$file.'<br /><br />');
|
---|
[815] | 39 | $file = $verze.'/'.$file;
|
---|
[302] | 40 | $xml_buffer = array(); //mazání
|
---|
[815] | 41 |
|
---|
[302] | 42 | $xml_parser = xml_parser_create();
|
---|
| 43 | xml_set_element_handler($xml_parser, 'startElement', 'endElement');
|
---|
[815] | 44 | if (!($fp = fopen($file, 'r')))
|
---|
[302] | 45 | {
|
---|
| 46 | die('could not open XML input');
|
---|
| 47 | }
|
---|
[195] | 48 |
|
---|
[815] | 49 | while ($data = fread($fp, 4096))
|
---|
[302] | 50 | {
|
---|
[815] | 51 | if (!xml_parse($xml_parser, $data, feof($fp)))
|
---|
[302] | 52 | {
|
---|
| 53 | die(sprintf("XML error: %s at line %d",
|
---|
[195] | 54 | xml_error_string(xml_get_error_code($xml_parser)),
|
---|
| 55 | xml_get_current_line_number($xml_parser)));
|
---|
[302] | 56 | }
|
---|
| 57 | }
|
---|
| 58 | xml_parser_free($xml_parser);
|
---|
[815] | 59 |
|
---|
| 60 | for ($i = 0; $i < count($xml_buffer); $i++)
|
---|
[302] | 61 | {
|
---|
| 62 | $line = $xml_buffer[$i];
|
---|
[815] | 63 | if (isset($line[1]['TEXT']))
|
---|
[302] | 64 | {
|
---|
| 65 | $name = $line[1]['NAME'];
|
---|
[195] | 66 |
|
---|
[815] | 67 | if ($name == '')
|
---|
[302] | 68 | { //u FontString
|
---|
| 69 | $j = 1;
|
---|
[815] | 70 | while (substr($name,0,1) == '')
|
---|
[302] | 71 | {
|
---|
[815] | 72 | if (isset($xml_buffer[$i-$j][1]['NAME']))
|
---|
[302] | 73 | {
|
---|
[815] | 74 | $name = $xml_buffer[$i-$j][1]['NAME'].$name;
|
---|
[302] | 75 | }
|
---|
[815] | 76 | $j++;
|
---|
[302] | 77 | }
|
---|
| 78 | }
|
---|
[195] | 79 |
|
---|
[815] | 80 | if (substr($name,0,1) == '$')
|
---|
[302] | 81 | { //zjišťování potomků
|
---|
| 82 | $j = 1;
|
---|
[815] | 83 | while (substr($name,0,1) == '$')
|
---|
[302] | 84 | {
|
---|
[815] | 85 | if (($xml_buffer[$i-$j][0] < $line[0]) and (isset($xml_buffer[$i-$j][1]['NAME'])))
|
---|
[302] | 86 | {
|
---|
| 87 | $name = substr($name,strlen('$parent'));
|
---|
[815] | 88 | $name = $xml_buffer[$i-$j][1]['NAME'].$name;
|
---|
[302] | 89 | }
|
---|
[815] | 90 | $j++;
|
---|
[302] | 91 | }
|
---|
| 92 | }
|
---|
| 93 | if ((' - ' <> $line[1]['TEXT']) and ('' <> $line[1]['TEXT']))
|
---|
| 94 | echo $name.':SetText(i["'.$line[1]['TEXT'].'"]);<br />';
|
---|
| 95 | }
|
---|
[195] | 96 | }
|
---|
[302] | 97 | }
|
---|
[195] | 98 | }
|
---|