| 57 | | /** |
|---|
| 58 | | * The main entry point method. |
|---|
| 59 | | */ |
|---|
| 60 | | public function main() |
|---|
| 61 | | { |
|---|
| 62 | | $command = sprintf("find %s -name '*.xml'", $this->root); |
|---|
| 63 | | exec($command, $result, $status); |
|---|
| 64 | | |
|---|
| 65 | | if ($status != 0 ) { |
|---|
| 66 | | throw new Exception("Find returned nonzero error!\n"); |
|---|
| 67 | | } |
|---|
| 68 | | $schemafiles = array(); |
|---|
| 69 | | foreach ($result as $key => $file ) { |
|---|
| 70 | | $filename = basename($file); |
|---|
| 71 | | if (is_dir($file)) continue; |
|---|
| 72 | | |
|---|
| 73 | | switch ($filename) { |
|---|
| 74 | | case 'mgdschema.xml': |
|---|
| 75 | | $schemafiles[] = $file; |
|---|
| 76 | | break; |
|---|
| 77 | | case 'package.xml': |
|---|
| 78 | | case 'build.xml': |
|---|
| 79 | | break; |
|---|
| 80 | | default: |
|---|
| 81 | | break; |
|---|
| 82 | | } |
|---|
| 83 | | } |
|---|
| 84 | | //var_dump($schemafiles); |
|---|
| 85 | | |
|---|
| 86 | | $xml = $this->generateXML($schemafiles); |
|---|
| 87 | | echo $xml; |
|---|
| 88 | | $location = $this->root . "/includes.xml"; |
|---|
| 89 | | file_put_contents($location , $xml); |
|---|
| 90 | | $this->project->setProperty($this->returnProperty, $location); |
|---|
| 91 | | } |
|---|
| 92 | | |
|---|
| 93 | | protected function generate_include ($file) { |
|---|
| 94 | | return sprintf(' <include name="%s" />"', $file); |
|---|
| 95 | | //var_dump($var); |
|---|
| 96 | | } |
|---|
| 97 | | |
|---|
| 98 | | protected function generateXML ($files) { |
|---|
| 99 | | $includes = implode("\n", array_map(array($this,'generate_include'), $files)); |
|---|
| 100 | | |
|---|
| 101 | | $xml = sprintf( |
|---|
| | 57 | /** |
|---|
| | 58 | * The main entry point method. |
|---|
| | 59 | */ |
|---|
| | 60 | public function main() |
|---|
| | 61 | { |
|---|
| | 62 | $command = sprintf("find %s -name '*.xml'", $this->root); |
|---|
| | 63 | exec($command, $result, $status); |
|---|
| | 64 | |
|---|
| | 65 | if ($status != 0 ) { |
|---|
| | 66 | throw new Exception("Find returned nonzero error!\n"); |
|---|
| | 67 | } |
|---|
| | 68 | $schemafiles = array(); |
|---|
| | 69 | foreach ($result as $key => $file ) { |
|---|
| | 70 | $filename = basename($file); |
|---|
| | 71 | if (is_dir($file)) continue; |
|---|
| | 72 | |
|---|
| | 73 | switch ($filename) { |
|---|
| | 74 | case 'mgdschema.xml': |
|---|
| | 75 | $schemafiles[] = $file; |
|---|
| | 76 | break; |
|---|
| | 77 | case 'package.xml': |
|---|
| | 78 | case 'build.xml': |
|---|
| | 79 | break; |
|---|
| | 80 | default: |
|---|
| | 81 | break; |
|---|
| | 82 | } |
|---|
| | 83 | } |
|---|
| | 84 | //var_dump($schemafiles); |
|---|
| | 85 | |
|---|
| | 86 | $xml = $this->generateXML($schemafiles); |
|---|
| | 87 | echo $xml; |
|---|
| | 88 | $location = $this->root . "/includes.xml"; |
|---|
| | 89 | file_put_contents($location , $xml); |
|---|
| | 90 | $this->project->setProperty($this->returnProperty, $location); |
|---|
| | 91 | } |
|---|
| | 92 | |
|---|
| | 93 | protected function generate_include ($file) { |
|---|
| | 94 | return sprintf(' <include name="%s" />"', $file); |
|---|
| | 95 | //var_dump($var); |
|---|
| | 96 | } |
|---|
| | 97 | |
|---|
| | 98 | protected function generateXML ($files) { |
|---|
| | 99 | $includes = implode("\n", array_map(array($this,'generate_include'), $files)); |
|---|
| | 100 | |
|---|
| | 101 | $xml = sprintf( |
|---|