Source for file generate.php

Documentation is available at generate.php

  1. <?php
  2.  
  3. // Check arguments
  4. $args $GLOBALS['argv'];
  5. if (count($args2{
  6.     echo "Generates a module file in the current directory\n\n";
  7.     echo "  Assumes the module talks to a table of the same name as the module\n";
  8.     echo "  e.g. Module 'Person' talks to table 'person'\n\n";
  9.     echo "  Usage: php script/generate.php module1 module2 ...\n";
  10.     exit;
  11. }
  12.  
  13. // Get the path to scaffold.php
  14. $scaffold_file str_replace("generate.php""scaffold.php"$args[0]);
  15.  
  16. // Get the scaffold code
  17. $scaffold file_get_contents($scaffold_file);
  18.  
  19. // Process each module specified
  20. for ($i 1$i count($args)$i++{
  21.     // Set module name
  22.     $modulename strtolower($args[$i]);
  23.     $uc_modulename ucwords($modulename);
  24.  
  25.     // Check if module file already exists
  26.     if (file_exists($uc_modulename.".php")) {
  27.         echo "Skipping module '$uc_modulenamesince it already exists\n";
  28.         continue;
  29.     }
  30.  
  31.     // Replace module name in scaffold code
  32.     $output str_replace("<<<modulename>>>"$modulename$scaffold);
  33.     $output str_replace("<<<uc_modulename>>>"$uc_modulename$output);
  34.     
  35.     // Save the output to file
  36.     file_put_contents($uc_modulename.".php"$output);
  37.     
  38.     // Message
  39.     echo "Generated module '$uc_modulename'\n";
  40. }
  41.  
  42. ?>

Documentation generated on Sat, 23 Jun 2007 21:28:19 -0500 by phpDocumentor 1.3.2