$template = file_get_contents('controller.tpl', true); $template = str_replace('{$class_name}', $class_name, $template); // Create the controller $file = fopen(BASE_PATH . '/../app/controllers/' . $name . '_controller.php', 'w'); fwrite($file, $template); fclose($file); // Create the folder mkdir(BASE_PATH . '/../app/views/' . strtolower($name)); echo "\nCreated the controller " . $class_name . " in\n"; echo realpath(dirname(BASE_PATH . '/../app/controllers/')) . '/controllers/' . $name . '_controller.php' . "\n\n"; } } // Generate a model public static function model($name) { if (file_exists(BASE_PATH . '/../app/models/' . $name . '.php')) { echo "\nThe model " . $name . " already exists in\n" . realpath(dirname(BASE_PATH . '/../app/models/')) . '/models/' . $name . '.php' . "\n\n"; } else { $class_name = ucfirst($name); $template = file_get_contents('model.tpl', true); $template = str_replace('{$class_name}', $class_name, $template); $file = fopen(BASE_PATH . '/../app/models/' . $name . '.php', 'w'); fwrite($file, $template); fclose($file); echo "\nCreated the model " . $class_name . " in\n"; echo realpath(dirname(BASE_PATH . '/../app/models/')) . '/models/' . $name . '.php' . "\n\n"; } } } Generator::init();
// $g_cwd = realpath(dirname($_SERVER['PHP_SELF'])); echo " CWD = " . $g_cwd . "\n"; // // Load, instantiate, and configure the smarty template engine. // echo " - Loading Smarty...\n"; $tpl = new Smarty(); $tpl->template_dir = $g_cwd . "/templates"; $tpl->compile_dir = $g_cwd . "/templates_c"; $tpl->clear_all_cache(); // By default we assume that the root of the Torque SDK // is located two folders up from the CWD. That is unless // another path is passed in the command line. $torqueRoot = "../.."; if ($argc >= 3) { $torqueRoot = str_replace("\\", "/", $argv[2]); } // Kick off the generator Generator::init($torqueRoot); // Ready to read our config file. echo " - Loading config file " . realpath($argv[1]) . "\n"; require $argv[1]; // Generate all projects Generator::generateProjects($tpl); // Now the solutions (if any) $tpl->clear_all_cache(); Generator::generateSolutions($tpl); // finally write out the sample.html for web deployment (if any) WebPlugin::writeSampleHtml(); exit;