parse($_SESSION['lampath'] . 'config/pdf/' . $scope . '/' . $definition); $border = array(); $structure = array(); $pdf_entries = $xml[1]['PDF']; $border[$current] = array(); while(($index = current($pdf_entries)) != null) { if($xml[0][$index]['attributes']['TYPE'] == $scope) { $border['start'] = $index; next($pdf_entries); $border['end'] = current($pdf_entries); } next($pdf_entries); } $structure = array_slice($xml[0],$border['start'] + 1,$border['end'] - ($border['start'] + 1)); return $structure; } function savePDFStructureDefinitions($scope,$definition) { $handle = fopen($_SESSION['lampath'] . 'config/pdf/' . $scope . '/' . $definition,'w'); $file = "\n"; foreach($_SESSION['currentPDFStructure'] as $entry) { $ident = ''; for($i=0;$i<$entry['level'] -1;$i++) { $ident .= "\t"; } $attributes = ''; if(is_array($entry['attributes'])) { foreach($entry['attributes'] as $key => $value) { $attributes .= ' ' . strtolower($key) . '="' . $value . '"'; } } if($entry['type'] == 'open') { $file .= $ident . '<' . strtolower($entry['tag']) . $attributes . ">\n"; } elseif($entry['type'] == 'close') { $file .= $ident . '\n"; } elseif($entry['type'] == 'complete') { if(isset($entry['value'])) { $file .= $ident . '<' . strtolower($entry['tag']) . $attributes . '>' . $entry['value'] . '\n"; } else { $file .= $ident . '<' . strtolower($entry['tag']) . $attributes . " />\n"; } } } $file .= ""; fwrite($handle,$file); fclose($handle); } ?>