Changeset 815 for trunk/Modules/Import/generatecodeXML.php
- Timestamp:
- Feb 22, 2015, 11:05:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Import/generatecodeXML.php
r565 r815 3 3 //$xml_buffer = array(); 4 4 5 function startElement($parser, $name, $attrs) 5 function startElement($parser, $name, $attrs) 6 6 { 7 7 global $depth, $xml_buffer; 8 9 for ($i = 0; $i < $depth[$parser]; $i++) 8 9 for ($i = 0; $i < $depth[$parser]; $i++) 10 10 { 11 11 echo " "; … … 14 14 // print_r( $attrs); 15 15 // generování proměných 16 16 17 17 $xml_buffer[count($xml_buffer)+1] = array($depth[$parser],$attrs); 18 18 // print_r($xml_buffer); … … 20 20 } 21 21 22 function endElement($parser, $name) 22 function endElement($parser, $name) 23 23 { 24 24 global $depth; 25 25 26 26 $depth[$parser]--; 27 27 } … … 30 30 31 31 $files = scandir($verze); 32 foreach($files as $file) 32 foreach($files as $file) 33 33 { 34 34 $end = substr($file, strlen($file) - 3); … … 36 36 { 37 37 echo('<br />--'.$file.'<br /><br />'); 38 $file = $verze.'/'.$file; 38 $file = $verze.'/'.$file; 39 39 $xml_buffer = array(); //mazání 40 40 41 41 $xml_parser = xml_parser_create(); 42 42 xml_set_element_handler($xml_parser, 'startElement', 'endElement'); 43 if (!($fp = fopen($file, 'r'))) 43 if (!($fp = fopen($file, 'r'))) 44 44 { 45 45 die('could not open XML input'); 46 46 } 47 47 48 while ($data = fread($fp, 4096)) 48 while ($data = fread($fp, 4096)) 49 49 { 50 if (!xml_parse($xml_parser, $data, feof($fp))) 50 if (!xml_parse($xml_parser, $data, feof($fp))) 51 51 { 52 52 die(sprintf("XML error: %s at line %d", … … 56 56 } 57 57 xml_parser_free($xml_parser); 58 59 for ($i = 0; $i < count($xml_buffer); $i++) 58 59 for ($i = 0; $i < count($xml_buffer); $i++) 60 60 { 61 61 $line = $xml_buffer[$i]; 62 if (isset($line[1]['TEXT'])) 62 if (isset($line[1]['TEXT'])) 63 63 { 64 64 $name = $line[1]['NAME']; 65 65 66 if ($name == '') 66 if ($name == '') 67 67 { //u FontString 68 68 $j = 1; 69 while (substr($name,0,1) == '') 69 while (substr($name,0,1) == '') 70 70 { 71 if (isset($xml_buffer[$i-$j][1]['NAME'])) 71 if (isset($xml_buffer[$i-$j][1]['NAME'])) 72 72 { 73 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 73 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 74 74 } 75 $j++; 75 $j++; 76 76 } 77 77 } 78 78 79 if (substr($name,0,1) == '$') 79 if (substr($name,0,1) == '$') 80 80 { //zjišťování potomků 81 81 $j = 1; 82 while (substr($name,0,1) == '$') 82 while (substr($name,0,1) == '$') 83 83 { 84 if (($xml_buffer[$i-$j][0] < $line[0]) and (isset($xml_buffer[$i-$j][1]['NAME']))) 84 if (($xml_buffer[$i-$j][0] < $line[0]) and (isset($xml_buffer[$i-$j][1]['NAME']))) 85 85 { 86 86 $name = substr($name,strlen('$parent')); 87 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 87 $name = $xml_buffer[$i-$j][1]['NAME'].$name; 88 88 } 89 $j++; 89 $j++; 90 90 } 91 91 }
Note:
See TracChangeset
for help on using the changeset viewer.