Show
Ignore:
Timestamp:
02/06/08 22:58:28 (10 months ago)
Author:
rambo
Message:

scripted whitespace normalization, see r14772

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/build/generateSchemaFile.php

    r5030 r14773  
    1717{ 
    1818 
    19          
     19     
    2020 
    21        function __construct() 
    22        
     21    function __construct() 
     22   
    2323 
    24        
     24   
    2525 
    26        protected $returnProperty; // name of property to set to return value 
     26    protected $returnProperty; // name of property to set to return value 
    2727 
    28        /** 
    29         * The root path to where the module is stored. 
    30         */ 
    31        private $root = null; 
    32        /** 
    33         * The target directory where the packagefile should be saved. 
    34         */ 
    35        protected $target_dir = null; 
     28    /** 
     29    * The root path to where the module is stored. 
     30    */ 
     31    private $root = null; 
     32    /** 
     33    * The target directory where the packagefile should be saved. 
     34    */ 
     35    protected $target_dir = null; 
    3636 
    37        public function setRoot($str) 
    38        
    39                $this->root = $str; 
    40        
     37    public function setRoot($str) 
     38   
     39        $this->root = $str; 
     40   
    4141 
    42        /** Sets property name to set with return value of function or expression.*/ 
    43        public function setReturnProperty($r) 
    44        
    45                $this->returnProperty = $r; 
    46        
     42    /** Sets property name to set with return value of function or expression.*/ 
     43    public function setReturnProperty($r) 
     44   
     45        $this->returnProperty = $r; 
     46   
    4747 
    4848 
    49        /** 
    50         * The init method: Do init steps. 
    51         */ 
    52        public function init() 
    53        
    54                  
    55        
     49    /** 
     50    * The init method: Do init steps. 
     51    */ 
     52    public function init() 
     53   
     54         
     55   
    5656 
    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( 
    102102'<?xml version="1.0" encoding="UTF-8"?> <Schema xmlns="http://www.midgard-project.org/repligard/1.4">  
    103103%s 
    104 </Schema>' , $includes ) ;              
    105                 return $xml;     
    106        
     104</Schema>' , $includes ) ;         
     105        return $xml;     
     106   
    107107 
    108          
     108     
    109109} 
    110110?>