Show
Ignore:
Timestamp:
04/03/06 16:27:26 (6 years ago)
Author:
haas
Message:

docs, test trax_generator

Files:
1 modified

Legend:

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

    r170 r195  
    2727 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    2828 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 * 
     30 *  @package PHPonTrax 
    2931 */ 
    3032 
    3133/** 
    32  *  Implement the commands of {@link generate.php script/generate.php} 
     34 *  Generate application files in the Trax work area 
    3335 * 
     36 *  Implements the commands of {@link generate.php script/generate.php} 
    3437 *  <p>Legal commands:</p> 
    3538 *  <ul> 
     
    3841 *    <li>{@link generate_scaffold() scaffold}</li> 
    3942 *  </ul> 
    40  * 
    41  *  @package PHPonTrax 
    4243 */ 
    4344class TraxGenerator { 
    4445 
    45     private 
    46         $view_path, 
    47         $controller_path, 
    48         $helper_path, 
    49         $model_path, 
    50         $mkdir_cmd, 
    51         $controller_template_file, 
    52         $helper_template_file, 
    53         $view_template_file, 
    54         $model_template_file, 
    55         $scaffold_template_path, 
    56         $layout_path, 
    57         $layout_filename; 
    58     public 
    59         $view_file_extention = TRAX_VIEWS_EXTENTION; 
     46    /** 
     47     *  Filesystem path to the app/views directory in the Trax work area 
     48     *  @var string 
     49     */ 
     50    private $view_path; 
     51 
     52    /** 
     53     *  Filesystem path to the app/controllers directory in the Trax work area 
     54     *  @var string 
     55     */ 
     56    private $controller_path; 
     57 
     58    /** 
     59     *  Filesystem path to the app/helpers directory in the Trax work area 
     60     *  @var string 
     61     */ 
     62    private $helper_path; 
     63 
     64    /** 
     65     *  Filesystem path to the app/model directory in the Trax work area 
     66     *  @var string 
     67     */ 
     68    private $model_path; 
     69 
     70    /** 
     71     *  Generated subdirectories in the Trax work area 
     72     * 
     73     *  When a controller is generated with a name that includes '/', 
     74     *  $extra_path is set to the implied subdirectories. 
     75     *  @var string 
     76     */ 
     77    private $extra_path; 
     78 
     79    /** 
     80     *  Platform-dependent command to make a directory 
     81     *  @var string 
     82     */ 
     83    private $mkdir_cmd; 
     84 
     85    /** 
     86     *  Filesystem path to the templates/controller.php file 
     87     *  @var string 
     88     */ 
     89    private $controller_template_file; 
     90 
     91    /** 
     92     *  Filesystem path to the templates/helper.php file 
     93     *  @var string 
     94     */ 
     95    private $helper_template_file; 
     96 
     97    /** 
     98     *  Filesystem path to the templates/view.phtml file 
     99     *  @var string 
     100     */ 
     101    private $view_template_file; 
     102 
     103    /** 
     104     *  Filesystem path to the templates/model.php file 
     105     *  @var string 
     106     */ 
     107    private $model_template_file; 
     108 
     109    /** 
     110     *  Filesystem path to templates/scaffolds/generator_templates directory 
     111     *  @var string 
     112     */ 
     113    private $scaffold_template_path; 
     114 
     115    /** 
     116     *  Filesystem path to the app/views/layouts/ directory in the 
     117     *  Trax work area 
     118     *  @var string 
     119     */ 
     120    private $layouts_path; 
     121 
     122    /** 
     123     *  @todo Document this variable 
     124     * 
     125     *  Value is set by {@link generate_controller()} and used by 
     126     *  {@link generate_scaffold()} 
     127     *  @var string 
     128     */ 
     129    private $layout_filename; 
     130 
     131    /** 
     132     *  CamelCase name of the controller class 
     133     *  @var string 
     134     */ 
     135    private $controller_class; 
     136 
     137    /** 
     138     *  Value of the view files extension (usually '.phtml') 
     139     *  @var string 
     140     */ 
     141    public $view_file_extention = TRAX_VIEWS_EXTENTION; 
    60142 
    61143    /** 
    62144     *  Constructor for the TraxGenerator object 
    63145     * 
     146     *  Compute and store filesystem paths to the various 
     147     *  subdirectories of the Trax work area and the template files 
     148     *  used to generate application files 
    64149     *  @uses $GLOBALS['TRAX_INCLUDES'] 
    65150     *  @global string[] $GLOBALS['TRAX_INCLUDES'] Array of paths to 
    66151     *                                             various Trax directories 
     152     *  @uses controller_path 
     153     *  @uses controller_template_file 
     154     *  @uses helper_path 
     155     *  @uses helper_template_file 
     156     *  @uses layouts_path 
     157     *  @uses model_path 
     158     *  @uses model_template_file 
     159     *  @uses scaffold_template_path 
     160     *  @uses view_path 
     161     *  @uses view_template_file 
    67162     */ 
    68163    function __construct() { 
    69         $this->view_path = TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['views']; 
    70         $this->controller_path = TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['controllers']; 
    71         $this->helper_path = TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['helpers']; 
    72         $this->model_path = TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['models']; 
    73         $this->layouts_path = TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['layouts']; 
    74         $this->controller_template_file = TRAX_LIB_ROOT . "/templates/controller.php"; 
    75         $this->helper_template_file = TRAX_LIB_ROOT . "/templates/helper.php"; 
    76         $this->view_template_file = TRAX_LIB_ROOT . "/templates/view.".$this->view_file_extention; 
    77         $this->model_template_file = TRAX_LIB_ROOT . "/templates/model.php"; 
    78         $this->scaffold_template_path = TRAX_LIB_ROOT . "/templates/scaffolds/generator_templates"; 
     164        $this->view_path = 
     165               TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['views']; 
     166        $this->controller_path = 
     167               TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['controllers']; 
     168        $this->helper_path = 
     169               TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['helpers']; 
     170        $this->model_path = 
     171               TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['models']; 
     172        $this->layouts_path = 
     173               TRAX_ROOT . $GLOBALS['TRAX_INCLUDES']['layouts']; 
     174        $this->controller_template_file = 
     175               TRAX_LIB_ROOT . "/templates/controller.php"; 
     176        $this->helper_template_file = 
     177               TRAX_LIB_ROOT . "/templates/helper.php"; 
     178        $this->view_template_file = 
     179               TRAX_LIB_ROOT . "/templates/view.".$this->view_file_extention; 
     180        $this->model_template_file = 
     181               TRAX_LIB_ROOT . "/templates/model.php"; 
     182        $this->scaffold_template_path = 
     183               TRAX_LIB_ROOT . "/templates/scaffolds/generator_templates"; 
    79184 
    80185        if (substr(PHP_OS, 0, 3) == 'WIN') { 
     
    83188            $this->mkdir_cmd = "mkdir -p"; 
    84189        } 
    85  
    86190    } 
    87191 
    88192    /** 
    89193     *  Parse command line and carry out the command 
    90      *  @todo Document this method 
     194     * 
     195     *  Command line arguments, if any are in $_SERVER['argv'] 
     196     *  @uses controller_help() 
     197     *  @uses generate_controller() 
     198     *  @uses generate_model() 
     199     *  @uses generate_scaffold() 
     200     *  @uses generator_help() 
     201     *  @uses model_help() 
     202     *  @uses scaffold_help() 
    91203     */ 
    92204    function run() { 
    93         $command = strtolower($_SERVER["argv"][1]); 
    94         $command_name = $_SERVER["argv"][2]; 
    95  
     205 
     206        //  If command line arguments exist, parse them 
     207        if (array_key_exists('argv', $_SERVER)) { 
     208            if (array_key_exists(1, $_SERVER['argv'])) { 
     209                $command = strtolower($_SERVER["argv"][1]); 
     210            } 
     211            if (array_key_exists(2, $_SERVER['argv'])) { 
     212                $command_name = $_SERVER["argv"][2]; 
     213            } 
     214        } 
     215 
     216        //  Execute command or output a diagnostic 
    96217        if(empty($command)) { 
    97218            $this->generator_help(); 
    98219        } else { 
    99220            switch($command) { 
     221 
     222                //  Process "controller" command 
    100223                case "controller": 
    101224                    if(empty($command_name)) { 
    102225                        $this->controller_help(); 
    103226                    } else { 
    104                         if($_SERVER["argv"][3] != "") { 
     227                        $views = array(); 
     228                        if(array_key_exists(3, $_SERVER['argv']) 
     229                           && ($_SERVER["argv"][3] != "")) { 
    105230                            for($i=3;$i < count($_SERVER["argv"]);$i++) { 
    106                                 $views[] = strtolower($_SERVER["argv"][$i]); 
     231                               $views[] = strtolower($_SERVER["argv"][$i]); 
    107232                            } 
    108233                        } 
     
    110235                    } 
    111236                    break; 
     237 
     238                //  Process "model" command 
     239                //  $command_name is the name of the model 
    112240                case "model": 
    113241                    if(empty($command_name)) { 
     
    117245                    } 
    118246                    break; 
     247 
     248                //  Process "scaffold" command 
     249                //  $command_name has the name of the model 
     250                //  $_SERVER['argv'][3] has the name of the controller 
    119251                case "scaffold": 
    120                     if(empty($command_name)) { 
     252 
     253                    //  Model name is required 
     254                    if( empty($command_name) ) { 
     255                        echo "Error: name of model omitted\n"; 
    121256                        $this->scaffold_help(); 
     257                        break; 
     258                    } 
     259 
     260                    //  Controller name is optional 
     261                    if (array_key_exists(3, $_SERVER["argv"])) { 
     262                        $controller_name = $_SERVER["argv"][3]; 
    122263                    } else { 
    123                         $controller_name = $_SERVER["argv"][3]; 
    124                         if($_SERVER["argv"][4] != "") { 
    125                             for($i=4;$i < count($_SERVER["argv"]);$i++) { 
    126                                 $views[] = strtolower($_SERVER["argv"][$i]); 
    127                             } 
    128                         }                         
    129                         $this->generate_scaffold($command_name, $controller_name, $views); 
     264                        $controller_name = null; 
    130265                    } 
     266                         
     267                    //  Views are optional following controller name 
     268                    $views = array(); 
     269                    if (array_key_exists(4, $_SERVER["argv"]) 
     270                        && ($_SERVER["argv"][4] != "")) { 
     271                        for($i=4;$i < count($_SERVER["argv"]);$i++) { 
     272                            $views[] = strtolower($_SERVER["argv"][$i]); 
     273                        } 
     274                    } 
     275                    $this->generate_scaffold($command_name, 
     276                                             $controller_name, $views); 
    131277                    break;                     
    132             } 
    133         } 
    134         exit; 
     278 
     279            default: 
     280                $this->generator_help(); 
     281            }                            // switch($command) 
     282        } 
     283        return; 
    135284    } 
    136285 
     
    160309     *  <samp>app/views/</samp><i>some_name/view2</i><samp>.phtml</samp></p> 
    161310     * 
    162      *  @param string $name Name of the controller to generate in camel case 
     311     *  @param string $name Name in CamelCase of the controller to generate. 
     312     *                      The value may include '/' which will cause 
     313     *                      creation of subdirectories indicated to 
     314     *                      hold the controller and view files. 
    163315     *  @param string $views  Optional list of views to generate 
    164316     *  @param boolean $scaffolding 
     317     *  @uses Inflector::underscore() 
     318     *  @uses $controller_class   Set during call 
     319     *  @uses $controller_path    Must be set before call. 
     320     *  @uses create_controller() 
     321     *  @uses create_helper() 
     322     *  @uses create_view() 
     323     *  @uses $extra_path         Set during call 
     324     *  @uses $helper_path        Must be set before call. 
     325     *  @uses $layouts_path       Must be set before call. 
     326     *  @uses $layout_filename    Set during call 
     327     *  @uses $view_path          Must be set before call. 
    165328     */ 
    166329    function generate_controller($name, $views="", $scaffolding = false) { 
     
    225388     *  <samp>class</samp> <i>SomeName</i> <samp>extends 
    226389     *  ActiveRecord {}</samp> 
    227      *  @param string $name Name of the model 
     390     *  @param string $name Name of the model.  May be in either 
     391     *                under_score or CamelCase.  If no '_' exists in 
     392     *                $name it is treated as CamelCase. 
     393     *  @uses Inflector::underscore() 
     394     *  @uses model_path           Must be set before call. 
     395     *                             Not changed during call. 
     396     *  @uses model_template_file  Must be set before call. 
     397     *                             Not changed during call. 
    228398     */ 
    229399    function generate_model($name) { 
     
    263433     *  @param string $controller_name 
    264434     *  @param string $views 
     435     *  @uses generate_controller() 
     436     *  @uses generate_model() 
     437     *  @uses Inflector::classify() 
     438     *  @uses Inflector::humanize() 
     439     *  @uses Inflector::pluralize() 
     440     *  @uses Inflector::singularize() 
     441     *  @uses Inflector::underscore() 
     442     *  @uses $layout_filename          Set as output from 
     443     *                                  generate_controller(). 
     444     *                                  Not changed afterward. 
     445     *  @uses fix_php_brackets() 
    265446     */ 
    266447    function generate_scaffold($model_name, $controller_name, $views="") { 
    267448        if(!$model_exists = $this->generate_model($model_name)) { 
    268449            echo "Error - Can't create Model: $model_name.\n";     
    269             exit; 
     450            return; 
    270451        } 
    271452 
     
    275456        $plural_model_name = Inflector::pluralize($model_name);   
    276457        $human_model_name = Inflector::humanize($model_name);       
     458 
    277459        $this->{$singluar_model_name} = new $model_class_name();             
    278         if(!$controller_name) { 
    279             $controller_name = Inflector::pluralize($model_name);    
     460        if(empty($controller_name)) { 
     461            $controller_name = Inflector::underscore($model_name);    
    280462        } else { 
    281463            $controller_name = Inflector::underscore($controller_name);     
    282464        } 
    283         $controller_file = "$this->controller_path/".$controller_name."_controller.php"; 
     465        $GLOBALS['current_controller_name'] = $controller_name; 
     466        $controller_file = 
     467            "$this->controller_path/" . $controller_name."_controller.php"; 
     468        $GLOBALS['current_controller_path'] = $controller_file; 
    284469        $non_scaffolded_actions = array(); 
    285470        $illegal_views = array("index","add","edit","show");       
     
    291476            } 
    292477        }          
    293         $this->generate_controller($controller_name, $non_scaffolded_actions, true);  
     478        $this->generate_controller($controller_name, 
     479                                   $non_scaffolded_actions, true);  
    294480        if(stristr($controller_name, "/")) { 
    295             $controller_class_name = Inflector::classify(substr($controller_name,strrpos($controller_name, "/")+1)); 
    296             $human_controller_name = Inflector::humanize(substr($controller_name,strrpos($controller_name, "/")+1)); 
     481            $controller_class_name = 
     482                Inflector::classify(substr($controller_name, 
     483                                           strrpos($controller_name, "/")+1)); 
     484            $human_controller_name = 
     485                Inflector::humanize(substr($controller_name, 
     486                                           strrpos($controller_name, "/")+1)); 
    297487        } else { 
    298488            $controller_class_name = Inflector::classify($controller_name); 
     
    416606 
    417607    /** 
    418      *  @todo Document this method 
    419      * 
     608     *  Create a controller file with optional view methods 
     609     * 
     610     *  @param string $controller Name of the controller 
     611     *  @param string[] $views    Name(s) of view(s), if any 
     612     *  @uses controller_class    Must be set before call. 
     613     *                            Not changed during call. 
     614     *  @uses controller_path     Must be set before call. 
     615     *                            Not changed during call. 
     616     *  @uses controller_template_file Must be set before call. 
     617     *                            Not changed during call. 
     618     *  @todo Should return succeed/fail indication 
    420619     */ 
    421620    function create_controller($controller,$views="") { 
    422621 
    423         $controller_file = "$this->controller_path/".$controller."_controller.php"; 
     622        $controller_file = "$this->controller_path/" 
     623            . $controller . "_controller.php"; 
    424624 
    425625        if(!file_exists($controller_file)) { 
    426626            if(file_exists($this->controller_template_file)) { 
    427627                $template = file_get_contents($this->controller_template_file); 
    428                 $template = str_replace('[class_name]',$this->controller_class,$template); 
    429                 if(is_array($views)) { 
    430                     foreach($views as $view) { 
    431                         $classMethods[] = "\tfunction $view() {\n\t}"; 
     628                $template = str_replace('[class_name]', 
     629                                        $this->controller_class,$template); 
     630                //  Add view methods 
     631                if (!empty($views)) { 
     632 
     633                    //  There are some views, add a method for each 
     634                    if(is_array($views)) { 
     635 
     636                        //  Multiple views in an array 
     637                        foreach($views as $view) { 
     638                            $classMethods[] = "\tfunction $view() {\n\t}"; 
     639                        } 
     640                        $classMethods = implode("\n\n",$classMethods); 
     641                    } else { 
     642                        $classMethods = "\tfunction $views() {\n\t}\n\n"; 
    432643                    } 
    433                     $classMethods = implode("\n\n",$classMethods); 
     644                    $template = str_replace('[class_methods]', 
     645                                            $classMethods,$template); 
     646                } else { 
     647 
     648                    //  No view methods to add, so remove unneeded template 
     649                    $template = str_replace('[class_methods]', '',$template); 
    434650                } 
    435                 $template = str_replace('[class_methods]',$classMethods,$template); 
    436651 
    437652                if(!file_put_contents($controller_file,$template)) { 
    438                     echo "error creating controller class file: $controller_file\n"; 
     653                    echo "error creating controller class file: " 
     654                        . $controller_file . "\n"; 
    439655                } else { 
    440656                    echo "created $controller_file\n"; 
     
    442658 
    443659            } else { 
    444                 echo "error controller template file doesn't exist: $this->controller_template_file\n"; 
     660                echo "error controller template file doesn't exist: " 
     661                    . $this->controller_template_file . "\n"; 
    445662            } 
    446663        } else { 
     
    450667 
    451668    /** 
    452      *  @todo Document this method 
    453      * 
     669     *  Create a helper file for a controller 
     670     * 
     671     *  @param string $controller Name of the controller 
     672     *  @uses controller_class      Must be set before call. 
     673     *                              Not changed during call. 
     674     *  @uses helper_path           Must be set before call. 
     675     *                              Not changed during call. 
     676     *  @uses helper_template_file  Must be set before call. 
     677     *                              Not changed during call. 
     678     *  @todo Should return succeed/fail indication 
    454679     */ 
    455680    function create_helper($controller) { 
    456  
    457681        $helper_file = "$this->helper_path/".$controller."_helper.php"; 
    458  
    459682        if(!file_exists($helper_file)) { 
    460683            if(file_exists($this->helper_template_file)) { 
    461684                $template = file_get_contents($this->helper_template_file); 
    462                 $template = str_replace('[class_name]',$this->controller_class,$template); 
     685                $template = str_replace('[class_name]', 
     686                                        $this->controller_class,$template); 
    463687                if(!file_put_contents($helper_file,$template)) { 
    464688                    echo "error creating helper file: $helper_file\n"; 
     
    468692 
    469693            } else { 
    470                 echo "error helper template file doesn't exist: $this->helper_template_file\n"; 
     694                echo "error helper template file doesn't exist: " 
     695                    . $this->helper_template_file . "\n"; 
    471696            } 
    472697        } else { 
     
    476701 
    477702    /** 
    478      *  @todo Document this method 
    479      * 
     703     *  Create a view file if it doesn't exist 
     704     * 
     705     *  Create a view file in the Trax work area if the required file 
     706     *  does not yet exist.  Generate the view file contents by 
     707     *  customizing the view template file with information about the 
     708     *  controller and view names. 
     709     * 
     710     *  @param string $view           Name of the view 
     711     *  @param string $controller     Name of the controller 
     712     *  @uses controller_class        Must be set before call. 
     713     *                                Not changed during call. 
     714     *  @uses view_file_extension     Must be set before call. 
     715     *                                Not changed during call. 
     716     *  @uses view_path               Must be set before call. 
     717     *                                Not changed during call. 
     718     *  @uses view_template_file      Must be set before call. 
     719     *                                Not changed during call. 
     720     *  @todo Should return succeed/fail indication 
    480721     */ 
    481722    function create_view($view, $controller) { 
     
    484725            if(file_exists($this->view_template_file)) { 
    485726                $template = file_get_contents($this->view_template_file); 
    486                 $template = str_replace('[class_name]',$this->controller_class,$template); 
     727                $template = str_replace('[class_name]', 
     728                                        $this->controller_class,$template); 
    487729                $template = str_replace('[controller]',$controller,$template); 
    488730                $template = str_replace('[view]',$view,$template); 
     
    493735                } 
    494736            } else { 
    495                 echo "error controller template file doesn't exist: $this->view_template_file\n"; 
     737                echo "error view template file doesn't exist: " 
     738                    . $this->view_template_file . "\n"; 
    496739            } 
    497740        } else { 
     
    504747     * 
    505748     *  @param string $cmd  Command to be executed 
     749     *  @todo Replace with calls to filesystem methods 
    506750     */ 
    507751    function exec($cmd) { 
     
    520764     */ 
    521765    function fix_php_brackets($string) { 
    522         return str_replace("? >", "?>", str_replace("< ?php", "<?php", $string));             
     766        return str_replace("? >", "?>", 
     767                           str_replace("< ?php", "<?php", $string)); 
    523768    } 
    524769 
     
    527772     */ 
    528773    function controller_help() { 
    529         echo "Usage: ./generate.php controller ControllerName [view1 view2 ...]\n\n"; 
     774        echo "Usage: php generate.php controller ControllerName [view1 view2 ...]\n\n"; 
    530775        echo "Description:\n"; 
    531         echo "\tThe controller generator creates functions for a new controller and its views.\n\n"; 
     776        echo "\tThe controller generator creates functions for a new controller and\n"; 
     777        echo"\tits views.\n\n"; 
    532778        echo "\tThe generator takes a controller name and a list of views as arguments.\n"; 
    533779        echo "\tThe controller name may be given in CamelCase or under_score and should\n"; 
     
    537783        echo "\ttemplates in app/views/controller_name.\n\n"; 
    538784        echo "Example:\n"; 
    539         echo "\t./script/generate.php controller CreditCard open debit credit close\n\n"; 
     785        echo "\tphp script/generate.php controller CreditCard open debit credit close\n\n"; 
    540786        echo "\tCredit card controller with URLs like /credit_card/debit.\n"; 
    541787        echo "\t\tController: app/controllers/credit_card_controller.php\n"; 
     
    543789        echo "\t\tHelper:     app/helpers/credit_card_helper.php\n\n"; 
    544790        echo "Module/Folders Example:\n"; 
    545         echo "\t./script/generate.php controller 'admin/credit_card' suspend late_fee\n\n"; 
     791        echo "\tphp script/generate.php controller 'admin/credit_card' suspend late_fee\n\n"; 
    546792        echo "\tCredit card admin controller with URLs /admin/credit_card/suspend.\n"; 
    547793        echo "\t\tController: app/controllers/admin/credit_card_controller.php\n"; 
     
    554800     */ 
    555801    function model_help() { 
    556         echo "Usage: ./generate.php model ModelName\n"; 
     802        echo "Usage: php generate.php model ModelName\n"; 
    557803        echo "Description:\n"; 
    558804        echo "\tThe model generator creates functions for a new model.\n"; 
    559         echo "\tThe generator takes a model name as its argument.  The model name may be\n"; 
    560         echo "\tgiven in CamelCase or under_score and should not be suffixed with 'Model'.\n"; 
    561         echo "\tThe generator creates a model class in app/models.\n"; 
     805        echo "\tThe generator takes a model name as its argument.  The model name\n"; 
     806        echo "\tmay be given in CamelCase or under_score and should not be suffixed\n"; 
     807        echo "\twith 'Model'. The generator creates a model class in app/models.\n"; 
    562808        echo "Example:\n"; 
    563         echo "\t./script/generate.php model Account\n"; 
     809        echo "\tphp script/generate.php model Account\n"; 
    564810        echo "\tThis will create an Account model:\n"; 
    565811        echo "\t\tModel:      app/models/account.php\n\n"; 
     
    570816     */ 
    571817    function scaffold_help() { 
    572         echo "Usage: ./generate.php scaffold ModelName [ControllerName] [view1 view2 ...]\n\n"; 
     818        echo "Usage: php script/generate.php scaffold ModelName [ControllerName] [view1 view2 ...]\n\n"; 
    573819        echo "Description:\n"; 
    574820        echo "\tThe scaffold generator creates a controller to interact with a model.\n"; 
    575         echo "\tIf the model does not exist, it creates the model as well.  The generated\n"; 
    576         echo "\tcode is equivalent to the ( public \$scaffold = \"model\"; ) declaration,\n"; 
    577         echo "\tmaking it easy to migrate when you wish to customize your controller and views.\n\n"; 
     821        echo "\tIf the model does not exist, it creates the model as well.  The\n"; 
     822        echo "\tgenerated code is equivalent to the ( public \$scaffold = \"model\"; )\n"; 
     823        echo "\tdeclaration, making it easy to migrate when you wish to customize\n"; 
     824        echo "\tyour controller and views.\n\n"; 
    578825        echo "\tThe generator takes a model name, an optional controller name, and a\n"; 
    579826        echo "\tlist of views as arguments.  Scaffolded actions and views are created\n"; 
     
    585832        echo "\tor under_score and should not be suffixed with 'Model' or 'Controller'.\n\n"; 
    586833        echo "Example:\n"; 
    587         echo "\t./generate scaffold Account Bank debit credit\n\n"; 
    588         echo "\tThis will generate an Account model and BankController with a basic user interface\n"; 
    589         echo "\tNow create the accounts table in your database and browse to http://localhost/bank/\n"; 
    590         echo "\tvoila, you're on Trax!\n\n"; 
     834        echo "\tphp script/generate.php scaffold Account Bank debit credit\n\n"; 
     835        echo "\tThis will generate an Account model and BankController with a basic\n"; 
     836        echo "\tuser interface.  Now create the accounts table in your database and\n"; 
     837        echo "\t browse to http://localhost/bank/.  Voila, you're on Trax!\n\n"; 
    591838        echo "Module/Folders Example:\n"; 
    592         echo "\t./generate scaffold CreditCard 'admin/credit_card' suspend late_fee\n\n"; 
    593         echo "\tThis will generate a CreditCard model and CreditCardController controller\n"; 
    594         echo "\tin the admin module.\n";             
     839        echo "\tphp script/generate.php scaffold CreditCard 'admin/credit_card' suspend late_fee\n\n"; 
     840        echo "\tThis will generate a CreditCard model and CreditCardController\n"; 
     841        echo "\tcontroller in the admin module.\n";             
    595842    } 
    596843 
     
    601848        echo "Usage:\n"; 
    602849        echo "Generate Controller:\n"; 
    603         echo "./generate.php controller controller_name [view1 view2 ..]\n"; 
    604         echo "for more controller info ./generate.php controller\n\n"; 
     850        echo "php script/generate.php controller controller_name [view1 view2 ..]\n"; 
     851        echo "for more controller info php script/generate.php controller\n\n"; 
    605852        echo "Generate Model:\n"; 
    606         echo "./generate.php model model_name\n"; 
    607         echo "for more model info ./generate.php model\n\n"; 
     853        echo "php script/generate.php model ModelName\n"; 
     854        echo "for more model info php script/generate.php model\n\n"; 
    608855        echo "Generate Scaffold:\n"; 
    609         echo "./generate.php scaffold ModelName [ControllerName] [view1 view2 ...]\n"; 
    610         echo "for more scaffold info ./generate.php scaffold\n\n";         
     856        echo "php script/generate.php scaffold ModelName [controller_name] [view1 view2 ...]\n"; 
     857        echo "for more scaffold info php script/generate.php scaffold\n\n";         
    611858    } 
    612859} 
    613860 
    614  
     861// -- set Emacs parameters -- 
     862// Local variables: 
     863// tab-width: 4 
     864// c-basic-offset: 4 
     865// c-hanging-comment-ender-p: nil 
     866// indent-tabs-mode: nil 
     867// End: 
    615868?>