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