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