Show
Ignore:
Timestamp:
04/20/06 10:20:30 (6 years ago)
Author:
haas
Message:

DateHelper? docs and tests

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/trax_generator.php

    r195 r198  
    346346 
    347347        # Create the extra folders for View / Controller 
    348         if(!file_exists($this->view_path)) { 
     348        if(file_exists($this->view_path)) { 
     349            echo "exists $this->view_path\n"; 
     350        } else{ 
    349351            $this->exec("$this->mkdir_cmd $this->view_path"); 
    350         } 
    351  
    352         if(!file_exists($this->controller_path)) { 
     352            echo "create $this->view_path\n"; 
     353        } 
     354 
     355        if(file_exists($this->controller_path)) { 
     356            echo "exists $this->controller_path\n"; 
     357        } else { 
    353358            $this->exec("$this->mkdir_cmd $this->controller_path"); 
    354         } 
    355  
    356         if(!file_exists($this->helper_path)) { 
     359            echo "create $this->controller_path\n"; 
     360        } 
     361 
     362        if(file_exists($this->helper_path)) { 
     363            echo "exists $this->helper_path\n"; 
     364        } else { 
    357365            $this->exec("$this->mkdir_cmd $this->helper_path"); 
     366            echo "create $this->helper_path\n"; 
    358367        } 
    359368 
     
    414423                    echo "error creating model file: $model_file\n"; 
    415424                } else { 
    416                     echo "created $model_file\n"; 
     425                    echo "create $model_file\n"; 
    417426                    return true; 
    418427                } 
     
    457466        $human_model_name = Inflector::humanize($model_name);       
    458467 
    459         $this->{$singluar_model_name} = new $model_class_name();             
     468        try { 
     469            $this->{$singluar_model_name} = new $model_class_name(); 
     470        } catch (ActiveRecordError $e) { 
     471            echo "Can't create model.\n"; 
     472            echo $e->getMessage()."\n"; 
     473            echo "for database '" 
     474                . $GLOBALS['TRAX_DB_SETTINGS'][TRAX_MODE]['database'] 
     475                . "' on host '" 
     476                . $GLOBALS['TRAX_DB_SETTINGS'][TRAX_MODE]['hostspec'] 
     477                . "' as user '" 
     478                . $GLOBALS['TRAX_DB_SETTINGS'][TRAX_MODE]['username'] 
     479                . "'\nDid you configure file " 
     480                . TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['config'] 
     481                . "/database.ini correctly?\n"; 
     482            die(); 
     483        } 
    460484        if(empty($controller_name)) { 
    461485            $controller_name = Inflector::underscore($model_name);    
     
    499523                echo "error creating controller class file: $controller_file\n"; 
    500524            } else { 
    501                 echo "created $controller_file\n"; 
     525                echo "create $controller_file\n"; 
    502526            }         
    503527        } else { 
     
    515539                echo "error creating view file: $view_file\n"; 
    516540            } else { 
    517                 echo "created $view_file\n"; 
     541                echo "create $view_file\n"; 
    518542            } 
    519543        } else { 
     
    531555                echo "error creating view file: $view_file\n"; 
    532556            } else { 
    533                 echo "created $view_file\n"; 
     557                echo "create $view_file\n"; 
    534558            } 
    535559        } else { 
     
    547571                echo "error creating view file: $view_file\n"; 
    548572            } else { 
    549                 echo "created $view_file\n"; 
     573                echo "create $view_file\n"; 
    550574            } 
    551575        } else { 
     
    563587                echo "error creating view file: $view_file\n"; 
    564588            } else { 
    565                 echo "created $view_file\n"; 
     589                echo "create $view_file\n"; 
    566590            } 
    567591        } else { 
     
    572596        $view_file = "$this->view_path/_form.".$this->view_file_extention; 
    573597        ob_start();     
    574         include("$this->scaffold_template_path/form_scaffolding.phtml"); 
     598        require "$this->scaffold_template_path/form_scaffolding.phtml"; 
    575599        $_form_contents = $this->fix_php_brackets(ob_get_contents()); 
    576600        ob_end_clean();   
     
    579603                echo "error creating view file: $view_file\n"; 
    580604            } else { 
    581                 echo "created $view_file\n"; 
     605                echo "create $view_file\n"; 
    582606            } 
    583607        } else { 
     
    598622                echo "error creating layout file: $layout_file\n"; 
    599623            } else { 
    600                 echo "created $layout_file\n"; 
     624                echo "create $layout_file\n"; 
    601625            } 
    602626        } else { 
     
    654678                        . $controller_file . "\n"; 
    655679                } else { 
    656                     echo "created $controller_file\n"; 
     680                    echo "create $controller_file\n"; 
    657681                } 
    658682 
     
    688712                    echo "error creating helper file: $helper_file\n"; 
    689713                } else { 
    690                     echo "created $helper_file\n"; 
     714                    echo "create $helper_file\n"; 
    691715                } 
    692716 
     
    732756                    echo "error creating view file: $view_file\n"; 
    733757                } else { 
    734                     echo "created $view_file\n"; 
     758                    echo "create $view_file\n"; 
    735759                } 
    736760            } else {